/** * __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($params = null, $fluid = false, $uid_or_auto = true) { static::$GLOBAL_STYLE = PSU_BASE_DIR . '/app/core/templates'; parent::__construct($uid_or_auto); if ($_SESSION['impersonate']) { \PSU::get('log/impersonate')->write('Impersonation' . (\PSU::isDev() ? ' on dev server' : '') . ': accessing ' . $_SERVER['REQUEST_URI'] . ($_SERVER['HTTP_REFERER'] ? ' via ' . $_SERVER['HTTP_REFERER'] : ''), $_SESSION['username'], serialize($_REQUEST)); } //end if if ($GLOBALS['TEMPLATES']) { $this->template_dir = $GLOBALS['TEMPLATES']; } if (!isset($GLOBALS['USE_APPLICATION_STYLE'])) { $GLOBALS['USE_APPLICATION_STYLE'] = true; } if ($params) { parse_str($params, $params); $key = key($params); if (!$params[$key]) { $params['page_title'] = str_replace('_', ' ', $key); } //end if } //end if $this->page_title = $params['page_title']; $this->app_title = $params['app_title'] ? $params['app_title'] : ($GLOBALS['TITLE'] ? $GLOBALS['TITLE'] : 'PSU Webapp'); $this->fluid = $params['fluid'] ? $params['fluid'] : $fluid; // register any custom functions $this->register_block('box', array($this, 'psu_box')); $this->register_block('col', array($this, 'psu_col')); $this->register_block('message', array($this, 'psu_message')); $this->register_modifier('yesno', array($this, 'yesno')); $this->register_modifier('pluralize', array($this, 'pluralize')); $this->register_modifier('query_string', 'http_build_query'); $this->register_function('myrel_access', array($this, 'myrel_access')); $this->register_function('myrel_list', array($this, 'myrel_list')); $this->register_function('randomid', array($this, 'randomid')); $this->register_function('nav', array($this, 'nav')); $this->register_function('navselect', array($this, 'navselect')); $this->register_modifier('bool2str', array($this, 'bool2str')); $this->content_classes = array(\PSU::isDev() ? 'webapp-dev' : 'webapp-prod'); $this->body_style_classes = array(); $this->body_style_classes[] = strtolower('month-' . date('F')); $this->body_style_classes[] = strtolower('weekday-' . date('l')); $this->body_style_classes[] = 'week-' . date('W'); $this->body_style_classes[] = 'day-of-year-' . date('z'); $this->body_style_classes[] = 'day-of-month-' . date('j'); $this->body_style_classes[] = 'hour-' . date('H'); $this->body_style_classes[] = 'minute-' . date('i'); if ($_SESSION['username']) { $this->body_style_classes[] = 'user-' . $_SESSION['username']; } //end if if ($_SESSION['wp_id']) { $this->body_style_classes[] = 'user-' . $_SESSION['wp_id']; } //end if if ($GLOBALS['FANCY_TPL']) { $this->body_style_classes[] = 'extra-tag-styles'; } $this->assign('facebook_api', \PSU::fbAPI()); $this->assign('facebook_enable', $GLOBALS['FACEBOOK_ENABLE'] == true); $go = new \go($_SESSION['wp_id'] ? $_SESSION['wp_id'] : $_SESSION['username']); $hot_links = $go->cacheGetSites($_SESSION['wp_id'] || $_SESSION['username'] ? 'popular-me' : 'popular-everyone'); if (sizeof($hot_links) < 5 && $_SESSION['username']) { $everyone_links = $go->cacheGetSites('popular-everyone'); $hot_links = array_merge($hot_links, $everyone_links); $hot_links = array_unique($hot_links); } //end if $this->assign('webapp_hot_links', $hot_links); // cdn base url; omit trailing slash $this->assign('cdn', substr(\PSU::cdn(), 0, -1)); if (\PSU::mobile() && $_COOKIE['psumobile'] != 'disable' || $_COOKIE['psumobile'] == 'force') { $this->mobile = true; } //end if }