Example #1
0
 public static function getReturnURL($params, $isLogged = false)
 {
     $type = empty($isLogged) ? 'login' : 'logout';
     if ($itemid = $params->get($type)) {
         $menu = JFactory::getApplication()->getMenu();
         $item = $menu->getItem($itemid);
         if ($item) {
             $url = JRoute::_($item->link . '&Itemid=' . $itemid, false);
         } else {
             // stay on the same page
             $uri = JFactory::getURI();
             $url = $uri->toString(array('path', 'query', 'fragment'));
         }
     } else {
         // Proceeed to the front page of EasyDiscuss.
         $itemid = DiscussRouter::getItemId();
         $url = JRoute::_('index.php?option=com_easydiscuss&Itemid=' . $itemid, false);
     }
     return base64_encode($url);
 }
Example #2
0
function EasyDiscussBuildRoute(&$query)
{
    $segments = array();
    $config = DiscussHelper::getConfig();
    if (isset($query['view'])) {
        switch ($query['view']) {
            case 'post':
                // We don't want to include the view for the entry links.
                unset($query['view']);
                if (isset($query['id'])) {
                    $segments[] = DiscussRouter::getPostAlias($query['id']);
                    unset($query['id']);
                }
                if (isset($query['layout'])) {
                    $segments[] = $query['layout'];
                    unset($query['layout']);
                }
                break;
            case 'profile':
                $segments[] = $query['view'];
                unset($query['view']);
                if (isset($query['layout'])) {
                    $segments[] = $query['layout'];
                    unset($query['layout']);
                }
                if (isset($query['id'])) {
                    $segments[] = DiscussRouter::getUserAlias($query['id']);
                    unset($query['id']);
                }
                if (isset($query['category_id'])) {
                    $aliases = DiscussRouter::getCategoryAliases($query['category_id']);
                    foreach ($aliases as $alias) {
                        $segments[] = $alias;
                    }
                    unset($query['category_id']);
                }
                if (isset($query['viewtype'])) {
                    $segments[] = $query['viewtype'];
                    unset($query['viewtype']);
                }
                break;
            case 'index':
                $segments[] = $query['view'];
                unset($query['view']);
                if (isset($query['category_id'])) {
                    $aliases = DiscussRouter::getCategoryAliases($query['category_id']);
                    foreach ($aliases as $alias) {
                        $segments[] = $alias;
                    }
                    unset($query['category_id']);
                }
                break;
            case 'ask':
                $segments[] = $query['view'];
                unset($query['view']);
                if (isset($query['category'])) {
                    $aliases = DiscussRouter::getCategoryAliases($query['category']);
                    foreach ($aliases as $alias) {
                        $segments[] = $alias;
                    }
                    unset($query['category']);
                }
                break;
            case 'points':
                $segments[] = $query['view'];
                unset($query['view']);
                $segments[] = $query['layout'];
                unset($query['layout']);
                $segments[] = DiscussRouter::getUserAlias($query['id']);
                unset($query['id']);
                break;
            case 'tags':
                $segments[] = $query['view'];
                unset($query['view']);
                if (isset($query['id'])) {
                    $segments[] = DiscussRouter::getTagAlias($query['id']);
                    unset($query['id']);
                }
                break;
            case 'users':
                $segments[] = $query['view'];
                unset($query['view']);
                if (isset($query['sorting'])) {
                    $segments[] = 'latest';
                    unset($query['sorting']);
                }
                break;
            case 'badges':
                $segments[] = $query['view'];
                unset($query['view']);
                if (isset($query['id'])) {
                    $segments[] = DiscussRouter::getAlias('badges', $query['id']);
                    unset($query['id']);
                    unset($query['layout']);
                }
                if (isset($query['layout'])) {
                    $segments[] = $query['layout'];
                    unset($query['layout']);
                }
                break;
            case 'favourites':
                // We don't want to include the view for the entry links.
                $segments[] = $query['view'];
                unset($query['view']);
                break;
            case 'categories':
                $segments[] = $query['view'];
                unset($query['view']);
                if (isset($query['layout'])) {
                    $segments[] = $query['layout'];
                    unset($query['layout']);
                }
                if (isset($query['category_id'])) {
                    $segments[] = DiscussRouter::getAlias('category', $query['category_id']);
                    unset($query['category_id']);
                }
                break;
            case 'conversation':
                $segments[] = $query['view'];
                unset($query['view']);
                if (isset($query['layout'])) {
                    $segments[] = $query['layout'];
                    unset($query['layout']);
                }
                break;
            default:
                $segments[] = $query['view'];
                unset($query['view']);
        }
    }
    if (isset($query['filter'])) {
        $segments[] = $query['filter'];
        unset($query['filter']);
    }
    if (isset($query['sort'])) {
        $segments[] = $query['sort'];
        unset($query['sort']);
    }
    if (!isset($query['Itemid'])) {
        $query['Itemid'] = DiscussRouter::getItemId();
    }
    return $segments;
}
Example #3
0
			<div class=" discuss-searchbar--input">
				<form name="discuss-search" method="GET" action="<?php 
    echo DiscussRouter::_('index.php?option=com_easydiscuss&view=search');
    ?>
