当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_Ad类代码示例

本文整理汇总了PHP中Model_Ad的典型用法代码示例。如果您正苦于以下问题:PHP Model_Ad类的具体用法?PHP Model_Ad怎么用?PHP Model_Ad使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Model_Ad类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: feedAction

 public function feedAction()
 {
     $woeid = $this->_request->getParam('woeid');
     $ad_type = $this->_request->getParam('ad_type');
     $status = $this->_request->getParam('status');
     $modelAd = new Model_Ad();
     $this->ads = $modelAd->getAdList($woeid, $ad_type, $status, 35);
     $rss['title'] = $this->view->translate($ad_type) . ' ' . $this->view->translate((string) $status) . ' - ' . $this->_helper->woeid->name($woeid, $this->lang) . ' | nolotiro.org';
     $rss['link'] = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->lang . '/rss/feed/woeid/' . $woeid . '/ad_type/' . $ad_type . '/status/' . $status;
     $rss['charset'] = 'utf-8';
     $rss['description'] = 'nolotiro.org - ' . $this->_helper->woeid->name($woeid, $this->lang);
     $rss['language'] = $this->lang;
     $rss['generator'] = 'nolotiro.org';
     $rss['entries'] = array();
     foreach ($this->ads as $value) {
         $entry = array();
         $entry['title'] = $value['title'];
         $entry['link'] = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->lang . '/ad/' . $value['id'] . '/' . $this->view->slugTitle($value['title']);
         $entry['description'] = $this->view->escapeEmail($value['body']);
         $entry['lastUpdate'] = strtotime($value['date_created']);
         $rss['entries'][] = $entry;
     }
     $feedObj = Zend_Feed::importArray($rss, 'rss');
     return $feedObj->send();
 }
开发者ID:Arteaga2k,项目名称:nolotiro,代码行数:25,代码来源:RssController.php

示例2: indexAction

 public function indexAction()
 {
     $this->_helper->layout()->setLayout('home');
     $this->view->suggestIP = $this->_helper->getLocationGeoIP->suggest();
     //check if user is locked
     $locked = $this->_helper->checkLockedUser->check();
     if ($locked == 1) {
         $this->_redirect('/' . $this->view->lang . '/auth/logout');
     }
     //if user is logged the redir to proper location, if not stand on not logged home view (index)
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $this->_redirect('/' . $this->view->lang . '/woeid/' . $this->location . '/give');
     }
     //check if request is / redir to /lang
     $langIndex = $this->getRequest()->getParam('language');
     if ($langIndex == null) {
         //add meta robots to not index the page without language param but allow follow-crawl all the rest
         //$this->view->metaRobots = 'noindex,follow';
         //force redirect with language
         $this->_redirect('/es', array('code' => 301));
     } else {
         $this->view->metaRobots = 'index,follow';
     }
     //add link rel canonical , better seo
     $this->view->canonicalUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->lang;
     $modelAd = new Model_Ad();
     $this->view->allGives = $modelAd->getAdListAllHome(1, null);
     $this->view->rankingWoeid = $modelAd->getRankingWoeid($limit = 40);
     $this->view->rankingUsers = $modelAd->getRankingUsers($limit = 80);
     //add meta description to head
     $this->view->metaDescription = $this->view->translate('nolotiro.org is a website where you can give away things you no longer want or no longer need to pick them up other people who may serve or be of much use.');
 }
开发者ID:Arteaga2k,项目名称:nolotiro,代码行数:33,代码来源:IndexController.php

