本文整理汇总了PHP中FlexicontentHelperRoute::_findCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentHelperRoute::_findCategory方法的具体用法?PHP FlexicontentHelperRoute::_findCategory怎么用?PHP FlexicontentHelperRoute::_findCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentHelperRoute
的用法示例。
在下文中一共展示了FlexicontentHelperRoute::_findCategory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCategoryRoute
/**
* Get routed links for categories
*/
static function getCategoryRoute($catid, $Itemid = 0, $urlvars = array())
{
static $component_default_menuitem_id = null; // Calculate later only if needed
static $current_language = null;
if ($current_language === null) {
$current_language = JFactory::getLanguage()->getTag(); // Current language tag for J2.5+ but not for J1.5
}
static $use_language = null;
if ($use_language === null)
{
$use_language = FLEXI_J16GE && JLanguageMultilang::isEnabled();
if ($use_language) {
self::_buildLanguageLookup();
}
}
global $globalcats;
$_catid = (int) $catid;
// **************************************
// Get data of the FLEXIcontent category
// data like: language, and ancestors ids
// **************************************
// Get language
$language = isset($globalcats[$_catid]->language) ? $globalcats[$_catid]->language : $current_language;
// Get item's parent categores to be used in search a menu item of type category view
$parents_ids = array();
if ( $_catid && isset($globalcats[$_catid]->ancestorsarray) ) {
$parents_ids = array_reverse($globalcats[$_catid]->ancestorsarray);
}
// **********************************************************
// Create the needles for table lookup in descending priority
// **********************************************************
$needles = array();
// Category view menu items of given category ID ... and then parent categories in ascending order
$needles['category'] = $parents_ids;
// Directory view menu items starting at given category ID ... and then parent categories in ascending order
$needles['flexicontent'] = $parents_ids;
// ***************
// Create the link
// ***************
$link = 'index.php?option=com_flexicontent&view=category&cid='.$catid;
// Other data to pass to _findCategory()
$data = array();
// Append given variables
foreach ($urlvars as $varname => $varval) $link .= '&'.$varname.'='.$varval;
$data['urlvars'] = $urlvars;
// use SEF language code as so configured
$data['language'] = '*'; // Default to ALL
if ($use_language && $language && $language != "*")
{
if(isset(self::$lang_lookup[$language]))
{
if ( self::$add_url_lang && isset(self::$interface_langs[$language]) ) {
$link .= '&lang='.self::$lang_lookup[$language];
}
$data['language'] = $language;
}
}
// USE the itemid provided, if we were given one it means it is "appropriate and relevant"
if ($Itemid) {
$link .= '&Itemid='.$Itemid;
}
// Try to find the most appropriate/relevant menu item, using the priority set via needles array
else if ($menuitem = FlexicontentHelperRoute::_findCategory($needles, $data)) {
$link .= '&Itemid='.$menuitem->id;
// Special handly if directory view was matched
if ( $menuitem->query['view'] == 'flexicontent' )
{
$link = str_replace('view=category', 'view=flexicontent', $link);
$link = str_replace('cid=', 'rootcat=', $link);
}
}
// Try to use component's default menu item, this is according to COMPONENT CONFIGURATION and includes ACTIVE menu item if appropriate
else {
if ($component_default_menuitem_id === null)
//.........这里部分代码省略.........
示例2: getCategoryRoute
/**
* Get routed links for categories
*/
static function getCategoryRoute($catid, $_Itemid = 0, $urlvars = array(), $category = null)
{
$Itemid = $_Itemid == -1 ? 0 : $_Itemid;
// -1 indicates to return the found menu Itemid instead of the produced link
// Calculate later only if needed
static $component_default_menuitem_id = null;
static $layout_default_menuitem_ids = null;
static $current_language = null;
if ($current_language === null) {
$current_language = JFactory::getLanguage()->getTag();
// Current language tag for J2.5+ but not for J1.5
}
static $use_language = null;
if ($use_language === null) {
$use_language = JLanguageMultilang::isEnabled();
if ($use_language) {
self::_buildLanguageLookup();
}
}
global $globalcats;
$_catid = (int) $catid;
// **************************************
// Get data of the FLEXIcontent category
// data like: language, and ancestors ids
// **************************************
// Get language
$language = $category && !empty($category->language) ? $category->language : null;
if (!$language) {
$language = isset($globalcats[$_catid]->language) ? $globalcats[$_catid]->language : $current_language;
}
// Get item's parent categores to be used in search a menu item of type category view
$parents_ids = array();
if ($_catid && isset($globalcats[$_catid]->ancestorsarray)) {
$parents_ids = array_reverse($globalcats[$_catid]->ancestorsarray);
}
// **********************************************************
// Create the needles for table lookup in descending priority
// **********************************************************
$needles = array();
// Category view menu items of given category ID ... and then parent categories in ascending order
$needles['category'] = $parents_ids;
// Directory view menu items starting at given category ID ... and then parent categories in ascending order
$needles['flexicontent'] = $parents_ids;
// If layout is set, then add cid: 0 (indexes: LayoutID_0), -1 (indexes: 0_0) as last needles
$layout = !empty($urlvars['layout']) ? $urlvars['layout'] : false;
if ($layout) {
$needles['category'][] = 0;
$needles['category'][] = -1;
}
// ***************
// Create the link
// ***************
$link = 'index.php?option=com_flexicontent&view=category';
if ($_catid) {
$link .= '&cid=' . $catid;
}
// Other data to pass to _findCategory()
$data = array();
// Append given variables
foreach ($urlvars as $varname => $varval) {
if ($varval) {
$link .= '&' . $varname . '=' . $varval;
} else {
unset($urlvars[$varname]);
}
}
$data['urlvars'] = $urlvars;
// use SEF language code as so configured
$data['language'] = '*';
// Default to ALL
if ($use_language && $language && $language != "*") {
if (isset(self::$lang_lookup[$language])) {
if (self::$add_url_lang && isset(self::$interface_langs[$language])) {
$link .= '&lang=' . self::$lang_lookup[$language];
}
$data['language'] = $language;
}
}
// USE the itemid provided, if we were given one it means it is "appropriate and relevant"
if ($Itemid) {
$link .= '&Itemid=' . $Itemid;
} else {
if ($menuitem = FlexicontentHelperRoute::_findCategory($needles, $data)) {
$Itemid = $menuitem->id;
$link .= '&Itemid=' . $Itemid;
// Special handly if directory view was matched
if ($menuitem->query['view'] == 'flexicontent') {
$link = str_replace('view=category', 'view=flexicontent', $link);
$link = str_replace('cid=', 'rootcat=', $link);
}
} else {
$layout = !empty($urlvars['layout']) ? $urlvars['layout'] : false;
if ($layout && $layout_default_menuitem_ids === null) {
$layout_default_menuitem_ids = FlexicontentHelperRoute::_setLayoutDefaultMenuitemIds();
}
if ($layout && !empty($layout_default_menuitem_ids[$layout])) {
$Itemid = $layout_default_menuitem_ids[$layout];
//.........这里部分代码省略.........