Exemplo n.º 1
0
 function getCategories()
 {
     $orderCol = $this->state->get('list.ordering');
     $orderDirn = $this->state->get('list.direction');
     //echo $orderCol.' '.$orderDirn.'<br /><br />';
     if (empty($this->_categories)) {
         if ($this->getState('filter.category') != '') {
             if ($this->getState('filter.category') == -1) {
                 $cat_f = 0;
             } else {
                 $cat_f = $this->getState('filter.category');
             }
             $db = JFactory::getDBO();
             $query = "SELECT c.*, cc.name as parent_name FROM #__djcf_categories c " . "LEFT JOIN #__djcf_categories cc ON c.parent_id=cc.id " . "WHERE c.parent_id=" . $cat_f . " ORDER BY c." . $orderCol . ' ' . $orderDirn;
             $db->setQuery($query);
             $this->_categories = $db->loadObjectList();
         } else {
             if ($orderCol == 'ordering') {
                 $orderCol = 'ord';
             }
             $this->_categories = DJClassifiedsCategory::getCatAll(0, $orderCol, $orderDirn);
         }
     }
     return $this->_categories;
 }
 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);
     }
 }
Exemplo n.º 4
0
 protected function getInput()
 {
     $attr = '';
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     $attr .= (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->element['multiple'] == 'true' ? ' multiple="multiple"' : '';
     $default_name = $this->element['default_name'] ? '- ' . JText::_($this->element['default_name']) . ' -' : null;
     $optionss = array();
     $optionss = DJClassifiedsCategory::getCatSelect();
     //$main_tab = array();
     //$main_tab[0]= JHTML::_('select.option', '0', JText::_('MOD_DJCLASSIFIEDS_ITEMS_ALL_CATEGORIES'));
     //$options = array();
     //$options = array_merge_recursive ($main_tab, $optionss);
     $html = JHTML::_('select.genericlist', $optionss, $this->name, trim($attr), 'value', 'text', $this->value);
     return $html;
 }
Exemplo n.º 5
0
 function display($tpl = null)
 {
     $document = JFactory::getDocument();
     //$par = &JComponentHelper::getParams( 'com_djclassifieds' );
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $par = $model->getParams();
     $cats = DJClassifiedsCategory::getCatAllItemsCount(1, 'c.name');
     //	echo '<pre>';print_r($cats);die();
     $cat_images = '';
     if ($par->get('cattree_img', 0)) {
         $cat_images = $model->getCatImages();
     }
     $this->assignRef('cats', $cats);
     $this->assignRef('cat_images', $cat_images);
     $this->assignRef('par', $par);
     parent::display($tpl);
 }
Exemplo n.º 6
0
 public static function getCategoryRoute($catid)
 {
     $needles = array('items' => array((int) $catid));
     //Create the link
     $link = 'index.php?option=com_djclassifieds&view=items';
     if ((int) $catid >= 0) {
         $cat_path = DJClassifiedsCategory::getSEOParentPath((int) $catid);
         if ($cat_path) {
             $path = $cat_path;
             $path[] = '0:all';
             $needles['items'] = $path;
             $link .= '&cid=' . $catid;
         }
     }
     if ($item = self::_findItem($needles)) {
         $link .= '&Itemid=' . $item;
     }
     return $link;
 }
Exemplo n.º 7
0
 function getCategories()
 {
     if (empty($this->_categories)) {
         if ($this->getState('filter.category') != '') {
             if ($this->getState('filter.category') == -1) {
                 $cat_f = 0;
             } else {
                 $cat_f = $this->getState('filter.category');
             }
             $db = JFactory::getDBO();
             $query = "SELECT c.*, cc.name as parent_name FROM #__djcf_categories c " . "LEFT JOIN #__djcf_categories cc ON c.parent_id=cc.id " . "WHERE c.parent_id=" . $cat_f . " ORDER BY c.ordering";
             $db->setQuery($query);
             $this->_categories = $db->loadObjectList();
         } else {
             $this->_categories = DJClassifiedsCategory::getCatAll();
         }
     }
     return $this->_categories;
 }
Exemplo n.º 8
0
 protected function getInput()
 {
     $language = JFactory::getLanguage();
     $c_lang = $language->getTag();
     if ($c_lang == 'pl-PL' || $c_lang == 'en-GB') {
         $language->load('com_djclassifieds', JPATH_SITE . '/components/com_djclassifieds', null, true);
     } else {
         $language->load('com_djclassifieds', JPATH_SITE, null, true);
     }
     $attr = '';
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     $attr .= (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->element['multiple'] == 'true' ? ' multiple="multiple"' : '';
     $default_name = $this->element['default_name'] ? '- ' . JText::_($this->element['default_name']) . ' -' : null;
     $optionss = array();
     $optionss = DJClassifiedsCategory::getCatSelect();
     $main_tab = array();
     $main_tab[0] = JHTML::_('select.option', '0', JText::_('COM_DJCLASSIFIEDS_ALL_CATEGORIES'));
     $options = array();
     $options = array_merge_recursive($main_tab, $optionss);
     $html = JHTML::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value);
     return $html;
 }
Exemplo n.º 9
0
 static function getItems($params)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $date_time = JFactory::getDate();
     $date_exp = $date_time->toSQL();
     $ord = "i.date_start DESC";
     if ($params->get('items_ord') == 1) {
         $ord = "i.display DESC";
     } else {
         if ($params->get('items_ord') == 2) {
             $ord = "rand()";
         }
     }
     if ($params->get('follow_search', 1) == 1 && JRequest::getInt('se', 0) != 0) {
         $where = '';
         $search = '';
         $search_fields = '';
         $cat_id = 0;
         $reg_id = 0;
         $search_radius_v = '';
         $search_radius_h = '';
         if (JRequest::getVar('search', JText::_('COM_DJCLASSIFIEDS_SEARCH'), '', 'string') != JText::_('COM_DJCLASSIFIEDS_SEARCH')) {
             $search_word = $db->Quote('%' . $db->escape(JRequest::getVar('search', '', '', 'string'), true) . '%');
             $search = " AND (CONCAT(i.name,i.intro_desc,i.description) LIKE " . $search_word . " OR c.name LIKE " . $search_word . " OR r.name LIKE " . $search_word . " ) ";
         }
         if (isset($_GET['se_cats'])) {
             $cat_id = end($_GET['se_cats']);
             if ($cat_id == '' && count($_GET['se_cats']) > 2) {
                 $cat_id = $_GET['se_cats'][count($_GET['se_cats']) - 2];
             }
         }
         $cat_id = str_ireplace('p', '', $cat_id);
         if ($cat_id > 0) {
             $cats = DJClassifiedsCategory::getSubCat($cat_id, 1);
             $catlist = $cat_id;
             foreach ($cats as $c) {
                 $catlist .= ',' . $c->id;
             }
             $search .= ' AND i.cat_id IN (' . $catlist . ') ';
             $search_fields = self::getSearchFields();
         }
         if (isset($_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];
             }
             $reg_id = (int) $reg_id;
         }
         if ($reg_id > 0) {
             $regs = DJClassifiedsRegion::getSubReg($reg_id, 1);
             $reglist = $reg_id;
             foreach ($regs as $r) {
                 $reglist .= ',' . $r->id;
             }
             $search .= ' AND i.region_id IN (' . $reglist . ') ';
         }
         $se_price_from = JRequest::getInt('se_price_f', '');
         $se_price_to = JRequest::getInt('se_price_t', '');
         if ($se_price_from) {
             $search .= " AND ABS(i.price) >= " . $se_price_from . " ";
         }
         if ($se_price_to && $se_price_to > $se_price_from) {
             $search .= " AND ABS(i.price) <= " . $se_price_to . " ";
         }
         $type_id = JRequest::getInt('se_type_id', '0');
         if ($type_id > 0) {
             $where .= " AND i.type_id=" . $type_id . " ";
         }
         $days_l = JRequest::getInt('days_l', '0');
         if ($days_l > 0) {
             $date_limit = date("Y-m-d H:i:s", mktime(date("H"), date("i"), date("s"), date("m"), date("d") - $days_l, date("Y")));
             $where .= " AND i.date_start >= '" . $date_limit . "' ";
         }
         $only_img = JRequest::getInt('se_only_img', 0);
         if ($only_img == 1) {
             $search .= " AND i.image_url!='' ";
         }
         $only_video = JRequest::getInt('se_only_video', 0);
         if ($only_video == 1) {
             $search .= " AND i.video!='' ";
         }
         $postcode = JRequest::getVar('se_postcode', '');
         $radius = JRequest::getInt('se_radius', 0);
         if ($postcode != '' && $postcode != JText::_('COM_DJCLASSIFIEDS_SEARCH_MODULE_POSTCODE') && $radius) {
             $postcode_country = JRequest::getVar('se_postcode_c', '');
             $post_coord = DJClassifiedsGeocode::getLocationPostCode($postcode, $postcode_country);
             $radius_unit = JRequest::getCmd('se_radius_unit', 'km');
             if ($radius_unit == 'mile') {
                 $radius_unit_v = 6371;
             } else {
                 $radius_unit_v = 3959;
             }
             if ($post_coord) {
                 $search_radius_v = ', ( ' . $radius_unit_v . ' * acos( cos( radians(' . $post_coord['lat'] . ') ) * cos( radians( i.latitude ) ) * cos( radians( i.longitude ) - radians(' . $post_coord['lng'] . ') ) + sin( radians(' . $post_coord['lat'] . ') ) * sin( radians( i.latitude ) ) ) ) AS distance ';
                 $search_radius_h = 'HAVING distance < ' . $radius . ' ';
             } else {
                 $app->enqueueMessage(JText::_('COM_DJCLASSIFIEDS_SORRY_WE_CANT_FIND_COORDINATES_FROM_POSTCODE_WE_OMIITED_RANGE_RESTRICTION'), 'notice');
             }
         }
         $query = "SELECT i.*, c.name AS c_name,c.alias AS c_alias, c.id as c_id, r.name as r_name, r.id as r_id " . $search_radius_v . ", img.path as img_path, img.name as img_name, img.ext as img_ext,img.caption as img_caption FROM " . $search_fields . " #__djcf_items i " . "LEFT JOIN #__djcf_categories c ON i.cat_id = c.id " . "LEFT JOIN #__djcf_regions r ON i.region_id = r.id " . "LEFT JOIN ( SELECT img.id, img.item_id, img.name, img.path, img.ext, img.ordering, img.caption \n\t\t \t\t\t\t\t  FROM (SELECT * FROM #__djcf_images WHERE type='item' ORDER BY ordering) img GROUP BY img.item_id ) AS img ON img.item_id=i.id " . "WHERE i.date_exp > NOW() AND i.published=1 " . $where;
         if ($search_fields) {
             $query .= " AND sf.item_id=i.id ";
         }
         $query .= $search_radius_h . $search . " ORDER BY i.special DESC, " . $ord . "";
         $db->setQuery($query);
         $items = $db->loadObjectList();
         //echo '<pre>'; print_r($items);die();
     } else {
         $where = '';
         $cid = JRequest::getInt('cid', '0');
         if ($params->get('follow_category', 1) == 1 && $cid > 0) {
             $djcfcatlib = new DJClassifiedsCategory();
             $cats = $djcfcatlib->getSubCat($cid, 1);
             $catlist = $cid;
             foreach ($cats as $c) {
                 $catlist .= ',' . $c->id;
             }
             $where .= ' AND i.cat_id IN (' . $catlist . ') ';
         }
         $query = "SELECT i.*, c.name as c_name, c.alias as c_alias, img.path as img_path, img.name as img_name, img.ext as img_ext,img.caption as img_caption " . "FROM #__djcf_categories c, #__djcf_items i  " . "LEFT JOIN ( SELECT img.id, img.item_id, img.name, img.path, img.ext, img.ordering, img.caption \n\t\t \t\t\t\t\t  FROM (SELECT * FROM #__djcf_images WHERE type='item' ORDER BY ordering) img GROUP BY img.item_id ) AS img ON img.item_id=i.id " . "WHERE i.date_exp > '" . $date_exp . "' AND i.published = 1 AND i.cat_id=c.id AND i.latitude!='0.000000000000000' AND i.longitude!='0.000000000000000' " . $where . " " . "ORDER BY " . $ord . " limit " . $params->get('items_limit');
         $db->setQuery($query);
         $items = $db->loadObjectList();
     }
     return $items;
 }