">
				<input type="text" class="input-searchbar" placeholder="<?php 
    echo JText::_('COM_EASYDISCUSS_SEARCH_PLACEHOLDER');
    ?>
" name="query" value="<?php 
    echo DiscussHelper::getHelper('String')->escape($query) ? DiscussHelper::getHelper('String')->escape($query) : '';
    ?>
" />
				<input type="hidden" name="option" value="com_easydiscuss" />
				<input type="hidden" name="view" value="search" />
				<input type="hidden" name="Itemid" value="<?php 
    echo DiscussRouter::getItemId('search');
    ?>
" />

				<button class="btn btn-searchbar"><?php 
    echo JText::_('COM_EASYDISCUSS_SEARCH_BUTTON');
    ?>
</button>
				</form>
			</div>
		</div>


	</div>
</div>
<?php 
<?php

/**
 * @package		EasyDiscuss
 * @copyright	Copyright (C) 2010 Stack Ideas Private Limited. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 *
 * EasyDiscuss is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once JPATH_ROOT . '/components/com_easydiscuss/helpers/helper.php';
require_once DISCUSS_HELPERS . '/string.php';
require_once dirname(__FILE__) . '/helper.php';
$lang = JFactory::getLanguage();
$lang->load('mod_easydiscuss_most_voted', JPATH_ROOT);
$posts = modMostVotedHelper::getData($params);
$itemid = DiscussRouter::getItemId('post');
$document = JFactory::getDocument();
DiscussHelper::loadStylesheet("module", "mod_easydiscuss_most_voted");
require JModuleHelper::getLayoutPath('mod_easydiscuss_most_voted');
Example #5
0
 public static function _getMenuItemId(&$params)
 {
     $itemid = DiscussRouter::getItemId('categories');
     return $itemid;
 }
        case 'categories':
            $permalink = DiscussRouter::getAlias('category', $id);
            break;
        case 'post':
            $permalink = DiscussRouter::getAlias('posts', $id);
            break;
        case 'profile':
            $permalink = DiscussRouter::getUserAlias($id);
            break;
        case 'tags':
            $permalink = DiscussRouter::getAlias('tags', $id);
            break;
    }
}
if (empty($Itemid)) {
    $Itemid = DiscussRouter::getItemId($view);
    shAddToGETVarsList('Itemid', $Itemid);
}
$name = shGetComponentPrefix($option);
$name = empty($name) ? getMenuTitle($option, $task, $Itemid, null, $shLangName) : $name;
$name = empty($name) || $name == '/' ? 'discuss' : $name;
$title[] = $name;
if (isset($view) && !empty($view)) {
    // Translate the view
    $title[] = JText::_('COM_EASYDISCUSS_SH404_VIEW_' . JString::strtoupper($view));
    shRemoveFromGETVarsList('view');
}
if ($view == 'categories' && !empty($category_id)) {
    $title[] = DiscussRouter::getAlias('category', $category_id);
    shRemoveFromGETVarsList('category_id');
    // Remove the view since we don't want to set the view.
Example #7
0
 public static function _($url, $xhtml = true, $ssl = null)
 {
     static $eUri = array();
     static $loaded = array();
     // to test if the Itemid is there or not.
     $jURL = $url . $xhtml;
     $index = $url . $xhtml;
     if (isset($loaded[$index])) {
         return $loaded[$index];
     }
     // convert the string to variable so that we can access it.
     parse_str(parse_url($url, PHP_URL_QUERY));
     if (!empty($Itemid)) {
         $loaded[$index] = JRoute::_($url, $xhtml, $ssl);
         return $loaded[$index];
     }
     $tmpId = '';
     $config = DiscussHelper::getConfig();
     $routingBehavior = $config->get('main_routing', 'currentactive');
     $mainframe = JFactory::getApplication();
     $dropSegment = false;
     if (empty($view)) {
         $view = 'index';
     }
     if ($routingBehavior == 'currentactive' || $routingBehavior == 'menuitem') {
         $routingMenuItem = $config->get('main_routing_itemid', '');
         if ($routingBehavior == 'menuitem' && $routingMenuItem != '') {
             $tmpId = $routingMenuItem;
         }
         // @rule: If there is already an item id, try to use the explicitly set one.
         if (empty($tmpId)) {
             if (!$mainframe->isAdmin()) {
                 // Retrieve the active menu item.
                 $menu = JFactory::getApplication()->getMenu();
                 $item = $menu->getActive();
                 if (isset($item->id)) {
                     $tmpId = $item->id;
                 }
             }
         }
     } else {
         // let easydiscuss to determine the best menu itemid.
         switch ($view) {
             case 'list':
             case 'categories':
                 if (isset($category_id)) {
                     $tmpId = self::getItemIdByCategories($category_id);
                 } else {
                     $tmpId = self::getItemId('categories', '', true);
                 }
                 if (!empty($tmpId)) {
                     $dropSegment = true;
                 }
                 break;
             case 'users':
                 $tmpId = self::getItemId('users', '', true);
                 if (!empty($tmpId)) {
                     $dropSegment = true;
                 }
                 break;
             case 'tags':
                 if (isset($id)) {
                     $tmpId = self::getItemIdByTags($id);
                 } else {
                     $tmpId = self::getItemId('tags', '', true);
                 }
                 if (!empty($tmpId)) {
                     $dropSegment = true;
                 }
                 break;
             case 'post':
                 $postId = $id;
                 if (!empty($postId)) {
                     $tbl = DiscussHelper::getTable('Post');
                     $tbl->load($postId);
                     $tmpId = self::getItemIdByDiscussion($tbl->id);
                     // we try to get the menu item base on category id
                     if (empty($tmpId)) {
                         $tmpId = self::getItemIdByCategories($tbl->category_id);
                     }
                 }
                 break;
         }
     }
     if (empty($tmpId)) {
         // make compatible with version 1.1.x where new question will be view=post&layout=submit
         if ($view == 'post') {
             $tmpId = !empty($layout) ? DiscussRouter::getItemId($view, $layout) : DiscussRouter::getItemId($view);
         } else {
             $tmpId = DiscussRouter::getItemId($view);
         }
     }
     if (!empty($tmpId)) {
         if (self::isSefEnabled() && $dropSegment) {
             $url = 'index.php?Itemid=' . $tmpId;
             $loaded[$index] = JRoute::_($url, $xhtml, $ssl);
             return $loaded[$index];
         }
     }
     //check if there is any anchor in the link or not.
     $pos = JString::strpos($url, '#');
     if ($pos === false) {
         $url .= '&Itemid=' . $tmpId;
     } else {
         $url = JString::str_ireplace('#', '&Itemid=' . $tmpId . '#', $url);
     }
     $loaded[$index] = JRoute::_($url, $xhtml, $ssl);
     return $loaded[$index];
 }