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


PHP Smarty_Internal_Template::appendParams方法代码示例

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


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

示例1: 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

示例2: smarty_function_textfield

/**
 * Renders text field
 *
 * If you wish to use autocomplete on a text field an additional parameter needs to be passed:
 *
 * <code>
 *	  autocomplete="controller=somecontroller field=fieldname"
 * </code>
 *
 * The controller needs to implement an autoComplete method, which must return the AutoCompleteResponse
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 *
 * @package application.helper.smarty.form
 * @author Integry Systems
 */
function smarty_function_textfield($params, Smarty_Internal_Template $smarty)
{
    if (empty($params['name'])) {
        $params['name'] = $smarty->getTemplateVars('input_name');
    }
    $smarty->assign('last_fieldType', 'textfield');
    $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 (!isset($params['type'])) {
        $params['type'] = 'text';
    }
    if (isset($params['ng_model'])) {
        $params['ng-model'] = $params['ng_model'];
        unset($params['ng_model']);
    } else {
        if (!empty($formParams['model'])) {
            $params['ng-model'] = $formParams['model'] . '.' . $params['name'];
        }
    }
    $params = $smarty->applyFieldValidation($params, $formHandler);
    // Check permissions
    if ($formParams['readonly']) {
        $params['readonly'] = 'readonly';
    }
    $value = array_pop(array_filter(array(isset($params['value']) ? $params['value'] : '', isset($params['default']) ? $params['default'] : '', $formHandler->get($fieldName))));
    unset($params['value'], $params['default']);
    if (isset($params['autocomplete']) && $params['autocomplete'] != 'off' && empty($params['id'])) {
        $params['id'] = uniqid();
    }
    if (!empty($params['placeholder'])) {
        $params['placeholder'] = $smarty->getApplication()->translate($params['placeholder']);
    }
    if (isset($params['autocomplete']) && $params['autocomplete'] != 'off') {
        $autocomplete = $params['autocomplete'];
        $params['autocomplete'] = 'off';
    }
    $content = '<input';
    $content = $smarty->appendParams($content, $params);
    $content .= ' value="' . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '"';
    $content .= '/>';
    $content = $smarty->formatControl($content, $params);
    if (!empty($autocomplete)) {
        $acparams = array();
        foreach (explode(' ', $params['autocomplete']) as $param) {
            list($p, $v) = explode('=', $param, 2);
            $acparams[$p] = $v;
        }
        $url = $smarty->getApplication()->getRouter()->createURL(array('controller' => $acparams['controller'], 'action' => 'autoComplete', 'query' => 'field=' . $acparams['field']), true);
        if (empty($acparams['field'])) {
            $acparams['field'] = 'query';
        }
        /*
        $content .= '<script type="text/javascript">
        				jQuery("#' . $params['id'] . '").typeahead({
        						source: function (query, process) {
        							return jQuery.get("' . $url . '", { ' . $acparams['field'] . ': query }, function (data) {
        								return process(jQuery.parseJSON(data));
        							});
        						}});
        			</script>';
        */
    }
    return $content;
}
开发者ID:saiber,项目名称:livecart,代码行数:86,代码来源:function.textfield.php


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