예제 #1
0
 public function action_index()
 {
     $this->auto_render = FALSE;
     $info = array('title' => 'RSS ' . htmlspecialchars(Core::config('general.site_name')), 'pubDate' => date("r"), 'description' => __('Latest published'), 'generator' => 'Open Classifieds');
     $items = array();
     //last ads, you can modify this value at: advertisement.feed_elements
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED)->order_by('published', 'desc')->limit(Core::config('advertisement.feed_elements'));
     //filter by category aor location
     if (Model_Category::current()->loaded()) {
         $ads->where('id_category', '=', Model_Category::current()->id_category);
     }
     if (Model_Location::current()->loaded()) {
         $ads->where('id_location', '=', Model_Location::current()->id_location);
     }
     $ads = $ads->cached()->find_all();
     foreach ($ads as $a) {
         $url = Route::url('ad', array('category' => $a->category->seoname, 'seotitle' => $a->seotitle));
         $item = array('title' => htmlspecialchars($a->title, ENT_QUOTES), 'link' => $url, 'pubDate' => Date::mysql2unix($a->published), 'description' => htmlspecialchars(Text::removebbcode($a->description), ENT_QUOTES), 'guid' => $url);
         if ($a->get_first_image() !== NULL) {
             $item['description'] = '<img src="' . $a->get_first_image() . '" />' . $item['description'];
         }
         $items[] = $item;
     }
     $xml = Feed::create($info, $items);
     $this->response->headers('Content-type', 'text/xml');
     $this->response->body($xml);
 }
예제 #2
0
 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     // get all categories
     if ($this->advanced != FALSE) {
         $this->cat_items = Model_Category::get_as_array();
         $this->cat_order_items = Model_Category::get_multidimensional();
         $this->selected_category = NULL;
         if (core::request('category')) {
             $this->selected_category = core::request('category');
         } elseif (Model_Category::current()->loaded()) {
             $this->selected_category = core::config('general.search_multi_catloc') ? array(Model_Category::current()->seoname) : Model_Category::current()->seoname;
         }
         // get all locations
         $this->loc_items = Model_Location::get_as_array();
         $this->loc_order_items = Model_Location::get_multidimensional();
         $this->selected_location = NULL;
         if (core::request('location')) {
             $this->selected_location = core::request('location');
         } elseif (Model_Location::current()->loaded()) {
             $this->selected_location = core::config('general.search_multi_catloc') ? array(Model_Location::current()->seoname) : Model_Location::current()->seoname;
         }
     }
     if ($this->custom != FALSE) {
         $fields = Model_Field::get_all();
         $this->custom_fields = $fields;
     }
 }
예제 #3
0
 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     $loc = new Model_Location();
     // loaded locations
     if (Model_Location::current()->loaded()) {
         $location = Model_Location::current()->id_location;
         // id_location
         //list of children of current location
         // if list_loc dosent have siblings take brothers //
         $list_loc = $loc->where('id_location_parent', '=', $location)->order_by('order', 'asc')->cached()->find_all();
         if (count($list_loc) == 0) {
             $list_loc = $loc->where('id_location_parent', '=', Model_Location::current()->id_location_parent)->order_by('order', 'asc')->cached()->find_all();
         }
         //parent of current location
         $loc_parent_deep = $loc->where('id_location', '=', Model_Location::current()->id_location_parent)->limit(1)->find();
         // array with name and seoname of a location and his parent. Is to build breadcrumb in widget
         $current_and_parent = array('name' => Model_Location::current()->name, 'id' => Model_Location::current()->id_location, 'seoname' => Model_Location::current()->seoname, 'parent_name' => $loc_parent_deep->name, 'id_parent' => $loc_parent_deep->id_location_parent, 'parent_seoname' => $loc_parent_deep->seoname);
     } else {
         $list_loc = $loc->where('id_location_parent', '=', 1)->order_by('order', 'asc')->cached()->find_all();
         $current_and_parent = NULL;
     }
     $this->locations = $this->locations;
     $this->loc_items = $list_loc;
     $this->loc_breadcrumb = $current_and_parent;
     $this->cat_seoname = URL::title(__('all'));
     if (Model_Category::current()->loaded()) {
         $this->cat_seoname = Model_Category::current()->seoname;
     }
 }
