public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     $_content = empty($_data['content']) ? $_data['file'] : $_data['content'];
     $_data['prefix'] = !empty($_data['prefix']) ? $_data['prefix'] : C('TMPL_CACHE_PREFIX');
     if ('sen' == $engine) {
         // Template engine using Sen
         if (!empty($_data['content']) && $this->checkContentCache($_data['content'], $_data['prefix']) || $this->checkCache($_data['file'], $_data['prefix'])) {
             // Cache is valid
             // Decomposition and load the template cache variables
             extract($_data['var'], EXTR_OVERWRITE);
             //Load template cache files
             include C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX');
         } else {
             $tpl = Sen::instance('SenTemplate');
             // Compile and load the template file
             $tpl->fetch($_content, $_data['var'], $_data['prefix']);
         }
     } else {
         // Called third-party template engine to parse and output
         $class = 'Template' . ucwords($engine);
         if (class_exists($class)) {
             $tpl = new $class();
             $tpl->fetch($_content, $_data['var']);
         } else {
             // Class does not define
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
 }
 /**
  * Resolution tab library
  * Need to call the corresponding tag library file parsing class
  * @access public
  * @param string $tagLib  Tag library name
  * @param string $tag  Tag names
  * @param string $attr  Tag attributes
  * @param string $content  Tag contents
  * @return string|false
  */
 public function parseXmlTag($tagLib, $tag, $attr, $content)
 {
     //if (MAGIC_QUOTES_GPC) {
     $attr = stripslashes($attr);
     $content = stripslashes($content);
     //}
     if (ini_get('magic_quotes_sybase')) {
         $attr = str_replace('\\"', '\'', $attr);
     }
     $tLib = Sen::instance('TagLib' . ucwords(strtolower($tagLib)));
     $parse = '_' . $tag;
     $content = trim($content);
     return $tLib->{$parse}($attr, $content);
 }
 /**
  * Architecture function
  * @access public
  */
 public function __construct()
 {
     $this->tagLib = strtolower(substr(get_class($this), 4));
     $this->tpl = Sen::instance('SenTemplate');
 }
 /**
  * Initialize the view
  * @access private
  * @return void
  */
 private function initView()
 {
     //View class is instantiated
     if (!$this->view) {
         $this->view = Sen::instance('View');
     }
     // Template variables by value
     if ($this->tVar) {
         $this->view->assign($this->tVar);
     }
 }
Ejemplo n.º 5
0
/**
 * Render Output Widget
 * @param string $name Widget name
 * @param array $data Transmission parameters
 * @param boolean $return Returns the content 
 * @return void
 */
function W($name, $data = array(), $return = false)
{
    $class = $name . 'Widget';
    require_cache(BASE_LIB_PATH . 'Widget/' . $class . '.class.php');
    if (!class_exists($class)) {
        throw_exception(L('_CLASS_NOT_EXIST_') . ':' . $class);
    }
    $widget = Sen::instance($class);
    $content = $widget->render($data);
    if ($return) {
        return $content;
    } else {
        echo $content;
    }
}