Exemplo n.º 10
0
 function addtosubcategories()
 {
     $app = JFactory::getApplication();
     $id = JRequest::getInt('id', '0');
     $cid = JRequest::getInt('cid', '0');
     $db = JFactory::getDBO();
     if ($cid) {
         $cats = DJClassifiedsCategory::getSubCat($cid);
         $id_list = '';
         foreach ($cats as $cat) {
             $id_list .= $id_list ? ',' . $cat->id : $cat->id;
         }
         //echo '<pre>';print_r($cats);die();
         if ($id_list) {
             $query = "SELECT c.id, IFNULL(fx.ord,0)+1 as ordering, IFNULL(f.active,0) as active FROM #__djcf_categories c " . "LEFT JOIN (SELECT count(fx.id) as ord, fx.cat_id FROM #__djcf_fields_xref fx GROUP BY fx.cat_id ) fx ON fx.cat_id=c.id " . "LEFT JOIN (SELECT count(fx.id) as active, fx.cat_id FROM #__djcf_fields_xref fx WHERE fx.field_id=" . $id . " GROUP BY fx.cat_id ) f ON f.cat_id=c.id " . "WHERE c.id IN (" . $id_list . ") ";
             $db =& JFactory::getDBO();
             $db->setQuery($query);
             $cats = $db->loadObjectList();
             //echo '<pre>';print_r($db);print_r($cats);die();
             $cat_c = 0;
             if (count($cats)) {
                 $query = "INSERT INTO #__djcf_fields_xref(`cat_id`,`field_id`,`ordering`) VALUES ";
                 foreach ($cats as $cat) {
                     if (!$cat->active) {
                         $query .= "('" . $cat->id . "','" . $id . "','" . $cat->ordering . "'), ";
                         $cat_c++;
                     }
                 }
                 if ($cat_c) {
                     $query = substr($query, 0, -2) . ';';
                     //echo '<pre>';print_r($query);die();
                     $db->setQuery($query);
                     $db->query();
                 }
             }
         }
     }
     $app->redirect('index.php?option=com_djclassifieds&task=field.edit&id=' . $id, JText::_('COM_DJCLASSIFIEDS_FIELD_ASSIGNED_TO_SELECTED_CATEGORIES'));
 }
Exemplo n.º 11
0
JHTML::_('behavior.framework');
$comparams = JComponentHelper::getParams('com_djclassifieds');
if (JRequest::getVar('option') != 'com_djclassifieds') {
    $document = JFactory::getDocument();
    DJClassifiedsTheme::includeCSSfiles();
    $language = JFactory::getLanguage();
    $c_lang = $language->getTag();
    if ($c_lang == 'pl-PL' || $c_lang == 'en-GB') {
        $language->load('com_djclassifieds', JPATH_SITE . '/components/com_djclassifieds', null, true);
    } else {
        if (!$language->load('com_djclassifieds', JPATH_SITE, null, true)) {
            $language->load('com_djclassifieds', JPATH_SITE . '/components/com_djclassifieds', null, true);
        }
    }
}
$djcfcatlib = new DJClassifiedsCategory();
$list = modDjClassifiedsSearch::getCats();
if ($params->get('cat_hide_empty', '0')) {
    $list = $djcfcatlib->getCatAllItemsCount(1, $params->get('cat_ordering', 'ord'), $params->get('cat_hide_empty', '0'));
    $categories = array();
    $categories[0] = array();
    foreach ($list as $cat) {
        if (!isset($categories[$cat->parent_id])) {
            $categories[$cat->parent_id] = array();
        }
        $categories[$cat->parent_id][] = $cat;
    }
    //echo '<pre>';print_r($categories);die();
} else {
    $categories = $djcfcatlib->getCategoriesSortParent(1, $params->get('cat_ordering', 'ord'));
}
echo $this->category->points;
?>
" />
							</div>
						</div>
						<div class="control-group">
							<div class="control-label"><?php 
echo JText::_('COM_DJCLASSIFIEDS_PARENT_CATEGORY');
?>
</div>
							<div class="controls">
								<?php 
