当前位置: 首页>>代码示例>>PHP>>正文


PHP Smarty_Internal_Template::getTemplateVars方法代码示例

本文整理汇总了PHP中Smarty_Internal_Template::getTemplateVars方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty_Internal_Template::getTemplateVars方法的具体用法?PHP Smarty_Internal_Template::getTemplateVars怎么用?PHP Smarty_Internal_Template::getTemplateVars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Smarty_Internal_Template的用法示例。


在下文中一共展示了Smarty_Internal_Template::getTemplateVars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_block_image

/**
 * Image block
 *
 * @param array $params
 * @param string $content
 * @param Smarty_Internal_Template $smarty
 * @param bool $repeat
 * @return void
 */
function smarty_block_image(array $params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
    if (!$repeat) {
        $content = $smarty->getTemplateVars('image') ? $content : '';
        $smarty->assign('image', null);
        return $content;
    }
    if (!array_key_exists('rendition', $params)) {
        throw new \InvalidArgumentException("Rendition not set");
    }
    $renditions = Zend_Registry::get('container')->getService('image.rendition')->getRenditions();
    if (!array_key_exists($params['rendition'], $renditions)) {
        throw new \InvalidArgumentException("Unknown rendition");
    }
    $article = $smarty->getTemplateVars('gimme')->article;
    if (!$article) {
        throw new \RuntimeException("Not in article context.");
    }
    $articleRenditions = $article->getRenditions();
    $articleRendition = $articleRenditions[$renditions[$params['rendition']]];
    if ($articleRendition === null) {
        $smarty->assign('image', false);
        $repeat = false;
        return;
    }
    if (array_key_exists('width', $params) && array_key_exists('height', $params)) {
        $preview = $articleRendition->getRendition()->getPreview($params['width'], $params['height']);
        $thumbnail = $preview->getThumbnail($articleRendition->getImage(), Zend_Registry::get('container')->getService('image'));
    } else {
        $thumbnail = $articleRendition->getRendition()->getThumbnail($articleRendition->getImage(), Zend_Registry::get('container')->getService('image'));
    }
    $smarty->assign('image', (object) array('src' => Zend_Registry::get('view')->url(array('src' => $thumbnail->src), 'image', true, false), 'width' => $thumbnail->width, 'height' => $thumbnail->height, 'caption' => $articleRendition->getImage()->getCaption(), 'photographer' => $articleRendition->getImage()->getPhotographer()));
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:42,代码来源:block.image.php

示例2: smarty_block_menuItem

/**
 * Smarty block plugin, for generating page menu item
 * This block must always be called in pageMenu block context
 *
 * @param array $params
 * @param Smarty $smarty
 * @param $repeat
 *
 * <code>
 *	{pageMenu id="menu"}
 *		{menuItem}
 *			{menuCaption}Click Me{/menuCaption}
 *			{menuAction}http://click.me.com{/menuAction}
 *		{/menuItem}
 *		{menuItem}
 *			{menuCaption}Another menu item{/menuCaption}
 *			{pageAction}alert('Somebody clicked on me too!'){/menuAction}
 *		{/menuItem}
 *  {/pageMenu}
 * </code>
 *
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_block_menuItem($params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
    if ($repeat) {
        $smarty->clear_assign('menuCaption');
        $smarty->clear_assign('menuAction');
        $smarty->clear_assign('menuPageAction');
    } else {
        $item = new HtmlElement('a');
        if ($smarty->getTemplateVars('menuAction')) {
            $href = $smarty->getTemplateVars('menuAction');
        } else {
            if ($smarty->getTemplateVars('menuPageAction')) {
                $onClick = $smarty->getTemplateVars('menuPageAction');
                $href = '#';
                $item->setAttribute('onClick', $onClick . '; return false;');
            }
        }
        $item->setAttribute('href', $href);
        // EXPERIMENTAL - set access key for menu item
        $caption = $smarty->getTemplateVars('menuCaption');
        if (FALSE != strpos($caption, '&&')) {
            $p = strpos($caption, '&&');
            $accessKey = substr($caption, $p + 2, 1);
            $item->setAttribute('accessKey', $accessKey);
            $caption = substr($caption, 0, $p + 3) . '</span>' . substr($caption, $p + 3);
            $caption = substr($caption, 0, $p) . '<span class="accessKey">' . substr($caption, $p + 2);
        }
        $item->setContent($caption);
        $smarty->append('pageMenuItems', $item->render());
    }
}
开发者ID:saiber,项目名称:livecart,代码行数:55,代码来源:block.menuItem.php

示例3: smarty_block_fis_widget

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);
            }
        }
    }
}
开发者ID:drehere,项目名称:shenmegui,代码行数:27,代码来源:block.fis_widget.php

示例4: smarty_function_getdatatablerow

/**
 * PixelManager CMS (Community Edition)
 * Copyright (C) 2016 PixelProduction (http://www.pixelproduction.de)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
function smarty_function_getdatatablerow($params, Smarty_Internal_Template $template)
{
    if (!isset($params['class']) || !isset($params['var']) || !isset($params['row'])) {
        return;
    }
    if (isset($params['page'])) {
        $page_id = $params['page'];
    } else {
        $page_id = $template->getTemplateVars('pageId');
    }
    if (isset($params['language'])) {
        $language_id = $params['language'];
    } else {
        $language_id = $template->getTemplateVars('languageId');
        if ($language_id === null) {
            $language_id = Config::get()->languages->standard;
        }
    }
    $data = array();
    if (isset($params['row'])) {
        $data_table = new $params['class']();
        $data = $data_table->getRowForFrontend($params['row'], $page_id, $language_id);
    }
    if (isset($params['var'])) {
        $template->assign($params['var'], $data);
    }
}
开发者ID:pixelproduction,项目名称:PixelManagerCMS,代码行数:44,代码来源:function.getdatatablerow.php

示例5: smarty_block_header

/**
 * Display page section header and footer only if content is present
 * This helps to avoid using redundant if's
 *
 * @param array $params
 * @param Smarty $smarty
 * @param $repeat
 *
 * <code>
 *	{sect}
 *		{header}
 *			Section header
 *		{/header}
 *		{content}
 *			Section content
 *		{/content}
 *		{footer}
 *			Section footer
 *		{/footer}
 *  {/sect}
 * </code>
 *
 * @return string Section HTML code
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_block_header($params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
    if (!$repeat) {
        $counter = $smarty->getTemplateVars('sectCounter');
        $blocks = $smarty->getTemplateVars('sect');
        $blocks[$counter]['header'] = $content;
        $smarty->assign('sect', $blocks);
    }
}
开发者ID:saiber,项目名称:livecart,代码行数:35,代码来源:block.header.php

示例6: smarty_function_input

/**
 * Renders an input in smarty.
 *
 * @param string[] $params
 * @param Smarty_Internal_Template $template
 * @return string
 */
function smarty_function_input($params, Smarty_Internal_Template $template)
{
    $name = $params['name'];
    $form = $template->smarty->getForm("Form_" . $template->getTemplateVars("currentForm"));
    $element = $form->get($name);
    $view = $form->createView();
    $renderer = $template->getFormRenderer();
    $c = $renderer->renderInput($element, "Form_" . $template->getTemplateVars("currentForm"), $params);
    return $c;
}
开发者ID:skelpo,项目名称:framework,代码行数:17,代码来源:function.input.php

示例7: smarty_function_pageurl

function smarty_function_pageurl($params, Smarty_Internal_Template $template)
{
    $output = '';
    if (isset($params['page'])) {
        if (isset($params['language'])) {
            $language_id = $params['language'];
        } else {
            $language_id = $template->getTemplateVars('languageId');
            if ($language_id === null) {
                $language_id = Config::get()->languages->standard;
            }
        }
        $mixed_id = $params['page'];
        $page_id = false;
        $pages = new Pages();
        if (is_int($mixed_id)) {
            $page_id = $mixed_id;
        } else {
            if (is_numeric($mixed_id)) {
                $page_id = (int) $mixed_id;
            } else {
                if (is_string($mixed_id)) {
                    $page_id = $pages->getPageIdByUniqueId($mixed_id);
                }
            }
        }
        if ($page_id !== false) {
            $output = $pages->getPageUrl($page_id, $language_id);
        }
    }
    return $output;
}
开发者ID:pixelproduction,项目名称:PixelManagerCMS,代码行数:32,代码来源:function.pageurl.php

示例8: smarty_function_metricsfield

/**
 *
 * @package application.helper.smarty.form
 * @author Integry Systems
 */
function smarty_function_metricsfield($params, Smarty_Internal_Template $smarty)
{
    if (empty($params['name'])) {
        $params['name'] = $smarty->getTemplateVars('input_name');
    }
    $formParams = $smarty->_tag_stack[0][1];
    $formHandler = $formParams['handle'];
    if (!isset($params['value']) && !$formHandler instanceof Form) {
        throw new HelperException('Element must be placed in {form} block');
    }
    if (!empty($formParams['model'])) {
        $params['ng-model'] = $formParams['model'] . '.' . $params['name'];
    }
    $application = $smarty->getApplication();
    $params['m_sw'] = $application->translate('_switch_to_english_units');
    $params['en_sw'] = $application->translate('_switch_to_metric_units');
    $params['m_hi'] = $application->translate('_units_kg');
    $params['m_lo'] = $application->translate('_units_g');
    $params['en_hi'] = $application->translate('_units_lbs');
    $params['en_lo'] = $application->translate('_units_oz');
    $params['type'] = strtolower($application->getConfig()->get('UNIT_SYSTEM'));
    $content = '<weight-input ' . $smarty->appendParams($content, $params) . '></weight-input>';
    $content = $smarty->formatControl($content, $params);
    return $content;
}
开发者ID:saiber,项目名称:livecart,代码行数:30,代码来源:function.metricsfield.php

示例9: smarty_block_image

/**
 * Image block
 *
 * @param array $params
 * @param string $content
 * @param Smarty_Internal_Template $smarty
 * @param bool $repeat
 * @return void
 */
function smarty_block_image(array $params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
    if (!$repeat) {
        $content = $smarty->getTemplateVars('image') ? $content : '';
        $smarty->assign('image', null);
        return $content;
    }
    if (!array_key_exists('rendition', $params)) {
        throw new \InvalidArgumentException("Rendition not set");
    }
    $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
    $renditionService = \Zend_Registry::get('container')->getService('image.rendition');
    $cacheKey = $cacheService->getCacheKey(array('theme_renditions'), 'theme');
    if ($cacheService->contains($cacheKey)) {
        $renditions = $cacheService->fetch($cacheKey);
    } else {
        $renditions = $renditionService->getRenditions();
        $cacheService->save($cacheKey, $renditions);
    }
    if (!array_key_exists($params['rendition'], $renditions)) {
        throw new \InvalidArgumentException("Unknown rendition");
    }
    $article = $smarty->getTemplateVars('gimme')->article;
    if (!$article) {
        throw new \RuntimeException("Not in article context.");
    }
    $articleRenditions = $article->getRenditions();
    $articleRendition = $articleRenditions[$renditions[$params['rendition']]];
    if ($articleRendition === null) {
        $smarty->assign('image', false);
        $repeat = false;
        return;
    }
    $image = null;
    if (array_key_exists('width', $params) && array_key_exists('height', $params)) {
        $image = $renditionService->getArticleRenditionImage($article->number, $params['rendition'], $params['width'], $params['height']);
    } else {
        $image = $renditionService->getArticleRenditionImage($article->number, $params['rendition']);
    }
    $imageService = \Zend_Registry::get('container')->getService('image');
    $preferencesService = \Zend_Registry::get('container')->getService('preferences');
    $caption = $imageService->getCaption($articleRendition->getImage(), $article->number, $article->language->number);
    if ($preferencesService->get('MediaRichTextCaptions', 'N') == 'N') {
        $caption = MetaDbObject::htmlFilter($caption);
    }
    $smarty->assign('image', (object) array('src' => \Zend_Registry::get('view')->url(array('src' => $image['src']), 'image', true, false), 'width' => $image['width'], 'height' => $image['height'], 'caption' => $caption, 'description' => $articleRendition->getImage()->getDescription(), 'photographer' => $articleRendition->getImage()->getPhotographer(), 'original' => $image['original']));
}
开发者ID:sourcefabric,项目名称:newscoop,代码行数:56,代码来源:block.image.php

示例10: smarty_block_sect

/**
 * Display page section header and footer only if content is present
 * This helps to avoid using redundant if's
 *
 * @param array $params
 * @param Smarty $smarty
 * @param $repeat
 *
 * <code>
 *	{sect}
 *		{header}
 *			Section header
 *		{/header}
 *		{content}
 *			Section content
 *		{/content}
 *		{footer}
 *			Section footer
 *		{/footer}
 *  {/sect}
 * </code>
 *
 * @return string Section HTML code
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_block_sect($params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
    $counter = $smarty->getTemplateVars('sectCounter');
    if ($repeat) {
        $counter++;
        $smarty->assign('sectCounter', $counter);
        $sections = $smarty->getTemplateVars('sect');
        $sections[$counter] = array('header' => '', 'content' => '', 'footer' => '');
        $smarty->assign('sect', $sections);
    } else {
        $blocks = $smarty->getTemplateVars('sect');
        $blocks = $blocks[$counter];
        $counter--;
        $smarty->assign('sectCounter', $counter);
        if (trim($blocks['content'])) {
            return $blocks['header'] . $blocks['content'] . $blocks['footer'];
        }
    }
}
开发者ID:saiber,项目名称:livecart,代码行数:45,代码来源:block.sect.php

示例11: smarty_function_numberDecimal

function smarty_function_numberDecimal(array $params, Smarty_Internal_Template $template)
{
    $value = $params['value'];
    if (!is_numeric($value)) {
        throw new CM_Exception_Invalid('Invalid non-numeric value');
    }
    /** @var CM_Frontend_Render $render */
    $render = $template->getTemplateVars('render');
    $formatter = new NumberFormatter($render->getLocale(), NumberFormatter::DECIMAL);
    return $formatter->format($value);
}
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:function.numberDecimal.php

