예제 #1
0
 /**
  * Return absolute path to default template
  *
  * @return string
  */
 public final function get_template_path()
 {
     // template path to return
     $template = null;
     // try to locate the template
     if ($this->template) {
         // was absolute path given?
         if (ICE_Files::path_is_absolute($this->template)) {
             // yep, use as is
             $template = $this->template;
         } else {
             // its relative, try to locate it
             $template = ICE_Scheme::instance()->locate_template($this->template);
         }
     }
     // was a template found?
     if ($template) {
         // yes! use that one
         return $template;
     } else {
         // try to locate the default template
         return $this->locate_file('template.php');
     }
 }
예제 #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 (count($this->files_export)) {
         // loop through all files
         foreach ($this->files_export as $file) {
             // resolve file path
             if (ICE_Files::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) . str_repeat(PHP_EOL, 2);
         //$code .= '/*!!! importing strings complete */' . PHP_EOL;
     }
     // all done
     return $code;
 }