예제 #4
0
 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     $cat = new Model_Category();
     // loaded category
     if (Model_Category::current()->loaded()) {
         $category = Model_Category::current()->id_category;
         // id_category
         //list of children of current category
         // if list_cat dosent have siblings take brothers
         $list_cat = $cat->where('id_category_parent', '=', $category)->order_by('order', 'asc')->cached()->find_all();
         if (count($list_cat) == 0) {
             $list_cat = $cat->where('id_category_parent', '=', Model_Category::current()->id_category_parent)->order_by('order', 'asc')->cached()->find_all();
         }
         //parent of current category
         $cat_parent_deep = $cat->where('id_category', '=', Model_Category::current()->id_category_parent)->limit(1)->find();
         // array with name and seoname of a category and his parent. Is to build breadcrumb in widget
         $current_and_parent = array('name' => Model_Category::current()->name, 'id' => Model_Category::current()->id_category, 'seoname' => Model_Category::current()->seoname, 'parent_name' => $cat_parent_deep->name, 'id_parent' => $cat_parent_deep->id_category_parent, 'parent_seoname' => $cat_parent_deep->seoname);
     } else {
         $list_cat = $cat->where('id_category_parent', '=', 1)->order_by('order', 'asc')->cached()->find_all();
         $current_and_parent = NULL;
     }
     $this->cat_items = $list_cat;
     $this->cat_breadcrumb = $current_and_parent;
     $this->loc_seoname = NULL;
     if (Model_Location::current()->loaded()) {
         if (Model_Location::current()->id_location != 1) {
             $this->loc_seoname = Model_Location::current()->seoname;
         }
     }
 }
예제 #5
0
 /**
  * gets the fragment name, unique using i18n theme and skin and cat and loc
  * @param  string $name 
  * @return string       
  */
 public static function fragment_name($name)
 {
     $cat_seoname = '';
     if (Model_Category::current()->loaded()) {
         $cat_seoname = '_category_' . Model_Category::current()->seoname;
     }
     $loc_seoname = '';
     if (Model_Location::current()->loaded()) {
         $loc_seoname = '_location_' . Model_Location::current()->seoname;
     }
     return 'fragment_' . $name . '_' . i18n::lang() . '_' . Theme::$theme . $cat_seoname . $loc_seoname;
     //.Theme::$skin
 }
예제 #6
0
 /**
  * Initialize properties before running the controller methods (actions),
  * so they are available to our action.
  */
 public function before($template = NULL)
 {
     parent::before();
     Theme::checker();
     $this->maintenance();
     $this->private_site();
     /**
      * selected category
      */
     self::$category = Model_Category::current();
     /**
      * selected location
      */
     self::$location = Model_Location::current();
     //Gets a coupon if selected
     Model_Coupon::current();
     if ($this->auto_render === TRUE) {
         // Load the template
         if ($template !== NULL) {
             $this->template = $template;
         }
         $this->template = View::factory($this->template);
         // Initialize template values
         $this->template->title = core::config('general.site_name');
         $this->template->meta_keywords = '';
         $this->template->meta_description = '';
         $this->template->meta_copyright = 'Open Classifieds ' . Core::VERSION;
         $this->template->meta_copywrite = $this->template->meta_copyright;
         //legacy for old themes
         $this->template->content = '';
         $this->template->styles = array();
         $this->template->scripts = array();
         $this->template->amphtml = NULL;
         $this->template->header = View::factory('header');
         $this->template->footer = View::factory('footer');
         // header_front_login fragment since CSRF gets cached :(
         // possible workaround ? @see http://kohanaframework.org/3.0/guide/kohana/fragments
         // if (Auth::instance()->logged_in())
         //     $this->template->header  = View::fragment('header_front_login','header');
         // else
         //     $this->template->header  = View::fragment('header_front','header');
         //$this->template->footer = View::fragment('footer_front','footer');
     }
 }
