Ejemplo n.º 1
0
	public function parseValue($value)
	{
		if ($value && is_numeric($value))
		{
			return JUDownloadFrontHelper::getLicense($value, '*', false);
		}

		return null;
	}
Ejemplo n.º 2
0
	public function display($tpl = null)
	{
		$app        = JFactory::getApplication();
		$licenseId  = $app->input->getInt('id', 0);
		$this->item = JUDownloadFrontHelper::getLicense($licenseId);
		if (!is_object($this->item))
		{
			return JError::raiseError(403, JText::_('COM_JUDOWNLOAD_LICENSE_NOT_FOUND'));
		}

		$this->params = JUDownloadHelper::getParams();

		
		if (count($errors = $this->get('Errors')))
		{
			JError::raiseError(500, implode("\n", $errors));

			return false;
		}

		$limitStart = $app->input->getUint('limitstart', 0);

		$dispatcher = JDispatcher::getInstance();
		JPluginHelper::importPlugin('content');
		$this->item->event = new stdClass();
		$context           = 'com_judownload.license';

		$results                              = $dispatcher->trigger('onContentAfterTitle', array($context, &$this->item, &$this->item->params, $limitStart));
		$this->item->event->afterDisplayTitle = trim(implode("\n", $results));

		$results                                 = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$this->item, &$this->item->params, $limitStart));
		$this->item->event->beforeDisplayContent = trim(implode("\n", $results));

		$results                                = $dispatcher->trigger('onContentAfterDisplay', array($context, &$this->item, &$this->item->params, $limitStart));
		$this->item->event->afterDisplayContent = trim(implode("\n", $results));

		$this->_prepareDocument();

		$this->_setBreadcrumb();

		
		parent::display($tpl);
	}
