/**
 * Smarty array2string modifier plugin
 * Type:     modifier<br>
 * Name:     array2string<br>
 * Purpose:  string to array
 *
 * @author FenghuiLee <*****@*****.**>
 *
 * @param array input array
 *
 * @return string
 */
function smarty_modifier_array2string($array)
{
    if ($string) {
        return ZUtils::array2string($array);
    }
    return null;
}
/**
 * Smarty string2array modifier plugin
 * Type:     modifier<br>
 * Name:     string2array<br>
 * Purpose:  string to array
 *
 * @author FenghuiLee <*****@*****.**>
 *
 * @param string input string
 *
 * @return array
 */
function smarty_modifier_string2array($string)
{
    if ($string) {
        return ZUtils::string2Array($string);
    }
    return array();
}
示例#3
0
/**
 * Smarty {imgurl} function plugin
 * Type:     function<br>
 * Name:     imgurl<br>
 * Purpose:  get a friendly url path
 *
 * @author FenghuiLee <*****@*****.**>
 *
 * @param array                    $params   parameters
 * @param Smarty_Internal_Template $template template object
 *
 * @return string|null
 */
function smarty_function_imgurl($params, $template)
{
    $url = !empty($params['url']) ? $params['url'] : null;
    $cover = !empty($params['cover']) ? $params['cover'] : null;
    if ($url && $cover) {
        $ext = ZUtils::getFileExtension($cover);
        return sprintf('/uploads/images/%s/%s.%s', substr(md5($cover), 0, 2), urlencode(base64_encode(urlencode($url . $cover))), $ext);
    }
    return null;
}