Пример #1
0
 public function display($tpl = null)
 {
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->canDo = JUDirectoryHelper::getActions('com_judirectory');
     $this->groupCanDoManage = JUDirectoryHelper::checkGroupPermission("comment.edit");
     $this->groupCanDoDelete = JUDirectoryHelper::checkGroupPermission("comments.delete");
     $this->rootComment = JUDirectoryFrontHelperComment::getRootComment();
     foreach ($this->items as &$item) {
         $this->ordering[$item->parent_id][] = $item->id;
     }
     $this->addToolBar();
     if (JUDirectoryHelper::isJoomla3x()) {
         $layout = JFactory::getApplication()->input->get('layout', '');
         if ($layout != 'modal') {
             $this->filterForm = $this->get('FilterForm');
             $this->activeFilters = $this->get('ActiveFilters');
         }
     }
     parent::display($tpl);
     $this->setDocument();
 }
Пример #2
0
 function approve($comment_ids)
 {
     if (!is_array($comment_ids) || empty($comment_ids)) {
         $this->setError('COM_JUDIRECTORY_NO_ITEM_SELECTED');
         return false;
     }
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables');
     $comment_table = JTable::getInstance("Comment", "JUDirectoryTable");
     $count = 0;
     $comment_ids = (array) $comment_ids;
     $rootComment = JUDirectoryFrontHelperComment::getRootComment();
     $listingIds = array();
     foreach ($comment_ids as $comment_id) {
         $comment_table->reset();
         if ($comment_table->load($comment_id) && $comment_table->parent_id == $rootComment->id && $comment_table->approved == 0) {
             $listingIds[$comment_table->listing_id] = $comment_table->listing_id;
         }
         $user = JFactory::getUser();
         $date = JFactory::getDate();
         $comment_table->approved = 1;
         $comment_table->published = 1;
         $comment_table->approved_by = $user->id;
         $comment_table->approved_time = $date->toSql();
         $comment_table->store();
         $count++;
         JUDirectoryFrontHelperMail::sendEmailByEvent('comment.approve', $comment_id);
         $logData = array('user_id' => $comment_table->user_id, 'event' => 'comment.approve', 'item_id' => $comment_id, 'listing_id' => $comment_table->listing_id, 'value' => 0, 'reference' => '');
         JUDirectoryFrontHelperLog::addLog($logData);
     }
     foreach ($listingIds as $listingId) {
         JUDirectoryHelper::rebuildRating($listingId);
     }
     return $count;
 }
Пример #3
0
 protected function allowEdit($data = array(), $key = 'id')
 {
     $recordId = (int) isset($data[$key]) ? $data[$key] : 0;
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $rootComment = JUDirectoryFrontHelperComment::getRootComment();
     if ($recordId && $recordId == $rootComment->id) {
         return false;
     }
     if ($user->authorise('core.edit', 'com_judirectory')) {
         return true;
     }
     if ($user->authorise('core.edit.own', 'com_judirectory')) {
         $ownerId = (int) isset($data['user_id']) ? $data['user_id'] : 0;
         if (empty($ownerId) && $recordId) {
             $record = $this->getModel()->getItem($recordId);
             if (empty($record)) {
                 return false;
             }
             $ownerId = $record->user_id;
         }
         if ($ownerId == $userId) {
             return true;
         }
     }
     return parent::allowEdit($data, $key);
 }
Пример #4
0
 protected function getInput()
 {
     $hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
     $size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
     $maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
     $class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
     $readonly = $this->readonly ? ' readonly' : '';
     $disabled = $this->disabled ? ' disabled' : '';
     $required = $this->required ? ' required aria-required="true"' : '';
     $hint = $hint ? ' placeholder="' . $hint . '"' : '';
     $autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
     $autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
     $autofocus = $this->autofocus ? ' autofocus' : '';
     $spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
     $pattern = !empty($this->pattern) ? ' pattern="' . $this->pattern . '"' : '';
     $inputmode = !empty($this->inputmode) ? ' inputmode="' . $this->inputmode . '"' : '';
     $dirname = !empty($this->dirname) ? ' dirname="' . $this->dirname . '"' : '';
     $onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
     $commentObject = JUDirectoryFrontHelperComment::getCommentObject($this->value);
     if ($commentObject->level > 0) {
         $commentLink = JRoute::_('index.php?option=com_judirectory&amp;task=comment.edit&amp;id=' . $commentObject->id);
         $html[] = '<div class="btn"><a href="' . $commentLink . '" target="_blank">' . $commentObject->title . '</a></div>';
     } else {
         $html[] = '<div class="btn">' . JText::_('COM_JUDIRECTORY_NO_PARENT') . '</div>';
     }
     $html[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '"' . $dirname . ' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $size . $disabled . $readonly . $hint . $onchange . $maxLength . $required . $autocomplete . $autofocus . $spellcheck . $inputmode . $pattern . ' />';
     return implode($html);
 }
Пример #5
0
 public function display($tpl = null)
 {
     $this->items = $this->get('Items');
     $this->params = JUDirectoryHelper::getParams();
     $this->state = $this->get('State');
     $this->pagination = $this->get('Pagination');
     $this->root_comment = JUDirectoryFrontHelperComment::getRootComment();
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->order_name_array = array('cm.title' => JText::_('COM_JUDIRECTORY_FIELD_TITLE'), 'cm.created' => JText::_('COM_JUDIRECTORY_FIELD_CREATED'), 'r.score' => JText::_('COM_JUDIRECTORY_FIELD_RATING_SCORE'), 'cm.helpful_votes' => JText::_('COM_JUDIRECTORY_FIELD_HELPFUL_VOTES'), 'cm.total_votes' => JText::_('COM_JUDIRECTORY_FIELD_TOTAL_VOTES'));
     $this->order_dir_array = array('ASC' => JText::_('COM_JUDIRECTORY_ASC'), 'DESC' => JText::_('COM_JUDIRECTORY_DESC'));
     $this->listOrder = $this->escape($this->state->get('list.ordering'));
     $this->listDirn = $this->escape($this->state->get('list.direction'));
     $this->_prepareDocument();
     $this->_setBreadcrumb();
     parent::display($tpl);
 }
Пример #6
0
 protected static function autoLinkVideo($text, $listingId = null)
 {
     $params = JUDirectoryHelper::getParams(null, $listingId);
     $auto_embed_youtube_in_comment = $params->get('auto_embed_youtube_in_comment', 0);
     $auto_embed_vimeo_in_comment = $params->get('auto_embed_vimeo_in_comment', 0);
     $video_width_in_comment = $params->get('video_width_in_comment', 360);
     $video_height_in_comment = $params->get('video_height_in_comment', 240);
     $regexYoutube = "#(?:http(?:s)?:\\/\\/)?(?:www\\.)?(?:youtu\\.be\\/|youtube\\.com\\/(?:(?:watch)?\\?(?:.*&)?v(?:i)?=|(?:v|vi|user)\\/))([^\\?&\"'<>\\/\\s]+)(?:\$|\\/|\\?|\\&)?#i";
     preg_match_all($regexYoutube, $text, $matchesYoutube);
     if ($auto_embed_youtube_in_comment && count($matchesYoutube[0])) {
         foreach ($matchesYoutube[0] as $key => $match) {
             $youtube_html = JUDirectoryFrontHelperComment::parseVideo($match, $video_width_in_comment, $video_height_in_comment);
             $text = str_replace($matchesYoutube[0][$key], $youtube_html . '<br/>', $text);
         }
     }
     $regexVimeo = "#(?:http(?:s)?:\\/\\/)?(?:www\\.)?vimeo.com\\/(\\d+)(?:\$|\\/|\\?)?#";
     preg_match_all($regexVimeo, $text, $matchesVimeo);
     if ($auto_embed_vimeo_in_comment && count($matchesVimeo[0])) {
         $arrIdVimeo = array_unique($matchesVimeo[0]);
         foreach ($arrIdVimeo as $key => $match) {
             $vimeo_html = JUDirectoryFrontHelperComment::parseVideo($match, $video_width_in_comment, $video_height_in_comment);
             $text = str_replace($matchesVimeo[0][$key], $vimeo_html, $text);
         }
     }
     return $text;
 }
Пример #7
0
            ?>
										<div class="comment-website">
											<?php 
            echo JText::_('COM_JUDIRECTORY_COMMENT_WEBSITE') . " : " . $commentObj->website;
            ?>
										</div>
									<?php 
        }
        ?>

								</div>
								<!-- /.judir-metadata -->

								<?php 
        $commentObj->comment = JUDirectoryFrontHelper::BBCode2Html($commentObj->comment);
        $commentObj->comment = JUDirectoryFrontHelperComment::parseCommentText($commentObj->comment, $this->listing_id);
        ?>

								<div class="see-more" itemprop="description">
									<?php 
        echo $commentObj->comment;
        ?>
								</div>
							</div>
						</div>
						<?php 
        $totalChildComments = $this->getModel()->getTotalChildComments($commentObj->id);
        if ($totalChildComments > 0) {
            $this->comment_parent_id = $commentObj->id;
            echo $this->loadTemplate('comments');
        }
