Exemple #1
0
 public function render($layout, $args = array())
 {
     // prevent render to recurse indefinitely
     static $count = 0;
     $count++;
     if ($count < self::MAX_RENDER_RECURSIONS) {
         // init vars
         $parts = explode($this->_separator, $layout);
         $this->_layout = preg_replace('/[^A-Z0-9_\\.-]/i', '', array_pop($parts));
         // render layout
         if ($__layout = JPath::find($this->_getPath(implode(DIRECTORY_SEPARATOR, $parts)), $this->_layout . $this->_extension)) {
             // import vars and layout output
             extract($args);
             ob_start();
             include $__layout;
             $output = ob_get_contents();
             ob_end_clean();
             $count--;
             return $output;
         }
         $count--;
         // raise warning, if layout was not found
         JError::raiseWarning(0, 'Renderer Layout "' . $layout . '" not found. (' . YUtility::debugInfo(debug_backtrace()) . ')');
         return null;
     }
     // raise warning, if render recurses indefinitly
     JError::raiseWarning(0, 'Warning! Render recursed indefinitly. (' . YUtility::debugInfo(debug_backtrace()) . ')');
     return null;
 }
Exemple #2
0
 public function partial($name, $args = array())
 {
     // clean the file name
     $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', '_' . $name);
     // set template path and add global partials
     $path = $this->_path['template'];
     $path[] = $this->_basePath . DS . 'partials';
     // load the partial
     $__file = $this->_createFileName('template', array('name' => $file));
     $__partial = JPath::find($path, $__file);
     // render the partial
     if ($__partial != false) {
         // import vars and get content
         extract($args);
         ob_start();
         include $__partial;
         $output = ob_get_contents();
         ob_end_clean();
         return $output;
     }
     return JError::raiseError(500, 'Partial Layout "' . $__file . '" not found. (' . YUtility::debugInfo(debug_backtrace()) . ')');
 }