aliroUserRequest.php

Go to the documentation of this file.
00001 <?php
00002 
00003 class aliroUserRequest extends aliroAbstractRequest {
00004     protected $prefix = 'user';
00005     protected $core_item = '';
00006     protected $path_side = 'front';
00007     protected $siteBaseURL = '';
00008 
00009     protected function __construct () {
00010         parent::__construct();
00011         $this->pathway = aliroPathway::getInstance();
00012         $this->siteBaseURL = $this->getCfg('live_site');
00013     }
00014     public static function getInstance () {
00015         if (self::$instance == null) self::$instance = new aliroUserRequest();
00016         return self::$instance;
00017     }
00018 
00019     // Called only by the user side index.php
00020     public function doControl () {
00021         if ($this->option == 'login' OR $this->option == 'logout') {
00022             if ($this->formcheck) $this->redirect($_SERVER['REQUEST_URI'], $this->getFormCheckError(), _ALIRO_ERROR_WARN);
00023             $authenticator = aliroUserAuthenticator::getInstance();
00024             if ($this->option == 'logout') $authenticator->logout();
00025             else $authenticator->userLogin();
00026         }
00027         if (strlen($_SERVER['REQUEST_URI']) < 2) $this->isHome = true;
00028         aliroSessionFactory::getSession()->rememberMe($this);
00029         $this->configuration->setRedirectHere();
00030         $indextype = $this->getParam($_REQUEST, 'indextype', 1);
00031         if ($indextype == 2) $this->urlerror = 0;
00032         else {
00033             $sef = aliroSEF::getInstance();
00034             $this->urlerror = $sef->sefRetrieval();
00035             $indextype = 1;
00036             $this->option = $this->component_name = strtolower($this->getParam($_REQUEST, 'option'));
00037         }
00038         $this->bestmatch = $this->mhandler->matchURL();
00039         if ($this->configuration->getCfg('offline') AND (!aliroSession::isAdminPresent())) {
00040             @session_write_close();
00041             new aliroOffline();
00042             exit();
00043         }
00044         if ($indextype == 2 AND $this->getParam( $_REQUEST, 'do_pdf', 0 ) == 1 ) {
00045             include_once('includes/pdf.php');
00046             exit();
00047         }
00049         // Should there be a condition on this?
00050         // $editor = aliroEditor::getInstance();
00051         // $this->initeditor = $editor->initEditor();
00052         $diagnostics = ob_get_clean();
00053         $this->invokeComponent($this->bestmatch);
00054         $this->userHeaders();
00055         ob_start();
00056         $mambothandler = aliroMambotHandler::getInstance();
00057         // This is an opportunity for a mambot that writes additional headers
00058         $mambothandler->trigger('onHeaders', array($this));
00059         // Shouldn't be any real output, but flush any diagnostics now headers are written
00060         $diagnostics .= ob_get_clean();
00061         if ($this->do_gzip) ob_start('ob_gzhandler');
00062         echo trim($diagnostics);
00063         $template = $this->getTemplateObject();
00064         if ($indextype == 1) {
00065             $this->runTemplate($template);
00066             $mambothandler->trigger('afterTemplate', array($this->configuration));
00067         }
00068         elseif ($indextype == 2) $this->runNonTemplate($template);
00069         if ($this->do_gzip) ob_end_flush();
00070     }
00071     
00072     public function isHome () {
00073         return $this->isHome;
00074     }
00075 
00076     protected function userHeaders () {
00077         header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
00078         header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
00079         header( 'Content-type: text/html; '._ISO);
00080         header( 'Cache-Control: no-store, no-cache, must-revalidate' );
00081         header( 'Cache-Control: post-check=0, pre-check=0', false );
00082         header( 'Pragma: no-cache' );
00083         if ('HEAD' == $_SERVER['REQUEST_METHOD']) exit;
00084     }
00085 
00086     protected function runTemplate ($template) {
00087         // loads template file
00088         aliroScreenArea::prepareTemplate($template);
00089         @session_write_close();
00090         $template->render();
00091         echo "<!-- ".time()." -->";
00092     }
00093 
00094     protected function runNonTemplate ($template) {
00095         @session_write_close();
00096         if ($this->getParam($_REQUEST, 'no_html')) echo $this->chandler->mosMainBody();
00097         else $template->component_render();
00098     }
00099 
00100     public function getTemplateObject () {
00101         if ($this->templateObject == null) {
00102             $templateclass = aliroTemplateHandler::getInstance()->getDefaultTemplateClass();
00103             $this->templateObject = new $templateclass();
00104         }
00105         return $this->templateObject;
00106     }
00107 
00108     protected function getComponentClass ($component) {
00109         return $component->class;
00110     }
00111 
00112     public function notAuthorised () {
00113         new aliroPage404();
00114     }
00115 
00116 }

Generated on Wed May 14 13:01:56 2008 for ALIRO by  doxygen 1.5.5