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


PHP Model_Ad::custom_columns方法代码示例

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


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

示例1: action_view

 /**
  * 
  * Display single advert. 
  * @throws HTTP_Exception_404
  * 
  */
 public function action_view()
 {
     $seotitle = $this->request->param('seotitle', NULL);
     if ($seotitle !== NULL) {
         $ad = new Model_Ad();
         $ad->where('seotitle', '=', $seotitle)->where('status', '!=', Model_Ad::STATUS_SPAM)->limit(1)->cached()->find();
         if ($ad->loaded()) {
             Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
             $location = NULL;
             $location_parent = NULL;
             if ($ad->location->loaded() and $ad->id_location != 1) {
                 $location = $ad->location;
                 //adding the location parent
                 if ($location->id_location_parent != 1 and $location->parent->loaded()) {
                     $location_parent = $location->parent;
                 }
             }
             $category = NULL;
             $category_parent = NULL;
             if ($ad->category->loaded()) {
                 $category = $ad->category;
                 //adding the category parent
                 if ($category->id_category_parent != 1 and $category->parent->loaded()) {
                     $category_parent = $category->parent;
                 }
             }
             //base category  title
             if ($category !== NULL) {
                 $this->template->title = $category->name;
             } else {
                 $this->template->title = '';
             }
             //adding location titles and breadcrumbs
             if ($location !== NULL) {
                 $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))));
                 }
             }
             $this->template->title = $ad->title . ' - ' . $this->template->title;
             Breadcrumbs::add(Breadcrumb::factory()->set_title($ad->title));
             $this->template->meta_description = $ad->title . ' ' . __('in') . ' ' . $category->name . ' ' . __('on') . ' ' . core::config('general.site_name');
             $permission = TRUE;
             //permission to add hit to advert and give access rights.
             $auth_user = Auth::instance();
             if (!$auth_user->logged_in() or $auth_user->get_user()->id_user != $ad->id_user and ($auth_user->get_user()->id_role != Model_Role::ROLE_ADMIN and $auth_user->get_user()->id_role != Model_Role::ROLE_MODERATOR) or $auth_user->get_user()->id_role != Model_Role::ROLE_ADMIN and $auth_user->get_user()->id_role != Model_Role::ROLE_MODERATOR) {
                 $permission = FALSE;
                 $user = NULL;
             } else {
                 $user = $auth_user->get_user()->id_user;
             }
             $hits = $ad->count_ad_hit();
             $captcha_show = core::config('advertisement.captcha');
             if ($ad->get_first_image() !== NULL) {
                 Controller::$image = $ad->get_first_image();
             }
             $this->template->bind('content', $content);
             $this->template->content = View::factory('pages/ad/single', array('ad' => $ad, 'permission' => $permission, 'hits' => $hits, 'captcha_show' => $captcha_show, 'user' => $user, 'cf_list' => $ad->custom_columns()));
         } else {
             //throw 404
             throw HTTP_Exception::factory(404, __('Page not found'));
         }
     } else {
         //throw 404
         throw HTTP_Exception::factory(404, __('Page not found'));
     }
 }
开发者ID:nick-catanchin-ie,项目名称:openclassifieds2,代码行数:89,代码来源:ad.php

