本文整理汇总了PHP中Gallery::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Gallery::save方法的具体用法?PHP Gallery::save怎么用?PHP Gallery::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gallery
的用法示例。
在下文中一共展示了Gallery::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AddGallerySave
public function AddGallerySave()
{
$array_value = array('img' => Input::file('image'));
$array_check = array('img' => array('required', 'mimes:png,gif,jpg,jpeg'));
$validator = Validator::make($array_value, $array_check);
if ($validator->fails()) {
$error = $validator->messages()->toArray();
$gallery = Gallery::all();
return View::make('admin.gallery.gallery')->with('gallery_img', $gallery)->with('error_gallery', $error);
} else {
$path = 'uploadgallery';
$type = Input::file('image')->getClientOriginalExtension();
$imgName = rand(1111111, 9999999) . time() . "." . $type;
$upload = Input::file('image')->move($path, $imgName);
if ($upload) {
$gallery = new Gallery();
$gallery->img = $imgName;
$gallery->save();
if ($gallery->save()) {
$gallery = Gallery::all();
return View::make('admin.gallery.gallery')->with('gallery_img', $gallery)->with('gallery_ok', '');
}
}
}
}
示例2: add_gallery
public function add_gallery()
{
$this->_checkPermission();
$data = $_POST['gallery'];
Flash::set('postdata', $data);
$image = $_POST['upload'];
$path = str_replace('..', '', $image['path']);
$overwrite = false;
// verification
// if (empty($data['title'])){
// Flash::set('error', __('You have to specify a gallery name!'));
// redirect(get_url('gallery/create'));
// }
// if (empty($data['url'])){
// Flash::set('error', __('You have to specify the URL!'));
// redirect(get_url('gallery/create'));
// }
if (isset($_FILES)) {
// no image file selected
if (empty($_FILES['upload_file']['name'])) {
Flash::set('error', __('You have to select a image to be uploaded!'));
redirect(get_url('gallery/create'));
}
} else {
Flash::set('error', __('You have to select a image to be uploaded!'));
redirect(get_url('gallery/create'));
}
$gallery = new Gallery($data);
$gallery->created_by_id = AuthUser::getId();
$gallery->created_on = date('Y-m-d H:i:s');
if (!$gallery->save()) {
Flash::set('error', __('Gallery is not added!'));
redirect(get_url('gallery/create'));
} else {
if (isset($_FILES)) {
$gallery_id = $gallery->lastInsertId();
$file = $this->upload_file($_FILES['upload_file']['name'], FILES_DIR . '/gallery/images/', $_FILES['upload_file']['tmp_name'], $overwrite, $gallery_id);
if ($file === false) {
Flash::set('error', __('Gallery image has not been uploaded!'));
}
//Add Image to database
$data = $_POST['gallery'];
Flash::set('post_data', (object) $data);
$gallery = Record::findByIdFrom('Gallery', $gallery_id);
if (!$gallery->update('Gallery', array('filename' => $file), 'id=' . $gallery_id)) {
Flash::set('error', __('Image has not been updated.'));
} else {
Flash::set('success', __('Gallery has been updated!'));
if (isset($_POST['commit'])) {
redirect(get_url('gallery'));
} else {
redirect(get_url('gallery/view/' . $gallery->id));
}
}
}
Flash::set('success', __('Gallery has been added!'));
}
redirect(get_url('gallery'));
}
示例3: actionCreate
/**
* Создает новую модель галереи.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @return void
*/
public function actionCreate()
{
$model = new Gallery();
if (($data = Yii::app()->getRequest()->getPost('Gallery')) !== null) {
$model->setAttributes($data);
if ($model->save()) {
Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('GalleryModule.gallery', 'Record was created'));
$this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create']));
}
}
$this->render('create', ['model' => $model]);
}
示例4: testFilterGalleryAttributesFromMetaFieldsWhenSaves
public function testFilterGalleryAttributesFromMetaFieldsWhenSaves()
{
$attributes = ['post_content' => 'Dummy Content.', 'post_title' => 'Dummy Title', 'post_date' => date('Y-m-d H:i:s'), 'pal_user_id' => 1, 'pal_gallery_id' => 1];
$gallery = new Gallery($attributes);
$gallery->save();
$attributes = $gallery->getAttributes();
assertThat($attributes, hasKey('post_content'));
assertThat($attributes, hasKey('post_title'));
assertThat($attributes, hasKey('post_date'));
assertThat($attributes, not(hasKey('pal_user_id')));
assertThat($attributes, not(hasKey('pal_gallery_id')));
}
示例5: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Gallery();
if (isset($_POST['Gallery'])) {
$model->attributes = $_POST['Gallery'];
$model->user_id = Yii::app()->getUser()->getId();
if ($model->save()) {
Yii::app()->user->setFlash('success', '创建成功');
$this->redirect(array('update', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Gallery();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Gallery'])) {
$model->attributes = $_POST['Gallery'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例7: beforeSave
/** Will create new gallery after save if no associated gallery exists */
public function beforeSave($event)
{
parent::beforeSave($event);
if ($event->isValid) {
if (empty($this->getOwner()->{$this->idAttribute})) {
$gallery = new Gallery();
$gallery->name = $this->name;
$gallery->description = $this->description;
$gallery->versions = $this->versions;
$gallery->save();
$this->getOwner()->{$this->idAttribute} = $gallery->id;
}
}
}
示例8: actionCreate
/**
* Создает новую модель галереи.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @return void
*/
public function actionCreate()
{
$model = new Gallery();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (($data = Yii::app()->getRequest()->getPost('Gallery')) !== null) {
$model->setAttributes($data);
if ($model->save()) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('GalleryModule.gallery', 'Record was created'));
$this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', array('create')));
}
}
$this->render('create', array('model' => $model));
}
示例9: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$photos = Input::file('photo');
foreach ($photos as $photo) {
$gallery = new Gallery();
$gallery->school_id = $id;
$gallery->photo = $photo;
try {
$gallery->save();
} catch (Exception $exc) {
return Response::make($exc->getMessage(), 500);
}
}
}
示例10: foreach
function save_orderlist($id = FALSE)
{
if ($_POST) {
foreach ($_POST['orderlist'] as $key => $item) {
if ($item) {
$gallery = new Gallery(@$_POST['orderid'][$key]);
$gallery->from_array(array('orderlist' => $item));
$gallery->save();
}
}
set_notify('success', lang('save_data_complete'));
}
redirect($_SERVER['HTTP_REFERER']);
}
示例11: LoadGallery
public static function LoadGallery($id)
{
$id = _xls_number_only($id);
if ($id > 1000) {
$id = 1000;
}
$gallery = Gallery::model()->findByPk($id);
if (!$gallery) {
$gallery = new Gallery();
$gallery->id = $id;
$gallery->name = true;
$gallery->description = true;
$gallery->versions = array('small' => array('resize' => array(200, null)), 'medium' => array('resize' => array(800, null)));
$gallery->save();
}
return $gallery;
}
示例12: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Gallery();
$photos = new GalleryPhoto();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Gallery'])) {
$model->attributes = $_POST['Gallery'];
if ($photoCover = $model->getCover()) {
$model->cover_photo_id = $photoCover->id;
}
if ($model->save()) {
$this->redirect(array('update?id=' . $model->id));
}
}
$this->render('create', array('model' => $model, 'photos' => $photos));
}
示例13: post_create
/**
* Creates our gallery when POSTed to. Performs snazzy validation.
* @return [type] [description]
*/
public function post_create()
{
$rules = array('title' => 'required|max:255');
$validation = Validator::make(Input::all(), $rules);
if ($validation->fails()) {
Messages::add('error', $validation->errors->all());
return Redirect::to('admin/' . $this->views . '/create')->with_input();
} else {
$gallery = new Gallery();
$gallery->title = Input::get('title');
$gallery->description = Input::get('description');
$gallery->created_by = $this->data['user']->id;
$gallery->save();
Messages::add('success', 'Gallery Added');
return Redirect::to('admin/' . $this->views . '');
}
}
示例14: save
function save($cat_id, $id = FALSE)
{
if ($_POST) {
$gallery = new Gallery($id);
if ($_FILES['image']['name']) {
if ($gallery->id) {
$gallery->delete_file($gallery->id, 'uploads/galleries/', 'image');
}
$_POST['image'] = $gallery->upload($_FILES['image'], 'uploads/galleries/');
$gallery->thumb('uploads/galleries/thumbs/', 170, 120);
}
$_POST['user_id'] = $this->session->userdata('id');
$gallery->from_array($_POST);
$gallery->save();
set_notify('success', lang('save_data_complete'));
}
redirect('galleries/admin/galleries/form/' . $cat_id);
}
示例15: post_create
public function post_create()
{
$new_gallery = array('title' => trim(Input::get('title')), 'slug' => trim(Input::get('slug')), 'visibility' => trim(Input::get('visible')));
// set up rules for new data
$rules = array('title' => 'required|min:3|max:128', 'slug' => 'unique:galleries,slug');
// make the validator
$v = Validator::make($new_gallery, $rules);
if ($v->fails()) {
// redirect to form
// errors
return Redirect::to('user/galleries/create')->with_errors($v)->with_input();
}
// create the new post
$gallery = new Gallery($new_gallery);
$gallery->save();
// add organisations to Organisation_Post
foreach (Input::get('organisations') as $org_id) {
$gallery->organisations()->attach($org_id);
}
// redirect to posts
return Redirect::to('user/galleries')->with('success', 'A new gallery has been created');
}