示例3: before

 /**
  * 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()
 {
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
     $ads->where('featured', 'IS NOT', NULL)->where('featured', '>', Date::unix2mysql())->order_by('featured', 'desc');
     $ads = $ads->limit($this->ads_limit)->find_all();
     $this->ads = $ads;
 }
开发者ID:zhangkom,项目名称:openclassifieds2,代码行数:14,代码来源:featured.php

示例4: before

 /**
  * 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()
 {
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
     $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');
     $ads = $ads->limit($this->ads_limit)->cached()->find_all();
     $this->ads = $ads;
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:14,代码来源:featured.php

示例5: before

 /**
  * 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()
 {
     $ad = new Model_Ad();
     $ad->where('seotitle', '=', Request::current()->param('seotitle'))->limit(1)->find();
     if ($ad->loaded()) {
         $this->id_ad = $ad->id_ad;
     }
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:14,代码来源:contact.php

示例6: action_user_contact

 public function action_user_contact()
 {
     $ad = new Model_Ad($this->request->param('id'));
     //message to user
     if ($ad->loaded() and $this->request->post()) {
         $user = new Model_User($ad->id_user);
         //require login to contact
         if ((core::config('advertisement.login_to_contact') == TRUE or core::config('general.messaging') == TRUE) and !Auth::instance()->logged_in()) {
             Alert::set(Alert::INFO, __('Please, login before contacting'));
             HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)));
         }
         if (captcha::check('contact')) {
             //check if user is loged in
             if (Auth::instance()->logged_in()) {
                 $email_from = $this->user->email;
                 $name_from = $this->user->name;
             } else {
                 $email_from = core::post('email');
                 $name_from = core::post('name');
             }
             //akismet spam filter
             if (!core::akismet($name_from, $email_from, core::post('message'))) {
                 if (core::config('general.messaging')) {
                     //price?
                     $price = (core::post('price') !== NULL and is_numeric(core::post('price'))) ? core::post('price') : NULL;
                     $ret = Model_Message::send_ad(core::post('message'), $this->user, $ad->id_ad, $price);
                 } else {
                     if (isset($_FILES['file'])) {
                         $file = $_FILES['file'];
                     } else {
                         $file = NULL;
                     }
                     //contact email is set use that one
                     if (isset($ad->cf_contactemail) and Valid::email($ad->cf_contactemail)) {
                         $to = $ad->cf_contactemail;
                     } else {
                         $to = NULL;
                     }
                     $ret = $user->email('user-contact', array('[EMAIL.BODY]' => core::post('message'), '[AD.NAME]' => $ad->title, '[EMAIL.SENDER]' => $name_from, '[EMAIL.FROM]' => $email_from, '[URL.AD]' => Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle))), $email_from, $name_from, $file, $to);
                 }
                 //if succesfully sent
                 if ($ret) {
                     Alert::set(Alert::SUCCESS, __('Your message has been sent'));
                     // we are updating field of visit table (contact)
                     Model_Visit::contact_ad($ad->id_ad);
                 } else {
                     Alert::set(Alert::ERROR, __('Message not sent'));
                 }
                 HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)));
             } else {
                 Alert::set(Alert::SUCCESS, __('This email has been considered as spam! We are sorry but we can not send this email.'));
             }
         } else {
             Alert::set(Alert::ERROR, __('Captcha is not correct'));
             HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)));
         }
     }
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:58,代码来源:contact.php

示例7: is_favorite

 /**
  * is favorite?
  * @param  Model_User $user user
  * @param  Model_Ad   $ad   ad
  * @return boolean          
  */
 public static function is_favorite(Model_User $user, Model_Ad $ad)
 {
     if ($user->loaded() and $ad->loaded()) {
         $fav = new Model_Favorite();
         $fav->where('id_user', '=', $user->id_user)->where('id_ad', '=', $ad->id_ad)->find();
         if ($fav->loaded()) {
             return TRUE;
         }
     }
     return FALSE;
 }
开发者ID:nick-catanchin-ie,项目名称:openclassifieds2,代码行数:17,代码来源:favorite.php

