public function action_index() { //template header $this->template->title = ''; // $this->template->meta_keywords = 'keywords'; $this->template->meta_description = Core::config('general.site_description'); //setting main view/template and render pages // swith to decide on ads_in_home $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); switch (core::config('advertisement.ads_in_home')) { case 2: $id_ads = array_keys(Model_Visit::popular_ads()); if (count($id_ads) > 0) { $ads->where('id_ad', 'IN', $id_ads); } break; case 1: $ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc'); break; case 0: default: $ads->order_by('published', 'desc'); break; } //if ad have passed expiration time dont show if (core::config('advertisement.expire_date') > 0) { $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', DB::expr('NOW()')); } $ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all(); $this->ads = $ads; $categs = Model_Category::get_category_count(); $this->template->bind('content', $content); $this->template->content = View::factory('pages/home', array('ads' => $ads, 'categs' => $categs)); }
public function action_index() { 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'; } //template header $this->template->title = ''; // $this->template->meta_keywords = 'keywords'; if (core::config('general.site_description') != '') { $this->template->meta_description = core::config('general.site_description'); } else { $this->template->meta_description = core::config('general.site_name') . ' ' . __('official homepage, get your post listed now.'); } //setting main view/template and render pages // swith to decide on ads_in_home $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); $ads_in_home = core::config('advertisement.ads_in_home'); //in case we do not count visits we cant show popular if (core::config('advertisement.count_visits') == 0 and $ads_in_home == 2) { $ads_in_home = 0; } switch ($ads_in_home) { case 2: $id_ads = array_keys(Model_Visit::popular_ads()); if (count($id_ads) > 0) { $ads->where('id_ad', 'IN', $id_ads); } break; case 1: $ads->where('featured', 'IS NOT', NULL)->where('featured', '>=', Date::unix2mysql())->order_by('featured', 'desc'); break; case 4: $ads->where('featured', 'IS NOT', NULL)->where('featured', '>=', Date::unix2mysql())->order_by(DB::expr('RAND()')); break; case 0: default: $ads->order_by('published', 'desc'); break; } //if ad have passed expiration time dont show if (core::config('advertisement.expire_date') > 0) { $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql()); } $ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all(); $categs = Model_Category::get_category_count(); $locats = Model_Location::get_location_count(); $auto_locats = NULL; if (core::config('general.auto_locate') and Model_User::get_userlatlng()) { $auto_locats = new Model_Location(); $auto_locats = $auto_locats->select(array(DB::expr('degrees(acos(sin(radians(' . $_COOKIE['mylat'] . ')) * sin(radians(`latitude`)) + cos(radians(' . $_COOKIE['mylat'] . ')) * cos(radians(`latitude`)) * cos(radians(abs(' . $_COOKIE['mylng'] . ' - `longitude`))))) * 111.321'), 'distance'))->where('latitude', 'IS NOT', NULL)->where('longitude', 'IS NOT', NULL)->having('distance', '<=', '100')->order_by('distance', 'desc')->find_all()->as_array(); } $this->template->bind('content', $content); $this->template->content = View::factory('pages/home', array('ads' => $ads, 'categs' => $categs, 'locats' => $locats, 'auto_locats' => $auto_locats)); }
public function action_index() { //template header $this->template->title = ''; // $this->template->meta_keywords = 'keywords'; $this->template->meta_description = Core::config('general.site_name') . ' ' . __('official homepage for the online store'); $products = new Model_Product(); $products->where('status', '=', Model_Product::STATUS_ACTIVE); switch (core::config('product.products_in_home')) { case 3: $id_products = Model_Review::best_rated(); $array_ids = array(); foreach ($id_products as $id => $id_product) { $array_ids = $id_product; } if (count($id_products) > 0) { $products->where('id_product', 'IN', $array_ids); } break; case 2: $id_products = array_keys(Model_Visit::popular_products()); if (count($id_products) > 0) { $products->where('id_product', 'IN', $id_products); } break; case 1: $products->where('featured', 'IS NOT', NULL)->where('featured', '>', Date::unix2mysql())->order_by('featured', 'desc'); break; case 0: default: $products->order_by('created', 'desc'); break; } $products = $products->limit(Theme::get('num_home_products', 21))->cached()->find_all(); $categs = Model_Category::get_category_count(); $this->template->bind('content', $content); $this->template->content = View::factory('pages/home', array('products' => $products, 'categs' => $categs)); }
?> </div> </div> </div> </div> <!-- end navbar top--> <div class="subnav navbar <?php echo (Request::current()->controller() !== 'faq' and Theme::get('fixed_toolbar') == 1) ? '' : 'fixed_header'; ?> "> <div class="container"> <ul class="nav nav-pills"> <?php $cats = Model_Category::get_category_count(); $cat_id = NULL; $cat_parent = NULL; if (Model_Category::current()->loaded()) { $cat_id = Model_Category::current()->id_category; $cat_parent = Model_Category::current()->id_category_parent; } ?> <?php foreach ($cats as $c) { ?> <?php if ($c['id_category_parent'] == 1 && $c['has_siblings'] == FALSE) { ?> <li class="<?php echo $c['id_category'] == $cat_id ? 'active' : '';
public function action_index() { if (core::config('general.auto_locate')) { if ($user_location = Core::post('user_location')) { Cookie::set('user_location', $user_location); $this->auto_render = FALSE; $this->template = View::factory('js'); $this->template->content = TRUE; return; } elseif (Core::get('user_location') == '0') { Cookie::delete('user_location'); } Theme::$scripts['async_defer'][] = '//maps.google.com/maps/api/js?libraries=geometry&v=3&key=' . core::config("advertisement.gm_api_key") . '&callback=initAutoLocate'; } //template header $this->template->title = ''; // $this->template->meta_keywords = 'keywords'; if (core::config('general.site_description') != '') { $this->template->meta_description = core::config('general.site_description'); } else { $this->template->meta_description = core::config('general.site_name') . ' ' . __('official homepage, get your post listed now.'); } //setting main view/template and render pages // get user location if any $user_location = NULL; if (is_numeric($user_id_location = Cookie::get('user_location'))) { $user_location = new Model_Location($user_id_location); if (!$user_location->loaded()) { $user_location = NULL; } } // swith to decide on ads_in_home $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); if ($user_location) { $ads->where('id_location', 'in', $user_location->get_siblings_ids()); } $ads_in_home = core::config('advertisement.ads_in_home'); //in case we do not count visits we cant show popular if (core::config('advertisement.count_visits') == 0 and $ads_in_home == 2) { $ads_in_home = 0; } switch ($ads_in_home) { case 2: $id_ads = array_keys(Model_Visit::popular_ads()); if (count($id_ads) > 0) { $ads->where('id_ad', 'IN', $id_ads); } break; case 1: $ads->where('featured', 'IS NOT', NULL)->where('featured', '>=', Date::unix2mysql())->order_by('featured', 'desc'); break; case 4: $ads->where('featured', 'IS NOT', NULL)->where('featured', '>=', Date::unix2mysql())->order_by(DB::expr('RAND()')); break; case 0: default: $ads->order_by('published', 'desc'); break; } //if ad have passed expiration time dont show if (core::config('advertisement.expire_date') > 0) { $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql()); } $ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all(); $categs = Model_Category::get_category_count(TRUE, $user_location); $hide_categories = json_decode(Core::config('general.hide_homepage_categories'), TRUE); $auto_locats = NULL; $auto_location_distance = Core::config('general.measurement') == 'imperial' ? Num::round(Core::config('advertisement.auto_locate_distance') * 1.60934) : Core::config('advertisement.auto_locate_distance'); if (core::config('general.auto_locate') and !isset($_COOKIE['cancel_auto_locate']) and Model_User::get_userlatlng()) { $auto_locats = new Model_Location(); $auto_locats = $auto_locats->select(array(DB::expr('degrees(acos(sin(radians(' . $_COOKIE['mylat'] . ')) * sin(radians(`latitude`)) + cos(radians(' . $_COOKIE['mylat'] . ')) * cos(radians(`latitude`)) * cos(radians(abs(' . $_COOKIE['mylng'] . ' - `longitude`))))) * 111.321'), 'distance'))->where('latitude', 'IS NOT', NULL)->where('longitude', 'IS NOT', NULL)->having('distance', '<=', $auto_location_distance)->order_by('distance', 'asc')->find_all()->as_array(); } $this->template->bind('content', $content); $this->template->content = View::factory('pages/home', compact('ads', 'categs', 'auto_locats', 'user_location', 'hide_categories')); }