$optionss = array();
$optionss = DJClassifiedsCategory::getCatSelect();
if ($this->category->id > 0) {
    $cat_list = DJClassifiedsCategory::getSubCat($this->category->id);
    $cat_list_assoc = array();
    $cat_list_assoc[$this->category->id] = 1;
    foreach ($cat_list as $cl) {
        $cat_list_assoc[$cl->id] = 1;
    }
    foreach ($optionss as $op) {
        if (isset($cat_list_assoc[$op->value])) {
            $op->disable = 1;
        }
    }
}
$main_tab = array();
$main_tab[0] = JHTML::_('select.option', '0', JText::_('COM_DJCLASSIFIEDS_MAIN_CATEGORY'));
$options = array();
$options = array_merge_recursive($main_tab, $optionss);
Exemplo n.º 13
0
*/
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');
?>



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();
$cid = 0;
if ($active) {
    if ($active->query['option'] == 'com_djclassifieds' && JRequest::getVar('option') == 'com_djclassifieds') {
        $cid = JRequest::getInt('cid', 0);
    }
} else {
    if (JRequest::getVar('option') == 'com_djclassifieds') {
        $cid = JRequest::getInt('cid', 0);
    }
}
$djcfcatlib = new DJClassifiedsCategory();
$ret = $djcfcatlib->getMenuCategories($cid, 1, $params->get('cat_ordering', 'ord'), $params->get('hide_empty', '0'));
$cats = $ret[0];
$cat_path = $ret[1];
/*$menus	= JSite::getMenu();	
	$menu_item = $menus->getItems('link','index.php?option=com_djclassifieds&view=items&cid=0',1);
	$menu_item_blog = $menus->getItems('link','index.php?option=com_djclassifieds&view=items&layout=blog&cid=0',1);
	$menu_newad_itemid = $menus->getItems('link','index.php?option=com_djclassifieds&view=additem',1);
			
	$itemid = ''; 
	if($menu_item){
		$itemid='&Itemid='.$menu_item->id;
	}else if($menu_item_blog){
		$itemid='&Itemid='.$menu_item_blog->id;
	}*/
if (JRequest::getVar('option') != 'com_djclassifieds') {
Exemplo n.º 15
0
 function display($tpl = null)
 {
     $model = $this->getModel();
     $par = JComponentHelper::getParams('com_djclassifieds');
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $dispatcher = JDispatcher::getInstance();
     $theme = $par->get('theme', 'default');
     $item = $model->getItem();
     $item_images = DJClassifiedsImage::getAdsImages($item->id);
     $category = $model->getCategory($item->cat_id);
     $fields = $model->getFields($item->cat_id);
     $fields_contact = $model->geContactFields();
     $item_payments = $model->getItemPayment($item->id);
     if ($item->user_id != 0) {
         $user_items_c = $model->getUserItemsCount($item->user_id);
         $this->assignRef('user_items_c', $user_items_c);
     }
     $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')) {
             $cid_menu = $m_active->query['cid'];
             if ($cid_menu > 0) {
                 $cat_menu_path = DJClassifiedsCategory::getParentPath(1, $cid_menu);
             }
         }
     }
     $main_cat_id = $item->cat_id;
     $pathway = $app->getPathway();
     $cat_path = array();
     $cat_theme = '';
     if ($category->id != 0) {
         $cat_path = DJClassifiedsCategory::getParentPath(1, $category->id);
         $main_cat_id = $cat_path[count($cat_path) - 1]->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));
             }
         }
         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/item');
         $theme = $cat_theme;
     }
     $regions = $model->getRegions();
     $country = '';
     $city = '';
     $region_name = '';
     if ($item->region_id != 0 && $par->get('show_regions', '1')) {
         $address = '';
         $rid = $item->region_id;
         if ($rid != 0) {
             while ($rid != 0) {
                 foreach ($regions as $li) {
                     if ($li->id == $rid) {
                         $rid = $li->parent_id;
                         $address .= $li->name . ', ';
                         if ($li->country) {
                             $country = $li->name;
                         }
                         if ($li->city) {
                             $city = $li->name;
                         }
                         if (!$region_name) {
                             $region_name = $li->name;
                         }
                         break;
                     }
                 }
                 if ($rid == $item->region_id) {
                     break;
                 }
             }
         }
         $address = substr($address, 0, -2);
     }
     $profile = '';
     if ($item->user_id) {
         $profile = $model->getProfile($item->user_id);
     }
     if ($item->metakey != '') {
         $document->setMetaData('keywords', $item->metakey);
     } else {
         if ($category->metakey != '') {
             $document->setMetaData('keywords', $category->metakey);
         } else {
             if ($m_active) {
                 if ($m_active->params->get('menu-meta_description')) {
                     $document->setMetaData('keywords', $m_active->params->get('menu-meta_description'));
                 }
             }
         }
     }
     if ($item->metadesc != '') {
         $document->setDescription($item->metadesc);
     } else {
         if ($par->get('seo_item_metadesc', '0') == 0) {
             $document->setDescription($item->intro_desc);
         } else {
             if ($category->metadesc != '') {
                 $document->setDescription($category->metadesc);
             } else {
                 if ($m_active) {
                     if ($m_active->params->get('menu-meta_keywords')) {
                         $document->setDescription($m_active->params->get('menu-meta_keywords'));
                     }
                 }
             }
         }
     }
     $c_title = $document->getTitle();
     $cat_name = $category->name;
     $item_name = $item->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>', '<item_name>', '<region_name>');
     $seo_title_to = array($seo_title_separator, $c_title, $cat_name, $seo_cat_path, $item_name, $region_name);
     $seo_title = str_ireplace($seo_title_from, $seo_title_to, $par->get('seo_title_item', '<item_name>|<category_name>|<default_title>'));
     $document->setTitle($seo_title);
     $document->setMetaData('og:title', $item->name);
     $document->setMetaData('og:description', $item->intro_desc);
     if ($item->image_url != '') {
         $images = explode(";", $item->image_url);
         $document->setMetaData('og:image', JURI::base() . 'components/com_djclassifieds/images/' . $images[0]);
     }
     /* plugins */
     JPluginHelper::importPlugin('djclassifieds');
     $results = $dispatcher->trigger('onPrepareItemDescription', array(&$item, &$par));
     $item->event = new stdClass();
     $resultsAfterTitle = $dispatcher->trigger('onAfterDJClassifiedsDisplayTitle', array(&$item, &$par));
     $item->event->afterDJClassifiedsDisplayTitle = trim(implode("\n", $resultsAfterTitle));
     $resultsBeforeContent = $dispatcher->trigger('onBeforeDJClassifiedsDisplayContent', array(&$item, &$par));
     $item->event->beforeDJClassifiedsDisplayContent = trim(implode("\n", $resultsBeforeContent));
     $resultsAfterContent = $dispatcher->trigger('onAfterDJClassifiedsDisplayContent', array(&$item, &$par));
     $item->event->afterDJClassifiedsDisplayContent = trim(implode("\n", $resultsAfterContent));
     $pathway->addItem($item->name);
     $this->assignRef('item', $item);
     $this->assignRef('item_images', $item_images);
     $this->assignRef('fields', $fields);
     $this->assignRef('fields_contact', $fields_contact);
     $this->assignRef('country', $country);
     $this->assignRef('city', $city);
     $this->assignRef('address', $address);
     $this->assignRef('main_cat_id', $main_cat_id);
     $this->assignRef('item_payments', $item_payments);
     $this->assignRef('category', $category);
     $this->assignRef('profile', $profile);
     $this->assignRef('theme', $theme);
     parent::display($tpl);
 }
 function getCountItems($catlist = '')
 {
     $par = JComponentHelper::getParams('com_djclassifieds');
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $where = '';
     if ($catlist) {
         $where = ' AND i.cat_id IN (' . $catlist . ') ';
     }
     $uid = JRequest::getVar('uid', '0', '', 'int');
     if ($uid > 0) {
         $where .= " AND i.user_id=" . $uid . " ";
     }
     $fav_lj = '';
     if ($par->get('favourite', '1') && $user->id > 0) {
         $fav_lj = "LEFT JOIN ( SELECT * FROM #__djcf_favourites WHERE user_id=" . $user->id . ") f ON i.id=f.item_id ";
         $fav = JRequest::getVar('fav', '0', '', 'int');
         if ($fav > 0) {
             $where .= " AND f.id IS NOT NULL ";
         }
     }
     $search = '';
     $search_fields = '';
     $cat_id = 0;
     $reg_id = 0;
     $search_radius_v = '';
     $search_radius_h = '';
     if (JRequest::getVar('se', '0', '', 'string') != '0') {
         if (JRequest::getVar('search', JText::_('COM_DJCLASSIFIEDS_SEARCH'), '', 'string') != JText::_('COM_DJCLASSIFIEDS_SEARCH')) {
             $search_word = $db->Quote('%' . $db->escape(JRequest::getVar('search', '', '', 'string'), true) . '%');
             $search = " AND (CONCAT_WS(i.name,i.intro_desc,i.description) LIKE " . $search_word . " OR c.name LIKE " . $search_word . " OR r.name LIKE " . $search_word . " ) ";
         }
         if (isset($_GET['se_cats'])) {
             $cat_id = end($_GET['se_cats']);
             if ($cat_id == '' && count($_GET['se_cats']) > 2) {
                 $cat_id = $_GET['se_cats'][count($_GET['se_cats']) - 2];
             }
         }
         $cat_id = str_ireplace('p', '', $cat_id);
         if ($cat_id > 0) {
             $cats = DJClassifiedsCategory::getSubCat($cat_id, 1);
             $catlist = $cat_id;
             foreach ($cats as $c) {
                 $catlist .= ',' . $c->id;
             }
             $search .= ' AND i.cat_id IN (' . $catlist . ') ';
             $search_fields = $this->getSearchFields();
         }
         if (isset($_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];
             }
             $reg_id = (int) $reg_id;
         }
         if ($reg_id > 0) {
             $regs = DJClassifiedsRegion::getSubReg($reg_id, 1);
             $reglist = $reg_id;
             foreach ($regs as $r) {
                 $reglist .= ',' . $r->id;
             }
             $search .= ' AND i.region_id IN (' . $reglist . ') ';
         }
         $se_price_from = JRequest::getInt('se_price_f', '');
         $se_price_to = JRequest::getInt('se_price_t', '');
         if ($se_price_from) {
             $search .= " AND ABS(i.price) >= '" . $se_price_from . "' ";
         }
         if ($se_price_to && $se_price_to > $se_price_from) {
             $search .= " AND ABS(i.price) <= '" . $se_price_to . "' ";
         }
         $type_id = JRequest::getInt('se_type_id', '0');
         if ($type_id > 0) {
             $where .= " AND i.type_id=" . $type_id . " ";
         }
         $days_l = JRequest::getInt('days_l', '0');
         if ($days_l > 0) {
             $date_limit = date("Y-m-d H:i:s", mktime(date("H"), date("i"), date("s"), date("m"), date("d") - $days_l, date("Y")));
             $where .= " AND i.date_start >= '" . $date_limit . "' ";
         }
         $only_img = JRequest::getInt('se_only_img', 0);
         if ($only_img == 1) {
             $search .= " AND img.img_c>0 ";
         }
         $only_video = JRequest::getInt('se_only_video', 0);
         if ($only_video == 1) {
             $search .= " AND i.video!='' ";
         }
         $postcode = JRequest::getVar('se_postcode', '');
         $radius = JRequest::getInt('se_radius', 0);
         if ($postcode && $radius) {
             $postcode_country = JRequest::getVar('se_postcode_c', '');
             $post_coord = DJClassifiedsGeocode::getLocationPostCode($postcode, $postcode_country);
             $radius_unit = JRequest::getCmd('se_radius_unit', 'km');
             if ($radius_unit == 'mile') {
                 $radius_unit_v = 6371;
             } else {
                 $radius_unit_v = 3959;
             }
             if ($post_coord) {
                 $search_radius_v = ', ( ' . $radius_unit_v . ' * acos( cos( radians(' . $post_coord['lat'] . ') ) * cos( radians( i.latitude ) ) * cos( radians( i.longitude ) - radians(' . $post_coord['lng'] . ') ) + sin( radians(' . $post_coord['lat'] . ') ) * sin( radians( i.latitude ) ) ) ) AS distance ';
                 $search_radius_h = 'HAVING distance < ' . $radius . ' ';
             }
         }
     }
     $date_time = JFactory::getDate();
     $date_exp = $date_time->toSQL();
     $query = "SELECT count(i.id) FROM (SELECT i.id " . $search_radius_v . " FROM " . $search_fields . " #__djcf_items i " . "LEFT JOIN #__djcf_categories c ON i.cat_id = c.id " . "LEFT JOIN #__djcf_regions r ON i.region_id = r.id " . "LEFT JOIN ( SELECT COUNT(img.id) as img_c, img.item_id FROM #__djcf_images img\r\n\t\t\t\t\t\t\t\tWHERE img.type='item' GROUP BY item_id ) img ON i.id=img.item_id " . $fav_lj . "WHERE i.date_exp > NOW() AND i.published=1 " . $where . $search;
     if ($search_fields) {
         $query .= " AND sf.item_id=i.id ";
     }
     $query .= $search_radius_h;
     $query .= " ) as i ";
     $db->setQuery($query);
     $items_count = $db->loadResult();
     //echo '<pre>';print_r($db);print_r($items_count);echo '<pre>';die();
     return $items_count;
 }
