/** * Create a new instance of a page. * * The default constructor should be called by any pages extending this object. It creates the * {@link I2CE_Template} and {@link I2CE_User} objects and sets up the basic member variables. * @param array $args * @param array $request_remainder The remainder of the request path */ public function __construct($args, $request_remainder, $get = null, $post = null) { if (array_key_exists('root_url', $args) && $args['root_url']) { $this->root_url = $args['root_url']; unset($args['root_url']); } $this->setIsPost(array_key_exists('REQUEST_METHOD', $_SERVER) && $_SERVER['REQUEST_METHOD'] == "POST"); $this->user = new I2CE_User(); if (function_exists('apache_note')) { apache_note("iHRIS-username", $this->user->username == '0' ? '-' : $this->user->username); } elseif (array_key_exists('HTTP_HOST', $_SERVER) && !headers_sent()) { header('X-iHRIS-username', $this->user->username == '0' ? '-' : $this->user->username); } I2CE_Locales::setPreferredLocale($this->user->getPreferredLocale()); $this->args = $args; $this->request_remainder = $request_remainder; $i2ce_config = I2CE::getConfig()->I2CE; if (!array_key_exists('access', $args)) { if (array_key_exists('HTTP_HOST', $_SERVER)) { $args['access'] = array('any'); //default is anyone logged in. } else { $args['access'] = array('all'); } } $this->access = $args['access']; $this->setupGetPost($get, $post); $this->template = null; if (!$this->initializeTemplate()) { I2CE::raiseError("Could not setup templates"); } $this->redirect = ""; $this->permissionParser = new I2CE_PermissionParser($this->template); I2CE_ModuleFactory::callHooks('page_constructor', array('page' => $this, 'args' => $args, 'request_remainder' => $request_remainder)); }