Пример #8
0
 public function quoteComment()
 {
     $app = JFactory::getApplication();
     $commentId = $app->input->getInt('comment_id', 0);
     $commentObj = JUDirectoryFrontHelperComment::getCommentObject($commentId);
     JUDirectoryHelper::obCleanData();
     $name = $commentObj->user_id > 0 ? JFactory::getUser($commentObj->user_id)->name : $commentObj->guest_name;
     echo $quote = '[quote="' . $name . '"]' . $commentObj->comment . '[/quote]';
     exit;
 }
Пример #9
0
 public function delete($pk = null, $children = true)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     if ($this->_trackAssets) {
         $name = $this->_getAssetName();
         $asset = JTable::getInstance('Asset');
         if (!$asset->_lock()) {
             return false;
         }
         if ($asset->loadByName($name)) {
             if (!$asset->delete(null, $children)) {
                 $this->setError($asset->getError());
                 $asset->_unlock();
                 return false;
             }
             $asset->_unlock();
         } else {
             $this->setError($asset->getError());
             $asset->_unlock();
             return false;
         }
     }
     if (!($node = $this->_getNode($pk))) {
         $this->_unlock();
         return false;
     }
     $commentObjList = array();
     if ($children) {
         $tree = $this->getTree($pk);
         foreach ($tree as $comment) {
             $this->_delete($comment);
             $commentObjList[] = JUDirectoryFrontHelperComment::getCommentObject($comment->id);
         }
         if (!$this->_lock()) {
             return false;
         }
         $query = $this->_db->getQuery(true);
         $query->delete();
         $query->from($this->_tbl);
         $query->where('lft BETWEEN ' . (int) $node->lft . ' AND ' . (int) $node->rgt);
         $this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('lft = lft - ' . (int) $node->width);
         $query->where('lft > ' . (int) $node->rgt);
         $this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('rgt = rgt - ' . (int) $node->width);
         $query->where('rgt > ' . (int) $node->rgt);
         $this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
     } else {
         $this->_delete($node);
         if (!$this->_lock()) {
             return false;
         }
         $query = $this->_db->getQuery(true);
         $query->delete();
         $query->from($this->_tbl);
         $query->where('lft = ' . (int) $node->lft);
         $this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('lft = lft - 1');
         $query->set('rgt = rgt - 1');
         $query->set('level = level - 1');
         $query->where('lft BETWEEN ' . (int) $node->lft . ' AND ' . (int) $node->rgt);
         $this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('parent_id = ' . (int) $node->parent_id);
         $query->where('parent_id = ' . (int) $node->{$k});
         $this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('lft = lft - 2');
         $query->where('lft > ' . (int) $node->rgt);
         $this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('rgt = rgt - 2');
         $query->where('rgt > ' . (int) $node->rgt);
         $this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
     }
     $this->_unlock();
     if ($children && !empty($commentObjList)) {
         foreach ($commentObjList as $commentObj) {
             if ($commentObj->approved == 0) {
                 JUDirectoryFrontHelperMail::sendEmailByEvent('comment.reject', $commentObj->id, get_object_vars($commentObj));
             } elseif (JUDirectoryFrontHelperModerator::isModerator()) {
                 JUDirectoryFrontHelperMail::sendEmailByEvent('comment.moddelete', $commentObj->id, get_object_vars($commentObj));
             } else {
                 JUDirectoryFrontHelperMail::sendEmailByEvent('comment.userdelete', $commentObj->id, get_object_vars($commentObj));
             }
         }
     } else {
         $commentObj = JUDirectoryFrontHelperComment::getCommentObject($node->id);
         if ($commentObj->approved == 0) {
             JUDirectoryFrontHelperMail::sendEmailByEvent('comment.reject', $commentObj->id, get_object_vars($commentObj));
         } elseif (JUDirectoryFrontHelperModerator::isModerator()) {
             JUDirectoryFrontHelperMail::sendEmailByEvent('comment.moddelete', $commentObj->id, get_object_vars($commentObj));
         } else {
             JUDirectoryFrontHelperMail::sendEmailByEvent('comment.userdelete', $commentObj->id, get_object_vars($commentObj));
         }
     }
     return true;
 }