Exemplo n.º 17
0
 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&amp;re=1&amp;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);
     }
 }
Exemplo n.º 18
0
 public static function getItems($params)
 {
     $date_time = JFactory::getDate();
     $date_exp = $date_time->toSQL();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $ord = "i.date_start DESC";
     if ($params->get('items_ord') == 1) {
         $ord = "i.display DESC";
     } else {
         if ($params->get('items_ord') == 2) {
             $ord = "rand()";
         } else {
             if ($params->get('items_ord') == 3) {
                 $ord = "i.name";
             }
         }
     }
     $promoted = '';
     $prom_list = array();
     if ($params->get('only_p_special', '0') == 1) {
         $prom_list[] = " i.promotions LIKE '%p_special%' ";
     }
     if ($params->get('only_p_first', '0') == 1) {
         $prom_list[] = " i.promotions LIKE '%p_first%' ";
     }
     if ($params->get('only_p_bold', '0') == 1) {
         $prom_list[] = " i.promotions LIKE '%p_bold%' ";
     }
     if ($params->get('only_p_border', '0') == 1) {
         $prom_list[] = " i.promotions LIKE '%p_border%' ";
     }
     if ($params->get('only_p_bg', '0') == 1) {
         $prom_list[] = " i.promotions LIKE '%p_bg%' ";
     }
     if (count($prom_list) == 1) {
         $promoted = ' AND ' . $prom_list[0] . ' ';
     } else {
         if (count($prom_list) > 1) {
             $promoted = ' AND (' . implode(' OR ', $prom_list) . ') ';
         }
     }
     $item_ids = $params->get('items_ids', '');
     if ($item_ids) {
         $item_ids = ' AND i.id IN (' . $item_ids . ')';
     } else {
         $item_ids = '';
     }
     $users_ids = $params->get('users_ids', '');
     if ($users_ids) {
         $users_ids = ' AND i.user_id IN (' . $users_ids . ')';
     } else {
         $users_ids = '';
     }
     $types_ids = $params->get('type_id', '');
     if (is_array($types_ids)) {
         $types_ids = ' AND i.type_id IN (' . implode(',', $types_ids) . ')';
     } else {
         $types_ids = '';
     }
     $cat_ids = $params->get('cat_id', '0');
     $cid = JRequest::getInt('cid', '0');
     $fallow_cat = '';
     $cat_list = '';
     if ($params->get('fallow_category') == 1 && JRequest::getVar('option', '') == 'com_djclassifieds' && $cid > 0) {
         $djcfcatlib = new DJClassifiedsCategory();
         $cats = $djcfcatlib->getSubCat($cid, 1);
         $catlist = $cid;
         foreach ($cats as $c) {
             $catlist .= ',' . $c->id;
         }
         $fallow_cat = ' AND i.cat_id IN (' . $catlist . ') ';
     } else {
         if (is_array($cat_ids)) {
             if (count($cat_ids) > 1) {
                 $cat_list = ' AND i.cat_id IN (' . implode(',', $cat_ids) . ') ';
             } else {
                 if ($cat_ids[0] > 0) {
                     $cat_list = ' AND i.cat_id = ' . $cat_ids[0] . ' ';
                 }
             }
         }
     }
     $reg_ids = $params->get('region_id', '0');
     $fallow_region = '';
     $region_list = '';
     if ($params->get('fallow_region', '0') == 1 && JRequest::getVar('option', '') == 'com_djclassifieds' && JRequest::getVar('view', '') == 'item') {
         $djcfreglib = new DJClassifiedsRegion();
         $id = JRequest::getInt('id', '0');
         $query = "SELECT i.region_id FROM #__djcf_items i " . "WHERE i.id=" . $id . " LIMIT 1";
         $db->setQuery($query);
         $region_id = $db->loadResult();
         if ($region_id) {
             $regs = $djcfreglib->getSubReg($region_id);
             $reglist = $region_id;
             foreach ($regs as $r) {
                 $reglist .= ',' . $r->id;
             }
             $fallow_region = ' AND i.region_id IN (' . $reglist . ') ';
         }
     }
     if (is_array($reg_ids) && $fallow_region == '') {
         if (count($reg_ids) > 1) {
             $region_list = ' AND i.region_id IN (' . implode(',', $reg_ids) . ') ';
         } else {
             if ($reg_ids[0] > 0) {
                 $region_list = ' AND i.region_id = ' . $reg_ids[0] . ' ';
             }
         }
     }
     $only_img = '';
     if ($params->get('only_with_img', '0') == 1) {
         $only_img = " AND img.name !='' ";
     }
     $source = '';
     $fav_lj = '';
     $fav_s = '';
     if ($user->id) {
         if ($params->get('items_source', '0') == 1) {
             $source = ' AND i.user_id=' . $user->id . ' ';
         } else {
             if ($params->get('items_source', '0') == 2) {
                 $fav_lj = "LEFT JOIN ( SELECT * FROM #__djcf_favourites WHERE user_id=" . $user->id . ") f ON i.id=f.item_id ";
                 $fav_s = ',f.id as f_id ';
                 $source = " AND f.id IS NOT NULL ";
             }
         }
     }
     $query = "SELECT i.*,c.id as c_id, c.name as c_name,c.alias as c_alias,c.icon_url as c_icon_url, r.name as r_name, " . " img.path as img_path, img.name as img_name, img.ext as img_ext,img.caption as img_caption " . $fav_s . "FROM #__djcf_categories c, #__djcf_items i " . "LEFT JOIN #__djcf_regions r ON r.id=i.region_id " . $fav_lj . "LEFT JOIN ( SELECT img.id, img.item_id, img.name, img.path, img.ext, img.ordering, img.caption \n\t\t \t\t\t\t\t  FROM (SELECT * FROM #__djcf_images WHERE type='item' ORDER BY ordering) img GROUP BY img.item_id ) AS img ON img.item_id=i.id " . "WHERE i.date_exp > '" . $date_exp . "' AND i.published = 1 AND c.published = 1 AND i.cat_id=c.id " . $promoted . $item_ids . $users_ids . $fallow_cat . $cat_list . $fallow_region . $region_list . $types_ids . $only_img . $source . "ORDER BY " . $ord . " limit " . $params->get('items_nr');
     $db->setQuery($query);
     $items = $db->loadObjectList();
     //echo '<pre>';print_r($db);die();
     return $items;
 }
