예제 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $destinationPath = '';
     $filename = '';
     $rules = array('title' => 'required|min:3', 'content' => 'required|min:3');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $user = Auth::user();
         $this->post->title = Input::get('title');
         $this->post->slug = Str::slug(Input::get('title'));
         if (Input::hasFile('img_path')) {
             $file = Input::file('img_path');
             $destinationPath = 'public/uploads/';
             $filename = str_random(6) . '_' . $file->getClientOriginalName();
             $uploadSuccess = $file->move($destinationPath, $filename);
             Image::make(sprintf($destinationPath . '%s', $filename))->resize(260, 180)->save();
         }
         $this->post->content = Input::get('content');
         $this->post->meta_title = Input::get('meta-title');
         $this->post->meta_description = Input::get('meta-description');
         $this->post->meta_keywords = Input::get('meta-keywords');
         $this->post->user_id = $user->id;
         $this->post->img_path = $destinationPath . $filename;
         if ($this->post->save()) {
             return Redirect::to('admin/blogs/' . $this->post->id . '/edit')->with('success', Lang::get('admin/blogs/messages.create.success'));
         }
         return Redirect::to('admin/blogs/create')->with('error', Lang::get('admin/blogs/messages.create.error'));
     }
     return Redirect::to('admin/blogs/create')->withInput()->withErrors($validator);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $rules = array('name' => 'required|min:3');
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         $this->escalations->name = Input::get('name');
         $this->escalations->delay = (int) Input::get('delay');
         $this->escalations->reply = Input::get('reply');
         $this->escalations->notify_admins = (int) Input::get('notify_admins');
         $this->escalations->flag = (int) Input::get('flag');
         $this->escalations->priority = json_encode(Input::get('priorities'));
         $this->escalations->new_status = (int) Input::get('new_status');
         $this->escalations->new_priority = (int) Input::get('new_priority');
         $this->escalations->new_department = (int) Input::get('new_department');
         $this->escalations->saveDeps(Input::get('departments'));
         $this->escalations->saveStatuses(Input::get('statuses'));
         $this->escalations->saveFlags(explode(',', Input::get('flags')));
         if ($this->escalations->save()) {
             return Api::to(array('success', Lang::get('l4cp-support::messages.create.success'))) ?: Redirect::to('admin/support/escalations/' . $this->escalations->id . '/edit')->with('success', Lang::get('l4cp-support::messages.create.success'));
         } else {
             return Api::to(array('error', Lang::get('l4cp-support::messages.create.error'))) ?: Redirect::to('admin/support/escalations/create')->with('error', Lang::get('l4cp-support::messages.create.error'));
         }
     } else {
         return Api::to(array('error', Lang::get('l4cp-support::messages.create.error'))) ?: Redirect::to('admin/support/escalations/create')->withInput()->withErrors($validator);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $rules = array('name' => 'required|min:3', 'flags' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         $this->department->name = Input::get('name');
         $this->department->description = Input::get('description');
         $this->department->email = Input::get('email');
         $this->department->pop_host = Input::get('pop_host');
         $this->department->pop_port = Input::get('pop_port');
         $this->department->pop_user = Input::get('pop_user');
         $this->department->pop_pass = Input::get('pop_pass');
         $this->department->clients_only = (int) Input::get('clients_only');
         $this->department->auto_respond = (int) Input::get('auto_respond');
         $this->department->hidden = (int) Input::get('hidden');
         $this->department->sort = (int) Input::get('sort');
         $this->department->saveFlags(Input::get('flags'));
         if ($this->department->save()) {
             return Api::to(array('success', Lang::get('l4cp-support::messages.create.success'))) ?: Redirect::to('admin/support/departments/' . $this->department->id . '/edit')->with('success', Lang::get('l4cp-support::messages.create.success'));
         } else {
             return Api::to(array('error', Lang::get('l4cp-support::messages.create.error'))) ?: Redirect::to('admin/support/departments/create')->with('error', Lang::get('l4cp-support::messages.create.error'));
         }
     } else {
         return Api::to(array('error', Lang::get('l4cp-support::messages.create.error'))) ?: Redirect::to('admin/support/departments/create')->withInput()->withErrors($validator);
     }
 }