예제 #7
0
<?php 
if (count($ads)) {
    ?>
    <div class="btn-group pull-right">
        <?php 
    if (core::config('advertisement.map') == 1) {
        ?>
            <a href="<?php 
        echo Route::url('map');
        ?>
?category=<?php 
        echo Model_Category::current()->loaded() ? Model_Category::current()->seoname : NULL;
        ?>
&location=<?php 
        echo Model_Location::current()->loaded() ? Model_Location::current()->seoname : NULL;
        ?>
" 
                class="btn btn-default btn-sm <?php 
        echo core::cookie('list/grid') == 0 ? 'active' : '';
        ?>
">
                <span class="glyphicon glyphicon-globe"></span> <?php 
        echo __('Map');
        ?>
            </a>
        <?php 
    }
    ?>
        <button type="button" id="sort" data-sort="<?php 
    echo core::request('sort');
예제 #8
0
    ?>
 - <?php 
    echo Model_Location::current()->name;
    ?>
"  href="<?php 
    echo Route::url('rss', array('category' => Model_Category::current()->seoname, 'location' => Model_Location::current()->seoname));
    ?>
" />
<?php 
} elseif (Model_Location::current()->loaded()) {
    ?>
<link rel="alternate" type="application/atom+xml"  title="RSS <?php 
    echo HTML::chars(Core::config('general.site_name') . ' - ' . Model_Location::current()->name);
    ?>
"  href="<?php 
    echo Route::url('rss', array('category' => URL::title(__('all')), 'location' => Model_Location::current()->seoname));
    ?>
" />
<?php 
} elseif (Model_Category::current()->loaded()) {
    ?>
<link rel="alternate" type="application/atom+xml"  title="RSS <?php 
    echo HTML::chars(Core::config('general.site_name') . ' - ' . Model_Category::current()->name);
    ?>
"  href="<?php 
    echo Route::url('rss', array('category' => Model_Category::current()->seoname));
    ?>
" />
<?php 
}
?>
예제 #9
0
 /**
  * Publis all adver.-s without filter
  */
 public function action_listing()
 {
     if (Theme::get('infinite_scroll')) {
         $this->template->scripts['footer'][] = '//cdn.jsdelivr.net/jquery.infinitescroll/2.0b2/jquery.infinitescroll.js';
         $this->template->scripts['footer'][] = 'js/listing.js';
     }
     if (core::config('general.auto_locate')) {
         Theme::$scripts['footer'][] = '//maps.google.com/maps/api/js?sensor=false&libraries=geometry&v=3.7';
         Theme::$scripts['footer'][] = '//cdn.jsdelivr.net/gmaps/0.4.15/gmaps.min.js';
     }
     $this->template->scripts['footer'][] = 'js/jquery.toolbar.js';
     $this->template->scripts['footer'][] = 'js/sort.js';
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
     /**
      * we get the model of category and location from controller to filter and generate urls titles etc...
      */
     $location = NULL;
     $location_parent = NULL;
     $location_name = NULL;
     if (Model_Location::current()->loaded()) {
         $location = Model_Location::current();
         if ($location->id_location != 1) {
             $location_name = $location->name;
         }
         //adding the location parent
         if ($location->id_location_parent != 1 and $location->parent->loaded()) {
             $location_parent = $location->parent;
         }
     }
     $category = NULL;
     $category_parent = NULL;
     $category_name = NULL;
     if (Model_Category::current()->loaded()) {
         $category = Model_Category::current();
         if ($category->id_category != 1) {
             $category_name = $category->name;
         }
         //adding the category parent
         if ($category->id_category_parent != 1 and $category->parent->loaded()) {
             $category_parent = $category->parent;
         }
     }
     //base title
     if ($category !== NULL) {
         //category image
         if (($icon_src = $category->get_icon()) !== FALSE) {
             Controller::$image = $icon_src;
         }
         $this->template->title = $category_name;
         if ($category->description != '') {
             $this->template->meta_description = $category->description;
         } else {
             $this->template->meta_description = __('All') . ' ' . $category_name . ' ' . __('in') . ' ' . core::config('general.site_name');
         }
     } else {
         $this->template->title = __('all');
         if ($location !== NULL) {
             if ($location->description != '') {
                 $this->template->meta_description = $location->description;
             } else {
                 $this->template->meta_description = __('List of all postings in') . ' ' . $location_name;
             }
         } else {
             $this->template->meta_description = __('List of all postings in') . ' ' . core::config('general.site_name');
         }
     }
     //adding location titles and breadcrumbs
     if ($location !== NULL) {
         //in case we dont have the category image we use the location
         if (($icon_src = $location->get_icon()) !== FALSE and Controller::$image === NULL) {
             Controller::$image = $icon_src;
         }
         $this->template->title .= ' - ' . $location->name;
         if ($location_parent !== NULL) {
             $this->template->title .= ' (' . $location_parent->name . ')';
             Breadcrumbs::add(Breadcrumb::factory()->set_title($location_parent->name)->set_url(Route::url('list', array('location' => $location_parent->seoname))));
         }
         Breadcrumbs::add(Breadcrumb::factory()->set_title($location->name)->set_url(Route::url('list', array('location' => $location->seoname))));
         if ($category_parent !== NULL) {
             Breadcrumbs::add(Breadcrumb::factory()->set_title($category_parent->name)->set_url(Route::url('list', array('category' => $category_parent->seoname, 'location' => $location->seoname))));
         }
         if ($category !== NULL) {
             Breadcrumbs::add(Breadcrumb::factory()->set_title($category->name)->set_url(Route::url('list', array('category' => $category->seoname, 'location' => $location->seoname))));
         }
     } else {
         if ($category_parent !== NULL) {
             $this->template->title .= ' (' . $category_parent->name . ')';
             Breadcrumbs::add(Breadcrumb::factory()->set_title($category_parent->name)->set_url(Route::url('list', array('category' => $category_parent->seoname))));
         }
         if ($category !== NULL) {
             Breadcrumbs::add(Breadcrumb::factory()->set_title($category->name)->set_url(Route::url('list', array('category' => $category->seoname))));
         }
     }
     $data = $this->list_logic($category, $location);
     $this->template->bind('content', $content);
     $this->template->content = View::factory('pages/ad/listing', $data);
 }