Пример #10
0
 public function voteComment($commentId)
 {
     $commentObj = JUDirectoryFrontHelperComment::getCommentObject($commentId);
     if (!$commentObj) {
         return;
     }
     $vote_up = JFactory::getApplication()->input->getInt('vote_up', 0);
     $helpful_votes = intval($commentObj->helpful_votes);
     $total_votes = intval($commentObj->total_votes);
     $params = JUDirectoryHelper::getParams(null, $commentObj->listing_id);
     $allow_vote_down_comment = $params->get('allow_vote_down_comment', 1);
     if (!$allow_vote_down_comment) {
         $like_system = true;
         if ($vote_up != 1) {
             $voteType = 0;
             $reference = 'unlike';
             $total_votes--;
             $helpful_votes--;
         } else {
             $voteType = 1;
             $reference = 'like';
             $total_votes++;
             $helpful_votes++;
         }
     } else {
         $like_system = false;
         if ($vote_up != 1) {
             $voteType = -1;
             $reference = 'vote_down';
             $total_votes++;
         } else {
             $voteType = 1;
             $reference = 'vote_up';
             $total_votes++;
             $helpful_votes++;
         }
     }
     $votedValue = $this->getCommentVotedValue($commentObj->id);
     if ($allow_vote_down_comment && $votedValue || $votedValue == $voteType) {
         $return = array();
         $return['message'] = JText::_('COM_JUDIRECTORY_VOTING_ERROR');
         $return['like_system'] = $like_system;
         $return['vote_type'] = null;
         JUDirectoryHelper::obCleanData();
         echo json_encode($return);
         exit;
     }
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->update('#__judirectory_comments')->set('helpful_votes = ' . $helpful_votes)->set('total_votes = ' . $total_votes)->where('id = ' . $commentObj->id);
     $db->setQuery($query);
     if ($db->execute()) {
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('judirectory');
         $dispatcher->trigger('onVoteComment', $commentObj, $like_system, $voteType);
         $user = JFactory::getUser();
         $userId = $user->id;
         $logData = array('user_id' => $user->id, 'event' => 'comment.vote', 'item_id' => $commentObj->id, 'listing_id' => $commentObj->listing_id, 'value' => $voteType, 'reference' => $reference);
         JUDirectoryFrontHelperLog::addLog($logData);
         if ($userId > 0) {
             $cookieName = 'judir-comment-vote-' . $commentObj->id . '_' . $userId;
         } else {
             $ipAddress = JUDirectoryFrontHelper::getIpAddress();
             $ipAddress = str_replace('.', '_', $ipAddress);
             $cookieName = 'judir-comment-vote-' . $commentObj->id . '_' . $ipAddress;
         }
         $config = JFactory::getConfig();
         $cookie_domain = $config->get('cookie_domain', '');
         $cookie_path = $config->get('cookie_path', '/');
         setcookie($cookieName, $voteType, time() + 60 * 60 * 24 * 30, $cookie_path, $cookie_domain);
         $return = array();
         $return['message'] = JText::sprintf('COM_JUDIRECTORY_N_HELPFUL_VOTES_N_TOTAL_VOTES', $helpful_votes, $total_votes);
         $return['like_system'] = $like_system;
         $return['vote_type'] = $voteType;
     } else {
         $return = array();
         $return['message'] = JText::_('COM_JUDIRECTORY_VOTING_ERROR');
         $return['like_system'] = $like_system;
         $return['vote_type'] = null;
     }
     JUDirectoryHelper::obCleanData();
     echo json_encode($return);
     exit;
 }
Пример #11
0
    protected function getInput()
    {
        $app = JFactory::getApplication();
        JHtml::_('behavior.modal', 'a.modal');
        $id = $this->form->getValue('id', null, 0);
        $script = array();
        $script[] = 'function commentURL() {
				     	var commenturl = document.id("commenturl").getAttribute("href");
						commenturl = commenturl + "&listing_id="+document.id(jform_listing_id).value;
						document.id("commenturl").setAttribute("href", commenturl);
						return true;
			  		}';
        $script[] = 'function jSelectComment_' . $this->id . '(id, title, level) {
			        	if(id != document.id("' . $this->id . '").value){
							document.id("' . $this->id . '").value = id;
		        			document.id("' . $this->id . '_name").value = title;
		        			level = parseInt(level) + 1
		        			document.id("jform_level").value = level;
				        	
		        		}
				        SqueezeBox.close();
					}';
        JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
        $html = array();
        $link = 'index.php?option=com_judirectory&amp;view=comments&amp;layout=modal&amp;tmpl=component&amp;id=' . $id . '&amp;function=jSelectComment_' . $this->id;
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select('title');
        $query->from('#__judirectory_comments');
        $query->where('id = ' . (int) $this->value);
        $db->setQuery($query);
        $title = $db->loadResult();
        if (empty($title)) {
            $rootComment = JUDirectoryFrontHelperComment::getRootComment();
            $title = $rootComment->title;
            $value = $rootComment->id;
        } else {
            $value = $this->value;
        }
        $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
        $joomla_version_arr = explode(".", JVERSION);
        $priVersion = $joomla_version_arr[0];
        if ($priVersion == 3) {
            $html[] = '<span class="' . ($app->isAdmin() ? 'input-append' : '') . '">';
            $html[] = '<input type="text" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="' . $this->element['size'] . '" />';
            if ($app->isAdmin()) {
                $html[] = '<a class="modal btn hasTooltip" title="' . JHtml::tooltipText('COM_JUDIRECTORY_SELECT_COMMENT') . '"  href="' . $link . '&amp;' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-list"></i> ' . JText::_('COM_JUDIRECTORY_SELECT') . '</a>';
            }
            $html[] = '</span>';
        } else {
            $html[] = '<div class="fltlft">';
            $html[] = '<input type="text" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="' . $this->element['size'] . '" />';
            $html[] = '</div>';
            if ($app->isAdmin()) {
                $html[] = '<div class="button2-left">';
                $html[] = '<div class="blank">';
                $html[] = '<a onclick="commentURL();" id="commenturl" class="modal" title="' . JText::_('COM_JUDIRECTORY_SELECT_COMMENT') . '"  href="' . $link . '&amp;' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">' . JText::_('COM_JUDIRECTORY_SELECT_COMMENT') . '</a>';
                $html[] = '</div>';
                $html[] = '</div>';
            }
        }
        $class = '';
        if ($this->required) {
            $class = ' class="required modal-value"';
        }
        $html[] = '<input type="hidden" id="' . $this->id . '"' . $class . ' name="' . $this->name . '" value="' . $value . '" />';
        return implode("\n", $html);
    }
