/** * test shouldn't replace an ascii smiley in a URL (shouldn't replace :/) * * @return void */ public function testSmileyInAnUrl() { // enable ASCII conversion $default_ascii = Emojione::$ascii; Emojione::$ascii = true; $ascii = 'Check out http://www.emojione.com'; $this->assertEquals(Emojione::shortnameToImage($ascii), $ascii); $this->assertEquals(Emojione::toImage($ascii), $ascii); $this->assertEquals(Emojione::shortnameToAscii($ascii), $ascii); $this->assertEquals(Emojione::unifyUnicode($ascii), $ascii); // back to default ASCII conversion Emojione::$ascii = $default_ascii; }
/** * test Emojione::shortnameToImage() * * @return void */ public function testShortnameToImage() { $test = 'Hello world! 😄 :smile:'; $expected = 'Hello world! 😄 <img class="emojione" alt="😄" src="//cdn.jsdelivr.net/emojione/assets/png/1F604.png' . $this->cacheBustParam . '"/>'; $this->assertEquals(Emojione::shortnameToImage($test), $expected); }
/** * test Emojione::shortnameToImage() * * @return void */ public function testShortnameToImage() { $test = 'Hello world! 😄 :smile:'; $expected = 'Hello world! 😄 <span class="emojione-1F604" title=":smile:">😄</span>'; $this->assertEquals(Emojione::shortnameToImage($test), $expected); }
public function carnival() { //return 'We Are Working'; //Changed $data['date'] = $this->getBaseDateTime(); /*19-May-2015 Ehsan*/ $user = User::find(Auth::user()->id); $url = Picture::find($user->picture); $data['self'] = $url; /*!!!!19-May-2015 Ehsan*/ // Everyday Question Generation $data['question'] = null; $data['prev_question'] = null; $question = Question::orderBy('id', 'desc')->first(); $prev_question = Question::orderBy('id', 'desc')->skip(1)->first(); if ($question) { $data['question'] = $question; $data['options_of_question'] = QuestionOption::whereQuestionId($question->id)->get(); //$get_count_of_the_answers = DB::table('users_answers')->select(DB::raw('option_number,count(*) as count'))->join('question_options','users_answers.option_id', '=', 'question_options.id')->whereQuestionId($question->id)->groupBy('option_id')->groupBy('option_number')->orderBy('option_number')->get(); $data['answered'] = UsersAnswer::whereUserId(Auth::user()->id)->whereQuestionId($question->id)->first(); } if ($prev_question) { $data['prev_question'] = $prev_question; $options_of_question = QuestionOption::whereQuestionId($prev_question->id)->get(); $total_answer = 0; foreach ($options_of_question as $key) { $current_answer = DB::table('users_answers')->select(DB::raw('count(*) as count'))->whereOptionId($key->id)->first()->count; $total_answer += $current_answer; $answers_count[$key->option_number] = array('option_details' => $key->option_details, 'total_answer' => $current_answer); } try { foreach ($options_of_question as $key) { $cur = $answers_count[$key->option_number]['total_answer'] * 1.0; $percentage = $cur / $total_answer * 100.0; $answers_count[$key->option_number]['total_answer'] = number_format((double) $percentage, 2, '.', ''); } } catch (Exception $e) { $answers_count[1]['total_answer'] = 33; $answers_count[2]['total_answer'] = 33; $answers_count[3]['total_answer'] = 33; } $data['total_votes'] = $total_answer; $data['answers'] = $answers_count; } // ENd of Question Related Code // Top And Flop Post Generation $posts = Post::select('posts.*')->join('users', 'users.id', '=', 'posts.user_id')->where('users.disable', '0')->whereType('3')->orderBy('posts.id', 'desc')->take(30)->lists('id'); $top_post = DB::table('likes')->select(DB::raw('count(*) as like_count, post_id'))->whereIn('post_id', $posts)->orderBy('like_count', 'desc')->groupBy('post_id')->first(); // return json_encode($top_post); $flop_post = DB::table('dislikes')->select(DB::raw('count(*) as dislike_count, post_id'))->whereIn('post_id', $posts)->orderBy('dislike_count', 'desc')->groupBy('post_id')->first(); $data['flop_post'] = null; $data['top_post'] = null; if ($top_post) { $post = Post::whereId($top_post->post_id)->first(); /*19-May-2015 Ehsan*/ $user = User::find($post->user_id); $url = Picture::find($user->picture); $url = $url->url; /*!!!!19-May-2015 Ehsan*/ $text = htmlentities($post->post); /*Eve-26-May-Ehsan*/ /*!!!!Eve-26-May-Ehsan*/ $text = preg_replace('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', '<a target="_blank" href="$1">$1</a>', $text); $text = preg_replace('/#([a-zA-Z0-9\\x{0980}-\\x{09FF}_])+/u', '<a href="#" class="tags">$0</a>', $text); $text = nl2br($text); $text = Emojione::shortnameToImage($text); $now = Carbon::parse($post->created_at); $data['top_post'] = array('id' => $post->id, 'post' => $text, 'user_id' => $post->user_id, 'img' => asset($url), 'like' => Like::wherePostId($post->id)->get()->count(), 'dislike' => Dislike::wherePostId($post->id)->get()->count(), 'liked' => Like::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'disliked' => Dislike::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'comment' => Comment::wherePostId($post->id)->get()->count(), 'ago' => $now->diffForHumans()); } else { $data['top_post'] = null; } if ($flop_post) { $post = Post::whereId($flop_post->post_id)->first(); /*19-May-2015 Ehsan*/ $user = User::find($post->user_id); $url = Picture::find($user->picture); $url = $url->url; /*!!!!19-May-2015 Ehsan*/ $text = htmlentities($post->post); /*Eve-26-May-Ehsan*/ /*!!!!Eve-26-May-Ehsan*/ $text = preg_replace('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', '<a target="_blank" href="$1">$1</a>', $text); $text = preg_replace('/#([a-zA-Z0-9\\x{0980}-\\x{09FF}_])+/u', '<a href="#" class="tags">$0</a>', $text); $text = nl2br($text); $text = Emojione::shortnameToImage($text); $now = Carbon::parse($post->created_at); $data['flop_post'] = array('id' => $post->id, 'post' => $text, 'user_id' => $post->user_id, 'img' => asset($url), 'like' => Like::wherePostId($post->id)->get()->count(), 'dislike' => Dislike::wherePostId($post->id)->get()->count(), 'liked' => Like::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'disliked' => Dislike::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'comment' => Comment::wherePostId($post->id)->get()->count(), 'ago' => $now->diffForHumans()); } else { $data['flop_post'] = null; } // Top And Flop Post Generation end // Get All Available Reports and Feelings $data['feelings'] = Feeling::get(); $data['reports'] = Report::get(); // $data['notifications'] = $this->getNotification(); //Get Current Trends $now = Carbon::now(); $before_12hours = Carbon::now()->subHours(12); $data['tags'] = DB::table('hash_tagged_posts')->select('tag_id', 'tag', DB::raw('count(*) as count'))->join('hashtags', 'hashtags.id', '=', 'hash_tagged_posts.tag_id')->whereIn('hash_tagged_posts.post_id', function ($query) { $query->select('id')->from('posts')->whereType('3'); })->whereBetween('hash_tagged_posts.created_at', array($before_12hours, $now))->groupBy(['tag_id', 'tag'])->orderBy('count', 'desc')->take(3)->get(); //Get Current Trends End $data['page'] = "carnival"; return View::make('carnival')->with('data', $data); }
private function replaceEmoji($input) { $strReplace = '___REPLACE___'; $arrEmoticons = array(":-)", ":)", ";-)", ";)", ":-(", ":("); $arrEmojione = array(":smiley:", ":smiley:", ":wink:", ":wink:", ":disappointed:", ":disappointed:"); $input = str_replace($arrEmoticons, $arrEmojione, $input); \Emojione\Emojione::$cacheBustParam = ''; \Emojione\Emojione::$imagePathPNG = $strReplace; $content = \Emojione\Emojione::shortnameToImage($input); $content = preg_replace_callback('/' . $strReplace . '(.*)' . '\\.png/Si', 'static::emoticonCallback', $content); return $content; }
</div> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <p class="post-info"><small>Feeling {{$post['feeling']}}</small></p> </div> @endif </div> <!-- End///////////////////06-May-2015-Ehsan --> <p> <!-- Eve-27-May-Ehsan --> <?php $text = preg_replace('#((https?|ftp)://(\\S*?\\.\\S*?))([\\s)\\[\\]{},;"\':<]|\\.\\s|$)#i', '<a target="_blank" href="$1">$1</a>', $post['post']); if ($post['type'] != 0) { $text = preg_replace('/#([a-zA-Z0-9\\x{0980}-\\x{09FF}_])+/u', '<a href="#" class="">$0</a>', $text); } $text = nl2br($text); $text = Emojione::shortnameToImage($text); ?> {{$text}} <!-- !!!Eve-27-May-Ehsan --> </p> <!-- 9-2 --> @if($post['vidsrc']) <div class="row mc-no-margin-padding embed-responsive embed-responsive-16by9"> <iframe class="embed-responsive-item" src="https://www.youtube.com/embed/{{$post['vidsrc']}}" allowfullscreen></iframe> </div> @endif <!-- 9-2 End --> <!-- Start///////////19-May-2015-Ehsan -->
public function postProcess($posts) { $data = null; $i = 0; foreach ($posts as $post) { $post = Post::find($post->id); //if ($i == 5) break; ///////////////////06-May-2015-Ehsan $now = Carbon::parse($post->created_at); $feeling = DB::table('feelings')->find($post->feeling)->name; $following = Following::whereFollowerId(Auth::user()->id)->whereFollowingId($post->user_id)->get()->count(); $confession = Confession::whereUserId($post->user_id)->first(); if ($confession) { $confess_time = Carbon::parse($confession->created_at); $confess_time = $confess_time->diffInHours(); //$confess_time = $confess_time->diffInSeconds(); if ($confess_time < 24) { if ($confession->updated_at < $post->created_at) { $confession_view = ConfessionView::whereConfessionId($confession->id)->whereIsValid(1)->get()->count(); $confession = ['id' => $confession->id, 'confess' => $confession->confess, 'view' => $confession_view]; } else { $confession = null; } } else { $confession = null; } } $user = User::find($post->user_id); if ($user->disable == 1) { continue; } $url = Picture::find($user->picture); $url = $url->url; $text = htmlentities($post->post); // Youtube Video Searching $pos = strpos($text, 'watch?v='); if ($pos != 0) { $pos = $pos + 8; $str = substr($text, $pos, 11); # code... } else { $str = null; } // $name = null; if (($post->type == 1 || $post->type == 3) && !$post->hide_name) { $user = User::find($post->user_id); $name = $user->username; } $text = preg_replace('/#([a-zA-Z0-9\\x{0980}-\\x{09FF}_])+/u', '<a href="" class="tags">$0</a>', $text); /* Eve-26-May-Ehsan */ $text = preg_replace('#((https?|ftp)://(\\S*?\\.\\S*?))([\\s)\\[\\]{},;"\':<]|\\.\\s|$)#i', '<a target="_blank" href="$1">$1</a>', $text); /* !!!!Eve-26-May-Ehsan */ $text = nl2br($text); $text = Emojione::shortnameToImage($text); $data[$i++] = array('id' => $post->id, 'post' => $text, 'user_id' => $post->user_id, 'img' => asset($url), 'confess' => $confession, 'following' => $following, 'type' => $post->type, 'like' => Like::wherePostId($post->id)->get()->count(), 'dislike' => Dislike::wherePostId($post->id)->get()->count(), 'liked' => Like::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'disliked' => Dislike::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'comment' => Comment::wherePostId($post->id)->get()->count(), 'feeling' => $feeling, 'vidsrc' => $str, 'name' => $name, 'ago' => $now->diffForHumans()); } return $data; }