예제 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     // Declare the rules for the form validation
     $rules = array('title' => 'required|min:3', 'content' => 'required|min:3');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Create a new blog post
         $user = Auth::user();
         // Update the blog post data
         $this->post->title = Input::get('title');
         $this->post->slug = Str::slug(Input::get('title'));
         $this->post->content = Input::get('content');
         $this->post->meta_title = Input::get('meta-title');
         $this->post->meta_description = Input::get('meta-description');
         $this->post->meta_keywords = Input::get('meta-keywords');
         $this->post->user_id = $user->id;
         // Was the blog post created?
         if ($this->post->save()) {
             // Redirect to the new blog post page
             return Redirect::to('admin/blogs/' . $this->post->id . '/edit')->with('success', Lang::get('admin/blogs/messages.create.success'));
         }
         // Redirect to the blog post create page
         return Redirect::to('admin/blogs/create')->with('error', Lang::get('admin/blogs/messages.create.error'));
     }
     // Form validation failed
     return Redirect::to('admin/blogs/create')->withInput()->withErrors($validator);
 }
 /**
  * Tests correct date/time setting.
  *
  * @return void
  * @since 0.1.0
  */
 public function testBehavior()
 {
     // mocking failed :(
     /*$post = Stub::Make(
           'Post',
           array(
               'insert' => function () {
                   return true;
               },
               'update' => function () {
                   return true;
               },
               'name' => 'Dummy name',
               'content' => 'Dummiest content',
               'user_id' => 1,
               'category_id' => 1,
           )
       );*/
     $post = new \Post();
     $post->setAttributes(array('name' => 'Dummy name', 'content' => 'Dummiest content', 'user_id' => 1, 'category_id' => 1), false);
     $this->assertNull($post->created);
     $post->save();
     $dt = new \DateTime();
     $this->assertSame($dt->format(\DateTime::ISO8601), $post->created);
     usleep(1.1 * 1000 * 1000);
     $post->save();
     $this->assertSame($dt->format(\DateTime::ISO8601), $post->created);
 }
 public function testLockedFields()
 {
     $post = new Post();
     $post->activateLocker();
     $post->activateLockCheck();
     $post->setTitle('A super book');
     $post->save();
     $this->assertTrue($post->getTitleLock());
     $this->assertEquals('A super book', $post->getTitle());
     $post->setTitle('New Title');
     $this->assertEquals('New Title', $post->getTitle());
     $post->save();
     $this->assertEquals('A super book', $post->getTitle());
 }
예제 #7
0
 public function store()
 {
     $files = Input::file('path');
     $filesStatus = Input::get('file_status');
     $status = 'success';
     if ($files == null) {
         Session::flash('status', 'false');
         $errors_message[] = "Over max upload size!";
         Session::flash('errors_message', $errors_message);
         return Redirect::to('user/upload')->header('Cache-Control', 'no-store, no-cache');
     }
     foreach ($files as $index => $file) {
         if ($file->isValid() && $filesStatus[$index] != 0) {
             $post = new Post();
             $post->save();
             $album = $this->saveAlbum($index, $post);
             if ($album) {
                 if (!$this->saveImage($index, $album->id, $post)) {
                     $status = 'false';
                     break;
                 }
             } else {
                 $status = 'false';
                 break;
             }
         }
     }
     Session::flash('status', $status);
     return Redirect::to('album/create')->header('Cache-Control', 'no-store, no-cache');
 }
 public function run()
 {
     $user = User::firstOrFail();
     $post1 = new Post();
     $post1->title = 'First post';
     $post1->subtitle = 'This is a subtitle';
     $post1->content = 'It is super easy to create a new post.';
     $post1->image = 'This is an image';
     $post1->user_id = $user->id;
     $post1->save();
     $post2 = new Post();
     $post2->title = 'Second post';
     $post2->subtitle = 'This is a subtitle';
     $post2->content = 'It is super easy to create a new post.';
     $post2->image = 'This is an image';
     $post2->user_id = $user->id;
     $post2->save();
     $post3 = new Post();
     $post3->title = 'Third post';
     $post3->subtitle = 'This is a subtitle';
     $post3->content = 'It is super easy to create a new post.';
     $post3->image = 'This is an image';
     $post3->user_id = $user->id;
     $post3->save();
     $post4 = new Post();
     $post4->title = 'Fourth post';
     $post4->subtitle = 'This is a subtitle';
     $post4->content = 'It is super easy to create a new post.';
     $post4->image = 'This is an image';
     $post4->user_id = $user->id;
     $post4->save();
 }