示例8: before

 /**
  * 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()
 {
     $ad = new Model_Ad();
     $user_ads = clone $ad;
     //get current ad do not filter by user since admin also can see
     $ad->where('seotitle', '=', Request::current()->param('seotitle'))->limit(1)->find();
     if ($ad->loaded() and Auth::instance()->logged_in()) {
         $user = Auth::instance()->get_user();
         if ($user->id_role == Model_Role::ROLE_ADMIN or $user->id_user == $ad->id_user) {
             $this->ad = $ad;
             $this->user_ads = $user_ads->where('id_user', '=', $ad->id_user)->find_all();
         }
     }
 }
开发者ID:zhangkom,项目名称:openclassifieds2,代码行数:20,代码来源:tools.php

示例9: action_create

 public function action_create()
 {
     try {
         if (!is_numeric(core::request('id_ad')) or !is_numeric(core::request('id_product')) or !is_numeric(core::request('id_user'))) {
             $this->_error(__('Missing parameters'), 501);
         } else {
             $user = new Model_User(core::request('id_user'));
             $ad = new Model_Ad(core::request('id_ad'));
             if ($user->loaded() and $ad->loaded()) {
                 $id_product = core::request('id_product');
                 $amount = core::request('amount');
                 //in case not set by request
                 if (!is_numeric($amount)) {
                     //get original price for the product
                     switch ($id_product) {
                         case Model_Order::PRODUCT_CATEGORY:
                             $amount = $ad->category->price;
                             break;
                         case Model_Order::PRODUCT_TO_TOP:
                             $amount = core::config('payment.pay_to_go_on_top');
                             break;
                         case Model_Order::PRODUCT_TO_FEATURED:
                             $amount = Model_Order::get_featured_price(core::request('featured_days'));
                             break;
                         case Model_Order::PRODUCT_AD_SELL:
                             $amount = $ad->price;
                             break;
                         default:
                             $plan = new Model_Plan($id_product);
                             $amount = $plan->loaded() ? $plan->price : 0;
                             break;
                     }
                 }
                 $order = Model_Order::new_order($ad, $user, $id_product, $amount, core::request('currency'), Model_Order::product_desc(core::request('id_product')), core::request('featured_days'));
                 $order->confirm_payment(core::request('paymethod', 'API'), core::request('txn_id'));
                 $order->save();
                 $this->rest_output(array('order' => self::get_order_array($order)));
             } else {
                 $this->_error(__('User or Ad not loaded'), 501);
             }
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
     }
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:45,代码来源:orders.php

示例10: action_index

 public function action_index()
 {
     $this->before('/pages/maps');
     $this->template->title = __('Map');
     $this->template->height = Core::get('height', '100%');
     $this->template->width = Core::get('width', '100%');
     $this->template->zoom = Core::get('zoom', core::config('advertisement.map_zoom'));
     $this->template->height_thumb = Core::config('image.height_thumb') / 4;
     $this->template->width_thumb = Core::config('image.width_thumb') / 4;
     if (Model_User::get_userlatlng()) {
         $this->template->center_lon = $_COOKIE['mylng'];
         $this->template->center_lat = $_COOKIE['mylat'];
     } else {
         $this->template->center_lon = Core::get('lon', core::config('advertisement.center_lon'));
         $this->template->center_lat = Core::get('lat', core::config('advertisement.center_lat'));
     }
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('address', 'IS NOT', NULL)->where('latitude', 'IS NOT', NULL)->where('longitude', 'IS NOT', NULL);
     //filter by category
     if (core::get('category') !== NULL) {
         $category = new Model_Category();
         $category->where('seoname', '=', core::get('category'))->cached()->limit(1)->find();
         if ($category->loaded()) {
             $ads->where('id_category', 'IN', $category->get_siblings_ids());
         }
     }
     //filter by location
     if (core::get('location') !== NULL) {
         $location = new Model_location();
         $location->where('seoname', '=', core::get('location'))->cached()->limit(1)->find();
         if ($location->loaded()) {
             $ads->where('id_location', 'IN', $location->get_siblings_ids());
         }
     }
     //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());
     }
     //if only 1 ad
     if (is_numeric(core::get('id_ad'))) {
         $ads = $ads->where('id_ad', '=', core::get('id_ad'));
     }
     $ads = $ads->order_by('published', 'desc')->limit(Core::config('advertisement.map_elements'))->find_all();
     $this->template->ads = $ads;
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:45,代码来源:map.php

示例11: action_index

 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));
 }
开发者ID:nick-catanchin-ie,项目名称:openclassifieds2,代码行数:56,代码来源:home.php

示例12: action_user_contact

 public function action_user_contact()
 {
     $ad = new Model_Ad($this->request->param('id'));
     //message to user
     if ($ad->loaded() and $this->request->post()) {
         $user = new Model_User($ad->id_user);
         if (captcha::check('contact')) {
             //akismet spam filter
             if (!core::akismet(core::post('name'), core::post('email'), core::post('message'))) {
                 if (isset($_FILES['file'])) {
                     $file = $_FILES['file'];
                 } else {
                     $file = NULL;
                 }
                 $ret = $user->email('user.contact', array('[EMAIL.BODY]' => core::post('message'), '[AD.NAME]' => $ad->title, '[EMAIL.SENDER]' => core::post('name'), '[EMAIL.FROM]' => core::post('email')), core::post('email'), core::post('name'), $file);
                 //if succesfully sent
                 if ($ret) {
                     Alert::set(Alert::SUCCESS, __('Your message has been sent'));
                     // we are updating field of visit table (contact)
                     $visit_contact_obj = new Model_Visit();
                     $visit_contact_obj->where('id_ad', '=', $this->request->param('id'))->order_by('created', 'desc')->limit(1)->find();
                     try {
                         $visit_contact_obj->contacted = 1;
                         $visit_contact_obj->save();
                     } catch (Exception $e) {
                         //throw 500
                         throw new HTTP_Exception_500($e->getMessage());
                     }
                 } else {
                     Alert::set(Alert::ERROR, __('Message not sent'));
                 }
                 Request::current()->redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)));
             } else {
                 Alert::set(Alert::SUCCESS, __('This email has been considered as spam! We are sorry but we can not send this email.'));
             }
         } else {
             Alert::set(Alert::ERROR, __('You made some mistake'));
         }
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:40,代码来源:contact.php

示例13: before

 /**
  * 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()
 {
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
     //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());
     }
     switch ($this->ads_type) {
         case 'popular':
             $id_ads = array_keys(Model_Visit::popular_ads());
             if (count($id_ads) > 0) {
                 $ads->where('id_ad', 'IN', $id_ads);
             }
             break;
         case 'featured':
             $ads->where('featured', 'IS NOT', NULL)->where('featured', '>', Date::unix2mysql())->order_by('featured', 'desc');
             break;
         case 'latest':
         default:
             $ads->order_by('published', 'desc');
             break;
     }
     $ads = $ads->limit($this->ads_limit)->cached()->find_all();
     //die(print_r($ads));
     $this->ads = $ads;
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:33,代码来源:ads.php

示例14: action_get

 public function action_get()
 {
     try {
         if (is_numeric($id_ad = $this->request->param('id'))) {
             $ad = new Model_Ad();
             //get distance to the ad
             if (isset($this->_params['latitude']) and isset($this->_params['longitude'])) {
                 $ad->select(array(DB::expr('degrees(acos(sin(radians(' . $this->_params['latitude'] . ')) * sin(radians(`latitude`)) + cos(radians(' . $this->_params['latitude'] . ')) * cos(radians(`latitude`)) * cos(radians(abs(' . $this->_params['longitude'] . ' - `longitude`))))) * 69.172'), 'distance'));
             }
             $ad->where('id_ad', '=', $id_ad)->where('status', '=', Model_Ad::STATUS_PUBLISHED)->cached()->find();
             if ($ad->loaded()) {
                 $a = $ad->as_array();
                 $a['price'] = i18n::money_format($ad->price);
                 $a['images'] = array_values($ad->get_images());
                 $a['category'] = $ad->category->as_array();
                 $a['location'] = $ad->location->as_array();
                 $a['user'] = Controller_Api_Users::get_user_array($ad->user);
                 $a['customfields'] = Model_Field::get_by_category($ad->id_category);
                 //sorting by distance, lets add it!
                 if (isset($ad->distance)) {
                     $a['distance'] = i18n::format_measurement($ad->distance);
                 }
                 $a['url'] = Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
                 $this->rest_output(array('ad' => $a));
             } else {
                 $this->_error(__('Advertisement not found'), 404);
             }
         } else {
             $this->_error(__('Advertisement not found'), 404);
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
         return;
     }
 }
开发者ID:vericoms,项目名称:openclassifieds2,代码行数:35,代码来源:listings.php

示例15: action_index

 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));
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:35,代码来源:home.php


注:本文中的Model_Ad类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。