本文整理汇总了PHP中Model_Ad::banned_words方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Ad::banned_words方法的具体用法?PHP Model_Ad::banned_words怎么用?PHP Model_Ad::banned_words使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Ad
的用法示例。
在下文中一共展示了Model_Ad::banned_words方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_update
/**
* Edit advertisement: Update
*
* All post fields are validated
*/
public function action_update()
{
//template header
$this->template->title = __('Edit advertisement');
$this->template->meta_description = __('Edit advertisement');
//local files
if (Theme::get('cdn_files') == FALSE) {
$this->template->styles = array('css/datepicker.css' => 'screen');
$this->template->scripts['footer'] = array('js/bootstrap-datepicker.js', 'js/jquery.validate.min.js', 'js/oc-panel/edit_ad.js');
} else {
$this->template->styles = array('http://cdn.jsdelivr.net/bootstrap.datepicker/0.1/css/datepicker.css' => 'screen');
$this->template->scripts['footer'] = array('http://cdn.jsdelivr.net/bootstrap.datepicker/0.1/js/bootstrap-datepicker.js', 'js/jquery.validate.min.js', 'js/oc-panel/edit_ad.js');
}
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
$form = new Model_Ad($this->request->param('id'));
//find all, for populating form select fields
list($categories, $order_categories) = Model_Category::get_all();
list($locations, $order_locations) = Model_Location::get_all();
if (Auth::instance()->logged_in() && Auth::instance()->get_user()->id_user == $form->id_user || Auth::instance()->logged_in() && Auth::instance()->get_user()->id_role == 10) {
$extra_payment = core::config('payment');
Breadcrumbs::add(Breadcrumb::factory()->set_title("Update"));
$this->template->content = View::factory('oc-panel/profile/edit_ad', array('ad' => $form, 'locations' => $locations, 'order_locations' => $order_locations, 'categories' => $categories, 'order_categories' => $order_categories, 'extra_payment' => $extra_payment, 'fields' => Model_Field::get_all()));
if ($this->request->post()) {
$cat = new Model_Category();
$loc = new Model_Location();
// deleting single image by path
$deleted_image = core::post('img_delete');
if ($deleted_image) {
$img_path = $form->gen_img_path($form->id_ad, $form->created);
if (!is_dir($img_path)) {
return FALSE;
} else {
//delete formated image
unlink($img_path . $deleted_image . '.jpg');
//delete original image
$orig_img = str_replace('thumb_', '', $deleted_image);
unlink($img_path . $orig_img . ".jpg");
$this->request->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'update', 'id' => $form->id_ad)));
}
}
// end of img delete
$data = array('_auth' => $auth = Auth::instance(), 'title' => $title = Model_Ad::banned_words(core::post('title')), 'seotitle' => $seotitle = core::post('title'), 'loc' => $loc = core::post('location'), 'description' => $description = Model_Ad::banned_words(core::post('description')), 'price' => $price = floatval(str_replace(',', '.', core::post('price'))), 'address' => $address = core::post('address'), 'website' => $website = core::post('website'), 'phone' => $phone = core::post('phone'), 'has_images' => 0, 'user' => $user = new Model_User());
// append to $data new custom values
foreach ($_POST as $name => $field) {
// get by prefix
if (strpos($name, 'cf_') !== false) {
$data[$name] = $field;
//checkbox when selected return string 'on' as a value
if ($field == 'on') {
$data[$name] = 1;
}
}
}
//insert data
if (core::post('title') != $form->title) {
if ($form->has_images == 1) {
$current_path = $form->gen_img_path($form->id_ad, $form->created);
// rename current image path to match new seoname
rename($current_path, $form->gen_img_path($form->id_ad, $form->created));
}
$seotitle = $form->gen_seo_title($data['title']);
$form->seotitle = $seotitle;
} else {
$form->seotitle = $form->seotitle;
}
$form->title = $data['title'];
$form->id_location = $data['loc'];
//$form->id_category = $data['cat'];
$form->description = $data['description'];
// $form->status = $data['status'];
$form->price = $data['price'];
$form->address = $data['address'];
$form->website = $data['website'];
$form->phone = $data['phone'];
// set custom values
foreach ($data as $key => $value) {
// get only custom values with prefix
if (strpos($key, 'cf_') !== false) {
$form->{$key} = $value;
}
}
// d($data['cf_radio']);
$obj_ad = new Model_Ad();
// IMAGE UPLOAD
// in case something wrong happens user is redirected to edit advert.
$filename = NULL;
$counter = 0;
for ($i = 0; $i < core::config("advertisement.num_images"); $i++) {
$counter++;
if (isset($_FILES['image' . $i])) {
$img_files = $_FILES['image' . $i];
$filename = $obj_ad->save_image($img_files, $form->id_ad, $form->created, $form->seotitle, $counter);
}
if ($filename) {
$form->has_images = 1;
//.........这里部分代码省略.........
示例2: save_new_ad
/**
* [save_new_ad Save new advertisement if validated, with a given parameters
*
* @param [array] $data [post values]
* @param [int] $status [status of advert.]
* @param [bool] $published [Confirms if advert is published. ref to model_ad]
* @param [int] $moderation [moderation status/mode]
*
* @return [view] View dependant on usecase
*/
public function save_new_ad($data, $status, $published, $moderation)
{
$user = new Model_User();
$new_ad = new Model_Ad();
//$_POST is submitted for a new ad
if ($this->request->post()) {
if (captcha::check('publish_new')) {
//FORM DATA
$seotitle = $new_ad->gen_seo_title($data['title']);
$new_ad->title = Model_Ad::banned_words($data['title']);
$new_ad->id_location = $data['loc'];
$new_ad->id_category = $data['cat'];
$new_ad->description = Model_Ad::banned_words($data['description']);
$new_ad->seotitle = $seotitle;
$new_ad->status = $status;
$new_ad->price = floatval(str_replace(',', '.', $data['price']));
$new_ad->address = $data['address'];
$new_ad->phone = $data['phone'];
$new_ad->website = $data['website'];
// set custom values
foreach ($data as $name => $field) {
// get only custom values with prefix
if (strpos($name, 'cf_') !== false) {
$new_ad->{$name} = $field;
}
}
// d($data);
// User detection, if doesnt exists create
$auth_user = Auth::instance();
if (!$auth_user->logged_in()) {
$name = core::post('name');
$email = core::post('email');
$user_id = $user->create_new_user($name, $email);
} else {
$user_id = $auth_user->get_user()->id_user;
$name = $auth_user->get_user()->name;
$email = $auth_user->get_user()->email;
}
// SAVE AD
$new_ad->id_user = $user_id;
// after handling user
try {
//akismet spam filter
if (!core::akismet(Model_Ad::banned_words($data['title']), $email, Model_Ad::banned_words($data['description']))) {
if ($moderation == Model_Ad::EMAIL_MODERATION or $moderation == Model_Ad::EMAIL_CONFIRMATION) {
$new_ad->status = Model_Ad::STATUS_UNCONFIRMED;
}
$new_ad->save();
} else {
Alert::set(Alert::SUCCESS, __('This post has been considered as spam! We are sorry but we cant publish this advertisement.'));
$this->request->redirect('default');
}
//akismet
// if moderation is off update db field with time of creation
if ($published) {
$_ad_published = new Model_Ad();
$_ad_published->where('seotitle', '=', $seotitle)->limit(1)->find();
$_ad_published->published = $_ad_published->created;
$_ad_published->save();
$created = $_ad_published->created;
} else {
$created = new Model_Ad();
$created = $created->where('seotitle', '=', $seotitle)->limit(1)->find();
$created = $created->created;
}
$user = $user->where('email', '=', $email)->limit(1)->find();
// after successful posting send them email depending on moderation
if ($moderation == Model_Ad::EMAIL_CONFIRMATION or $moderation == Model_Ad::EMAIL_MODERATION) {
$edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $new_ad->id_ad;
$delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $new_ad->id_ad;
//we get the QL, and force the regen of token for security
$url_ql = $user->ql('default', array('controller' => 'ad', 'action' => 'confirm_post', 'id' => $new_ad->id_ad), TRUE);
$ret = $user->email('ads.confirm', array('[URL.QL]' => $url_ql, '[AD.NAME]' => $new_ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
} elseif ($moderation == Model_Ad::MODERATION_ON) {
$edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $new_ad->id_ad;
$delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $new_ad->id_ad;
//we get the QL, and force the regen of token for security
$url_ql = $user->ql('oc-panel', array('controller' => 'profile', 'action' => 'update', 'id' => $new_ad->id_ad), TRUE);
$ret = $user->email('ads.notify', array('[URL.QL]' => $url_ql, '[AD.NAME]' => $new_ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
// email to notify user of creating, but it is in moderation currently
} elseif ($moderation == Model_Ad::POST_DIRECTLY) {
$edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $new_ad->id_ad;
$delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $new_ad->id_ad;
$url_cont = $user->ql('contact', array(), TRUE);
$url_ad = $user->ql('ad', array('category' => $data['cat'], 'seotitle' => $seotitle), TRUE);
$ret = $user->email('ads.user_check', array('[URL.CONTACT]' => $url_cont, '[URL.AD]' => $url_ad, '[AD.NAME]' => $new_ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
}
// new ad notification email to admin (notify_email), if set to TRUE
if (core::config('email.new_ad_notify')) {
$url_ad = $user->ql('ad', array('category' => $data['cat'], 'seotitle' => $seotitle), TRUE);
//.........这里部分代码省略.........