Exemplo n.º 19
0
 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);
 }
Exemplo n.º 20
0
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();
$cid = 0;
if ($active) {
    if ($active->query['option'] == 'com_djclassifieds' && JRequest::getVar('option') == 'com_djclassifieds') {
        $cid = JRequest::getInt('cid', 0);
    }
} else {
    if (JRequest::getVar('option') == 'com_djclassifieds') {
        $cid = JRequest::getInt('cid', 0);
    }
}
$djcfcatlib = new DJClassifiedsCategory();
if ($params->get('only_current_level', 0) && $cid) {
    $category = $djcfcatlib->getCategory($cid, 1);
    $ret = $djcfcatlib->getMenuCategories($cid, 1, $params->get('cat_ordering', 'ord'), $params->get('hide_empty', '0'), $category->parent_id, 1);
} else {
    $ret = $djcfcatlib->getMenuCategories($cid, 1, $params->get('cat_ordering', 'ord'), $params->get('hide_empty', '0'));
}
if ($params->get('expand_type', '0') == 1) {
    //$regs = $ret[2];
    $cats = $ret[2];
} else {
    $cats = $ret[0];
}
$cat_path = $ret[1];
/*$menus	= JSite::getMenu();	
	$menu_item = $menus->getItems('link','index.php?option=com_djclassifieds&view=items&cid=0',1);
							
							<div class="tab-pane" id="category_custom_fields">
								<div class="control-group">
									<div class="control-group">
										<div class="control-label"><?php 
echo JText::_('COM_DJCLASSIFIEDS_CATEGORY');
?>
</div>
										<div class="controls">
											<select autocomplete="off" name="cat_id" class="inputbox" onchange="getFields(this.value)" >
												<option value=""><?php 
echo JText::_('JOPTION_SELECT_CATEGORY');
?>
</option>
												<?php 
echo JHtml::_('select.options', DJClassifiedsCategory::getCatSelect(), 'value', 'text', $this->item->cat_id, true);
?>
											</select>
										</div>
									</div>	
									<div class="control-group">
										<div class="control-label"><?php 
echo JText::_('COM_DJCLASSIFIEDS_EXTRA_FIELDS');
?>
</div>
										<div class="controls">
											<div id="ex_fields"><?php 
echo JText::_('COM_DJCLASSIFIEDS_PLEASE_SELECT_CATEGORY');
?>
</div>
										</div>
Exemplo n.º 22
0
 function display($tpl = null)
 {
     $model = $this->getModel();
     $par = JComponentHelper::getParams('com_djclassifieds');
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $dispatcher = JDispatcher::getInstance();
     $theme = $par->get('theme', 'default');
     $user = JFactory::getUser();
     $item = $model->getItem();
     if ($item->user_id != $user->id) {
         $groups_acl = ',' . implode(',', $user->getAuthorisedViewLevels()) . ',';
         if (!strstr($groups_acl, ',' . $item->c_access_view . ',') || !$item) {
             DJClassifiedsTheme::djAccessRestriction('category');
         } else {
             if ($item->access_view == 0) {
                 if (!strstr($groups_acl, ',' . $item->c_access_item_view . ',')) {
                     DJClassifiedsTheme::djAccessRestriction();
                 }
             } else {
                 if (!strstr($groups_acl, ',' . $item->access_view . ',')) {
                     DJClassifiedsTheme::djAccessRestriction();
                 }
             }
         }
     }
     $item_images = DJClassifiedsImage::getAdsImages($item->id);
     $category = $model->getCategory($item->cat_id);
     $fields = $model->getFields($item->cat_id);
     $fields_contact = $model->geContactFields();
     $item_payments = $model->getItemPayment($item->id);
     $item_options = $model->getItemOptions($item->id);
     $bids = $model->getBids($item->id, $par->get('bids_displayed', 5));
     if ($item->user_id != 0) {
         $user_items_c = $model->getUserItemsCount($item->user_id);
         $this->assignRef('user_items_c', $user_items_c);
     }
     $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')) {
             $cid_menu = $m_active->query['cid'];
             if ($cid_menu > 0) {
                 $cat_menu_path = DJClassifiedsCategory::getParentPath(1, $cid_menu);
             }
         }
     }
     $warning18 = '';
     $main_cat_id = $item->cat_id;
     $pathway = $app->getPathway();
     $cat_path = array();
     $cat_theme = '';
     if ($category->id != 0) {
         $cat_path = DJClassifiedsCategory::getParentPath(1, $category->id);
         $main_cat_id = $cat_path[count($cat_path) - 1]->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));
             }
         }
         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/item');
         $theme = $cat_theme;
     }
     $regions = $model->getRegions();
     $country = '';
     $city = '';
     $region_name = '';
     if ($item->region_id != 0 && $par->get('show_regions', '1')) {
         $address = '';
         $rid = $item->region_id;
         if ($rid != 0) {
             while ($rid != 0) {
                 foreach ($regions as $li) {
                     if ($li->id == $rid) {
                         $rid = $li->parent_id;
                         $address .= $li->name . ', ';
                         if ($li->country) {
                             $country = $li->name;
                         }
                         if ($li->city) {
                             $city = $li->name;
                         }
                         if (!$region_name) {
                             $region_name = $li->name;
                         }
                         break;
                     }
                 }
                 if ($rid == $item->region_id) {
                     break;
                 }
             }
         }
         $address = substr($address, 0, -2);
     }
     $profile = '';
     if ($item->user_id) {
         $profile = $model->getProfile($item->user_id);
     }
     $custom_ask_seller = $model->getCustomAskSellerFields();
     if ($item->metakey != '') {
         $document->setMetaData('keywords', $item->metakey);
     } else {
         if ($category->metakey != '') {
             $document->setMetaData('keywords', $category->metakey);
         } else {
             if ($m_active) {
                 if ($m_active->params->get('menu-meta_description')) {
                     $document->setMetaData('keywords', $m_active->params->get('menu-meta_description'));
                 }
             }
         }
     }
     if ($item->metadesc != '') {
         $document->setDescription($item->metadesc);
     } else {
         if ($par->get('seo_item_metadesc', '0') == 0) {
             $document->setDescription($item->intro_desc);
         } else {
             if ($category->metadesc != '') {
                 $document->setDescription($category->metadesc);
             } else {
                 if ($m_active) {
                     if ($m_active->params->get('menu-meta_keywords')) {
                         $document->setDescription($m_active->params->get('menu-meta_keywords'));
                     }
                 }
             }
         }
     }
     $c_title = $document->getTitle();
     $cat_name = $category->name;
     $item_name = $item->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>', '<item_name>', '<region_name>');
     $seo_title_to = array($seo_title_separator, $c_title, $cat_name, $seo_cat_path, $item_name, $region_name);
     $seo_title = str_ireplace($seo_title_from, $seo_title_to, $par->get('seo_title_item', '<item_name>|<category_name>|<default_title>'));
     $document->setTitle($seo_title);
     $document->setMetaData('og:title', $item->name);
     $document->setMetaData('og:description', $item->intro_desc);
     if ($item_images) {
         $document->setMetaData('og:image', JURI::base() . $item_images[0]->thumb_b);
     }
     if ($par->get('comments', '0') == 1 && $par->get('fb_comments_admin', '') != '') {
         $document->addCustomTag('<meta property="fb:admins" content="' . $par->get('fb_comments_admin', '') . '" />');
     }
     $anch = $par->get('showitem_jump', 0) ? '#dj-classifieds' : '';
     $correct_link = JRoute::_(DJClassifiedsSEO::getItemRoute($item->id . ':' . $item->alias, $item->cat_id . ':' . $item->c_alias)) . $anch;
     $document->setMetaData('canonical', $correct_link);
     /* plugins */
     if ($category) {
         $item->c_alias = $category->alias;
     }
     $results = $dispatcher->trigger('onPrepareItemDescription', array(&$item, &$par, 'item'));
     $item->event = new stdClass();
     $resultsAfterTitle = $dispatcher->trigger('onAfterDJClassifiedsDisplayTitle', array(&$item, &$par, 'item'));
     $item->event->afterDJClassifiedsDisplayTitle = trim(implode("\n", $resultsAfterTitle));
     $resultsBeforeContent = $dispatcher->trigger('onBeforeDJClassifiedsDisplayContent', array(&$item, &$par, 'item'));
     $item->event->beforeDJClassifiedsDisplayContent = trim(implode("\n", $resultsBeforeContent));
     $resultsAfterContent = $dispatcher->trigger('onAfterDJClassifiedsDisplayContent', array(&$item, &$par, 'item'));
     $item->event->afterDJClassifiedsDisplayContent = trim(implode("\n", $resultsAfterContent));
     $resultsAfterAuthorProfile = $dispatcher->trigger('onAfterDJClassifiedsDisplayAdvertAuthor', array(&$item, &$par, 'item'));
     $item->event->onAfterDJClassifiedsDisplayAdvertAuthor = trim(implode("\n", $resultsAfterAuthorProfile));
     $pathway->addItem($item->name);
     $this->assignRef('item', $item);
     $this->assignRef('item_images', $item_images);
     $this->assignRef('item_options', $item_options);
     $this->assignRef('fields', $fields);
     $this->assignRef('fields_contact', $fields_contact);
     $this->assignRef('country', $country);
     $this->assignRef('city', $city);
     $this->assignRef('address', $address);
     $this->assignRef('main_cat_id', $main_cat_id);
     $this->assignRef('item_payments', $item_payments);
     $this->assignRef('category', $category);
     $this->assignRef('profile', $profile);
     $this->assignRef('theme', $theme);
     $this->assignRef('bids', $bids);
     $this->assignRef('custom_ask_seller', $custom_ask_seller);
     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);
         parent::display('terms');
     } else {
         parent::display($tpl);
     }
 }