Пример #12
0
 protected function _prepareData()
 {
     $this->token = JSession::getFormToken();
     $this->session = JFactory::getSession();
     $this->item->related_listings = $this->model->getRelatedListings($this->item->id);
     if (count($this->item->related_listings)) {
         foreach ($this->item->related_listings as $listingRelated) {
             $listingRelated->link = JRoute::_(JUDirectoryHelperRoute::getListingRoute($listingRelated->id));
             $listingRelated->image = JUDirectoryHelper::getListingImage($listingRelated->image);
         }
     }
     $additionFields = $ignoredFields = array();
     $this->item->fieldLocations = JUDirectoryFrontHelperField::getField('locations', $this->item);
     $this->item->fieldGallery = JUDirectoryFrontHelperField::getField('gallery', $this->item);
     $this->item->fields = JUDirectoryFrontHelperField::getFields($this->item, 2, array(), array('gallery', 'locations'), $additionFields);
     $user = JFactory::getUser();
     $uri = JUri::getInstance();
     if ($this->item->checked_out > 0 && $this->item->checked_out != $user->get('id')) {
         if (JUDirectoryFrontHelperPermission::canCheckInListing($this->item->id)) {
             $this->item->checkin_link = JRoute::_('index.php?option=com_judirectory&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_judirectory&task=form.edit&id=' . $this->item->id . '&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($this->item->id));
         if ($this->item->published == 1) {
             $this->item->editstate_link = JRoute::_('index.php?option=com_judirectory&task=forms.unpublish&id=' . $this->item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($this->item->id));
         } else {
             $this->item->editstate_link = JRoute::_('index.php?option=com_judirectory&task=forms.publish&id=' . $this->item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($this->item->id));
         }
     }
     $this->item->delete_link = JRoute::_('index.php?option=com_judirectory&task=forms.delete&id=' . $this->item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($this->item->id));
     $this->item->contact_link = JRoute::_(JUDirectoryHelperRoute::getContactRoute($this->item->id));
     $this->item->report_link = JRoute::_(JUDirectoryHelperRoute::getReportListingRoute($this->item->id));
     $this->item->claim_link = JRoute::_(JUDirectoryHelperRoute::getClaimListingRoute($this->item->id));
     $this->item->print_link = JRoute::_(JUDirectoryHelperRoute::getListingRoute($this->item->id) . '&layout=print&tmpl=component&print=1');
     $this->item->comment = new stdClass();
     $this->item->comment->total_comments_no_filter = $this->model->getTotalCommentsOfListing($this->item->id);
     $this->root_comment = JUDirectoryFrontHelperComment::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 (JUDirectoryFrontHelperPermission::canCheckInComment($comment->id)) {
             $uri = JUri::getInstance();
             $comment->checkout_link = 'index.php?option=com_judirectory&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_JUDIRECTORY_ASC'), 'DESC' => JText::_('COM_JUDIRECTORY_DESC'));
     $this->total_stars = $this->params->get('number_rating_stars', 5);
     $this->filter_comment_stars = array('' => JText::_('COM_JUDIRECTORY_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_JUDIRECTORY_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('judirectory_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'];
     }
 }
Пример #13
0
						<td>
							<?php 
        if ($item->level == 1) {
            $limitStart = $listingModel->getLimitStartForComment($item->id);
            ?>
								<a href="<?php 
            echo JRoute::_(JUDirectoryHelperRoute::getListingRoute($item->listing_id) . '&limitstart=' . $limitStart . '&resetfilter=1' . '#comment-item-' . $item->id);
            ?>
">
									<?php 
            echo $item->listing_title;
            ?>
</a>
							<?php 
        } elseif ($item->level > 1) {
            $parentCommentObject = JUDirectoryFrontHelperComment::getCommentObject($item->parent_id, 'cm.id, cm.title');
            $limitStart = $listingModel->getLimitStartForComment($parentCommentObject->id);
            ?>
								<a href="<?php 
            echo JRoute::_(JUDirectoryHelperRoute::getListingRoute($item->listing_id));
            ?>
">
									<?php 
            echo $item->listing_title;
            ?>
								</a>
								<span> / </span>
								<a target="_blank"
								   href="<?php 
            echo JRoute::_(JUDirectoryHelperRoute::getListingRoute($item->listing_id) . '&limitstart=' . $limitStart . '&resetfilter=1' . '#comment-item-' . $parentCommentObject->id);
            ?>
Пример #14
0
 protected function getListQuery()
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('cm.*, r.score');
     $query->from('#__judirectory_comments AS cm');
     $query->join('LEFT', '#__judirectory_rating AS r ON cm.rating_id = r.id');
     $query->where('cm.published  = 1');
     $query->where('cm.approved  = 1');
     $rootComment = JUDirectoryFrontHelperComment::getRootComment();
     $query->where('cm.id != ' . $rootComment->id);
     $params = $this->getState('params');
     if ($params->get('top_comment_level', 'toplevel') == 'toplevel') {
         $query->where('cm.level = 1');
     }
     $ordering = $this->getState('list.ordering', 'cm.created');
     $direction = $this->getState('list.direction', 'desc');
     $query->order($ordering . ' ' . $direction);
     return $query;
 }
Пример #15
0
 public static function BBCode2Html($text)
 {
     $text = trim($text);
     if (!function_exists('escape')) {
         function escape($s)
         {
             global $text;
             $text = strip_tags($text);
             $code = $s[1];
             $code = htmlspecialchars($code);
             $code = str_replace("[", "&#91;", $code);
             $code = str_replace("]", "&#93;", $code);
             return '<pre><code>' . $code . '</code></pre>';
         }
     }
     $text = preg_replace_callback('/\\[code\\](.*?)\\[\\/code\\]/ms', "escape", $text);
     $in = array('3:)', ':)', ':(', ':P', ':D', '&gt;:o', ':o', ';)', ':-/', ':v', ':\'(', '^_^', '8-)', '&lt;3', '-_-', 'o.O', ':3', '(y)');
     $smileFolder = JUri::root(true) . '/components/com_judirectory/assets/wysibb/theme/default/img/smiles/';
     $out = array('<img  src="' . $smileFolder . 'devil.png" />', '<img  src="' . $smileFolder . 'smile.png" />', '<img  src="' . $smileFolder . 'frown.png" />', '<img  src="' . $smileFolder . 'tongue.png" />', '<img  src="' . $smileFolder . 'grin.png" />', '<img  src="' . $smileFolder . 'angry.png" />', '<img  src="' . $smileFolder . 'gasp.png" />', '<img  src="' . $smileFolder . 'wink.png" />', '<img  src="' . $smileFolder . 'unsure.png" />', '<img  src="' . $smileFolder . 'pacman.png" />', '<img  src="' . $smileFolder . 'cry.png" />', '<img  src="' . $smileFolder . 'kiki.png" />', '<img  src="' . $smileFolder . 'glasses.png" />', '<img  src="' . $smileFolder . 'heart.png" />', '<img  src="' . $smileFolder . 'squinting.png" />', '<img  src="' . $smileFolder . 'confused.png" />', '<img  src="' . $smileFolder . 'colonthree.png" />', '<img  src="' . $smileFolder . 'like.png" />');
     $text = str_replace($in, $out, $text);
     $in = array('/\\[b\\](.*?)\\[\\/b\\]/ms', '/\\[i\\](.*?)\\[\\/i\\]/ms', '/\\[u\\](.*?)\\[\\/u\\]/ms', '/\\[align=(.*?)\\](.*?)\\[\\/align\\]/ms', '/\\[img\\](.*?)\\[\\/img\\]/ms', '/\\[email\\](.*?)\\[\\/email\\]/ms', '/\\[url\\="?(.*?)"?\\](.*?)\\[\\/url\\]/ms', '/\\[size\\="?(.*?)"?\\](.*?)\\[\\/size\\]/ms', '/\\[color\\="?(.*?)"?\\](.*?)\\[\\/color\\]/ms', '/\\[background\\="?(.*?)"?\\](.*?)\\[\\/background\\]/ms', '/\\[list\\=(.*?)\\](.*?)\\[\\/list\\]/ms', '/\\[list\\](.*?)\\[\\/list\\]/ms', '/\\[\\*\\]([^\\[\\]\\*\\<]*)/ms', '/\\[left\\](.*?)\\[\\/left\\]/ms', '/\\[right\\](.*?)\\[\\/right\\]/ms', '/\\[center\\](.*?)\\[\\/center\\]/ms');
     $out = array('<strong>\\1</strong>', '<em>\\1</em>', '<u>\\1</u>', '<p style="\\1">\\2</p>', '<img src="\\1" alt="\\1" />', '<a href="mailto:\\1">\\1</a>', '<a href="\\1" rel="nofollow">\\2</a>', '<span style="font-size:\\1%">\\2</span>', '<span style="color:\\1">\\2</span>', '<span style="background-color:\\1">\\2</span>', '<ol start="\\1">\\2</ol>', '<ul>\\1</ul>', '<li>\\1</li>', '<p style="text-align:left">\\1</p>', '<p style="text-align:right">\\1</p>', '<p style="text-align:center">\\1</p>');
     $text = preg_replace($in, $out, $text);
     $quoteFind = array('/\\[quote\\]/is', '/\\[\\/quote\\]/is', '/\\[quote\\s*=\\s*"?([^"]*?)"?\\s*\\]/is');
     $quoteReplace = array('<blockquote>', '</blockquote>', '<span class="author">$1 said:</span><blockquote>');
     $count = 0;
     do {
         $text = preg_replace($quoteFind, $quoteReplace, $text, -1, $count);
     } while ($count > 0);
     $videoPatt = '/\\[video\\](.*?)\\[\\/video\\]/ms';
     preg_match($videoPatt, $text, $matches);
     if ($matches && $matches[1]) {
         $vimeo_html = JUDirectoryFrontHelperComment::parseVideo($matches[1]);
         $text = str_replace($matches[0], $vimeo_html, $text);
     }
     $text = str_replace("\r", "", $text);
     $text = "<p>" . preg_replace("/(\n){2,}/", "</p><p>", $text) . "</p>";
     $text = nl2br($text);
     if (!function_exists('removeBr')) {
         function removeBr($s)
         {
             return str_replace("<br />", "", $s[0]);
         }
     }
     $text = preg_replace_callback('/<pre>(.*?)<\\/pre>/ms', "removeBr", $text);
     $text = preg_replace('/<p><pre>(.*?)<\\/pre><\\/p>/ms', "<pre>\\1</pre>", $text);
     $text = preg_replace_callback('/<ul>(.*?)<\\/ul>/ms', "removeBr", $text);
     $text = preg_replace('/<p><ul>(.*?)<\\/ul><\\/p>/ms', "<ul>\\1</ul>", $text);
     return $text;
 }
Пример #16
0
 protected function canEditState($record)
 {
     $rootComment = JUDirectoryFrontHelperComment::getRootComment();
     if (isset($record->id) && $record->id == $rootComment->id) {
         return false;
     }
     $app = JFactory::getApplication();
     if ($app->isSite()) {
         $modCanEditState = JUDirectoryFrontHelperModerator::checkModeratorCanDoWithComment($record->id, 'comment_edit_state');
         if ($modCanEditState) {
             return true;
         }
         return false;
     }
     return parent::canEditState($record);
 }
Пример #17
0
 public function build(&$query)
 {
     $segments = array();
     $app = JFactory::getApplication('site');
     $menus = $app->getMenu('site');
     $activeMenu = $menus->getActive();
     $params = JUDirectoryHelper::getParams();
     $homeItemId = JUDirectoryHelperRoute::getHomeMenuItemId();
     if (empty($query['Itemid']) && isset($query['view']) && $query['view'] != 'category' && $query['view'] != 'listing') {
         $query['Itemid'] = JUDirectoryHelperRoute::findJUDirectoryTreeItemId();
     }
     if (isset($query['view'])) {
         $menuItem = $menus->getItem($query['Itemid']);
         if (isset($menuItem) && ($menuItem->component != 'com_judirectory' && $menuItem->id != $homeItemId)) {
             unset($query['Itemid']);
         }
     }
     if (!$query || !isset($query['view']) && !isset($query['task'])) {
         if (isset($query['start'])) {
             $sefPageConfig = JApplication::stringURLSafe('page');
             $pageX = JUDirectoryHelperRoute::getPage($query['start'], $activeMenu->query['view']);
             $segments[] = $sefPageConfig . ':' . $pageX;
             unset($query['start']);
         }
         JUDirectoryHelperRoute::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 = JUDirectoryHelperRoute::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 = JUDirectoryHelper::getCategoryById($query['id']);
                 $segments[] = $query['id'] . ":" . (isset($categoryObject->alias) ? $categoryObject->alias : '');
                 unset($query['id']);
             }
             JUDirectoryHelperRoute::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 = JUDirectoryHelperRoute::getCategorySegment($query['id'], $query, $fullPathCategory);
                 if ($segments !== false) {
                     unset($query['id']);
                 }
             }
             JUDirectoryHelperRoute::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']);
         }
         JUDirectoryHelperRoute::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');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::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 = JUDirectoryFrontHelper::getCollectionById($query['id']);
                 $segments[] = $query['id'] . ':' . (isset($collectionObject->alias) ? $collectionObject->alias : '');
                 unset($query['id']);
                 JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
             } else {
                 $segments[] = JApplication::stringURLSafe('collection');
                 $segments[] = JApplication::stringURLSafe('new-collection');
                 JUDirectoryHelperRoute::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']);
         }
         JUDirectoryHelperRoute::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');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['id'])) {
                 unset($query['id']);
             }
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::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 = JUDirectoryFrontHelperComment::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['listing_id'])) {
         if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId) {
             $sefRootCategory = JApplication::stringURLSafe('root');
             $segments[] = JApplication::stringURLSafe($sefRootCategory);
         }
         $segments = JUDirectoryHelperRoute::getListingSegment($query['listing_id'], $query, $params);
         $segments[] = JApplication::stringURLSafe('contact');
         JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         unset($query['listing_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');
         JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'listing') {
         if (!$hasActiveMenu) {
             $seoLayout = true;
             if (isset($query['id'])) {
                 $segments = JUDirectoryHelperRoute::getListingSegment($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 ($seoLayout) {
                 JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
             }
         } else {
             if (isset($query['id'])) {
                 unset($query['id']);
             }
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::seoPagination($query, $params, $segments);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'listings') {
         if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId) {
             $sefRootCategory = JApplication::stringURLSafe('root');
             $segments[] = JApplication::stringURLSafe($sefRootCategory);
         }
         $segments[] = JApplication::stringURLSafe('modal-listings');
         if (isset($query['tmpl'])) {
             $segments[] = $query['tmpl'];
             unset($query['tmpl']);
         }
         if (isset($query['function'])) {
             $segments[] = $query['function'];
             unset($query['function']);
         }
         JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         JUDirectoryHelperRoute::seoPagination($query, $params, $segments);
         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 = JUDirectoryHelper::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 = JUDirectoryHelper::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 = JUDirectoryHelper::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']);
             }
             JUDirectoryHelperRoute::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']);
         }
         JUDirectoryHelperRoute::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 = JUDirectoryHelper::getCategoryById($query['cat_id']);
             $segments[] = $query['cat_id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
             unset($query['cat_id']);
         } else {
             $categoryRoot = JUDirectoryFrontHelperCategory::getRootCategory();
             if (is_object($categoryRoot)) {
                 $segments[] = $categoryRoot->id . ':' . (isset($categoryRoot->alias) ? $categoryRoot->alias : '');
             }
         }
         $segments[] = JApplication::stringURLSafe('new-listing');
         JUDirectoryHelperRoute::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 = JUDirectoryHelperRoute::getListingSegment($query['id'], $query, $params);
         if (isset($query['approve']) && $query['approve'] == 1) {
             $segments[] = JApplication::stringURLSafe('approve');
             unset($query['approve']);
         }
         JUDirectoryHelperRoute::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 = JUDirectoryHelper::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 = JUDirectoryHelper::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 = JUDirectoryHelper::getCategoryById($query['id']);
                     $segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
                     unset($query['id']);
                 }
             }
             $segments[] = JApplication::stringURLSafe('list-all');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['id'])) {
                 unset($query['id']);
             }
         }
         if (isset($query['format'])) {
             $segments[] = JApplication::stringURLSafe('rss');
             unset($query['format']);
         }
         JUDirectoryHelperRoute::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 = JUDirectoryHelper::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 = JUDirectoryHelper::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 = JUDirectoryHelper::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']);
             }
             JUDirectoryHelperRoute::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']);
         }
         JUDirectoryHelperRoute::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');
         JUDirectoryHelperRoute::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 = JUDirectoryFrontHelperComment::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']);
         }
         JUDirectoryHelperRoute::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');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::seoPagination($query, $params, $segments);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'modlistings') {
         if (!$hasActiveMenu) {
             if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId) {
                 $sefRootCategory = JApplication::stringURLSafe('root');
                 $segments[] = JApplication::stringURLSafe($sefRootCategory);
             }
             $segments[] = JApplication::stringURLSafe('mod-listings');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::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'];
         JUDirectoryHelperRoute::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');
         JUDirectoryHelperRoute::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');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::seoPagination($query, $params, $segments);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'modpendinglistings') {
         if (!$hasActiveMenu) {
             if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId) {
                 $sefRootCategory = 'root';
                 $segments[] = JApplication::stringURLSafe($sefRootCategory);
             }
             $segments[] = JApplication::stringURLSafe('mod-pending-listings');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::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');
         JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'claim' && isset($query['listing_id'])) {
         if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId) {
             $sefRootCategory = 'root';
             $segments[] = JApplication::stringURLSafe($sefRootCategory);
         }
         $segments = JUDirectoryHelperRoute::getListingSegment($query['listing_id'], $query, $params);
         $segments[] = JApplication::stringURLSafe('claim');
         JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         unset($query['listing_id']);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'report' && isset($query['listing_id'])) {
         if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId) {
             $sefRootCategory = 'root';
             $segments[] = JApplication::stringURLSafe($sefRootCategory);
         }
         $segments = JUDirectoryHelperRoute::getListingSegment($query['listing_id'], $query, $params);
         $segments[] = JApplication::stringURLSafe('report');
         JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         unset($query['listing_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 = JUDirectoryFrontHelperComment::getCommentObject($query['comment_id']);
         $commentAlias = JApplication::stringURLSafe($commentObject->title);
         $segments[] = $query['comment_id'] . ':' . $commentAlias;
         unset($query['comment_id']);
         $segments[] = JApplication::stringURLSafe('report');
         JUDirectoryHelperRoute::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 = JUDirectoryHelper::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']);
             }
             JUDirectoryHelperRoute::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']);
             }
         }
         JUDirectoryHelperRoute::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 = JUDirectoryFrontHelperField::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']);
             }
             JUDirectoryHelperRoute::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']);
             }
         }
         JUDirectoryHelperRoute::seoPagination($query, $params, $segments);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'subscribe' && isset($query['listing_id'])) {
         if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId) {
             $sefRootCategory = 'root';
             $segments[] = JApplication::stringURLSafe($sefRootCategory);
         }
         $segments = JUDirectoryHelperRoute::getListingSegment($query['listing_id'], $query, $params);
         $segments[] = JApplication::stringURLSafe('guest-subscribe');
         JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         unset($query['listing_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 = JUDirectoryFrontHelper::getTagById($query['id']);
             $segments[] = $query['id'] . ':' . (isset($tagObject->alias) ? $tagObject->alias : '');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['id'])) {
                 unset($query['id']);
             }
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::seoFormat($query, $params, $segments);
         JUDirectoryHelperRoute::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');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::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');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::seoPagination($query, $params, $segments);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'customlist') {
         if (!$hasActiveMenu) {
             if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId) {
                 $sefRootCategory = 'root';
                 $segments[] = JApplication::stringURLSafe($sefRootCategory);
             }
             $segments[] = JApplication::stringURLSafe('custom-list');
             if (isset($query['id'])) {
                 if ($query['id']) {
                     $customListObject = JUDirectoryHelper::getCustomListById($query['id']);
                     $segments[] = $query['id'] . ':' . (isset($customListObject->alias) ? $customListObject->alias : '');
                 }
                 unset($query['id']);
             }
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['id'])) {
                 unset($query['id']);
             }
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::seoFormat($query, $params, $segments);
         JUDirectoryHelperRoute::seoPagination($query, $params, $segments);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'compare') {
         if (!$hasActiveMenu) {
             if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId) {
                 $sefRootCategory = 'root';
                 $segments[] = JApplication::stringURLSafe($sefRootCategory);
             }
             $segments[] = JApplication::stringURLSafe('compare');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::seoPagination($query, $params, $segments);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'toplistings') {
         $addCategoryToSegment = true;
         if (!$hasActiveMenu) {
             if (isset($query['Itemid'])) {
                 if ($query['Itemid'] == $homeItemId) {
                     $sefRootCategory = 'root';
                     $segments[] = JApplication::stringURLSafe($sefRootCategory);
                     if (isset($query['id'])) {
                         $categoryObject = JUDirectoryHelper::getCategoryById($query['id']);
                         if ($categoryObject->level > 0) {
                             $segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
                         }
                         unset($query['id']);
                     }
                     $addCategoryToSegment = false;
                 } else {
                     $assignMenuTopListings = $menus->getItem($query['Itemid']);
                     if ($assignMenuTopListings && isset($assignMenuTopListings->query) && $assignMenuTopListings->query['view'] == 'tree' && isset($assignMenuTopListings->query['id'])) {
                         if (isset($query['id'])) {
                             $categoryObject = JUDirectoryHelper::getCategoryById($query['id']);
                             if ($assignMenuTopListings->query['id'] != $categoryObject->id) {
                                 $segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
                             }
                             unset($query['id']);
                         }
                         $addCategoryToSegment = false;
                     }
                 }
             }
             if ($addCategoryToSegment) {
                 if (isset($query['id'])) {
                     $categoryObject = JUDirectoryHelper::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-listings');
                         break;
                     case 'featured':
                         $segments[] = JApplication::stringURLSafe('top-featured-listings');
                         break;
                     case 'recent_modified':
                         $segments[] = JApplication::stringURLSafe('recent-modified-listings');
                         break;
                     case 'recent_updated':
                         $segments[] = JApplication::stringURLSafe('recent-updated-listings');
                         break;
                     case 'popular':
                         $segments[] = JApplication::stringURLSafe('popular-listings');
                         break;
                     case 'most_rated':
                         $segments[] = JApplication::stringURLSafe('most-rated-listings');
                         break;
                     case 'top_rated':
                         $segments[] = JApplication::stringURLSafe('top-rated-listings');
                         break;
                     case 'latest_rated':
                         $segments[] = JApplication::stringURLSafe('latest-rated-listings');
                         break;
                     case 'most_commented':
                         $segments[] = JApplication::stringURLSafe('most-commented-listings');
                         break;
                     case 'latest_commented':
                         $segments[] = JApplication::stringURLSafe('latest-commented-listings');
                         break;
                     case 'recently_viewed':
                         $segments[] = JApplication::stringURLSafe('recent-viewed-listings');
                         break;
                     case 'alpha_ordered':
                         $segments[] = JApplication::stringURLSafe('alpha-ordered-listings');
                         break;
                     case 'random':
                         $segments[] = JApplication::stringURLSafe('random-listings');
                         break;
                     case 'random_fast':
                         $segments[] = JApplication::stringURLSafe('random-fast-listings');
                         break;
                     case 'random_featured':
                         $segments[] = JApplication::stringURLSafe('random-featured-listings');
                         break;
                     default:
                         $segments[] = JApplication::stringURLSafe('latest-listings');
                 }
                 unset($query['ordertype']);
             }
             if (isset($query['all'])) {
                 if ($query['all'] == 1) {
                     $segments[] = JApplication::stringURLSafe('all');
                 }
                 unset($query['all']);
             }
             JUDirectoryHelperRoute::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']);
             }
         }
         JUDirectoryHelperRoute::seoFormat($query, $params, $segments);
         JUDirectoryHelperRoute::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 = JUDirectoryHelper::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 = JUDirectoryHelper::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 = JUDirectoryHelper::getCategoryById($query['id']);
                     $segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
                 }
             }
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['id'])) {
                 unset($query['id']);
             }
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::seoFormat($query, $params, $segments);
         JUDirectoryHelperRoute::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');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if (isset($query['id'])) {
                 unset($query['id']);
             }
             if (isset($query['layout'])) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::seoPagination($query, $params, $segments);
         unset($query['view']);
     }
     if (isset($query['view']) && $query['view'] == 'userlistings') {
         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('listings');
             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']);
             }
             JUDirectoryHelperRoute::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']);
             }
         }
         JUDirectoryHelperRoute::seoFormat($query, $params, $segments);
         JUDirectoryHelperRoute::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');
             JUDirectoryHelperRoute::seoLayout($query, $segments, $params);
         } else {
             if ($query['layout']) {
                 unset($query['layout']);
             }
         }
         JUDirectoryHelperRoute::seoPagination($query, $params, $segments);
         unset($query['id']);
         unset($query['view']);
     }
     if (isset($query['task']) && $query['task'] == 'form.add') {
         if (isset($query['cat_id'])) {
             $categoryObject = JUDirectoryHelper::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 = JUDirectoryHelperRoute::getListingSegment($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 = JUDirectoryHelperRoute::getListingSegment($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 = JUDirectoryHelperRoute::getListingSegment($query['id'], $query, $params);
         $segments[] = JApplication::stringURLSafe('checkin');
         unset($query['id']);
         unset($query['task']);
     }
     if (isset($query['task']) && $query['task'] == 'listing.removeCompare' && isset($query['listing_id'])) {
         $segments = JUDirectoryHelperRoute::getListingSegment($query['listing_id'], $query, $params);
         $segments[] = JApplication::stringURLSafe('remove-compare');
         unset($query['listing_id']);
         unset($query['task']);
     }
     if (isset($query['task']) && $query['task'] == 'listing.removeCompare' && isset($query['all']) && $query['all'] == 1) {
         $segments[] = JApplication::stringURLSafe('remove-compare');
         $segments[] = JApplication::stringURLSafe('all');
         unset($query['all']);
         unset($query['task']);
     }
     if (isset($query['task']) && $query['task'] == 'modpendinglisting.edit' && isset($query['id'])) {
         $segments = JUDirectoryHelperRoute::getListingSegment($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 = JUDirectoryHelperRoute::getListingSegment($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 = JUDirectoryHelperRoute::getListingSegment($query['id'], $query, $params);
         $segments[] = JApplication::stringURLSafe('publish');
         unset($query['id']);
         unset($query['task']);
     }
     if (isset($query['task']) && $query['task'] == 'subscribe.save' && isset($query['listing_id']) && !isset($query['comment_id'])) {
         $segments = JUDirectoryHelperRoute::getListingSegment($query['listing_id'], $query, $params);
         $segments[] = JApplication::stringURLSafe('subscribe');
         unset($query['listing_id']);
         unset($query['task']);
     }
     if (isset($query['task']) && $query['task'] == 'listing.redirecturl') {
         if (isset($query['listing_id'])) {
             $segments = JUDirectoryHelperRoute::getListingSegment($query['listing_id'], $query, $params);
             unset($query['listing_id']);
         }
         if (isset($query['field_id'])) {
             $fieldObject = JUDirectoryFrontHelperField::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 = JUDirectoryFrontHelperComment::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 = JUDirectoryFrontHelperComment::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 = JUDirectoryFrontHelperComment::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 = JUDirectoryFrontHelper::getSubscriptionObject($query['sub_id']);
         if ($subscriptionObject->type == 'listing') {
             $segments = JUDirectoryHelperRoute::getListingSegment($subscriptionObject->item_id, $query, $params);
             $segments[] = JApplication::stringURLSafe('unsubscribe');
             $segments[] = $query['sub_id'];
             if ($query['code']) {
                 $segments[] = $query['code'];
                 unset($query['code']);
             }
             unset($query['listing_id']);
             unset($query['task']);
             unset($query['sub_id']);
             unset($query['task']);
         } elseif ($subscriptionObject->type == 'comment') {
             $segments[] = JApplication::stringURLSafe('comment');
             $commentObject = JUDirectoryFrontHelperComment::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'] == 'listing.deleteComment' && isset($query['comment_id'])) {
         $segments[] = JApplication::stringURLSafe('comment');
         $commentObject = JUDirectoryFrontHelperComment::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 = JUDirectoryFrontHelper::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 = JUDirectoryFrontHelper::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['listing_id'])) {
             $segments = JUDirectoryHelperRoute::getListingSegment($query['listing_id'], $query, $params);
             unset($query['listing_id']);
         }
         if (isset($query['field_id'])) {
             $fieldObject = JUDirectoryFrontHelperField::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;
 }
Пример #18
0
 public static function canVoteComment($listingId, $commentId)
 {
     $params = JUDirectoryHelper::getParams(null, $listingId);
     if (!$params->get('allow_vote_comment', 1)) {
         return false;
     }
     $commentObject = JUDirectoryFrontHelperComment::getCommentObject($commentId);
     if ($commentObject->published != 1 || $commentObject->approved != 1) {
         return false;
     }
     $session = JFactory::getSession();
     if ($session->has('judir-comment-voted-' . $commentId)) {
         return false;
     }
     $user = JFactory::getUser();
     $enableVoteComment = $params->get('allow_vote_comment', 1);
     if (!$user->get('guest') && $enableVoteComment) {
         $isCommentOwner = JUDirectoryFrontHelperPermission::isCommentOwner($commentId);
         if ($isCommentOwner) {
             $commentOwnerCanVoteOwnComment = $params->get('can_vote_own_comment', 0);
             if ($commentOwnerCanVoteOwnComment) {
                 return true;
             } else {
                 return false;
             }
         }
         $isListingOwner = JUDirectoryFrontHelperPermission::isListingOwner($listingId);
         $listingOwnerCanVoteComment = $params->get('listing_owner_can_vote_comment', 1);
         if ($isListingOwner && $listingOwnerCanVoteComment) {
             return true;
         }
         $asset = 'com_judirectory.listing.' . $listingId;
         if ($user->authorise('judir.comment.vote', $asset)) {
             return true;
         }
     }
     return false;
 }