00001 <?php 00002 00003 class aliroAdminRequest extends aliroAbstractRequest { 00004 protected $prefix = 'admin'; 00005 protected $core_item = ''; 00006 protected $path_side = 'admin'; 00007 protected $siteBaseURL = ''; 00008 00009 protected function __construct () { 00010 parent::__construct(); 00011 if ($this->core_item = strtolower($this->getParam($_REQUEST, 'core'))) $this->component_name = $this->core_item; 00012 $this->siteBaseURL = $this->getCfg('admin_site'); 00013 } 00014 00015 public static function getInstance () { 00016 if (self::$instance == null) self::$instance = new aliroAdminRequest(); 00017 return self::$instance; 00018 } 00019 00020 public function simpleURL () { 00021 return $this->siteBaseURL.'/index.php?'.($this->core_item ? 'core='.$this->core_item : 'option='.$this->option); 00022 } 00023 00024 // Called only by the admin side index.php 00025 public function doControl () { 00026 aliroExtensionHandler::getInstance()->checkStarterPack(); 00027 if ($this->option == 'login' OR $this->option == 'logout') { 00028 $authenticator = aliroAdminAuthenticator::getInstance(); 00029 if ($this->option == 'logout') $authenticator->logout(); 00030 else { 00031 $this->user = $authenticator->login(); 00032 $this->alironoscript = $this->getStickyAliroParam($_POST, 'alironoscript'); 00033 if (count($_POST)) $this->fixPostItems(); 00034 $this->option = $this->component_name = strtolower($this->getParam($_REQUEST, 'option')); 00035 $this->core_item = strtolower($this->getParam($_REQUEST, 'core')); 00036 } 00037 } 00038 // Handle special admin side options 00039 // If this is not login, we should already have a valid admin session 00040 if (is_object($this->user) AND $this->user->id) $this->adminActiveUser(); 00041 // If a valid user was not set, the only possibility is to ask for an admin side login 00042 else { 00043 // Flush any diagnostic output 00044 ob_end_flush(); 00045 $template = $this->getTemplateObject(); 00046 $template->login(); 00047 } 00048 } 00049 00050 protected function adminActiveUser () { 00051 if ($this->core_item OR $this->option) $this->invokeComponent (); 00052 else { 00053 $moduleid = $this->getParam($_REQUEST, 'moduleid', 0); 00054 $template = $this->getTemplateObject(); 00055 aliroScreenArea::prepareTemplate($template); 00056 } 00057 00058 $diagnostics = ob_get_clean(); 00059 if ($this->do_gzip) ob_start('ob_gzhandler'); 00060 echo $diagnostics; 00061 @session_write_close(); 00062 00063 // If no_html is set, we avoid starting the template, and go straight to the component 00064 if ($this->getParam($_REQUEST, 'no_html', '')) { 00065 echo $this->chandler->mosMainBody(); 00066 exit; 00067 } 00068 else { 00069 $template = $this->getTemplateObject(); 00070 // aliroTemplate::prepareTemplate($template); 00071 $template->render(); 00072 } 00073 if ($this->do_gzip) ob_end_flush(); 00074 } 00075 00076 public function getTemplateObject () { 00077 if ($this->templateObject == null) { 00078 $templateclass = aliroTemplateHandler::getInstance()->getDefaultTemplateClass(); 00079 $this->templateObject = new $templateclass(); 00080 } 00081 return $this->templateObject; 00082 } 00083 00084 protected function getComponentClass ($component) { 00085 return $component->adminclass; 00086 } 00087 00088 }
1.5.5