/** * 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'); } }
/** * Returns feed of latest news. * * @return xml */ public function news() { $feed = $this->makeChannel(App::make('options')->getSiteName() . ' - ' . trans('feed.newsDesc'), trans('feed.newsDesc'), Request::url()); $news = App::make('Lib\\News\\NewsRepository')->latest(); foreach ($news as $n) { $feed->item(array('title' => $n['title'], 'description|cdata' => Str::words($n['body'], 75), 'link' => Helpers::url($n['title'], $n['id'], 'news'))); } return Response::make($feed, 200, array('Content-Type' => 'text/xml')); }
public function renderBody($characterLimit = null) { $Parsedown = new Parsedown(); $config = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($config); $body = $Parsedown->text($this->body); $cleanBody = $purifier->purify($body); if (!is_null($characterLimit)) { return Str::words($cleanBody, $characterLimit); } return $cleanBody; }
public function run() { DB::table('users')->delete(); DB::table('users')->insert([['username' => 'alexandre', 'password' => Hash::make('admin'), 'role' => 'teacher'], ['username' => 'abel', 'password' => Hash::make('abel'), 'role' => 'first_class'], ['username' => 'al', 'password' => Hash::make('al'), 'role' => 'first_class'], ['username' => 'alan', 'password' => Hash::make('alan'), 'role' => 'first_class'], ['username' => 'arthur', 'password' => Hash::make('arthur'), 'role' => 'first_class'], ['username' => 'carl', 'password' => Hash::make('carl'), 'role' => 'first_class'], ['username' => 'blaise', 'password' => Hash::make('blaise'), 'role' => 'first_class'], ['username' => 'steve', 'password' => Hash::make('steve'), 'role' => 'first_class'], ['username' => 'alfred', 'password' => Hash::make('alfred'), 'role' => 'final_class'], ['username' => 'brenda', 'password' => Hash::make('brenda'), 'role' => 'final_class'], ['username' => 'tom', 'password' => Hash::make('tom'), 'role' => 'final_class'], ['username' => 'rasmus', 'password' => Hash::make('rasmus'), 'role' => 'final_class']]); $this->command->info('remplissage des uttilisateurs : ok'); DB::table('posts')->delete(); DB::table('posts')->insert([['user_id' => User::where('username', '=', 'alexandre')->first(), 'title' => 'les suites récurentes', 'content' => $content = "L'étude des suites récurentes linéaires d'ordre supérieur se ramène à un problème d'algèbre linéaire.", 'abstract' => Str::words($content, 20, '...'), 'url_thumbnail' => 'http://www.enpc.fr/sites/default/files/images/Maths_dullhunk_flickr_20111202_cc.jpg'], ['user_id' => User::where('username', '=', 'alexandre')->first(), 'title' => 'développez factorisez', 'content' => $content = "développez, factorisez, Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reiciendis neque quam impedit quasi quas facere aspernatur perspiciatis, animi perferendis suscipit.", 'abstract' => Str::words($content, 20, '...'), 'url_thumbnail' => 'http://www.rts.ch/2013/02/14/10/11/4660368.image?w=517'], ['user_id' => User::where('username', '=', 'alexandre')->first(), 'title' => 'triangles trigonométriques', 'content' => $content = "Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental: in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es.", 'abstract' => Str::words($content, 20, '...'), 'url_thumbnail' => 'http://recit.cssamares.qc.ca/tm/images/imagesweb/Academique/MatieresRegulieres/MATH/Math7.jpg'], ['user_id' => User::where('username', '=', 'alexandre')->first(), 'title' => 'les intégrales', 'content' => $content = "Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental: in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es.", 'abstract' => Str::words($content, 20, '...'), 'url_thumbnail' => 'http://recit.cssamares.qc.ca/tm/images/imagesweb/Academique/MatieresRegulieres/MATH/Math7.jpg'], ['user_id' => User::where('username', '=', 'alexandre')->first(), 'title' => 'Probabilités', 'content' => $content = "Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental: in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es.", 'abstract' => Str::words($content, 20, '...'), 'url_thumbnail' => 'http://recit.cssamares.qc.ca/tm/images/imagesweb/Academique/MatieresRegulieres/MATH/Math7.jpg']]); $this->command->info('remplissage des posts : ok'); DB::table('comments')->delete(); DB::table('comments')->insert([['user_id' => User::where('username', '=', 'tom')->first()->id, 'post_id' => Post::where('title', '=', 'Probabilités')->first()->id, 'title' => 'Un commentaire', 'content' => 'Lorem ipsum dolor sit amet']]); $this->command->info('remplissage des commentaires : ok'); DB::table('questions')->delete(); DB::table('questions')->insert([$machineTuring = ['title' => 'la machine de Turing', 'content' => 'la machine de Turing c\'est quoi ?', 'class_level' => 'premiere'], $javaScript = ['title' => 'javaScript', 'content' => 'language de programation', 'class_level' => 'terminale']]); $this->command->info('remplissage des questions : ok'); DB::table('choices')->delete(); DB::table('choices')->insert([['question_id' => Question::where('title', $machineTuring['title'])->first()->id, 'content' => 'une machine à laver', 'status' => 'no'], ['question_id' => Question::where('title', $machineTuring['title'])->first()->id, 'content' => 'une machine à voyager dans le temps', 'status' => 'no'], ['question_id' => Question::where('title', $machineTuring['title'])->first()->id, 'content' => 'un modèle abstrait de fonctionnement des appareils mécaniques de calcul', 'status' => 'yes'], ['question_id' => Question::where('title', $javaScript['title'])->first()->id, 'content' => 'un language de programation compilé', 'status' => 'no'], ['question_id' => Question::where('title', $javaScript['title'])->first()->id, 'content' => 'est utilisable uniquement sur navigateur', 'status' => 'no'], ['question_id' => Question::where('title', $javaScript['title'])->first()->id, 'content' => 'sert principalement à rendre le contenu plus intéractif', 'status' => 'yes']]); $this->command->info('remplissage des reponses : ok'); }
/** * Store a newly created message in storage. * * @return Response */ public function store() { $rules = array('body' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Response::json(['success' => false, 'result' => $validator->messages()]); } $conversation = Conversation::where('name', Input::get('conversation'))->first(); $params = array('conversation_id' => $conversation->id, 'body' => Input::get('body'), 'user_id' => Input::get('user_id'), 'created_at' => new DateTime()); $message = Message::create($params); // Create Message Notifications $messages_notifications = array(); foreach ($conversation->users()->get() as $user) { array_push($messages_notifications, new MessageNotification(array('user_id' => $user->id, 'conversation_id' => $conversation->id, 'read' => false))); } $message->messages_notifications()->saveMany($messages_notifications); // Publish Data To Redis $data = array('room' => Input::get('conversation'), 'message' => array('body' => Str::words($message->body, 5), 'user_id' => Input::get('user_id'))); Event::fire(ChatMessagesEventHandler::EVENT, array(json_encode($data))); return Response::json(['success' => true, 'result' => $message]); }
@import url(http://fonts.googleapis.com/css?family=Open+Sans:300,400,700,600); </style> <div style="width:100%;background-color:#f2f3f4;margin:0px;padding:30px 0px"> <div style="width:700px;background-color:#fff; box-shadow: 0px 1px 13px 0px rgba(183,183,183,1);margin:0 auto;font-family: 'Open Sans', sans-serif;font-weight: 400"> <div style="width:95%;height:60px;border-bottom:1px solid #efefef;padding:0px 18px;"> <p style=" float:left;margin:0px;font-weight:300;color:#33627c;font-size: 17px;margin-top:24px;padding-left: 12px;" class="MsoNormal">Newsletter</p> </div> <div style="width:77%;padding: 55px 80px 85px;"> <p style="color:#003d79;font-size:22px;margin:0px;font-weight: 600" class="MsoNormal"><?php echo $post->title; ?> </p> <p style="margin-top: 22px;font-size: 13px;color:#5a5a5a;" class="MsoNormal"><?php echo Str::words(strip_tags($post->text), 50); ?> </p> <div> <div style="height:30px;"></div> <a href="<?php echo $post_url; ?> " target="_blank" style="background-color: #019ae6;border-bottom: 2px solid #247cab;color:#fff;font-size: 12px;text-decoration: none;font-weight: 700;padding:7px 18px;margin-right:20px;">Vezi articolul</a> </div> <p style="margin-top: 22px;font-size: 11px;color:#a7a7a7;" class="MsoNormal"> Pentru dezabonare, click <a href="<?php echo $unsubscribe_link; ?>
" alt="<?php echo $item->title; ?> " src="<?php echo url($item->cover['path']); ?> " width="347"> <?php } ?> </div> </div> <div class="right"> <p class="info"><?php echo Str::words(strip_tags($item->text), 55); ?> </p> </div> <a href="<?php echo $page_url; ?> ?item=<?php echo $item->uri; ?> " class="more"></a> <div class="clearfix"></div> </div> <?php } ?>
<ul class="prom"> <?php foreach ($posts as $item) { ?> <li> <p class="ttl"><?php echo $item->title; ?> </p> <p class="info"><?php echo Str::words(strip_tags(WebAPL\Shortcodes::strip($item->text)), 40); ?> </p> <a href="<?php echo $page_url; ?> ?item=<?php echo $item['uri']; ?> "></a> </li> <?php } ?> </ul> <div class="clearfix"></div> <?php if (method_exists($posts, 'links')) {
if (empty($project->image)) { $image = 'project3.jpg'; } else { $image = $project->image; } ?> <div class="media row"> <img class="media-object col-lg-4" src="/img/projects/{{$image}}" alt="{{{$project->title}}}"> <br> <div class="media-body"> <a href="{{$project->slug}}"><h4 class="media-heading">{{{$project->title}}}</h4></a> <div class="row"> <div class="col-lg-12"> {{{$project->city_county}}} <br> {{{$project->state_country}}} </div> </div> <p> <?php $teaser = strip_tags(Str::words($project->body, 50)); ?> {{$teaser}} </p> <div><a href="{{$project->slug}}">read more...</a></div> </div> </div>
public function insertcomment() { $rules = array('text' => 'required|min:10|max:300'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { $messages = $validator->messages(); foreach ($messages->all() as $message) { $alert = '<div class="alert alert-danger alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> ' . $message . ' </div>'; return $alert; } } else { $image = Input::get('img'); $type = Input::get('type'); $postid = Input::get('post_id'); $commentid = Input::get('comment_id'); $text = Input::get('text'); if (!$commentid) { if (empty($type) && !empty($image)) { $message = 'Please choose the comment type (attack, assist, defense) at the icons belows'; $alert = '<div class="alert alert-danger alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> ' . $message . ' </div>'; return $alert; } else { if (!empty($type) && empty($image)) { $message = 'If you want to attack, assist or defense please upload an image'; $alert = '<div class="alert alert-danger alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> ' . $message . ' </div>'; return $alert; } else { if (!empty($image)) { $image = explode('/', $image); $image = urldecode(end($image)); $extension = explode(".", $image); $extension = end($extension); list($width, $height) = getimagesize('files/' . $image); if ($width > 500) { $img = Image::make('files/' . $image); $img->resize(400, null, function ($constraint) { $constraint->aspectRatio(); }); $img->save('files/' . $image); } else { if ($height > 500) { $img = Image::make('files/' . $image); $img->resize(null, 400, function ($constraint) { $constraint->aspectRatio(); }); $img->save('files/' . $image); } } // create directory if (!File::exists('comments/' . $postid)) { File::makeDirectory('comments/' . $postid, 0775, true); } $newname = date('YmdHis') . '_' . str_random(40) . '.' . $extension; File::move('files/' . $image, 'comments/' . $postid . '/' . $newname); } } } } else { if (empty($type) && !empty($image)) { $message = 'Please choose the comment type (attack, assist, defense) at the icons above'; $alert = '<div class="alert alert-danger alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> ' . $message . ' </div>'; return $alert; } else { if (!empty($type) && empty($image)) { $message = 'If you want to attack, assist or defense please upload an image'; $alert = '<div class="alert alert-danger alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> ' . $message . ' </div>'; return $alert; } else { // ada comment id if (!empty($image)) { $image = explode('/', $image); $image = urldecode(end($image)); $extension = explode(".", $image); $extension = end($extension); list($width, $height) = getimagesize('files/' . $image); if ($width > 500) { $img = Image::make('files/' . $image); $img->resize(400, null, function ($constraint) { $constraint->aspectRatio(); }); $img->save('files/' . $image); } else { if ($height > 500) { $img = Image::make('files/' . $image); $img->resize(null, 400, function ($constraint) { $constraint->aspectRatio(); }); $img->save('files/' . $image); } } // create directory if (!File::exists('comments/' . $postid)) { File::makeDirectory('comments/' . $postid, 0775, true); } $newname = date('YmdHis') . '_' . str_random(40) . '.' . $extension; File::move('files/' . $image, 'comments/' . $postid . '/' . $newname); } } } } //end comment id if (!$commentid) { $parentCommentOwner = ''; } else { $parentCommentOwnerId = Comment::find($commentid)->user_id; $parentCommentOwner = User::find($parentCommentOwnerId); if ($parentCommentOwner) { $parentCommentOwner = '<a href="#" style="color:blue">@' . $parentCommentOwner->username . '</a>'; } else { $parentCommentOwner = ''; } $text = $parentCommentOwner . ' ' . $text; } // insert $comment = new Comment(); $comment->user_id = Auth::id(); if ($postid) { $comment->post_id = $postid; } if ($commentid) { $comment->parent_comment_id = $commentid; } // if($type) $comment->type = $type; else $comment->type = 'none'; $comment->type = $type; $comment->text = $text; $comment->upload_type = !empty($image) ? 'image' : 'none'; if (!empty($image)) { $comment->image = $newname; } Session::flash('success', 'New comment inserted'); $comment->save(); $post = Post::find($postid); if ($type) { if ($type == 'attack') { $desc = Auth::user()->username . ' Attacked you at <a href="' . url('post/' . $post->slug) . '">' . Str::words($post->title, 3, '...') . '</a> post'; } else { if ($type == 'assist') { $desc = Auth::user()->username . ' Assisted you at <a href="' . url('post/' . $post->slug) . '">' . Str::words($post->title, 3, '...') . '</a> post'; } else { if ($type == 'defense') { $desc = Auth::user()->username . ' Defense your post at <a href="' . url('post/' . $post->slug) . '">' . Str::words($post->title, 3, '...') . '</a>'; } } } } else { $desc = Auth::user()->username . ' commented at your <a href="' . url('post/' . $post->slug) . '">' . Str::words($post->title, 3, '...') . '</a> post'; } $notif = new Notification(); $notif->receiver_id = $post->user_id; $notif->sender_id = Auth::id(); $notif->other_id = $comment->id; $notif->type = 'comment'; $notif->description = $desc; $notif->save(); $receiverUserEmail = User::find($post->user_id)->email; $receiverUserName = User::find($post->user_id)->username; Mail::send('emails.message', array('desc' => $desc), function ($message) use($receiverUserEmail, $receiverUserName) { $message->to($receiverUserEmail, $receiverUserName)->subject('Tifosiwar Alert'); }); return 'success'; } //end else }
public function getRenovacion($id) { $mtto_detalle = VistaDetalleMantenimiento::find($id); $dataModule["vendedores"] = VistaAsesorPromotor::where('activo', 1)->get(); $dataModule["status"] = Session::pull('status'); $dataModule["config_gral"] = ConfiguracionGeneral::where('activo', 1)->firstorfail(); $dataModule['cesped'] = cesped::sum('cantidad'); $dataModule["mtto_r"] = $mtto_detalle; $dataModule["nuevos"] = VentaMantenimiento::where('nuevo', '=', 1)->count(); $dataModule["renovados"] = VentaMantenimiento::where('nuevo', '=', 0)->count(); $dataModule["telefono_casa"] = Telefono::where('tipo_telefono_id', '=', 2)->where('cliente_id', '=', $mtto_detalle->cliente_id)->first(); $dataModule["telefono_celular"] = Telefono::where('tipo_telefono_id', '=', 1)->where('cliente_id', '=', $mtto_detalle->cliente_id)->first(); $dataModule["inhumados_r"] = VistaInhumadosMtto::all(); $dataModule["clientes"] = VistaDetalleMantenimiento::leftjoin('vista_clientes', 'vista_detalle_mantenimiento.cliente_id', '=', 'vista_clientes.id')->groupby('vista_clientes.id')->get(); $dataModule['tipos_mantenimientos'] = Mantenimiento::select('producto.id as producto_id', 'producto.nombre', 'precio.monto', 'meses', 'construccion.descripcion')->leftjoin('producto', 'mantenimiento.producto_id', '=', 'producto.id')->leftjoin('precio', 'producto.id', '=', 'precio.producto_id')->leftjoin('construccion', 'mantenimiento.construccion_id', '=', 'construccion.id')->where('precio.activo', 1)->where('construccion.id', '=', $mtto_detalle->construccion_id)->get(); $dataModule["tipos_mantenimientos_sin_filtro"] = Mantenimiento::select('producto.id as producto_id', 'producto.nombre', 'precio.monto', 'meses', 'construccion.descripcion')->leftjoin('producto', 'mantenimiento.producto_id', '=', 'producto.id')->leftjoin('precio', 'producto.id', '=', 'precio.producto_id')->leftjoin('construccion', 'mantenimiento.construccion_id', '=', 'construccion.id')->where('precio.activo', 1)->where('construccion.descripcion', 'like', '%' . Str::words($mtto_detalle->descripcion, 2, $end = '') . '%')->get(); return View::make($this->department . ".main", $this->data)->nest('child', 'mantenimiento.renovacion', $dataModule); }
/** * Set meta value * @param text $key * @param text $value * @param boolean $override */ public static function setMeta($key, $value, $override = false) { $value = \Str::words(strip_tags(trim(preg_replace('/\\s\\s+/', ' ', $value))), 40); if ($override) { static::$meta[$key] = $value; } else { if (isset(static::$meta[$key])) { static::$meta[$key] = $value; } } }
/** * Test the Str::words method. * * @group laravel */ public function testStringCanBeLimitedByWords() { $this->assertEquals('Taylor...', Str::words('Taylor Otwell', 1)); $this->assertEquals('Taylor___', Str::words('Taylor Otwell', 1, '___')); $this->assertEquals('Taylor Otwell', Str::words('Taylor Otwell', 3)); }
'><?php echo Str::words(strip_tags($parent->value), 12); ?> </a> <?php } ?> / <?php if (isset($var) && $var->key) { ?> <a href='<?php echo url("var/index/{$var->key}"); ?> '><?php echo Str::words(strip_tags($var->value), 12); ?> </a> <?php } ?> </h3> <form action="<?php echo url('var/search'); ?> " method="post"> <div class="input-group"> <input type="search" name="varname" placeholder="<?php echo varlang('search-vars'); ?>
echo url(); ?> </link> <description></description> <?php foreach ($posts as $item) { ?> <item> <title><?php echo htmlspecialchars($item->title); ?> </title> <link><?php echo \WebAPL\Language::url('topost/' . $item->id); ?> </link> <description><?php echo htmlspecialchars(htmlspecialchars_decode(Str::words(strip_tags($item->text), 200))); ?> </description> <pubDate><?php echo date("D, d M Y H:i:s O", strtotime($item->created_at)); ?> </pubDate> </item> <?php } ?> </channel> </rss>
protected function sanitize($string) { return \Str::words(nl2br(htmlspecialchars($string)), 30); }