当前位置: 首页>>代码示例>>PHP>>正文


PHP JLanguageMultilang::getSiteLangs方法代码示例

本文整理汇总了PHP中JLanguageMultilang::getSiteLangs方法的典型用法代码示例。如果您正苦于以下问题:PHP JLanguageMultilang::getSiteLangs方法的具体用法?PHP JLanguageMultilang::getSiteLangs怎么用?PHP JLanguageMultilang::getSiteLangs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JLanguageMultilang的用法示例。


在下文中一共展示了JLanguageMultilang::getSiteLangs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: displayAssociations

 /**
  * Method to display in frontend the associations for a given article
  *
  * @param   integer  $id  Id of the article
  *
  * @return  array   An array containing the association URL and the related language object
  *
  * @since  __DEPLOY_VERSION__
  */
 public static function displayAssociations($id)
 {
     $return = array();
     if ($associations = self::getAssociations($id)) {
         $levels = JFactory::getUser()->getAuthorisedViewLevels();
         $languages = JLanguageHelper::getLanguages();
         foreach ($languages as $language) {
             // Do not display language when no association
             if (empty($associations[$language->lang_code])) {
                 continue;
             }
             // Do not display language without frontend UI
             if (!array_key_exists($language->lang_code, JLanguageMultilang::getSiteLangs())) {
                 continue;
             }
             // Do not display language without specific home menu
             if (!array_key_exists($language->lang_code, JLanguageMultilang::getSiteHomePages())) {
                 continue;
             }
             // Do not display language without authorized access level
             if (isset($language->access) && $language->access && !in_array($language->access, $levels)) {
                 continue;
             }
             $return[$language->lang_code] = array('item' => $associations[$language->lang_code], 'language' => $language);
         }
     }
     return $return;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:37,代码来源:association.php

示例2: display

 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     require_once JPATH_COMPONENT . '/helpers/multilangstatus.php';
     $this->homes = MultilangstatusHelper::getHomes();
     $this->language_filter = JLanguageMultilang::isEnabled();
     $this->switchers = MultilangstatusHelper::getLangswitchers();
     $this->listUsersError = MultilangstatusHelper::getContacts();
     $this->contentlangs = MultilangstatusHelper::getContentlangs();
     $this->site_langs = JLanguageMultilang::getSiteLangs();
     $this->statuses = MultilangstatusHelper::getStatus();
     $this->homepages = JLanguageMultilang::getSiteHomePages();
     parent::display($tpl);
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:20,代码来源:view.html.php

示例3: display

 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     JLoader::register('MultilangstatusHelper', JPATH_ADMINISTRATOR . '/components/com_languages/helpers/multilangstatus.php');
     $this->homes = MultilangstatusHelper::getHomes();
     $this->language_filter = JLanguageMultilang::isEnabled();
     $this->switchers = MultilangstatusHelper::getLangswitchers();
     $this->listUsersError = MultilangstatusHelper::getContacts();
     $this->contentlangs = MultilangstatusHelper::getContentlangs();
     $this->site_langs = JLanguageMultilang::getSiteLangs();
     $this->statuses = MultilangstatusHelper::getStatus();
     $this->homepages = JLanguageMultilang::getSiteHomePages();
     parent::display($tpl);
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:20,代码来源:view.html.php

示例4: onAfterDispatch

 /**
  * Method to add alternative meta tags for associated menu items.
  *
  * @return  void
  *
  * @since   1.7
  */
 public function onAfterDispatch()
 {
     $doc = JFactory::getDocument();
     if ($this->app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') {
         $languages = $this->lang_codes;
         $homes = JLanguageMultilang::getSiteHomePages();
         $menu = $this->app->getMenu();
         $active = $menu->getActive();
         $levels = JFactory::getUser()->getAuthorisedViewLevels();
         $remove_default_prefix = $this->params->get('remove_default_prefix', 0);
         $server = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
         $is_home = false;
         if ($active) {
             $active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false);
             $current_link = JUri::getInstance()->toString(array('path', 'query'));
             // Load menu associations
             if ($active_link == $current_link) {
                 $associations = MenusHelper::getAssociations($active->id);
             }
             // Check if we are on the homepage
             $is_home = $active->home && ($active_link == $current_link || $active_link == $current_link . 'index.php' || $active_link . '/' == $current_link);
         }
         // Load component associations.
         $option = $this->app->input->get('option');
         $cName = JString::ucfirst(JString::str_ireplace('com_', '', $option)) . 'HelperAssociation';
         JLoader::register($cName, JPath::clean(JPATH_COMPONENT_SITE . '/helpers/association.php'));
         if (class_exists($cName) && is_callable(array($cName, 'getAssociations'))) {
             $cassociations = call_user_func(array($cName, 'getAssociations'));
         }
         // For each language...
         foreach ($languages as $i => &$language) {
             switch (true) {
                 // Language without frontend UI || Language without specific home menu || Language without authorized access level
                 case !array_key_exists($i, JLanguageMultilang::getSiteLangs()):
                 case !isset($homes[$i]):
                 case isset($language->access) && $language->access && !in_array($language->access, $levels):
                     unset($languages[$i]);
                     break;
                     // Home page
                 // Home page
                 case $is_home:
                     $language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $homes[$i]->id);
                     break;
                     // Current language link
                 // Current language link
                 case $i == $this->current_lang:
                     $language->link = JUri::getInstance()->toString(array('path', 'query'));
                     break;
                     // Component association
                 // Component association
                 case isset($cassociations[$i]):
                     $language->link = JRoute::_($cassociations[$i] . '&lang=' . $language->sef);
                     break;
                     // Menu items association
                     // Heads up! "$item = $menu" here below is an assignment, *NOT* comparison
                 // Menu items association
                 // Heads up! "$item = $menu" here below is an assignment, *NOT* comparison
                 case isset($associations[$i]) && ($item = $menu->getItem($associations[$i])):
                     $language->link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
                     break;
                     // Too bad...
                 // Too bad...
                 default:
                     unset($languages[$i]);
             }
         }
         // If there are at least 2 of them, add the rel="alternate" links to the <head>
         if (count($languages) > 1) {
             // Remove the sef from the default language if "Remove URL Language Code" is on
             if (isset($languages[$this->default_lang]) && $remove_default_prefix) {
                 $languages[$this->default_lang]->link = preg_replace('|/' . $languages[$this->default_lang]->sef . '/|', '/', $languages[$this->default_lang]->link, 1);
             }
             foreach ($languages as $i => &$language) {
                 $doc->addHeadLink($server . $language->link, 'alternate', 'rel', array('hreflang' => $i));
             }
             // Add x-default language tag
             if ($this->params->get('xdefault', 1)) {
                 $xdefault_language = $this->params->get('xdefault_language', $this->default_lang);
                 $xdefault_language = $xdefault_language == 'default' ? $this->default_lang : $xdefault_language;
                 if (isset($languages[$xdefault_language])) {
                     // Use a custom tag because addHeadLink is limited to one URI per tag
                     $doc->addCustomTag('<link href="' . $server . $languages[$xdefault_language]->link . '" rel="alternate" hreflang="x-default" />');
                 }
             }
         }
     }
 }