예제 #9
0
 public function run()
 {
     $user = User::firstOrFail();
     $post1 = new Post();
     $post1->title = '1st Blog Post';
     $post1->username = '******';
     $post1->date = '2016-01-11';
     $post1->description = 'This is my first blog post on my laravel blog';
     $post1->user_id = $user->id;
     $post1->save();
     $post2 = new Post();
     $post2->title = '2nd Blog Post';
     $post2->username = '******';
     $post2->date = '2016-01-11';
     $post2->description = 'This is my second blog post.';
     $post2->user_id = $user->id;
     $post2->save();
     $post3 = new Post();
     $post3->title = '3rd Blog Post';
     $post3->username = '******';
     $post3->date = '2016-01-11';
     $post3->description = 'This is my third blog post';
     $post3->user_id = $user->id;
     $post3->save();
 }
예제 #10
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Post::$rules);
     if ($validator->fails()) {
         Session::flash('errorMessage', 'Something went wrong here!');
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $post = new Post();
         $post->title = Input::get('title');
         $post->body = Input::get('body');
         $post->user_id = Auth::id();
         if (Input::hasFile('picture')) {
             if (Input::file('picture')->isValid()) {
                 Storage::upload(Input::file('picture'), "{$post->picture}" . "jpg");
             }
             $post->picture = Input::file('picture');
         }
         if (Input::has('tags')) {
             $post->tags = implode(', ', Input::get('tags'));
         }
         $post->save();
         $posts = Post::paginate(5);
         Session::flash('goodMessage', 'All went right here!');
         return View::make('posts/index')->with('posts', $posts);
     }
 }
 public function testCounterIncrementsAndDecrementsWhen()
 {
     $post_with_comments = new Post();
     $post_with_comments->title = 'post 1';
     $this->assertTrue($post_with_comments->save());
     $post_without_comments = new Post();
     $post_without_comments->title = 'post 2';
     $this->assertTrue($post_without_comments->save());
     //Create 10 comments, ensure counter increments
     for ($i = 1; $i <= 10; $i++) {
         $comment = new Comment();
         $comment->postId = $post_with_comments->id;
         $comment->text = 'comment ' . $i;
         $this->assertTrue($comment->save());
         $post_with_comments->refresh();
         $post_without_comments->refresh();
         $this->assertEquals($post_with_comments->commentsCount, $i);
         $this->assertEquals($post_without_comments->commentsCount, 0);
     }
     //Delete all comments, ensure counter decrements
     $comments = Comment::find()->all();
     $count = count($comments);
     foreach ($comments as $comment) {
         $this->assertEquals($comment->delete(), 1);
         $count--;
         $post_with_comments->refresh();
         $this->assertEquals($post_with_comments->commentsCount, $count);
     }
 }
예제 #12
0
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 30; $i++) {
         $tags = ['funny', 'troll', 'sad', 'current', 'serious', 'music', 'gaming', 'technology', 'business'];
         $j = 0;
         $tempArray = [];
         $randomNum = mt_rand(1, 3);
         $post = new Post();
         $post->title = $faker->catchPhrase . " " . $faker->catchPhrase;
         $post->body = $faker->realText(200, 2);
         $post->picture = $faker->image($dir = '/tmp', $width = 640, $height = 480);
         $post->user_id = User::all()->random(1)->id;
         do {
             $tag = $tags[mt_rand(0, sizeof($tags) - 1)];
             if ($j <= 1) {
                 array_push($tempArray, $tag);
                 unset($tags[$tag]);
             } else {
                 $tempArray = ["{$tag}"];
                 unset($tags[$tag]);
             }
             //var j to determine how many elements have been pushed
             $j++;
             $randomNum--;
         } while ($randomNum == 0);
         $post->tags = implode(", ", $tempArray);
         $post->save();
     }
 }