Ejemplo n.º 3
0
	protected function _prepareData()
	{
		
		$this->token = JSession::getFormToken();

		
		$this->session = JFactory::getSession();

		
		$this->item->changelogs = JUDownloadFrontHelper::getChangeLogField($this->item->id);

		
		$this->item->versions = $this->model->getVersions($this->item->id);

		
		$this->item->related_documents = $this->model->getRelatedDocuments($this->item->id);
		if (count($this->item->related_documents))
		{
			foreach ($this->item->related_documents AS $documentRelated)
			{
				$documentRelated->link = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($documentRelated->id));
				$documentRelated->icon = JUDownloadHelper::getDocumentIcon($documentRelated->icon);
			}
		}

		
		$this->item->files               = JUDownloadFrontHelperDocument::getFilesByDocumentId($this->item->id);
		$this->can_download_document     = JUDownloadFrontHelperPermission::canDownloadDocument($this->item->id, false);
		$this->display_download_rule_msg = $this->params->get('show_rule_messages', 'modal');

		
		$additionFields = array();
		if (trim($this->item->external_link))
		{
			$additionFields[] = 'external_link';
		}

		if ($this->item->license_id && $this->item->confirm_license)
		{
			$additionFields[] = 'license_id';
			$additionFields[] = 'confirm_license';
		}

		$this->item->fieldGallery = JUDownloadFrontHelperField::getField('gallery', $this->item);
		$this->item->fields       = JUDownloadFrontHelperField::getFields($this->item, 2, array(), array('gallery'), $additionFields);

		
		$this->item->license = JUDownloadFrontHelper::getLicense($this->item->license_id);

		$user = JFactory::getUser();
		$uri  = JUri::getInstance();
		
		if ($this->item->checked_out > 0 && $this->item->checked_out != $user->get('id'))
		{
			if (JUDownloadFrontHelperPermission::canCheckInDocument($this->item->id))
			{
				$this->item->checkin_link = JRoute::_('index.php?option=com_judownload&task=forms.checkin&id=' . $this->item->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri)));
			}
		}
		else
		{
			$this->item->edit_link = JRoute::_('index.php?option=com_judownload&task=form.edit&id=' . $this->item->id . '&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($this->item->id));

			if ($this->item->published == 1)
			{
				$this->item->editstate_link = JRoute::_('index.php?option=com_judownload&task=forms.unpublish&id=' . $this->item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($this->item->id));
			}
			else
			{
				$this->item->editstate_link = JRoute::_('index.php?option=com_judownload&task=forms.publish&id=' . $this->item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($this->item->id));
			}
		}

		$this->item->delete_link = JRoute::_('index.php?option=com_judownload&task=forms.delete&id=' . $this->item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($this->item->id));

		
		if ($this->item->is_subscriber)
		{
			$this->item->unsubscribe_link = $this->model->getUnsubscribeLink($this->item->id);
		}
		else
		{
			$this->item->subscribe_link = $this->model->getSubscribeLink($this->item->id);
		}

		$this->item->contact_link = JRoute::_(JUDownloadHelperRoute::getContactRoute($this->item->id));

		$this->item->report_link = JRoute::_(JUDownloadHelperRoute::getReportDocumentRoute($this->item->id));

		$this->item->print_link = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->item->id) . '&layout=print&tmpl=component&print=1');

		
		$this->item->comment = new stdClass();
		
		$this->item->comment->total_comments_no_filter = $this->model->getTotalCommentsOfDocument($this->item->id);

		
		$this->root_comment = JUDownloadFrontHelperComment::getRootComment();

		
		$langArray   = JHtml::_('contentlanguage.existing');
		$JAll        = new JObject();
		$JAll->text  = JText::_('JALL');
		$JAll->value = '*';
		array_unshift($langArray, $JAll);
		$this->langArray = $langArray;

		
		$this->item->comment->items = $this->get('Items');
		foreach ($this->item->comment->items AS $comment)
		{
			if (JUDownloadFrontHelperPermission::canCheckInComment($comment->id))
			{
				$uri                    = JUri::getInstance();
				$comment->checkout_link = 'index.php?option=com_judownload&task=modcomments.checkin&cid=' . $comment->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri));
			}
			else
			{
				$comment->checkout_link = '';
			}
		}

		$this->item->comment->pagination = $this->get('Pagination');

		
		$this->item->comment->total_comments = $this->get('Total');

		
		$this->item->comment->parent_id = $this->root_comment->id;

		
		$this->website_field_in_comment_form = $this->params->get('website_field_in_comment_form', 0);
		$this->min_comment_characters        = $this->params->get('min_comment_characters', 20);
		$this->max_comment_characters        = $this->params->get('max_comment_characters', 1000);

		
		$this->allow_vote_comment      = $this->params->get('allow_vote_comment', 1);
		$this->allow_vote_down_comment = $this->params->get('allow_vote_down_comment', 1);

		
		$this->order_comment_name_array = $this->model->getCommentOrderingOptions();

		
		$this->order_comment_dir_array = array(
			'ASC'  => JText::_('COM_JUDOWNLOAD_ASC'),
			'DESC' => JText::_('COM_JUDOWNLOAD_DESC')
		);

		
		$this->total_stars          = $this->params->get('number_rating_stars', 5);
		$this->filter_comment_stars = array('' => JText::_('COM_JUDOWNLOAD_ANY_STAR'));
		for ($i = 0; $i <= $this->total_stars; $i++)
		{

			$score                              = ($i == 0) ? 0 : round((($i - 1) * 10) / $this->total_stars, 5) . ',' . round(($i * 10) / $this->total_stars, 5);
			$this->filter_comment_stars[$score] = JText::plural('COM_JUDOWNLOAD_N_STAR', $i);
		}

		
		if ($this->params->get('filter_comment_language', 0))
		{
			$this->list_lang_comment = $this->escape($this->state->get('list.lang'));
		}
		$this->list_order_comment  = $this->escape($this->state->get('list.ordering'));
		$this->list_dir_comment    = $this->escape($this->state->get('list.direction'));
		$this->filter_comment_star = $this->state->get('list.star_filter', '');

		
		$this->website  = $this->title = $this->email = $this->comment = $this->name = '';
		$this->language = '*';
		$form           = $this->session->get('judownload_commentform_' . $this->item->id, null);
		$this->form     = $form;
		if (!empty($form) && $form['parent_id'] == $this->root_comment->id)
		{
			$this->title    = $form['title'];
			$this->name     = $form['guest_name'];
			$this->email    = $form['guest_email'];
			$this->comment  = $form['comment'];
			$this->website  = (isset($form['website'])) ? $form['website'] : '';
			$this->language = $form['comment_language'];
		}
	}
