X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FController.php;h=34ca7eca91844af2790dc0bb24f45c75e1fe4408;hb=4846df9154866b0a33ee8ec7a1f48c65c77b670b;hp=10c952551dbaf20b75ab81647e89157a2ef12ec2;hpb=1761553f7e28866ef0c0a9f54abbb222487cea5c;p=civicrm-core.git diff --git a/CRM/Core/Controller.php b/CRM/Core/Controller.php index 10c952551d..34ca7eca91 100644 --- a/CRM/Core/Controller.php +++ b/CRM/Core/Controller.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * This class acts as our base controller class and adds additional @@ -52,28 +52,28 @@ require_once 'HTML/QuickForm/Action/Direct.php'; class CRM_Core_Controller extends HTML_QuickForm_Controller { /** - * The title associated with this controller + * The title associated with this controller. * * @var string */ protected $_title; /** - * The key associated with this controller + * The key associated with this controller. * * @var string */ public $_key; /** - * The name of the session scope where values are stored + * The name of the session scope where values are stored. * * @var object */ protected $_scope; /** - * The state machine associated with this controller + * The state machine associated with this controller. * * @var object */ @@ -116,33 +116,35 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { public $_generateQFKey = TRUE; /** - * QF response type + * QF response type. + * + * @var string */ public $_QFResponseType = 'html'; /** - * Cache the smarty template for efficiency reasons + * Cache the smarty template for efficiency reasons. * * @var CRM_Core_Smarty */ static protected $_template; /** - * Cache the session for efficiency reasons + * Cache the session for efficiency reasons. * * @var CRM_Core_Session */ static protected $_session; /** - * The parent of this form if embedded + * The parent of this form if embedded. * * @var object */ protected $_parent = NULL; /** - * The destination if set will override the destination the code wants to send it to + * The destination if set will override the destination the code wants to send it to. * * @var string; */ @@ -159,18 +161,19 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { /** * All CRM single or multi page pages should inherit from this class. * - * @param string $title descriptive title of the controller - * @param bool $modal whether controller is modal - * @param null $mode - * @param string $scope name of session if we want unique scope, used only by Controller_Simple - * @param bool $addSequence should we add a unique sequence number to the end of the key - * @param bool $ignoreKey should we not set a qfKey for this controller (for standalone forms) - * - * @access public - * - * @return CRM_Core_Controller + * @param string $title + * Descriptive title of the controller. + * @param bool $modal + * Whether controller is modal. + * @param mixed $mode + * @param string $scope + * Name of session if we want unique scope, used only by Controller_Simple. + * @param bool $addSequence + * Should we add a unique sequence number to the end of the key. + * @param bool $ignoreKey + * Should we not set a qfKey for this controller (for standalone forms). */ - function __construct( + public function __construct( $title = NULL, $modal = TRUE, $mode = NULL, @@ -190,8 +193,8 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { // lets try to get it from the session and/or the request vars // we do this early on in case there is a fatal error in retrieving the // key and/or session - $this->_entryURL = - CRM_Utils_Request::retrieve('entryURL', 'String', $this); + $this->_entryURL + = CRM_Utils_Request::retrieve('entryURL', 'String', $this); // add a unique validable key to the name $name = CRM_Utils_System::getClassName($this); @@ -200,7 +203,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { // definitely different for different forms $name = $scope; } - $name = $name . '_' . $this->key($name, $addSequence, $ignoreKey); + $name = $name . '_' . $this->key($name, $addSequence, $ignoreKey); $this->_title = $title; if ($scope) { $this->_scope = $scope; @@ -215,8 +218,8 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { if (!empty($this->_key)) { CRM_Core_Session::registerAndRetrieveSessionObjects(array( "_{$name}_container", - array('CiviCRM', $this->_scope), - )); + array('CiviCRM', $this->_scope), + )); } $this->HTML_QuickForm_Controller($name, $modal); @@ -247,7 +250,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { } } - // if the request has a reset value, initialize the controller session + // if the request has a reset value, initialize the controller session if (!empty($_GET['reset'])) { $this->reset(); @@ -262,7 +265,6 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { // and created the scope etc $this->set('qfKey', $this->_key); - // also retrieve and store destination in session $this->_destination = CRM_Utils_Request::retrieve( 'civicrmDestination', @@ -274,9 +276,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { ); } - function fini() { + public function fini() { CRM_Core_BAO_Cache::storeSessionToCache(array( - "_{$this->_name}_container", + "_{$this->_name}_container", array('CiviCRM', $this->_scope), ), TRUE @@ -290,7 +292,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * * @return mixed|string */ - function key($name, $addSequence = FALSE, $ignoreKey = FALSE) { + public function key($name, $addSequence = FALSE, $ignoreKey = FALSE) { $config = CRM_Core_Config::singleton(); if ( @@ -328,8 +330,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * This run is basically a composition of the original run and the * jump action * + * @return mixed */ - function run() { + public function run() { // the names of the action and page should be saved // note that this is split into two, because some versions of // php 5.x core dump on the triple assignment :) @@ -353,7 +356,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { /** * @return bool */ - function validate() { + public function validate() { $this->_actionName = $this->getActionName(); list($pageName, $action) = $this->_actionName; @@ -376,15 +379,13 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * Helper function to add all the needed default actions. Note that the framework * redefines all of the default QFC actions * - * @param string directory to store all the uploaded files - * @param array names for the various upload buttons (note u can have more than 1 upload) + * @param string $uploadDirectory to store all the uploaded files + * @param array $uploadNames for the various upload buttons (note u can have more than 1 upload) * - * @access private * * @return void - * */ - function addActions($uploadDirectory = NULL, $uploadNames = NULL) { + public function addActions($uploadDirectory = NULL, $uploadNames = NULL) { $names = array( 'display' => 'CRM_Core_QuickForm_Action_Display', 'next' => 'CRM_Core_QuickForm_Action_Next', @@ -407,24 +408,22 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { } /** - * Getter method for stateMachine + * Getter method for stateMachine. * * @return CRM_Core_StateMachine - * @access public */ - function getStateMachine() { + public function getStateMachine() { return $this->_stateMachine; } /** - * Setter method for stateMachine + * Setter method for stateMachine. * * @param CRM_Core_StateMachine $stateMachine * * @return void - * @access public */ - function setStateMachine($stateMachine) { + public function setStateMachine($stateMachine) { $this->_stateMachine = $stateMachine; } @@ -437,14 +436,13 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * typicaly this will be add/view/edit * * @return void - * @access public */ - function addPages(&$stateMachine, $action = CRM_Core_Action::NONE) { + public function addPages(&$stateMachine, $action = CRM_Core_Action::NONE) { $pages = $stateMachine->getPages(); foreach ($pages as $name => $value) { $className = CRM_Utils_Array::value('className', $value, $name); - $title = CRM_Utils_Array::value('title', $value); - $options = CRM_Utils_Array::value('options', $value); + $title = CRM_Utils_Array::value('title', $value); + $options = CRM_Utils_Array::value('options', $value); $stateName = CRM_Utils_String::getClassName($className); if (!empty($value['className'])) { $formName = $name; @@ -455,10 +453,10 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { $ext = CRM_Extension_System::singleton()->getMapper(); if ($ext->isExtensionClass($className)) { - require_once ($ext->classToPath($className)); + require_once $ext->classToPath($className); } else { - require_once (str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; } $$stateName = new $className($stateMachine->find($className), $action, 'post', $formName); if ($title) { @@ -485,10 +483,10 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * we have two submit buttons, we could have one displayed as a button and * the other as an image, both are of type 'submit'. * - * @return string the name of the button that has been pressed by the user - * @access public + * @return string + * the name of the button that has been pressed by the user */ - function getButtonName() { + public function getButtonName() { $data = &$this->container(); return CRM_Utils_Array::value('_qf_button_name', $data); } @@ -496,11 +494,10 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { /** * Destroy all the session state of the controller. * - * @access public * * @return void */ - function reset() { + public function reset() { $this->container(TRUE); self::$_session->resetScope($this->_scope); } @@ -513,53 +510,50 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * and can change based on the arguments * * @return void - * @access public */ - function process() {} + public function process() { + } /** - * Store the variable with the value in the form scope + * Store the variable with the value in the form scope. * - * @param string|array $name name of the variable or an assoc array of name/value pairs - * @param mixed $value value of the variable if string + * @param string|array $name name of the variable or an assoc array of name/value pairs + * @param mixed $value + * Value of the variable if string. * - * @access public * * @return void - * */ - function set($name, $value = NULL) { + public function set($name, $value = NULL) { self::$_session->set($name, $value, $this->_scope); } /** - * Get the variable from the form scope + * Get the variable from the form scope. * - * @param string $name : name of the variable + * @param string $name + * name of the variable. * - * @access public - * * @return mixed - * */ - function get($name) { + public function get($name) { return self::$_session->get($name, $this->_scope); } /** - * Create the header for the wizard from the list of pages + * Create the header for the wizard from the list of pages. * Store the created header in smarty * - * @param string $currentPageName name of the page being displayed + * @param string $currentPageName + * Name of the page being displayed. * * @return array - * @access public */ - function wizardHeader($currentPageName) { - $wizard = array(); + public function wizardHeader($currentPageName) { + $wizard = array(); $wizard['steps'] = array(); - $count = 0; + $count = 0; foreach ($this->_pages as $name => $page) { $count++; $wizard['steps'][] = array( @@ -591,11 +585,11 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { /** * @param array $wizard */ - function addWizardStyle(&$wizard) { + public function addWizardStyle(&$wizard) { $wizard['style'] = array( 'barClass' => '', 'stepPrefixCurrent' => '»', - 'stepPrefixPast' => '√', + 'stepPrefixPast' => '✔', 'stepPrefixFuture' => ' ', 'subStepPrefixCurrent' => '  ', 'subStepPrefixPast' => '  ', @@ -605,101 +599,100 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { } /** - * Assign value to name in template + * Assign value to name in template. * * @param string $var - * @param mixed $value value of varaible + * @param mixed $value + * Value of varaible. * * @return void - * @access public */ - function assign($var, $value = NULL) { + public function assign($var, $value = NULL) { self::$_template->assign($var, $value); } /** - * Assign value to name in template by reference + * Assign value to name in template by reference. * * @param string $var - * @param mixed $value (reference) value of varaible + * @param mixed $value + * (reference) value of varaible. * * @return void - * @access public */ - function assign_by_ref($var, &$value) { + public function assign_by_ref($var, &$value) { self::$_template->assign_by_ref($var, $value); } /** - * Appends values to template variables + * Appends values to template variables. * * @param array|string $tpl_var the template variable name(s) - * @param mixed $value the value to append + * @param mixed $value + * The value to append. * @param bool $merge */ - function append($tpl_var, $value=NULL, $merge=FALSE) { + public function append($tpl_var, $value = NULL, $merge = FALSE) { self::$_template->append($tpl_var, $value, $merge); } /** - * Returns an array containing template variables + * Returns an array containing template variables. * * @param string $name * * @return array */ - function get_template_vars($name=null) { + public function get_template_vars($name = NULL) { return self::$_template->get_template_vars($name); } /** - * Setter for embedded + * Setter for embedded. * - * @param boolean $embedded + * @param bool $embedded * * @return void - * @access public */ - function setEmbedded($embedded) { + public function setEmbedded($embedded) { $this->_embedded = $embedded; } /** - * Getter for embedded + * Getter for embedded. * - * @return boolean return the embedded value - * @access public + * @return bool + * return the embedded value */ - function getEmbedded() { + public function getEmbedded() { return $this->_embedded; } /** - * Setter for skipRedirection + * Setter for skipRedirection. * - * @param boolean $skipRedirection + * @param bool $skipRedirection * * @return void - * @access public */ - function setSkipRedirection($skipRedirection) { + public function setSkipRedirection($skipRedirection) { $this->_skipRedirection = $skipRedirection; } /** - * Getter for skipRedirection + * Getter for skipRedirection. * - * @return boolean return the skipRedirection value - * @access public + * @return bool + * return the skipRedirection value */ - function getSkipRedirection() { + public function getSkipRedirection() { return $this->_skipRedirection; } /** * @param null $fileName */ - function setWord($fileName = NULL) { + public function setWord($fileName = NULL) { //Mark as a CSV file. header('Content-Type: application/vnd.ms-word'); @@ -713,7 +706,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { /** * @param null $fileName */ - function setExcel($fileName = NULL) { + public function setExcel($fileName = NULL) { //Mark as an excel file. header('Content-Type: application/vnd.ms-excel'); @@ -726,14 +719,13 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { } /** - * Setter for print + * Setter for print. * - * @param boolean $print + * @param bool $print * * @return void - * @access public */ - function setPrint($print) { + public function setPrint($print) { if ($print == "xls") { $this->setExcel(); } @@ -744,19 +736,19 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { } /** - * Getter for print + * Getter for print. * - * @return boolean return the print value - * @access public + * @return bool + * return the print value */ - function getPrint() { + public function getPrint() { return $this->_print; } /** * @return string */ - function getTemplateFile() { + public function getTemplateFile() { if ($this->_print) { if ($this->_print == CRM_Core_Smarty::PRINT_PAGE) { return 'CRM/common/print.tpl'; @@ -857,7 +849,6 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * and present the user a better message and/or redirect to the same page with a reset url * * @return void - * */ public function invalidKey() { self::invalidKeyCommon();