예제 #13
0
 public function actionCreateImage($feed)
 {
     $feed = $this->loadFeed($feed);
     $post = new Post(Post::IMAGE);
     $post->type = Post::IMAGE;
     $post->user_id = Yii::app()->user->id;
     $post->feed_id = $feed->id;
     if ($feed->project) {
         $post->status = $feed->project->status;
     }
     $image = new Image();
     if (!isset($_POST['Post']) || !isset($_POST['Image'])) {
         $this->render('create-image', array('post' => $post, 'image' => $image));
         Yii::app()->end();
     }
     $post->attributes = $_POST['Post'];
     $image->attributes = $_POST['Image'];
     $image->file = CUploadedFile::getInstance($image, 'file');
     if (!$image->save()) {
         $this->render('create-image', array('post' => $post, 'image' => $image));
         Yii::app()->end();
     }
     $post->attributes = $_POST['Post'];
     $post->image_id = $image->id;
     if (!$post->save()) {
         $image->delete();
         $this->render('create-image', array('post' => $post, 'image' => $image));
         Yii::app()->end();
     }
     $this->renderText('window.parent.location = "' . $this->createUrl('view', array('id' => $post->id)) . '";');
 }
예제 #14
0
 public function run()
 {
     $user = User::firstOrFail();
     $post1 = new Post();
     $post1->title = 'Zee\'s first blog';
     $post1->body = 'This is a blog post about my time creating my personal website. It has been interesting.';
     $post1->user_id = $user->id;
     $post1->save();
     $post2 = new Post();
     $post2->title = 'What new language should I learn? ';
     $post2->body = 'there has been plenty of talk about Python and Ruby. I don\'t know which way to go. But, I think Javascript is where I am going to focus mos tof my practice.... for now.';
     $post2->user_id = $user->id;
     $post2->save();
     $post3 = new Post();
     $post3->title = 'Codeup is where this was created.';
     $post3->body = 'Codeup is where I spent the last 6 months developing my skills as a software engineer. Locate din the heart of San Antonio, it has helped a few hundred folks get into the coding world.';
     $post3->user_id = $user->id;
     $post3->save();
     $post4 = new Post();
     $post4->title = 'Practice, Practice, Practice';
     $post4->body = 'Practice makes perfect, right? Well I need to keep developing my skills. Upddating and changing my website as needed.';
     $post4->user_id = $user->id;
     $post4->save();
     $post5 = new Post();
     $post5->title = 'This is a blog post about my life.';
     $post5->body = 'Born and raised in DFW, I moved to Austin at 18 years old. I have loved it ever since. It is the only city I have ever called home.';
     $post5->user_id = $user->id;
     $post5->save();
 }
예제 #15
0
 public function run()
 {
     $user = User::firstOrFail();
     $post1 = new Post();
     $post1->title = "Title 1";
     $post1->content = "Content 1";
     $post1->user_id = $user->id;
     $post1->save();
     $post2 = new Post();
     $post2->title = "Title 2";
     $post2->content = "Content 2";
     $post2->user_id = $user->id;
     $post2->save();
     $post3 = new Post();
     $post3->title = "Title 3";
     $post3->content = "Content 3";
     $post3->user_id = $user->id;
     $post3->save();
     $post4 = new Post();
     $post4->title = "Title 4";
     $post4->content = "Content 4";
     $post4->user_id = $user->id;
     $post4->save();
     $post5 = new Post();
     $post5->title = "Title 5";
     $post5->content = "Content 5";
     $post5->user_id = $user->id;
     $post5->save();
 }
