本文整理汇总了PHP中MenusHelper::getAssociations方法的典型用法代码示例。如果您正苦于以下问题:PHP MenusHelper::getAssociations方法的具体用法?PHP MenusHelper::getAssociations怎么用?PHP MenusHelper::getAssociations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenusHelper
的用法示例。
在下文中一共展示了MenusHelper::getAssociations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: association
/**
* Generate the markup to display the item associations
*
* @param int $itemid The menu item id
*
* @return string
*
* @since 3.0
*
* @throws Exception If there is an error on the query
*/
public static function association($itemid)
{
// Defaults
$html = '';
// Get the associations
if ($associations = MenusHelper::getAssociations($itemid)) {
// Get the associated menu items
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('m.id, m.title')->select('l.sef as lang_sef')->select('mt.title as menu_title')->from('#__menu as m')->join('LEFT', '#__menu_types as mt ON mt.menutype=m.menutype')->where('m.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON m.language=l.lang_code')->select('l.image')->select('l.title as language_title');
$db->setQuery($query);
try {
$items = $db->loadObjectList('id');
} catch (runtimeException $e) {
throw new Exception($e->getMessage(), 500);
}
// Construct html
if ($items) {
foreach ($items as &$item) {
$text = strtoupper($item->lang_sef);
$url = JRoute::_('index.php?option=com_menus&task=item.edit&id=' . (int) $item->id);
$tooltipParts = array(JHtml::_('image', 'mod_languages/' . $item->image . '.gif', $item->language_title, array('title' => $item->language_title), true), $item->title, '(' . $item->menu_title . ')');
$class = 'hasTooltip label label-association label-' . $item->lang_sef;
$item->link = JHtml::_('tooltip', implode(' ', $tooltipParts), null, null, $text, $url, null, $class);
}
}
$html = JLayoutHelper::render('joomla.content.associations', $items);
}
return $html;
}
示例2: association
/**
* @param int $itemid The menu item id
*/
static function association($itemid)
{
// Get the associations
$associations = MenusHelper::getAssociations($itemid);
// Get the associated menu items
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('m.*');
$query->select('mt.title as menu_title');
$query->from('#__menu as m');
$query->leftJoin('#__menu_types as mt ON mt.menutype=m.menutype');
$query->where('m.id IN (' . implode(',', array_values($associations)) . ')');
$query->leftJoin('#__languages as l ON m.language=l.lang_code');
$query->select('l.image');
$query->select('l.title as language_title');
$db->setQuery($query);
$items = $db->loadObjectList('id');
// Check for a database error.
if ($error = $db->getErrorMsg()) {
JError::raiseWarning(500, $error);
return false;
}
// Construct html
$text = array();
foreach ($associations as $tag => $associated) {
if ($associated != $itemid) {
$text[] = JText::sprintf('COM_MENUS_TIP_ASSOCIATED_LANGUAGE', JHtml::_('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, array('title' => $items[$associated]->language_title), true), $items[$associated]->title, $items[$associated]->menu_title);
}
}
return JHtml::_('tooltip', implode('<br />', $text), JText::_('COM_MENUS_TIP_ASSOCIATION'), 'menu/icon-16-links.png');
}
示例3: association
/**
* Generate the markup to display the item associations
*
* @param int $itemid The menu item id
*
* @return string
*
* @since 3.0
*
* @throws Exception If there is an error on the query
*/
public static function association($itemid)
{
// Defaults
$html = '';
// Get the associations
if ($associations = MenusHelper::getAssociations($itemid)) {
// Get the associated menu items
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('m.id, m.title')->select('l.sef as lang_sef, l.lang_code')->select('mt.title as menu_title')->from('#__menu as m')->join('LEFT', '#__menu_types as mt ON mt.menutype=m.menutype')->where('m.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON m.language=l.lang_code')->select('l.image')->select('l.title as language_title');
$db->setQuery($query);
try {
$items = $db->loadObjectList('id');
} catch (runtimeException $e) {
throw new Exception($e->getMessage(), 500);
}
// Construct html
if ($items) {
foreach ($items as &$item) {
$text = strtoupper($item->lang_sef);
$url = JRoute::_('index.php?option=com_menus&task=item.edit&id=' . (int) $item->id);
$tooltip = $item->title . '<br />' . JText::sprintf('COM_MENUS_MENU_SPRINTF', $item->menu_title);
$classes = 'hasPopover label label-association label-' . $item->lang_sef;
$item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes . '" data-content="' . $tooltip . '" data-placement="top">' . $text . '</a>';
}
}
JHtml::_('bootstrap.popover');
$html = JLayoutHelper::render('joomla.content.associations', $items);
}
return $html;
}
示例4: getList
public static function getList(&$params)
{
$user = JFactory::getUser();
$lang = JFactory::getLanguage();
$app = JFactory::getApplication();
$menu = $app->getMenu();
// Get menu home items
$homes = array();
foreach ($menu->getMenu() as $item) {
if ($item->home) {
$homes[$item->language] = $item;
}
}
// Load associations
$assoc = isset($app->menu_associations) ? $app->menu_associations : 0;
if ($assoc) {
$active = $menu->getActive();
if ($active) {
$associations = MenusHelper::getAssociations($active->id);
}
}
$levels = $user->getAuthorisedViewLevels();
$languages = JLanguageHelper::getLanguages();
// Filter allowed languages
foreach ($languages as $i => &$language) {
// Do not display language without frontend UI
if (!JLanguage::exists($language->lang_code)) {
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();
if ($app->getLanguageFilter()) {
if (isset($associations[$language->lang_code]) && $menu->getItem($associations[$language->lang_code])) {
$itemid = $associations[$language->lang_code];
if ($app->getCfg('sef') == '1') {
$language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
} else {
$language->link = 'index.php?lang=' . $language->sef . '&Itemid=' . $itemid;
}
} else {
if ($app->getCfg('sef') == '1') {
$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 = 'index.php?lang=' . $language->sef;
}
}
} else {
$language->link = JRoute::_('&Itemid=' . $homes['*']->id);
}
}
}
return $languages;
}
示例5: getList
public static function getList(&$params)
{
$lang = JFactory::getLanguage();
$languages = JLanguageHelper::getLanguages();
$db = JFactory::getDBO();
$app = JFactory::getApplication();
$query = $db->getQuery(true);
$query->select('id');
$query->select('language');
$query->from($db->nameQuote('#__menu'));
$query->where('home=1');
$db->setQuery($query);
$homes = $db->loadObjectList('language');
if ($app->get('menu_associations', 0)) {
$menu = $app->getMenu();
$active = $menu->getActive();
if ($active) {
$associations = MenusHelper::getAssociations($active->id);
}
}
foreach ($languages as $i => &$language) {
// Do not display language without frontend UI
if (!JLanguage::exists($language->lang_code)) {
unset($languages[$i]);
} elseif (!isset($homes[$language->lang_code])) {
unset($languages[$i]);
} else {
$language->active = $language->lang_code == $lang->getTag();
if ($app->getLanguageFilter()) {
if (isset($associations[$language->lang_code]) && $menu->getItem($associations[$language->lang_code])) {
$itemid = $associations[$language->lang_code];
if ($app->getCfg('sef') == '1') {
$language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
} else {
$language->link = 'index.php?lang=' . $language->sef . '&Itemid=' . $itemid;
}
} else {
if ($app->getCfg('sef') == '1') {
$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 = 'index.php?lang=' . $language->sef;
}
}
} else {
$language->link = JRoute::_('&Itemid=' . $homes['*']->id);
}
}
}
return $languages;
}
示例6: onAfterDispatch
/**
* This method adds alternate meta tags for associated menu items
*
* @return nothing
* @since 1.7
*/
public function onAfterDispatch()
{
if (App::isSite() && $this->params->get('alternate_meta') && Document::getType() == 'html') {
// Get active menu item
$active = App::get('menu')->getActive();
if (!$active) {
return;
}
// Get menu item link
if (Config::get('sef')) {
$active_link = Route::url('index.php?Itemid=' . $active->id, false);
} else {
$active_link = Route::url($active->link . '&Itemid=' . $active->id, false);
}
if ($active_link == JUri::base(true) . '/') {
$active_link .= 'index.php';
}
// Get current link
$current_link = Request::getUri();
if ($current_link == Request::base(true) . '/') {
$current_link .= 'index.php';
}
// Check the exact menu item's URL
if ($active_link == $current_link) {
// Get menu item associations
JLoader::register('MenusHelper', PATH_CORE . '/components/com_menus/admin/helpers/menus.php');
$associations = MenusHelper::getAssociations($active->id);
// Remove current menu item
unset($associations[$active->language]);
// Associated menu items in other languages
if ($associations && $this->params->get('menu_associations')) {
$menu = App::get('menu');
$server = JURI::getInstance()->toString(array('scheme', 'host', 'port'));
foreach (JLanguageHelper::getLanguages() as $language) {
if (isset($associations[$language->lang_code])) {
$item = $menu->getItem($associations[$language->lang_code]);
if ($item && Lang::exists($language->lang_code)) {
if (Config::get('sef')) {
$link = Route::url('index.php?Itemid=' . $associations[$language->lang_code] . '&lang=' . $language->sef);
} else {
$link = Route::url($item->link . '&Itemid=' . $associations[$language->lang_code] . '&lang=' . $language->sef);
}
// Check if language is the default site language and remove url language code is on
if ($language->sef == self::$default_sef && $this->params->get('remove_default_prefix') == '1') {
$relLink = preg_replace('|/' . $language->sef . '/|', '/', $link, 1);
Document::addHeadLink($server . $relLink, 'alternate', 'rel', array('hreflang' => $language->lang_code));
} else {
Document::addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
}
}
}
}
} elseif ($active->home) {
$menu = App::get('menu');
$server = JURI::getInstance()->toString(array('scheme', 'host', 'port'));
foreach (JLanguageHelper::getLanguages() as $language) {
$item = $menu->getDefault($language->lang_code);
if ($item && $item->language != $active->language && $item->language != '*' && JLanguage::exists($language->lang_code)) {
if (Config::get('sef')) {
$link = Route::url('index.php?Itemid=' . $item->id . '&lang=' . $language->sef);
} else {
$link = Route::url($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
}
// Check if language is the default site language and remove url language code is on
if ($language->sef == self::$default_sef && $this->params->get('remove_default_prefix') == '1') {
$relLink = preg_replace('|/' . $language->sef . '/|', '/', $link, 1);
Document::addHeadLink($server . $relLink, 'alternate', 'rel', array('hreflang' => $language->lang_code));
} else {
Document::addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
}
}
}
}
}
}
}
示例7: onAfterDispatch
/**
* Method to add alternative meta tags for associated menu items.
*
* @return void
*
* @since 1.7
*/
public function onAfterDispatch()
{
$doc = JFactory::getDocument();
$menu = $this->app->getMenu();
$server = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
$option = $this->app->input->get('option');
$eName = JString::ucfirst(JString::str_ireplace('com_', '', $option));
if ($this->app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') {
// Get active menu item.
$active = $menu->getActive();
$assocs = array();
$home = false;
// Load menu associations.
if ($active) {
$active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false);
// Get current link.
$current_link = JUri::getInstance()->toString(array('path', 'query'));
// Check the exact menu item's URL.
if ($active_link == $current_link) {
$associations = MenusHelper::getAssociations($active->id);
unset($associations[$active->language]);
$assocs = array_keys($associations);
// If the menu item is a home menu item and the URLs are identical, we are on the homepage
$home = true;
}
}
// Load component associations.
$cName = JString::ucfirst($eName . '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'));
$lang_code = $this->app->input->cookie->getString(JApplicationHelper::getHash('language'));
// No cookie - let's try to detect browser language or use site default.
if (!$lang_code) {
if ($this->params->get('detect_browser', 1)) {
$lang_code = JLanguageHelper::detectLanguage();
} else {
$lang_code = $this->default_lang;
}
}
unset($cassociations[$lang_code]);
$assocs = array_merge(array_keys($cassociations), $assocs);
}
// Handle the default associations.
if ($this->params->get('item_associations') || $active && $active->home && $home) {
$languages = JLanguageHelper::getLanguages('lang_code');
foreach ($assocs as $language) {
if (!JLanguage::exists($language)) {
continue;
}
$lang = $languages[$language];
if (isset($cassociations[$language])) {
$link = JRoute::_($cassociations[$language] . '&lang=' . $lang->sef);
// Check if language is the default site language and remove url language code is on
if ($lang->sef == $this->lang_codes[$this->default_lang]->sef && $this->params->get('remove_default_prefix') == '1') {
$link = preg_replace('|/' . $lang->sef . '/|', '/', $link, 1);
}
$doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language));
} elseif (isset($associations[$language])) {
$item = $menu->getItem($associations[$language]);
if ($item) {
$link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $lang->sef);
$doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language));
}
}
}
}
}
}
示例8: switchLangAssocItem
//.........这里部分代码省略.........
}
// Indentify previous and current flexicontent view
$prev_page_isitemview = $view==FLEXI_ITEMVIEW && $option=='com_flexicontent';
$prev_page_iscatview = $view=='category' && $option=='com_flexicontent';
$curr_page_isitemview = JRequest::getVar('view')==FLEXI_ITEMVIEW && JRequest::getVar('option')=='com_flexicontent';
$curr_page_iscatview = JRequest::getVar('view')=='category' && JRequest::getVar('option')=='com_flexicontent';
// Execute only if previous page was a FLEXIcontent item or category view
if ( !$prev_page_isitemview && !$prev_page_iscatview ) return;
// Calculate flags needed to decide action to take
$language_changed = $prev_lang_tag!=$curr_lang_tag;
$prev_page_isflexi = $prev_page_isitemview || $prev_page_iscatview;
$switching_language = $prev_page_isflexi && $curr_page_ishome && $language_changed;
// Check Joomla switching language for (a) Home Page menu items OR (b) other language associated menu items
if ( $curr_menu && $curr_menu->language!='*' && $curr_menu->language!=$prev_lang_tag )
{
// (a) Home Page menu items
if ($prev_page_ishome && $curr_page_ishome)
{
if ($this->params->get('debug_lang_switch', 0))
$app->enqueueMessage( "Joomla language switched Home Page menu items<br><br>", 'message');
$switching_language = false;
}
// (b) Other language associated menu items
else
{
// Get menu item associations for previously activated menu item
require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'menus.php');
$helper = new MenusHelper();
$associated = $helper->getAssociations($prev_menu_id);
if ( isset($associated[$curr_lang_tag]) && $associated[$curr_lang_tag] == $curr_menu_id ) {
if ($this->params->get('debug_lang_switch', 0))
$app->enqueueMessage( "Associated menu for $prev_menu_id: ".print_r($associated, true)."<br>" , 'message');
if ( ($prev_page_isitemview && !$prev_menu_isitem) || ($prev_page_iscatview && !$prev_menu_iscat) ){
if ($this->params->get('debug_lang_switch', 0))
$app->enqueueMessage( "Joomla language switched associated menu items that did not point to current content: Doing FLEXI switch<br>", 'message');
$switching_language = true;
} else {
if ($this->params->get('debug_lang_switch', 0))
$app->enqueueMessage( "Joomla language switched associated menu items: that do point to current content: Aborting FLEXI switch<br><br>", 'message');
$switching_language = false;
}
}
}
}
/*echo "<br>prev_page_isflexi: $prev_page_isflexi, curr_page_ishome: $curr_page_ishome,"
."<br>language_changed: $language_changed,"
."<br>prev_page_isitemview: $prev_page_isitemview, prev_page_iscatview: $prev_page_iscatview"
."<br>curr_page_isitemview: $curr_page_isitemview, curr_page_iscatview: $curr_page_iscatview";*/
// Decide to execute switching:
if ( !$switching_language && // (a) if previous page was a FLEXIcontent view (item or category view) and we switched language
!$curr_page_isitemview // (b) if current page is FLEXIcontent item in order to check if language specified is not that of item's language
) return;
$cat_id = (int) (($switching_language && $this->params->get('lang_switch_cats', 1)) ? $cat_slug : JRequest::getVar('cid'));
$item_id = (int) ($switching_language ? $item_slug : JRequest::getVar('id'));
$view = $switching_language ? $view : JRequest::getVar('view');
$option = $switching_language ? $option : JRequest::getVar('option');
示例9: onAfterDispatch
/**
* Method to add alternative meta tags for associated menu items.
*
* @return void
*
* @since 1.7
*/
public function onAfterDispatch()
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$menu = $app->getMenu();
$server = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
$option = $app->input->get('option');
$eName = JString::ucfirst(JString::str_ireplace('com_', '', $option));
if ($app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') {
// Get active menu item.
$active = $menu->getActive();
// Load menu associations.
if ($active) {
// Get menu item link.
if ($app->get('sef')) {
$active_link = JRoute::_('index.php?Itemid=' . $active->id, false);
} else {
$active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false);
}
if ($active_link == JUri::base(true) . '/') {
$active_link .= 'index.php';
}
// Get current link.
$current_link = JUri::getInstance()->toString(array('path', 'query'));
if ($current_link == JUri::base(true) . '/') {
$current_link .= 'index.php';
}
// Check the exact menu item's URL.
if ($active_link == $current_link) {
$associations = MenusHelper::getAssociations($active->id);
unset($associations[$active->language]);
}
}
// Load component associations.
$cName = JString::ucfirst($eName . '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'));
$lang_code = $app->input->cookie->getString(JApplication::getHash('language'));
// No cookie - let's try to detect browser language or use site default.
if (!$lang_code) {
if ($this->params->get('detect_browser', 1)) {
$lang_code = JLanguageHelper::detectLanguage();
} else {
$lang_code = self::$default_lang;
}
}
unset($cassociations[$lang_code]);
}
// Handle the default associations.
if ((!empty($associations) || !empty($cassociations)) && $this->params->get('item_associations')) {
foreach (JLanguageHelper::getLanguages() as $language) {
if (!JLanguage::exists($language->lang_code)) {
continue;
}
if (isset($cassociations[$language->lang_code])) {
$link = JRoute::_($cassociations[$language->lang_code] . '&lang=' . $language->sef);
$doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
} elseif (isset($associations[$language->lang_code])) {
$item = $menu->getItem($associations[$language->lang_code]);
if ($item) {
if ($app->get('sef')) {
$link = JRoute::_('index.php?Itemid=' . $item->id . '&lang=' . $language->sef);
} else {
$link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
}
$doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
}
}
}
} elseif ($active && $active->home) {
foreach (JLanguageHelper::getLanguages() as $language) {
if (!JLanguage::exists($language->lang_code)) {
continue;
}
$item = $menu->getDefault($language->lang_code);
if ($item && $item->language != $active->language && $item->language != '*') {
if ($app->get('sef')) {
$link = JRoute::_('index.php?Itemid=' . $item->id . '&lang=' . $language->sef);
} else {
$link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
}
$doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
}
}
}
}
}
示例10: getList
/**
* Gets a list of available languages
*
* @param JRegistry &$params module params
*
* @return array
*/
public static function getList(&$params)
{
$user = JFactory::getUser();
$lang = JFactory::getLanguage();
$app = JFactory::getApplication();
$menu = $app->getMenu();
// Get menu home items
$homes = array();
foreach ($menu->getMenu() as $item) {
if ($item->home) {
$homes[$item->language] = $item;
}
}
// Load associations
$assoc = JLanguageAssociations::isEnabled();
if ($assoc) {
$active = $menu->getActive();
if ($active) {
$associations = MenusHelper::getAssociations($active->id);
}
// Load component associations
$option = $app->input->get('option');
$eName = JString::ucfirst(JString::str_ireplace('com_', '', $option));
$cName = JString::ucfirst($eName . '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'));
}
}
$levels = $user->getAuthorisedViewLevels();
$languages = JLanguageHelper::getLanguages();
// Filter allowed languages
foreach ($languages as $i => &$language) {
// Do not display language without frontend UI
if (!JLanguage::exists($language->lang_code)) {
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();
if (JLanguageMultilang::isEnabled()) {
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];
if ($app->get('sef') == '1') {
$language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
} else {
$language->link = 'index.php?lang=' . $language->sef . '&Itemid=' . $itemid;
}
} else {
if ($app->get('sef') == '1') {
$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 = 'index.php?lang=' . $language->sef;
}
}
} else {
$language->link = JRoute::_('&Itemid=' . $homes['*']->id);
}
}
}
return $languages;
}
示例11: getContinueShoppingUrl
function getContinueShoppingUrl()
{
$params = J2Store::config();
$type = $params->get('config_continue_shopping_page', 'previous');
$item = new JObject();
$item->type = $type;
switch ($type) {
case 'previous':
default:
$item->url = '';
break;
case 'menu':
$url = '';
//get the menu item id
$menu_itemid = $params->get('continue_shopping_page_menu', '');
if (empty($menu_itemid)) {
$item->url = '';
$item->type = 'previous';
} else {
$application = JFactory::getApplication();
$menu = $application->getMenu('site');
$menu_item = $menu->getItem($menu_itemid);
if (is_object($menu_item)) {
// we have the menu item. See if language associations are there
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
try {
$associations = MenusHelper::getAssociations($menu_item->id);
} catch (Exception $e) {
$associations = array();
}
//get the current language code
$tag = JFactory::getLanguage()->getTag();
if (isset($associations[$tag])) {
$cmenu = $menu->getItem($associations[$tag]);
} else {
$cmenu = $menu_item;
}
$link = JRoute::_($cmenu->link . '&Itemid=' . $cmenu->id, false);
if (JURI::isInternal($link)) {
$url = $link;
}
}
if (empty($url)) {
$item->url = '';
$item->type = 'previous';
} else {
$item->url = $url;
}
}
break;
case 'url':
$custom_url = $params->get('config_continue_shopping_page_url', '');
if (empty($custom_url)) {
$item->url = '';
$item->type = 'previous';
} else {
$item->url = $custom_url;
}
break;
}
//allow plugins to alter the checkout link.
//This allows 3rd-party developers to create different checkout steps for j2store
//Example. The plugin can return a completely different link
J2Store::plugin()->event('GetContinueShoppingUrl', array(&$item));
return $item;
}
示例12: getRootItemAssociations
/**
* Return a list of Root Menu Items associated with the current Root Menu Item
*
* @access public
*
* @param null
*
* @return array
*/
public static function getRootItemAssociations()
{
$assoc = JLanguageAssociations::isEnabled();
if ($assoc == false) {
return false;
}
$root_item = MageBridgeUrlHelper::getRootItem();
if ($root_item == false) {
return false;
}
$associations = MenusHelper::getAssociations($root_item->id);
return $associations;
}
示例13: array
/**
* function to discover a default item id only once
*/
static function _setDefaultMenuitemId()
{
// Cache the result on multiple calls
static $_component_default_menuitem_id = null;
if ( $_component_default_menuitem_id!==null ) return $_component_default_menuitem_id;
// Default item not found (yet) ... set it to false to indicate that we tried
$_component_default_menuitem_id = false;
$curr_langtag = JFactory::getLanguage()->getTag(); // Current language tag for J2.5+ but not for J1.5
//$public_acclevel = !FLEXI_J16GE ? 0 : 1;
$user = JFactory::getUser();
if (FLEXI_J16GE)
$aid_arr = JAccess::getAuthorisedViewLevels($user->id);
else
$aid = (int) $user->get('aid');
// NOTE: In J1.5 the static method JSite::getMenu() will give an error, while JFactory::getApplication('site')->getMenu() will not return the frontend menus
$menus = JFactory::getApplication()->getMenu('site', array()); // this will work in J1.5 backend too !!!
// Get preference for default menu item
$params = JComponentHelper::getParams('com_flexicontent');
$default_menuitem_preference = $params->get('default_menuitem_preference', 0);
switch ($default_menuitem_preference) {
case 1:
// Try to use ACTIVE (current) menu item if pointing to Flexicontent, (if so configure in global options)
$menu = $menus->getActive();
// Check that (a) it exists and is active (b) points to com_flexicontent
if ($menu && @ $menu->query['option']=='com_flexicontent' )
{
// For J1.5 access level is already OK (since active), for J2.5+ check language
$item_matches = !FLEXI_J16GE ? true : ($curr_langtag == '*' || in_array($menu->language, array('*', $curr_langtag)) || !JLanguageMultilang::isEnabled());
// If matched set default and return it
if ($item_matches) return $_component_default_menuitem_id = $menu->id;
}
// DO NOT BREAK HERE !! FALLBACK to 2
case 2:
// Try to use (user defined) component's default menu item, (if so configure in global options)
$_component_default_menuitem_id = $params->get('default_menu_itemid', false);
$menu = $menus->getItem($_component_default_menuitem_id);
// Check that (a) it exists and is active (b) points to com_flexicontent
if ($menu && @ $menu->query['option']=='com_flexicontent' )
{
// For J1.5 check access and for J2.5+ check language
$item_matches = !FLEXI_J16GE ? ($menu->access <= $aid) : ($curr_langtag == '*' || in_array($menu->language, array('*', $curr_langtag)) || !JLanguageMultilang::isEnabled());
// If matched set default and return it
if ($item_matches) return $_component_default_menuitem_id = $menu->id;
// For J2.5+ we also need to try menu item associations and select the current language item
if ( FLEXI_J16GE && $menu->language!='*' && $menu->language!='' && $menu->language!=$curr_langtag )
{
require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'menus.php');
$helper = new MenusHelper();
$associated = $helper->getAssociations($_component_default_menuitem_id);
// Return associated menu item for current language
if ( isset($associated[$curr_langtag]) ) $_component_default_menuitem_id = $associated[$curr_langtag];
}
}
return $_component_default_menuitem_id;
}
}
示例14: array
/**
* function to discover a default item id only once
*/
static function _setLayoutDefaultMenuitemIds()
{
// Cache the result on multiple calls
static $_layouts_default_menuitem_id = null;
if ($_layouts_default_menuitem_id !== null) {
return $_layouts_default_menuitem_id[$layout];
}
// Default item not found (yet) ... set it to empty array to indicate that we tried
$_layouts_default_menuitem_id = array();
$curr_langtag = JFactory::getLanguage()->getTag();
// Current language tag for J2.5+ but not for J1.5
// NOTE: In J1.5 the static method JSite::getMenu() will give an error, while JFactory::getApplication('site')->getMenu() will not return the frontend menus
$menus = JFactory::getApplication()->getMenu('site', array());
// this will work in J1.5 backend too !!!
// Get preference for default menu item
$params = JComponentHelper::getParams('com_flexicontent');
$_layouts_default_menuitem_id = array();
$_layouts_default_menuitem_id['tags'] = $params->get('cat_tags_default_menu_itemid', 0);
$_layouts_default_menuitem_id['favs'] = $params->get('cat_favs_default_menu_itemid', 0);
$_layouts_default_menuitem_id['author'] = $params->get('cat_author_default_menu_itemid', 0);
$_layouts_default_menuitem_id['myitems'] = $params->get('cat_myitems_default_menu_itemid', 0);
$_layouts_default_menuitem_id['mcats'] = $params->get('cat_mcats_default_menu_itemid', 0);
foreach ($_layouts_default_menuitem_id as $layout => $menuitem_id) {
$menu = $menus->getItem($menuitem_id);
// Check that (a) it exists and is active (b) points to com_flexicontent (c) is category view and of correct layout
if ($menu && @$menu->query['option'] == 'com_flexicontent' && @$menu->query['view'] == 'category' && @$menu->query['layout'] == $layout) {
// For J2.5+ check language, for J2.5+ checking access is not needed as it was done already above, by the JMenu::getItem()
$item_matches = $curr_langtag == '*' || in_array($menu->language, array('*', $curr_langtag)) || !JLanguageMultilang::isEnabled();
// If item matched then selected menu item is good, continue with next layout type
if ($item_matches) {
continue;
}
// For J2.5+ we also need to try menu item associations and select the current language item
if ($menu->language != '*' && $menu->language != '' && $menu->language != $curr_langtag) {
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_menus' . DS . 'helpers' . DS . 'menus.php';
$helper = new MenusHelper();
$associated = $helper->getAssociations($menuitem_id);
// Assign the associated menu item as default, continue with next layout type
if (isset($associated[$curr_langtag])) {
// Check the associated menu item too
$menu = $menus->getItem($associated[$curr_langtag]);
if ($menu && @$menu->query['option'] == 'com_flexicontent' && @$menu->query['view'] == 'category' && @$menu->query['layout'] == $layout) {
$_layouts_default_menuitem_id[$layout] = $associated[$curr_langtag];
continue;
}
}
}
}
// Default menu item for the layout, did not match, clear it
$_layouts_default_menuitem_id[$layout] = 0;
}
return $_layouts_default_menuitem_id;
}
示例15: isset
$active = $menu->getDefault();
}
if ($tplparams->get('tpl_userpage_mid') == $active->id) {
// Load associations
$assoc = isset($app->item_associations) ? $app->item_associations : 0;
if ($assoc) {
// load component associations
$option = $app->input->get('option');
$eName = JString::ucfirst(JString::str_ireplace('com_', '', $option));
$cName = JString::ucfirst($eName . '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'));
}
if (!empty($cassociations)) {
$associations = MenusHelper::getAssociations($active->id);
foreach ($list as $language) {
if (!$language->active && $cassociations[$language->lang_code] && $associations[$language->lang_code]) {
$language->link = JRoute::_(preg_replace('@Itemid=(\\d+)@', 'Itemid=' . $associations[$language->lang_code], $cassociations[$language->lang_code] . '&lang=' . $language->sef));
}
}
}
}
}
?>
<div class="dropdown mod-languages">
<?php
if ($headerText) {
?>
<div class="pretext"><p><?php