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


PHP Banner::save方法代码示例

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


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

示例1: createAction

 public function createAction()
 {
     $this->view->Title = "Quản lý quảng cáo";
     $this->view->headTitle($this->view->Title);
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest()->getParams();
         $Banner = new Banner();
         $Banner->merge($request);
         if ($Banner->trySave()) {
             $folder = $Banner->id;
         }
         if ($_FILES['images']['name']) {
             $dirname = "uploads/banner/" . $folder . "/";
             $upload = new My_Plugin_Upload();
             $error = $upload->uploadImageFile($_FILES['images'], 2048, 1024, 1024000, array("image/png", "image/jpg", "image/gif", "image/x-png", "image/jpeg"), $dirname);
             if (!$error) {
                 $filename = $upload->fileName;
             }
         }
         if (count($error) == 0) {
             if ($filename != "") {
                 $Banner->image = $filename;
             }
             $Banner->save();
             $this->Member->log('Quảng cáo:' . $Banner->name . '(' . $Banner->id . ')', 'Tạo mới');
             My_Plugin_Libs::setSplash('Quảng cáo: <b>' . $Banner->name . '</b> đã tạo thành công. ');
             $this->_redirect($this->_helper->url('index', 'banner', 'admin'));
         }
         if (count($error)) {
             $this->view->error = $error;
         }
     }
 }
开发者ID:hoaitn,项目名称:base-zend,代码行数:33,代码来源:BannerController.php

示例2: active

 function active($id)
 {
     $banners = new Banner($id);
     if (!$banners->exists()) {
         show_404();
     }
     $banners->active = ($banners->active + 1) % 2;
     if ($banners->save()) {
         flash_message('success', 'Thành công. Thao tác đã được thực hiện.');
         redirect($this->admin . 'banners/list_all/');
     }
 }
开发者ID:lxthien,项目名称:batdongsan,代码行数:12,代码来源:banners_bak.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Banner();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Banner'])) {
         $model->attributes = $_POST['Banner'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:R-thomas,项目名称:shopMob,代码行数:17,代码来源:BannerController.php

示例4: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Banner();
     $this->tituloManual = "Cadastrar banner";
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Banner'])) {
         $model->attributes = $_POST['Banner'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('arrayTipoSabor' => TipoSabor::getArrayTipoSabor(), 'model' => $model));
 }
开发者ID:BrunoCheble,项目名称:novopedido,代码行数:18,代码来源:BannerController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $authuser = Auth::user();
     if (!File::exists('images/banners/')) {
         $result = File::makeDirectory('images/banners/', 0777);
     }
     $rules = array('seccion' => 'required', 'imagen' => 'required|mimes:png,gif,jpeg,txt,pdf,doc,rtf|max:200000000');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('vistausuario/banners/create')->withErrors($validator)->withInput();
     } else {
         $file = Input::file('imagen');
         $id = Str::random(4);
         $date_now = new DateTime();
         $destinationPath = 'images/banners/';
         $filename = $date_now->format('YmdHis') . $id;
         $mime_type = $file->getMimeType();
         $extension = $file->getClientOriginalExtension();
         $upload_success = $file->move($destinationPath, $filename . '.' . $extension);
         $banner = new Banner();
         $banner->usuario_id = $authuser->id;
         $banner->banner_img = $filename . '.' . $extension;
         $banner->solicitar_habilitar = 1;
         $banner->habilitar = 0;
         $banner->link = Input::get('link');
         $banner->seccion = Input::get('seccion');
         $banner->save();
         //TODO: Crear pago pendiente
         //Generar row en cobros y cobros_pendientes
         //'BLOG-IZQUIERDA' => 'BLOG - IZQUIERDA', 'BLOG-DERECHA' => 'BLOG - DERECHA','DIRECTORIO-IZQUIERDA' => 'DIRECTORIO - IZQUIERDA', 'DIRECTORIO-DERECHA' => 'DIRECTORIO - DERECHA','EVENTOS-IZQUIERDA' => 'EVENTOS - IZQUIERDA', 'EVENTOS-DERECHA' => 'EVENTOS - DERECHA','CLASIFICADOS-IZQUIERDA' => 'CLASIFICADOS - IZQUIERDA', 'CLASIFICADOS-DERECHA' => 'CLASIFICADOS - DERECHA','VIDEOBLOG-IZQUIERDA' => 'VIDEOBLOG - IZQUIERDA', 'VIDEOBLOG-DERECHA' => 'VIDEOBLOG - DERECHA'
         $cobrotipoBanner = CobroTipo::where('tipo', 'BANNER-' . Input::get('seccion'))->first();
         $cobro = new Cobro();
         $cobro->tipo_id = $cobrotipoBanner->id;
         $cobro->usuario_id = $authuser->id;
         $cobro->estado = 'pendiente';
         $cobro->datosAdicionales = $banner->id;
         $cobro->save();
         $id = Str::random(4);
         $date_now = new DateTime();
         $cobrop = new CobroPendiente();
         $cobrop->cobro_id = $cobro->id;
         $cobrop->fecha = $date_now;
         $cobrop->cobro_concepto = 'TODCONS' . $cobro->id . 'BANN' . $banner->id . $date_now->format('YmdHi') . $id;
         // Concepto = clave_empresa+ clave_cobro+ clave_tipo_cobro + clave_objeto_de_cobro + fecha+4_digitos_random (Por favor mejorar!!)
         $cobrop->save();
         return Redirect::to("vistausuario/banners")->with(array('usuarioimg' => $authuser->imagen, 'usuarionombre' => $authuser->nombre, 'usuarioid' => $authuser->id));
     }
 }
