protected function _getAssetParentId(JTable $table = null, $id = null) { $assetId = null; if (isset($this->cat_id) && $this->cat_id) { $cat_id = $this->cat_id; } elseif ($this->id) { $cat_id = JUDirectoryHelper::getListingById($this->id)->cat_id; } if ($cat_id) { $query = $this->_db->getQuery(true); $query->select($this->_db->quoteName('asset_id')); $query->from($this->_db->quoteName('#__judirectory_categories')); $query->where($this->_db->quoteName('id') . ' = ' . $cat_id); $this->_db->setQuery($query); if ($result = $this->_db->loadResult()) { $assetId = (int) $result; } } if ($assetId === null) { $query = $this->_db->getQuery(true); $query->select($this->_db->quoteName('id')); $query->from($this->_db->quoteName('#__assets')); $query->where($this->_db->quoteName('name') . ' = ' . $this->_db->quote('com_judirectory')); $this->_db->setQuery($query); if ($result = $this->_db->loadResult()) { $assetId = (int) $result; } } if ($assetId) { return $assetId; } else { return parent::_getAssetParentId($table, $id); } }
public function back() { $app = JFactory::getApplication(); $listing_id = $app->input->getInt('listing_id', 0); $cat_id = JUDirectoryFrontHelperCategory::getRootCategory()->id; if ($listing_id) { $listingObj = JUDirectoryHelper::getListingById($listing_id); if (isset($listingObj->cat_id) && $listingObj->cat_id) { $cat_id = $listingObj->cat_id; } } $this->setRedirect("index.php?option=com_judirectory&view=listcats&cat_id={$cat_id}"); }
public function getInput() { $db = JFactory::getDbo(); $groups = array(); $app = JFactory::getApplication(); $appendInherit = ''; if ($app->input->get("view") == "listing") { if ($this->form->getValue("id")) { $listing = JUDirectoryHelper::getListingById($this->form->getValue("id")); $appendInherit = "(" . $this->calculatorInheritStyle($listing->cat_id) . ")"; } } else { if ($this->form->getValue("parent_id")) { $appendInherit = "(" . $this->calculatorInheritStyle($this->form->getValue("parent_id")) . ")"; } } $appendDefault = "(" . $this->getStyle() . ")"; $groups['inherit'] = array(); $groups['inherit']['id'] = $this->id . '_inherit'; $groups['inherit']['text'] = '---' . JText::_('COM_JUDIRECTORY_INHERIT') . '---'; $groups['inherit']['items'] = array(); $groups['inherit']['items'][] = JHtml::_('select.option', '-2', JText::_('COM_JUDIRECTORY_DEFAULT') . ' ' . $appendDefault); $groups['inherit']['items'][] = JHtml::_('select.option', '-1', JText::_('COM_JUDIRECTORY_INHERIT') . ' ' . $appendInherit); $query = $db->getQuery(true); $query->select('style.*'); $query->select('plg.title AS template_title, plg.folder'); $query->from('#__judirectory_template_styles AS style'); $query->join('', '#__judirectory_templates AS tpl ON tpl.id = style.template_id'); $query->join('', '#__judirectory_plugins AS plg ON plg.id = tpl.plugin_id'); $query->where('style.lft > 0'); $query->order('style.lft ASC'); $db->setQuery($query); $styles = $db->loadObjectList(); for ($i = 0, $n = count($styles); $i < $n; $i++) { $styles[$i]->text = str_repeat('- ', $styles[$i]->level - 1) . $styles[$i]->title . " [ " . $styles[$i]->template_title . " ]"; } $groups['style'] = array(); $groups['style']['id'] = 'template_style'; $groups['style']['text'] = JText::_('COM_JUDIRECTORY_TEMPLATE_STYLES'); $groups['style']['items'] = array(); foreach ($styles as $style) { $groups['style']['items'][] = JHtml::_('select.option', $style->id, $style->text); } $html = JHtml::_('select.groupedlist', $groups, $this->name, array('id' => $this->id, 'group.id' => 'id', 'list.attr' => "", 'list.select' => $this->value)); return $html; }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->model = $this->getModel(); $this->app = JFactory::getApplication(); $cat_id = $this->item->cat_id ? $this->item->cat_id : $this->app->input->get('cat_id'); $this->params = JUDirectoryHelper::getParams(null, $this->item->id); if ($cat_id == JUDirectoryFrontHelperCategory::getRootCategory()->id && !$this->params->get('allow_add_listing_to_root', 0)) { JError::raiseError(500, JText::_('COM_JUDIRECTORY_CAN_NOT_ADD_LISTING_TO_ROOT_CATEGORY')); return false; } if ($tempListing = JUDirectoryHelper::getTempListing($this->item->id)) { $editPendingListingLink = '<a href="index.php?option=com_judirectory&task=document.edit&approve=1&id=' . $tempListing->id . '">' . $tempListing->title . '</a>'; JError::raiseNotice('', JText::sprintf('COM_JUDIRECTORY_THIS_LISTING_HAS_PENDING_LISTING_X_PLEASE_APPROVE_PENDING_LISTING_FIRST', $editPendingListingLink)); } if ($this->item->approved < 0) { $oriListingId = abs($this->item->approved); $oriListingObj = JUDirectoryHelper::getListingById($oriListingId); $editOriDocLink = '<a href="index.php?option=com_judirectory&task=document.edit&id=' . $oriListingId . '">' . $oriListingObj->title . '</a>'; JError::raiseNotice('', JText::sprintf('COM_JUDIRECTORY_ORIGINAL_LISTING_X', $editOriDocLink)); } $this->script = $this->get('Script'); $this->plugins = $this->get('Plugins'); $this->fieldLocations = $this->get('FieldLocations'); $this->fieldsetDetails = $this->model->getCoreFields('details'); $this->fieldsetPublishing = $this->model->getCoreFields('publishing'); $this->fieldsetTemplateStyleAndLayout = $this->model->getCoreFields('template_style'); $this->fieldsetMetadata = $this->model->getCoreFields('metadata'); $this->fieldCatid = JUDirectoryFrontHelperField::getField('cat_id', $this->item); $this->fieldGallery = $this->get('GalleryField'); $this->extraFields = $this->get('ExtraFields'); $this->fieldsData = $this->app->getUserState("com_judirectory.edit.listing.fieldsdata", array()); $this->relatedListings = $this->get('RelatedListings'); $this->canDo = JUDirectoryHelper::getActions('com_judirectory', 'category', $this->item->cat_id); $this->addToolBar(); $this->setDocument(); parent::display($tpl); }
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 . '"' : ''; $listingObject = JUDirectoryHelper::getListingById($this->value); $listingLink = JRoute::_('index.php?option=com_judirectory&task=listing.edit&id=' . $listingObject->id); $html[] = '<div class="btn"><a href="' . $listingLink . '" target="_blank">' . $listingObject->title . '</a></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); }
public static function getCurrentTemplateStyle($view = '', $id = null) { $app = JFactory::getApplication(); $jInput = $app->input; if (!$view) { $view = $jInput->getString('view', ''); } if ($jInput->getString('option', '') != 'com_judirectory') { $view = ''; } if (!$id) { switch ($view) { case 'form': $id = $jInput->getInt('id', 0); $rootCategory = JUDirectoryFrontHelperCategory::getRootCategory(); $cat_id = $jInput->getInt('cat_id', $rootCategory->id); break; case 'listing': $id = $jInput->getInt('id', 0); break; case 'category': $rootCategory = JUDirectoryFrontHelperCategory::getRootCategory(); $id = $jInput->getInt('id', $rootCategory->id); break; } } switch ($view) { case 'form': if ($id) { $templateStyleObject = self::getTemplateStyleOfListing($id); $listingObject = JUDirectoryHelper::getListingById($id); $templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $listingObject->template_params); } else { $templateStyleObject = self::getTemplateStyleOfCategory($cat_id); $categoryObject = JUDirectoryHelper::getCategoryById($cat_id); $templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $categoryObject->template_params); } break; case 'listing': $templateStyleObject = self::getTemplateStyleOfListing($id); $listingObject = JUDirectoryHelper::getListingById($id); $templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $listingObject->template_params); break; case 'category': $templateStyleObject = self::getTemplateStyleOfCategory($id); $categoryObject = JUDirectoryHelper::getCategoryById($id); $templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $categoryObject->template_params); break; default: $templateStyleObject = self::getDefaultTemplateStyle(); $templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id); break; } return $templateStyleObject; }
public function onCopy($toListingId, &$fieldsData = array()) { $db = JFactory::getDbo(); if ($this->listing->image && strpos($this->listing->image, "default/") === false) { $ori_image_name = $this->listing->image; $new_image_name = $toListingId . substr($ori_image_name, strpos($ori_image_name, '_')); $query = "UPDATE #__judirectory_listings SET image = '" . $new_image_name . "' WHERE id=" . $toListingId; $db->setQuery($query); $db->execute(); $image_directory = JPATH_ROOT . "/" . JUDirectoryFrontHelper::getDirectory("listing_image_directory", "media/com_judirectory/images/listing/"); if (JFile::exists($image_directory . $ori_image_name)) { JFile::copy($image_directory . $ori_image_name, $image_directory . $new_image_name); } if (JFile::exists($image_directory . "original/" . $ori_image_name)) { JFile::copy($image_directory . "original/" . $ori_image_name, $image_directory . "original/" . $new_image_name); } } if ($this->listing_id && isset($fieldsData[$this->id])) { $toListingObject = JUDirectoryHelper::getListingById($toListingId); $fieldsData[$this->id] = $toListingObject->image; } }
public static function getMainCategoryId($listingId, $resetCache = false) { $listingObj = JUDirectoryHelper::getListingById($listingId, $resetCache); if (is_object($listingObj)) { return $listingObj->cat_id; } return null; }
public function getListingSubmitType($listingId, $listingObject = null, $isNew = null) { if (!is_null($isNew)) { if ($isNew) { return 'submit'; } } if ($listingId == 0) { return 'submit'; } if (!is_object($listingObject)) { $listingObject = JUDirectoryHelper::getListingById($listingId); } if ($listingObject->approved == 0) { return 'submit'; } else { return 'edit'; } }
public static function getListingDisplayParams($listing_id) { if (!$listing_id) { return null; } $storeId = md5(__METHOD__ . "::{$listing_id}"); if (!isset(self::$cache[$storeId])) { $params = JUDirectoryHelper::getParams(null, $listing_id); $global_display_params = $params->get('display_params'); $global_listing_display_object = isset($global_display_params->listing) ? $global_display_params->listing : array(); $global_listing_display_params = new JRegistry($global_listing_display_object); $listingObj = JUDirectoryHelper::getListingById($listing_id); $listing_params = $listingObj->params; if ($listing_params) { $listing_params = json_decode($listing_params); $listing_display_params = $listing_params->display_params; if ($listing_display_params) { $global_listing_display_params = JUDirectoryFrontHelperField::mergeFieldOptions($global_listing_display_params->toObject(), $listing_display_params); unset($listing_display_params->fields); foreach ($listing_display_params as $option => $value) { if ($value == '-2') { unset($listing_display_params->{$option}); } } $global_listing_display_params->loadObject($listing_display_params); } } self::$cache[$storeId] = $global_listing_display_params; } return self::$cache[$storeId]; }
public function getInput($fieldValue = null) { if (!$this->isPublished()) { return ""; } if (JUDirectoryHelper::getListingSubmitType($this->listing_id) == 'submit' && $this->canSubmit() || JUDirectoryHelper::getListingSubmitType($this->listing_id) == 'edit' && $this->canEdit()) { $disabled = false; } else { $disabled = true; } $document = JFactory::getDocument(); $rootCat = JUDirectoryFrontHelperCategory::getRootCategory(); JText::script('COM_JUDIRECTORY_TOTAL_CATS_OVER_MAXIMUM_N_CATS'); JText::script('COM_JUDIRECTORY_CATEGORY_X_ALREADY_EXIST'); $app = JFactory::getApplication(); // getParams by cat_id if possible if (isset($this->listing) && $this->listing->cat_id) { $params = JUDirectoryHelper::getParams($this->listing->cat_id); } else { $params = JUDirectoryHelper::getParams(null, $this->listing_id); } $db = JFactory::getDbo(); $listingId = $this->listing_id; $listingObject = JUDirectoryHelper::getListingById($listingId); $secondaryCatIds = $secondaryCatIdsStr = ""; // Edit listing, but not valid data -> $fieldValue = user selected categories if ($fieldValue && !empty($fieldValue['main'])) { $categoryId = (int) $fieldValue['main']; if ($fieldValue['secondary']) { $secondaryCatIdsStr = $fieldValue['secondary']; $secondaryCatIds = explode(",", $secondaryCatIdsStr); } $query = $db->getQuery(true); $query->select("c.id, c.parent_id"); $query->from("#__judirectory_categories AS c"); $query->select("field_group.id AS fieldgroup_id, field_group.name AS fieldgroup_name"); $query->join("LEFT", "#__judirectory_fields_groups AS field_group ON (field_group.id = c.fieldgroup_id AND field_group.published = 1)"); $query->where("c.id = " . $categoryId); $db->setQuery($query); $mainCategory = $db->loadObject(); } elseif ($listingId) { $categories = $this->value; foreach ($categories as $category) { if ($category->main == 1) { $mainCategory = $category; $query = $db->getQuery(true); $query->select("field_group.id, field_group.name"); $query->from("#__judirectory_fields_groups AS field_group"); $query->join("", "#__judirectory_categories AS c on c.fieldgroup_id = field_group.id"); $query->where("c.id = " . $mainCategory->id); $query->where("field_group.published = 1"); $db->setQuery($query); $fieldGroup = $db->loadObject(); if (is_object($fieldGroup)) { $mainCategory->fieldgroup_name = $fieldGroup->name; $mainCategory->fieldgroup_id = $fieldGroup->id; } else { $mainCategory->fieldgroup_name = null; $mainCategory->fieldgroup_id = null; } } else { $secondaryCatIds[] = $category->id; } } if ($secondaryCatIds) { $secondaryCatIdsStr = implode(",", $secondaryCatIds); } } elseif ($app->input->getInt('cat_id')) { $categoryId = $app->input->getInt('cat_id'); $mainCategory = JUDirectoryHelper::getCategoryById($categoryId); $query = "SELECT id, name FROM #__judirectory_fields_groups WHERE id= " . $mainCategory->fieldgroup_id . " AND published = 1"; $db->setQuery($query); $fieldGroup = $db->loadObject(); if (is_object($fieldGroup)) { $mainCategory->fieldgroup_name = $fieldGroup->name; $mainCategory->fieldgroup_id = $fieldGroup->id; } else { $mainCategory->fieldgroup_name = null; $mainCategory->fieldgroup_id = null; } } else { $mainCategory = new stdClass(); $mainCategory->id = ''; $mainCategory->parent_id = $rootCat->id; $mainCategory->fieldgroup_name = null; $mainCategory->fieldgroup_id = null; } $document->addStyleSheet(JUri::root() . "components/com_judirectory/fields/" . $this->folder . "/core_categories.css"); if (!$disabled) { $document->addScript(JUri::root() . "components/com_judirectory/fields/" . $this->folder . "/core_categories.js"); if (JUDirectoryHelper::isJoomla3x()) { $jsIsJoomla3x = 1; } else { $jsIsJoomla3x = 0; } $script = "jQuery(document).ready(function(\$){\n\t\t\t\t\t\t\t\t\$('.category_selection').listingChangeCategory({\n\t\t\t\t\t\t\t\t\tlisting_id: '" . $listingId . "',\n\t\t\t\t\t\t\t\t\tis_joomla_3x: '" . $jsIsJoomla3x . "',\n\t\t\t\t\t\t\t\t\tmain_cat_id: '" . $mainCategory->id . "',\n\t\t\t\t\t\t\t\t\tfieldgroup_id: '" . $mainCategory->fieldgroup_id . "',\n\t\t\t\t\t\t\t\t\tfieldgroup_name : '" . $mainCategory->fieldgroup_name . "',\n\t\t\t\t\t\t\t\t\tmax_cats : " . (int) $params->get("max_cats_per_listing", 0) . "\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});"; $document->addScriptDeclaration($script); } $this->addAttribute("class", "categories", "input"); $this->addAttribute("class", $this->getInputClass(), "input"); $this->setVariable('mainCategory', $mainCategory); $this->setVariable('secondaryCatIds', $secondaryCatIds); $this->setVariable('listingObject', $listingObject); $this->setVariable('disabled', $disabled); $this->setVariable('secondaryCatIdsStr', $secondaryCatIdsStr); $this->setVariable('rootCat', $rootCat); $this->setVariable('params', $params); return $this->fetch('input.php', __CLASS__); }
protected function getInput() { $clientId = $this->element['client_id']; if (is_null($clientId) && $this->form instanceof JForm) { $clientId = $this->form->getValue('client_id'); } $clientId = (int) $clientId; $client = JApplicationHelper::getClientInfo($clientId); $extn = (string) $this->element['extension']; if (empty($extn) && $this->form instanceof JForm) { $extn = $this->form->getValue('extension'); } $extn = preg_replace('#\\W#', '', $extn); $template = (string) $this->element['template']; $template = preg_replace('#\\W#', '', $template); if ($this->form instanceof JForm) { $template_style_id = $this->form->getValue('template_style_id'); } $template_style_id = preg_replace('#\\W#', '', $template_style_id); $view = (string) $this->element['view']; $view = preg_replace('#\\W#', '', $view); if ($extn && $view && $client) { $lang = JFactory::getLanguage(); $lang->load($extn . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, null, false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, $lang->getDefault(), false, false); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('e.element, e.name'); $query->from('#__extensions AS e'); $query->where('e.client_id = ' . (int) $clientId); $query->where('e.type = ' . $db->quote('template')); $query->where('e.enabled = 1'); if ($template) { $query->where('e.element = ' . $db->quote($template)); } if ($template_style_id) { $query->join('LEFT', '#__template_styles AS s ON s.template=e.element'); $query->where('s.id=' . (int) $template_style_id); } $db->setQuery($query); $templates = $db->loadObjectList('element'); if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } $component_path = JPath::clean($client->path . '/components/' . $extn . '/views/' . $view . '/tmpl'); $component_layouts = array(); $groups = array(); $items = array(); if ($this->element['useinherit']) { $groups['inherit'] = array(); $groups['inherit']['id'] = $this->id . '_inherit'; $groups['inherit']['text'] = '---' . JText::_('COM_JUDIRECTORY_INHERIT') . '---'; $groups['inherit']['items'] = array(); } if (is_dir($component_path) && ($component_layouts = JFolder::files($component_path, '^[^_]*\\.xml$', false, true))) { $groups['_'] = array(); $groups['_']['id'] = $this->id . '__'; $groups['_']['text'] = JText::sprintf('JOPTION_FROM_COMPONENT'); $groups['_']['items'] = array(); foreach ($component_layouts as $i => $file) { if (!($xml = simplexml_load_file($file))) { unset($component_layouts[$i]); continue; } if (!($menu = $xml->xpath('layout[1]'))) { unset($component_layouts[$i]); continue; } $menu = $menu[0]; $value = JFile::stripext(JFile::getName($file)); $component_layouts[$i] = $value; $text = isset($menu['option']) ? JText::_($menu['option']) : (isset($menu['title']) ? JText::_($menu['title']) : $value); $groups['_']['items'][] = JHtml::_('select.option', '_:' . $value, $text); $items['_'][$value] = $text; } } $attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; if ($this->element['useinherit']) { $appendInherit = ""; $app = JFactory::getApplication(); if ($app->input->get('view', '') == "listing" && $this->form->getValue("id")) { $listing = JUDirectoryHelper::getListingById($this->form->getValue("id")); if ($listing) { $appendInherit = $this->calculatorInheritLayout($items, $listing->cat_id); } } elseif ($app->input->get('view', '') == "category") { if ($this->form->getValue("parent_id")) { $appendInherit = $this->calculatorInheritLayout($items, $this->form->getValue("parent_id")); } } $appendGlodbal = $this->getLayout($items); $groups['inherit']['items'][] = JHtml::_('select.option', '-2', 'Global config ' . $appendGlodbal); $groups['inherit']['items'][] = JHtml::_('select.option', '-1', 'Inherit category ' . $appendInherit); } $selected = array($this->value); return JHtml::_('select.groupedlist', $groups, $this->name, array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected)); } else { return ''; } }
public function updateRating($data) { $user = JFactory::getUser(); $created = JFactory::getDate()->toSql(); $criteriaArray = isset($data['criteria_array']) ? $data['criteria_array'] : array(); $listingId = $data['listing_id']; $commentId = $data['comment_id']; $ratingObj = $this->getRating($listingId, $commentId); $ratingId = $ratingObj->id; $ratingScoreOld = $ratingObj->score; $ratingScoreNew = JUDirectoryFrontHelperRating::calculateRatingScore($data, $listingId, $criteriaArray); $dataRating = array('id' => $ratingId, 'user_id' => $user->id, 'comment_id' => $commentId, 'score' => $ratingScoreNew, 'created' => $created, 'listing_id' => $listingId); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables'); $ratingTable = JTable::getInstance('Rating', 'JUDirectoryTable'); $ratingTable->bind($dataRating); if (!$ratingTable->check()) { return false; } $ratingStore = $ratingTable->store(); if (!$ratingStore) { return false; } if ($ratingStore && count($criteriaArray) > 0) { $oldCriteriaIdArr = $this->getCriteriasId($ratingId); $criteriaIdArr = array(); foreach ($criteriaArray as $criteria) { $criteriaIdArr[] = $criteria->id; } $flagUpdate = false; if (count(array_diff($criteriaIdArr, $oldCriteriaIdArr)) == 0) { $flagUpdate = true; } if ($flagUpdate == false) { $this->deleteCriteriasByRatingId($ratingId); } foreach ($criteriaArray as $criteria) { if ($flagUpdate == true) { $this->updateCriteriaValue($ratingId, $criteria->id, $criteria->value); } else { JUDirectoryMultiRating::insertCriteriaValue($ratingId, $criteria->id, $criteria->value); } } } $listingItem = JUDirectoryHelper::getListingById($listingId); $rating = ($listingItem->rating * $listingItem->total_votes + $ratingScoreNew - $ratingScoreOld) / $listingItem->total_votes; $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->update('#__judirectory_listings'); $query->set('rating = ' . $rating); $query->where('id = ' . $listingId); $db->setQuery($query); $db->execute(); $session = JFactory::getSession(); $timeNow = JFactory::getDate()->toSql(); $timeNowStamp = strtotime($timeNow); $inputCookie = JFactory::getApplication()->input->cookie; $config = JFactory::getConfig(); $cookie_domain = $config->get('cookie_domain', ''); $cookie_path = $config->get('cookie_path', '/'); $inputCookie->set('judir-listing-rated-' . $listingId, $timeNowStamp, time() + 864000, $cookie_path, $cookie_domain); $session->set('judir-listing-rated-' . $listingId, $timeNowStamp); $logData = array('user_id' => $user->id, 'event' => 'listing.rate', 'item_id' => $listingId, 'listing_id' => $listingId, 'value' => $ratingScoreNew, 'reference' => $ratingTable->id); JUDirectoryFrontHelperLog::addLog($logData); return true; }
public static function appendDataToListingObjList(&$listingObjectList, $params, $usingForMod = false) { if (is_array($listingObjectList) && count($listingObjectList)) { $user = JFactory::getUser(); foreach ($listingObjectList as $listingObject) { JUDirectoryHelper::getListingById($listingObject->id, false, $listingObject); $listingObject->params = JUDirectoryFrontHelperListing::getListingDisplayParams($listingObject->id); if (!$user->get('guest')) { $canEditListing = JUDirectoryFrontHelperPermission::canEditListing($listingObject->id); $canEditStateListing = JUDirectoryFrontHelperPermission::canEditStateListing($listingObject); $canDeleteListing = JUDirectoryFrontHelperPermission::canDeleteListing($listingObject->id); $listingObject->params->set('access-edit', $canEditListing); $listingObject->params->set('access-edit-state', $canEditStateListing); $listingObject->params->set('access-delete', $canDeleteListing); } if ($listingObject->published != 1) { $listingObject->label_unpublished = true; } else { $listingObject->label_unpublished = false; } $listingObject->label_pending = false; $nowDate = JFactory::getDate()->toSql(); if (intval($listingObject->publish_up) > 0) { if (strtotime($listingObject->publish_up) > strtotime($nowDate)) { $listingObject->label_pending = true; } } $listingObject->label_expired = false; if (intval($listingObject->publish_down) > 0) { if (intval($listingObject->publish_up) > 0) { if (strtotime($listingObject->publish_up) <= strtotime($nowDate)) { if (strtotime($listingObject->publish_down) < strtotime($nowDate)) { $listingObject->label_expired = true; } } } else { if (strtotime($listingObject->publish_down) < strtotime($nowDate)) { $listingObject->label_expired = true; } } } if ($params->get('show_new_label', 1) && JUDirectoryFrontHelper::isWithinXDays($listingObject->publish_up, $params->get('num_day_to_show_as_new', 10))) { $listingObject->label_new = true; } else { $listingObject->label_new = false; } if ($params->get('show_updated_label', 1) && JUDirectoryFrontHelper::isWithinXDays($listingObject->updated, $params->get('num_day_to_show_as_updated', 10))) { $listingObject->label_updated = true; } else { $listingObject->label_updated = false; } if ($params->get('show_hot_label', 1) && JUDirectoryFrontHelperListing::checkHotListing($listingObject->publish_up, $params->get('num_hit_per_day_to_be_hot', 100), $listingObject->hits)) { $listingObject->label_hot = true; } else { $listingObject->label_hot = false; } if ($params->get('show_featured_label', 1) && $listingObject->featured) { $listingObject->label_featured = true; } else { $listingObject->label_featured = false; } } } }
public static function getListingSegment($listingId, &$query, $params) { if (isset($query['Itemid'])) { unset($query['Itemid']); } $fullPathListing = $params->get('sef_listing_full_path', 0); $listingObject = JUDirectoryHelper::getListingById($listingId); $mainCategoryId = $listingObject->cat_id; $segment = JUDirectoryHelperRoute::getCategorySegment($mainCategoryId, $query, $fullPathListing); $segment[] = $listingId . ":" . (isset($listingObject->alias) ? $listingObject->alias : ''); return $segment; }
public function cancel($key = null) { JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $listing_id = $app->input->getInt('id', 0); if ($listing_id) { $listingObject = JUDirectoryHelper::getListingById($listing_id); $cat_id = $listingObject->cat_id; } else { $fieldCategory = JUDirectoryFrontHelperField::getField('cat_id'); $fieldsData = $app->input->post->get('fields', array(), 'array'); $cat_id = $fieldsData[$fieldCategory->id]['main']; } if (!$cat_id) { $rootCategory = JUDirectoryFrontHelperCategory::getRootCategory(); $cat_id = $rootCategory->id; } $context = $this->option . ".edit." . $this->context; $app->setUserState($context . '.data', null); $app->setUserState($context . '.fieldsdata', null); $app->setUserState($context . '.related_listings', null); if ($listing_id) { $db = JFactory::getDbo(); $query = "SELECT cat_id FROM #__judirectory_listings_xref WHERE listing_id = {$listing_id} AND main = 1"; $db->setQuery($query); $cat_id = $db->loadResult(); } parent::cancel($key = null); if ($this->view_list == "pendinglistings") { $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); } else { $this->setRedirect("index.php?option=com_judirectory&view=listcats&cat_id={$cat_id}"); } }
public function loadListing($listing, $resetCache = false) { if (is_numeric($listing) && $listing > 0) { $listing = clone JUDirectoryHelper::getListingById($listing, $resetCache); } if (is_object($listing) || is_null($listing)) { $this->listing = $listing; } }
JHtml::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/helpers/html'); JHtml::_('behavior.multiselect'); if (JUDirectoryHelper::isJoomla3x()) { $classTooltip = "hasTooltip"; $separator = "<br/>"; JHtml::_('bootstrap.tooltip'); } else { JHtml::_('behavior.tooltip'); $separator = "::"; $classTooltip = "hasTip"; } $session = JFactory::getSession(); $moved_listing_id = $session->get('moved_listing_id'); $listings = array(); foreach ($moved_listing_id as $doc_id) { $listings[] = JUDirectoryHelper::getListingById($doc_id); } ?> <div class="jubootstrap"> <div id="iframe-help"></div> <form action="<?php echo JRoute::_('index.php?option=com_judirectory&view=listings'); ?> " method="post" name="adminForm" id="adminForm"> <fieldset class="adminform"> <legend><?php echo JText::_('COM_JUDIRECTORY_MOVE_LISTINGS'); ?>
public function parse(&$segments) { $total = count($segments); $vars = array(); for ($i = 0; $i < $total; $i++) { $segments[$i] = preg_replace('/:/', '-', $segments[$i], 1); } $params = JUDirectoryHelper::getParams(); $app = JFactory::getApplication('site'); $menu = $app->getMenu(); $activeMenu = $menu->getActive(); $indexLastSegment = $total - 1; $endSegment = end($segments); $searchViewApproveComment = array_search(JApplication::stringURLSafe('mod-comment'), $segments); if ($searchViewApproveComment !== false) { $vars['view'] = 'modcomment'; if (isset($segments[$searchViewApproveComment + 1])) { $vars['id'] = (int) $segments[$searchViewApproveComment + 1]; } if (isset($segments[$searchViewApproveComment + 2])) { if ($segments[$searchViewApproveComment + 2] == JApplication::stringURLSafe('approve')) { $vars['approve'] = 1; } } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } if (isset($segments[0]) && $segments[0] == JApplication::stringURLSafe('comment')) { if (isset($segments[2])) { switch ($segments[2]) { case JApplication::stringURLSafe('edit'): $vars['task'] = 'modcomment.edit'; if (isset($segments[1])) { $vars['id'] = (int) $segments[1]; } break; case JApplication::stringURLSafe('approve'): $vars['task'] = 'modpendingcomment.edit'; if (isset($segments[1])) { $vars['id'] = (int) $segments[1]; } break; case JApplication::stringURLSafe('subscribe'): $vars['task'] = 'subscribe.save'; if (isset($segments[1])) { $vars['comment_id'] = (int) $segments[1]; } break; case JApplication::stringURLSafe('unsubscribe'): $vars['task'] = 'subscribe.remove'; if (isset($segments[3])) { $vars['sub_id'] = (int) $segments[3]; } if (isset($segments[4])) { $vars['code'] = $segments[4]; } break; case JApplication::stringURLSafe('delete'): $vars['task'] = 'listing.deleteComment'; if (isset($segments[1])) { $vars['comment_id'] = (int) $segments[1]; } break; default: break; } if (isset($vars['task'])) { return $vars; } } } $searchViewReportComment = array_search(JApplication::stringURLSafe('comment'), $segments); if ($searchViewReportComment !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewReportComment, $validArrayIndex)) { if (isset($segments[$searchViewReportComment + 2])) { if ($segments[$searchViewReportComment + 2] == JApplication::stringURLSafe('report')) { $vars['view'] = 'report'; if (isset($segments[$searchViewReportComment + 1])) { $vars['comment_id'] = (int) $segments[$searchViewReportComment + 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } } } $searchViewModeratorPermission = array_search(JApplication::stringURLSafe('mod-permission'), $segments); if ($searchViewModeratorPermission !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewModeratorPermission, $validArrayIndex)) { $vars['view'] = 'modpermission'; if (isset($segments[$searchViewModeratorPermission + 1])) { $vars['id'] = (int) $segments[$searchViewModeratorPermission + 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewCustomList = array_search(JApplication::stringURLSafe('custom-list'), $segments); if ($searchViewCustomList !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewCustomList, $validArrayIndex)) { $vars['view'] = 'customlist'; if (isset($segments[$searchViewCustomList + 1])) { $vars['id'] = (int) $segments[$searchViewCustomList + 1]; } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewCompare = array_search(JApplication::stringURLSafe('compare'), $segments); if ($searchViewCompare !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewCompare, $validArrayIndex)) { $vars['view'] = 'compare'; $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } if (isset($segments[0]) && $segments[0] == JApplication::stringURLSafe('user-subscriptions')) { if (isset($segments[2])) { if ($segments[2] == JApplication::stringURLSafe('unsubscribe')) { $vars['task'] = 'usersubscriptions.unsubscribe'; if (isset($segments[1])) { $vars['sub_id'] = (int) $segments[1]; } return $vars; } } } if (isset($segments[0]) && $segments[0] == JApplication::stringURLSafe('email')) { if (isset($segments[1]) && $segments[1] == JApplication::stringURLSafe('download-attachment')) { $vars['task'] = 'email.downloadattachment'; if (isset($segments[2])) { $vars['mail_id'] = (int) $segments[2]; } if (isset($segments[3])) { $vars['file'] = $segments[3]; } if (isset($segments[4])) { $vars['code'] = $segments[4]; } } return $vars; } $searchViewModeratorPermissions = array_search(JApplication::stringURLSafe('mod-permissions'), $segments); if ($searchViewModeratorPermissions !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewModeratorPermissions, $validArrayIndex)) { $vars['view'] = 'modpermissions'; $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewProfile = array_search(JApplication::stringURLSafe('profile'), $segments); if ($searchViewProfile !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewProfile, $validArrayIndex)) { $vars['view'] = 'profile'; $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewModeratorPendingListings = array_search(JApplication::stringURLSafe('mod-pending-listings'), $segments); if ($searchViewModeratorPendingListings !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewModeratorPendingListings, $validArrayIndex)) { $vars['view'] = 'modpendinglistings'; $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewModeratorPendingComments = array_search(JApplication::stringURLSafe('mod-pending-comments'), $segments); if ($searchViewModeratorPendingComments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewModeratorPendingComments, $validArrayIndex)) { $vars['view'] = 'modpendingcomments'; $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewModeratorComments = array_search(JApplication::stringURLSafe('mod-comments'), $segments); if ($searchViewModeratorComments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewModeratorComments, $validArrayIndex)) { $vars['view'] = 'modcomments'; $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewModeratorListings = array_search(JApplication::stringURLSafe('mod-listings'), $segments); if ($searchViewModeratorListings !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewModeratorListings, $validArrayIndex)) { $vars['view'] = 'modlistings'; $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } if (isset($segments[0]) && $segments[0] == JApplication::stringURLSafe('subscribe')) { if (isset($segments[1]) && $segments[1] == JApplication::stringURLSafe('activate')) { $vars['task'] = 'subscribe.activate'; if (isset($segments[2])) { $vars['code'] = $segments[2]; } if (isset($segments[3])) { $vars['id'] = (int) $segments[3]; } if (isset($segments[4])) { $vars['listing_id'] = (int) $segments[4]; } return $vars; } } $searchViewSearch = array_search(JApplication::stringURLSafe('search'), $segments); if ($searchViewSearch !== false) { $validArrayIndex = array(0, 1, 2, 3); if (in_array($searchViewSearch, $validArrayIndex)) { $vars['view'] = 'search'; if (isset($segments[$searchViewSearch - 1])) { if ($segments[$searchViewSearch - 1] == JApplication::stringURLSafe('all')) { $vars['sub_cat'] = 1; if (isset($segments[$searchViewSearch - 2])) { $vars['cat_id'] = (int) $segments[$searchViewSearch - 2]; } } else { $vars['cat_id'] = (int) $segments[$searchViewSearch - 1]; } } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment]) && $previousIndexSegment > $searchViewSearch) { $vars['searchword'] = $segments[$previousIndexSegment]; $previousIndexSegment -= 1; } return $vars; } } $searchViewCategories = array_search(JApplication::stringURLSafe('categories'), $segments); if ($searchViewCategories !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewCategories, $validArrayIndex)) { $vars['view'] = 'categories'; if (isset($segments[$searchViewCategories + 1])) { $vars['id'] = (int) $segments[$searchViewCategories + 1]; } if (isset($segments[$searchViewCategories + 2])) { JUDirectoryHelperRoute::parseLayout($segments[$searchViewCategories + 2], $vars, $params); } return $vars; } } $searchViewAdvancedSearch = array_search(JApplication::stringURLSafe('advanced-search'), $segments); if ($searchViewAdvancedSearch !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewAdvancedSearch, $validArrayIndex)) { $vars['view'] = 'advsearch'; $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewCommentTree = array_search(JApplication::stringURLSafe('comment-tree'), $segments); if ($searchViewCommentTree !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewCommentTree, $validArrayIndex)) { $vars['view'] = 'commenttree'; if (isset($segments[$searchViewCommentTree + 1])) { $vars['id'] = (int) $segments[$searchViewCommentTree + 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewListings = array_search(JApplication::stringURLSafe('modal-listings'), $segments); if ($searchViewListings !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewListings, $validArrayIndex)) { $vars['view'] = 'listings'; if (isset($segments[$searchViewListings + 1])) { $vars['tmpl'] = $segments[$searchViewListings + 1]; } if (isset($segments[$searchViewListings + 2])) { $vars['function'] = $segments[$searchViewListings + 2]; } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewMaintenance = array_search(JApplication::stringURLSafe('maintenance'), $segments); if ($searchViewMaintenance !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewMaintenance, $validArrayIndex)) { $vars['view'] = 'maintenance'; $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewSearchBy = array_search(JApplication::stringURLSafe('search-by'), $segments); if ($searchViewSearchBy !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewSearchBy, $validArrayIndex)) { $vars['view'] = 'searchby'; if (isset($segments[$searchViewSearchBy + 1])) { $vars['field_id'] = (int) $segments[$searchViewSearchBy + 1]; } if (isset($segments[$searchViewSearchBy + 2])) { $vars['value'] = $segments[$searchViewSearchBy + 2]; } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewTag = array_search(JApplication::stringURLSafe('tag'), $segments); if ($searchViewTag !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewTag, $validArrayIndex)) { $vars['view'] = 'tag'; if (isset($segments[$searchViewTag + 1])) { $vars['id'] = (int) $segments[$searchViewTag + 1]; } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewTags = array_search(JApplication::stringURLSafe('tags'), $segments); if ($searchViewTags !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewTags, $validArrayIndex)) { $vars['view'] = 'tags'; $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewTopComments = array_search(JApplication::stringURLSafe('top-comments'), $segments); if ($searchViewTopComments !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewTopComments, $validArrayIndex)) { $vars['view'] = 'topcomments'; $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewTree = array_search(JApplication::stringURLSafe('tree'), $segments); if ($searchViewTree !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewTree, $validArrayIndex)) { $vars['view'] = 'tree'; $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('root')) { $rootCategory = JUDirectoryFrontHelperCategory::getRootCategory(); $vars['id'] = $rootCategory->id; } else { $vars['id'] = (int) $segments[$previousIndexSegment]; } $previousIndexSegment -= 1; } else { if ($activeMenu && isset($activeMenu->query) && isset($activeMenu->query['view']) && isset($activeMenu->query['id']) && $activeMenu->query['view'] == 'tree') { $vars['id'] = $activeMenu->query['id']; } } return $vars; } } $orderTypeTopListings = array(); $orderTypeTopListings[] = JApplication::stringURLSafe('latest-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('top-featured-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('recent-modified-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('recent-updated-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('popular-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('most-rated-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('top-rated-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('latest-rated-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('most-commented-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('latest-commented-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('recent-viewed-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('alpha-ordered-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('random-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('random-fast-listings'); $orderTypeTopListings[] = JApplication::stringURLSafe('random-featured-listings'); if (!empty($orderTypeTopListings)) { foreach ($orderTypeTopListings as $orderTypeTopListingItem) { $searchViewTopListings = array_search($orderTypeTopListingItem, $segments); if ($searchViewTopListings !== false) { break; } } if ($searchViewTopListings !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewTopListings, $validArrayIndex)) { $vars['view'] = 'toplistings'; switch ($segments[$searchViewTopListings]) { case JApplication::stringURLSafe('latest-listings'): $vars['ordertype'] = 'new'; break; case JApplication::stringURLSafe('top-featured-listings'): $vars['ordertype'] = 'featured'; break; case JApplication::stringURLSafe('recent-modified-listings'): $vars['ordertype'] = 'recent_modified'; break; case JApplication::stringURLSafe('recent-updated-listings'): $vars['ordertype'] = 'recent_updated'; break; case JApplication::stringURLSafe('popular-listings'): $vars['ordertype'] = 'popular'; break; case JApplication::stringURLSafe('most-rated-listings'): $vars['ordertype'] = 'most_rated'; break; case JApplication::stringURLSafe('top-rated-listings'): $vars['ordertype'] = 'top_rated'; break; case JApplication::stringURLSafe('latest-rated-listings'): $vars['ordertype'] = 'latest_rated'; break; case JApplication::stringURLSafe('most-commented-listings'): $vars['ordertype'] = 'most_commented'; break; case JApplication::stringURLSafe('latest-commented-listings'): $vars['ordertype'] = 'latest_commented'; break; case JApplication::stringURLSafe('recent-viewed-listings'): $vars['ordertype'] = 'recently_viewed'; break; case JApplication::stringURLSafe('alpha-ordered-listings'): $vars['ordertype'] = 'alpha_ordered'; break; case JApplication::stringURLSafe('random-listings'): $vars['ordertype'] = 'random'; break; case JApplication::stringURLSafe('random-fast-listings'): $vars['ordertype'] = 'random_fast'; break; case JApplication::stringURLSafe('random-featured-listings'): $vars['ordertype'] = 'random_featured'; break; default: $vars['ordertype'] = 'new'; break; } if (isset($segments[$searchViewTopListings - 1])) { if ($segments[$searchViewTopListings - 1] == JApplication::stringURLSafe('root')) { $rootCategory = JUDirectoryFrontHelperCategory::getRootCategory(); $vars['id'] = $rootCategory->id; } else { $vars['id'] = (int) $segments[$searchViewTopListings - 1]; } } else { if ($activeMenu && isset($activeMenu->query) && isset($activeMenu->query['view']) && isset($activeMenu->query['id']) && $activeMenu->query['view'] == 'tree') { $vars['id'] = $activeMenu->query['id']; } } if (isset($segments[$searchViewTopListings + 1])) { if ($segments[$searchViewTopListings + 1] == JApplication::stringURLSafe('all')) { $vars['all'] = 1; } } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } } $searchSefRedirectUrl = array_search(JApplication::stringURLSafe('redirect-url'), $segments); if ($searchSefRedirectUrl !== false) { $vars['task'] = 'listing.redirecturl'; if (isset($segments[$searchSefRedirectUrl - 1])) { $vars['field_id'] = (int) $segments[$searchSefRedirectUrl - 1]; } if (isset($segments[$searchSefRedirectUrl - 2])) { $vars['listing_id'] = (int) $segments[$searchSefRedirectUrl - 2]; } return $vars; } $searchSefTaskRawData = array_search(JApplication::stringURLSafe('raw-data'), $segments); if ($searchSefTaskRawData !== false) { $vars['task'] = 'rawdata'; if (isset($segments[$searchSefTaskRawData - 1])) { $vars['field_id'] = (int) $segments[$searchSefTaskRawData - 1]; } if (isset($segments[$searchSefTaskRawData - 2])) { $vars['listing_id'] = (int) $segments[$searchSefTaskRawData - 2]; } return $vars; } $searchSefCollection = array_search(JApplication::stringURLSafe('collection'), $segments); if ($searchSefCollection !== false) { if (isset($segments[$searchSefCollection + 1])) { if ($segments[$searchSefCollection + 1] == JApplication::stringURLSafe('add')) { $vars['task'] = 'collection.add'; return $vars; } } } $searchSefCollection = array_search(JApplication::stringURLSafe('collection'), $segments); if ($searchSefCollection !== false) { if (isset($segments[$searchSefCollection + 2])) { if ($segments[$searchSefCollection + 2] == JApplication::stringURLSafe('edit')) { if (isset($segments[$searchSefCollection - 1])) { $vars['user_id'] = (int) $segments[$searchSefCollection - 1]; } $vars['id'] = (int) $segments[$searchSefCollection + 1]; $vars['task'] = 'collection.edit'; return $vars; } } } $searchSefCollection = array_search(JApplication::stringURLSafe('collection'), $segments); if ($searchSefCollection !== false) { if (isset($segments[$searchSefCollection + 2])) { if ($segments[$searchSefCollection + 2] == JApplication::stringURLSafe('delete')) { $vars['cid'] = (int) $segments[$searchSefCollection + 1]; $vars['task'] = 'collections.delete'; return $vars; } } } $searchSefCollection = array_search(JApplication::stringURLSafe('collection'), $segments); if ($searchSefCollection !== false) { if (isset($segments[$searchSefCollection + 1])) { if ($segments[$searchSefCollection + 1] == JApplication::stringURLSafe('new-collection')) { $vars['id'] = 0; $vars['view'] = 'collection'; JUDirectoryHelperRoute::parseLayout($segments[$searchSefCollection + 2], $vars, $params); return $vars; } } } $searchSefCollection = array_search(JApplication::stringURLSafe('collection'), $segments); if ($searchSefCollection !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefCollection, $validArrayIndex)) { $vars['view'] = 'collection'; if (isset($segments[$searchSefCollection - 1])) { if ($segments[$searchSefCollection - 1] != 'root') { $vars['user_id'] = (int) $segments[$searchSefCollection - 1]; } } if (isset($segments[$searchSefCollection + 1])) { $vars['id'] = (int) $segments[$searchSefCollection + 1]; } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchSefClaimListing = array_search(JApplication::stringURLSafe('claim'), $segments); if ($searchSefClaimListing !== false) { $vars['view'] = 'claim'; if (isset($segments[$searchSefClaimListing - 1])) { $vars['listing_id'] = (int) $segments[$searchSefClaimListing - 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } $searchSefReportListing = array_search(JApplication::stringURLSafe('report'), $segments); if ($searchSefReportListing !== false) { $vars['view'] = 'report'; if (isset($segments[$searchSefReportListing - 1])) { $vars['listing_id'] = (int) $segments[$searchSefReportListing - 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } $searchSefRemoveCompare = array_search(JApplication::stringURLSafe('remove-compare'), $segments); if ($searchSefRemoveCompare !== false) { $vars['task'] == 'listing.removeCompare'; if (isset($segments[$searchSefRemoveCompare + 1])) { if ($segments[$searchSefRemoveCompare + 1] == JApplication::stringURLSafe('all')) { $vars['all'] = 1; return $vars; } } if (isset($segments[$searchSefRemoveCompare - 1])) { $vars['listing_id'] = (int) $segments[$searchSefRemoveCompare - 1]; return $vars; } return $vars; } $searchSefSubscribeListingForGuest = array_search(JApplication::stringURLSafe('guest-subscribe'), $segments); if ($searchSefSubscribeListingForGuest !== false) { $vars['view'] = 'subscribe'; if (isset($segments[$searchSefSubscribeListingForGuest - 1])) { $vars['listing_id'] = (int) $segments[$searchSefSubscribeListingForGuest - 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } $searchSefListAll = array_search('list-all', $segments); if ($searchSefListAll !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefListAll, $validArrayIndex)) { $vars['view'] = 'listall'; if (isset($segments[$searchSefListAll - 1])) { if ($segments[$searchSefListAll - 1] == JApplication::stringURLSafe('root')) { $rootCategory = JUDirectoryFrontHelperCategory::getRootCategory(); $vars['id'] = $rootCategory->id; } else { $vars['id'] = (int) $segments[$searchSefListAll - 1]; } } else { if ($activeMenu && isset($activeMenu->query) && isset($activeMenu->query['view']) && isset($activeMenu->query['id']) && $activeMenu->query['view'] == 'tree') { $vars['id'] = $activeMenu->query['id']; } } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchSefListAlpha = array_search(JApplication::stringURLSafe('list-alpha'), $segments); if ($searchSefListAlpha !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefListAlpha, $validArrayIndex)) { $vars['view'] = 'listalpha'; if (isset($segments[$searchSefListAlpha - 1])) { if ($segments[$searchSefListAlpha - 1] == JApplication::stringURLSafe('root')) { $rootCategory = JUDirectoryFrontHelperCategory::getRootCategory(); $vars['id'] = $rootCategory->id; } else { $vars['id'] = (int) $segments[$searchSefListAlpha - 1]; } } else { if ($activeMenu && isset($activeMenu->query) && isset($activeMenu->query['view']) && isset($activeMenu->query['id']) && $activeMenu->query['view'] == 'tree') { $vars['id'] = $activeMenu->query['id']; } } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { if ($previousIndexSegment > $searchSefListAlpha) { $vars['alpha'] = $segments[$previousIndexSegment]; } } return $vars; } } $searchSefFeatured = array_search(JApplication::stringURLSafe('featured'), $segments); if ($searchSefFeatured !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefFeatured, $validArrayIndex)) { $vars['view'] = 'featured'; if (isset($segments[$searchSefFeatured - 1])) { if ($segments[$searchSefFeatured - 1] == JApplication::stringURLSafe('root')) { $rootCategory = JUDirectoryFrontHelperCategory::getRootCategory(); $vars['id'] = $rootCategory->id; } else { $vars['id'] = (int) $segments[$searchSefFeatured - 1]; } } else { if ($activeMenu && isset($activeMenu->query) && isset($activeMenu->query['view']) && isset($activeMenu->query['id']) && $activeMenu->query['view'] == 'tree') { $vars['id'] = $activeMenu->query['id']; } } if (isset($segments[$searchSefFeatured + 1])) { if ($segments[$searchSefFeatured + 1] == JApplication::stringURLSafe('all')) { $vars['all'] = 1; } } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefCollections = array_search(JApplication::stringURLSafe('collections'), $segments); if ($searchSefCollections !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefCollections, $validArrayIndex)) { $vars['view'] = 'collections'; if (isset($segments[$searchSefCollections - 1])) { if ($segments[$searchSefCollections - 1] != JApplication::stringURLSafe('root')) { $vars['id'] = (int) $segments[$searchSefCollections - 1]; } } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefDashboard = array_search(JApplication::stringURLSafe('dashboard'), $segments); if ($searchSefDashboard !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefDashboard, $validArrayIndex)) { $vars['view'] = 'dashboard'; if (isset($segments[$searchSefDashboard - 1])) { if ($segments[$searchSefDashboard - 1] != JApplication::stringURLSafe('root')) { $vars['id'] = (int) $segments[$searchSefDashboard - 1]; } } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefUserComments = array_search(JApplication::stringURLSafe('comments'), $segments); if ($searchSefUserComments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefUserComments, $validArrayIndex)) { $vars['view'] = 'usercomments'; if (isset($segments[$searchSefUserComments - 1])) { if ($segments[$searchSefUserComments - 1] != JApplication::stringURLSafe('root')) { $vars['id'] = (int) $segments[$searchSefUserComments - 1]; } } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefUserListings = array_search(JApplication::stringURLSafe('listings'), $segments); if ($searchSefUserListings !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefUserListings, $validArrayIndex)) { $vars['view'] = 'userlistings'; if (isset($segments[$searchSefUserListings - 1])) { if ($segments[$searchSefUserListings - 1] != JApplication::stringURLSafe('root')) { $vars['id'] = (int) $segments[$searchSefUserListings - 1]; } } if (isset($segments[$searchSefUserListings + 1])) { if ($segments[$searchSefUserListings + 1] == JApplication::stringURLSafe('published')) { $vars['filter'] = 'published'; } elseif ($segments[$searchSefUserListings + 1] == JApplication::stringURLSafe('unpublished')) { $vars['filter'] = 'unpublished'; } elseif ($segments[$searchSefUserListings + 1] == JApplication::stringURLSafe('pending')) { $vars['filter'] = 'pending'; } } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefUserSubscriptions = array_search(JApplication::stringURLSafe('user-subscriptions'), $segments); if ($searchSefUserSubscriptions !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefUserSubscriptions, $validArrayIndex)) { $vars['view'] = 'usersubscriptions'; if (isset($segments[$searchSefUserSubscriptions - 1])) { if ($segments[$searchSefUserSubscriptions - 1] != JApplication::stringURLSafe('root')) { $vars['id'] = (int) $segments[$searchSefUserSubscriptions - 1]; } } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefSearchBy = array_search(JApplication::stringURLSafe('search-by'), $segments); if ($searchSefSearchBy !== false) { $validArrayIndex = array(0, 1); if (in_array($searchSefSearchBy, $validArrayIndex)) { $vars['view'] = 'searchby'; if (isset($segments[$searchSefSearchBy + 1])) { $vars['field_id'] = (int) $segments[$searchSefSearchBy + 1]; } if (isset($segments[$searchSefSearchBy + 2])) { $vars['value'] = $segments[$searchSefSearchBy + 2]; } $previousIndexSegment = $total - 1; $isPaged = JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefContact = array_search(JApplication::stringURLSafe('contact'), $segments); if ($searchSefContact !== false) { if ($searchSefContact == $indexLastSegment || $searchSefContact == $indexLastSegment - 1) { $vars['view'] = 'contact'; if (isset($segments[$searchSefContact - 1])) { $vars['listing_id'] = (int) $segments[$searchSefContact - 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefCheckIn = array_search(JApplication::stringURLSafe('checkin'), $segments); if ($searchSefCheckIn !== false) { $vars['task'] = 'forms.checkin'; if (isset($segments[$searchSefCheckIn - 1])) { $vars['id'] = (int) $segments[$searchSefCheckIn - 1]; } return $vars; } $searchSefAdd = array_search(JApplication::stringURLSafe('add'), $segments); if ($searchSefAdd !== false) { $vars['task'] = 'form.add'; if (isset($segments[$searchSefAdd - 1])) { $vars['cat_id'] = (int) $segments[$searchSefAdd - 1]; } return $vars; } $searchSefEdit = array_search(JApplication::stringURLSafe('edit'), $segments); if ($searchSefEdit !== false) { $vars['task'] = 'form.edit'; if (isset($segments[$searchSefEdit - 1])) { $vars['id'] = (int) $segments[$searchSefEdit - 1]; } return $vars; } $searchSefDelete = array_search(JApplication::stringURLSafe('delete'), $segments); if ($searchSefDelete !== false) { $vars['task'] = 'forms.delete'; if (isset($segments[$searchSefDelete - 1])) { $vars['id'] = (int) $segments[$searchSefDelete - 1]; } return $vars; } $searchNewListing = array_search(JApplication::stringURLSafe('new-listing'), $segments); if ($searchNewListing !== false) { $vars['view'] = 'form'; $vars['layout'] = 'edit'; if (isset($segments[$searchNewListing - 1])) { $vars['cat_id'] = (int) $segments[$searchNewListing - 1]; } return $vars; } $searchSefApprove = array_search(JApplication::stringURLSafe('approve'), $segments); if ($searchSefApprove !== false) { if ($searchSefApprove == $indexLastSegment) { $vars['task'] = 'modpendinglisting.edit'; $vars['approve'] = 1; } else { $vars['view'] = 'form'; $vars['layout'] = 'edit'; $vars['approve'] = 1; } if (isset($segments[$searchSefApprove - 1])) { $vars['id'] = (int) $segments[$searchSefApprove - 1]; } return $vars; } $searchSefPublish = array_search(JApplication::stringURLSafe('publish'), $segments); if ($searchSefPublish !== false) { $vars['task'] = 'forms.publish'; if (isset($segments[$searchSefPublish - 1])) { $vars['id'] = (int) $segments[$searchSefPublish - 1]; } return $vars; } $searchSefUnPublish = array_search(JApplication::stringURLSafe('unpublish'), $segments); if ($searchSefUnPublish !== false) { $vars['task'] = 'forms.unpublish'; if (isset($segments[$searchSefUnPublish - 1])) { $vars['id'] = (int) $segments[$searchSefUnPublish - 1]; } return $vars; } $searchSefSubscribe = array_search(JApplication::stringURLSafe('subscribe'), $segments); if ($searchSefSubscribe !== false) { $vars['task'] = 'subscribe.save'; if (isset($segments[$searchSefSubscribe - 1])) { $vars['listing_id'] = (int) $segments[$searchSefSubscribe - 1]; } return $vars; } $searchSefUnSubscribe = array_search(JApplication::stringURLSafe('unsubscribe'), $segments); if ($searchSefUnSubscribe !== false) { $vars['task'] = 'subscribe.remove'; if (isset($segments[$searchSefUnSubscribe + 1])) { $vars['sub_id'] = (int) $segments[$searchSefUnSubscribe + 1]; } if (isset($segments[$searchSefUnSubscribe + 2])) { $vars['code'] = $segments[$searchSefUnSubscribe + 2]; } return $vars; } $previousIndexSegment = $indexLastSegment; if (isset($segments[$previousIndexSegment])) { $isPaged = preg_match('/' . preg_quote(JApplication::stringURLSafe('page') . '-') . '[0-9]*+/', $segments[$previousIndexSegment]); if ($isPaged) { if ($indexLastSegment == 0) { if (is_object($activeMenu) && $activeMenu->component == 'com_judirectory') { $vars = $activeMenu->query; JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); return $vars; } } $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isFeed = $segments[$previousIndexSegment] == JApplication::stringURLSafe('rss') ? true : false; if ($isFeed) { $vars['format'] = 'feed'; if ($indexLastSegment == 0) { if (is_object($activeMenu) && $activeMenu->component == 'com_judirectory') { $vars = $activeMenu->query; $vars['format'] = 'feed'; return $vars; } } $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } if (!empty($segments)) { $reverseSegments = array_reverse($segments); foreach ($reverseSegments as $segmentItemKey => $segmentItem) { if (preg_match('/^\\d+\\-.+/', $segmentItem)) { $indexAlias = $indexLastSegment - $segmentItemKey; break; } } if (isset($indexAlias) && isset($segments[$indexAlias])) { if (strpos($segments[$indexAlias], '-') === false) { $itemId = (int) $segments[$indexAlias]; $itemAlias = substr($segments[$indexAlias], strlen($itemId) + 1); } else { list($itemId, $itemAlias) = explode('-', $segments[$indexAlias], 2); } if (is_numeric($itemId)) { $categoryObject = JUDirectoryHelper::getCategoryById($itemId); if (is_object($categoryObject) && isset($categoryObject->alias) && $categoryObject->alias == $itemAlias) { $vars['view'] = 'category'; $vars['id'] = $itemId; JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); return $vars; } $listingObject = JUDirectoryHelper::getListingById($itemId); if (is_object($listingObject) && isset($listingObject->alias) && $listingObject->alias == $itemAlias) { $vars['id'] = $itemId; if (isset($vars['layout'])) { if ($vars['layout'] == 'edit') { $vars['view'] = 'form'; } else { $vars['view'] = 'listing'; } } if (!isset($vars['view'])) { $vars['view'] = 'listing'; } if ($vars['view'] == 'listing') { if (isset($segments[$indexAlias + 1])) { if ($segments[$indexAlias + 1] == JApplication::stringURLSafe('print')) { $vars['print'] = 1; $vars['tmpl'] = 'component'; $vars['layout'] = 'print'; } } } JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); return $vars; } if (is_object($categoryObject) && isset($categoryObject->id) && $categoryObject->id) { $vars['view'] = 'category'; $vars['id'] = $itemId; JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); return $vars; } if (is_object($listingObject) && isset($listingObject->id) && $listingObject->id) { $vars['id'] = $itemId; if (isset($vars['layout'])) { if ($vars['layout'] == 'edit') { $vars['view'] = 'form'; } else { $vars['view'] = 'listing'; } } if (!isset($vars['view'])) { $vars['view'] = 'listing'; } if ($vars['view'] == 'listing') { if (isset($segments[$indexAlias + 1])) { if ($segments[$indexAlias + 1] == JApplication::stringURLSafe('print')) { $vars['print'] = 1; $vars['tmpl'] = 'component'; $vars['layout'] = 'print'; } elseif ($segments[$indexAlias + 1] == JApplication::stringURLSafe('changelogs')) { $vars['layout'] = 'changelogs'; } elseif ($segments[$indexAlias + 1] == JApplication::stringURLSafe('versions')) { $vars['layout'] = 'versions'; } } } JUDirectoryHelperRoute::parsePagination($vars, $segments, $params); return $vars; } } } } if (is_object($activeMenu) && $activeMenu->component == 'com_judirectory') { $vars = $activeMenu->query; } return $vars; }
public static function getListingSubmitType($listingId) { if ($listingId == 0) { return 'submit'; } $listingObject = JUDirectoryHelper::getListingById($listingId); if ($listingObject->approved == 0) { return 'submit'; } else { return 'edit'; } }
public static function canRateListing($listingId) { $listingObject = JUDirectoryHelper::getListingById($listingId); if (!is_object($listingObject)) { return false; } $params = JUDirectoryHelper::getParams(null, $listingId); if (!$params->get('enable_listing_rate', 1)) { return false; } $userCanViewListing = JUDirectoryFrontHelperPermission::userCanDoListing($listingId, true); if (!$userCanViewListing) { return false; } $ratingField = new JUDirectoryFieldCore_rating(); if (!$ratingField->canView()) { return false; } $user = JFactory::getUser(); $criteriaGroupId = JUDirectoryFrontHelperCriteria::getCriteriaGroupIdByCategoryId($listingObject->cat_id); if ($criteriaGroupId == 0 || !JUDirectoryHelper::hasMultiRating()) { $assetName = 'com_judirectory.category.' . $listingObject->cat_id; if ($user->authorise('judir.single.rate', $assetName)) { if ($user->authorise('judir.single.rate.many_times', $assetName)) { return true; } else { if ($user->get('guest')) { $session = JFactory::getSession(); if (!$session->has('judir-listing-rated-' . $listingId)) { return true; } } else { $totalVoteTimes = JUDirectoryFrontHelperRating::getTotalListingVotesOfUser($user->id, $listingId); if ($totalVoteTimes == 0) { return true; } } } } } else { $assetName = 'com_judirectory.criteriagroup.' . $criteriaGroupId; if ($user->authorise('judir.criteria.rate', $assetName)) { if ($user->authorise('judir.criteria.rate.many_times', $assetName)) { return true; } else { if ($user->get('guest')) { $session = JFactory::getSession(); if (!$session->has('judir-listing-rated-' . $listingId)) { return true; } } else { $totalVoteTimes = JUDirectoryFrontHelperRating::getTotalListingVotesOfUser($user->id, $listingId); if ($totalVoteTimes == 0) { return true; } } } } } return false; }
public function listingChangeCategory() { $app = JFactory::getApplication(); if ($app->input->get('action', '') == 'update-maincat') { $ori_cat_id = $app->input->getInt('ori_cat_id', 0); $ori_cat = JUDirectoryHelper::getCategoryById($ori_cat_id); $data['ori_field_group_id'] = 0; $data['new_field_group_id'] = 0; $data['new_field_group_name'] = ""; $data['path'] = ""; if ($ori_cat) { $data['ori_field_group_id'] = $ori_cat->fieldgroup_id; } $new_cat_id = $app->input->getInt('new_cat_id', 0); $rootCat = JUDirectoryFrontHelperCategory::getRootCategory(); $params = JUDirectoryHelper::getParams(); if ($rootCat->id == $new_cat_id && !$params->get('allow_add_listing_to_root', 0)) { return ""; } $new_cat = JUDirectoryHelper::getCategoryById($new_cat_id); if ($new_cat) { $db = JFactory::getDbo(); $query = "SELECT id, name FROM #__judirectory_fields_groups WHERE id = " . $new_cat->fieldgroup_id . " AND published = 1"; $db->setQuery($query); $fieldgroup = $db->loadObject(); if ($fieldgroup) { $data['new_field_group_id'] = $fieldgroup->id; $data['new_field_group_name'] = $fieldgroup->name; } $data['path'] = JUDirectoryHelper::generateCategoryPath($new_cat_id); } if ($data['ori_field_group_id'] != $data['new_field_group_id']) { $data['msg_field_group'] = JText::_('COM_JUDIRECTORY_CHANGE_MAIN_CATEGORY_CAUSE_CHANGE_FIELD_GROUP_WARNING'); } $listingId = $app->input->getInt('id', 0); $data['message_style'] = JText::_('COM_JUDIRECTORY_INHERIT'); if ($listingId) { $listingObject = JUDirectoryHelper::getListingById($listingId); if ($listingObject->style_id == -1) { $oldStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($listingId->cat_id); $newStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($new_cat->id); if ($oldStyleObject->template_id != $newStyleObject->template_id) { $data['msg_style'] = JText::_('COM_JUDIRECTORY_CHANGE_MAIN_CATEGORY_CAUSE_CHANGE_TEMPLATE_WARNING'); } } $newTemplateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($new_cat->id); $data['message_style'] = JText::_('COM_JUDIRECTORY_INHERIT') . ' (' . $newTemplateStyleObject->title . ' [' . $newTemplateStyleObject->template_title . ' ]' . ')'; } return json_encode($data); } elseif ($app->input->getInt('action', '') == 'insert_secondary_cat') { $cat_id_str = $app->input->get('secondary_cat_id', '', 'string'); $html = ''; if (!empty($cat_id_str)) { $cat_id_arr = explode(",", $cat_id_str); foreach ($cat_id_arr as $key => $cat_id) { $html .= "<li id=\"cat-" . $cat_id . "\"><a class=\"drag-icon\"></a><span>" . JUDirectoryHelper::generateCategoryPath($cat_id) . "</span><a href=\"#\" onclick=\"return false\" class=\"remove-secondary-cat\" ><i class=\"icon-minus fa fa-minus-circle\"></i> " . JText::_('COM_JUDIRECTORY_REMOVE') . "</a></li>"; } } return $html; } }
?> " name="listingid[]" id="listing<?php echo $i; ?> " /> <?php } ?> </td> <?php foreach ($this->model->fields_use as $field) { echo '<td>'; switch ($field->field_name) { case "title": if (!$item->main) { $main_cat_id = JUDirectoryHelper::getListingById($item->id)->cat_id; ?> <a href="<?php echo JRoute::_('index.php?option=com_judirectory&view=listcats&cat_id=' . $main_cat_id); ?> "><?php echo JUDirectoryHelper::generateCategoryPath($main_cat_id); ?> </a> > <?php } if ($item->checked_out) { echo JHtml::_('jgrid.checkedout', $i, $item->checked_out_name, $item->checked_out_time, 'listings.', $canCheckin || $user->authorise('core.manage', 'com_checkin'), 'listing'); } if ($canEdit || $canEditOwn) { ?>
public static function getFields($listing, $view = null, $includedOnlyFields = array(), $ignoredFields = array(), $additionFields = array()) { $user = JFactory::getUser(); $accessLevel = implode(',', $user->getAuthorisedViewLevels()); $date = JFactory::getDate(); $db = JFactory::getDbo(); if (is_object($listing) && !isset($listing->cat_id)) { $listing = JUDirectoryHelper::getListingById($listing->id); } if (is_numeric($listing)) { $listing = JUDirectoryHelper::getListingById($listing); } $catId = $listing->cat_id; $catObjStoreId = md5(__METHOD__ . "::catObj::{$catId}::{$accessLevel}"); if (!isset(self::$cache[$catObjStoreId])) { $query = $db->getQuery(true); $query->select('c.id, c.field_ordering_type'); $query->select('fg.id AS field_group_id, fg.field_ordering_type AS fg_field_ordering_type'); $query->from('#__judirectory_categories AS c'); $query->join('LEFT', '#__judirectory_fields_groups AS fg ON (fg.id = c.fieldgroup_id AND fg.published = 1 AND fg.access IN (' . $accessLevel . '))'); $query->where('c.id = ' . $catId); $db->setQuery($query); self::$cache[$catObjStoreId] = $db->loadObject(); } $catObj = self::$cache[$catObjStoreId]; if (empty($catObj)) { return false; } if ($catObj->field_ordering_type == 1) { $item_id = $catObj->id; $type = 'category'; $field_group_id = $catObj->field_group_id; } else { if ($catObj->fg_field_ordering_type == 1) { $item_id = $catObj->field_group_id; $type = 'fieldgroup'; $field_group_id = $catObj->field_group_id; } else { $item_id = 0; $type = ''; $field_group_id = $catObj->field_group_id; } } $fieldsStoreId = md5(__METHOD__ . "::fieldsObj::{$item_id}::{$type}::{$field_group_id}::{$view}::" . "::" . serialize($includedOnlyFields) . "::" . serialize($ignoredFields) . "::" . serialize($additionFields)); if (!isset(self::$cache[$fieldsStoreId])) { $query = $db->getQuery(true); $query->select("field.*, plg.folder"); $query->from("#__judirectory_fields AS field"); $query->join("", "#__judirectory_plugins AS plg ON (field.plugin_id = plg.id)"); if ($item_id) { $query->select("fordering.ordering"); $query->join("LEFT", "#__judirectory_fields_ordering AS fordering ON (fordering.field_id = field.id AND fordering.item_id = " . (int) $item_id . " AND fordering.type = '{$type}')"); $query->order("fordering.ordering"); } $query->join("", "#__judirectory_fields_groups AS fg ON (fg.id = field.group_id)"); $query->where('fg.access IN (' . $accessLevel . ')'); $nullDate = $db->quote($db->getNullDate()); $nowDate = $db->quote($date->toSql()); $query->where('field.published = 1'); $query->where('field.publish_up <= ' . $nowDate); $query->where('(field.publish_down = ' . $nullDate . ' OR field.publish_down > ' . $nowDate . ')'); $query->where('field.access IN (' . $accessLevel . ')'); if ($field_group_id > 1) { $query->where("(field.group_id = 1 OR field.group_id = " . (int) $field_group_id . ")"); } else { $query->where("field.group_id = 1"); } $additionFieldsStr = ""; if ($additionFields) { $additionFieldIds = $additionFieldNames = array(); foreach ($additionFields as $additionField) { if ($additionField && is_numeric($additionField)) { $additionFieldIds[$additionField] = $additionField; } elseif ($additionField) { $additionFieldNames[$additionField] = $additionField; } } if ($additionFieldIds) { $additionFieldsStr .= " OR field.id IN (" . implode(",", $additionFieldIds) . ")"; } if ($additionFieldNames) { $additionFieldsStr .= " OR field.field_name IN ('" . implode("','", $additionFieldNames) . "')"; } } $app = JFactory::getApplication(); $languageTag = JFactory::getLanguage()->getTag(); if ($app->getLanguageFilter()) { $query->where("(field.language IN (" . $db->quote($languageTag) . "," . $db->quote('*') . "," . $db->quote('') . ")" . $additionFieldsStr . ")"); } if ($view == 1) { $query->where("(field.list_view = 1" . $additionFieldsStr . ")"); } elseif ($view == 2) { $query->where("(field.details_view = 1" . $additionFieldsStr . ")"); } if ($ignoredFields) { $ignoreFieldIds = $ignoreFieldNames = array(); foreach ($ignoredFields as $ignoredField) { if ($ignoredField && is_numeric($ignoredField)) { $ignoreFieldIds[$ignoredField] = $ignoredField; } elseif ($ignoredField) { $ignoreFieldNames[$ignoredField] = $ignoredField; } } if ($ignoreFieldIds) { $query->where("field.id NOT IN (" . implode(",", $ignoreFieldIds) . ")"); } if ($ignoreFieldNames) { $query->where("field.field_name NOT IN ('" . implode("','", $ignoreFieldNames) . "')"); } } if ($includedOnlyFields) { $includedFieldIds = $includedFieldNames = array(); foreach ($includedOnlyFields as $includedField) { if ($includedField && is_numeric($includedField)) { $includedFieldIds[$includedField] = $includedField; } elseif ($includedField) { $includedFieldNames[$includedField] = $includedField; } } if ($includedFieldIds) { $query->where("field.id IN (" . implode(",", $includedFieldIds) . ")"); } if ($includedFieldNames) { $query->where("field.field_name IN ('" . implode("','", $includedFieldNames) . "')"); } } $query->group('field.id'); $query->order("fg.ordering, field.ordering"); $db->setQuery($query); $fields = $db->loadObjectList(); $newFields = array(); foreach ($fields as $key => $field) { if (isset($field->ordering) && is_null($field->ordering)) { $newFields[] = $field; unset($fields[$key]); } } if (!empty($newFields)) { $fields = array_merge($fields, $newFields); } self::$cache[$fieldsStoreId] = $fields; } $fields = self::$cache[$fieldsStoreId]; if (!$fields) { return false; } $fieldObjectList = array(); if (count($fields)) { foreach ($fields as $_field) { $field = clone $_field; if ($field->field_name != "") { $newKey = $field->field_name; } else { $newKey = $field->id; } $fieldObjectList[$newKey] = self::getField($field, $listing); unset($field); } } return $fieldObjectList; }
public function prepareDataToImport($data, $importType, $config = array()) { $defaultData = array('cat_id' => $data['main_cat']); $isInsert = $importType == 1 ? true : false; if ($isInsert) { $defaultData['publish_up'] = JFactory::getDate()->toSql(); if ($config['force_publish'] != "") { $pulishFieldId = JUDirectoryFrontHelperField::getField('published')->id; $data[$pulishFieldId] = $config['force_publish']; } if (!empty($config['created_by']) && $config['created_by'] > 0) { $defaultData['created_by'] = $config['created_by']; } $defaultData['language'] = '*'; $defaultData['access'] = 1; $defaultData['style_id'] = -1; $defaultData['layout'] = -1; $defaultData['approved'] = 1; $params = array('display_params' => array('show_comment' => -2, 'fields' => array('title' => array('detail_view' => -2), 'created' => array('detail_view' => -2), 'author' => array('detail_view' => -2), 'cat_id' => array('detail_view' => -2), 'rating' => array('detzail_view' => -2)))); $defaultData['params'] = json_encode($params); } $aliasFieldId = JUDirectoryFrontHelperField::getField('alias')->id; $titleFieldId = JUDirectoryFrontHelperField::getField('title')->id; $newTitle = isset($data[$titleFieldId]) && $data[$titleFieldId] ? $data[$titleFieldId] : ""; $newAlias = isset($data[$aliasFieldId]) && $data[$aliasFieldId] ? $data[$aliasFieldId] : ""; if (!$newAlias) { if ($data['id']) { if ($newTitle && $config['rebuild_alias']) { $data['alias'] = JApplication::stringURLSafe($newTitle); } else { $listing = JUDirectoryHelper::getListingById($data['id']); $data['alias'] = $listing->alias; } } else { $data['alias'] = JApplication::stringURLSafe($newTitle); } } else { $data['alias'] = $newAlias; } if (!$newTitle) { $listing = JUDirectoryHelper::getListingById($data['id']); $data['title'] = $listing->title; } else { $data['title'] = $newTitle; } $this->titleIncrement($data['main_cat'], $data['id'], $defaultData['alias']); $data[$titleFieldId] = $data['title']; $data[$aliasFieldId] = $data['alias']; $related_listings = !empty($data['related_listings']) ? explode(',', $data['related_listings']) : array(); $fieldsData = array(); foreach ($data as $key => $value) { if (is_numeric($key)) { $fieldsData[$key] = $value; } elseif (is_string($key) && $key != 'related_listings') { $defaultData[$key] = $value; } } $postData = array('main_cat' => $data['main_cat'], 'data' => $defaultData, 'fieldsData' => $fieldsData, 'related_listings' => $related_listings); return $postData; }