Exemplo n.º 1
0
function smarty_block_fis_widget($params, $content, Smarty_Internal_Template $template, &$repeat)
{
    if (!$repeat) {
        if (isset($params['extends'])) {
            $path = $params['extends'];
            unset($params['extends']);
            foreach ($params as $key => $v) {
                if ($template->getTemplateVars($key)) {
                    $params[$key] = $template->getTemplateVars($key);
                }
            }
            return $content = $template->getSubTemplate($path, $template->cache_id, $template->compile_id, null, null, $params, Smarty::SCOPE_LOCAL);
        } else {
            return $content;
        }
    } else {
        if (isset($params['extends'])) {
            unset($params['extends']);
        }
        foreach ($params as $key => $v) {
            $value = $template->getTemplateVars($key);
            if ($value === null) {
                $template->assign($key, $v, true);
            }
        }
    }
}
Exemplo n.º 2
0
 public function getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
 {
     // get variables from calling scope
     if ($parent_scope == \Smarty::SCOPE_LOCAL) {
         $newData = $this->tpl_vars;
         $newData['smarty'] = clone $this->tpl_vars['smarty'];
     } elseif ($parent_scope == \Smarty::SCOPE_PARENT) {
         $newData =& $this->tpl_vars;
     } elseif ($parent_scope == \Smarty::SCOPE_GLOBAL) {
         $newData =& \Smarty::$global_tpl_vars;
     } elseif (($scope_ptr = $this->getScopePointer($parent_scope)) == null) {
         $newData =& $this->tpl_vars;
     } else {
         $newData =& $scope_ptr->tpl_vars;
     }
     if (!empty($data)) {
         // set up variable values
         foreach ($data as $_key => $_val) {
             $newData[$_key] = new \Smarty_variable($_val);
         }
     }
     $extension = '.' . \Config::get('smartyview::extension', 'tpl');
     if (substr_compare($template, $extension, -strlen($extension), strlen($extension)) !== 0) {
         try {
             return \View::make($template, array_map(function ($v) {
                 return $v->value;
             }, $newData));
         } catch (\Exception $e) {
         }
     }
     // Fall back to parent's getSubTemplate..
     return parent::getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope);
 }
Exemplo n.º 3
0
function smarty_function_header($p, Smarty_Internal_Template $template)
{
    $tpl = $template->smarty;
    if (isset($p['title'])) {
        $tpl->data['title'] = $p['title'];
    }
    if (isset($p['keywords'])) {
        $tpl->data['keywords'] = $p['keywords'];
    }
    if (isset($p['description'])) {
        $tpl->data['description'] = $p['description'];
    }
    if (isset($p['creator'])) {
        $tpl->data['creator'] = $p['creator'];
    }
    if (isset($p['subject'])) {
        $tpl->data['subject'] = $p['subject'];
    }
    $vars = array();
    foreach ($p as $key => $val) {
        if ($key == 'title' || $key == 'file' || $key == 'keywords' || $key == 'description' || $key == 'creator' || $key == 'subject') {
            continue;
        }
        $vars[$key] = $val;
    }
    return $template->getSubTemplate(isset($p['file']) ? $p['file'] : "header.tpl", $template->cache_id, $template->compile_id, null, null, $vars, 0);
}
Exemplo n.º 4
0
function smarty_function_footer($p, Smarty_Internal_Template $template)
{
    $vars = array();
    foreach ($p as $key => $val) {
        if ($key == 'file') {
            continue;
        }
        $vars[$key] = $val;
    }
    return $template->getSubTemplate(isset($p['file']) ? $p['file'] : "footer.tpl", $template->cache_id, $template->compile_id, null, null, $vars, 0);
}
Exemplo n.º 5
0
function smarty_block_fis_widget_inline($params, $content, Smarty_Internal_Template $template, &$repeat)
{
    if (!$repeat) {
        //block 定义结束
        if (isset($params['extends'])) {
            $path = $params['extends'];
            unset($params['extends']);
            $content = $template->getSubTemplate($path, $template->cache_id, $template->compile_id, null, null, $params, Smarty::SCOPE_LOCAL);
        }
        FISBlockFisWidget::pop($template->tpl_vars);
        return $content;
    } else {
        //block 定义开始
        if (isset($params['extends'])) {
            unset($params['extends']);
        }
        FISBlockFisWidget::push($params, $template->tpl_vars);
    }
}