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


PHP Model_Ad::get_images方法代码示例

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


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

示例1: action_get

 public function action_get()
 {
     try {
         if (is_numeric($id_ad = $this->request->param('id'))) {
             $ad = new Model_Ad($id_ad);
             if ($ad->loaded()) {
                 if ($ad->id_user == $this->user->id_user) {
                     $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['customfields'] = Model_Field::get_by_category($ad->id_category);
                     $this->rest_output(array('ad' => $a));
                 } else {
                     $this->_error(__('Not your advertisement'), 401);
                 }
             } else {
                 $this->_error(__('Advertisement not found'), 404);
             }
         } else {
             $this->_error(__('Advertisement not found'), 404);
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
         return;
     }
 }
开发者ID:AndresGrams,项目名称:openclassifieds2,代码行数:28,代码来源:ads.php

示例2: 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

示例3: 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


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