예제 #10
0
 /**
  * counts how many ads have each category
  * @param  boolean $location_filter filters by location 
  * @param  Model_Location $location 
  * @return array
  */
 public static function get_category_count($location_filter = TRUE, $location = NULL)
 {
     //cache by location
     if ($location_filter === TRUE and $location and $location->loaded()) {
         $id_location = $location->id_location;
     } elseif ($location_filter === TRUE and Model_Location::current()->loaded()) {
         $id_location = Model_Location::current()->id_location;
     } else {
         $id_location = 'all';
     }
     //name used in the cache for storage
     $cache_name = 'get_category_count_' . $id_location;
     if (($cats_count = Core::cache($cache_name)) === NULL) {
         $expr_date = is_numeric(core::config('advertisement.expire_date')) ? core::config('advertisement.expire_date') : 0;
         $db_prefix = Database::instance('default')->table_prefix();
         //get the categories that have ads id_category->num ads
         $count_ads = DB::select('c.id_category', array(DB::expr('COUNT("a.id_ad")'), 'count'))->from(array('categories', 'c'))->join(array('ads', 'a'))->using('id_category')->where('a.id_category', '=', DB::expr($db_prefix . 'c.id_category'))->where(DB::expr('IF(' . $expr_date . ' <> 0, DATE_ADD( published, INTERVAL ' . $expr_date . ' DAY), DATE_ADD( NOW(), INTERVAL 1 DAY))'), '>', Date::unix2mysql())->where('a.status', '=', Model_Ad::STATUS_PUBLISHED);
         //filter the count by location
         if ($location_filter === TRUE and $location and $location->loaded()) {
             $count_ads = $count_ads->where('a.id_location', 'in', $location->get_siblings_ids());
         } elseif ($location_filter === TRUE and Model_Location::current()->loaded()) {
             $count_ads = $count_ads->where('a.id_location', 'in', Model_Location::current()->get_siblings_ids());
         }
         $count_ads = $count_ads->group_by('c.id_category')->order_by('c.order', 'asc')->cached()->execute();
         $count_ads = $count_ads->as_array('id_category');
         //getting the count of ads into the parents
         $parents_count = array();
         foreach ($count_ads as $count_ad) {
             $id_category = $count_ad['id_category'];
             $count = $count_ad['count'];
             //adding himself if doesnt exists
             if (!isset($parents_count[$id_category])) {
                 $parents_count[$id_category] = $count_ad;
                 $parents_count[$id_category]['has_siblings'] = FALSE;
             }
             $category = new Model_Category($id_category);
             //for each parent of this category add the count
             $parents_ids = $category->get_parents_ids();
             if (count($parents_ids) > 0) {
                 foreach ($parents_ids as $id) {
                     if (isset($parents_count[$id])) {
                         $parents_count[$id]['count'] += $count_ads[$category->id_category]['count'];
                     } else {
                         $parents_count[$id]['count'] = $count_ads[$category->id_category]['count'];
                     }
                     $parents_count[$id]['has_siblings'] = TRUE;
                 }
             }
         }
         //get all the categories with level 0 and 1
         $categories = new self();
         $categories = $categories->where('id_category', '!=', 1)->where('parent_deep', 'IN', array(0, 1))->order_by('order', 'asc')->cached()->find_all();
         //generating the array
         $cats_count = array();
         foreach ($categories as $category) {
             $has_siblings = isset($parents_count[$category->id_category]) ? $parents_count[$category->id_category]['has_siblings'] : FALSE;
             //they may not have counted the siblings since the count was 0 but he actually has siblings...
             if ($has_siblings === FALSE and $category->has_siblings()) {
                 $has_siblings = TRUE;
             }
             $cats_count[$category->id_category] = $category->as_array();
             $cats_count[$category->id_category] = array('id_category' => $category->id_category, 'seoname' => $category->seoname, 'name' => $category->name, 'id_category_parent' => $category->id_category_parent, 'parent_deep' => $category->parent_deep, 'order' => $category->order, 'price' => $category->price, 'has_siblings' => $has_siblings, 'count' => isset($parents_count[$category->id_category]) ? $parents_count[$category->id_category]['count'] : 0);
         }
         //cache the result is expensive!
         Core::cache($cache_name, $cats_count);
     }
     return $cats_count;
 }