示例12: smarty_block_label

/**
 * Form field row
 *
 * @package application.helper.smarty
 * @author Integry Systems
 *
 * @package application.helper.smarty
 */
function smarty_block_label($params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
    if (!$repeat) {
        $class = $smarty->getTemplateVars('last_fieldType') . ' ' . $params['class'];
        if (strpos($class, 'checkbox') === false) {
            $class = 'control-label col-lg-2 ' . $class;
        }
        $for = empty($params['for']) ? '' : ' for="' . $params['for'] . '"';
        $content = '<label class="' . $class . '"' . $for . '>' . $content . '</label>';
        return $content;
    }
}
开发者ID:saiber,项目名称:livecart,代码行数:20,代码来源:block.label.php

示例13: smarty_function_chess_fugure

function smarty_function_chess_fugure($params, Smarty_Internal_Template &$template)
{
    // Постановка фигуры на доску
    $x = $params['x'];
    $y = $params['y'];
    $value = '';
    $figure = '';
    $data = array();
    $class = array();
    if ($y == 0 || $y == 9) {
        switch ($x) {
            case 1:
                $value = 'A';
                break;
            case 2:
                $value = 'B';
                break;
            case 3:
                $value = 'C';
                break;
            case 4:
                $value = 'D';
                break;
            case 5:
                $value = 'E';
                break;
            case 6:
                $value = 'F';
                break;
            case 7:
                $value = 'G';
                break;
            case 8:
                $value = 'H';
                break;
        }
    } else {
        if ($x == 0 || $x == 9) {
            $value = $y;
        } else {
            $class[] = ($x + $y) % 2 == 0 ? 'even' : 'odd';
            $figs = $template->getTemplateVars('figures');
            $pos = $x . $y;
            //Позиция фигуры, например a6
            if (is_array($figs) && array_key_exists($pos, $figs)) {
                $figure = $figs[$pos];
                $value = "<span class=\"{$figure}\"></span>";
            }
        }
    }
    return PsHtml::html2('td', array('class' => $class), $value);
}
开发者ID:ilivanoff,项目名称:www,代码行数:52,代码来源:function.chess_fugure.php

