當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。