Exemplo n.º 23
0
			<select name="filter_category" class="inputbox" onchange="this.form.submit()">
				<option value=""><?php 
echo JText::_('JOPTION_SELECT_CATEGORY');
?>
</option>
				<option <?php 
if ($this->state->get('filter.category') == -1) {
    echo 'SELECTED';
}
?>
 value="-1"><?php 
echo JText::_('COM_DJCLASSIFIEDS_MAIN_CATEGORY');
?>
</option>
				<?php 
$optionss = DJClassifiedsCategory::getCatSelect();
?>
			
				<?php 
echo JHtml::_('select.options', $optionss, 'value', 'text', $this->state->get('filter.category'));
?>
			</select>
		</div>
	</fieldset>
	<div class="clr"> </div>
    <table class="adminlist">
        <thead>
            <tr>
                <th width="5%">
                    <input type="checkbox" name="checkall-toggle" value="" onclick="checkAll(this)" />
                </th>
Exemplo n.º 24
0
 public static function getListSubcat(&$lists, &$lists_const, $main_id = 0, $main_level = 0, $main_f = 0, &$option = array())
 {
     foreach ($lists as $list) {
         if (isset($list->level)) {
             $current_level = $list->level;
         } else {
             $current_level = 0;
         }
         if ($main_f == 1 && ($main_level > $current_level || $current_level == $main_level)) {
             break;
         }
         if ($main_id == $list->id) {
             $main_f = 1;
             $main_level = $current_level;
         }
         if ($main_f == 1 && $main_level < $current_level) {
             $cat_item = new CatItem();
             $cat_item->id = $list->id;
             $cat_item->name = $list->name;
             $cat_item->alias = $list->alias;
             $cat_item->price = $list->price;
             $cat_item->points = $list->points;
             $cat_item->description = $list->description;
             $cat_item->parent_id = $list->parent_id;
             $cat_item->parent_name = $list->parent_name;
             $cat_item->icon_url = $list->icon_url;
             $cat_item->ordering = $list->ordering;
             $cat_item->published = $list->published;
             $cat_item->autopublish = $list->autopublish;
             $cat_item->theme = $list->theme;
             $cat_item->access = $list->access;
             $cat_item->ads_disabled = $list->ads_disabled;
             $cat_item->items_count = $list->items_count;
             $cat_item->level = $current_level;
             $option[] = $cat_item;
         }
         $childs = array();
         if (isset($lists_const[$list->id])) {
             for ($i = 0; $i < count($lists_const[$list->id]); $i++) {
                 $child = new CatItem();
                 $child->id = $lists_const[$list->id][$i]->id;
                 $child->name = $lists_const[$list->id][$i]->name;
                 $child->alias = $lists_const[$list->id][$i]->alias;
                 $child->parent_id = $lists_const[$list->id][$i]->parent_id;
                 $child->price = $lists_const[$list->id][$i]->price;
                 $child->points = $lists_const[$list->id][$i]->points;
                 $child->description = $lists_const[$list->id][$i]->description;
                 $child->parent_id = $lists_const[$list->id][$i]->parent_id;
                 $child->parent_name = $lists_const[$list->id][$i]->parent_name;
                 $child->icon_url = $lists_const[$list->id][$i]->icon_url;
                 $child->ordering = $lists_const[$list->id][$i]->ordering;
                 $child->published = $lists_const[$list->id][$i]->published;
                 $child->autopublish = $lists_const[$list->id][$i]->autopublish;
                 $child->theme = $lists_const[$list->id][$i]->theme;
                 $child->access = $lists_const[$list->id][$i]->access;
                 $child->ads_disabled = $lists_const[$list->id][$i]->ads_disabled;
                 $child->items_count = $lists_const[$list->id][$i]->items_count;
                 if (isset($list->level)) {
                     $child->level = $list->level + 1;
                 } else {
                     $child->level = 1;
                 }
                 $childs[] = $child;
             }
             DJClassifiedsCategory::getListSubcat($childs, $lists_const, $main_id, $main_level, $main_f, $option);
             //echo count($lists_const).' ';
             unset($lists_const[$list->id]);
         }
     }
     return $option;
 }
