Пример #1
0
 /**
  * Create and return a new logic object
  *
  * @param string $code valid javascript code
  * @return ICE_Script_Logic
  */
 public function logic($code = null)
 {
     // new logic object
     $logic = new ICE_Script_Logic($code);
     // add it to logic stack
     $this->logic->push($logic);
     return $logic;
 }
Пример #2
0
 /**
  * Inject static code/markup
  *
  * @return string
  */
 public function export()
 {
     // the code that will be returned
     $code = null;
     // handle callbacks
     if ($this->has_callbacks()) {
         // loop em
         foreach ($this->callbacks as $callback) {
             // execute callback with myself as only argument
             call_user_func($callback, $this);
         }
     }
     // have any files?
     if ($this->files_export->count()) {
         // loop through all files
         foreach ($this->files_export as $file) {
             // resolve file path
             if (path_is_absolute($file)) {
                 // its absolute already, which is good
                 $filename = $file;
             } else {
                 // relative path, need to locate it
                 $filename = $this->component()->locate_file($file);
             }
             // only import each file once!
             if (self::$files_imported->contains($filename)) {
                 // already imported that one
                 continue;
             } else {
                 // push it on to imported stack
                 self::$files_imported->push($filename);
             }
             // inject helpful comment ;)
             //$code .= '/*+++ import source: ' . $filename . ' */' . PHP_EOL;
             // make sure file actually exists
             if (ICE_Files::cache($filename)->is_readable()) {
                 // get entire contents of file
                 $code .= $this->get_file_contents($filename) . PHP_EOL;
                 // success
                 //$code .= '/*--- import complete! */' . PHP_EOL . PHP_EOL;
             } else {
                 //$code .= '/*!!! import failed! */' . PHP_EOL . PHP_EOL;
             }
         }
     }
     // handle strings
     if ($this->has_strings()) {
         //$code .= '/*--- importing strings */' . PHP_EOL;
         $code .= implode(PHP_EOL, $this->strings->to_array()) . str_repeat(PHP_EOL, 2);
         //$code .= '/*!!! importing strings complete */' . PHP_EOL;
     }
     // all done
     return $code;
 }
Пример #3
0
 /**
  * Enable components for the scheme by passing a valid policy object
  *
  * @param ICE_Policy $policy
  * @param string $ini_file_name
  * @return boolean
  */
 public function enable_component(ICE_Policy $policy)
 {
     // loop through entire theme stack BOTTOM UP and try to load options
     foreach ($this->theme_stack(false) as $theme) {
         // path to ini file
         $ini_file = $this->theme_config_file($theme, $policy->get_handle());
         // load the option config if it exists
         if (ICE_Files::cache($ini_file)->is_readable()) {
             // skip loaded files
             if ($this->config_files_loaded->contains($ini_file)) {
                 continue;
             }
             // try to load ini file
             if ($policy->registry()->load_config_file($ini_file, $theme)) {
                 // push onto loaded stack
                 $this->config_files_loaded->push($ini_file);
             }
         }
     }
     // finalize policy
     $policy->finalize();
     return true;
 }
Пример #4
0
 /**
  * Add a path to check. Later items are check first.
  *
  * @param string $path
  * @return boolean
  */
 public final function add_path($path)
 {
     if (!$this->paths->contains($path)) {
         $this->paths->push($path);
         return true;
     }
     // already exists
     return false;
 }
Пример #5
0
 /**
  * Push an exportable object onto the stack
  *
  * @param ICE_Exportable $obj
  * @return ICE_Stack
  */
 public function push(ICE_Exportable $obj)
 {
     // not allowed if callback is set
     if ($this->callback) {
         throw new Exception('Adding exportable objects not allowed when a callback is set');
     }
     // push object on to stack
     $this->stack->push($obj);
     // handle recursive objects
     if ($obj instanceof ICE_Recursable) {
         // loop children
         foreach ($obj->get_children() as $name => $child) {
             // push to child
             $this->child($name)->push($child);
         }
     }
     return $this;
 }