/** * Bind data to the view. * * @param View $view * @return void */ public function compose(View $view) { $menu = new Menu('ul', 'nav navbar-nav'); $menu->addItem(new MenuItem('#page-top', trans('pages.home_title'), 'li', 'hidden', 'page-scroll')); $menu = content_filter('main_menu', $menu); $view->with('main_menu', $menu); }
public function render() { $data = ['og:type' => $this->ogType, 'og:title' => $this->ogTitle, 'og:description' => $this->ogDescription, 'og:url' => $this->ogUrl, 'og:site_name' => $this->ogSiteName, 'og:image' => $this->ogImage, 'og:locale' => $this->ogLocale, 'og:locale:alternate' => $this->ogLocaleAlternate]; $data = content_filter('open_graph_tags_before_render', $data); return $this->parseCollection($data); }
/** * @param string $formattedCurrency * @param string $originalCurrencyCode * @return float */ public function fromFormatCurrency($formattedCurrency, $originalCurrencyCode = null) { if (empty($originalCurrencyCode)) { $originalCurrencyCode = $this->currencyCode; } $number = $this->fromFormat($formattedCurrency); $number = content_filter(self::FILTER_FROM_FORMAT_CURRENCY, $number, [$originalCurrencyCode]); return $number; }
public function register() { $sharing_buttons = []; if ($this->facebookEnable) { enqueue_theme_footer($this->facebookJsSdk(), 'facebook_js_sdk'); add_filter('open_graph_tags_before_render', new CallableObject(function ($data) { $data['fb:app_id'] = $this->facebookAppId; return $data; })); if ($this->facebookCommentEnable) { view()->share('facebook_comment', true); $color_scheme = $this->facebookCommentColorScheme; $num_posts = $this->facebookCommentNumPosts; $order_by = $this->facebookCommentOrderBy; $mobile = $this->facebookCommentMobile; $width = $this->facebookCommentWidth; $widthUnit = $this->facebookCommentWidthUnit; add_place('facebook_comment', new CallableObject(function ($url) use($color_scheme, $num_posts, $order_by, $mobile, $width, $widthUnit) { $color_scheme = ' data-colorscheme="' . $color_scheme . '"'; $num_posts = ' data-numposts="' . $num_posts . '"'; $order_by = ' data-order-by="' . $order_by . '"'; if ($mobile != 'auto') { $mobile = ' data-mobile="' . ($mobile == 'yes' ? 'true' : 'false') . '"'; } $width = ' data-width="' . $width . $widthUnit . '"'; return '<div class="fb-comments" data-href="' . $url . '"' . $color_scheme . $num_posts . $order_by . $mobile . $width . '"></div>'; })); } if ($this->facebookLikeEnable || $this->facebookShareEnable || $this->facebookRecommendEnable || $this->facebookSendEnable) { enqueue_theme_header('<style>.fb_iframe_widget > span{vertical-align: baseline!important;}</style>', 'facebook_css_fixed'); } if ($this->facebookLikeEnable) { $sharing_buttons['facebook_like'] = '<div class="fb-like" data-href="{sharing_url}" data-layout="' . $this->facebookLikeLayout . '" data-action="like" data-show-faces="false" data-share="false"></div>'; } if ($this->facebookShareEnable) { $sharing_buttons['facebook_share'] = '<div class="fb-share-button" data-href="{sharing_url}" data-layout="' . $this->facebookShareLayout . '"></div>'; } if ($this->facebookRecommendEnable) { $sharing_buttons['facebook_recommend'] = '<div class="fb-like" data-href="{sharing_url}" data-layout="' . $this->facebookRecommendLayout . '" data-action="recommend" data-show-faces="false" data-share="false"></div>'; } if ($this->facebookSendEnable) { $sharing_buttons['facebook_send'] = '<div class="fb-send" data-href="{sharing_url}"></div>'; } if ($this->facebookSaveEnable) { $sharing_buttons['facebook_save'] = '<div class="fb-save" data-uri="{sharing_url}" data-size="small"></div>'; } } if ($this->twitterEnable) { enqueue_theme_footer($this->twitterJsSdk(), 'twitter_js_sdk'); if ($this->twitterShareEnable) { $sharing_buttons['twitter_tweet'] = '<a href="https://twitter.com/share" class="twitter-share-button" data-url="{sharing_url}" data-lang="' . currentLocaleCode() . '">Tweet</a>'; } } if ($this->linkedInEnable) { enqueue_theme_footer($this->linkedInJsSdk(), 'linkedin_js_sdk'); if ($this->linkedInShareEnable) { if ($this->linkedInShareCountMode != 'nocount') { $sharing_buttons['linkedin_share'] = '<script type="IN/Share" data-url="{sharing_url}" data-counter="' . $this->linkedInShareCountMode . '"></script>'; } else { $sharing_buttons['linkedin_share'] = '<script type="IN/Share" data-url="{sharing_url}"></script>'; } } } if ($this->googleEnable) { enqueue_theme_footer($this->googleJsSdk(), 'google_plus_js_sdk'); if ($this->googleShareEnable) { if ($this->googleShareButtonAnnotation == 'inline') { $sharing_buttons['google_share'] = '<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="300" data-href="{sharing_url}"></div>'; } else { $sharing_buttons['google_share'] = '<div class="g-plusone" data-size="' . $this->googleShareButtonSize . '" data-annotation="' . $this->googleShareButtonAnnotation . '" data-href="{sharing_url}"></div>'; } } } add_place('sharing_buttons', new CallableObject(function ($sharing_url) use($sharing_buttons) { $buttons = content_filter('sharing_buttons', $sharing_buttons); if (count($buttons) > 0) { array_walk($buttons, function (&$button) use($sharing_url) { $button = str_replace('{sharing_url}', $sharing_url, $button); }); return '<ul class="list-inline"><li>' . implode('</li><li>', $buttons) . '</li></ul>'; } return ''; })); }
break; case 'chat': //聊天行为 $category = $msg['category']; $date = date('Y年m月d日 H:i:s'); $from = $msg['from']; $usr = get_valid_usr($ws, $from, $frame->fd); $media = $msg['media']; if (empty($from) || empty($usr)) { $ws->push($frame->fd, jsonResult('error', ERROR_CODE, '用户名信息异常,请刷新页面!')); break; } elseif (strlen($msg['content']) >= 2 * 1024 * 1024) { $ws->push($frame->fd, jsonResult('error', ERROR_CODE, '内容大小超出最大限制(2MB)')); break; } $content = $media ? $msg['content'] : content_filter($msg['content']); $avatar = get_avatar_number($from); $to = $msg['to']; if ($category == 'robot') { //发送成功 $data = array('username' => $from, 'avatar' => $avatar, 'time' => $date, 'content' => $content, 'room' => $to, 'room_icon' => get_avatar_number($to), 'media' => $media); $ws->push($frame->fd, jsonResult($act, SUCCESS_CODE, 'success', $data)); //访问机器人 if ($media) { $content = '好看吗'; } $result = $robot->chat($content); $date = date('Y年m月d日 H:i:s'); $data = array('username' => $to, 'avatar' => get_avatar_number($to), 'time' => $date, 'content' => $result, 'room' => $to, 'room_icon' => get_avatar_number($to), 'media' => 0); //机器人应答 $ws->push($frame->fd, jsonResult($act, SUCCESS_CODE, 'success', $data));