本文整理汇总了PHP中Smarty::getTemplateVars方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::getTemplateVars方法的具体用法?PHP Smarty::getTemplateVars怎么用?PHP Smarty::getTemplateVars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::getTemplateVars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_block_form
/**
* Smarty {form} block plugin
*
* Type: block<br>
* Name: form<br>
* Purpose: Set up a form block
*
* @param $params
* @param $content
* @param \Smarty $smarty
* @param $repeat
*/
function smarty_block_form($params, $content, &$smarty, &$repeat)
{
if (empty($content)) {
$name = isset($params['name']) ? $params['name'] : 'form';
$id = empty($params['id']) ? $name : $params['id'];
$module = isset($params['module']) ? $params['module'] : $smarty->getTemplateVars('__loc')->mod;
$controller = isset($params['controller']) ? $params['controller'] : $smarty->getTemplateVars('__loc')->con;
$method = isset($params['method']) ? $params['method'] : "POST";
$enctype = isset($params['enctype']) ? $params['enctype'] : 'multipart/form-data';
echo "<!-- Form Object 'form' -->\r\n";
echo '<script type="text/javascript" src="' . PATH_RELATIVE . 'framework/core/subsystems/forms/js/inputfilters.js.php"></script>' . "\r\n";
// echo '<script type="text/javascript" src="'.PATH_RELATIVE.'framework/core/subsystems/forms/controls/listbuildercontrol.js"></script>'."\r\n";
// echo '<script type="text/javascript" src="'.PATH_RELATIVE.'framework/core/subsystems/forms/js/required.js"></script>'."\r\n";
// echo '<script type="text/javascript" src="'.PATH_RELATIVE.'external/jscalendar/calendar.js"></script>'."\r\n";
// echo '<script type="text/javascript" src="'.PATH_RELATIVE.'external/jscalendar/lang/calendar-en.js"></script>'."\r\n";
// echo '<script type="text/javascript" src="'.PATH_RELATIVE.'external/jscalendar/calendar-setup.js"></script>'."\r\n";
// echo '<script type="text/javascript" src="'.PATH_RELATIVE.'js/PopupDateTimeControl.js"></script>'."\r\n";
expCSS::pushToHead(array("corecss" => "forms"));
echo '<form id="' . $id . '" name="' . $name . '" class="' . $params['class'] . '" method="' . $method . '" action="' . URL_FULL . 'index.php" enctype="' . $enctype . '">' . "\r\n";
if (!empty($controller)) {
echo '<input type="hidden" name="controller" id="controller" value="' . $controller . '" />' . "\r\n";
} else {
echo '<input type="hidden" name="module" id="module" value="' . $module . '" />' . "\r\n";
}
echo '<input type="hidden" name="src" id="src" value="' . $smarty->getTemplateVars('__loc')->src . '" />' . "\r\n";
echo '<input type="hidden" name="int" id="int" value="' . $smarty->getTemplateVars('__loc')->int . '" />' . "\r\n";
if (isset($params['action'])) {
echo '<input type="hidden" name="action" id="action" value="' . $params['action'] . '" />' . "\r\n";
}
//echo the innards
} else {
echo $content;
echo '</form>';
}
}
示例2: get
/**
* Get the evaluated contents of the view.
*
* @param string $path
* @param array $data
* @return string
*/
public function get($path, array $data = array())
{
$template = $this->smarty->createTemplate($path);
$template->assign($this->smarty->getTemplateVars());
$template->assign($data);
return $template->fetch();
}
示例3: smarty_function_url
/**
* print an url
* @param unknown_type $params
* @param Smarty $smarty
* @param unknown_type $template
* @return string
*/
function smarty_function_url($params, $smarty, $template)
{
$action = isset($params['action']) ? $params['action'] : $smarty->getTemplateVars('action');
$controller = isset($params['controller']) ? $params['controller'] : $smarty->getTemplateVars('controller');
unset($params['action']);
unset($params['controller']);
$extra = '';
foreach ($params as $key => $param) {
$extra .= '/' . $key . '/' . $param;
}
return "{$smarty->getTemplateVars('baseUrl')}/{$controller}/{$action}{$extra}";
}
示例4: smarty_function_uniqueid
/**
* Smarty {uniqueid} function plugin
*
* Type: function<br>
* Name: uniquieid<br>
* Purpose: create a unique id
*
* @param $params
* @param \Smarty $smarty
* @return bool
*/
function smarty_function_uniqueid($params, &$smarty)
{
$badvals = array("[", "]", ",", " ", "'", "\"", "&", "#", "%", "@", "!", "\$", "(", ")", "{", "}");
$randstr = 'exp';
$randstr .= empty($smarty->getTemplateVars('__loc')->src) ? mt_rand(1, 9999) : str_replace($badvals, "", $smarty->getTemplateVars('__loc')->src);
$id = $randstr . $params['id'];
if (!empty($params['prepend'])) {
$id = $params['prepend'] . $id;
}
if (isset($params['assign'])) {
$smarty->assign($params['assign'], $id);
} else {
echo $id;
}
}
示例5: smarty_function_textarea
/**
* ...
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty.form
* @author Integry Systems
*/
function smarty_function_textarea($params, $smarty)
{
if (empty($params['name'])) {
$params['name'] = $smarty->getTemplateVars('input_name');
}
// @todo: can be removed when all TinyMCE editors are instantiated via Angular
if (empty($params['id']) && empty($params['tinymce'])) {
$params['id'] = uniqid();
}
$formParams = $smarty->_tag_stack[0][1];
$formHandler = $formParams['handle'];
$fieldName = $params['name'];
if (empty($params['ng_model']) && !empty($formParams['model'])) {
$params['ng-model'] = $formParams['model'] . '.' . $params['name'];
unset($params['ng_model']);
}
$params = $smarty->applyFieldValidation($params, $formHandler);
if (!empty($params['tinymce'])) {
if (is_bool($params['tinymce'])) {
$params['tinymce'] = 'getTinyMceOpts()';
}
$params['ui-tinymce'] = $params['tinymce'];
unset($params['tinymce']);
}
// Check permissions
if ($formParams['readonly']) {
$params['readonly'] = 'readonly';
}
$content = '<textarea';
$content = $smarty->appendParams($content, $params);
$content .= '>' . htmlspecialchars($formHandler->get($fieldName), ENT_QUOTES, 'UTF-8') . '</textarea>';
$content = $smarty->formatControl($content, $params);
return $content;
}
示例6: 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();
}
示例7: smarty_function_securelink
/**
* Smarty {securelink} function plugin
*
* Type: function<br>
* Name: securelink<br>
* Purpose: create a secure link
*
* @param $params
* @param \Smarty $smarty
* @return bool
*/
function smarty_function_securelink($params, &$smarty)
{
/*$loc = $smarty->getTemplateVars('__loc');
if (!isset($params['module'])) $params['module'] = $loc->mod;
if (!isset($params['src'])) $params['src'] = $loc->src;
if (!isset($params['int'])) $params['int'] = $loc->int;
$params['expid'] = session_id();
*/
$loc = $smarty->getTemplateVars('__loc');
if (!isset($params['module'])) {
$params['module'] = empty($params['controller']) ? $loc->mod : $params['controller'];
}
if (!isset($params['src'])) {
if (expModules::controllerExists($params['module'])) {
$params['src'] = $loc->src;
} elseif (@call_user_func(array($loc->mod, 'hasSources'))) {
$params['src'] = $loc->src;
}
}
if (!isset($params['int'])) {
$params['int'] = $loc->int;
}
echo expCore::makeSecureLink($params);
}
示例8: smarty_function_hidden
/**
* ...
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty.form
* @author Integry Systems
*/
function smarty_function_hidden($params, $smarty)
{
if (empty($params['name'])) {
$params['name'] = $smarty->getTemplateVars('input_name');
}
$formParams = $smarty->_tag_stack[0][1];
$formHandler = $formParams['handle'];
$fieldName = $params['name'];
if (!$formHandler instanceof Form) {
throw new HelperException('Element must be placed in {form} block');
}
if (!empty($formParams['model'])) {
$params['ng-model'] = $formParams['model'] . '.' . $params['name'];
}
$fieldName = $params['name'];
$output = '<input type="hidden"';
if (!isset($params['value'])) {
$params['value'] = $formHandler->get($fieldName);
}
foreach ($params as $name => $value) {
$output .= ' ' . $name . '="' . htmlspecialchars($value, ENT_QUOTES) . '"';
}
$output .= " />";
return $output;
}
示例9: smarty_function_radio
/**
* Display radio button
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty.form
* @author Integry Systems <http://integry.com>
*/
function smarty_function_radio($params, $smarty)
{
if (empty($params['name'])) {
$params['name'] = $smarty->getTemplateVars('input_name');
}
$formParams = $smarty->_tag_stack[0][1];
$formHandler = $formParams['handle'];
if (!$formHandler instanceof Form) {
throw new HelperException('Element must be placed in {form} block');
}
$fieldName = $params['name'];
if (!empty($formParams['model'])) {
$params['ng-model'] = $formParams['model'] . '.' . $params['name'];
}
// Check permissions
if ($formParams['readonly']) {
$params['disabled'] = 'disabled';
}
// get checked state
$formValue = $formHandler->get($fieldName);
if ($formValue == $params['value'] || empty($formValue) && $params['checked']) {
$params['checked'] = 'checked';
}
$output = '<input type="radio"';
foreach ($params as $name => $value) {
$output .= ' ' . $name . '="' . $value . '"';
}
$output .= "/>";
return $output;
}
示例10: smarty_function_yuimenu
/**
* Smarty {yuimenu} function plugin
*
* Type: function<br>
* Name: yuimenu<br>
* Purpose: display a yui menu
*
* @param $params
* @param \Smarty $smarty
* @return bool
*/
function smarty_function_yuimenu($params, &$smarty)
{
$menu = '
function buildmenu () {
var oMenuSidenavJs = new YAHOO.widget.Menu("' . $params['buildon'] . '", {
position: "static",
hidedelay: 100,
lazyload: true });
var aSubmenuData = ' . navigationmodule::navtojson() . ';
oMenuSidenavJs.subscribe("beforeRender", function () {
if (this.getRoot() == this) {
for (i=0; i<=this.getItems().length; i++){
var j=i;
// console.debug(aSubmenuData[j].itemdata.length);
if (aSubmenuData[j].itemdata.length>0){
this.getItem(i).cfg.setProperty("submenu", aSubmenuData[j]);
}
}
}
});
oMenuSidenavJs.render();
}
YAHOO.util.Event.onDOMReady(buildmenu);
';
expJavascript::pushToFoot(array("unique" => "yuimenubar-" . $params['buildon'], "yui2mods" => "menu", "yui3mods" => $smarty->getTemplateVars('__name'), "content" => $menu, "src" => ""));
}
示例11: smarty_compiler_translateStatic
function smarty_compiler_translateStatic($params, Smarty $smarty)
{
/** @var CM_Frontend_Render $render */
$render = $smarty->getTemplateVars('render');
$key = eval('return ' . $params['key'] . ';');
return $render->getTranslation($key);
}
示例12: smarty_function_disable_view_cache
/**
* Simple smarty function to disable View caching of the current page
*
* @param array $params Associative (and/or indexed) array of smarty parameters passed in from the template
* @param Smarty $smarty Parent Smarty template object
*
* @return string
*/
function smarty_function_disable_view_cache($params, $smarty){
$tmpl = $smarty->getTemplateVars('__core_template');
$view = ($tmpl instanceof \Core\Templates\TemplateInterface) ? $tmpl->getView() : \Core\view();
$view->disableCache();
}
示例13: fromSmarty
/**
* @param \Smarty $smarty
* @return \MistyForms\FormBlock
*/
public static function fromSmarty($smarty)
{
$vars = $smarty->getTemplateVars();
if (!isset($vars[self::VIEW_KEY])) {
throw new ConfigurationException('The form is missing. This is probably a bug');
}
return $vars[self::VIEW_KEY];
}
示例14: smarty_function_head
/**
* @todo Finish documentation of smarty_function_head
* @param array $params Associative (and/or indexed) array of smarty parameters passed in from the template
* @param Smarty $smarty Parent Smarty template object
*
* @return string
*/
function smarty_function_head($params, $smarty){
$tmpl = $smarty->getTemplateVars('__core_template');
$view = ($tmpl instanceof \Core\Templates\TemplateInterface) ? $tmpl->getView() : \Core\view();
// Load any head elements currently in the CurrentPage cache
return $view->getHeadContent();
}
示例15: smarty_function_getchromemenu
/**
* Smarty {getchromemenu} function plugin
*
* Type: function<br>
* Name: getchromemenu<br>
* Purpose: display the chrome menu
*
* @param $params
* @param \Smarty $smarty
* @return bool
*/
function smarty_function_getchromemenu($params, &$smarty)
{
global $router, $user;
$cloc = $smarty->getTemplateVars('__loc');
$module = $params['module'];
$list = '<ul class="container-menu">';
$list .= '<li class="container-info">' . $module->action . ' / ' . str_replace($module->action . '_', '', $module->view) . '</li>';
if (!empty($params['rank']) && expPermissions::check('order_modules', $cloc)) {
$uplink = $router->makeLink(array('module' => 'containermodule', 'src' => $cloc->src, 'action' => 'order', 'a' => $params['rank'] - 2, 'b' => $params['rank'] - 1));
$downlink = $router->makeLink(array('module' => 'containermodule', 'src' => $cloc->src, 'action' => 'order', 'a' => $params['rank'] - 1, 'b' => $params['rank']));
if ($params['rank'] != 1) {
//dont show this up arrow if it's the first module in a container
$list .= '<li><a href="' . $uplink . '" class="mod-up">' . gt("Move Module Up") . '</a></li>';
}
if (!$params['last']) {
//if this is the last module in a container don't show down arrow.
$list .= '<li><a href="' . $downlink . '" class="mod-down">' . gt("Move Module Down") . '</a></li>';
}
}
$rerank = $params['rerank'];
if ($rerank == 'false') {
$rerank = 0;
} else {
$rerank = 1;
}
if ($user->isAdmin()) {
$userlink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'userperms', '_common' => 1));
$grouplink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'groupperms', '_common' => 1));
$list .= '<li><a href="' . $userlink . '" class="user">' . gt("User Permissions") . '</a></li>';
$list .= '<li><a href="' . $grouplink . '" class="group">' . gt("Group Permissions") . '</a></li>';
}
if (!empty($module->id) && expPermissions::check('edit_module', $cloc) && $module->permissions['administrate'] == 1) {
$editlink = $router->makeLink(array('module' => 'containermodule', 'id' => $module->id, 'action' => 'edit', 'src' => $module->info['source']));
$list .= '<li><a href="' . $editlink . '" class="config-view">' . gt("Configure Action") . " & " . gt("View") . '</a></li>';
}
if ($module->permissions['configure'] == 1) {
if (expModules::controllerExists($module->info['class'])) {
$configlink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'configure', 'hcview' => $module->view));
$list .= '<li><a href="' . $configlink . '" class="config-mod">' . gt("Configure Settings") . '</a></li>';
} elseif ($module->info['hasConfig']) {
$configlink = $router->makeLink(array('module' => $module->info['class'], 'src' => $module->info['source'], 'action' => 'configure', '_common' => 1));
$list .= '<li><a href="' . $configlink . '" class="config-mod">' . gt("Configure Settings") . '</a></li>';
}
}
if (!empty($module->id) && expPermissions::check('delete_module', $cloc)) {
$deletelink = $router->makeLink(array('module' => 'containermodule', 'id' => $module->id, 'action' => 'delete', 'rerank' => $rerank));
$list .= '<li><a href="' . $deletelink . '" class="delete" onclick="alert(\'' . gt("This content is being sent to the Recycle Bin to be recovered later if you wish.") . '\')">' . gt("Remove Module") . '</a></li>';
}
if (HELP_ACTIVE) {
$helplink = help::makeHelpLink(expModules::getControllerName($module->info['class']));
$list .= '<li><a href="' . $helplink . '" class="helplink" target="_blank">' . gt("Get Help") . '</a></li>';
}
$list .= '</ul>';
expCSS::pushToHead(array("unique" => "container-chrome", "link" => PATH_RELATIVE . "framework/modules/container/assets/css/admin-container.css"));
expJavascript::pushToFoot(array("unique" => 'container-chrome', "yui3mods" => 'node', "src" => PATH_RELATIVE . "framework/core/assets/js/exp-container.js"));
echo $list;
}