private function _startSession() { // Start the session TIP::startSession(); $this->_session_started = true; // Set $_referer $request = HTTP_Session2::get('request'); $referer = HTTP_Session2::get('referer'); if (is_null($request)) { // Entry page or new session: the referer is the main page $this->_referer = null; } elseif ($this->_request['uri'] == $referer['uri']) { // Current URI equals to the old referer URI: probably a back action $this->_referer = null; } elseif ($this->_request['module'] != $request['module'] || $this->_request['action'] != $request['action']) { // New action: the referer is the previous request $this->_referer = $request; } else { // Same action: leave the old referer $this->_referer = $referer; } if (!is_array($this->_referer)) { $this->_referer = array('uri' => TIP::getHome(), 'module' => null, 'action' => null); $this->_referer['action'] = null; } $this->keys['REFERER'] = $this->_referer['uri']; // Store request and referer HTTP_Session2::set('referer', $this->_referer); HTTP_Session2::set('request', $this->_request); // Profiler initialization in "admin" mode if ($this->keys['IS_ADMIN']) { require_once 'Benchmark/Profiler.php'; $GLOBALS['_tip_profiler'] = new Benchmark_Profiler(); $GLOBALS['_tip_profiler']->start(); } }
/** * Build an action (relative) URI * @param string $module The module name * @param string $action The action to perform * @param string $id The subject of the action * @param array $args Optional additional query arguments * @return string The constructed URI */ public static function buildActionUri($module, $action, $id = null, $args = null) { $uri = TIP::getHome(); if (empty($module) || empty($action)) { empty($args) || ($uri .= '?' . http_build_query($args, '', '&')); return $uri; } $namespace = TIP_Application::getGlobal('namespace'); if (is_null($namespace)) { $args['module'] = $module; $args['action'] = $action; is_null($id) || ($args['id'] = $id); $uri .= '?' . http_build_query($args, '', '&'); return $uri; } // Strip the namespace from the module name, if present if (strpos($module, $namespace . '_') === 0) { $module = substr($module, strlen($namespace) + 1); } $uri .= $module . '/' . $action; is_null($id) || ($uri .= '/' . $id); empty($args) || ($uri .= '?' . http_build_query($args, '', '&')); return $uri; }