+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
protected $_name;
/**
- * The title associated with this page
+ * The title associated with this page.
*
* @var object
*/
* Cache the smarty template for efficiency reasons
*
* @var CRM_Core_Smarty
- * @static
*/
static protected $_template;
* Cache the session for efficiency reasons
*
* @var CRM_Core_Session
- * @static
*/
static protected $_session;
public $useLivePageJS;
/**
- * Class constructor
+ * Class constructor.
*
* @param string $title
* Title of the page.
* @return CRM_Core_Page
*/
public function __construct($title = NULL, $mode = NULL) {
- $this->_name = CRM_Utils_System::getClassName($this);
+ $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)) {
/**
* 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
+ * @return void|string
* The content generated by running this page
*/
public function run() {
if ($this->_embedded) {
- return;
+ return NULL;
}
self::$_template->assign('mode', $this->_mode);
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 {
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);
}
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
*
*
* @return void
- *
*/
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.
*
+ * @param string $name name of the variable
*
* @return mixed
- *
*/
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
}
/**
- * Assign value to name in template by reference
+ * Assign value to name in template by reference.
*
* @param string $var
* @param mixed $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 bool $merge
*/
- public 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
*/
- public function get_template_vars($name=null) {
+ public function get_template_vars($name = NULL) {
return self::$_template->get_template_vars($name);
}
}
/**
- * Use the form name to create the tpl file name
+ * Use the form name to create the tpl file name.
*
* @return string
*/
public function getTemplateFileName() {
- return str_replace('_',
- DIRECTORY_SEPARATOR,
- CRM_Utils_System::getClassName($this)
+ return strtr(
+ CRM_Utils_System::getClassName($this),
+ array(
+ '_' => DIRECTORY_SEPARATOR,
+ '\\' => DIRECTORY_SEPARATOR,
+ )
) . '.tpl';
}
}
/**
- * Setter for embedded
+ * Setter for embedded.
*
* @param bool $embedded
*
}
/**
- * Getter for embedded
+ * Getter for embedded.
*
- * @return boolean return the embedded value
+ * @return bool
+ * return the embedded value
*/
public function getEmbedded() {
return $this->_embedded;
}
/**
- * Setter for print
+ * Setter for print.
*
* @param bool $print
*
}
/**
- * Getter for print
+ * Getter for print.
*
- * @return boolean return the print value
+ * @return bool
+ * return the print value
*/
public function getPrint() {
return $this->_print;
public function setVar($name, $value) {
$this->$name = $value;
}
+
}