예제 #11
0
 /**
  * Publis all adver.-s without filter
  */
 public function action_listing()
 {
     if (Theme::get('infinite_scroll')) {
         $this->template->scripts['footer'][] = '//cdn.jsdelivr.net/jquery.infinitescroll/2.0b2/jquery.infinitescroll.js';
         $this->template->scripts['footer'][] = 'js/listing.js';
     }
     if (core::config('general.auto_locate') or core::config('advertisement.map')) {
         Theme::$scripts['async_defer'][] = '//maps.google.com/maps/api/js?libraries=geometry,places&v=3&key=' . core::config("advertisement.gm_api_key") . '&callback=initLocationsGMap';
     }
     $this->template->scripts['footer'][] = 'js/jquery.toolbar.js';
     $this->template->scripts['footer'][] = 'js/sort.js';
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
     /**
      * we get the model of category and location from controller to filter and generate urls titles etc...
      */
     $location = NULL;
     $location_parent = NULL;
     $location_name = NULL;
     if (Model_Location::current()->loaded()) {
         $location = Model_Location::current();
         if ($location->id_location != 1) {
             $location_name = $location->name;
         }
         //adding the location parent
         if ($location->id_location_parent != 1 and $location->parent->loaded()) {
             $location_parent = $location->parent;
         }
     }
     $category = NULL;
     $category_parent = NULL;
     $category_name = NULL;
     if (Model_Category::current()->loaded()) {
         $category = Model_Category::current();
         if ($category->id_category != 1) {
             $category_name = $category->name;
         }
         //adding the category parent
         if ($category->id_category_parent != 1 and $category->parent->loaded()) {
             $category_parent = $category->parent;
         }
     }
     //base title
     if ($category !== NULL) {
         //category image
         if (($icon_src = $category->get_icon()) !== FALSE) {
             Controller::$image = $icon_src;
         }
         $this->template->title = $category_name;
         if ($category->description != '') {
             $this->template->meta_description = $category->description;
         } else {
             $this->template->meta_description = __('All') . ' ' . $category_name . ' ' . __('in') . ' ' . core::config('general.site_name');
         }
     } else {
         $this->template->title = __('all');
         if ($location !== NULL) {
             if ($location->description != '') {
                 $this->template->meta_description = $location->description;
             } else {
                 $this->template->meta_description = __('List of all postings in') . ' ' . $location_name;
             }
         } else {
             $this->template->meta_description = __('List of all postings in') . ' ' . core::config('general.site_name');
         }
     }
     //adding location titles and breadcrumbs
     if ($location !== NULL) {
         //in case we dont have the category image we use the location
         if (($icon_src = $location->get_icon()) !== FALSE and Controller::$image === NULL) {
             Controller::$image = $icon_src;
         }
         $this->template->title .= ' - ' . $location->name;
         if ($location_parent !== NULL) {
             $this->template->title .= ' (' . $location_parent->name . ')';
             Breadcrumbs::add(Breadcrumb::factory()->set_title($location_parent->name)->set_url(Route::url('list', array('location' => $location_parent->seoname))));
         }
         Breadcrumbs::add(Breadcrumb::factory()->set_title($location->name)->set_url(Route::url('list', array('location' => $location->seoname))));
         if ($category_parent !== NULL) {
             Breadcrumbs::add(Breadcrumb::factory()->set_title($category_parent->name)->set_url(Route::url('list', array('category' => $category_parent->seoname, 'location' => $location->seoname))));
         }
         if ($category !== NULL) {
             Breadcrumbs::add(Breadcrumb::factory()->set_title($category->name)->set_url(Route::url('list', array('category' => $category->seoname, 'location' => $location->seoname))));
         }
     } else {
         if ($category_parent !== NULL) {
             $this->template->title .= ' (' . $category_parent->name . ')';
             Breadcrumbs::add(Breadcrumb::factory()->set_title($category_parent->name)->set_url(Route::url('list', array('category' => $category_parent->seoname))));
         }
         if ($category !== NULL) {
             Breadcrumbs::add(Breadcrumb::factory()->set_title($category->name)->set_url(Route::url('list', array('category' => $category->seoname))));
         }
     }
     $data = $this->list_logic($category, $location);
     //if home page is the listing
     if (($landing = json_decode(core::config('general.landing_page'))) != NULL and $landing->controller == 'ad' and $landing->action == 'listing' and (isset($data['pagination']) and $data['pagination']->current_page == 1) and $location === NULL and $category === NULL) {
         //only show site title
         $this->template->title = NULL;
         // if we have site description lets use that ;)
         if (core::config('general.site_description') != '') {
             $this->template->meta_description = core::config('general.site_description');
         }
     }
     $this->template->bind('content', $content);
     $this->template->content = View::factory('pages/ad/listing', $data);
 }
