本文整理汇总了PHP中CrowdfundingHelperRoute::prepareCategoryOrDetails方法的典型用法代码示例。如果您正苦于以下问题:PHP CrowdfundingHelperRoute::prepareCategoryOrDetails方法的具体用法?PHP CrowdfundingHelperRoute::prepareCategoryOrDetails怎么用?PHP CrowdfundingHelperRoute::prepareCategoryOrDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CrowdfundingHelperRoute
的用法示例。
在下文中一共展示了CrowdfundingHelperRoute::prepareCategoryOrDetails方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CrowdfundingParseRoute
/**
* Method to parse Route
*
* @param array $segments
*
* @return array
*/
function CrowdfundingParseRoute($segments)
{
$total = count($segments);
$vars = array();
for ($i = 0; $i < $total; $i++) {
$segments[$i] = str_replace('-', ':', $segments[$i]);
}
//Get the active menu item.
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getActive();
// Count route segments
$count = count($segments);
// Standard routing for articles. If we don't pick up an Itemid then we get the view from the segments
// the first segment is the view and the last segment is the id of the details, category or payment.
if (null === $item) {
$vars['view'] = $segments[0];
$vars['id'] = $segments[$count - 1];
return $vars;
}
// COUNT == 1
// Category or backing layout.
if ($count === 1) {
// We check to see if an alias is given. If not, we assume it is a project,
// because categories have always alias.
// If it is a menu item "Details" that could be one of its specific views - backing, embed,...
if (false === strpos($segments[0], ':')) {
switch ($segments[0]) {
case 'backing':
case 'friendmail':
case 'embed':
$id = $item->query['id'];
$project = CrowdfundingHelperRoute::getProject($id);
$vars['view'] = $segments[0];
$vars['catid'] = (int) $project['catid'];
$vars['id'] = (int) $project['id'];
break;
default:
$vars['view'] = 'details';
$vars['id'] = (int) $segments[0];
break;
}
return $vars;
}
$vars = CrowdfundingHelperRoute::prepareCategoryOrDetails($segments);
if (0 !== count($vars)) {
return $vars;
}
}
// COUNT >= 2
if ($count >= 2) {
$view = $segments[$count - 1];
switch ($view) {
case 'embed':
case 'backing':
$itemId = (int) $segments[$count - 2];
// Get catid from menu item
if (!empty($item->query['id'])) {
$catId = (int) $item->query['id'];
} else {
$catId = (int) $segments[$count - 3];
}
$vars['view'] = $view;
$vars['id'] = (int) $itemId;
$vars['catid'] = (int) $catId;
break;
case 'updates':
// Screens of details - 'updates', 'comments', 'funders'
// Screens of details - 'updates', 'comments', 'funders'
case 'comments':
case 'funders':
$itemId = (int) $segments[$count - 2];
// Get catid from menu item
if (!empty($item->query['id'])) {
$catId = (int) $item->query['id'];
} else {
$catId = (int) $segments[$count - 3];
}
$vars['view'] = 'details';
$vars['id'] = (int) $itemId;
$vars['catid'] = (int) $catId;
// Get screen
$screen = $segments[$count - 1];
$allowedScreens = array('updates', 'comments', 'funders');
if (in_array($screen, $allowedScreens, true)) {
$vars['screen'] = $screen;
}
break;
default:
// Subcategory or details page.
// if there was more than one segment, then we can determine where the URL points to
// because the first segment will have the target category id prepended to it. If the
// last segment has a number prepended, it is details, otherwise, it is a category.
//.........这里部分代码省略.........