3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * We use QFC for both single page and multi page wizards. We want to make
14 * creation of single page forms as easy and as seamless as possible. This
15 * class is used to optimize and make single form pages a relatively trivial
19 * @copyright CiviCRM LLC https://civicrm.org/licensing
22 class CRM_Core_Controller_Simple
extends CRM_Core_Controller
{
28 * The class Path of the form being implemented
31 * @param bool $imageUpload
32 * @param bool $addSequence
33 * Should we add a unique sequence number to the end of the key.
34 * @param bool $ignoreKey
35 * Should we not set a qfKey for this controller (for standalone forms).
36 * @param bool $attachUpload
38 * @return \CRM_Core_Controller_Simple
40 public function __construct(
49 // by definition a single page is modal :). We use the form name as the scope for this controller
50 parent
::__construct($title, TRUE, $mode, $path, $addSequence, $ignoreKey);
52 $this->_stateMachine
= new CRM_Core_StateMachine($this);
54 $params = [$path => NULL];
56 $savedAction = CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, NULL);
57 if (!empty($savedAction) &&
63 $this->_stateMachine
->addSequentialPages($params, $mode);
65 $this->addPages($this->_stateMachine
, $mode);
67 //changes for custom data type File
68 $uploadNames = $this->get('uploadNames');
70 $config = CRM_Core_Config
::singleton();
72 if (is_array($uploadNames) && !empty($uploadNames)) {
73 $uploadArray = $uploadNames;
74 $this->addActions($config->customFileUploadDir
, $uploadArray);
75 $this->set('uploadNames', NULL);
78 // always allow a single upload file with same name
80 $this->addActions($config->uploadDir
,
81 CRM_Core_BAO_File
::uploadNames()
84 elseif ($imageUpload) {
85 $this->addActions($config->imageUploadDir
, ['uploadFile']);
98 public function setParent($parent) {
99 $this->_parent
= $parent;
103 * Get template file name.
107 public function getTemplateFileName() {
108 // there is only one form here, so should be quite easy
109 $actionName = $this->getActionName();
110 list($pageName, $action) = $actionName;
112 return $this->_pages
[$pageName]->getTemplateFileName();
116 * A wrapper for getTemplateFileName.
118 * This includes calling the hook to prevent us from having to copy & paste
119 * the logic of calling the hook
121 public function getHookedTemplateFileName() {
122 $pageTemplateFile = $this->getTemplateFileName();
123 CRM_Utils_Hook
::alterTemplateFile(get_class($this), $this, 'page', $pageTemplateFile);
124 return $pageTemplateFile;