Example #1
0
 private function extendImport($import)
 {
     $path = self::$DIR . "/{$import['name']}.xml";
     if (!is_readable_file($path)) {
         throw new XMLModelException("XML import '{$path}' not found.", E_USER_WARNING);
     }
     $class = __CLASS__;
     $xml = new $class(file_get_contents($path));
     foreach ($xml->children() as $node) {
         $this->append($node);
     }
 }
Example #2
0
 /**
  * Renders the contents of an PHP file by require()'ing it while output
  * buffering is active.
  *
  * Optionally can prefix local HTML paths in the output.
  *
  * @param string $_PATH_ Path to the PHP file to render.
  * @param array $_DATA_ Variables to introduce into local scope.
  * @param string $_PREFIX_ String with which to prefix local URLs in HTML.
  * @return string Rendered template contents
  */
 public static function render($_PATH_, $_DATA_ = false, $_PREFIX_ = false)
 {
     if (!is_readable_file($_PATH_)) {
         throw new ViewException("Could not read file '{$_PATH_}'");
     }
     if (is_array($_DATA_)) {
         extract($_DATA_);
     }
     ob_start();
     include $_PATH_;
     return is_string($_PREFIX_) ? self::Prefix(ob_get_clean(), $_PREFIX_) : ob_get_clean();
 }
Example #3
0
 public function render($name, $_DATA_ = false, $_PREFIX_ = false)
 {
     if ($name[0] == '~') {
         $name = substr($name, 1);
         $_PATH_ = DIR_SHARED . "/View/{$name}.html";
     } else {
         $_PATH_ = DIR_VIEWS . "/{$name}.html";
     }
     if (!is_readable_file($_PATH_)) {
         new \Exception("Could not read file '{$_PATH_}'");
     }
     if (is_array($_DATA_)) {
         extract($_DATA_);
     }
     ob_start();
     include $_PATH_;
     return is_string($_PREFIX_) ? View::prefix(ob_get_clean(), $_PREFIX_) : ob_get_clean();
 }