Ejemplo n.º 4
0
	public function build(&$query)
	{
		$segments = array();

		
		$app   = JFactory::getApplication('site');
		$menus = $app->getMenu('site');
		
		$activeMenu = $menus->getActive();
		$params     = JUDownloadHelper::getParams();
		$homeItemId = JUDownloadHelperRoute::getHomeMenuItemId();

		
		if (empty($query['Itemid']) && isset($query['view']) && $query['view'] != 'category' && $query['view'] != 'document')
		{
			$query['Itemid'] = JUDownloadHelperRoute::findJUDownloadTreeItemId();
		}

		if (isset($query['view']))
		{
			$menuItem = $menus->getItem($query['Itemid']);

			
			if (isset($menuItem) && ($menuItem->component != 'com_judownload' && $menuItem->id != $homeItemId))
			{
				unset($query['Itemid']);
			}
		}

		if (!$query || (!isset($query['view']) && !isset($query['task'])))
		{
			
			if (isset($query['start']))
			{
				$sefPageConfig = JApplication::stringURLSafe('page');
				$pageX         = JUDownloadHelperRoute::getPage($query['start'], $activeMenu->query['view']);
				$segments[]    = $sefPageConfig . ':' . $pageX;

				unset($query['start']);
			}

			JUDownloadHelperRoute::seoFormat($query, $params, $segments);

			$total = count($segments);

			for ($i = 0; $i < $total; $i++)
			{
				$segments[$i] = str_replace(':', '-', $segments[$i]);
			}

			if (isset($query['limit']))
			{
				unset($query['limit']);
			}

			
			return $segments;
		}

		$hasActiveMenu = false;
		if (is_object($activeMenu) && isset($activeMenu->query))
		{
			if (isset($query['Itemid']) && ($query['Itemid'] == $activeMenu->id))
			{
				$hasActiveMenu = JUDownloadHelperRoute::compareQuery($activeMenu, $query);
			}
		}

		

		
		if (isset($query['view']) && $query['view'] == 'categories')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['id']))
				{
					if (isset($query['Itemid']))
					{
						if ($query['Itemid'] == $homeItemId)
						{
							
							$sefRootCategory = JApplication::stringURLSafe('root');
							$segments[]      = JApplication::stringURLSafe($sefRootCategory);
						}
					}

					
					$sefCategoriesConfig = JApplication::stringURLSafe('categories');
					$segments[]          = JApplication::stringURLSafe($sefCategoriesConfig);

					$categoryObject = JUDownloadHelper::getCategoryById($query['id']);

					$segments[] = $query['id'] . ":" . (isset($categoryObject->alias) ? $categoryObject->alias : '');

					unset($query['id']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'category')
		{
			if (!$hasActiveMenu)
			{
				$fullPathCategory = $params->get('sef_category_full_path', 0);
				if (isset($query['id']))
				{
					$segments = JUDownloadHelperRoute::getCategorySegment($query['id'], $query, $fullPathCategory);
					if ($segments !== false)
					{
						unset($query['id']);
					}
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			if (isset($query['format']))
			{
				$segments[] = JApplication::stringURLSafe('rss');
				unset($query['format']);
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'advsearch')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = JApplication::stringURLSafe('root');
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('advanced-search');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'collection')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				if (isset($query['id']) && $query['id'])
				{
					if (isset($query['user_id']))
					{
						$user       = JFactory::getUser($query['user_id']);
						$userAlias  = JApplication::stringURLSafe($user->username);
						$segments[] = $query['user_id'] . ':' . $userAlias;
						unset($query['user_id']);
					}

					$segments[] = JApplication::stringURLSafe('collection');

					$collectionObject = JUDownloadFrontHelper::getCollectionById($query['id']);

					$segments[] = $query['id'] . ':' . (isset($collectionObject->alias) ? $collectionObject->alias : '');
					unset($query['id']);

					JUDownloadHelperRoute::seoLayout($query, $segments, $params);
				}
				else
				{
					$segments[] = JApplication::stringURLSafe('collection');

					$segments[] = JApplication::stringURLSafe('new-collection');

					JUDownloadHelperRoute::seoLayout($query, $segments, $params);

					if (isset($query['id']))
					{
						unset($query['id']);
					}
				}
			}
			else
			{
				if (isset($query['user_id']))
				{
					unset($query['user_id']);
				}

				if (isset($query['id']))
				{
					unset($query['id']);
				}
			}

			if (isset($query['format']))
			{
				$segments[] = JApplication::stringURLSafe('rss');
				unset($query['format']);
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'collections')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = JApplication::stringURLSafe('root');
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				if (isset($query['id']))
				{
					$user       = JFactory::getUser($query['id']);
					$userAlias  = JApplication::stringURLSafe($user->username);
					$segments[] = $query['id'] . ':' . $userAlias;
					unset($query['id']);
				}

				$segments[] = JApplication::stringURLSafe('collections');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'commenttree' && isset($query['id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('comment-tree');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['id'] . ':' . $commentAlias;

			if (isset($query['tmpl']))
			{
				$segments[] = JApplication::stringURLSafe('component');
				unset($query['tmpl']);
			}

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'contact' && isset($query['doc_id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('contact');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['doc_id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'dashboard')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			if (isset($query['id']))
			{
				$user       = JFactory::getUser($query['id']);
				$userAlias  = JApplication::stringURLSafe($user->username);
				$segments[] = $query['id'] . ':' . $userAlias;
				unset($query['id']);
			}

			$segments[] = JApplication::stringURLSafe('dashboard');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'document')
		{
			if (!$hasActiveMenu)
			{
				$seoLayout = true;
				if (isset($query['id']))
				{
					$segments = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
					unset($query['id']);
				}

				if (isset($query['print']))
				{
					$seoLayout  = false;
					$segments[] = JApplication::stringURLSafe('print');
					unset($query['print']);
					unset($query['layout']);
					unset($query['tmpl']);
				}

				if (isset($query['layout']) && $query['layout'] == 'changelogs')
				{
					$seoLayout  = false;
					$segments[] = JApplication::stringURLSafe('changelogs');
					unset($query['layout']);
				}

				if (isset($query['layout']) && $query['layout'] == 'versions')
				{
					$seoLayout  = false;
					$segments[] = JApplication::stringURLSafe('versions');
					unset($query['layout']);
				}

				if ($seoLayout)
				{
					JUDownloadHelperRoute::seoLayout($query, $segments, $params);
				}
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'documents')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('modal-documents');

			if (isset($query['tmpl']))
			{
				$segments[] = $query['tmpl'];
				unset($query['tmpl']);
			}

			if (isset($query['function']))
			{
				$segments[] = $query['function'];
				unset($query['function']);
			}

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		

		
		if (isset($query['view']) && $query['view'] == 'downloaderror')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('error-download');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			if (isset($query['return']))
			{
				$segments[] = $query['return'];
				unset($query['return']);
			}

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'featured')
		{
			if (!$hasActiveMenu)
			{
				$addCategoryToSegment = true;
				if (isset($query['Itemid']))
				{
					if ($query['Itemid'] == $homeItemId)
					{
						
						$sefRootCategory = JApplication::stringURLSafe('root');
						$segments[]      = JApplication::stringURLSafe($sefRootCategory);

						if (isset($query['id']))
						{
							$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
							if ($categoryObject->level > 0)
							{
								$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
							}
							unset($query['id']);
						}

						$addCategoryToSegment = false;
					}
					else
					{
						$assignMenuFeatured = $menus->getItem($query['Itemid']);
						if ($assignMenuFeatured && isset($assignMenuFeatured->query) && $assignMenuFeatured->query['view'] == 'tree'
							&& isset($assignMenuFeatured->query['id'])
						)
						{
							if (isset($query['id']))
							{
								$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
								if ($assignMenuFeatured->query['id'] != $categoryObject->id)
								{
									$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								}
								unset($query['id']);
							}

							$addCategoryToSegment = false;
						}
					}
				}

				if ($addCategoryToSegment)
				{
					if (isset($query['id']))
					{
						$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
						$segments[]     = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
						unset($query['id']);
					}
				}

				$segments[] = JApplication::stringURLSafe('featured');

				if (isset($query['all']))
				{
					if ($query['all'] == 1)
					{
						$segments[] = JApplication::stringURLSafe('all');
					}
					unset($query['all']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['all']))
				{
					unset($query['all']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			if (isset($query['format']))
			{
				$segments[] = JApplication::stringURLSafe('rss');
				unset($query['format']);
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'form' && isset($query['layout']) && $query['layout'] == 'edit' && (!isset($query['id']) || (isset($query['id']) && !$query['id'])))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			if (isset($query['cat_id']))
			{
				$categoryObject = JUDownloadHelper::getCategoryById($query['cat_id']);
				$segments[]     = $query['cat_id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
				unset($query['cat_id']);
			}
			else
			{
				$categoryRoot = JUDownloadFrontHelperCategory::getRootCategory();
				if (is_object($categoryRoot))
				{
					$segments[] = $categoryRoot->id . ':' . (isset($categoryRoot->alias) ? $categoryRoot->alias : '');
				}
			}

			$segments[] = JApplication::stringURLSafe('new-document');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'form' && isset($query['layout']) && $query['layout'] == 'edit' && isset($query['id']) && $query['id'])
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			if (isset($query['approve']) && $query['approve'] == 1)
			{
				$segments[] = JApplication::stringURLSafe('approve');
				unset($query['approve']);
			}

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'license' && isset($query['id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('license');

			$licenseObject = JUDownloadFrontHelper::getLicense($query['id']);

			$segments[] = $query['id'] . ':' . (isset($licenseObject->alias) ? $licenseObject->alias : '');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'listall')
		{
			if (!$hasActiveMenu)
			{
				$addCategoryToSegment = true;
				if (isset($query['Itemid']))
				{
					if ($query['Itemid'] == $homeItemId)
					{
						
						$sefRootCategory = JApplication::stringURLSafe('root');
						$segments[]      = JApplication::stringURLSafe($sefRootCategory);

						if (isset($query['id']))
						{
							$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
							if ($categoryObject->level > 0)
							{
								$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								unset($query['id']);
							}
						}

						$addCategoryToSegment = false;
					}
					else
					{
						$assignMenuListAll = $menus->getItem($query['Itemid']);
						if ($assignMenuListAll && isset($assignMenuListAll->query) && $assignMenuListAll->query['view'] == 'tree'
							&& isset($assignMenuListAll->query['id'])
						)
						{
							if (isset($query['id']))
							{
								$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
								if ($assignMenuListAll->query['id'] != $categoryObject->id)
								{
									$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								}
								unset($query['id']);
							}

							$addCategoryToSegment = false;
						}
					}
				}

				if ($addCategoryToSegment)
				{
					if (isset($query['id']))
					{
						$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
						$segments[]     = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
						unset($query['id']);
					}
				}

				$segments[] = JApplication::stringURLSafe('list-all');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}
			}

			if (isset($query['format']))
			{
				$segments[] = JApplication::stringURLSafe('rss');
				unset($query['format']);
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'listalpha')
		{
			if (!$hasActiveMenu)
			{
				$addCategoryToSegment = true;
				if (isset($query['Itemid']))
				{
					if ($query['Itemid'] == $homeItemId)
					{
						
						$sefRootCategory = JApplication::stringURLSafe('root');
						$segments[]      = JApplication::stringURLSafe($sefRootCategory);

						if (isset($query['id']))
						{
							$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
							if ($categoryObject->level > 0)
							{
								$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
							}
							unset($query['id']);
						}

						$addCategoryToSegment = false;
					}
					else
					{
						$assignMenuListAlpha = $menus->getItem($query['Itemid']);
						if ($assignMenuListAlpha && isset($assignMenuListAlpha->query) && $assignMenuListAlpha->query['view'] == 'tree'
							&& isset($assignMenuListAlpha->query['id'])
						)
						{
							if (isset($query['id']))
							{
								$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
								if ($assignMenuListAlpha->query['id'] != $categoryObject->id)
								{
									$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								}
								unset($query['id']);
							}

							$addCategoryToSegment = false;
						}
					}
				}

				if ($addCategoryToSegment)
				{
					if (isset($query['id']))
					{
						$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
						$segments[]     = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
						unset($query['id']);
					}
				}

				$segments[] = JApplication::stringURLSafe('list-alpha');

				if (isset($query['alpha']))
				{
					$segments[] = $query['alpha'];
					unset($query['alpha']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['alpha']))
				{
					unset($query['alpha']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			if (isset($query['format']))
			{
				$segments[] = JApplication::stringURLSafe('rss');
				unset($query['format']);
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'maintenance')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('maintenance');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modcomment' && isset($query['layout']) && $query['layout'] == 'edit' && isset($query['id']) && $query['id'])
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('mod-comment');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['id']);
			if (is_object($commentObject))
			{
				$commentAlias = JApplication::stringURLSafe($commentObject->title);
				$segments[]   = $query['id'] . ':' . $commentAlias;
				unset($query['id']);
			}

			if (isset($query['approve']) && $query['approve'])
			{
				$segments[] = JApplication::stringURLSafe('approve');
				unset($query['approve']);
			}

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
			unset($query['layout']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modcomments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = JApplication::stringURLSafe('root');
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('mod-comments');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'moddocuments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = JApplication::stringURLSafe('root');
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('mod-documents');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modpermission' && isset($query['id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('mod-permission');
			$segments[] = $query['id'];

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modpermissions')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = 'root';
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('mod-permissions');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modpendingcomments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('mod-pending-comments');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modpendingdocuments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('mod-pending-documents');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'profile')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = 'root';
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('profile');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'report' && isset($query['doc_id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = 'root';
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('report');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['doc_id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'report' && isset($query['comment_id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = 'root';
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[]    = JApplication::stringURLSafe('comment');
			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['comment_id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['comment_id'] . ':' . $commentAlias;
			unset($query['comment_id']);

			$segments[] = JApplication::stringURLSafe('report');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['comment_id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'search')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				if (isset($query['cat_id']))
				{
					$categoryObject = JUDownloadHelper::getCategoryById($query['cat_id']);
					$segments[]     = $query['cat_id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
					unset($query['cat_id']);
				}

				if (isset($query['sub_cat']))
				{
					$segments[] = JApplication::stringURLSafe('all');
					unset($query['sub_cat']);
				}

				$segments[] = JApplication::stringURLSafe('search');

				if (isset($query['searchword']))
				{
					$segments[] = $query['searchword'];
					unset($query['searchword']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['cat_id']))
				{
					unset($query['cat_id']);
				}

				if (isset($query['searchword']))
				{
					unset($query['searchword']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'searchby')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('search-by');

				if (isset($query['field_id']))
				{
					$fieldObject = JUDownloadFrontHelperField::getFieldById($query['field_id']);
					$segments[]  = $query['field_id'] . ':' . (isset($fieldObject->alias) ? $fieldObject->alias : '');
					unset($query['field_id']);
				}

				if (isset($query['value']))
				{
					$segments[] = $query['value'];
					unset($query['value']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['field_id']))
				{
					unset($query['field_id']);
				}

				if (isset($query['value']))
				{
					unset($query['value']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'subscribe' && isset($query['doc_id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = 'root';
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('guest-subscribe');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['doc_id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'tag' && isset($query['id']))
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('tag');

				$tagObject = JUDownloadFrontHelper::getTagById($query['id']);

				$segments[] = $query['id'] . ':' . (isset($tagObject->alias) ? $tagObject->alias : '');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoFormat($query, $params, $segments);

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'tags')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('tags');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'topcomments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('top-comments');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'topdocuments')
		{
			$addCategoryToSegment = true;
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']))
				{
					if ($query['Itemid'] == $homeItemId)
					{
						
						$sefRootCategory = 'root';
						$segments[]      = JApplication::stringURLSafe($sefRootCategory);

						if (isset($query['id']))
						{
							$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
							if ($categoryObject->level > 0)
							{
								$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
							}
							unset($query['id']);
						}

						$addCategoryToSegment = false;
					}
					else
					{
						$assignMenuTopDocuments = $menus->getItem($query['Itemid']);
						if ($assignMenuTopDocuments && isset($assignMenuTopDocuments->query) && $assignMenuTopDocuments->query['view'] == 'tree'
							&& isset($assignMenuTopDocuments->query['id'])
						)
						{
							if (isset($query['id']))
							{
								$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
								if ($assignMenuTopDocuments->query['id'] != $categoryObject->id)
								{
									$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								}
								unset($query['id']);
							}

							$addCategoryToSegment = false;
						}
					}
				}

				if ($addCategoryToSegment)
				{
					if (isset($query['id']))
					{
						$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
						$segments[]     = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
						unset($query['id']);
					}
				}

				if (isset($query['ordertype']))
				{
					switch ($query['ordertype'])
					{
						case 'new' :
							$segments[] = JApplication::stringURLSafe('latest-documents');
							break;
						case 'featured' :
							$segments[] = JApplication::stringURLSafe('top-featured-documents');
							break;
						case 'recent_modified' :
							$segments[] = JApplication::stringURLSafe('recent-modified-documents');
							break;
						case 'recent_updated' :
							$segments[] = JApplication::stringURLSafe('recent-updated-documents');
							break;
						case 'popular' :
							$segments[] = JApplication::stringURLSafe('popular-documents');
							break;
						case 'most_downloaded' :
							$segments[] = JApplication::stringURLSafe('most-downloaded-documents');
							break;
						case 'most_rated' :
							$segments[] = JApplication::stringURLSafe('most-rated-documents');
							break;
						case 'top_rated' :
							$segments[] = JApplication::stringURLSafe('top-rated-documents');
							break;
						case 'latest_rated' :
							$segments[] = JApplication::stringURLSafe('latest-rated-documents');
							break;
						case 'most_commented' :
							$segments[] = JApplication::stringURLSafe('most-commented-documents');
							break;
						case 'latest_commented' :
							$segments[] = JApplication::stringURLSafe('latest-commented-documents');
							break;
						case 'recently_viewed' :
							$segments[] = JApplication::stringURLSafe('recent-viewed-documents');
							break;
						case 'alpha_ordered' :
							$segments[] = JApplication::stringURLSafe('alpha-ordered-documents');
							break;
						case 'random' :
							$segments[] = JApplication::stringURLSafe('random-documents');
							break;
						case 'random_fast' :
							$segments[] = JApplication::stringURLSafe('random-fast-documents');
							break;
						case 'random_featured' :
							$segments[] = JApplication::stringURLSafe('random-featured-documents');
							break;
						default:
							$segments[] = JApplication::stringURLSafe('latest-documents');
					}
					unset($query['ordertype']);
				}

				if (isset($query['all']))
				{
					if ($query['all'] == 1)
					{
						$segments[] = JApplication::stringURLSafe('all');
					}

					unset($query['all']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['ordertype']))
				{
					unset($query['ordertype']);
				}

				if (isset($query['all']))
				{
					unset($query['all']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoFormat($query, $params, $segments);

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'tree' && isset($query['id']))
		{
			if (!$hasActiveMenu)
			{
				$addCategoryToSegment = true;
				if (isset($query['Itemid']))
				{
					if ($query['Itemid'] == $homeItemId)
					{
						
						$sefRootCategory = 'root';
						$segments[]      = JApplication::stringURLSafe($sefRootCategory);

						if (isset($query['id']))
						{
							$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
							if ($categoryObject->level > 0)
							{
								$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
							}
							unset($query['id']);
						}

						$addCategoryToSegment = false;
					}
					else
					{
						$assignMenuTree = $menus->getItem($query['Itemid']);
						if ($assignMenuTree && isset($assignMenuTree->query) && $assignMenuTree->query['view'] == 'tree'
							&& isset($assignMenuTree->query['id'])
						)
						{
							if (isset($query['id']))
							{
								$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
								if ($assignMenuTree->query['id'] != $categoryObject->id)
								{
									$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								}
								unset($query['id']);
							}

							$addCategoryToSegment = false;
						}
					}
				}

				$segments[] = 'tree';

				if ($addCategoryToSegment)
				{
					if (isset($query['id']))
					{
						$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
						$segments[]     = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
					}
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoFormat($query, $params, $segments);

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'usercomments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				if (isset($query['id']))
				{
					$user       = JFactory::getUser($query['id']);
					$userAlias  = JApplication::stringURLSafe($user->username);
					$segments[] = $query['id'] . ':' . $userAlias;
					unset($query['id']);
				}
				$segments[] = JApplication::stringURLSafe('comments');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'userdocuments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				if (isset($query['id']))
				{
					$user       = JFactory::getUser($query['id']);
					$userAlias  = JApplication::stringURLSafe($user->username);
					$segments[] = $query['id'] . ':' . $userAlias;
					unset($query['id']);
				}

				$segments[] = JApplication::stringURLSafe('documents');

				if (isset($query['filter']))
				{
					if ($query['filter'] == 'pending')
					{
						$segments[] = JApplication::stringURLSafe('pending');
					}
					elseif ($query['filter'] == 'unpublished')
					{
						$segments[] = JApplication::stringURLSafe('unpublished');
					}
					else
					{
						$segments[] = JApplication::stringURLSafe('published');
					}
					unset($query['filter']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['filter']))
				{
					unset($query['filter']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoFormat($query, $params, $segments);

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'usersubscriptions' && isset($query['id']))
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$user       = JFactory::getUser($query['id']);
				$userAlias  = JApplication::stringURLSafe($user->username);
				$segments[] = $query['id'] . ':' . $userAlias;
				$segments[] = JApplication::stringURLSafe('user-subscriptions');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if ($query['layout'])
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['id']);
			unset($query['view']);
		}

		

		
		if (isset($query['task']) && $query['task'] == 'form.add')
		{
			if (isset($query['cat_id']))
			{
				$categoryObject = JUDownloadHelper::getCategoryById($query['cat_id']);
				if (is_object($categoryObject))
				{
					$segments[] = $query['cat_id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
					unset($query['cat_id']);
				}
			}

			$segments[] = JApplication::stringURLSafe('add');
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'form.edit' && isset($query['id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('edit');

			if (isset($query['layout']))
			{
				unset($query['layout']);
			}

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'forms.delete' && isset($query['id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('delete');

			unset($query['id']);
			unset($query['task']);
		}

		if (isset($query['task']) && $query['task'] == 'forms.checkin' && isset($query['id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('checkin');

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'modpendingdocument.edit' && isset($query['id']))
		{
			$segments = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);

			if (isset($query['approve']))
			{
				$segments[] = JApplication::stringURLSafe('approve');
				unset($query['approve']);
			}

			if (isset($query['layout']))
			{
				unset($query['layout']);
			}

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'forms.unpublish' && isset($query['id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('unpublish');

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'forms.publish' && isset($query['id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('publish');

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'subscribe.save' && isset($query['doc_id']) && !isset($query['comment_id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('subscribe');

			unset($query['doc_id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'download.download' && isset($query['doc_id']))
		{
			$segments = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);

			if (isset($query['version']))
			{
				$segments[] = $query['version'];
				unset($query['version']);
			}
			else
			{
				$segments[] = JApplication::stringURLSafe('latest');
			}

			$segments[] = JApplication::stringURLSafe('download');

			unset($query['doc_id']);
			unset($query['task']);
		}

		if (isset($query['task']) && $query['task'] == 'download.download' && isset($query['file_id']))
		{
			$segments[] = JApplication::stringURLSafe('file');
			$fileObject = JUDownloadFrontHelper::getFileObject($query['file_id']);
			$fileAlias  = JApplication::stringURLSafe($fileObject->rename);
			$segments[] = $query['file_id'] . ':' . $fileAlias;

			if (isset($query['version']))
			{
				$segments[] = $query['version'];
				unset($query['version']);
			}
			else
			{
				$segments[] = JApplication::stringURLSafe('latest');
			}

			$segments[] = JApplication::stringURLSafe('download');

			unset($query['file_id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'document.redirecturl')
		{
			if (isset($query['doc_id']))
			{
				$segments = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
				unset($query['doc_id']);
			}

			if (isset($query['field_id']))
			{
				$fieldObject = JUDownloadFrontHelperField::getFieldById($query['field_id']);
				$segments[]  = $query['field_id'] . ':' . (isset($fieldObject->alias) ? $fieldObject->alias : '');
				unset($query['field_id']);
			}

			$segments[] = JApplication::stringURLSafe('redirect-url');

			unset($query['task']);
		}

		

		
		if (isset($query['task']) && $query['task'] == 'modcomment.edit' && isset($query['id']))
		{
			$segments[] = JApplication::stringURLSafe('comment');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['id'] . ':' . $commentAlias;
			unset($query['id']);

			$segments[] = JApplication::stringURLSafe('edit');

			if (isset($query['layout']))
			{
				unset($query['layout']);
			}

			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'modpendingcomment.edit' && isset($query['id']))
		{
			$segments[] = JApplication::stringURLSafe('comment');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['id'] . ':' . $commentAlias;
			unset($query['id']);

			$segments[] = JApplication::stringURLSafe('approve');

			if (isset($query['layout']))
			{
				unset($query['layout']);
			}

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'subscribe.save' && isset($query['comment_id']))
		{
			$segments[] = JApplication::stringURLSafe('comment');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['comment_id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['comment_id'] . ':' . $commentAlias;
			unset($query['comment_id']);

			$segments[] = JApplication::stringURLSafe('subscribe');
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'subscribe.remove' && isset($query['sub_id']))
		{
			$subscriptionObject = JUDownloadFrontHelper::getSubscriptionObject($query['sub_id']);
			if ($subscriptionObject->type == 'document')
			{
				$segments = JUDownloadHelperRoute::getDocumentSegment($subscriptionObject->item_id, $query, $params);

				$segments[] = JApplication::stringURLSafe('unsubscribe');

				$segments[] = $query['sub_id'];

				if ($query['code'])
				{
					$segments[] = $query['code'];
					unset($query['code']);
				}

				unset($query['doc_id']);
				unset($query['task']);

				unset($query['sub_id']);
				unset($query['task']);
			}
			elseif ($subscriptionObject->type == 'comment')
			{
				$segments[] = JApplication::stringURLSafe('comment');

				$commentObject = JUDownloadFrontHelperComment::getCommentObject($subscriptionObject->item_id);
				if (is_object($commentObject))
				{
					$commentAlias = JApplication::stringURLSafe($commentObject->title);
					$segments[]   = $commentObject->id . ':' . $commentAlias;
				}

				$segments[] = JApplication::stringURLSafe('unsubscribe');

				$segments[] = $query['sub_id'];

				if ($query['code'])
				{
					$segments[] = $query['code'];
					unset($query['code']);
				}

				unset($query['sub_id']);
				unset($query['task']);
			}
		}

		
		if (isset($query['task']) && $query['task'] == 'document.deleteComment' && isset($query['comment_id']))
		{
			$segments[] = JApplication::stringURLSafe('comment');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['comment_id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['comment_id'] . ':' . $commentAlias;
			unset($query['comment_id']);

			$segments[] = JApplication::stringURLSafe('delete');
			unset($query['task']);
		}

		

		
		if (isset($query['task']) && $query['task'] == 'collection.add')
		{
			$segments[] = JApplication::stringURLSafe('collection');
			$segments[] = JApplication::stringURLSafe('add');

			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'collection.edit' && isset($query['id']))
		{
			if (isset($query['user_id']))
			{
				$user       = JFactory::getUser($query['user_id']);
				$userAlias  = JApplication::stringURLSafe($user->username);
				$segments[] = $query['user_id'] . ':' . $userAlias;
				unset($query['user_id']);
			}

			$segments[] = JApplication::stringURLSafe('collection');

			$collectionObject = JUDownloadFrontHelper::getCollectionById($query['id']);

			$segments[] = $query['id'] . ':' . (isset($collectionObject->alias) ? $collectionObject->alias : '');
			unset($query['id']);

			$segments[] = JApplication::stringURLSafe('edit');

			if (isset($query['layout']))
			{
				unset($query['layout']);
			}

			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'collections.delete' && isset($query['cid']))
		{
			$segments[] = JApplication::stringURLSafe('collection');

			$collectionObject = JUDownloadFrontHelper::getCollectionById($query['cid']);

			$segments[] = $query['cid'] . ':' . (isset($collectionObject->alias) ? $collectionObject->alias : '');
			unset($query['cid']);

			$segments[] = JApplication::stringURLSafe('delete');

			unset($query['task']);
		}

		

		
		if (isset($query['task']) && $query['task'] == 'usersubscriptions.unsubscribe' && isset($query['sub_id']))
		{
			$segments[] = JApplication::stringURLSafe('user-subscriptions');
			$segments[] = $query['sub_id'];
			$segments[] = JApplication::stringURLSafe('unsubscribe');

			unset($query['sub_id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'rawdata')
		{
			if (isset($query['doc_id']))
			{
				$segments = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
				unset($query['doc_id']);
			}

			if (isset($query['field_id']))
			{
				$fieldObject = JUDownloadFrontHelperField::getFieldById($query['field_id']);

				$segments[] = $query['field_id'] . ':' . (isset($fieldObject->alias) ? $fieldObject->alias : '');
				unset($query['field_id']);
			}

			$segments[] = JApplication::stringURLSafe('raw-data');
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'subscribe.activate')
		{
			$segments[] = JApplication::stringURLSafe('activate-subscription');

			if ($query['id'])
			{
				$segments[] = $query['id'];
			}

			if (isset($query['code']))
			{
				$segments[] = $query['code'];
			}

			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'email.downloadattachment')
		{
			$segments[] = JApplication::stringURLSafe('email');
			$segments[] = JApplication::stringURLSafe('download-attachment');

			if (isset($query['mail_id']))
			{
				$segments[] = $query['mail_id'];
				unset($query['mail_id']);
			}

			if (isset($query['file']))
			{
				$segments[] = $query['file'];
				unset($query['file']);
			}

			if (isset($query['code']))
			{
				$segments[] = $query['code'];
				unset($query['code']);
			}

			unset($query['task']);
		}

		$total = count($segments);

		for ($i = 0; $i < $total; $i++)
		{
			$segments[$i] = str_replace(':', '-', $segments[$i]);
		}

		if (isset($query['limit']))
		{
			unset($query['limit']);
		}

		return $segments;
	}