Example #1
0
 /**
  * Set a new template theme.
  * @param string $name 
  */
 public function setTemplate($name)
 {
     if ($name == $this->template) {
         return false;
     }
     if (!file_exists(Core\Context::getTemplateFilePath($name))) {
         throw new Core\Exception('Template not found in [' . Core\Context::getTemplateFilePath($name) . ']', E_USER_WARNING, $this->name);
     }
     $this->template = $name;
     if ($this->tpl != null) {
         $this->tpl->addTemplateDir(Core\Context::getTemplatePath($this->template));
     }
 }
Example #2
0
 /**
  * Get important context data as an array (useful for template hydratation)
  */
 public function getDataArray()
 {
     $array = array();
     try {
         $array['module'] = array();
         $array['module']['name'] = \Orion::module()->getName();
         $array['module']['path'] = \Orion\Core\Context::getModulePath();
         $array['module']['url'] = \Orion\Core\Context::getModuleURL(\Orion::module()->getName());
         $array['module']['uri'] = \Orion\Core\Context::getModuleURI();
         $array['module']['fulluri'] = \Orion\Core\Context::getFullURI();
         $array['template'] = array();
         $array['template']['name'] = \Orion::module()->getTemplate();
         $array['template']['path'] = \Orion\Core\Context::getTemplatePath(\Orion::module()->getTemplate());
         $array['template']['abspath'] = \Orion\Core\Context::getTemplateAbsolutePath(\Orion::module()->getTemplate());
         if (\Orion::config()->defined(strtoupper(\Orion::getMode()) . '_MENU')) {
             $array['menu'] = \Orion::config()->get(strtoupper(\Orion::getMode()) . '_MENU');
         }
         $array['title'] = \Orion::config()->get('SITE_NAME');
         $array['description'] = \Orion::config()->get('SITE_DESC');
         $array['author'] = \Orion::config()->get('SITE_AUTHOR');
         $array['baseurl'] = \Orion::config()->get('BASE_URL');
         $array['mode'] = \Orion::getMode();
         $array['logged'] = \Orion\Core\Auth::logged() ? 'yes' : 'no';
         if (\Orion\Core\Auth::user() != null) {
             $array['user'] = array();
             $array['user']['login'] = \Orion\Core\Auth::user()->login;
             $array['user']['hasadmin'] = \Orion\Core\Auth::user()->is('moderator', true);
         }
     } catch (Exception $e) {
         $array['error'] = 'Unable to retreive all data.';
     }
     return $array;
 }