示例#1
0
 public function __construct(Request $request)
 {
     AppOptionHelper::load();
     $this->localeCode = currentLocaleCode();
     $this->is_auth = isAuth();
     $this->auth_user = authUser();
     if ($this->is_auth) {
         $own_directory = $this->auth_user->ownDirectory;
         config(['katniss.disks.' . $own_directory => ['driver' => 'local', 'root' => storage_path('../public/upload/file_manager/users/' . $own_directory)]]);
     }
 }
示例#2
0
 protected function checkForceLocale(Request $request)
 {
     $allSupportedLocaleCodes = allSupportedLocaleCodes();
     $isDirectLocale = in_array($request->segment(1), $allSupportedLocaleCodes);
     $forceLocale = $isDirectLocale ? currentLocaleCode() : SettingsFacade::getLocale();
     if ($request->has(AppConfig::KEY_FORCE_LOCALE)) {
         $forceLocale = $request->input(AppConfig::KEY_FORCE_LOCALE);
     }
     if (in_array($forceLocale, $allSupportedLocaleCodes)) {
         if ($forceLocale != SettingsFacade::getLocale()) {
             SettingsFacade::setLocale($forceLocale);
             SettingsFacade::storeSession();
             SettingsFacade::storeUser();
         }
         if ($forceLocale != currentLocaleCode()) {
             $rdr = redirect(currentURL($forceLocale));
             return SettingsFacade::storeCookie($rdr);
         }
     }
     return false;
 }
示例#3
0
 protected function __init()
 {
     if ($this::WIDGET_TRANSLATABLE) {
         $locale = currentLocaleCode();
         $fallbackLocale = config('app.fallback_locale');
         $this->localizedData = null;
         if (!empty($this->data[$locale])) {
             $this->localizedData = $this->data[$locale];
         } elseif (!empty($this->data[$fallbackLocale])) {
             $this->localizedData = $this->data[$fallbackLocale];
         }
     }
 }
示例#4
0
 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 '';
     }));
 }
示例#5
0
 protected function __init()
 {
     if (!$this::EXTENSION_EDITABLE) {
         abort(404);
     }
     if ($this::EXTENSION_TRANSLATABLE) {
         $locale = currentLocaleCode();
         $fallbackLocale = config('app.fallback_locale');
         $this->localizedData = null;
         if (!empty($this->data[$locale])) {
             $this->localizedData = $this->data[$locale];
         } elseif (!empty($this->data[$fallbackLocale])) {
             $this->localizedData = $this->data[$fallbackLocale];
         }
     }
 }
示例#6
0
function transPath($route = '', array $params = [], $localeCode = null)
{
    if (empty($localeCode)) {
        $localeCode = currentLocaleCode();
    }
    if (empty($route)) {
        return $localeCode;
    }
    $route = trans('routes.' . $route, [], '', $localeCode);
    return $localeCode . '/' . embedParamsInRoute($route, $params);
}