开发者ID:ubx-caloca,项目名称:todoconstruimos,代码行数:54,代码来源:BannersVistaController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = ['empresa' => 'required', 'file' => 'required'];
     if (!Banner::isValid(Input::all(), $rules)) {
         return Redirect::back()->withInput()->withErrors(Banner::$errors);
     }
     $banner = new Banner();
     $banner->empresa = Input::get('empresa');
     $banner->file = Input::get('file');
     $banner->link = Input::get('link');
     $banner->posicion = Input::get('posicion');
     $banner->activo = Input::get('activo');
     $banner->save();
     return Redirect::to('/banners');
 }
开发者ID:keloxers,项目名称:Cooperativa,代码行数:20,代码来源:BannersController.php

示例7: actionCreate

 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl('banner_create');
     $model = new Banner();
     if (isset($_POST['Banner'])) {
         $file = XUpload::upload($_FILES['attach']);
         $model->attributes = $_POST['Banner'];
         if (is_array($file)) {
             $model->image = $file['pathname'];
         }
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入banner,ID:' . $model->id));
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:zywh,项目名称:maplecity,代码行数:21,代码来源:BannerController.php

示例8: actionAdd

 public function actionAdd()
 {
     if (empty($_POST)) {
         $stations = Banner::model()->getBannertSation();
         $viewData = array();
         $viewData['stations'] = $stations;
         $this->render('add', $viewData);
         exit;
     }
     $res = array('statusCode' => 200, 'message' => '添加成功!');
     try {
         $banner_name = '';
         $image = CUploadedFile::getInstanceByName('banner_image');
         if ($image) {
             $dir = Yii::getPathOfAlias('webroot') . '/images/banner';
             // $extension = substr(strrchr($image->name, '.'), 1);
             $extension = $image->getExtensionName();
             $banner_name = time() . '_' . rand(100, 999) . '.' . $extension;
             $imagePath = $dir . '/' . $banner_name;
             $image->saveAs($imagePath, true);
         }
         $m = new Banner();
         $m->title = $_REQUEST['title'];
         $m->station = $_REQUEST['station'];
         $m->img = $banner_name;
         $m->link = $_REQUEST['link'];
         $m->sort = $_REQUEST['sort'];
         $m->is_show = $_REQUEST['is_show'];
         $m->start_time = strtotime($_REQUEST['start_time']);
         $m->end_time = strtotime($_REQUEST['end_time']);
         $m->add_time = time();
         $flag = $m->save();
         if (!$flag) {
             throw new exception('添加失败');
         }
     } catch (Exception $e) {
         $res['statusCode'] = 300;
         $res['message'] = '失败【' . $e->getMessage() . '】';
     }
     $res['navTabId'] = 'bannerList';
     $res['callbackType'] = 'closeCurrent';
     $res['forwardUrl'] = '/manage/banner/index';
     $this->ajaxDwzReturn($res);
 }
开发者ID:conghua1013,项目名称:yii,代码行数:44,代码来源:BannerController.php

示例9: insert

 public function insert()
 {
     $rules = array('image_banner' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('admin/addbanner')->withErrors($validator)->withInput();
     } else {
         $image = explode(url() . '/', Input::get('image_banner'));
         $realpath = public_path($image[1]);
         $newname = date('YmdHis') . '.jpg';
         File::move($realpath, 'images/slider/' . $newname);
         // insert to db
         $banner = new Banner();
         $banner->image = 'images/slider/' . $newname;
         $banner->save();
         Session::flash('success', 'New banner created');
         return Redirect::to('admin/banners');
     }
 }
开发者ID:ChavezRuston,项目名称:fansemo,代码行数:19,代码来源:BannerController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $validation = Validate::BannerValidation(Input::all());
     if ($validation->fails()) {
         return Redirect::to('banner/create')->withErrors($validation)->withInput();
     } else {
         $banner = new Banner();
         $banner->title = Input::get('title');
         $banner->image = "";
         $banner->save();
         mkdir("img/banners/" . $banner->id, 0700);
         $destinationPath = 'img/banners/' . $banner->id;
         $filename = $banner->id . "." . Input::file('image')->getClientOriginalExtension();
         Input::file('image')->move($destinationPath, $filename);
         $banner2 = Banner::find($banner->id);
         $banner2->image = 'img/banners/' . $banner->id . "/" . $filename;
         $banner2->save();
         return Redirect::to('admin/banner');
     }
 }
