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


PHP EBR::translate方法代碼示例

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


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

示例1: EasyBlogParseRoute

function EasyBlogParseRoute(&$segments)
{
    // Load site's language file
    EB::loadLanguages();
    $vars = array();
    $active = JFactory::getApplication()->getMenu()->getActive();
    $config = EB::config();
    // We know that the view=categories&layout=listings&id=xxx because there's only 1 segment
    // and the active menu is view=categories
    if (isset($active) && $active->query['view'] == 'categories' && !isset($active->query['layout']) && count($segments) == 1) {
        $vars['view'] = 'categories';
        $vars['layout'] = 'listings';
        $category = EB::table('Category');
        $category->load(array('alias' => $segments[0]));
        // if still can't get the correct category id try this
        if (!$category->id) {
            $categoryAlias = $segments[0];
            $categoryAlias = str_replace(':', '-', $categoryAlias);
            $category->load(array('alias' => $categoryAlias));
        }
        $vars['id'] = $category->id;
        return $vars;
    }
    // RSD View
    if (isset($segments[0]) && $segments[0] == 'rsd') {
        $vars['view'] = 'rsd';
        return $vars;
    }
    // Feed view
    if (isset($segments[1])) {
        if ($segments[1] == 'rss' || $segments[1] == 'atom') {
            $vars['view'] = $segments[0];
            unset($segments);
            return $vars;
        }
    }
    // If user chooses to use the simple sef setup, we need to add the proper view
    if ($config->get('main_sef') == 'simple' && count($segments) == 1) {
        $files = JFolder::folders(JPATH_ROOT . '/components/com_easyblog/views');
        $views = array();
        foreach ($files as $file) {
            $views[] = EBR::translate($file);
        }
        if (!in_array($segments[0], $views)) {
            array_unshift($segments, EBR::translate('entry'));
        }
    }
    // Composer view
    if (isset($segments[0]) && $segments[0] == EBR::translate('composer')) {
        $vars['view'] = 'composer';
    }
    // Entry view
    if (isset($segments[0]) && $segments[0] == EBR::translate('entry')) {
        $count = count($segments);
        $entryId = '';
        // perform manual split on the string.
        if ($config->get('main_sef_unicode')) {
            $permalinkSegment = $segments[$count - 1];
            $permalinkArr = explode(':', $permalinkSegment);
            $entryId = $permalinkArr[0];
        } else {
            $index = $count - 1;
            $alias = $segments[$index];
            $post = EB::post();
            $post->loadByPermalink($alias);
            if ($post) {
                $entryId = $post->id;
            }
        }
        if ($entryId) {
            $vars['id'] = $entryId;
        }
        $vars['view'] = 'entry';
    }
    // Calendar view
    if (isset($segments[0]) && $segments[0] == EBR::translate('calendar')) {
        $vars['view'] = 'calendar';
        $count = count($segments);
        $totalSegments = $count - 1;
        if ($totalSegments >= 1) {
            // First segment is always the year
            if (isset($segments[1])) {
                $vars['year'] = $segments[1];
            }
            // Second segment is always the month
            if (isset($segments[2])) {
                $vars['month'] = $segments[2];
            }
            // Third segment is always the day
            if (isset($segments[3])) {
                $vars['day'] = $segments[3];
            }
        }
    }
    if (isset($segments[0]) && $segments[0] == EBR::translate('archive')) {
        $vars['view'] = 'archive';
        $count = count($segments);
        $totalSegments = $count - 1;
        if ($totalSegments >= 1) {
            $indexSegment = 1;
//.........這裏部分代碼省略.........
開發者ID:BetterBetterBetter,項目名稱:B3App,代碼行數:101,代碼來源:router.php


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