예제 #16
0
파일: refresh.php 프로젝트: noose/Planeta
function parseItem($blog, $item, $ts)
{
    if ($ts != 0 && $item->pubdate <= $ts) {
        logmsg('Zatrzymanie na wpisie: %s', StringUtils::removeAccents($item->title));
        return false;
    }
    logmsg('  - Parsowanie wpisu: %s', StringUtils::removeAccents($item->title));
    $post = new Post();
    $post->setBlog($blog);
    foreach ($item->tags as $name) {
        $tag = TagPeer::retriveByName($name, true);
        if ($post->addTag($tag)) {
            logmsg('    - Znaleziono tag: %s', $name);
        }
    }
    if ($post->hasTags()) {
        $shortened = $post->setFullContent($item->content);
        $post->setLink(htmlspecialchars($item->link));
        $post->setTitle($item->title);
        $post->setCreatedAt($item->pubdate);
        $post->setShortened($shortened);
        $post->save();
    } else {
        logmsg('    - Nie znaleziono tagow');
    }
    return true;
}
예제 #17
0
 public static function createPost($input)
 {
     $answer = [];
     $rules = ['title' => 'required', 'body' => 'required', 'user_id' => 'required|integer'];
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         $answer['message'] = $validation->errors()->getMessages();
         $answer['error'] = true;
     } else {
         $post = new Post();
         $post->title = Input::get('title');
         $post->image_url = Input::get('image_url');
         $post->body = Input::get('body');
         $post->user_id = Input::get('user_id');
         $post->status = 1;
         if ($post->save()) {
             $answer['message'] = 'Creado con exito!';
             $answer['error'] = false;
             $answer['data'] = $post;
         } else {
             $answer['message'] = 'CREATE error, team noob!';
             $answer['error'] = false;
         }
     }
     return $answer;
 }
예제 #18
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $rules = array('title' => 'required|min:3');
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes() && (Input::get('user_id') || Input::get('email'))) {
         if (Input::get('user_id')) {
             $this->tickets->user_id = Input::get('user_id');
         }
         $this->tickets->admin_id = Confide::user()->id;
         $this->tickets->department_id = Input::get('department_id');
         $this->tickets->name = Input::get('name');
         $this->tickets->email = Input::get('email');
         $this->tickets->title = Input::get('title');
         $this->tickets->attachment = Input::get('attachment');
         $this->tickets->message = Input::get('content');
         $this->tickets->priority = Input::get('priority');
         $this->tickets->status = Input::get('status');
         $this->tickets->saveFlags(explode(',', Input::get('flags')));
         if ($this->tickets->save()) {
             $not = new TicketNotes(array('id' => '0', 'content' => Input::get('notes'), 'admin_id' => Confide::user()->id));
             $this->tickets->notes()->save($not);
             Support::Trigger('open', $this->tickets);
             return Api::to(array('success', Lang::get('l4cp-support::messages.create.success'))) ?: Redirect::to('admin/support/' . $this->tickets->id . '/edit')->with('success', Lang::get('l4cp-support::messages.create.success'));
         } else {
             return Api::to(array('error', Lang::get('l4cp-support::messages.create.error'))) ?: Redirect::to('admin/support/create')->with('error', Lang::get('l4cp-support::messages.create.error'));
         }
     } else {
         return Api::to(array('error', Lang::get('l4cp-support::messages.create.error'))) ?: Redirect::to('admin/support/create')->withInput()->withErrors($validator);
     }
 }
예제 #19
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // create the validator
     $validator = Validator::make(Input::all(), Post::$rules);
     // attempt validation
     if ($validator->fails()) {
         // validation failed, redirect to the post create page with validation errors and old inputs
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         // validation succeeded, create and save the post
         $post = new Post();
         $post->title = Input::get('title');
         $post->description = Input::get('description');
         $post->user_id = Auth::id();
         $result = $post->save();
         if ($result) {
             Session::flash('successMessage', 'Your post successfully saved');
             return Redirect::action('posts.index');
         } else {
             Session::flash('errorMessage', 'Your post wasn\'t saved');
             Log::warning('Post failed to save: ', Input::all());
             return Redirect::back()->withInput();
         }
     }
 }
