本文整理汇总了PHP中DiscussRouter::encodeSegments方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussRouter::encodeSegments方法的具体用法?PHP DiscussRouter::encodeSegments怎么用?PHP DiscussRouter::encodeSegments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussRouter
的用法示例。
在下文中一共展示了DiscussRouter::encodeSegments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: EasyDiscussParseRoute
function EasyDiscussParseRoute($segments)
{
$vars = array();
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getActive();
$config = DiscussHelper::getConfig();
$views = array('attachments', 'categories', 'index', 'post', 'profile', 'search', 'tag', 'tags', 'users', 'notifications', 'badges', 'ask', 'subscriptions', 'featured', 'favourites', 'assigned');
// @rule: For view=post&id=xxx we do not include
if (isset($segments[0]) && !in_array($segments[0], $views)) {
$vars['view'] = 'post';
$count = count($segments);
if ($count >= 1) {
// Submission
$index = 0;
if ($segments[$index] == 'submit') {
$vars['layout'] = $segments[$index];
$index += 1;
}
if (isset($segments[$index])) {
$table = DiscussHelper::getTable('Post');
$table->load($segments[$index], true);
$vars['id'] = $table->id;
$index += 1;
}
if (isset($segments[$index])) {
if ($segments[$index] == 'edit') {
$vars['layout'] = $segments[$index];
} else {
$vars['sort'] = $segments[$index];
}
}
}
}
if (isset($segments[0]) && $segments[0] == 'index') {
$count = count($segments);
if ($count > 1) {
$vars['view'] = $segments[0];
$segments = DiscussRouter::encodeSegments($segments);
//if( in_array( $segments[ $count - 1 ] , array( 'unanswered', 'featured', 'new' ) ) )
if (in_array($segments[1], array('allposts', 'unanswered', 'unresolved', 'unread', 'resolved'))) {
$vars['filter'] = $segments[1];
if (isset($segments[2])) {
$vars['sort'] = $segments[2];
}
}
}
}
if (isset($segments[0]) && $segments[0] == 'points') {
// Get the current view
$vars['view'] = $segments[0];
// Get the current layout
$vars['layout'] = $segments[1];
// Get the user's id.
$alias = $segments[2];
$id = DiscussHelper::getUserId($alias);
if (!$id) {
// Username might contains "-" character
$alias = JString::str_ireplace(':', '-', $alias);
$id = DiscussHelper::getUserId($alias);
}
if (!$id) {
// Username might contains "-" character
$alias = JString::str_ireplace('-', ' ', $alias);
$id = DiscussHelper::getUserId($alias);
}
$vars['id'] = $id;
}
if (isset($segments[0]) && $segments[0] == 'categories') {
$count = count($segments);
if ($count > 1) {
$vars['view'] = $segments[0];
$segments = DiscussRouter::encodeSegments($segments);
if (isset($segments[1]) && $segments[1] == 'listings') {
// Get the last item since the category might be recursive.
$cid = $segments[2];
$category = DiscussHelper::getTable('Category');
$category->load($cid, true);
$vars['layout'] = $segments[1];
$vars['category_id'] = $category->id;
} else {
// Get the last item since the category might be recursive.
$cid = $segments[1];
$category = DiscussHelper::getTable('Category');
$category->load($cid, true);
$vars['category_id'] = $category->id;
}
if (isset($segments[3])) {
$vars['filter'] = $segments[3];
if (isset($segments[4])) {
$vars['sort'] = $segments[4];
}
}
}
}
if (isset($segments[0]) && $segments[0] == 'tags') {
$count = count($segments);
if ($count > 1) {
$segments = DiscussRouter::encodeSegments($segments);
$table = DiscussHelper::getTable('Tags');
//.........这里部分代码省略.........