示例2: action_index

 public function action_index()
 {
     $this->auto_render = FALSE;
     $info = array('title' => 'RSS ' . Core::config('general.site_name'), 'pubDate' => date("D, d M Y H:i:s T"), 'description' => __('Latest published'), 'generator' => 'Open Classifieds');
     $items = array();
     //last ads, you can modify this value at: general.feed_elements
     $ads = DB::select('a.seotitle')->select(array('c.seoname', 'category'), 'a.id_ad', 'a.title', 'a.description', 'a.published', 'a.address', 'a.price', 'a.phone', 'a.website')->from(array('ads', 'a'))->join(array('categories', 'c'), 'INNER')->on('a.id_category', '=', 'c.id_category')->where('a.status', '=', Model_Ad::STATUS_PUBLISHED)->order_by('published', 'desc')->limit(Core::config('general.feed_elements'));
     //filter by category aor location
     if (Controller::$category !== NULL) {
         if (Controller::$category->loaded()) {
             $ads->where('a.id_category', '=', Controller::$category->id_category);
         }
     }
     if (Controller::$location !== NULL) {
         if (Controller::$location->loaded()) {
             $ads->where('a.id_location', '=', Controller::$location->id_location);
         }
     }
     $ads = $ads->as_object()->cached()->execute();
     foreach ($ads as $a) {
         $url = Route::url('ad', array('category' => $a->category, 'seotitle' => $a->seotitle));
         // This is idiotic
         $feed_entry = array('id' => $a->id_ad, 'title' => preg_replace('/&(?!\\w+;)/', '&', $a->title), 'link' => $url, 'pubDate' => Date::mysql2unix($a->published), 'description' => preg_replace('/&(?!\\w+;)/', '&', $a->description), 'category' => $a->category, 'address' => $a->address, 'website' => $a->website, 'phone' => $a->phone, 'price' => $a->price);
         $ad_obj = new Model_Ad($a->id_ad);
         $cc = $ad_obj->custom_columns();
         foreach ($cc as $k => $v) {
             if ($v['value']) {
                 $feed_entry[$k] = $v['value'];
             }
         }
         //	    define('QR_DIR', ROOT.'qrs/');
         $cur_qr_dir = QR_DIR . $a->id_ad;
         if (is_dir($cur_qr_dir)) {
             $qr_dir = opendir($cur_qr_dir);
             $qrs = array();
             $qr_url = "http://" . $_SERVER['HTTP_HOST'] . "/qrs/" . $a->id_ad . "/";
             if ($qr_dir) {
                 while (($file = readdir($qr_dir)) !== false) {
                     if ($file == "." || $file == "..") {
                         continue;
                     }
                     $type = str_replace($a->id_ad . "_", "", $file);
                     $type = str_replace(".png", "", $type);
                     $feed_entry['qr_' . $type] = $qr_url . $file;
                 }
             }
         }
         $imgs = $ad_obj->get_images();
         $img_cnt = 0;
         foreach ($imgs as $img) {
             $dir = $img['image'];
             $url = 'http://' . $_SERVER['HTTP_HOST'] . "/" . $dir;
             $img_key = 'image' . $img_cnt;
             $feed_entry[$img_key] = trim($url);
             $img_cnt++;
         }
         $items[] = $feed_entry;
     }
     $xml = Feed::create($info, $items);
     $this->response->headers('Content-type', 'text/xml');
     $this->response->body($xml);
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:62,代码来源:feed.php

示例3: action_view

 /**
  * 
  * Display single advert. 
  * @throws HTTP_Exception_404
  * 
  */
 public function action_view()
 {
     $seotitle = $this->request->param('seotitle', NULL);
     if ($seotitle !== NULL) {
         $ad = new Model_Ad();
         $ad->where('seotitle', '=', $seotitle)->where('status', '!=', Model_Ad::STATUS_SPAM)->limit(1)->cached()->find();
         if ($ad->loaded()) {
             //throw 404
             if ($ad->status == Model_Ad::STATUS_UNAVAILABLE or $ad->status == Model_Ad::STATUS_NOPUBLISHED) {
                 throw HTTP_Exception::factory(404, __('This advertisement doesn´t exist, or is not yet published!'));
             }
             Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
             $location = NULL;
             $location_parent = NULL;
             if ($ad->location->loaded() and $ad->id_location != 1) {
                 $location = $ad->location;
                 //adding the location parent
                 if ($location->id_location_parent != 1 and $location->parent->loaded()) {
                     $location_parent = $location->parent;
                 }
             }
             $category = NULL;
             $category_parent = NULL;
             if ($ad->category->loaded()) {
                 $category = $ad->category;
                 //adding the category parent
                 if ($category->id_category_parent != 1 and $category->parent->loaded()) {
                     $category_parent = $category->parent;
                 }
             }
             //base category  title
             if ($category !== NULL) {
                 $this->template->title = $category->name;
             } else {
                 $this->template->title = '';
             }
             //adding location titles and breadcrumbs
             if ($location !== NULL) {
                 $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))));
                 }
             }
             $this->template->title = $ad->title . ' - ' . $this->template->title;
             Breadcrumbs::add(Breadcrumb::factory()->set_title($ad->title));
             $this->template->meta_description = $ad->title . ' ' . __('in') . ' ' . $category->name . ' ' . __('on') . ' ' . core::config('general.site_name');
             $permission = TRUE;
             //permission to add hit to advert and give access rights.
             $auth_user = Auth::instance();
             if (!$auth_user->logged_in() or $auth_user->get_user()->id_user != $ad->id_user and (!$auth_user->get_user()->is_admin() and !$auth_user->get_user()->is_moderator()) or !$auth_user->get_user()->is_admin() and !$auth_user->get_user()->is_moderator()) {
                 $permission = FALSE;
                 $user = NULL;
             } else {
                 $user = $auth_user->get_user()->id_user;
             }
             Model_Visit::hit_ad($ad->id_ad);
             $hits = $ad->count_ad_hit();
             $captcha_show = core::config('advertisement.captcha');
             if ($ad->get_first_image() !== NULL) {
                 Controller::$image = $ad->get_first_image();
             }
             $view_file = 'pages/ad/single';
             if (Core::get('amp') == '1') {
                 $this->template = 'amp/main';
                 $this->before();
                 $this->template->canonical = Route::url('ad', array('controller' => 'ad', 'category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
                 $this->template->structured_data = $ad->structured_data();
                 $view_file = 'amp/pages/ad/single';
             }
             $cf_list = $ad->custom_columns();
             $this->template->amphtml = Route::url('ad', array('controller' => 'ad', 'category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)) . '?amp=1';
             $this->template->bind('content', $content);
             $this->template->content = View::factory($view_file, compact('ad', 'permission', 'hits', 'captcha_show', 'user', 'cf_list'));
         } else {
             //throw 404
             throw HTTP_Exception::factory(404, __('Page not found'));
         }
     } else {
//.........这里部分代码省略.........
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:101,代码来源:ad.php

示例4: action_view

 /**
  * 
  * Display single advert. 
  * @throws HTTP_Exception_404
  * 
  */
 public function action_view()
 {
     $seotitle = $this->request->param('seotitle', NULL);
     if ($seotitle !== NULL) {
         $ad = new Model_Ad();
         $ad->where('seotitle', '=', $seotitle)->where('status', '!=', Model_Ad::STATUS_SPAM)->limit(1)->cached()->find();
         if ($ad->loaded()) {
             Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
             $location = NULL;
             $location_parent = NULL;
             if ($ad->location->loaded() and $ad->id_location != 1) {
                 $location = $ad->location;
                 //adding the location parent
                 if ($location->id_location_parent != 1 and $location->parent->loaded()) {
                     $location_parent = $location->parent;
                 }
             }
             $category = NULL;
             $category_parent = NULL;
             if ($ad->category->loaded()) {
                 $category = $ad->category;
                 //adding the category parent
                 if ($category->id_category_parent != 1 and $category->parent->loaded()) {
                     $category_parent = $category->parent;
                 }
             }
             //base category  title
             if ($category !== NULL) {
                 $this->template->title = $category->name;
             } else {
                 $this->template->title = '';
             }
             //adding location titles and breadcrumbs
             if ($location !== NULL) {
                 $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))));
                 }
             }
             $this->template->title = $ad->title . ' - ' . $this->template->title;
             Breadcrumbs::add(Breadcrumb::factory()->set_title($ad->title));
             $this->template->meta_description = text::removebbcode($ad->description);
             $permission = TRUE;
             //permission to add hit to advert and give access rights.
             if (!Auth::instance()->logged_in() || Auth::instance()->get_user()->id_user != $ad->id_user && Auth::instance()->get_user()->id_role != Model_Role::ROLE_ADMIN || Auth::instance()->get_user()->id_role != Model_Role::ROLE_ADMIN) {
                 if (!Auth::instance()->logged_in()) {
                     $visitor_id = NULL;
                 } else {
                     $visitor_id = Auth::instance()->get_user()->id_user;
                 }
                 $do_hit = $ad->count_ad_hit($ad->id_ad, $visitor_id, ip2long(Request::$client_ip));
                 // hits counter
                 $permission = FALSE;
                 $user = NULL;
             } else {
                 $user = Auth::instance()->get_user()->id_user;
             }
             //count how many matches are found
             $hits = new Model_Visit();
             $hits = $hits->where('id_ad', '=', $ad->id_ad)->count_all();
             $captcha_show = core::config('advertisement.captcha');
             $this->template->bind('content', $content);
             $this->template->content = View::factory('pages/ad/single', array('ad' => $ad, 'permission' => $permission, 'hits' => $hits, 'captcha_show' => $captcha_show, 'user' => $user, 'custom_fields' => $ad->custom_columns()));
         } else {
             //throw 404
             throw new HTTP_Exception_404();
         }
     } else {
         //throw 404
         throw new HTTP_Exception_404();
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:94,代码来源:ad.php


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