/** * __construct * * Initial object setup. * * @param string|boolean $uid_or_auto indicates how cache and template directories should be set. uid specifies a unique id to build names, true generates paths automatically. leave blank or false to specify these paths yourself. */ function __construct($uid_or_auto = true) { self::$GLOBAL_TEMPLATES = PSU_LEGACY_DIR . '/templates'; self::$STYLE_TEMPLATES = PSU_BASE_DIR . '/app/core/templates'; parent::__construct(); static::$js_registry = array('jquery' => 'http' . ($_SERVER['HTTPS'] ? 's' : '') . '://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.js', 'jquery-ui' => 'http' . ($_SERVER['HTTPS'] ? 's' : '') . '://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js', 'ddm' => '/includes/js/jquery-plugins/jquery.multi-ddm.min.js', 'my-combined' => '/webapp/my/js/combined.js', 'my-behavior' => '/webapp/my/js/behavior.js', 'myjs' => '/webapp/portal/myjs/index.php', 'style-behavior' => '/webapp/style-bootstrap/js/behavior.js', 'bootstrap' => '/webapp/style-bootstrap/js/bootstrap.min.js'); $this->psu_server = ($_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://'; if (PSU::isdev()) { $this->psu_server .= self::psu_dev_server; } else { $this->psu_server .= self::psu_prod_server; } // does user want us to set up smarty dirs? if ($uid_or_auto) { // what's our temp directory? $tmp = null; if (isset($GLOBALS['TEMPORARY_FILES'])) { $tmp = $GLOBALS['TEMPORARY_FILES']; } else { foreach (self::$DEFAULT_TMP as $this_tmp) { if (is_dir($this_tmp) && is_writable($this_tmp)) { $tmp = $this_tmp; break; } } } if ($uid_or_auto === true) { // true means full automatic. use BASE_URL as the unique seed if (!isset($GLOBALS['BASE_URL'])) { // can't be full auto without a base url. throw new PSUSmartyException(PSUSmartyException::NO_BASE_URL); } $md5 = md5($GLOBALS['BASE_URL']); $this->compile_dir = $tmp . '/smarty_tc_' . $md5; } else { // uid was set, and it wasn't true, so use the string $this->compile_dir = $tmp . '/smarty_tc_' . $uid_or_auto; } } elseif (isset($GLOBALS['SMARTY_COMPILE'])) { // user did not want an auto dir, but specified a dir elsewhere $this->compile_dir = $GLOBALS['SMARTY_COMPILE']; } // create compile directory if it's not there yet if (!is_dir($this->compile_dir)) { $old_umask = umask(07); mkdir($this->compile_dir); umask($old_umask); } $this->plugins_dir[] = PSU_EXTERNAL_DIR . '/smarty/psu_plugins'; $this->head = array('js' => array(), 'google_lazy_js' => array(), 'css' => array()); // register any custom functions $this->register_function('PSU_JS', array($this, 'psu_js')); $this->register_function('psu_js', array($this, 'psu_js')); $this->register_function('PSU_GOOGLE_LAZY_JS', array($this, 'psu_google_lazy_js')); $this->register_function('PSU_CSS', array($this, 'psu_css')); $this->register_function('psu_dbug', array($this, 'psu_dbug')); $this->register_function('icon', array($this, 'icon')); $this->register_function('iconbox', array($this, 'iconbox')); $this->register_function('psu_puke', array($this, 'psu_puke')); $this->register_function('psu_progress', array($this, 'psu_progress')); $this->register_function('psu_authz_js', array($this, 'psu_authz_js')); $this->register_outputfilter(array($this, 'psu_head_includes')); $this->register_modifier('cdn', array($this, 'cdn')); $this->register_modifier('cssslug', array($this, 'cssslug')); $this->register_function('paging_querystring', array($this, 'paging_querystring')); $this->register_modifier('paging_order', array($this, 'paging_order')); $this->register_function('psu_messages', array($this, 'psu_messages')); $this->register_function('psu_errors', array($this, 'psu_errors')); $this->register_function('psu_successes', array($this, 'psu_successes')); $this->register_function('psu_warnings', array($this, 'psu_warnings')); $https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'; // add in the registry $this->assign('psureg', PSU::get()); }