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


PHP TikiLib::contextualizeKey方法代碼示例

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


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

示例1: smarty_function_icon

function smarty_function_icon($params, $smarty)
{
    if (!is_array($params)) {
        $params = array();
    }
    global $prefs, $tc_theme, $tc_theme_option, $url_path, $base_url, $tikipath, $iconset;
    $cachelib = TikiLib::lib('cache');
    if (empty($tc_theme)) {
        $current_theme = !empty($prefs['theme']) ? $prefs['theme'] : '';
        $current_theme_option = isset($prefs['theme_option']) ? $prefs['theme_option'] : '';
    } else {
        $current_theme = $tc_theme;
        $current_theme_option = !empty($tc_theme_option) ? $tc_theme_option : '';
    }
    if (isset($params['_type'])) {
        if ($params['_type'] === 'absolute_uri') {
            $params['path_prefix'] = $base_url;
        } else {
            if ($params['_type'] === 'absolute_path') {
                $params['path_prefix'] = $url_path;
            }
        }
    }
    $serialized_params = serialize(array_merge($params, array($current_theme, $current_theme_option, isset($_SERVER['HTTPS']))));
    $cache_key = TikiLib::contextualizeKey('icons_' . '_' . md5($serialized_params), 'language', 'external');
    if ($cached = $cachelib->getCached($cache_key)) {
        return $cached;
    }
    $basedirs = array('img/icons', 'img/icons/mime');
    $icons_extension = empty($params['_extension']) ? '.png' : '.' . $params['_extension'];
    $tag = 'img';
    $notag = false;
    $default_class = 'icon';
    $default_width = 16;
    $default_height = 16;
    $menu_text = false;
    $menu_icon = false;
    $confirm = '';
    $html = '';
    if (empty($params['_id'])) {
        if (isset($params['_defaultdir']) && $params['_defaultdir'] == 'img/icons/large') {
            $params['_id'] = 'green_question48x48';
        } else {
            $params['_id'] = 'green_question';
        }
    }
    if (!empty($params['_defaultdir'])) {
        array_unshift($basedirs, $params['_defaultdir']);
        if ($params['_defaultdir'] == 'img/icons/large') {
            $default_width = $default_height = strpos($params['_id'], '48x48') !== false ? 48 : 32;
        }
    }
    // ICONSET START, work-in-progress, more information: dev.tiki.org/icons. $iconset array is prepared by lib/setup/theme.php
    // N.B. In some contexts such as the console $iconset may not be set up
    if (!empty($params['name']) && empty($params['_tag']) && !empty($iconset)) {
        $name = $params['name'];
        $html = $iconset->getHtml($name, $params);
        $menu_text = isset($params['_menu_text']) && $params['_menu_text'] == 'y';
        if (!empty($params['href']) || !empty($params['title']) || $menu_text) {
            /* Generate a link for the icon if href or title (for tips) parameter is set.
             * This will produce a link element (<a>) around the icon.
             * If you want a button element (<button>), use the {button} smarty_tiki function */
            //collect link components
            if (!empty($params['title'])) {
                //add title if not empty
                $a_title = $params['title'];
            } elseif (!empty($params['alt'])) {
                $a_title = $params['alt'];
            } else {
                $a_title = '';
            }
            if (!empty($a_title)) {
                $title_attr = $menu_text ? '' : 'title="' . $a_title . '"';
            } else {
                $title_attr = '';
            }
            if (isset($params['class'])) {
                //if set, use these classes instead of the default bootstrap
                $a_class = $params['class'];
            } else {
                $a_class = 'btn btn-link';
                //the default classes to be used
            }
            if (!empty($params['href'])) {
                //use href if not empty
                $a_href = 'href="' . $params['href'] . '"';
            } else {
                $a_href = '';
            }
            if (isset($params['data-toggle'])) {
                //add data-toggle if set
                $a_datatoggle = 'data-toggle="' . $params['data-toggle'] . '"';
            } else {
                $a_datatoggle = '';
            }
            if (isset($params['onclick'])) {
                //add onclick if set
                $a_onclick = 'onclick="' . $params['onclick'] . '"';
            } else {
                $a_onclick = '';
//.........這裏部分代碼省略.........
開發者ID:rjsmelo,項目名稱:tiki,代碼行數:101,代碼來源:function.icon.php


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