CRM-15626 fixes - Relationship Create Widget Not always showing the correct available...
[civicrm-core.git] / CRM / Core / Controller.php
index 3aa9582bdb006d30bae41ce0448a53afd4cc11da..d9715e457fc1757e4ec311cab118f1e2960747b3 100644 (file)
 require_once 'HTML/QuickForm/Controller.php';
 require_once 'HTML/QuickForm/Action/Direct.php';
 
+/**
+ * Class CRM_Core_Controller
+ */
 class CRM_Core_Controller extends HTML_QuickForm_Controller {
 
   /**
-   * the title associated with this controller
+   * The title associated with this controller
    *
    * @var string
    */
@@ -63,14 +66,14 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   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
    */
@@ -118,14 +121,14 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   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
    */
@@ -156,16 +159,16 @@ 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 boolean whether      controller is modal
-   * @param string  scope        name of session if we want unique scope, used only by Controller_Simple
-   * @param boolean addSequence  should we add a unique sequence number to the end of the key
-   * @param boolean ignoreKey    should we not set a qfKey for this controller (for standalone forms)
+   * @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 void
-   *
+   * @return CRM_Core_Controller
    */
   function __construct(
     $title = NULL,
@@ -230,8 +233,8 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
         $this->_generateQFKey = FALSE;
       }
       elseif ($snippet == 5) {
-        // this is used for popups and inlined ajax forms
-        // also used for the various tabs via TabHeader
+        // mode deprecated in favor of json
+        // still used by dashlets, probably nothing else
         $this->_print = CRM_Core_Smarty::PRINT_NOFORM;
       }
       // Respond with JSON if in AJAX context (also support legacy value '6')
@@ -280,6 +283,13 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     );
   }
 
+  /**
+   * @param string $name
+   * @param bool $addSequence
+   * @param bool $ignoreKey
+   *
+   * @return mixed|string
+   */
   function key($name, $addSequence = FALSE, $ignoreKey = FALSE) {
     $config = CRM_Core_Config::singleton();
 
@@ -340,6 +350,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     return $this->_pages[$pageName]->handle($action);
   }
 
+  /**
+   * @return bool
+   */
   function validate() {
     $this->_actionName = $this->getActionName();
     list($pageName, $action) = $this->_actionName;
@@ -394,9 +407,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * getter method for stateMachine
+   * Getter method for stateMachine
    *
-   * @return object
+   * @return CRM_Core_StateMachine
    * @access public
    */
   function getStateMachine() {
@@ -404,9 +417,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * setter method for stateMachine
+   * Setter method for stateMachine
    *
-   * @param object a stateMachineObject
+   * @param CRM_Core_StateMachine $stateMachine
    *
    * @return void
    * @access public
@@ -416,16 +429,15 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * add pages to the controller. Note that the controller does not really care
+   * Add pages to the controller. Note that the controller does not really care
    * the order in which the pages are added
    *
-   * @param object $stateMachine  the state machine object
-   * @param int    $action        the mode in which the state machine is operating
+   * @param CRM_Core_StateMachine $stateMachine
+   * @param \const|int $action the mode in which the state machine is operating
    *                              typicaly this will be add/view/edit
    *
    * @return void
    * @access public
-   *
    */
   function addPages(&$stateMachine, $action = CRM_Core_Action::NONE) {
     $pages = $stateMachine->getPages();
@@ -482,7 +494,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * function to destroy all the session state of the controller.
+   * Destroy all the session state of the controller.
    *
    * @access public
    *
@@ -494,7 +506,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * virtual function to do any processing of data.
+   * Virtual function to do any processing of data.
    * Sometimes it is useful for the controller to actually process data.
    * This is typically used when we need the controller to figure out
    * what pages are potentially involved in this wizard. (this is dynamic
@@ -523,7 +535,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   /**
    * Get the variable from the form scope
    *
-   * @param  string name  : name  of the variable
+   * @param  string $name  : name  of the variable
    *
    * @access public
 
@@ -576,6 +588,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     return $wizard;
   }
 
+  /**
+   * @param array $wizard
+   */
   function addWizardStyle(&$wizard) {
     $wizard['style'] = array(
       'barClass' => '',
@@ -590,9 +605,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * assign value to name in template
+   * Assign value to name in template
    *
-   * @param array|string $name  name  of variable
+   * @param string $var
    * @param mixed $value value of varaible
    *
    * @return void
@@ -603,9 +618,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * assign value to name in template by reference
+   * Assign value to name in template by reference
    *
-   * @param array|string $name  name  of variable
+   * @param string $var
    * @param mixed $value (reference) value of varaible
    *
    * @return void
@@ -616,7 +631,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * 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
@@ -630,7 +645,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
    * Returns an array containing template variables
    *
    * @param string $name
-   * @param string $type
+   *
    * @return array
    */
   function get_template_vars($name=null) {
@@ -638,7 +653,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * setter for embedded
+   * Setter for embedded
    *
    * @param boolean $embedded
    *
@@ -650,7 +665,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * getter for embedded
+   * Getter for embedded
    *
    * @return boolean return the embedded value
    * @access public
@@ -660,7 +675,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * setter for skipRedirection
+   * Setter for skipRedirection
    *
    * @param boolean $skipRedirection
    *
@@ -672,7 +687,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * getter for skipRedirection
+   * Getter for skipRedirection
    *
    * @return boolean return the skipRedirection value
    * @access public
@@ -681,6 +696,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     return $this->_skipRedirection;
   }
 
+  /**
+   * @param null $fileName
+   */
   function setWord($fileName = NULL) {
     //Mark as a CSV file.
     header('Content-Type: application/vnd.ms-word');
@@ -692,6 +710,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     header("Content-Disposition: attachment; filename=Contacts_$fileName");
   }
 
+  /**
+   * @param null $fileName
+   */
   function setExcel($fileName = NULL) {
     //Mark as an excel file.
     header('Content-Type: application/vnd.ms-excel');
@@ -705,7 +726,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * setter for print
+   * Setter for print
    *
    * @param boolean $print
    *
@@ -723,7 +744,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * getter for print
+   * Getter for print
    *
    * @return boolean return the print value
    * @access public
@@ -732,6 +753,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     return $this->_print;
   }
 
+  /**
+   * @return string
+   */
   function getTemplateFile() {
     if ($this->_print) {
       if ($this->_print == CRM_Core_Smarty::PRINT_PAGE) {
@@ -750,6 +774,10 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     }
   }
 
+  /**
+   * @param $uploadDir
+   * @param $uploadNames
+   */
   public function addUploadAction($uploadDir, $uploadNames) {
     if (empty($uploadDir)) {
       $config = CRM_Core_Config::singleton();
@@ -775,18 +803,31 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     $this->addAction('upload', $action);
   }
 
+  /**
+   * @param $parent
+   */
   public function setParent($parent) {
     $this->_parent = $parent;
   }
 
+  /**
+   * @return object
+   */
   public function getParent() {
     return $this->_parent;
   }
 
+  /**
+   * @return string
+   */
   public function getDestination() {
     return $this->_destination;
   }
 
+  /**
+   * @param null $url
+   * @param bool $setToReferer
+   */
   public function setDestination($url = NULL, $setToReferer = FALSE) {
     if (empty($url)) {
       if ($setToReferer) {
@@ -802,6 +843,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     $this->set('civicrmDestination', $this->_destination);
   }
 
+  /**
+   * @return mixed
+   */
   public function cancelAction() {
     $actionName = $this->getActionName();
     list($pageName, $action) = $actionName;