예제 #20
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = ['title' => 'required', 'content' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/teacher/posts/create')->withErrors($validator);
     } else {
         $post = new Post();
         $post->title = Input::get('title');
         $post->content = Input::get('content');
         // variables liées à la gestion de l'image
         $destinationPath = '';
         $filename = '';
         if (Input::hasFile('image')) {
             $file = Input::file('image');
             $destinationPath = $destinationPath = public_path() . '/img/';
             $filename = $file->getClientOriginalName();
             $uploadSuccess = $file->move($destinationPath, $filename);
             $post->url_thumbnail = $filename;
         }
         $post->abstract = Str::words($post->content, 20, '...');
         $post->user_id = Auth::user()->id;
         $post->save();
         /*echo "<pre>";
         		var_dump(public_path().'\\img\\'.'lol.jpg');
         		echo '</pre>';*/
         Session::flash('message_success', 'L\'article a bien été ajouté');
         return Redirect::to('/teacher/posts');
     }
 }
예제 #21
0
 public function actionAddBlog()
 {
     $model = new Post();
     $rec = Lookup::model()->findAll(array('condition' => 'type=:t', 'params' => array(':t' => 'PostStatus')));
     $admin = Admin::model()->find();
     $adminId = $admin->id;
     foreach ($rec as $type) {
         $id[] = $type->id;
         $name[] = $type->name;
         $op = array_combine($id, $name);
     }
     if (isset($_POST['Post'])) {
         $model->attributes = $_POST['Post'];
         if ($model->validate()) {
             $model->author_id = $adminId;
             if ($model->save()) {
                 $this->redirect(array('postlisting', 'id' => $model->id));
             }
         } else {
             $errors = $model->getErrors();
             //var_dump($errors);
         }
     }
     $this->render('addblog', array('model' => $model, 'type' => $op));
 }
예제 #22
0
 public function postContent($type_id, $id = 'add')
 {
     $all = Input::all();
     if (!$all['slug']) {
         $all['slug'] = BaseController::ru2Lat($all['title']);
     }
     $rules = array('name' => 'required|min:2|max:255', 'title' => 'required|min:3|max:255', 'slug' => 'required|min:4|max:255|alpha_dash');
     $validator = Validator::make($all, $rules);
     if ($validator->fails()) {
         return Redirect::to('/admin/content/' . $type_id . '/' . $id)->withErrors($validator)->withInput()->with('error', 'Ошибка');
     }
     if (is_numeric($id)) {
         $post = Post::find($id);
     } else {
         $post = new Post();
     }
     $post->type_id = $all['type_id'];
     $post->name = $all['name'];
     $post->title = $all['title'];
     $post->slug = $all['slug'];
     $post->text = $all['text'];
     $post->parent = $all['parent'];
     $post->status = isset($all['status']) ? true : false;
     $post->order = $all['order'];
     $post->description = $all['description'];
     $post->keywords = $all['keywords'];
     if (isset($all['image'])) {
         $post->image = AdminController::saveImage($all['image'], 'upload/image/', 250);
     }
     $post->save();
     return Redirect::to('/admin/content/' . $all['type_id'] . '/' . $id)->with('success', 'Изменения сохранены');
 }
예제 #23
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $user_id = Auth::id();
     $comment = Input::get('comment');
     $tags = Input::get('tagged_uid');
     $rating = Input::get('rating');
     $type = Input::get('media_type');
     $imdb_id = Input::get('imdb_id');
     $post = new Post();
     $post->user_id = $user_id;
     $post->type = $type;
     $post->imdb_id = $imdb_id;
     $post->rating = $rating;
     $post->comment = $comment;
     $post->save();
     if (sizeof($tags) > 0) {
         foreach ($tags as $tagged_uid) {
             $tag = new Tag();
             $tag->post_id = $post->id;
             $tag->user_tagging = $user_id;
             $tag->user_tagged = $tagged_uid;
             $tag->save();
         }
     }
     return Redirect::to('/media/' . $imdb_id);
 }
