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
21 class CRM_Core_Controller_Simple
extends CRM_Core_Controller
{
27 * The class Path of the form being implemented
30 * @param bool $imageUpload
31 * @param bool $addSequence
32 * Should we add a unique sequence number to the end of the key.
33 * @param bool $ignoreKey
34 * Should we not set a qfKey for this controller (for standalone forms).
35 * @param bool $attachUpload
37 * @return \CRM_Core_Controller_Simple
39 public function __construct(
48 // by definition a single page is modal :). We use the form name as the scope for this controller
49 parent
::__construct($title, TRUE, $mode, $path, $addSequence, $ignoreKey);
51 $this->_stateMachine
= new CRM_Core_StateMachine($this);
53 $params = [$path => NULL];
55 $savedAction = CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, NULL);
56 if (!empty($savedAction) &&
62 $this->_stateMachine
->addSequentialPages($params, $mode);
64 $this->addPages($this->_stateMachine
, $mode);
66 //changes for custom data type File
67 $uploadNames = $this->get('uploadNames');
69 $config = CRM_Core_Config
::singleton();
71 if (is_array($uploadNames) && !empty($uploadNames)) {
72 $uploadArray = $uploadNames;
73 $this->addActions($config->customFileUploadDir
, $uploadArray);
74 $this->set('uploadNames', NULL);
77 // always allow a single upload file with same name
79 $this->addActions($config->uploadDir
,
80 CRM_Core_BAO_File
::uploadNames()
83 elseif ($imageUpload) {
84 $this->addActions($config->imageUploadDir
, ['uploadFile']);
97 public function setParent($parent) {
98 $this->_parent
= $parent;
102 * Get template file name.
106 public function getTemplateFileName() {
107 // there is only one form here, so should be quite easy
108 $actionName = $this->getActionName();
109 list($pageName, $action) = $actionName;
111 return $this->_pages
[$pageName]->getTemplateFileName();
115 * A wrapper for getTemplateFileName.
117 * This includes calling the hook to prevent us from having to copy & paste
118 * the logic of calling the hook
120 public function getHookedTemplateFileName() {
121 $pageTemplateFile = $this->getTemplateFileName();
122 CRM_Utils_Hook
::alterTemplateFile(get_class($this), $this, 'page', $pageTemplateFile);
123 return $pageTemplateFile;