CRM-15988 - Cleanup internal use of entity names
[civicrm-core.git] / CRM / Core / Page.php
index f2de786a2cb0da4635b5a73c29dff24382ccd7c4..60bcc3e07c038020c1df9d0f525f330de314695a 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -47,15 +47,13 @@ class CRM_Core_Page {
    * The name of the page (auto generated from class name)
    *
    * @var string
-   * @access protected
    */
   protected $_name;
 
   /**
-   * The title associated with this page
+   * The title associated with this page.
    *
    * @var object
-   * @access protected
    */
   protected $_title;
 
@@ -63,7 +61,6 @@ class CRM_Core_Page {
    * A page can have multiple modes. (i.e. displays
    * a different set of data based on the input
    * @var int
-   * @access protected
    */
   protected $_mode;
 
@@ -73,7 +70,6 @@ class CRM_Core_Page {
    * parent object takes care of the display)
    *
    * @var boolean
-   * @access protected
    */
   protected $_embedded = FALSE;
 
@@ -82,7 +78,6 @@ class CRM_Core_Page {
    * functionality to do a minimal display :)
    *
    * @var boolean
-   * @access protected
    */
   protected $_print = FALSE;
 
@@ -90,8 +85,6 @@ class CRM_Core_Page {
    * Cache the smarty template for efficiency reasons
    *
    * @var CRM_Core_Smarty
-   * @access protected
-   * @static
    */
   static protected $_template;
 
@@ -99,8 +92,6 @@ class CRM_Core_Page {
    * Cache the session for efficiency reasons
    *
    * @var CRM_Core_Session
-   * @access protected
-   * @static
    */
   static protected $_session;
 
@@ -125,17 +116,19 @@ class CRM_Core_Page {
   public $useLivePageJS;
 
   /**
-   * Class constructor
+   * Class constructor.
    *
-   * @param string $title title of the page
-   * @param int    $mode  mode of the page
+   * @param string $title
+   *   Title of the page.
+   * @param int $mode
+   *   Mode of the page.
    *
    * @return CRM_Core_Page
    */
-  function __construct($title = NULL, $mode = NULL) {
-    $this->_name  = CRM_Utils_System::getClassName($this);
+  public function __construct($title = NULL, $mode = NULL) {
+    $this->_name = CRM_Utils_System::getClassName($this);
     $this->_title = $title;
-    $this->_mode  = $mode;
+    $this->_mode = $mode;
 
     // let the constructor initialize this, should happen only once
     if (!isset(self::$_template)) {
@@ -169,14 +162,15 @@ class CRM_Core_Page {
 
   /**
    * This function takes care of all the things common to all
-   * pages. This typically involves assigning the appropriate
-   * smarty variable :)
+   * pages. This typically involves assigning the appropriate smarty
+   * variable :)
    *
-   * @return string The content generated by running this page
+   * @return void|string
+   *   The content generated by running this page
    */
-  function run() {
+  public function run() {
     if ($this->_embedded) {
-      return;
+      return NULL;
     }
 
     self::$_template->assign('mode', $this->_mode);
@@ -188,8 +182,12 @@ class CRM_Core_Page {
     CRM_Utils_Hook::pageRun($this);
 
     if ($this->_print) {
-      if (in_array( $this->_print, array( CRM_Core_Smarty::PRINT_SNIPPET,
-        CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON ))) {
+      if (in_array($this->_print, array(
+        CRM_Core_Smarty::PRINT_SNIPPET,
+        CRM_Core_Smarty::PRINT_PDF,
+        CRM_Core_Smarty::PRINT_NOFORM,
+        CRM_Core_Smarty::PRINT_JSON,
+      ))) {
         $content = self::$_template->fetch('CRM/common/snippet.tpl');
       }
       else {
@@ -226,8 +224,8 @@ class CRM_Core_Page {
     CRM_Utils_Check::singleton()->showPeriodicAlerts();
 
     if ($this->useLivePageJS &&
-      CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajaxPopupsEnabled', NULL, TRUE))
-    {
+      CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajaxPopupsEnabled', NULL, TRUE)
+    {
       CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header');
       $this->assign('includeWysiwygEditor', TRUE);
     }
@@ -244,107 +242,104 @@ class CRM_Core_Page {
     CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
 
     echo CRM_Utils_System::theme($content, $this->_print);
-    return;
   }
 
   /**
-   * 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->_name);
   }
 
   /**
-   * Get the variable from the form scope
-   *
-   * @param  string name  : name  of the variable
+   * Get the variable from the form scope.
    *
-   * @access public
+   * @param string $name name of the variable
    *
    * @return mixed
-   *
    */
-  function get($name) {
+  public function get($name) {
     return self::$_session->get($name, $this->_name);
   }
 
   /**
-   * 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);
   }
 
   /**
    * Destroy all the session state of this page.
    *
-   * @access public
    *
    * @return void
    */
-  function reset() {
+  public function reset() {
     self::$_session->resetScope($this->_name);
   }
 
   /**
-   * Use the form name to create the tpl file name
+   * Use the form name to create the tpl file name.
    *
    * @return string
-   * @access public
    */
-  function getTemplateFileName() {
-    return str_replace('_',
-      DIRECTORY_SEPARATOR,
-      CRM_Utils_System::getClassName($this)
+  public function getTemplateFileName() {
+    return strtr(
+      CRM_Utils_System::getClassName($this),
+      array(
+        '_' => DIRECTORY_SEPARATOR,
+        '\\' => DIRECTORY_SEPARATOR,
+      )
     ) . '.tpl';
   }
 
@@ -352,7 +347,7 @@ class CRM_Core_Page {
    * A wrapper for getTemplateFileName that includes calling the hook to
    * prevent us from having to copy & paste the logic of calling the hook
    */
-  function getHookedTemplateFileName() {
+  public function getHookedTemplateFileName() {
     $pageTemplateFile = $this->getTemplateFileName();
     CRM_Utils_Hook::alterTemplateFile(get_class($this), $this, 'page', $pageTemplateFile);
     return $pageTemplateFile;
@@ -363,60 +358,57 @@ class CRM_Core_Page {
    * i.e. we dont override
    *
    * @return string
-   * @access public
    */
-  function overrideExtraTemplateFileName() {
+  public function overrideExtraTemplateFileName() {
     return NULL;
   }
 
   /**
-   * 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 print
+   * Setter for print.
    *
-   * @param boolean $print
+   * @param bool $print
    *
    * @return void
-   * @access public
    */
-  function setPrint($print) {
+  public function setPrint($print) {
     $this->_print = $print;
   }
 
   /**
-   * 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 CRM_Core_Smarty
    */
-  static function &getTemplate() {
+  public static function &getTemplate() {
     return self::$_template;
   }
 
@@ -425,7 +417,7 @@ class CRM_Core_Page {
    *
    * @return null
    */
-  function getVar($name) {
+  public function getVar($name) {
     return isset($this->$name) ? $this->$name : NULL;
   }
 
@@ -433,8 +425,8 @@ class CRM_Core_Page {
    * @param string $name
    * @param $value
    */
-  function setVar($name, $value) {
+  public function setVar($name, $value) {
     $this->$name = $value;
   }
-}
 
+}