本文整理汇总了PHP中Smarty类的典型用法代码示例。如果您正苦于以下问题:PHP Smarty类的具体用法?PHP Smarty怎么用?PHP Smarty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Smarty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ShowSearchForm
function ShowSearchForm(VirgoAPI $api, Smarty $smarty, $lng)
{
$smarty->assign("ShowSearchForm", true);
$smarty->assign("provinces", $api->GetInvestmentsProvinces($lng));
$smarty->assign("categories", $api->GetInvestmentsCategories($lng));
$smarty->assign("post", $_POST);
}
示例2: smarty_function_filegal_uploader
/** filegal_uploader: Adds a widget to the page to upload files
*
* @param array $params
* 'galleryId' => int file gallery to upload into by default
*
* @param Smarty $smarty
* @return string html
*/
function smarty_function_filegal_uploader($params, $smarty)
{
$headerlib = TikiLib::lib('header');
// Image loader and canvas libs
$headerlib->add_jsfile('vendor/blueimp/javascript-load-image/js/load-image.all.min.js');
$headerlib->add_jsfile('vendor/blueimp/javascript-canvas-to-blob/js/canvas-to-blob.min.js');
// The Iframe Transport is required for browsers without support for XHR file uploads
$headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js');
// The basic File Upload plugin
$headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js');
// The File Upload processing plugin
$headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-process.js');
// The File Upload image preview & resize plugin
$headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-image.js');
// The File Upload audio preview plugin
$headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-audio.js');
// The File Upload video preview plugin
$headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-video.js');
// The File Upload validation plugin
$headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-validate.js');
// The File Upload user interface plugin
$headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js');
// CSS
$headerlib->add_cssfile('vendor/blueimp/jquery-file-upload/css/jquery.fileupload.css');
$headerlib->add_cssfile('vendor/blueimp/jquery-file-upload/css/jquery.fileupload-ui.css');
// Tiki customised application script
$headerlib->add_jsfile('lib/jquery_tiki/tiki-jquery_upload.js');
$return = $smarty->fetch('file/jquery_upload.tpl');
return $return;
}
示例3: smarty_block_copixhtmlheader
/**
* Permet au concepteur de template d'ajouter des éléments censés apparaitre dans la partie
* <head> du template HTML.
*
* Params: kind: string (jsLink, cssLink, style, others, jsCode)
*
* @param array $params tableau des paramètres passés à la balise
* @param string $content contenu du block
* @param Smarty $smarty pointeur sur l'élement smarty
* @return string
*
* <code>
* {copixhtmlheader kind=JsCode}
* var variable = "{$maVariableValue}";
* {/copixhtmlheader}
* </code>
*/
function smarty_block_copixhtmlheader($params, $content, &$smarty)
{
if (is_null($content)) {
return;
}
//Si aucun type n'a été demandé, on utilise others par défaut.
$kind = isset($params['kind']) ? strtolower($params['kind']) : 'others';
$key = isset($params['key']) ? $params['key'] : null;
$funcName = 'add' . $kind;
switch ($kind) {
case 'jscode':
case 'jsdomreadycode':
case 'others':
CopixHTMLHeader::$funcName($content, $key);
break;
case 'jslink':
case 'csslink':
foreach (array_filter(array_map('trim', explode("\n", $content))) as $line) {
if (strlen(trim($line)) > 0) {
CopixHTMLHeader::$funcName($line);
}
}
break;
case 'style':
case 'others':
CopixHTMLHeader::$funcName($content);
break;
default:
$smarty->_trigger_fatal_error("[plugin copixhtmlheader] unknow kind " . $params['kind'] . ", only jsLink, cssLink, style, others, jsCode are available");
}
return '';
}
示例4: clearCache
/**
* Empty cache for a specific template
*
* @api Smarty::clearCache()
* @link http://www.smarty.net/docs/en/api.clear.cache.tpl
*
* @param \Smarty $smarty
* @param string $template_name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param integer $exp_time expiration time
* @param string $type resource type
*
* @return integer number of cache files deleted
*/
public function clearCache(Smarty $smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
{
$smarty->_clearTemplateCache();
// load cache resource and call clear
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time);
}
示例5: compile_CFG
function compile_CFG($prop)
{
$smarty = new Smarty();
$smarty->assign($prop);
$string = $smarty->fetch(dirname(__FILE__) . '/compile.tpl');
return $string;
}
示例6: setUp
public function setUp()
{
$smarty = new Smarty();
$render = new CM_Frontend_Render();
$this->_template = $smarty->createTemplate('string:');
$this->_template->assignGlobal('render', $render);
}
示例7: smarty_function_mobile_access_paginator
/**
* Render pagination block
*
* Parameters:
*
* - page - current_page
* - total_pages - total pages
* - route - route for URL assembly
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_mobile_access_paginator($params, &$smarty)
{
$url_params = '';
if (is_foreachable($params)) {
foreach ($params as $k => $v) {
if (strpos($k, 'url_param_') !== false && $v) {
$url_params .= '&' . substr($k, 10) . '=' . $v;
}
// if
}
// foreach
}
// if
$paginator = array_var($params, 'paginator', new Pager());
$paginator_url = array_var($params, 'url', ROOT_URL);
$paginator_anchor = array_var($params, 'anchor', '');
$smarty->assign(array("_mobile_access_paginator_url" => $paginator_url, "_mobile_access_paginator" => $paginator, '_mobile_access_paginator_anchor' => $paginator_anchor, "_mobile_access_paginator_url_params" => $url_params));
$paginator_url = strpos($paginator_url, '?') === false ? $paginator_url . '?' : $paginator_url . '&';
if (!$paginator->isFirst()) {
$smarty->assign('_mobile_access_paginator_prev_url', $paginator_url . 'page=' . ($paginator->getCurrentPage() - 1) . $url_params . $paginator_anchor);
}
// if
if (!$paginator->isLast()) {
$smarty->assign('_mobile_access_paginator_next_url', $paginator_url . 'page=' . ($paginator->getCurrentPage() + 1) . $url_params . $paginator_anchor);
}
// if
return $smarty->fetch(get_template_path('_paginator', null, MOBILE_ACCESS_MODULE));
}
示例8: doDefault
/**
* 显示登录页(默认Action)
*/
function doDefault()
{
$base = dirname(__FILE__);
// 初始化smarty
import('smarty.Smarty');
$smarty = new Smarty();
$smarty->template_dir = $this->app->cfg['smarty']['template_dir'];
$smarty->compile_dir = $this->app->cfg['smarty']['compile_dir'];
$smarty->config_dir = $this->app->cfg['smarty']['config_dir'];
$smarty->cache_dir = $this->app->cfg['smarty']['cache_dir'];
$smarty->debugging = $this->app->cfg['smarty']['debugging'];
$smarty->caching = $this->app->cfg['smarty']['caching'];
$smarty->cache_lifetime = $this->app->cfg['smarty']['cache_lifetime'];
$smarty->left_delimiter = '{<';
$smarty->right_delimiter = '>}';
$result = null;
if (isset($_POST['u']) && isset($_POST['p'])) {
//$password 是从数据库中读取的用户密码,现在暂定hello
$password = "hello";
//计算密码和验证码的md5值
if (md5($password . $_SESSION['VALIDATE_CODE']) == $_POST['p']) {
$result = "The result is: right";
} else {
$result = "The result is: false";
}
}
$smarty->assign("result", $result);
$smarty->display($base . "\\md5demo.tpl");
}
示例9: _renderForm
function _renderForm(&$page)
{
$pageName = $page->getAttribute('name');
$tabPreview = array_slice($page->controller->_tabs, -2, 1);
// setup a template object
$tpl = new Smarty();
$tpl->template_dir = './templates';
$tpl->compile_dir = './templates_c';
// on preview tab, add progress bar javascript and stylesheet
if ($pageName == $tabPreview[0][0]) {
$bar = $page->controller->createProgressBar();
$tpl->assign(array('qf_style' => $bar->getStyle(), 'qf_script' => $bar->getScript()));
$barElement = $page->getElement('progressBar');
$barElement->setText($bar->toHtml());
}
$renderer = new HTML_QuickForm_Renderer_Array(true);
$page->accept($renderer);
$tpl->assign('form', $renderer->toArray());
// capture the array stucture
// (only for showing in sample template)
ob_start();
print_r($renderer->toArray());
$tpl->assign('dynamic_array', ob_get_contents());
ob_end_clean();
$tpl->display('smarty-dynamic.tpl');
}
示例10: admin_joinus
function admin_joinus()
{
global $db, $countries;
$tpl = new smarty();
$db->query('SELECT tname, `joinID`, `name`, b.username, b.email, b.icq, b.msn, `age`, b.country, `teamID`, `comment`, `IP`, `datum`, `closed`, `closedby`, a.username as closedby_username FROM ' . DB_PRE . 'ecp_joinus as b LEFT JOIN ' . DB_PRE . 'ecp_teams ON (teamID = tID) LEFT JOIN ' . DB_PRE . 'ecp_user as a ON (ID=closedby) ORDER BY closed ASC, datum ASC');
$joinus = array();
while ($row = $db->fetch_assoc()) {
$row['datum'] = date(SHORT_DATE, $row['datum']);
if ($row['joinID'] == (int) @$_GET['id']) {
$spe = $row;
}
$joinus[] = $row;
}
if (@$spe) {
ob_start();
$tpl1 = new Smarty();
foreach ($spe as $key => $value) {
$tpl1->assign($key, $value);
}
$tpl1->assign('countryname', $countries[$spe['country']]);
$tpl1->assign('id', $row['joinID']);
$tpl1->display(DESIGN . '/tpl/admin/joinus_view.html');
$tpl->assign('details', ob_get_contents());
ob_end_clean();
}
$tpl->assign('joinus', $joinus);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/joinus.html');
$content = ob_get_contents();
ob_end_clean();
main_content(JOINUS, $content, '', 1);
}
示例11: __construct
private function __construct()
{
$mode = isset($_GET['mode']) ? $_GET['mode'] : false;
require 'core/models/class.Access.php';
switch ($mode) {
case 'login':
$login = new Access();
$login->Login();
break;
case 'reg':
if (isset($_POST['faccion'])) {
$reg = new Access();
$reg->Register();
} else {
$lng = new Lang();
$template = new Smarty();
$template->assign(array('x_user' => $lng->x_user, 'x_pass' => $lng->x_pass, 'x_email' => $lng->x_email, 'x_registrarme' => $lng->x_registrarme));
$template->display('public/registro.xnv');
}
break;
default:
$lng = new Lang();
$template = new Smarty();
$template->assign(array('x_user' => $lng->x_user, 'x_pass' => $lng->x_pass, 'x_recordar' => $lng->x_recordar, 'x_submit' => $lng->x_submit));
$template->display('public/index.xnv');
break;
}
unset($lng, $template);
}
示例12: smarty_function_get_favorites
/**
* Smarty {get_favorites} function plugin
*
* Type: function<br>
* Name: get_favorites<br>
* Purpose: get and assign favorites
*
* @param $params
* @param \Smarty $smarty
* @return bool
*/
function smarty_function_get_favorites($params, &$smarty)
{
global $user;
$uid = empty($params['user_id']) ? $user->id : $params['user_id'];
$id = empty($params['id']) ? null : $params['id'];
$smarty->assign($params['assign'], favorites::get($params['module'], $id, $uid));
}
示例13: smarty_function_oxscript
/**
* Smarty plugin
* -------------------------------------------------------------
* File: function.oxscript.php
* Type: string, html
* Name: oxscript
* Purpose: Collect given javascript includes/calls, but include/call them at the bottom of the page.
*
* Add [{oxscript add="oxid.popup.load();"}] to add script call.
* Add [{oxscript include="oxid.js"}] to include local javascript file.
* Add [{oxscript include="oxid.js?20120413"}] to include local javascript file with query string part.
* Add [{oxscript include="http://www.oxid-esales.com/oxid.js"}] to include external javascript file.
*
* IMPORTANT!
* Do not forget to add plain [{oxscript}] tag before closing body tag, to output all collected script includes and calls.
* -------------------------------------------------------------
*
* @param array $params Params
* @param Smarty $smarty Clever simulation of a method
*
* @return string
*/
function smarty_function_oxscript($params, &$smarty)
{
$isDynamic = isset($smarty->_tpl_vars["__oxid_include_dynamic"]) ? (bool) $smarty->_tpl_vars["__oxid_include_dynamic"] : false;
$priority = !empty($params['priority']) ? $params['priority'] : 3;
$widget = !empty($params['widget']) ? $params['widget'] : '';
$isInWidget = !empty($params['inWidget']) ? $params['inWidget'] : false;
$output = '';
if (isset($params['add'])) {
if (empty($params['add'])) {
$smarty->trigger_error("{oxscript} parameter 'add' can not be empty!");
return '';
}
$register = oxNew('OxidEsales\\EshopCommunity\\Core\\ViewHelper\\JavaScriptRegistrator');
$register->addSnippet($params['add'], $isDynamic);
} elseif (isset($params['include'])) {
if (empty($params['include'])) {
$smarty->trigger_error("{oxscript} parameter 'include' can not be empty!");
return '';
}
$register = oxNew('OxidEsales\\EshopCommunity\\Core\\ViewHelper\\JavaScriptRegistrator');
$register->addFile($params['include'], $priority, $isDynamic);
} else {
$renderer = oxNew('OxidEsales\\EshopCommunity\\Core\\ViewHelper\\JavaScriptRenderer');
$output = $renderer->render($widget, $isInWidget, $isDynamic);
}
return $output;
}
示例14: smarty_function_public_url
/**
* @param array $params
* SSL default behaviour:
* Decided by current page.
* Set parameter __ssl to true or false to override default ssl behaviour.
* @param Smarty $smarty
* @return string
*/
function smarty_function_public_url($params = array(), &$smarty)
{
$path = '';
if (!empty($params['path'])) {
$path = $params['path'];
unset($params['path']);
}
if (!empty($params['__ssl'])) {
$ssl = $params['__ssl'];
unset($params['__ssl']);
} else {
$ssl = \Skully\App\Helpers\UrlHelper::isSecure();
}
$arguments = array();
foreach ($params as $key => $val) {
$arguments[$key] = $val;
}
/** @var \Skully\ApplicationInterface $app */
$app = $smarty->getRegisteredObject('app');
if (strpos($path, "http://") !== 0 && strpos($path, "https://") !== 0) {
$path = $app->getTheme()->getPublicBaseUrl($ssl) . $path;
}
if (!empty($arguments)) {
$argumentsStr = http_build_query($arguments);
return $path . '?' . $argumentsStr;
} else {
return $path;
}
}
示例15: smarty_function_optiondisplayer
/**
* Smarty {optiondisplayer} function plugin
*
* Type: function<br>
* Name: optiondisplayer<br>
* Purpose: display option dropdown list
*
* @param $params
* @param \Smarty $smarty
* @return bool
*/
function smarty_function_optiondisplayer($params, &$smarty)
{
global $db;
$groupname = $params['options'];
$product = $params['product'];
$display_price_as = isset($params['display_price_as']) ? $params['display_price_as'] : 'diff';
// get the option group
$og = new optiongroup();
//$group = $og->find('bytitle', $groupname);
$group = $og->find('first', 'product_id=' . $product->id . ' AND title="' . $groupname . '"');
//grab the options configured for this product
$options = $product->optionDropdown($group->title, $display_price_as);
// if there are no options we can return now
if (empty($options)) {
return false;
}
// find the default option if there is one.
$default = $db->selectValue('option', 'id', 'optiongroup_id=' . $group->id . ' AND is_default=1');
$view = $params['view'];
//if((isset() || $og->required == false) $includeblank = $params['includeblank'] ;
//elseif((isset($params['includeblank']) && $params['includeblank'] == false) || $og->required == true) $includeblank = false;
$includeblank = $og->required == false && !isset($params['includeblank']) ? gt('-- Please Select an Option --') : $params['includeblank'];
$template = get_common_template($view, $smarty->getTemplateVars('__loc'), 'options');
$template->assign('product', $product);
$template->assign('options', $options);
$template->assign('group', $group);
$template->assign('params', $params);
$template->assign('default', $default);
$template->assign('includeblank', $includeblank);
$template->assign('required', $params['required']);
$template->assign('selected', $params['selected']);
echo $template->render();
}