开发者ID:N6REJ,项目名称:joomla-cms,代码行数:94,代码来源:languagefilter.php

示例5: getSitelangs

 /**
  * Method to return a list of published site languages.
  *
  * @return  array of language extension objects.
  *
  * @deprecated  4.0  Use JLanguageMultilang::getSiteLangs() instead.
  */
 public static function getSitelangs()
 {
     JLog::add(__METHOD__ . ' is deprecated, use JLanguageMultilang::getSiteLangs() instead.', JLog::WARNING, 'deprecated');
     return JLanguageMultilang::getSiteLangs();
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:12,代码来源:multilangstatus.php

示例6: getList

 /**
  * Gets a list of available languages
  *
  * @param   \Joomla\Registry\Registry  &$params  module params
  *
  * @return  array
  */
 public static function getList(&$params)
 {
     $user = JFactory::getUser();
     $lang = JFactory::getLanguage();
     $languages = JLanguageHelper::getLanguages();
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     // Get menu home items
     $homes = array();
     $homes['*'] = $menu->getDefault('*');
     foreach ($languages as $item) {
         $default = $menu->getDefault($item->lang_code);
         if ($default && $default->language == $item->lang_code) {
             $homes[$item->lang_code] = $default;
         }
     }
     // Load associations
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $active = $menu->getActive();
         if ($active) {
             $associations = MenusHelper::getAssociations($active->id);
         }
         // Load component associations
         $class = str_replace('com_', '', $app->input->get('option')) . 'HelperAssociation';
         JLoader::register($class, JPATH_COMPONENT_SITE . '/helpers/association.php');
         if (class_exists($class) && is_callable(array($class, 'getAssociations'))) {
             $cassociations = call_user_func(array($class, 'getAssociations'));
         }
     }
     $levels = $user->getAuthorisedViewLevels();
     $sitelangs = JLanguageMultilang::getSiteLangs();
     $multilang = JLanguageMultilang::isEnabled();
     // Filter allowed languages
     foreach ($languages as $i => &$language) {
         // Do not display language without frontend UI
         if (!array_key_exists($language->lang_code, $sitelangs)) {
             unset($languages[$i]);
         } elseif (!isset($homes[$language->lang_code])) {
             unset($languages[$i]);
         } elseif (isset($language->access) && $language->access && !in_array($language->access, $levels)) {
             unset($languages[$i]);
         } else {
             $language->active = $language->lang_code == $lang->getTag();
             // Fetch language rtl
             // If loaded language get from current JLanguage metadata
             if ($language->active) {
                 $language->rtl = $lang->isRtl();
             } else {
                 $languageMetadata = JLanguage::getMetadata($language->lang_code);
                 $language->rtl = $languageMetadata['rtl'];
             }
             if ($multilang) {
                 if (isset($cassociations[$language->lang_code])) {
                     $language->link = JRoute::_($cassociations[$language->lang_code] . '&lang=' . $language->sef);
                 } elseif (isset($associations[$language->lang_code]) && $menu->getItem($associations[$language->lang_code])) {
                     $itemid = $associations[$language->lang_code];
                     $language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
                 } else {
                     if ($language->active) {
                         $language->link = JUri::getInstance()->toString(array('path', 'query'));
                     } else {
                         $itemid = isset($homes[$language->lang_code]) ? $homes[$language->lang_code]->id : $homes['*']->id;
                         $language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
                     }
                 }
             } else {
                 $language->link = JRoute::_('&Itemid=' . $homes['*']->id);
             }
         }
     }
     return $languages;
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:80,代码来源:helper.php


注:本文中的JLanguageMultilang::getSiteLangs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。