Exemplo n.º 25
0
 function getCountItems($catlist = '')
 {
     $par = JComponentHelper::getParams('com_djclassifieds');
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $cid = JRequest::getInt('cid', 0);
     $app = JFactory::getApplication();
     $where = '';
     if ($catlist) {
         $where = ' AND i.cat_id IN (' . $catlist . ') ';
     }
     $uid = JRequest::getVar('uid', '0', '', 'int');
     if ($uid > 0) {
         $where .= " AND i.user_id=" . $uid . " ";
     }
     $fav_lj = '';
     if ($par->get('favourite', '1') && $user->id > 0) {
         $fav_lj = "LEFT JOIN ( SELECT * FROM #__djcf_favourites WHERE user_id=" . $user->id . ") f ON i.id=f.item_id ";
         $fav = JRequest::getVar('fav', '0', '', 'int');
         if ($fav > 0) {
             $where .= " AND f.id IS NOT NULL ";
         }
     }
     $search = '';
     $search_fields = '';
     $cat_id = 0;
     $reg_id = 0;
     $search_radius_v = '';
     $search_radius_h = '';
     $search_img_count_lj = '';
     if (JRequest::getVar('se', '0', '', 'string') != '0') {
         if (JRequest::getVar('search', JText::_('COM_DJCLASSIFIEDS_SEARCH'), '', 'string') != JText::_('COM_DJCLASSIFIEDS_SEARCH')) {
             if ($par->get('search_type_phrase', 0) == 1) {
                 $se_words = explode(' ', $db->escape(JRequest::getVar('search', '', '', 'string'), true));
                 foreach ($se_words as $se_w) {
                     if (strlen($se_w) > 2) {
                         $search .= " AND (CONCAT_WS(i.name,i.intro_desc,i.description) LIKE " . $db->Quote('%' . $se_w . '%') . " OR c.name LIKE " . $db->Quote('%' . $se_w . '%') . " OR r.name LIKE " . $db->Quote('%' . $se_w . '%') . " OR i.id=" . $db->Quote($se_w) . " ) ";
                     }
                 }
             } else {
                 $search_word = $db->Quote('%' . $db->escape(JRequest::getVar('search', '', '', 'string'), true) . '%');
                 $search_word2 = $db->Quote($db->escape(JRequest::getVar('search', '', '', 'string'), true));
                 $search = " AND (CONCAT_WS(i.name,i.intro_desc,i.description) LIKE " . $search_word . " OR c.name LIKE " . $search_word . " OR r.name LIKE " . $search_word . "  OR i.id=" . $search_word2 . "  ) ";
             }
         }
         if (isset($_GET['se_cats'])) {
             if (is_array($_GET['se_cats'])) {
                 $cat_id = end($_GET['se_cats']);
                 if ($cat_id == '' && count($_GET['se_cats']) > 2) {
                     $cat_id = $_GET['se_cats'][count($_GET['se_cats']) - 2];
                 }
             } else {
                 $cat_ids = explode(',', JRequest::getVar('se_cats'));
                 $cat_id = end($cat_ids);
             }
             $cat_id = (int) $cat_id;
         }
         $cat_id = str_ireplace('p', '', $cat_id);
         if ($cat_id > 0) {
             $cats = DJClassifiedsCategory::getSubCat($cat_id, 1);
             $catlist = $cat_id;
             foreach ($cats as $c) {
                 $catlist .= ',' . $c->id;
             }
             $search .= ' AND i.cat_id IN (' . $catlist . ') ';
         }
         $se_ef = JRequest::getInt('ef', 0);
         if ($cat_id > 0 || $se_ef) {
             $search_fields = $this->getSearchFields($cat_id, $se_ef);
         }
         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 > 0) {
             $regs = DJClassifiedsRegion::getSubReg($reg_id, 1);
             $reglist = $reg_id;
             foreach ($regs as $r) {
                 $reglist .= ',' . $r->id;
             }
             $search .= ' AND i.region_id IN (' . $reglist . ') ';
         }
         $se_price_from = JRequest::getInt('se_price_f', '');
         $se_price_to = JRequest::getInt('se_price_t', '');
         if ($se_price_from) {
             $search .= " AND ABS(i.price) >= '" . $se_price_from . "' ";
         }
         if ($se_price_to && $se_price_to > $se_price_from) {
             $search .= " AND ABS(i.price) <= '" . $se_price_to . "' ";
         }
         $type_id = JRequest::getInt('se_type_id', '0');
         if ($type_id > 0) {
             $where .= " AND i.type_id=" . $type_id . " ";
         }
         $days_l = JRequest::getInt('days_l', '0');
         if ($days_l > 0) {
             $date_limit = date("Y-m-d H:i:s", mktime(date("H"), date("i"), date("s"), date("m"), date("d") - $days_l, date("Y")));
             $where .= " AND i.date_start >= '" . $date_limit . "' ";
         }
         $only_img = JRequest::getInt('se_only_img', 0);
         if ($only_img == 1) {
             $search .= " AND img.img_c>0 ";
             $search_img_count_lj = "LEFT JOIN ( SELECT COUNT(img.id) as img_c, img.item_id FROM #__djcf_images img\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE img.type='item' GROUP BY item_id ) img ON i.id=img.item_id ";
         }
         $only_video = JRequest::getInt('se_only_video', 0);
         if ($only_video == 1) {
             $search .= " AND i.video!='' ";
         }
         $only_auctions = JRequest::getInt('se_only_auctions', 0);
         if ($only_auctions == 1) {
             $search .= " AND i.auction = 1 ";
         }
         $postcode = JRequest::getVar('se_postcode', '');
         $radius = JRequest::getFloat('se_radius', 0);
         $se_address = JRequest::getVar('se_address', '');
         $se_geoloc = JRequest::getVar('se_geoloc', '');
         if ($radius) {
             $radius_unit = JRequest::getCmd('se_radius_unit', 'km');
             if ($radius_unit == 'mile') {
                 $radius_unit_v = 3959;
             } else {
                 $radius_unit_v = 6371;
             }
             if ($se_geoloc) {
                 $user_latlog = explode('_', $_COOKIE["djcf_latlon"]);
                 $search_radius_v = ', ( ' . $radius_unit_v . ' * acos( cos( radians(' . $user_latlog[0] . ') ) * cos( radians( i.latitude ) ) * cos( radians( i.longitude ) - radians(' . $user_latlog[1] . ') ) + sin( radians(' . $user_latlog[0] . ') ) * sin( radians( i.latitude ) ) ) ) AS distance ';
                 $search_radius_h = 'HAVING distance < ' . $radius . ' ';
             } else {
                 if ($postcode != '' && $postcode != JText::_('COM_DJCLASSIFIEDS_SEARCH_MODULE_POSTCODE')) {
                     $postcode_country = JRequest::getVar('se_postcode_c', '');
                     $post_coord = DJClassifiedsGeocode::getLocationPostCode($postcode, $postcode_country);
                     if ($post_coord) {
                         $search_radius_v = ', ( ' . $radius_unit_v . ' * acos( cos( radians(' . $post_coord['lat'] . ') ) * cos( radians( i.latitude ) ) * cos( radians( i.longitude ) - radians(' . $post_coord['lng'] . ') ) + sin( radians(' . $post_coord['lat'] . ') ) * sin( radians( i.latitude ) ) ) ) AS distance ';
                         $search_radius_h = 'HAVING distance < ' . $radius . ' ';
                     } else {
                         //$app->enqueueMessage(JText::_('COM_DJCLASSIFIEDS_SORRY_WE_CANT_FIND_COORDINATES_FROM_POSTCODE_WE_OMIITED_RANGE_RESTRICTION'),'notice');
                     }
                 } else {
                     if ($se_address != '' && $se_address != JText::_('COM_DJCLASSIFIEDS_SEARCH_MODULE_ADDRESS')) {
                         $se_address_coord = DJClassifiedsGeocode::getLocation($se_address);
                         if ($se_address_coord) {
                             $search_radius_v = ', ( ' . $radius_unit_v . ' * acos( cos( radians(' . $se_address_coord['lat'] . ') ) * cos( radians( i.latitude ) ) * cos( radians( i.longitude ) - radians(' . $se_address_coord['lng'] . ') ) + sin( radians(' . $se_address_coord['lat'] . ') ) * sin( radians( i.latitude ) ) ) ) AS distance ';
                             $search_radius_h = 'HAVING distance < ' . $radius . ' ';
                         } else {
                             //$app->enqueueMessage(JText::_('COM_DJCLASSIFIEDS_SORRY_WE_CANT_FIND_COORDINATES_FROM_ADDRESS_WE_OMIITED_RANGE_RESTRICTION'),'notice');
                         }
                     }
                 }
             }
         }
         if (JRequest::getInt('se_also_18', 0) == 0) {
             $search .= " AND c.restriction_18=0 ";
         }
     } else {
         if ($par->get('restriction_18_allads', 0) == 1 && !isset($_COOKIE["djcf_warning18"])) {
             $where .= " AND c.restriction_18=0 ";
         }
     }
     $groups_acl = '0,' . implode(',', $user->getAuthorisedViewLevels());
     $where .= " AND c.access_view IN (" . $groups_acl . ") ";
     $date_time = JFactory::getDate();
     $date_exp = $date_time->toSQL();
     $date_now = date("Y-m-d H:i:s");
     $query = "SELECT count(i.id) FROM (SELECT i.id " . $search_radius_v . " FROM " . $search_fields . " #__djcf_items i " . "LEFT JOIN #__djcf_categories c ON i.cat_id = c.id " . "LEFT JOIN #__djcf_regions r ON i.region_id = r.id " . $search_img_count_lj . $fav_lj . "WHERE i.date_exp > '" . $date_now . "' AND i.published=1 AND c.published=1 " . $where . $search;
     if ($search_fields) {
         $query .= " AND sf.item_id=i.id ";
     }
     $query .= $search_radius_h;
     $query .= " ) as i ";
     $db->setQuery($query);
     $items_count = $db->loadResult();
     //	echo '<pre>';print_r($db);print_r($items_count);echo '<pre>';die();
     return $items_count;
 }