示例14: smarty_block_pageMenu

/**
 * Smarty block plugin, for generating page menus
 *
 * @param array $params
 * @param Smarty $smarty
 * @param $repeat
 *
 * <code>
 *	{pageMenu id="menu"}
 *		{menuItem}
 *			{menuCaption}Click Me{/menuCaption}
 *			{menuAction}http://click.me.com{/menuAction}
 *		{/menuItem}
 *		{menuItem}
 *			{menuCaption}Another menu item{/menuCaption}
 *			{pageAction}alert('Somebody clicked on me too!'){/menuAction}
 *		{/menuItem}
 *  {/pageMenu}
 * </code>
 *
 * @return string Menu HTML code
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_block_pageMenu($params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
    if ($repeat) {
        $smarty->clear_assign('pageMenuItems');
    } else {
        $items = $smarty->getTemplateVars('pageMenuItems');
        $menuDiv = new HtmlElement('div');
        $menuDiv->setAttribute('id', $params['id']);
        $menuDiv->setAttribute('tabIndex', 1);
        $menuDiv->setContent(implode(' | ', $items));
        return $menuDiv->render();
    }
}
开发者ID:saiber,项目名称:livecart,代码行数:37,代码来源:block.pageMenu.php

示例15: smarty_function_getdatatablesomerows

/**
 * PixelManager CMS (Community Edition)
 * Copyright (C) 2016 PixelProduction (http://www.pixelproduction.de)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
function smarty_function_getdatatablesomerows($params, Smarty_Internal_Template $template)
{
    if (!isset($params['class']) || !isset($params['var']) || !isset($params['rows'])) {
        return;
    }
    if (isset($params['page'])) {
        $page_id = $params['page'];
    } else {
        $page_id = $template->getTemplateVars('pageId');
    }
    if (isset($params['language'])) {
        $language_id = $params['language'];
    } else {
        $language_id = $template->getTemplateVars('languageId');
        if ($language_id === null) {
            $language_id = Config::get()->languages->standard;
        }
    }
    // Sicherstellen, dass $id_list auch wirklich ein Array ist
    // es ist auch möglich, einen kommaseparierten String zu übergeben
    $id_list = $params['rows'];
    if (!is_array($id_list)) {
        if (is_numeric($id_list)) {
            $id_list = array(intval($id_list));
        } else {
            $id_list = strval($id_list);
            $id_list = explode(',', $id_list);
            if (count($id_list) > 0) {
                foreach ($id_list as &$row_id) {
                    $row_id = intval(trim($row_id));
                }
            }
        }
    }
    $data_table = new $params['class']();
    $data = $data_table->getSomeRowsForFrontend($id_list, $page_id, $language_id);
    $template->assign($params['var'], $data);
}
开发者ID:pixelproduction,项目名称:PixelManagerCMS,代码行数:55,代码来源:function.getdatatablesomerows.php


注:本文中的Smarty_Internal_Template::getTemplateVars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。