开发者ID:abrahammontas,项目名称:Supplements-online-store,代码行数:26,代码来源:BannerController.php

示例11: banners

 public function banners($do = '', $id = '')
 {
     $this->data['heading'] = 'Administrasi: Banner';
     switch ($do) {
         case 'form':
             if (post('submit')) {
                 $data = [User::primary() => 1, 'tgl_input' => date('Y-m-d'), 'judul' => post('judul'), 'keterangan' => post('keterangan'), 'url' => post('url'), 'gambar' => post('gambar'), 'tgl_mulai' => formatTanggal(post('tgl_mulai'), 'Y-m-d'), 'tgl_akhir' => formatTanggal(post('tgl_akhir'), 'Y-m-d'), 'aktif' => post('aktif'), 'tipe' => post('tipe')];
                 try {
                     $upload = new Upload('gambar');
                     $data['gambar'] = $upload->doUpload();
                 } catch (Exception $e) {
                     setAlert('error', $e->getMessage());
                 }
                 if (Banner::save($data, $id)) {
                     if ($id) {
                         setAlert('success', 'Berhasil memperbarui data banner <b>' . $data['judul'] . '</b>');
                     } else {
                         setAlert('success', 'Berhasil menambahkan banner <b>' . $data['judul'] . '</b>');
                     }
                     return redirect('admin-shop/banners');
                 }
                 setAlert('error', 'Terjadi kesalahan dalam penyimpanan banner <b>' . $data['judul'] . '</b>');
                 return redirect($this->uri->path());
             } else {
                 if ($id) {
                     $this->data['data'] = Banner::show([Banner::primary() => $id])->fetchOne();
                 }
                 return $this->render('banner-form', $this->data);
             }
             break;
         case 'delete':
             if (Banner::del([Banner::primary() => $id])) {
                 setAlert('success', 'Banner berhasil terhapus');
             } else {
                 setAlert('error', 'Terjadi kesalahan dalam penghapusan banner');
             }
             return redirect('admin-shop/banners');
             break;
         default:
             $this->data['data'] = Banner::show();
             return $this->render('banner-table', $this->data);
             break;
     }
 }
开发者ID:tommyputranto,项目名称:tokonlen,代码行数:44,代码来源:AdminShop.class.php

示例12: basename

 function upload_file($origin, $dest, $tmp_name, $overwrite = false)
 {
     FileManagerController::_checkPermission();
     $origin = basename($origin);
     $full_dest = $dest . $origin;
     $file_name = $origin;
     for ($i = 1; file_exists($full_dest); $i++) {
         if ($overwrite) {
             unlink($full_dest);
             continue;
         }
         $file_ext = strpos($origin, '.') === false ? '' : '.' . substr(strrchr($origin, '.'), 1);
         $file_name = substr($origin, 0, strlen($origin) - strlen($file_ext)) . '_' . $i . $file_ext;
         $full_dest = $dest . $file_name;
     }
     if (move_uploaded_file($tmp_name, $full_dest)) {
         //Add Banner to database
         $data = $_POST['banner'];
         Flash::set('post_data', (object) $data);
         $last_banner = Record::query('Select sequence from ' . TABLE_PREFIX . 'banner order by sequence desc LIMIT 0,1');
         $last_banner = $last_banner->fetchObject();
         $last_seq = $last_banner->sequence;
         $banner = new Banner($data);
         $banner->filename = $file_name;
         $banner->source = URL_PUBLIC . 'public/banner/' . $file_name;
         $banner->sequence = $last_seq + 1;
         if (!$banner->save()) {
             Flash::set('error', __('Banner has not been added. Name must be unique!'));
             redirect(get_url('banner', 'add'));
         } else {
             Flash::set('success', __('Banner has been added!'));
             //Observer::notify('snippet_after_add', $banner);
         }
         // change mode of the dire to 0644 by default
         chmod($full_dest, 0644);
         return $file_name;
     }
     return false;
 }
