Ejemplo n.º 1
0
 public function display($tpl = null)
 {
     $this->model = $this->getModel();
     $this->state = $this->get('State');
     $this->params = $this->state->params;
     $this->tag = $this->get('Tag');
     if (!is_object($this->tag)) {
         JError::raiseError(404, JText::_('COM_JUDIRECTORY_TAG_NOT_FOUND'));
         return false;
     }
     $user = JFactory::getUser();
     $uri = JUri::getInstance();
     $this->items = $this->get('Items');
     foreach ($this->items as $item) {
         $item->report_link = JRoute::_(JUDirectoryHelperRoute::getReportListingRoute($item->id));
         $item->claim_link = JRoute::_(JUDirectoryHelperRoute::getClaimListingRoute($item->id));
         if ($item->checked_out > 0 && $item->checked_out != $user->get('id')) {
             if (JUDirectoryFrontHelperPermission::canCheckInListing($item->id)) {
                 $item->checkin_link = JRoute::_('index.php?option=com_judirectory&task=forms.checkin&id=' . $item->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri)));
             }
         } else {
             $item->edit_link = JRoute::_('index.php?option=com_judirectory&task=form.edit&id=' . $item->id . '&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
             if ($item->published == 1) {
                 $item->editstate_link = JRoute::_('index.php?option=com_judirectory&task=forms.unpublish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
             } else {
                 $item->editstate_link = JRoute::_('index.php?option=com_judirectory&task=forms.publish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
             }
         }
         $item->delete_link = JRoute::_('index.php?option=com_judirectory&task=forms.delete&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('content');
         $item->event = new stdClass();
         $context = 'com_judirectory.listing_list';
         $results = $dispatcher->trigger('onContentAfterTitle', array($context, &$this->item, &$this->params, 0));
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$this->item, &$this->params, 0));
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array($context, &$this->item, &$this->params, 0));
         $item->event->afterDisplayContent = trim(implode("\n", $results));
     }
     $this->pagination = $this->get('Pagination');
     $this->token = JSession::getFormToken();
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->show_feed = JUDIRPROVERSION ? $this->params->get('rss_display_icon', 1) : 0;
     $rssLink = JRoute::_(JUDirectoryHelperRoute::getTagRoute($this->tag->id, false, true));
     $this->rss_link = JRoute::_($rssLink, false);
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $this->_prepareData();
     $this->_prepareDocument();
     $this->_setBreadcrumb();
     parent::display($tpl);
 }
Ejemplo n.º 2
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'];
     }
 }