Exemplo n.º 26
0
 public static function getItems($params)
 {
     $date_time = JFactory::getDate();
     $date_exp = $date_time->toSQL();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $ord = "i.date_start DESC";
     if ($params->get('items_ord') == 1) {
         $ord = "i.display DESC";
     } else {
         if ($params->get('items_ord') == 2) {
             $ord = "rand()";
         } else {
             if ($params->get('items_ord') == 3) {
                 $ord = "i.name";
             }
         }
     }
     $promoted = '';
     $prom_list = array();
     if ($params->get('only_p_special', '0') == 1) {
         $prom_list[] = " i.promotions LIKE '%p_special%' ";
     }
     if ($params->get('only_p_first', '0') == 1) {
         $prom_list[] = " i.promotions LIKE '%p_first%' ";
     }
     if ($params->get('only_p_bold', '0') == 1) {
         $prom_list[] = " i.promotions LIKE '%p_bold%' ";
     }
     if ($params->get('only_p_border', '0') == 1) {
         $prom_list[] = " i.promotions LIKE '%p_border%' ";
     }
     if ($params->get('only_p_bg', '0') == 1) {
         $prom_list[] = " i.promotions LIKE '%p_bg%' ";
     }
     if (count($prom_list) == 1) {
         $promoted = ' AND ' . $prom_list[0] . ' ';
     } else {
         if (count($prom_list) > 1) {
             $promoted = ' AND (' . implode(' OR ', $prom_list) . ') ';
         }
     }
     $item_ids = $params->get('items_ids', '');
     if ($item_ids) {
         $item_ids = ' AND i.id IN (' . $item_ids . ')';
     } else {
         $item_ids = '';
     }
     $users_ids = $params->get('users_ids', '');
     if ($users_ids) {
         $users_ids = ' AND i.user_id IN (' . $users_ids . ')';
     } else {
         $users_ids = '';
     }
     $types_ids_v = $params->get('type_id', '');
     $types_ids = '';
     if (is_array($types_ids_v)) {
         if (count($types_ids_v)) {
             $types_ids = ' AND i.type_id IN (' . implode(',', $types_ids_v) . ')';
         }
     }
     $cat_ids = $params->get('cat_id', '0');
     $cid = JRequest::getInt('cid', '0');
     $fallow_cat = '';
     $cat_list = '';
     if ($params->get('fallow_category') == 1 && JRequest::getVar('option', '') == 'com_djclassifieds' && $cid > 0) {
         $djcfcatlib = new DJClassifiedsCategory();
         $cats = $djcfcatlib->getSubCat($cid, 1);
         $catlist = $cid;
         foreach ($cats as $c) {
             $catlist .= ',' . $c->id;
         }
         $fallow_cat = ' AND i.cat_id IN (' . $catlist . ') ';
     } else {
         if (is_array($cat_ids)) {
             if (count($cat_ids) > 1) {
                 $cat_list = ' AND i.cat_id IN (' . implode(',', $cat_ids) . ') ';
             } else {
                 if (isset($cat_ids[0])) {
                     if ($cat_ids[0] > 0) {
                         $cat_list = ' AND i.cat_id = ' . $cat_ids[0] . ' ';
                     }
                 }
             }
         }
     }
     $reg_ids = $params->get('region_id', '0');
     $fallow_region = '';
     $region_list = '';
     if ($params->get('fallow_region', '0') == 1 && JRequest::getVar('option', '') == 'com_djclassifieds') {
         $djcfreglib = new DJClassifiedsRegion();
         if (JRequest::getVar('view', '') == 'item') {
             $id = JRequest::getInt('id', '0');
             $query = "SELECT i.region_id FROM #__djcf_items i " . "WHERE i.id=" . $id . " LIMIT 1";
             $db->setQuery($query);
             $region_id = $db->loadResult();
             if ($region_id) {
                 $regs = $djcfreglib->getSubReg($region_id);
                 $reglist = $region_id;
                 foreach ($regs as $r) {
                     $reglist .= ',' . $r->id;
                 }
                 $fallow_region = ' AND i.region_id IN (' . $reglist . ') ';
             }
         } else {
             if (JRequest::getVar('view', '') == 'items' && JRequest::getInt('se', '') == 1 && isset($_GET['se_regs'])) {
                 if (is_array($_GET['se_regs'])) {
                     $reg_id_se = end($_GET['se_regs']);
                     if ($reg_id_se == '' && count($_GET['se_regs']) > 2) {
                         $reg_id_se = $_GET['se_regs'][count($_GET['se_regs']) - 2];
                     }
                 } else {
                     $reg_ids_se = explode(',', JRequest::getVar('se_regs'));
                     $reg_id_se = end($reg_ids_se);
                 }
                 $reg_id_se = (int) $reg_id_se;
                 if ($reg_id_se) {
                     $regs = $djcfreglib->getSubReg($reg_id_se);
                     $reglist = $reg_id_se;
                     foreach ($regs as $r) {
                         $reglist .= ',' . $r->id;
                     }
                     $fallow_region = ' AND i.region_id IN (' . $reglist . ') ';
                 }
             }
         }
     }
     if (is_array($reg_ids) && $fallow_region == '') {
         if (count($reg_ids) > 1) {
             $region_list = ' AND i.region_id IN (' . implode(',', $reg_ids) . ') ';
         } else {
             if (isset($reg_ids[0])) {
                 if ($reg_ids[0] > 0) {
                     $region_list = ' AND i.region_id = ' . $reg_ids[0] . ' ';
                 }
             }
         }
     }
     $only_img = '';
     $search_img_count_lj = '';
     if ($params->get('only_with_img', '0') == 1) {
         //$only_img = " AND img.name !='' ";
         $only_img .= " AND img.img_c>0 ";
         $search_img_count_lj = "LEFT JOIN ( SELECT COUNT(img.id) as img_c, img.item_id FROM #__djcf_images img\r\n\t\t\t\t\t\t\t\t\tWHERE img.type='item' GROUP BY item_id ) img ON i.id=img.item_id ";
     }
     $source = '';
     $fav_lj = '';
     $fav_s = '';
     if ($user->id) {
         if ($params->get('items_source', '0') == 1) {
             $source = ' AND i.user_id=' . $user->id . ' ';
         } else {
             if ($params->get('items_source', '0') == 2) {
                 $fav_lj = "LEFT JOIN ( SELECT * FROM #__djcf_favourites WHERE user_id=" . $user->id . ") f ON i.id=f.item_id ";
                 $fav_s = ',f.id as f_id ';
                 $source = " AND f.id IS NOT NULL ";
             }
         }
     }
     $groups_acl = '0,' . implode(',', $user->getAuthorisedViewLevels());
     $access_view = " AND c.access_view IN (" . $groups_acl . ") ";
     $current_ad = '';
     if (JRequest::getVar('option', '') == 'com_djclassifieds' && JRequest::getVar('view', '') == 'item' && JRequest::getInt('id', 0) > 0) {
         $current_ad = ' AND i.id!=' . JRequest::getInt('id', 0) . ' ';
     }
     $adult_restriction = '';
     if (!isset($_COOKIE["djcf_warning18"])) {
         $adult_restriction .= " AND c.restriction_18=0 ";
     }
     $query = "SELECT i.*,c.id as c_id, c.name as c_name,c.alias as c_alias,c.icon_url as c_icon_url, r.name as r_name " . $fav_s . "FROM #__djcf_categories c, #__djcf_items i " . $search_img_count_lj . "LEFT JOIN #__djcf_regions r ON r.id=i.region_id " . $fav_lj . "WHERE i.date_exp > '" . $date_exp . "' AND i.published = 1 AND c.published = 1 AND i.cat_id=c.id " . $promoted . $item_ids . $users_ids . $fallow_cat . $cat_list . $fallow_region . $region_list . $types_ids . $only_img . $source . $access_view . $current_ad . $adult_restriction . "ORDER BY " . $ord . " limit " . $params->get('items_nr');
     $db->setQuery($query);
     $items = $db->loadObjectList();
     //echo '<pre>';print_r($db);die();
     if (count($items)) {
         $id_list = '';
         foreach ($items as $item) {
             if ($id_list) {
                 $id_list .= ',' . $item->id;
             } else {
                 $id_list .= $item->id;
             }
         }
         $items_img = DJClassifiedsImage::getAdsImages($id_list);
         for ($i = 0; $i < count($items); $i++) {
             $img_found = 0;
             $items[$i]->images = array();
             foreach ($items_img as $img) {
                 if ($items[$i]->id == $img->item_id) {
                     $img_found = 1;
                     $items[$i]->images[] = $img;
                 } else {
                     if ($img_found) {
                         break;
                     }
                 }
             }
         }
     }
     return $items;
 }