Beispiel #1
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'];
     }
 }