예제 #12
0
?>
" alt="<?php 
echo HTML::chars(core::config('general.site_name'));
?>
">
                <h1><?php 
echo core::config('general.site_name');
?>
</h1>
            </a>

            <?php 
$cats = Model_Category::get_category_count();
$loc_seoname = NULL;
if (Model_Location::current()->loaded()) {
    $loc_seoname = Model_Location::current()->seoname;
}
?>
	    
			<div class="collapse navbar-collapse navbar-right" id="mobile-menu-panel">
				<ul class="nav navbar-nav">
					<?php 
echo Theme::nav_link(__('Listing'), 'ad', '', 'listing', 'list');
?>
					<li class="nav-dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php 
echo __('Categories');
?>
 <b class="caret"></b></a>
						<ul class="dropdown-menu">
						<?php 
예제 #13
0
 public function action_index()
 {
     $this->auto_render = FALSE;
     $info = array('title' => 'RSS ' . htmlspecialchars(Core::config('general.site_name'), ENT_QUOTES), 'pubDate' => date("r"), 'description' => htmlspecialchars(__('Latest published'), ENT_QUOTES), 'generator' => 'Yclas');
     $items = array();
     //last ads, you can modify this value at: advertisement.feed_elements
     $ads = new Model_Ad();
     //only published ads
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
     //filter by category aor location
     if (Model_Category::current()->loaded()) {
         $ads->where('id_category', '=', Model_Category::current()->id_category);
     }
     if (Model_Location::current()->loaded()) {
         $ads->where('id_location', '=', Model_Location::current()->id_location);
     }
     //order depending on the sort parameter
     switch (core::request('sort', core::config('advertisement.sort_by'))) {
         //title z->a
         case 'title-asc':
             $ads->order_by('title', 'asc')->order_by('published', 'desc');
             break;
             //title a->z
         //title a->z
         case 'title-desc':
             $ads->order_by('title', 'desc')->order_by('published', 'desc');
             break;
             //cheaper first
         //cheaper first
         case 'price-asc':
             $ads->order_by('price', 'asc')->order_by('published', 'desc');
             break;
             //expensive first
         //expensive first
         case 'price-desc':
             $ads->order_by('price', 'desc')->order_by('published', 'desc');
             break;
             //featured
         //featured
         case 'featured':
             $ads->order_by('featured', 'desc')->order_by('published', 'desc');
             break;
             //rating
         //rating
         case 'rating':
             $ads->order_by('rate', 'desc')->order_by('published', 'desc');
             break;
             //favorited
         //favorited
         case 'favorited':
             $ads->order_by('favorited', 'desc')->order_by('published', 'desc');
             break;
             //oldest first
         //oldest first
         case 'published-asc':
             $ads->order_by('published', 'asc');
             break;
             //newest first
         //newest first
         case 'published-desc':
         default:
             $ads->order_by('published', 'desc');
             break;
     }
     $ads = $ads->limit(Core::config('advertisement.feed_elements'))->cached()->find_all();
     foreach ($ads as $a) {
         $url = Route::url('ad', array('category' => $a->category->seoname, 'seotitle' => $a->seotitle));
         $item = array('title' => htmlspecialchars($a->title, ENT_QUOTES), 'link' => $url, 'pubDate' => Date::mysql2unix($a->published), 'description' => htmlspecialchars(Text::removebbcode($a->description), ENT_QUOTES), 'guid' => $url);
         if ($a->get_first_image() !== NULL) {
             $item['description'] = '<img src="' . $a->get_first_image() . '" />' . $item['description'];
         }
         $items[] = $item;
     }
     $xml = Feed::create($info, $items);
     $this->response->headers('Content-type', 'text/xml');
     $this->response->body($xml);
 }
예제 #14
0
    ?>
    <div class="panel-heading">
        <h3 class="panel-title"><?php 
    echo $widget->map_title;
    ?>
</h3>
    </div>
<?php 
}
?>

<div class="panel-body">
    <iframe frameborder="0" noresize="noresize" 
            height="<?php 
echo $widget->map_height + $widget->map_height * 0.1;
?>
px" width="100%" 
            src="<?php 
echo Route::url('map');
?>
?height=<?php 
echo $widget->map_height;
?>
&controls=0&zoom=<?php 
echo $widget->map_zoom;
echo Model_Category::current()->loaded() ? '&category=' . Model_Category::current()->seoname : '';
echo Model_Location::current()->loaded() ? '&location=' . Model_Location::current()->seoname : '';
?>
">
    </iframe>
</div>