Ejemplo n.º 3
0
 public function display($tpl = null)
 {
     $model = $this->getModel();
     $this->model = $model;
     $this->state = $this->get('State');
     $params = $this->state->params;
     $this->params = $params;
     $this->token = JSession::getFormToken();
     $this->root_category = JUDirectoryFrontHelperCategory::getRootCategory();
     $categoryId = $this->state->get('category.id', $this->root_category->id);
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     $error = array();
     if (!JUDirectoryFrontHelperPermission::canDoCategory($categoryId, true, $error)) {
         $user = JFactory::getUser();
         if ($user->id) {
             return JError::raiseError($error['code'], $error['message']);
         } else {
             $uri = JUri::getInstance();
             $loginUrl = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($uri), false);
             $app = JFactory::getApplication();
             $app->redirect($loginUrl, JText::_('COM_JUDIRECTORY_YOU_ARE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE'), 'warning');
             return false;
         }
     }
     $topLevelCats = JUDirectoryHelper::getCatsByLevel(1, $categoryId);
     if (is_array($topLevelCats) && count($topLevelCats) > 0) {
         $this->tl_catid = $topLevelCats[0]->id;
     }
     $this->category = JUDirectoryFrontHelperCategory::getCategory($categoryId);
     $this->show_feed = JUDIRPROVERSION ? $this->params->get('rss_display_icon', 1) : 0;
     $this->rss_link = JRoute::_(JUDirectoryHelperRoute::getCategoryRoute($this->category->id, null, true));
     if (isset($this->category->images) && !empty($this->category->images) && !empty($this->category->images->detail_image)) {
         $this->category->images->detail_image_src = JUri::root(true) . '/' . JUDirectoryFrontHelper::getDirectory('category_detail_image_directory', 'media/com_judirectory/images/category/detail/', true) . $this->category->images->detail_image;
     }
     $this->category->images->detail_image_width = (int) $this->params->get('category_image_width', 200);
     $this->category->images->detail_image_height = (int) $this->params->get('category_image_height', 200);
     if ($this->params->get('category_show_description', 1)) {
         $this->category->description = $this->category->introtext . $this->category->fulltext;
     } else {
         $this->category->description = $this->category->fulltext;
     }
     $categoryDescLimit = (int) $this->params->get('category_desc_limit', 0);
     if ($categoryDescLimit > 0) {
         $this->category->description = JUDirectoryFrontHelperString::truncateHtml($this->category->description, $categoryDescLimit);
     }
     if ($this->params->get('plugin_support', 0)) {
         $this->category->description = JHtml::_('content.prepare', $this->category->description, '', 'com_judirectory.category');
     }
     $this->category->class_sfx = htmlspecialchars($this->category->class_sfx);
     $relatedCatOrdering = $this->params->get('related_category_ordering', 'crel.ordering');
     $relatedCatDirection = $this->params->get('related_category_direction', 'ASC');
     $this->related_cats = $model->getRelatedCategories($this->category->id, $relatedCatOrdering, $relatedCatDirection);
     if (is_array($this->related_cats) && count($this->related_cats) > 0) {
         foreach ($this->related_cats as $relatedCategory) {
             if (isset($relatedCategory->images->intro_image) && !empty($relatedCategory->images->intro_image)) {
                 $relatedCategory->images->intro_image_src = JUri::root(true) . '/' . JUDirectoryFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judirectory/images/category/intro/', true) . $relatedCategory->images->intro_image;
             }
             $relatedCategory->images->intro_image_width = (int) $this->params->get('related_category_intro_image_width', 200);
             $relatedCategory->images->intro_image_height = (int) $this->params->get('related_category_intro_image_height', 200);
             if ($this->params->get('related_category_show_introtext', 1)) {
                 $relatedCategoryDescLimit = (int) $this->params->get('related_category_introtext_character_limit', 500);
                 if ($relatedCategoryDescLimit > 0) {
                     $relatedCategory->introtext = JUDirectoryFrontHelperString::truncateHtml($relatedCategory->introtext, $relatedCategoryDescLimit);
                 }
                 if ($params->get('plugin_support', 0)) {
                     $relatedCategory->introtext = JHtml::_('content.prepare', $relatedCategory->introtext, '', 'com_judirectory.category');
                 }
             } else {
                 $relatedCategory->introtext = '';
             }
         }
     }
     $subCatOrdering = $this->params->get('subcategory_ordering', 'title');
     $subCatDirection = $this->params->get('subcategory_direction', 'ASC');
     $this->subcategories = $model->getSubCategories($this->category->id, $subCatOrdering, $subCatDirection);
     if (is_array($this->subcategories) && count($this->subcategories) > 0) {
         foreach ($this->subcategories as $subCategory) {
             if (isset($subCategory->images->intro_image) && !empty($subCategory->images->intro_image)) {
                 $subCategory->images->intro_image_src = JUri::root(true) . '/' . JUDirectoryFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judirectory/images/category/intro/', true) . $subCategory->images->intro_image;
             }
             $subCategory->images->intro_image_width = (int) $this->params->get('subcategory_intro_image_width', 200);
             $subCategory->images->intro_image_height = (int) $this->params->get('subcategory_intro_image_height', 200);
             if ($this->params->get('subcategory_show_introtext', 1)) {
                 $subCategoryDescLimit = (int) $this->params->get('subcategory_introtext_character_limit', 500);
                 if ($subCategoryDescLimit > 0) {
                     $subCategory->introtext = JUDirectoryFrontHelperString::truncateHtml($subCategory->introtext, $subCategoryDescLimit);
                 }
                 if ($this->params->get('plugin_support', 0)) {
                     $subCategory->introtext = JHtml::_('content.prepare', $subCategory->introtext, '', 'com_judirectory.category');
                 }
             } else {
                 $subCategory->introtext = '';
             }
         }
     }
     $this->category->can_submit_listing = JUDirectoryFrontHelperPermission::canSubmitListing($this->category->id);
     if ($this->category->can_submit_listing && $this->params->get('show_submit_listing_btn_in_category', 1)) {
         $this->category->submit_listing_link = JUDirectoryFrontHelperListing::getAddListingLink($this->category->id);
     }
     $this->items = array();
     if ($this->category->show_item) {
         $user = JFactory::getUser();
         $uri = JUri::getInstance();
         $this->items = $this->get('Items');
         foreach ($this->items as $item) {
             $item->report_link = JRoute::_(JUDirectoryHelperRoute::getReportListingRoute($item->id));
             $item->claim_link = JRoute::_(JUDirectoryHelperRoute::getClaimListingRoute($item->id));
             if ($item->checked_out > 0 && $item->checked_out != $user->get('id')) {
                 if (JUDirectoryFrontHelperPermission::canCheckInListing($item->id)) {
                     $item->checkin_link = JRoute::_('index.php?option=com_judirectory&task=forms.checkin&id=' . $item->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri)));
                 }
             } else {
                 $item->edit_link = JRoute::_('index.php?option=com_judirectory&task=form.edit&id=' . $item->id . '&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
                 if ($item->published == 1) {
                     $item->editstate_link = JRoute::_('index.php?option=com_judirectory&task=forms.unpublish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
                 } else {
                     $item->editstate_link = JRoute::_('index.php?option=com_judirectory&task=forms.publish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
                 }
             }
             $item->delete_link = JRoute::_('index.php?option=com_judirectory&task=forms.delete&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('content');
             $item->event = new stdClass();
             $context = 'com_judirectory.listing_list';
             $results = $dispatcher->trigger('onContentAfterTitle', array($context, &$item, &$item->params, 0));
             $item->event->afterDisplayTitle = trim(implode("\n", $results));
             $results = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$item, &$item->params, 0));
             $item->event->beforeDisplayContent = trim(implode("\n", $results));
             $results = $dispatcher->trigger('onContentAfterDisplay', array($context, &$item, &$item->params, 0));
             $item->event->afterDisplayContent = trim(implode("\n", $results));
         }
         $this->pagination = $this->get('Pagination');
         //print_r($this->pagination);
     }
     $this->locations = JUDirectoryFrontHelper::getLocations($this->items);
     //print_r($this->locations);
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $this->_prepareData();
     $this->_prepareDocument();
     $this->_setBreadcrumb();
     parent::display($tpl);
 }