本文整理汇总了PHP中JUDirectoryHelper::getCategoryPath方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDirectoryHelper::getCategoryPath方法的具体用法?PHP JUDirectoryHelper::getCategoryPath怎么用?PHP JUDirectoryHelper::getCategoryPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDirectoryHelper
的用法示例。
在下文中一共展示了JUDirectoryHelper::getCategoryPath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCatPluginParamRecursive
public static function getCatPluginParamRecursive($pluginName, $catId, $param, $default = '', $inheritParam = '', $globalParam = '', $inherit = '-1', $global = '-2')
{
$inheritParam = $inheritParam ? $inheritParam : $param;
$globalParam = $globalParam ? $globalParam : $param;
$path = JUDirectoryHelper::getCategoryPath($catId);
$rootCat = $path[0];
$plugin = JPluginHelper::getPlugin('judirectory', $pluginName);
$pluginParamsStr = isset($plugin->params) ? $plugin->params : '{}';
$pluginParams = new JRegistry($pluginParamsStr);
$pathCatToRoot = array_reverse($path);
foreach ($pathCatToRoot as $category) {
$plugin_params = $category->plugin_params;
if ($plugin_params) {
$plugins = new JRegistry($plugin_params);
$pluginObject = $plugins->get($pluginName, "");
$pluginRegistry = new JRegistry($pluginObject);
if ($pluginRegistry->get($inheritParam, '') !== $inherit) {
if ($pluginRegistry->get($globalParam, '') === $global) {
return $pluginParams->get($param, $default);
} else {
return $pluginRegistry->get($param, $default);
}
} else {
if ($category->parent_id == $rootCat->id) {
return $pluginParams->get($param, $default);
} else {
continue;
}
}
} else {
return $default;
}
}
return $default;
}
示例2: canDoCategory
public static function canDoCategory($categoryId, $checkAccess = false, &$error = array())
{
if (!$categoryId) {
return false;
}
$storeId = md5(__METHOD__ . "::{$categoryId}::" . (int) $checkAccess);
$storeId_AccessibleCategoryIds = md5(__CLASS__ . '::AccessibleCategoryIds');
if (isset(self::$cache[$storeId_AccessibleCategoryIds])) {
$categoryIdArrayCanAccess = self::$cache[$storeId_AccessibleCategoryIds];
if (!empty($categoryIdArrayCanAccess) && in_array($categoryId, $categoryIdArrayCanAccess)) {
self::$cache[$storeId] = true;
return self::$cache[$storeId];
} else {
self::$cache[$storeId] = false;
return self::$cache[$storeId];
}
}
if (!isset(self::$cache[$storeId])) {
if (!$categoryId) {
self::$cache[$storeId] = false;
return self::$cache[$storeId];
}
$path = JUDirectoryHelper::getCategoryPath($categoryId);
if (!$path) {
self::$cache[$storeId] = false;
return self::$cache[$storeId];
}
$user = JFactory::getUser();
$levels = $user->getAuthorisedViewLevels();
$nowDate = JFactory::getDate()->toSql();
foreach ($path as $category) {
if ($category->published != 1) {
$error = array("code" => 404, "message" => JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
self::$cache[$storeId] = false;
return self::$cache[$storeId];
}
if ($category->publish_up > $nowDate || intval($category->publish_down) > 0 && $category->publish_down < $nowDate) {
$error = array("code" => 404, "message" => JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
self::$cache[$storeId] = false;
return self::$cache[$storeId];
}
if ($checkAccess && !in_array($category->access, $levels)) {
$error = array("code" => 403, "message" => JText::_('JERROR_ALERTNOAUTHOR'));
self::$cache[$storeId] = false;
return self::$cache[$storeId];
}
}
self::$cache[$storeId] = true;
}
return self::$cache[$storeId];
}
示例3: getBreadcrumbCategory
public static function getBreadcrumbCategory($categoryId)
{
$app = JFactory::getApplication();
$menus = $app->getMenu('site');
$categoryPath = JUDirectoryHelper::getCategoryPath($categoryId);
$pathwayArray = array();
if (!empty($categoryPath)) {
if (!isset($categoryPath[1])) {
$findMenuTreeLevel1 = false;
} else {
$topCategoryLevelId = $categoryPath[1]->id;
$needles = array('tree' => array((int) $topCategoryLevelId));
$findMenuTreeLevel1 = JUDirectoryHelperRoute::findItemId($needles, true);
}
if (!$findMenuTreeLevel1) {
$pathwayArray[] = JUDirectoryFrontHelperBreadcrumb::getRootPathway();
array_shift($categoryPath);
} else {
$menuTreeLevel1 = $menus->getItem($findMenuTreeLevel1);
$pathwayItem = new stdClass();
$pathwayItem->name = html_entity_decode($menuTreeLevel1->title, ENT_COMPAT, 'UTF-8');
$pathwayItem->link = JRoute::_($menuTreeLevel1->link);
$pathwayArray[] = $pathwayItem;
array_shift($categoryPath);
array_shift($categoryPath);
}
if (!empty($categoryPath)) {
foreach ($categoryPath as $categoryPathItem) {
$pathwayItem = new stdClass();
$pathwayItem->name = html_entity_decode($categoryPathItem->title, ENT_COMPAT, 'UTF-8');
$pathwayItem->link = JUDirectoryHelperRoute::getCategoryRoute($categoryPathItem->id, $topCategoryLevelId);
$pathwayArray[] = $pathwayItem;
}
}
}
return $pathwayArray;
}
示例4: getTemplateStyleOfCategory
public static function getTemplateStyleOfCategory($categoryId)
{
$categoryPath = JUDirectoryHelper::getCategoryPath($categoryId);
$categoryPathReverse = array_reverse($categoryPath);
foreach ($categoryPathReverse as $categoryObject) {
if ($categoryObject->style_id == -2) {
$templateStyleObject = self::getDefaultTemplateStyle();
return $templateStyleObject;
} elseif ($categoryObject->style_id == -1) {
if ($categoryObject->parent_id == 0) {
$templateStyleObject = self::getDefaultTemplateStyle();
return $templateStyleObject;
} else {
continue;
}
} else {
$templateStyleObject = self::getTemplateStyleObject($categoryObject->style_id);
if (is_object($templateStyleObject)) {
return $templateStyleObject;
}
}
}
$templateStyleObject = self::getDefaultTemplateStyle();
return $templateStyleObject;
}
示例5: getListingLayoutFromCategory
public static function getListingLayoutFromCategory($categoryId)
{
$path = JUDirectoryHelper::getCategoryPath($categoryId);
$pathCatToRoot = array_reverse($path);
foreach ($pathCatToRoot as $category) {
if ($category->layout_listing == -2) {
$params = JUDirectoryHelper::getParams($categoryId);
$layout = $params->get('layout_listing', '_:default');
return $layout;
} elseif ($category->layout_listing == -1) {
if ($category->parent_id == 0) {
$params = JUDirectoryHelper::getParams($categoryId);
$layout = $params->get('layout_listing', '_:default');
return $layout;
} else {
continue;
}
} else {
$layout = trim($category->layout_listing);
return $layout;
}
}
return '_:default';
}
示例6: getCategorySegment
public static function getCategorySegment($categoryId, &$query, $fullPath = 0)
{
if (isset($query['Itemid'])) {
unset($query['Itemid']);
}
$segments = array();
$params = JUDirectoryHelper::getParams();
$rootCategory = JUDirectoryFrontHelperCategory::getRootCategory();
$categoryObject = JUDirectoryHelper::getCategoryById($categoryId);
if (!is_object($categoryObject)) {
return false;
}
if ($categoryObject->level == 0) {
$itemIdTreeRoot = JUDirectoryHelperRoute::getMenuItemIdOfViewCategoryTreeRoot();
if ($itemIdTreeRoot > 0) {
$query['Itemid'] = $itemIdTreeRoot;
return $segments;
}
$query['Itemid'] = JUDirectoryHelperRoute::getHomeMenuItemId();
$sefRootCategory = $rootCategory->id . ':' . $params->get('sef_root_cat', 'root');
$segments[] = JApplication::stringURLSafe($sefRootCategory);
return $segments;
} elseif ($categoryObject->level == 1) {
$menuItemIdsOfViewCategoryTreeLevel1 = JUDirectoryHelperRoute::getMenuItemIdArrayOfViewCategoryTreeLevel1();
if (isset($menuItemIdsOfViewCategoryTreeLevel1[$categoryObject->id])) {
$query['Itemid'] = $menuItemIdsOfViewCategoryTreeLevel1[$categoryObject->id];
return $segments;
}
$itemIdTreeRoot = JUDirectoryHelperRoute::getMenuItemIdOfViewCategoryTreeRoot();
if ($itemIdTreeRoot > 0) {
$query['Itemid'] = $itemIdTreeRoot;
$segments[] = $categoryObject->id . ":" . $categoryObject->alias;
return $segments;
}
$query['Itemid'] = JUDirectoryHelperRoute::getHomeMenuItemId();
$sefRootCategory = $params->get('sef_root_cat', 'root');
$segments[] = JApplication::stringURLSafe($sefRootCategory);
$segments[] = $categoryObject->id . ":" . $categoryObject->alias;
return $segments;
} else {
$levelCats = JUDirectoryHelper::getCatsByLevel(1, $categoryObject->id);
if (is_array($levelCats) && count($levelCats)) {
$categoryIdAncestorLevel1 = $levelCats[0]->id;
}
$menuItemIdsOfViewCategoryTreeLevel1 = JUDirectoryHelperRoute::getMenuItemIdArrayOfViewCategoryTreeLevel1();
if (isset($menuItemIdsOfViewCategoryTreeLevel1[$categoryIdAncestorLevel1])) {
$query['Itemid'] = $menuItemIdsOfViewCategoryTreeLevel1[$categoryIdAncestorLevel1];
if ($fullPath) {
$categoryPath = JUDirectoryHelper::getCategoryPath($categoryId);
if (is_array($categoryPath) && count($categoryPath)) {
foreach ($categoryPath as $categoryPathValue) {
if ($categoryPathValue->level > 1 && $categoryPathValue->id != $categoryObject->id) {
$segments[] = $categoryPathValue->alias;
}
}
}
}
$segments[] = $categoryObject->id . ":" . $categoryObject->alias;
return $segments;
}
$itemIdTreeRoot = JUDirectoryHelperRoute::getMenuItemIdOfViewCategoryTreeRoot();
if ($itemIdTreeRoot > 0) {
$query['Itemid'] = $itemIdTreeRoot;
if ($fullPath) {
$categoryPath = JUDirectoryHelper::getCategoryPath($categoryId);
if (is_array($categoryPath) && count($categoryPath)) {
foreach ($categoryPath as $categoryPathValue) {
if ($categoryPathValue->level > 0 && $categoryPathValue->id != $categoryObject->id) {
$segments[] = $categoryPathValue->alias;
}
}
}
}
$segments[] = $categoryObject->id . ":" . $categoryObject->alias;
return $segments;
}
$query['Itemid'] = JUDirectoryHelperRoute::getHomeMenuItemId();
if ($fullPath) {
$sefRootCategory = $params->get('sef_root_cat', 'root');
$segments[] = JApplication::stringURLSafe($sefRootCategory);
$categoryPath = JUDirectoryHelper::getCategoryPath($categoryId);
if (is_array($categoryPath) && count($categoryPath)) {
foreach ($categoryPath as $categoryPathValue) {
if ($categoryPathValue->level > 0 && $categoryPathValue->id != $categoryObject->id) {
$segments[] = $categoryPathValue->alias;
}
}
}
}
$segments[] = $categoryObject->id . ":" . $categoryObject->alias;
return $segments;
}
return $segments;
}