Esempio n. 1
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;
 }
Esempio n. 2
0
 /**
  * Generate javascript markup for this script's dynamic code
  *
  * @return string
  */
 public function export()
 {
     // the markup that will be returned
     $code = parent::export();
     // render rules
     if ($this->logic->count()) {
         // begin script generation
         $code .= sprintf('/*+++ begin script: %s */', $this->token) . PHP_EOL;
         // loop all logic objects
         foreach ($this->logic->to_array() as $logic) {
             // append output of logic export
             $code .= $logic->export();
         }
         // end script generation
         $code .= sprintf('/*+++ end script: %s */', $this->token) . PHP_EOL . PHP_EOL;
     }
     // all done
     return $code;
 }
Esempio n. 3
0
 /**
  * Return theme stack as an array
  *
  * @param boolean $top_down
  * @return array
  */
 public function theme_stack($top_down = true)
 {
     // is there anything in the stack yet?
     if ($this->themes->count() === 0) {
         // not good. throw an exception here so we don't have to
         // act paranoid and check the result of every call to this.
         throw new Exception('You are trying to get the theme stack before it has been loaded');
     }
     // top down?
     if (true === $top_down) {
         // empty cache?
         if (null === $this->theme_stack_topdown) {
             // populate cache
             $this->theme_stack_topdown = $this->themes->to_array(true);
         }
         // return reversed array
         return $this->theme_stack_topdown;
     } else {
         // return array as is
         return $this->themes->to_array();
     }
 }