示例#1
0
 /**
  * Load a component extension
  *
  * Override this class to load component class files which exist outside of ICE's path
  *
  * @param string $ext Name of the extension
  * @return string Name of the class which was loaded
  */
 public function load_ext($ext)
 {
     // expand extension name
     $ext_full = $this->policy()->get_handle() . '/' . $ext;
     // try to load it with extension loader
     return ICE_Ext_Loader::load_one($ext_full);
 }
示例#2
0
 /**
  * Return singleton instance
  *
  * @return ICE_Ext_Loader
  */
 public static final function instance()
 {
     // new instance if necessary
     if (!self::$instance instanceof self) {
         // create singleton instance
         self::$instance = new self();
     }
     return self::$instance;
 }
示例#3
0
 /**
  * Load the scheme, using a theme as the starting point for the stack
  *
  * This method recursively crawls UP the theme hiearachy
  *
  * @param string $theme Theme's *directory name*
  * @return boolean
  */
 public function load($theme = null)
 {
     // was a theme passed?
     if (empty($theme)) {
         // fall back to using active theme
         $theme = ICE_ACTIVE_THEME;
     }
     // get path to config file
     $ini_file = $this->theme_config_file($theme, $this->config_file);
     // does ini file exist?
     if (ICE_Files::cache($ini_file)->is_readable()) {
         // parse it
         $ini = parse_ini_file($ini_file, true);
         // push onto loaded stack
         $this->config_files_loaded->push($ini_file);
     } else {
         // yipes, theme has no ini file.
         // assume that parent theme is the root theme
         $ini[self::DIRECTIVE_PARENT_THEME] = $this->root_theme;
     }
     // make sure we got something
     if ($ini !== false) {
         // parent theme?
         $parent_theme = isset($ini[self::DIRECTIVE_PARENT_THEME]) ? $ini[self::DIRECTIVE_PARENT_THEME] : false;
         // recurse up the theme stack if necessary
         if ($parent_theme) {
             // load it
             $this->load($parent_theme);
         }
         // push onto the stack AFTER recursion
         $this->themes->push($theme);
         // loop through directives and set them
         foreach ($ini as $name => $value) {
             if ($name == self::DIRECTIVE_ADVANCED) {
                 if (is_array($value)) {
                     foreach ($value as $name_adv => $value_adv) {
                         $this->directives()->set($theme, $name_adv, $value_adv, true);
                     }
                 }
                 continue;
             } else {
                 $this->directives()->set($theme, $name, $value, true);
             }
         }
         // make sure theme is NOT compiled in
         if (false === $this->themes_compiled->contains($theme)) {
             // add extension dir to extension loader
             ICE_Ext_Loader::path($this->theme_file($theme, $this->exts_dir));
         }
     } else {
         throw new Exception('Failed to parse theme ini file: ' . $ini_file);
     }
 }
示例#4
0
 /**
  * Return path to an ext file
  *
  * @param string $filename
  * @return string
  */
 public final function locate_file($filename)
 {
     // loop class ancestry
     foreach ($this->reflect_stack() as $reflection) {
         // call ext loader file locator helper
         $located = ICE_Ext_Loader::instance()->locate_file($reflection->getName(), $filename);
         // anything?
         if ($located) {
             return $located;
         }
     }
     // no file found :(
     return false;
 }