开发者ID:sindotnet,项目名称:hotelyan,代码行数:39,代码来源:BannerController.php

示例13: banner_new

	/**
	 * Processes the new banner and redirects to the banner list
	 */
	public function banner_new() {
		
		//	get the validated input
		$input = $this->__validate($_POST);
		
		//	attempt to upload the image
		if (!$input['image'] = $this->__upload('banner',$input)) $this->display('banner/views/edit',$input);
		
		//	set the created date
		$input['created'] = date('Y-m-d H:i:s');
		$input['updated'] = date('Y-m-d H:i:s');
		
		//	save the new banner, if there is an issue delete the uploaded image
		$record = new Banner($input);
		if (!$record->save()) {
			$fullpath = CMS_ROOT."/{$this->settings['imgpath']}/{$input['image']}";
			if (!unlink($fullpath)) {
				Flash::set('error','Banners - '.__('Could not save banner in database and permission denied deleting image!'));
				$this->display('banner/views/edit',$input);
			}
			Flash::set('error','Banners - '.__('Could not save banner in database!'));
			$this->display('banner/views/edit',$input);
		}
		
		//	pat on the back and send back to banner list
		Flash::set('success','Banners - '.__('banner saved!'));
		redirect(get_url('plugin/banner/banner_list'));

	}//*/
开发者ID:realslacker,项目名称:Banner-Plugin,代码行数:32,代码来源:BannerController.php

示例14: Banner

 function banner_save()
 {
     if ($_POST) {
         $banner = new Banner($id);
         $_POST['status'] = "approve";
         $_POST['start_date'] = Date2DB($_POST['start_date']);
         $_POST['end_date'] = Date2DB($_POST['end_date']);
         $banner->from_array($_POST);
         $banner->save();
         set_notify('success', lang('save_data_complete'));
     }
     redirect('home/banner');
 }
开发者ID:unisexx,项目名称:adf16,代码行数:13,代码来源:home.php

示例15: updateBanner

 public function updateBanner()
 {
     if (Input::has('pk')) {
         if (!Request::ajax()) {
             return App::abort(404);
         }
         return self::updateQuickEdit();
     } else {
         if (!Request::ajax()) {
             return App::abort(404);
         }
     }
     $arrReturn = ['status' => 'error'];
     $banner = new Banner();
     $banner->name = Input::get('name');
     $banner->order_no = (int) Input::get('order_no');
     $banner->active = Input::has('active') ? 1 : 0;
     if (Input::hasFile('image')) {
         $oldPath = $banner->image;
         $path = VIImage::upload(Input::file('image'), public_path('assets' . DS . 'images' . DS . 'banners'), 1440, false);
         $path = str_replace(public_path() . DS, '', $path);
         $banner->image = str_replace(DS, '/', $path);
         if ($oldPath == $banner->image) {
             unset($oldPath);
         }
     }
     $pass = $banner->valid();
     if ($pass) {
         $banner->save();
         if (isset($oldPath) && File::exists(public_path($oldPath))) {
             File::delete(public_path($oldPath));
         }
         $arrReturn = ['status' => 'ok'];
         $arrReturn['message'] = $banner->name . ' has been saved';
         $arrReturn['data'] = $banner;
     } else {
         $arrReturn['message'] = '';
         $arrErr = $pass->messages()->all();
         foreach ($arrErr as $value) {
             $arrReturn['message'] .= "{$value}\n";
         }
     }
     $response = Response::json($arrReturn);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
开发者ID:nguyendaivu,项目名称:imagestock,代码行数:46,代码来源:BannersController.php


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