當前位置: 首頁>>代碼示例>>PHP>>正文


PHP unknown_type::get_template_vars方法代碼示例

本文整理匯總了PHP中unknown_type::get_template_vars方法的典型用法代碼示例。如果您正苦於以下問題:PHP unknown_type::get_template_vars方法的具體用法?PHP unknown_type::get_template_vars怎麽用?PHP unknown_type::get_template_vars使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在unknown_type的用法示例。


在下文中一共展示了unknown_type::get_template_vars方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: smarty_function_sugar_replace_vars

/**
 * This function will replace fields taken from the fields variable
 * and insert them into the passed string replacing [variableName] 
 * tokens where found.
 *
 * @param unknown_type $params
 * @param unknown_type $smarty
 * @return unknown
 */
function smarty_function_sugar_replace_vars($params, &$smarty)
{
    if (empty($params['subject'])) {
        $smarty->trigger_error("sugarvar: missing 'subject' parameter");
        return;
    }
    $fields = $smarty->get_template_vars('fields');
    $subject = $params['subject'];
    $matches = array();
    $count = preg_match_all('/\\[([^\\]]*)\\]/', $subject, $matches);
    for ($i = 0; $i < $count; $i++) {
        $match = $matches[1][$i];
        if (!empty($fields[$match]) && isset($fields[$match]['value'])) {
            $value = $fields[$match]['value'];
            if (isset($fields[$match]['type']) && $fields[$match]['type'] == 'enum' && isset($fields[$match]['options']) && isset($fields[$match]['options'][$value])) {
                $subject = str_replace($matches[0][$i], $fields[$match]['options'][$value], $subject);
            } else {
                $subject = str_replace($matches[0][$i], $value, $subject);
            }
        }
    }
    if (!empty($params['assign'])) {
        $smarty->assign($params['assign'], $subject);
        return '';
    }
    return $subject;
}
開發者ID:klr2003,項目名稱:sourceread,代碼行數:36,代碼來源:function.sugar_replace_vars.php

示例2: smarty_function_sugar_replace_vars

/**
 * This function will replace fields taken from the fields variable
 * and insert them into the passed string replacing [variableName] 
 * tokens where found.
 *
 * @param unknown_type $params
 * @param unknown_type $smarty
 * @return unknown
 */
function smarty_function_sugar_replace_vars($params, &$smarty)
{
    if (empty($params['subject'])) {
        $smarty->trigger_error("sugarvar: missing 'subject' parameter");
        return;
    }
    $fields = empty($params['fields']) ? $smarty->get_template_vars('fields') : $params['fields'];
    $lDelim = "[";
    $rDelim = "]";
    if ($params['use_curly']) {
        $lDelim = "{";
        $rDelim = "}";
    }
    $subject = $params['subject'];
    $matches = array();
    $count = preg_match_all('/\\' . $lDelim . '([^\\' . $rDelim . ']*)\\' . $rDelim . '/', $subject, $matches);
    for ($i = 0; $i < $count; $i++) {
        $match = $matches[1][$i];
        //List views will have fields be an array where all the keys are upper case and the values are jsut strings
        if (!isset($fields[$match]) && isset($fields[strtoupper($match)])) {
            $match = strtoupper($match);
        }
        $value = isset($fields[$match]) ? $fields[$match] : null;
        if (!is_null($value)) {
            if (isset($value['function']['returns']) && $value['function']['returns'] == 'html') {
                $bean = $smarty->get_template_vars('bean');
                $value = $bean->{$match};
            } else {
                if (is_array($value) && isset($value['value'])) {
                    $value = $value['value'];
                }
            }
            if (isset($fields[$match]['type']) && $fields[$match]['type'] == 'enum' && isset($fields[$match]['options']) && isset($fields[$match]['options'][$value])) {
                $subject = str_replace($matches[0][$i], $fields[$match]['options'][$value], $subject);
            } else {
                $subject = str_replace($matches[0][$i], $value, $subject);
            }
        }
    }
    if (!empty($params['assign'])) {
        $smarty->assign($params['assign'], $subject);
        return '';
    }
    return $subject;
}
開發者ID:MexinaD,項目名稱:SuiteCRM,代碼行數:54,代碼來源:function.sugar_replace_vars.php

示例3: smarty_function_sugar_replace_vars

/**
 * This function will replace fields taken from the fields variable
 * and insert them into the passed string replacing [variableName] 
 * tokens where found.
 *
 * @param unknown_type $params
 * @param unknown_type $smarty
 * @return unknown
 */
function smarty_function_sugar_replace_vars($params, &$smarty)
{
    if (empty($params['subject'])) {
        $smarty->trigger_error("sugarvar: missing 'subject' parameter");
        return;
    }
    $fields = empty($params['fields']) ? $smarty->get_template_vars('fields') : $params['fields'];
    $subject = replace_sugar_vars($params['subject'], $fields, !empty($params['use_curly']));
    if (!empty($params['assign'])) {
        $smarty->assign($params['assign'], $subject);
        return '';
    }
    return $subject;
}
開發者ID:jglaine,項目名稱:sugar761-ent,代碼行數:23,代碼來源:function.sugar_replace_vars.php


注:本文中的unknown_type::get_template_vars方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。