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


PHP core::config方法代码示例

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


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

示例1: check

 /**
  * check if its valid or not
  * @param string $name for the session
  * @return boolean
  */
 public static function check($name = '', $ajax = FALSE)
 {
     //d(strtolower(core::post('captcha')));
     //d(Session::instance()->get('captcha_'.$name));
     //d(Session::instance()->get('captcha_'.$name) == strtolower(core::post('captcha')));
     //for OC
     if (core::config('advertisement.captcha') != NULL and core::config('advertisement.captcha') == FALSE) {
         // Captcha disabled on OC
         return TRUE;
     }
     //for OE
     if (core::config('general.captcha') != NULL and core::config('general.captcha') == FALSE) {
         // Captchas disabled on OE
         return TRUE;
     }
     // verify with recaptcha if enabled
     if (Core::config('general.recaptcha_active')) {
         if (self::recaptcha_verify()) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
     if (Session::instance()->get('captcha_' . $name) == strtolower(core::post('captcha'))) {
         if ($ajax === FALSE) {
             Session::instance()->set('captcha_' . $name, '');
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:ThomWensink,项目名称:common,代码行数:37,代码来源:captcha.php

示例2: notify

 /**
  * Function to notify subscribers
  */
 public static function notify(Model_Ad $ad)
 {
     $subscribers = new Model_Subscribe();
     if ($ad->price > 0) {
         $subscribers->where_open()->where(DB::EXPR((int) $ad->price), 'BETWEEN', array('min_price', 'max_price'))->or_where('max_price', '=', 0)->where_close();
     }
     //location is set
     if (is_numeric($ad->id_location)) {
         $subscribers->where('id_location', 'in', array($ad->id_location, 0));
     }
     //filter by category, 0 means all the cats, in case was not set
     $subscribers->where('id_category', 'in', array($ad->id_category, 0));
     $subscribers = $subscribers->find_all();
     $subscribers_id = array();
     // array to be filled with user emails
     foreach ($subscribers as $subs) {
         // do not repeat same users.
         if (!in_array($subs->id_user, $subscribers_id)) {
             $subscribers_id[] = $subs->id_user;
         }
     }
     // query for getting users, transform it to array and pass to email function
     if (count($subscribers_id) > 0) {
         $query = DB::select('email')->select('name')->from('users')->where('id_user', 'IN', $subscribers_id)->where('status', '=', Model_User::STATUS_ACTIVE)->execute();
         $users = $query->as_array();
         // Send mails like in newsletter, to multiple users simultaneously
         if (count($users) > 0) {
             $url_ad = Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
             $replace = array('[URL.AD]' => $url_ad, '[AD.TITLE]' => $ad->title);
             Email::content($users, '', core::config('email.notify_email'), core::config('general.site_name'), 'ads-subscribers', $replace);
         }
     }
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:36,代码来源:subscribe.php

示例3: action_index

 public function action_index()
 {
     //if they want to see a single post
     $seotitle = $this->request->param('seotitle', NULL);
     if ($seotitle !== NULL) {
         return $this->action_view($seotitle);
     }
     //template header
     $this->template->title = __('Blog');
     $this->template->meta_description = core::config('general.site_name') . ' ' . __('blog section.');
     $posts = new Model_Post();
     $posts->where('status', '=', Model_Post::STATUS_ACTIVE)->where('id_forum', 'IS', NULL);
     if (($search = Core::get('search')) !== NULL and strlen(Core::get('search')) >= 3) {
         $posts->where_open()->where('title', 'like', '%' . $search . '%')->or_where('description', 'like', '%' . $search . '%')->where_close();
     }
     $res_count = clone $posts;
     $res_count = $res_count->count_all();
     // check if there are some post
     if ($res_count > 0) {
         // pagination module
         $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $res_count))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
         Breadcrumbs::add(Breadcrumb::factory()->set_title(__("Page ") . $pagination->current_page));
         //we sort all ads with few parameters
         $posts = $posts->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
     } else {
         $posts = NULL;
         $pagination = NULL;
     }
     $this->template->bind('content', $content);
     $this->template->content = View::factory('pages/blog/listing', array('posts' => $posts, 'pagination' => $pagination, 'user' => Auth::instance()->get_user()));
 }
开发者ID:nick-catanchin-ie,项目名称:common,代码行数:31,代码来源:blog.php

示例4: action_buy

 /**
  * [action_buy] Pay for ad, and set new order 
  *
  */
 public function action_buy()
 {
     if (Core::config('general.subscriptions') == FALSE) {
         throw HTTP_Exception::factory(404, __('Page not found'));
     }
     //getting the user that wants to buy now
     if (!Auth::instance()->logged_in()) {
         Alert::set(Alert::INFO, __('To buy this product you need to register first.'));
         $this->redirect(Route::url('oc-panel'));
     }
     //check plan exists
     $plan = new Model_Plan();
     $plan->where('seoname', '=', $this->request->param('id'))->where('status', '=', 1)->find();
     //loaded published and with stock if we control the stock.
     if ($plan->loaded() and $plan->status == 1) {
         //free plan can not be renewed
         if ($plan->price == 0 and $this->user->subscription()->id_plan == $plan->id_plan) {
             Alert::set(Alert::WARNING, __('Free plan can not be renewed, before expired'));
             HTTP::redirect(Route::url('pricing'));
         }
         $order = Model_Order::new_order(NULL, $this->user, $plan->id_plan, $plan->price, core::config('payment.paypal_currency'), __('Subscription to ') . $plan->name);
         //free plan no checkout
         if ($plan->price == 0) {
             $order->confirm_payment('cash');
             $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
         } else {
             $this->redirect(Route::url('default', array('controller' => 'plan', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         throw HTTP_Exception::factory(404, __('Page not found'));
     }
 }
开发者ID:johnulist,项目名称:openclassifieds2,代码行数:36,代码来源:plan.php

示例5: action_index

 public function action_index()
 {
     //if they want to see a single post
     $seotitle = $this->request->param('seotitle', NULL);
     if ($seotitle !== NULL) {
         return $this->action_view($seotitle);
     }
     //template header
     $this->template->title = __('Blog');
     $this->template->meta_description = __('Blog');
     $posts = new Model_Post();
     $posts->where('status', '=', 1);
     $res_count = $posts->count_all();
     // check if there are some post
     if ($res_count > 0) {
         // pagination module
         $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $res_count, 'items_per_page' => core::config('general.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
         Breadcrumbs::add(Breadcrumb::factory()->set_title(__("Page ") . $pagination->current_page));
         //we sort all ads with few parameters
         $posts = $posts->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
     } else {
         $posts = NULL;
         $pagination = NULL;
     }
     $this->template->bind('content', $content);
     $this->template->content = View::factory('pages/blog/listing', array('posts' => $posts, 'pagination' => $pagination, 'user' => Auth::instance()->get_user()));
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:27,代码来源:blog.php

示例6: url

	static function url()
	{
		$args= href::processArgs(func_get_args());

		$hash='';
		if (isset($args['request']['#']))
		{
			$hash= '#'.$args['request']['#'];
			unset($args['request']['#']);
		}
		$args= href::required($args);
		if (core::config('rewrite-encode') && (!core::config('no-cache') || !in_array($args['template'],core::$config['no-cache'])))
		{
			$url= call_user_func(core::$config['rewrite-encode'],$args['module'],$args['request'],$hash);
		}
		else
		{
			if (isset(core::$config['index.php'])) $url= core::$config['index.php'];
	    	else $url= '';
	    	$pairs= array();
	    	if ($args['module']!=core::$config['default-module']) $pairs[]= core::$config['module-var'].'='.$args['module'];
			foreach ($args['request'] as $name=>$val) if(!is_null($val)) $pairs[]= $name.'='.urlencode($val);
			if ($pairs) $url.= '?'.implode('&',$pairs);
			if (!$url && !isset($args['current'])) $url= (isset($_SERVER['HTTPS '])?'https':'http').'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['SCRIPT_NAME'],0,-9); // cut off "index.php"
		}
		$url= $url.$hash;
		return $url;
	}
开发者ID:Emperor359,项目名称:conkit,代码行数:28,代码来源:href1.php

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

示例8: action_form

 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_form()
 {
     $this->auto_render = FALSE;
     $order_id = $this->request->param('id');
     $order = new Model_Order();
     $order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         // dependant on product we have different names
         if ($order->id_product == Paypal::to_featured) {
             $item_name = __('Advertisement to featured');
         } else {
             if ($order->id_product == Paypal::to_top) {
                 $item_name = __('Advertisement to top');
             } else {
                 $item_name = $order->description . __(' category');
             }
         }
         $paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway;
         $paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => core::config('payment.paypal_account'), 'paypal_currency' => core::config('payment.paypal_currency'), 'item_name' => $item_name);
         $this->template = View::factory('paypal', $paypal_data);
         $this->response->body($this->template->render());
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->request->redirect(Route::url('default'));
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:29,代码来源:paypal.php

示例9: validate_ipn

 /**
  * validates the data at paypal c&p from https://www.x.com/developers/PayPal/documentation-tools/code-sample/216623
  * @note impossible to test on sandbox, paypal wont work.
  * I really dislike this code but seems to work...
  * @return boolean
  */
 public static function validate_ipn()
 {
     if (core::config('payment.sandbox')) {
         $ipn_url = self::ipn_sandbox_url;
     } else {
         $ipn_url = self::ipn_url;
     }
     // STEP 1: Read POST data
     // reading posted data from directly from $_POST causes serialization
     // issues with array data in POST
     // reading raw POST data from input stream instead.
     $raw_post_data = file_get_contents('php://input');
     $raw_post_array = explode('&', $raw_post_data);
     $myPost = array();
     foreach ($raw_post_array as $keyval) {
         $keyval = explode('=', $keyval);
         if (count($keyval) == 2) {
             $myPost[$keyval[0]] = urldecode($keyval[1]);
         }
     }
     // read the post from PayPal system and add 'cmd'
     $req = 'cmd=_notify-validate';
     if (function_exists('get_magic_quotes_gpc')) {
         $get_magic_quotes_exists = true;
     }
     foreach ($myPost as $key => $value) {
         if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
             $value = urlencode(stripslashes($value));
         } else {
             $value = urlencode($value);
         }
         $req .= "&{$key}={$value}";
     }
     // STEP 2: Post IPN data back to paypal to validate
     $ch = curl_init($ipn_url);
     curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
     if (!($res = curl_exec($ch))) {
         // error_log("Got " . curl_error($ch) . " when processing IPN data");
         curl_close($ch);
         exit;
     }
     curl_close($ch);
     // STEP 3: Inspect IPN validation result and act accordingly
     if (strcmp($res, "VERIFIED") == 0) {
         return TRUE;
     } elseif (strcmp($res, "INVALID") == 0) {
         Kohana::$log->add(Log::ERROR, 'Paypal invalid payment error. Result: ' . $res . ' Data: ' . json_encode($_POST));
         return FALSE;
     } else {
         Kohana::$log->add(Log::ERROR, 'Unknown result from IPN verification. Result: ' . $res . ' Data: ' . json_encode($_POST));
         return FALSE;
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:66,代码来源:paypal.php

示例10: action_index

 public function action_index()
 {
     //template header
     $this->template->title = __('Contact Us');
     $this->template->meta_description = __('Contact') . ' ' . core::config('general.site_name');
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Contact Us')));
     if ($this->request->post()) {
         //captcha check
         if (captcha::check('contact')) {
             //check if user is loged in
             if (Auth::instance()->logged_in()) {
                 $email_from = Auth::instance()->get_user()->email;
                 $name_from = Auth::instance()->get_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'))) {
                 $replace = array('[EMAIL.BODY]' => core::post('message'), '[EMAIL.SENDER]' => $name_from, '[EMAIL.FROM]' => $email_from);
                 if (Email::content(core::config('email.notify_email'), core::config('general.site_name'), $email_from, $name_from, 'contact-admin', $replace)) {
                     Alert::set(Alert::SUCCESS, __('Your message has been sent'));
                 } else {
                     Alert::set(Alert::ERROR, __('Message not sent'));
                 }
             } else {
                 Alert::set(Alert::WARNING, __('This email has been considered as spam! We are sorry but we can not send this email.'));
             }
         } else {
             Alert::set(Alert::ERROR, __('Wrong captcha'));
         }
     }
     $this->template->content = View::factory('pages/contact');
 }
开发者ID:Ryanker,项目名称:open-eshop,代码行数:35,代码来源:contact.php

示例11: action_index

 public function action_index()
 {
     //template header
     $this->template->title = __('Contact Us');
     $this->template->meta_description = __('Contact Us');
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Contact Us')));
     if ($this->request->post()) {
         //captcha check
         if (captcha::check('contact')) {
             //akismet spam filter
             if (!core::akismet(core::post('name'), core::post('email'), core::post('message'))) {
                 $replace = array('[EMAIL.BODY]' => core::post('message'), '[EMAIL.SENDER]' => core::post('name'), '[EMAIL.FROM]' => core::post('email'));
                 if (Email::content(core::config('email.notify_email'), core::config('general.site_name'), core::post('email'), core::post('name'), 'contact.admin', $replace)) {
                     Alert::set(Alert::SUCCESS, __('Your message has been sent'));
                 } else {
                     Alert::set(Alert::ERROR, __('Message not sent'));
                 }
             } 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, __('Check the form for errors'));
         }
     }
     $this->template->content = View::factory('pages/contact');
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:27,代码来源:contact.php

示例12: send

 function send($message, $data = false)
 {
     if (!is_array($this->devices) || count($this->devices) == 0) {
         $this->error("No devices set");
     }
     if (strlen($this->serverApiKey) < 8) {
         $this->error("Server API Key not set");
     }
     $fields = array('registration_ids' => $this->devices, 'data' => array("message" => $message), 'notification' => array("title" => core::config('general.site_name'), "message" => $message, "body" => $message));
     if (is_array($data)) {
         foreach ($data as $key => $value) {
             $fields['data'][$key] = $value;
         }
     }
     $headers = array('Authorization: key=' . $this->serverApiKey, 'Content-Type: application/json');
     // Open connection
     $ch = curl_init();
     // Set the url, number of POST vars, POST data
     curl_setopt($ch, CURLOPT_URL, $this->url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
     // Avoids problem with https certificate
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     // Execute post
     $result = curl_exec($ch);
     // Close connection
     curl_close($ch);
     return $result;
 }
开发者ID:JeffPedro,项目名称:project-garage-sale,代码行数:32,代码来源:GCMPushMessage.php

示例13: action_pay

 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_pay()
 {
     $this->auto_render = FALSE;
     $order_id = $this->request->param('id');
     $order = new Model_Order();
     $order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         // case when selling advert
         if ($order->id_product == Model_Order::PRODUCT_AD_SELL) {
             $paypal_account = $order->ad->paypal_account();
             $currency = i18n::get_intl_currency_symbol();
             if (isset($order->ad->cf_shipping) and Valid::numeric($order->ad->cf_shipping) and $order->ad->cf_shipping > 0) {
                 $order->amount = $order->amount + $order->ad->cf_shipping;
             }
         } else {
             $paypal_account = core::config('payment.paypal_account');
             $currency = core::config('payment.paypal_currency');
         }
         $paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway;
         $paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => $paypal_account, 'paypal_currency' => $currency, 'item_name' => $order->description);
         $this->template = View::factory('paypal', $paypal_data);
         $this->response->body($this->template->render());
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default'));
     }
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:30,代码来源:paypal.php

示例14: before

 /**
  * Initialize properties before running the controller methods (actions),
  * so they are available to our action.
  * @param  string $template view to use as template
  * @return void           
  */
 public function before($template = NULL)
 {
     Theme::checker();
     $this->maintenance();
     if ($this->auto_render === TRUE) {
         // Load the template
         $this->template = $template === NULL ? 'oc-panel/main' : $template;
         $this->template = View::factory($this->template);
         // Initialize empty values
         $this->template->title = __('Panel') . ' - ' . core::config('general.site_name');
         $this->template->meta_keywords = '';
         $this->template->meta_description = '';
         $this->template->meta_copywrite = 'Open Classifieds ' . Core::version;
         $this->template->header = View::factory('oc-panel/header');
         $this->template->content = '';
         $this->template->footer = View::factory('oc-panel/footer');
         $this->template->styles = array();
         $this->template->scripts = array();
         $this->template->user = Auth::instance()->get_user();
         //other color
         if (Theme::get('admin_theme') != 'bootstrap' and Theme::get('admin_theme') != '') {
             Theme::$styles = array('http://netdna.bootstrapcdn.com/bootswatch/3.0.0/' . Theme::get('admin_theme') . '/bootstrap.min.css' => 'screen', 'http://cdn.jsdelivr.net/bootstrap/2.3.2/css/bootstrap-responsive.min.css' => 'screen', 'http://cdn.jsdelivr.net/chosen/1.0.0/chosen.css' => 'screen', 'http://cdn.jsdelivr.net/sceditor/1.4.3/themes/default.min.css' => 'screen', 'css/admin-styles.css' => 'screen');
         } else {
             Theme::$styles = array('http://netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css' => 'screen', 'http://cdn.jsdelivr.net/sceditor/1.4.3/themes/default.min.css' => 'screen', 'http://cdn.jsdelivr.net/chosen/1.0.0/chosen.css' => 'screen', 'css/admin-styles.css' => 'screen');
         }
         Theme::$scripts['footer'] = array('http://code.jquery.com/jquery-1.10.2.min.js', 'js/jquery.sceditor.min.js', 'http://netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js', 'http://cdn.jsdelivr.net/chosen/1.0.0/chosen.jquery.min.js', 'js/oc-panel/theme.init.js?v=2.1', 'js/oc-panel/sidebar.js');
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:34,代码来源:controller.php

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


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