예제 #24
0
 public function run()
 {
     $user = User::firstOrFail();
     $post1 = new Post();
     $post1->title = 'A Long Long';
     $post1->subtitle = 'In a Galaxy Far Far Away';
     $post1->content = 'Lorem ipsum dolor sit amet, ut numquam repudiandae vim, vix no novum saperet appellantur. Periculis signiferumque ea pri, et dolore conceptam sit. Nominavi facilisi cu vix, eos ut probatus suavitate, solum utinam epicuri ex vis. Quis appareat quaestio et sit, ei pri illud eripuit lobortis, vis modus vivendo tacimates at. Quem moderatius pri in, ut brute noster dicunt his, graeci definitiones mei an';
     $post1->image = '/img/264H.jpg';
     $post1->user_id = $user->id;
     $post1->save();
     $post2 = new Post();
     $post2->title = 'A Long Long Time';
     $post2->subtitle = 'In a Galaxy Far Far Away';
     $post2->content = 'Lorem ipsum dolor sit amet, ut numquam repudiandae vim, vix no novum saperet appellantur. Periculis signiferumque ea pri, et dolore conceptam sit. Nominavi facilisi cu vix, eos ut probatus suavitate, solum utinam epicuri ex vis. Quis appareat quaestio et sit, ei pri illud eripuit lobortis, vis modus vivendo tacimates at. Quem moderatius pri in, ut brute noster dicunt his, graeci definitiones mei an';
     $post2->image = '/img/264H.jpg';
     $post2->user_id = $user->id;
     $post2->save();
     $post3 = new Post();
     $post3->title = 'A Long Long Time Ago';
     $post3->subtitle = 'In a Galaxy Far Far Away';
     $post3->content = 'Lorem ipsum dolor sit amet, ut numquam repudiandae vim, vix no novum saperet appellantur. Periculis signiferumque ea pri, et dolore conceptam sit. Nominavi facilisi cu vix, eos ut probatus suavitate, solum utinam epicuri ex vis. Quis appareat quaestio et sit, ei pri illud eripuit lobortis, vis modus vivendo tacimates at. Quem moderatius pri in, ut brute noster dicunt his, graeci definitiones mei an';
     $post3->image = '/img/264H.jpg';
     $post3->user_id = $user->id;
     $post3->save();
 }
예제 #25
0
 protected function makePost()
 {
     $post = new Post();
     $post->title = "titulo";
     $post->save();
     return $post;
 }
예제 #26
0
function update_post()
{
	global $user;	
	global $CONF;

	$post = new Post();

	if (isset($_GET['postid_update_post'])){
		$post->setId($_GET['postid_update_post']);
		$post->load();
		if ( ($user->getId()!=$post->getUser()->getId()) || ($user->isAnon()!=$post->getUser()->isAnon()) )
			return array('ok'=>false, 'error'=>'you are not the owner');
	} else {
		return array('ok'=>false,error=>'no id');
	}

	$msg = unescape_ampersand($_POST['msg_update_post']);
	if (strlen(str_replace(' ', '', strip_tags($msg))) < $CONF['min_msg_chars'])
		return array('ok'=>false, 'error'=>'Too short message.');

	$msg = strip_tags($msg, $CONF['permitted_tags_msg']);
	$post->setPost($msg);

	if ($post->save()=='ok'){
		return array('ok'=>true, 'error'=>'');
	}
	else
		return array('ok'=>false, 'error'=>'Problem with this post.');
}
예제 #27
0
 /**
  * Store a newly created resource in storage.
  * POST /estudios
  *
  * @return Response
  */
 public function store()
 {
     //check for a file
     if (!Input::hasFile('Filedata')) {
         return 'No file.';
     }
     //nuevo archivo
     $now = Carbon::now();
     $code = $now->timestamp;
     $file = $code . '.' . Input::file('Filedata')->getClientOriginalExtension();
     if (Input::file('Filedata')->move(public_path() . '/media', $file)) {
         $nueva = new Post();
         $nueva->titulo = Input::get('titulo');
         $nueva->tipo = 1;
         $nueva->categoria = 1;
         $nueva->fecha_publicacion = Carbon::now();
         $nueva->attachment = $file;
         $nueva->imagen = '';
         $nueva->subtitulo = '';
         $nueva->descripcion = Input::get('descripcion');
         $nueva->save();
         return '1';
     } else {
         return 'Invalid file type.';
     }
 }
