public function actionGenerate()
 {
     if (isset($_POST['SlideForm'])) {
         $error = "";
         if (empty($_POST['SlideForm']['name'])) {
             $error = "name";
         }
         if (empty($_POST['SlideForm']['content'])) {
             $error = "content";
         }
         if (Env::getCurrentUser() == null) {
             $error = "auth";
         }
         if (Env::getCurrentUser()->isBanned()) {
             $error = "banned";
         }
         if (!empty($error)) {
             Env::setCookie("slider_content", $_POST['SlideForm']['content']);
             Env::setCookie("slider_name", $_POST['SlideForm']['name']);
             $this->redirect('/post/create/#error-' . $error);
         } else {
             Env::deleteCookie("slider_content");
             Env::deleteCookie("slider_name");
             $slide = new Slide();
             $slide->name = Env::clear($_POST['SlideForm']['name']);
             $slide->content = $_POST['SlideForm']['content'];
             $slide->save();
             $this->redirect('/slider');
         }
     }
 }
示例#2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Slide();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Slide'])) {
         $model->attributes = $_POST['Slide'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function postCriarSlide()
 {
     $file = Input::file('imagem');
     $imageNome = $file->getClientOriginalName();
     $pasta = public_path() . '/assets_site/images/slider/';
     $upload_success = $file->move($pasta, $imageNome);
     if ($upload_success) {
         $img = new Slide();
         $img->foto = 'assets_site/images/slider/' . $imageNome;
         $img->link = Input::get('link');
         $img->save();
         Session::flash('message', 'Slide cadastrodo com sucesso!');
     } else {
         Session::flash('message', 'Erro ao cadastrar o slide!');
     }
     return Redirect::to('admin/slide');
 }