コード例 #1
0
function smarty_function_attrDefault($params, &$smarty)
{
    /*
        param default_request(string,required): name of request key, that if has been set, will be returned as
    					    default, request is always prefered over other methods
        param target(string,required): attribute target, should be "user" or "group" that attribute default
    				    would be seek in it
        param default_var(string,required): name of target attribute, that if has been set, will be returned as
    					    default, this is preffered after default_request
    					    target attributes are searched through target array as set it target parameter
    					    
        param default(string,optional): optional string that will be returned if none of other default values matched
    */
    $target_attrs = getTargetAttrsFromSmarty($smarty, $params["target"]);
    $default = isset($params["default"]) ? $params["default"] : "";
    return attrDefault($target_attrs, $params["default_var"], $params["default_request"], $default);
}
コード例 #2
0
ファイル: attr_lib.php プロジェクト: zeroleo12345/freeIBS
function getSelectedAttrFromSmartyParams(&$smarty, &$params)
{
    /* Get selected value of an attr, from smarty object and smarty params.
        This function is useful for smarty plugins that needs to get what is value of selected
    
        param default_request(string,optional): name of request key, that if has been set, will be returned as
    					    default, request is always prefered over other methods
    
        param target(string,optional): attribute target, should be "user" or "group" that attribute default
    				    would be seek in it
    
        param default_var(string,optional): name of target attribute, that if has been set, will be returned as
    					    default, this is preffered after default_request
    					    target attributes are searched through target array as set it target parameter
    
    
        param default_smarty(string,optional): name of smarty variable that if has been set will be set after above 
    					    conditions failed
    
        param default(string,optional): optional string that will be returned if none of other default values matched
    */
    if (isset($params["default_var"]) and isset($params["default_request"]) and isset($params["target"])) {
        $selected = attrDefault(getTargetAttrsFromSmarty($smarty, $params["target"]), $params["default_var"], $params["default_request"]);
    } else {
        if (isset($params["default_request"]) and isInRequest($params["default_request"])) {
            $selected = $_REQUEST[$params["default_request"]];
        } else {
            if (isset($params["default_smarty"]) and $smarty->is_assigned($params["default_smarty"])) {
                $selected = $smarty->get_assigned_value($params["default_smarty"]);
            } else {
                if (isset($params["default"])) {
                    $selected = $params["default"];
                } else {
                    $selected = "";
                }
            }
        }
    }
    return $selected;
}