public function _buildWhere() { $app = JFactory::getApplication(); $where = ''; $category = $this->getState('filter.category'); if (is_numeric($category) && $category != 0) { $catlist = ''; $cats = DJClassifiedsCategory::getSubCatIemsCount((int) $category); $catlist = (int) $category; foreach ($cats as $c) { $catlist .= ',' . $c->id; } $where = ' AND i.cat_id IN (' . $catlist . ') '; } $search = $this->getState('filter.search'); if (!empty($search)) { $db = JFactory::getDBO(); $search = $db->Quote('%' . $db->escape($search, true) . '%'); $where .= " AND (i.name LIKE " . $search . " OR u.name LIKE " . $search . " OR u.email LIKE " . $search . " )"; } $published = $this->getState('filter.published'); if (is_numeric($published)) { $where .= ' AND i.published = ' . (int) $published; } $active = $this->getState('filter.active'); if (is_numeric($active)) { if ($active) { $where .= ' AND i.date_start <= NOW() AND i.date_exp >= NOW() '; } else { $where .= ' AND (i.date_start >= NOW() OR i.date_exp <= NOW()) '; } } return $where; }
function display($tpl = null) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $Itemid = JRequest::getVar('Itemid', 0, 'int'); //$document->link = JRoute::_(WeblinksHelperRoute::getCategoryRoute(JRequest::getVar('id', null, '', 'int'))); JRequest::setVar('limit', $app->getCfg('feed_limit')); $siteEmail = $app->getCfg('mailfrom'); $fromName = $app->getCfg('fromname'); $document->editor = $fromName; $document->editorEmail = $siteEmail; // Get some data from the model $model = $this->getModel(); $cat_id = JRequest::getVar('cid', 0, '', 'int'); $catlist = ''; $maincat = ''; if ($cat_id > 0) { $main_cat = $model->getMainCat($cat_id); $document->title = $main_cat->name; $cats = DJClassifiedsCategory::getSubCatIemsCount($cat_id, 1); $catlist = $cat_id; foreach ($cats as $c) { $catlist .= ',' . $c->id; } } $items = $model->getItems($catlist); foreach ($items as $item) { // strip html from feed item title $title = $this->escape($item->name); $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8'); // url link to article //$link = JRoute::_('index.php?option=com_djclassifieds&view=item&cid='.$item->cat_id.'&id='.$item->id.'&Itemid='.$Itemid); if (!$item->alias) { $item->alias = DJClassifiedsSEO::getAliasName($item->name); } if (!$item->c_alias) { $item->c_alias = DJClassifiedsSEO::getAliasName($item->c_name); } $link = JRoute::_(DJClassifiedsSEO::getItemRoute($item->id . ':' . $item->alias, $item->cat_id . ':' . $item->c_alias)); //echo $link;die(); // strip html from feed item description text $description = $item->intro_desc; $date = $item->date_start ? date('r', strtotime($item->date_start)) : ''; if ($item->image_url != '') { $images = explode(';', $item->image_url); $description .= '<img align="right" src="' . JURI::base() . '/components/com_djclassifieds/images/' . $images[0] . '.ths.jpg" />'; } // load individual item creator class $feeditem = new JFeedItem(); $feeditem->title = $title; $feeditem->link = $link; $feeditem->description = $description; $feeditem->date = $date; $feeditem->category = $item->c_name; // loads item info into rss array $document->addItem($feeditem); } }
function display($tpl = null) { JHTML::_('behavior.modal'); $document = JFactory::getDocument(); $par = JComponentHelper::getParams('com_djclassifieds'); $app = JFactory::getApplication(); $user = JFactory::getUser(); $model = $this->getModel(); $cat_id = JRequest::getVar('cid', 0, '', 'int'); $uid = JRequest::getVar('uid', 0, '', 'int'); $se = JRequest::getVar('se', 0, '', 'int'); $reset = JRequest::getVar('reset', 0, '', 'int'); $layout = JRequest::getVar('layout', ''); $order = JRequest::getCmd('order', $par->get('items_ordering', 'date_e')); $ord_t = JRequest::getCmd('ord_t', $par->get('items_ordering_dir', 'desc')); $theme = $par->get('theme', 'default'); if ($layout == 'favourites') { if ($user->id == '0') { $uri = JFactory::getURI(); $app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('COM_DJCLASSIFIEDS_PLEASE_LOGIN')); } JRequest::setVar('fav', '1'); } if ($reset) { $items = $model->resetSearchFilters(); } $catlist = ''; if ($cat_id > 0) { $cats = DJClassifiedsCategory::getSubCatIemsCount($cat_id, 1, $par->get('subcats_ordering', 'ord'), $par->get('subcats_hide_empty', 0)); $catlist = $cat_id; foreach ($cats as $c) { $catlist .= ',' . $c->id; } } else { $cats = DJClassifiedsCategory::getCatAllItemsCount(1, $par->get('subcats_ordering', 'ord'), $par->get('subcats_hide_empty', 0)); } $subcats = ''; $cat_images = ''; foreach ($cats as $c) { if ($c->parent_id == $cat_id) { $subcats .= $c->id . ','; } } if ($subcats) { $subcats = substr($subcats, 0, -1); $cat_images = $model->getCatImages($subcats); } $items = $model->getItems($catlist); $countitems = $model->getCountItems($catlist); $menus = $app->getMenu('site'); $m_active = $menus->getActive(); $cat_menu_path = array(); $cid_menu = 0; if ($m_active) { if (strstr($m_active->link, 'com_djclassifieds') && strstr($m_active->link, 'items')) { if (isset($m_active->query['cid'])) { $cid_menu = $m_active->query['cid']; if ($cid_menu > 0) { $cat_menu_path = DJClassifiedsCategory::getParentPath(1, $cid_menu); } } } } if ($uid > 0 || $se || $order != $par->get('items_ordering', 'date_e') || $ord_t != $par->get('items_ordering_dir', 'desc')) { $document->setMetaData('robots', 'NOINDEX, FOLLOW'); } $cat_id = JRequest::getVar('cid', 0, '', 'int'); $main_cat = ''; if ($cat_id > 0) { $main_cat = $model->getMainCat($cat_id); if ($main_cat->metakey != '') { $document->setMetaData('keywords', $main_cat->metakey); } else { if ($m_active) { if ($m_active->params->get('menu-meta_description')) { $document->setMetaData('keywords', $m_active->params->get('menu-meta_description')); } } } if ($main_cat->metadesc != '') { $document->setDescription($main_cat->metadesc); } else { if ($m_active) { if ($m_active->params->get('menu-meta_keywords')) { $document->setDescription($m_active->params->get('menu-meta_keywords')); } } } $cat_path = array(); $pathway = $app->getPathway(); if ($main_cat->parent_id == 0) { if ($cid_menu != $cat_id) { $pathway->addItem($main_cat->name); } $cat_path[] = $main_cat; } else { $cat_path = DJClassifiedsCategory::getParentPath(1, $main_cat->id); for ($c = count($cat_path); $c > 0; $c--) { $to_b = 1; if (count($cat_menu_path)) { foreach ($cat_menu_path as $cm) { if ($cm->id == $cat_path[$c - 1]->id) { $to_b = 0; break; } } } if ($to_b) { $pathway->addItem($cat_path[$c - 1]->name, DJClassifiedsSEO::getCategoryRoute($cat_path[$c - 1]->id . ':' . $cat_path[$c - 1]->alias)); } } } $cat_theme = ''; foreach ($cat_path as $cp) { if ($cp->theme) { $cat_theme = $cp->theme; } } DJClassifiedsTheme::includeCSSfiles($cat_theme); if ($cat_theme) { $this->_addPath('template', JPATH_COMPONENT . '/themes/' . $cat_theme . '/views/items'); $theme = $cat_theme; } $c_title = $document->getTitle(); $cat_name = $main_cat->name; $seo_cat_path = ''; $seo_title_separator = $par->get('seo_title_separator', ' - '); foreach ($cat_path as $cp) { if ($seo_cat_path) { $seo_cat_path .= $seo_title_separator; } $seo_cat_path .= $cp->name; } $seo_title_from = array('|', '<default_title>', '<category_name>', '<category_path>'); $seo_title_to = array($seo_title_separator, $c_title, $cat_name, $seo_cat_path); $seo_title = str_ireplace($seo_title_from, $seo_title_to, $par->get('seo_title_items', '<category_path>|<default_title>')); $document->setTitle($seo_title); } else { if ($se && isset($_GET['se_cats'])) { $se_cat_id = end($_GET['se_cats']); if ($se_cat_id == '' && count($_GET['se_cats']) > 2) { $se_cat_id = $_GET['se_cats'][count($_GET['se_cats']) - 2]; } $se_cat_id = str_ireplace('p', '', $se_cat_id); if ($se_cat_id > 0) { $main_cat = $model->getMainCat($se_cat_id); } } } $re = JRequest::getVar('re', 0, '', 'int'); $reg_id = 0; if (isset($_GET['se_regs'])) { if (count($_GET['se_regs']) > 1) { $main_reg = ''; } else { $reg_id = end($_GET['se_regs']); if ($reg_id == '' && count($_GET['se_regs']) > 2) { $reg_id = $_GET['se_regs'][count($_GET['se_regs']) - 2]; } $reg_id = (int) $reg_id; if ($reg_id) { $main_reg = $model->getMainRegions($reg_id); } else { $main_reg = ''; } } } if ($uid > 0) { $u_name = $model->getUserName($uid); $this->assignRef('u_name', $u_name); } if ($par->get('show_types', '0')) { $types = $model->getTypes(); $this->assignRef('types', $types); } $limit = JRequest::getVar('limit', $par->get('limit_djitem_show'), '', 'int'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $pagination = new JPagination($countitems, $limitstart, $limit); // $main_name = $model->makePathway($cat_list); if ($par->get('rss_feed', 1) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } $custom_fields = $model->getCustomFields(); $this->assignRef('cats', $cats); $this->assignRef('cat_path', $cat_path); $this->assignRef('cat_images', $cat_images); $this->assignRef('items', $items); $this->assignRef('custom_fields', $custom_fields); $this->assignRef('countitems', $countitems); $this->assignRef('main_cat', $main_cat); $this->assignRef('main_reg', $main_reg); $this->assignRef('pagination', $pagination); $this->assignRef('theme', $theme); parent::display('cat'); parent::display($tpl); }
function display($tpl = null) { JHTML::_('behavior.modal'); $document = JFactory::getDocument(); $par = JComponentHelper::getParams('com_djclassifieds'); $app = JFactory::getApplication(); $user = JFactory::getUser(); $model = $this->getModel(); $dispatcher = JDispatcher::getInstance(); $config = JFactory::getConfig(); $cat_id = JRequest::getVar('cid', 0, '', 'int'); $uid = JRequest::getVar('uid', 0, '', 'int'); $se = JRequest::getVar('se', 0, '', 'int'); $reset = JRequest::getVar('reset', 0, '', 'int'); $layout = JRequest::getVar('layout', ''); $order = JRequest::getCmd('order', $par->get('items_ordering', 'date_e')); $ord_t = JRequest::getCmd('ord_t', $par->get('items_ordering_dir', 'desc')); $theme = $par->get('theme', 'default'); if ($layout == 'favourites') { if ($user->id == '0') { $uri = JFactory::getURI(); $app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('COM_DJCLASSIFIEDS_PLEASE_LOGIN')); } JRequest::setVar('fav', '1'); } if ($reset) { $items = $model->resetSearchFilters(); } $catlist = ''; if ($cat_id > 0) { $cats = DJClassifiedsCategory::getSubCatIemsCount($cat_id, 1, $par->get('subcats_ordering', 'ord'), $par->get('subcats_hide_empty', 0)); $catlist = $cat_id; foreach ($cats as $c) { $catlist .= ',' . $c->id; } } else { $cats = DJClassifiedsCategory::getCatAllItemsCount(1, $par->get('subcats_ordering', 'ord'), $par->get('subcats_hide_empty', 0)); } $subcats = ''; $cat_images = ''; foreach ($cats as $c) { if ($c->parent_id == $cat_id) { $subcats .= $c->id . ','; } } if ($subcats) { $subcats = substr($subcats, 0, -1); $cat_images = $model->getCatImages($subcats); } $items = $model->getItems($catlist); $countitems = $model->getCountItems($catlist); $menus = $app->getMenu('site'); $m_active = $menus->getActive(); $cat_menu_path = array(); $cid_menu = 0; if ($m_active) { if (strstr($m_active->link, 'com_djclassifieds') && strstr($m_active->link, 'items')) { if (isset($m_active->query['cid'])) { $cid_menu = $m_active->query['cid']; if ($cid_menu > 0) { $cat_menu_path = DJClassifiedsCategory::getParentPath(1, $cid_menu); } } } } if ($uid > 0 || $se || $order != $par->get('items_ordering', 'date_e') || $ord_t != $par->get('items_ordering_dir', 'desc')) { $document->setMetaData('robots', 'NOINDEX, FOLLOW'); } $warning18 = ''; $cat_id = JRequest::getVar('cid', 0, '', 'int'); $main_cat = ''; if ($cat_id > 0) { $main_cat = $model->getMainCat($cat_id); if (!$main_cat) { DJClassifiedsTheme::djAccessRestriction('category'); } if ($main_cat->metakey != '') { $document->setMetaData('keywords', $main_cat->metakey); } else { if ($m_active) { if ($m_active->params->get('menu-meta_keywords')) { $document->setMetaData('keywords', $m_active->params->get('menu-meta_keywords')); } } } if ($main_cat->metadesc != '') { $document->setDescription($main_cat->metadesc); } else { if ($m_active) { if ($m_active->params->get('menu-meta_description')) { $document->setDescription($m_active->params->get('menu-meta_description')); } } } $cat_path = array(); $pathway = $app->getPathway(); if ($main_cat->parent_id == 0) { if ($cid_menu != $cat_id) { $pathway->addItem($main_cat->name); } $cat_path[] = $main_cat; } else { $cat_path = DJClassifiedsCategory::getParentPath(1, $main_cat->id); for ($c = count($cat_path); $c > 0; $c--) { $to_b = 1; if (count($cat_menu_path)) { foreach ($cat_menu_path as $cm) { if ($cm->id == $cat_path[$c - 1]->id) { $to_b = 0; break; } } } if ($to_b) { $pathway->addItem($cat_path[$c - 1]->name, DJClassifiedsSEO::getCategoryRoute($cat_path[$c - 1]->id . ':' . $cat_path[$c - 1]->alias)); } } } $cat_theme = ''; foreach ($cat_path as $cp) { if ($cp->theme) { $cat_theme = $cp->theme; } if ($cp->restriction_18) { $warning18 = 1; } } DJClassifiedsTheme::includeCSSfiles($cat_theme); if ($cat_theme) { $this->_addPath('template', JPATH_COMPONENT . '/themes/' . $cat_theme . '/views/items'); $theme = $cat_theme; } $c_title = $document->getTitle(); $cat_name = $main_cat->name; $seo_cat_path = ''; $seo_title_separator = $par->get('seo_title_separator', ' - '); foreach ($cat_path as $cp) { if ($seo_cat_path) { $seo_cat_path .= $seo_title_separator; } $seo_cat_path .= $cp->name; } $seo_title_from = array('|', '<default_title>', '<category_name>', '<category_path>'); $seo_title_to = array($seo_title_separator, $c_title, $cat_name, $seo_cat_path); $seo_title = str_ireplace($seo_title_from, $seo_title_to, $par->get('seo_title_items', '<category_path>|<default_title>')); $document->setTitle($seo_title); } else { if ($se && isset($_GET['se_cats'])) { if (is_array($_GET['se_cats'])) { $se_cat_id = end($_GET['se_cats']); if ($se_cat_id == '' && count($_GET['se_cats']) > 2) { $se_cat_id = $_GET['se_cats'][count($_GET['se_cats']) - 2]; } } else { $se_cat_ids = explode(',', JRequest::getVar('se_cats')); $se_cat_id = end($se_cat_ids); } $se_cat_id = (int) str_ireplace('p', '', $se_cat_id); if ($se_cat_id > 0) { $main_cat = $model->getMainCat($se_cat_id); } } } $re = JRequest::getVar('re', 0, '', 'int'); $reg_id = 0; if (isset($_GET['se_regs'])) { if (is_array($_GET['se_regs'])) { $reg_id = end($_GET['se_regs']); if ($reg_id == '' && count($_GET['se_regs']) > 2) { $reg_id = $_GET['se_regs'][count($_GET['se_regs']) - 2]; } } else { $reg_ids = explode(',', JRequest::getVar('se_regs')); $reg_id = end($reg_ids); } $reg_id = (int) $reg_id; } if ($reg_id) { $main_reg = $model->getMainRegions($reg_id); } else { $main_reg = ''; } $se_results_link = JRoute::_(DJClassifiedsSEO::getCategoryRoute('0:all')); if ($config->get('sef')) { $se_results_link .= '?se=1&re=1&se_regs='; } else { $se_results_link .= '&se=1&re=1&se_regs='; } if ($uid > 0) { $u_name = $model->getUserName($uid); $this->assignRef('u_name', $u_name); } if ($par->get('show_types', '0')) { $types = $model->getTypes(); $this->assignRef('types', $types); } $limit = JRequest::getVar('limit', $par->get('limit_djitem_show'), '', 'int'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $pagination = new JPagination($countitems, $limitstart, $limit); // $main_name = $model->makePathway($cat_list); if ($par->get('rss_feed', 1) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } if (!isset($_COOKIE["djcf_warning18"])) { $cats_all = DJClassifiedsCategory::getCategories(); foreach ($items as $item) { if (isset($cats_all[$item->cat_id])) { if ($cats_all[$item->cat_id]->restriction_18) { $warning18 = 1; break; } } } } if ($warning18 && !isset($_COOKIE["djcf_warning18"])) { $warning18_link = ''; if ($par->get('restriction_18_art_id', 0)) { require_once JPATH_SITE . '/components/com_content/helpers/route.php'; $terms_article = $model->getTermsLink($par->get('restriction_18_art_id', 0)); if ($terms_article) { $slug = $terms_article->id . ':' . $terms_article->alias; $cslug = $terms_article->catid . ':' . $terms_article->c_alias; $warning18_link = ContentHelperRoute::getArticleRoute($slug, $cslug); if ($par->get('restriction_18_art', 0) == 2) { $warning18_link .= '&tmpl=component'; } $warning18_link = JRoute::_($warning18_link); } } $this->assignRef('terms_link', $warning18_link); $this->assignRef('theme', $theme); parent::display('terms'); } else { if ($cat_id > 0) { $correct_link = DJClassifiedsSEO::getCategoryRoute($main_cat->id . ':' . $main_cat->alias); $document->setMetaData('canonical', JRoute::_($correct_link)); } /* plugins */ if ($layout == 'blog') { $event_view = 'items.blog'; } else { $event_view = 'items.table'; } JPluginHelper::importPlugin('djclassifieds'); foreach ($items as $item) { $results = $dispatcher->trigger('onPrepareItemDescription', array(&$item, &$par, 'items')); $item->event = new stdClass(); $resultsAfterTitle = $dispatcher->trigger('onAfterDJClassifiedsDisplayTitle', array(&$item, &$par, $event_view)); $item->event->afterDJClassifiedsDisplayTitle = trim(implode("\n", $resultsAfterTitle)); $resultsBeforeContent = $dispatcher->trigger('onBeforeDJClassifiedsDisplayContent', array(&$item, &$par, $event_view)); $item->event->beforeDJClassifiedsDisplayContent = trim(implode("\n", $resultsBeforeContent)); $resultsAfterContent = $dispatcher->trigger('onAfterDJClassifiedsDisplayContent', array(&$item, &$par, $event_view)); $item->event->afterDJClassifiedsDisplayContent = trim(implode("\n", $resultsAfterContent)); } if (!$tpl && $layout != 'blog') { $itemid = JRequest::getVar('Itemid', ''); $menu_tpl = -1; if ($itemid) { $menu = $app->getMenu('site'); $menu_item = $menu->getItem($itemid); if ($menu_item) { $menu_tpl = $menu_item->params->get('table_type', '-1'); } } if ($menu_tpl != -1) { if ($menu_tpl != 'classic') { $tpl = $menu_tpl; } } else { if ($menu_tpl == -1 && $par->get('table_type', '')) { $tpl = $par->get('table_type', ''); } } } $custom_fields = $model->getCustomFields(); $this->assignRef('cats', $cats); $this->assignRef('cat_path', $cat_path); $this->assignRef('cat_images', $cat_images); $this->assignRef('items', $items); $this->assignRef('custom_fields', $custom_fields); $this->assignRef('countitems', $countitems); $this->assignRef('main_cat', $main_cat); $this->assignRef('main_reg', $main_reg); $this->assignRef('se_results_link', $se_results_link); $this->assignRef('pagination', $pagination); $this->assignRef('theme', $theme); parent::display('cat'); parent::display($tpl); } }
*/ defined('_JEXEC') or die('Restricted access'); if (!defined("DS")) { define('DS', DIRECTORY_SEPARATOR); } require_once dirname(__FILE__) . DS . 'helper.php'; require_once JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_djclassifieds' . DS . 'lib' . DS . 'djcategory.php'; require_once JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_djclassifieds' . DS . 'lib' . DS . 'djseo.php'; require_once JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_djclassifieds' . DS . 'lib' . DS . 'djtheme.php'; $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); if (JRequest::getVar('option') != 'com_djclassifieds') { DJClassifiedsTheme::includeCSSfiles(); } if ($params->get('cat_id', 0) > 0) { $cats = DJClassifiedsCategory::getSubCatIemsCount($params->get('cat_id', 0), 1, 'c.name'); } else { $cats = DJClassifiedsCategory::getCatAllItemsCount(1, 'c.name'); } // echo '<pre>';print_r($cats);die(); $cat_images = ''; if ($params->get('cattree_img', 0)) { $cat_images = modDjClassifiedsCatTree::getCatImages(); } require JModuleHelper::getLayoutPath('mod_djclassifieds_cattree'); ?>