예제 #28
0
 public function run()
 {
     $user = User::firstOrFail();
     $post1 = new Post();
     $post1->title = 'Calculator';
     $post1->body = 'Early in Codeup, I made a calculator that functions using JavaScript\'s internal math functions to do the computations. I styled the calculator to look somewhat real, and I was very happy with the glossy buttons I was able to make with some CSS befores and afters. I was also able to approximate the old school real LED display with some CSS gradients. Lastly, there\'s a not-at-all subtle Star Wars reference on the calculator in the lower left corner. Anyone catch the reference?';
     $post1->image_url = 'img/cal.png';
     $post1->user_id = $user->id;
     $post1->save();
     $post2 = new Post();
     $post2->title = 'Weather API';
     $post2->body = 'I got to say that the weather API was a lot of fun. It was incredible to see the two APIs (Open Weather and Google Maps) come together and see how AJAX requests work with JavaScript and jQuery. I kept the CSS simple here, but I like the layout in those square units I created. I feel like it gets the important info out there in a format that is easy to read and look at. I am especially proud of the search area which has the added reverse address look up. Normally, one types in an address and gets the weather for that location. But if one drags the map pin, the search area will also display an address for that location as well. Very neat!';
     $post2->image_url = 'img/weather.png';
     $post2->user_id = $user->id;
     $post2->save();
     $post3 = new Post();
     $post3->title = 'Simon Says';
     $post3->body = 'Simon Says was my first game using JavaScript and jQuery. I did my best to make my Simon to look like the childhood favorite of yesteryear. I\'m so happy with the name plate area. That CSS was a blast to figure out with the metalic shine and realistic buttons! Of course, the real star of this game is the jQuery animations that make it all work.';
     $post3->image_url = 'img/simon.png';
     $post3->user_id = $user->id;
     $post3->save();
     $post4 = new Post();
     $post4->title = 'Whack-a-mole';
     $post4->body = 'Or Whack-a-gopher as I\'ve made it! This game was an amazing build and it was so much fun! I admit it, I got carried away with making each and every game element out of HTML and CSS. I used no images whatsoever! And I think it was totally worth it. This is also where I started to really become fond of CSS animations as I figured out how to make each gopher spin like a 3D game piece upon being clicked. ';
     $post4->image_url = 'img/mole.png';
     $post4->user_id = $user->id;
     $post4->save();
     $post5 = new Post();
     $post5->title = 'Spatula City';
     $post5->body = 'Or our ad lister/Craigslist clone. I made this call-back to the 80s and Weird Al with Zeshan Segal and Reagan Wilkins. Together I think we made a fantastic site for selling and buying spatulas of all sorts, shapes and colors! I was responsible for the ad create form, the ad edit form, and the ads DB table. It was challenging to make the ad edit form which retrieved data from the DB for it to be altered. I also built the ads index page and the ads show pages. Within those two pages, I am super pleased with the categories bar that allows one to filter the ads showing on the ads index page in real time. I used PHP\'s ability to query MySQL and added a change listener with jQuery to submit the radio button selected. That was a great breakthrough for me. To showcase this project, which was never a live site, I have decided to show a few screenshots. Each screenshot shows one of the items I worked to develop such as the navbar, the ads index page (aka the Product page), and the deals page (the dancing spatulas).';
     $post5->image_url = 'img/adlister.png';
     $post5->user_id = $user->id;
     $post5->save();
 }
예제 #29
0
 protected function makePost()
 {
     $post = new Post();
     $post->text = 'Some title';
     $post->save();
     return $post;
 }
예제 #30
0
 public function add()
 {
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required|min:4', 'link' => "required|unique:{$this->table}", 'content' => 'required|min:100', 'published_at' => 'required', 'meta_keywords' => 'required', 'meta_description' => 'max:500');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/{$this->name}/{$this->action}")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = new Post();
             $table->title = Input::get('title');
             $table->link = Input::get('link');
             $table->user_id = Auth::user()->id;
             $table->content = Input::get('content');
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->description;
             $table->meta_keywords = Input::get('meta_keywords');
             $table->published_at = Post::toDate(Input::get('published_at'));
             $table->active = Input::get('active', 0);
             if ($table->save()) {
                 $name = trans("name.{$this->name}");
                 return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
             }
             return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
         }
     }
     return View::make("admin.{$this->name}.{$this->action}", ['name' => $this->name, 'action' => $this->action]);
 }