Beispiel #1
0
 public function initialize($config = array())
 {
     // initialize config
     foreach ($config as $key => $val) {
         $this->{'_' . $key} = $val;
     }
     unset($config);
     // No locations set in config?
     if ($this->_theme_locations === array()) {
         // Let's use this obvious default
         $this->_theme_locations = array(THEMEPATH);
     }
     // Set default theme
     if ($default_theme = $this->CI->config->item(APPDIR, 'default_themes')) {
         $this->setTheme($default_theme);
     }
     // Load the theme config and store array in $this->_theme_config
     $this->_theme_config = load_theme_config($this->_theme, APPDIR);
     // Modular Separation / Modular Extensions has been detected
     if (method_exists($this->CI->router, 'fetch_module')) {
         $this->_module = $this->CI->router->fetch_module();
     }
     // What controllers or methods are in use
     $this->_controller = $this->CI->router->fetch_class();
     $this->_method = $this->CI->router->fetch_method();
     // Load user agent library if not loaded
     $this->CI->load->library('user_agent');
 }
Beispiel #2
0
 public function render($view, $data = array(), $return = FALSE)
 {
     // Set whatever values are given. These will be available to all view files
     is_array($data) or $data = (array) $data;
     // Merge in what we already have with the specific data
     $this->_data = array_merge($this->_data, $data);
     // We don't need you any more buddy
     unset($data);
     // Load the theme config and store array in $theme_config
     $theme_config = load_theme_config($this->_theme, APPDIR);
     if (!empty($theme_config['head_tags'])) {
         $this->setHeadTags($theme_config['head_tags']);
     }
     // Set the modules for this layout using the current URI segments
     if ($this->_load_partial === TRUE) {
         $this->_modules = $this->getLayoutModules();
     }
     // Output template variables to the template
     $template['title'] = $this->_head_tags['title'];
     $template['breadcrumbs'] = $this->_breadcrumbs;
     //*** future reference
     $template['partials'] = array();
     // Assign by reference, as all loaded views will need access to partials
     $this->_data['template'] =& $template;
     // Load the partials variables
     foreach ($this->_partials as $name => $partial) {
         $template['partials'][$name] = $this->_loadPartial($partial);
     }
     // Load the layouts variables
     foreach ($this->_layouts as $name => $layout) {
         $template['partials'][$name] = $this->_loadPartial($layout);
     }
     // Lets do the caching instead of the browser
     if ($this->CI->config->item('cache_mode') === '1') {
         //			$this->CI->output->cache($this->CI->config->item('cache_time'));
     }
     // Want it returned or output to browser?
     if (!$return) {
         $this->CI->load->view('themes/' . $this->_theme . '/' . $view, $this->_data, FALSE);
     } else {
         return self::_load_view('themes/' . $this->_theme . '/' . $view, $this->_data, NULL);
     }
 }
Beispiel #3
0
 public function initialize($config = array())
 {
     // initialize config
     foreach ($config as $key => $val) {
         $this->{'_' . $key} = $val;
     }
     unset($config);
     // No locations set in config?
     if ($this->_theme_locations === array()) {
         // Let's use this obvious default
         $this->_theme_locations = array(THEMEPATH);
     }
     // Set default theme
     if ($default_theme = $this->CI->config->item(APPDIR, 'default_themes')) {
         $this->setTheme($default_theme);
     }
     // Load the theme config and store array in $this->_theme_config
     $this->_theme_config = load_theme_config($this->_theme, APPDIR);
     // Set the parent theme if theme is child
     $this->_parent_theme = isset($this->_theme_config['parent']) ? $this->_theme_config['parent'] : '';
     // Modular Separation / Modular Extensions has been detected
     if (method_exists($this->CI->router, 'fetch_module')) {
         $this->_module = $this->CI->router->fetch_module();
     }
     // What controllers or methods are in use
     $this->_controller = $this->CI->router->fetch_class();
     $this->_method = $this->CI->router->fetch_method();
     if (!empty($this->_theme_config['head_tags'])) {
         $this->setHeadTags($this->_theme_config['head_tags']);
     }
     $this->setPartialArea();
     // Set the modules for this layout using the current URI segments
     !empty($this->_modules) or $this->_modules = $this->getLayoutModules();
     // Load user agent library if not loaded
     $this->CI->load->library('user_agent');
 }
 /**
  * List existing themes in the system
  *
  * Lists the existing themes in the system by examining the
  * theme folders in both admin and main domain, and also gets the theme
  * config.
  *
  * @return array The names,path,config of the theme directories.
  */
 function list_themes()
 {
     $themes = array();
     foreach (array(MAINDIR, ADMINDIR) as $domain) {
         foreach (glob(ROOTPATH . "{$domain}/views/themes/*", GLOB_ONLYDIR) as $filepath) {
             $filename = basename($filepath);
             $themes[] = array('location' => $domain, 'basename' => $filename, 'path' => "{$domain}/views/themes/{$filename}", 'config' => load_theme_config($filename, $domain));
         }
     }
     return $themes;
 }