コード例 #1
0
ファイル: PageController.php プロジェクト: crobays/paging
 public function page($page = FALSE)
 {
     if ($locale = Cookie::get('locale')) {
         App::setLocale($locale);
     }
     if (!$page) {
         return Redirect::to(Lang::get('navigation.consumer'), 301);
     }
     $nav = array();
     foreach (['consumer', 'exporter'] as $item) {
         $loc = Lang::get('navigation.' . $item);
         $link = strtolower(str_replace(' ', '-', $loc));
         if ($link == $page) {
             $page = $item;
         }
         $nav[$link] = ucfirst($loc);
     }
     if (!View::exists('layouts.public.' . $page)) {
         App::abort(404);
     }
     $sub_nav = array();
     $view = View::make('layouts.public.' . $page);
     switch ($page) {
         case 'exporter':
             $sub_nav = ['assortment', 'horticulture', 'certification', 'contact'];
             $picturebox = new Picturebox\PictureboxManager();
             $view->with('picturebox', $picturebox);
             break;
     }
     $view->with('sub_nav', $sub_nav);
     return $view->with('nav', $nav);
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: Yashwanth1/aregudam
 public function __construct()
 {
     $this->middleware('ipblocked');
     $driver = config('database.default');
     $database = config('database.connections');
     $this->db = $database[$driver]['database'];
     $this->dbuser = $database[$driver]['username'];
     $this->dbpass = $database[$driver]['password'];
     $this->dbhost = $database[$driver]['host'];
     if (\Auth::check() == true) {
         if (!\Session::get('gid')) {
             \Session::put('uid', \Auth::user()->id);
             \Session::put('gid', \Auth::user()->group_id);
             \Session::put('eid', \Auth::user()->email);
             \Session::put('ll', \Auth::user()->last_login);
             \Session::put('fid', \Auth::user()->first_name . ' ' . \Auth::user()->last_name);
             \Session::put('themes', 'sximo-light-blue');
         }
     }
     if (!\Session::get('themes')) {
         \Session::put('themes', 'sximo');
     }
     if (defined('CNF_MULTILANG') && CNF_MULTILANG == 1) {
         $lang = \Session::get('lang') != "" ? \Session::get('lang') : CNF_LANG;
         \App::setLocale($lang);
     }
     $data = array('last_activity' => strtotime(Carbon::now()));
     \DB::table('tb_users')->where('id', \Session::get('uid'))->update($data);
 }
コード例 #3
0
ファイル: APIController.php プロジェクト: echojc/osu-web
 /**
  * GET /api/$version/translation/$lang?/$string.
  *
  * @api
  *
  * @return json
  */
 public function getTranslation($lang, $string = null)
 {
     if (!$string) {
         $string = $lang;
         $lang = 'en';
     }
     try {
         App::setLocale($lang);
     } catch (Exception $e) {
         return Response::json(['error' => 'unsupported language']);
     }
     if (strpos($string, ' ')) {
         // dealing with an array
         $strings = explode(' ', $string);
         $translation = [];
         foreach ($strings as $str) {
             $translation[$str] = Lang::get($str);
         }
     } else {
         // single strings allow for fallback to english.
         // multiples would involve too much
         $translation = Lang::get($string);
         if ($translation == $string and $lang != 'en') {
             App::setLocale(Config::get('app.locale', 'en'));
             $translation = Lang::get($string);
         }
     }
     return Response::json(['translation' => $translation]);
 }
コード例 #4
0
ファイル: BaseCommand.php プロジェクト: hirokws/syncle
 /**
  * Override run method to internationalize error message.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int Return code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // Set extra colors
     // The most problem is $output->getFormatter() don't work.
     // So create new formatter to add extra color.
     $formatter = new OutputFormatter($output->isDecorated());
     $formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
     $formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
     $formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
     $formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
     $formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
     $formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
     $output->setFormatter($formatter);
     \App::setLocale(\Config::get('syncle::MessageLang'));
     try {
         $result = parent::run($input, $output);
     } catch (\RuntimeException $e) {
         // All error messages were hard coded in
         // Symfony/Component/Console/Input/Input.php
         if ($e->getMessage() == 'Not enough arguments.') {
             $this->error(\Lang::get('syncle::BaseCommand.ArgumentNotEnough'));
         } elseif ($e->getMessage() == 'Too many arguments.') {
             $this->error(\Lang::get('syncle::BaseCommand.TooManyArgument'));
         } elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
             $this->error(\Lang::get('syncle::BaseCommand.OptionNotExist', array('option' => $matches[1])));
         } else {
             $this->error($e->getMessage());
         }
         $result = 1;
     }
     return $result;
 }
コード例 #5
0
 /**
  *
  */
 public function boot()
 {
     $this->loadViewsFrom(__DIR__ . '/../../views', 'admin-lte');
     $this->loadTranslationsFrom(__DIR__ . '/../../lang', 'admin');
     $this->mergeConfigFrom(__DIR__ . '/../../config/config.php', 'admin');
     $this->mergeConfigFrom(__DIR__ . '/../../config/theme.php', 'admintheme');
     $this->publishes([__DIR__ . '/../../config/config.php' => config_path('admin.php'), __DIR__ . '/../../config/theme.php' => config_path('admintheme.php')], 'config');
     // Publish migrations
     $migrations = realpath(__DIR__ . '/Database/Migrations');
     $this->publishes([$migrations => $this->app->databasePath() . '/migrations'], 'migrations');
     $this->publishes([__DIR__ . '/../../../public/' => public_path('vendor/sleeping-owl/admin/')], 'assets');
     //we need this, otherwise we have no access to existing session values
     //like the applocale which will be used to set the app language correctly
     app('SleepingOwl\\Admin\\Helpers\\StartSession')->run();
     if (\Config::get('admin.language_switcher') && \Session::has('applocale') && array_key_exists(\Session::get('applocale'), \Config::get('admin.languages'))) {
         \App::setLocale(\Session::get('applocale'));
     } else {
         // This is optional as Laravel will automatically set the fallback language if there is none specified
         \App::setLocale(\Config::get('app.fallback_locale'));
     }
     Admin::instance();
     $this->registerTemplate();
     $this->registerProviders();
     $this->initializeTemplate();
 }
コード例 #6
0
ファイル: BaseController.php プロジェクト: doptor/doptor
 /**
  * Initializer.
  *
  * @access   public
  * @return BaseController
  */
 public function __construct()
 {
     $is_admin = Request::is('admin*');
     $is_backend = Request::is('backend*');
     /* Set middleware(s) based on route URLs */
     if ($is_admin || $is_backend) {
         $this->middleware('auth');
         if ($is_backend) {
             // Backend specific middleware
             $this->middleware('auth.backend');
         }
         $this->middleware('auth.permissions');
         if (!Request::is('*users/change-password')) {
             // No validation for stale password if password is being changed
             $this->middleware('auth.pw_6_months');
         }
     }
     list($this->link_type, $this->link, $this->layout, $this->current_theme) = current_section();
     View::share('link_type', $this->link_type);
     View::share('current_theme', $this->current_theme);
     $website_settings = Setting::lists('value', 'name')->all();
     View::share('website_settings', $website_settings);
     $locale = Setting::value('language');
     App::setLocale($locale);
     Lang::setLocale($locale);
     $this->user = current_user();
     View::share('current_user', $this->user);
     View::share('current_user_companies', current_user_companies());
 }
コード例 #7
0
 /**
  * Detect and set application localization environment (language).
  * NOTE: Don't foreget to ADD/SET/UPDATE the locales array in app/config/app.php!
  *
  */
 private function configureLocale()
 {
     $mLocale = Config::get('app.locale');
     if (!Session::has('locale')) {
         $mFromCookie = Cookie::get('locale', null);
         if ($mFromCookie != null && in_array($mFromCookie, Config::get('app.locales'))) {
             $mLocale = $mFromCookie;
         } else {
             $mFromURI = Request::segment(1);
             if ($mFromURI != null && in_array($mFromURI, Config::get('app.locales'))) {
                 $mLocale = $mFromURI;
             } else {
                 $mFromBrowser = substr(Request::server('http_accept_language'), 0, 2);
                 if ($mFromBrowser != null && in_array($mFromBrowser, Config::get('app.locales'))) {
                     $mLocale = $mFromBrowser;
                 }
             }
         }
         Session::put('locale', $mLocale);
         Cookie::forever('locale', $mLocale);
     } else {
         $mLocale = Session::get('locale');
     }
     App::setLocale($mLocale);
 }
コード例 #8
0
ファイル: BaseController.php プロジェクト: erpio/Reportula
 public function __construct()
 {
     /* Set the Language Based on Agent Browser */
     $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
     $lang = substr($languages[0], 0, 2);
     App::setLocale($lang);
     /* Load Assets */
     Asset::add('bootstraptheme', 'assets/css/bootstrap-spacelab.css');
     Asset::add('bootstrapresponsive', 'assets/css/bootstrap-responsive.css');
     Asset::add('charisma', 'assets/css/charisma-app.css');
     Asset::add('uniform', 'assets/css/uniform.default.css');
     Asset::add('elfinder', 'assets/css/elfinder.min.css');
     Asset::add('opaicons', 'assets/css/opa-icons.css');
     Asset::add('famfam', 'assets/css/famfam.css');
     Asset::add('jqueryloadermin', 'assets/css/jquery.loader-min.css');
     Asset::add('reportula', 'assets/css/reportula.css');
     Asset::add('jquery', 'assets/js/jquery-2.0.3.min.js');
     Asset::add('datatables', 'assets/js/jquery.dataTables.min.js', 'jquery');
     Asset::add('jqueryloader', 'assets/js/jquery.loader-min.js', 'jquery');
     Asset::add('main', 'assets/js/main.js', 'TableTools');
     Asset::add('modal', 'assets/js/bootstrap-modal.js', 'jquery');
     /* Get Monolog instance from Laravel */
     $monolog = Log::getMonolog();
     /* Add the FirePHP handler */
     $monolog->pushHandler(new \Monolog\Handler\FirePHPHandler());
     /* Resolve Database Names Myslq and Postgres */
     if (Config::get('database.default') == 'mysql') {
         $this->tables = array('job' => 'Job', 'client' => 'Client', 'files' => 'Files', 'media' => 'Media', 'pool' => 'Pool', 'path' => 'Path', 'filename' => 'Filename', 'file' => 'File', 'jobfiles' => 'JobFiles', 'jobmedia' => 'JobMedia');
     } else {
         $this->tables = array('job' => 'job', 'client' => 'client', 'files' => 'files', 'media' => 'media', 'pool' => 'pool', 'path' => 'path', 'filename' => 'filename', 'file' => 'file', 'jobfiles' => 'jobfiles', 'jobmedia' => 'jobmedia');
     }
 }
コード例 #9
0
ファイル: LangController.php プロジェクト: quannh02/thuexeweb
 public function __construct()
 {
     $lang = Session::get('locale');
     if ($lang != null) {
         \App::setLocale($lang);
     }
 }
コード例 #10
0
 public function doChangeLocale()
 {
     $locale = Input::get('locale');
     LaravelLocalization::setLocale($locale);
     App::setLocale($locale);
     Cookie::queue('locale', $locale);
     return Response::json(array('status' => true, 'link' => geturl(Input::get('url'))));
 }
コード例 #11
0
ファイル: KalUpdateLocale.php プロジェクト: stjanilofts/normx
 public function handle($request, \Closure $next)
 {
     if ($request->has('language')) {
         $request->session()->put('language', $request->get('language'));
     }
     \App::setLocale($request->session()->get('language') ?: config('app.locale'));
     return $next($request);
 }
コード例 #12
0
 /**
  * Create a new filter instance.
  * @param  Guard $auth
  * @return void
  */
 public function __construct(Guard $auth)
 {
     $this->auth = $auth;
     $lang = Session::get('locale');
     if ($lang != null) {
         \App::setLocale($lang);
     }
 }
コード例 #13
0
 public function indexAction($sub)
 {
     App::setLocale("en");
     if (Input::get("lang") === "nl") {
         App::setLocale("nl");
     }
     return View::make("index/index", ["post" => Post::first()]);
 }
コード例 #14
0
 public function testAcTrans()
 {
     $defaultErrorMessage = ac_trans("messages.unauthorized.default");
     $this->assertEquals('You are not authorized to access this page.', $defaultErrorMessage);
     App::setLocale('fr');
     $defaultErrorMessageFr = ac_trans("messages.unauthorized.default");
     $this->assertNotEquals('You are not authorized to access this page.', $defaultErrorMessageFr);
     $this->assertEquals("Vous n'êtes pas autorisé à accéder à cette page.", $defaultErrorMessageFr);
 }
 /**
  * Create a new filter instance.
  *
  * @param  Guard  $auth
  * @return void
  */
 public function __construct(Guard $auth)
 {
     $this->auth = $auth;
     $lang = \Session::get('user_locale');
     //        echo'<pre>';print_r($lang);die("dxsvg");
     if ($lang != null) {
         \App::setLocale($lang);
     }
 }
コード例 #16
0
 public function test_lists_of_translated_fields_with_fallback()
 {
     App::make('config')->set('translatable.fallback_locale', 'en');
     App::setLocale('de');
     $country = new Country();
     $country->useTranslationFallback = true;
     $list = [['id' => '1', 'name' => 'Griechenland'], ['id' => '2', 'name' => 'France']];
     $this->assertEquals($list, $country->listsTranslations('name')->get()->toArray());
 }
コード例 #17
0
ファイル: Language.php プロジェクト: Qeenslet/elite-lara
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Session::has('applocale') and array_key_exists(Session::get('applocale'), Config::get('languages'))) {
         \App::setLocale(Session::get('applocale'));
     } elseif (strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'], 'ru') !== false) {
         \App::setLocale('ru');
     }
     return $next($request);
 }
コード例 #18
0
ファイル: AutoLang.php プロジェクト: kuenzelit/auto-lang
 public function init()
 {
     if (\Session::has('AutoLang')) {
         \App::setLocale(\Session::get('AutoLang'));
         return;
     }
     $detectedLang = AutoLang::detectLanguage();
     \Session::put('AutoLang', $detectedLang);
     \App::setLocale($detectedLang);
 }
コード例 #19
0
ファイル: Language.php プロジェクト: vuthaihoc/soa-sentinel
 public function handle($request, Closure $next)
 {
     if (\Config::get('admin.language_switcher') && \Session::has('applocale') && array_key_exists(\Session::get('applocale'), \Config::get('admin.languages'))) {
         \App::setLocale(\Session::get('applocale'));
     } else {
         // This is optional as Laravel will automatically set the fallback language if there is none specified
         \App::setLocale(\Config::get('app.fallback_locale'));
     }
     return $next($request);
 }
コード例 #20
0
 public static function setupLanguage($lang)
 {
     $retour = false;
     if (!empty($lang) && in_array($lang, self::$languages)) {
         self::$language = $lang;
         $retour = true;
     }
     App::setLocale($lang);
     return $retour;
 }
コード例 #21
0
 /**
  * Sets the locale if it exists in the session or uses preferred or default locale
  *
  * @return void
  */
 public function configureLocale()
 {
     $defaultLocale = static::getDefaultLocale();
     // set fallback locale
     \App('translator')->setFallback($defaultLocale);
     // set main locale
     \Request::setDefaultLocale($defaultLocale);
     $sessionKey = static::getLocaleSessionKey();
     $preferredLocale = \Request::getPreferredLanguage(static::getAllowedLocales());
     \App::setLocale($sessionKey ? \Session::get($sessionKey, $preferredLocale) : $preferredLocale);
 }
コード例 #22
0
 public function update($email = null)
 {
     if (is_null($email)) {
         return;
     }
     $key = \Input::get('verification_key');
     $subscriptor = \Modules\Newsletter\Entities\NewsletterSubscriptor::where('email', $email)->where('verification_key', $key)->firstOrFail();
     $subscriptor->prefered_language = \Input::get('prefered_language');
     $subscriptor->save();
     \App::setLocale(\Input::get('prefered_language'));
     return view('fullPageMessage', array('title' => \Lang::get('newsletter::messages.successChangingSettingsTitle'), 'message' => null, 'buttons' => array(['label' => \Lang::get('newsletter::messages.homePage'), 'url' => '/' . \Input::get('prefered_language')])));
 }
コード例 #23
0
ファイル: TestCase.php プロジェクト: 360weboy/october
 /**
  * Creates the application.
  *
  * @return Symfony\Component\HttpKernel\HttpKernelInterface
  */
 public function createApplication()
 {
     $unitTesting = true;
     $testEnvironment = 'testing';
     $result = (require __DIR__ . '/../bootstrap/start.php');
     /*
      * Use the array driver during the unit testing
      */
     Config::set('cache.driver', 'array');
     App::setLocale('en');
     return $result;
 }
コード例 #24
0
 public function setPageIdAttribute($value)
 {
     if (!isset($this->attributes['name'])) {
         \App::setLocale('es');
         if ($page = \Solunes\Master\App\Page::find($value)) {
             $page_name = $page->name;
         } else {
             $page_name = '-';
         }
         $this->attributes['name'] = $page_name;
     }
     $this->attributes['page_id'] = $value;
 }
コード例 #25
0
 public function setLang($lang)
 {
     if (array_key_exists($lang, $this->languages)) {
         App::setLocale($lang);
         if ($lang == 'en') {
             return '';
         } else {
             return $lang;
         }
     } else {
         return '';
     }
 }
コード例 #26
0
 public function gethistory()
 {
     App::setLocale(Session::get('locale', 'en'));
     $fb = LazySalesHelper::fb();
     $fbApp = LazySalesHelper::fbApp();
     $post = Post::where('uid', '=', $_SESSION['uid'])->get();
     if ($post != "[]") {
         $target_timezone = Config::get('timezone.' . Input::get('timezone'));
         return View::make('LazySales.history', array('target_timezone' => $target_timezone, 'post' => $post));
     } else {
         return Lang::get('lazysales.history_empty');
     }
 }
コード例 #27
0
ファイル: BaseController.php プロジェクト: Kr3m/Doptor
 /**
  * Initializer.
  *
  * @access   public
  * @return BaseController
  */
 public function __construct()
 {
     list($this->link_type, $this->link, $this->layout, $this->current_theme) = current_section();
     View::share('link_type', $this->link_type);
     View::share('current_theme', $this->current_theme);
     $website_settings = Setting::lists('value', 'name');
     View::share('website_settings', $website_settings);
     $locale = Setting::value('language');
     App::setLocale($locale);
     Lang::setLocale($locale);
     $this->user = current_user();
     View::share('current_user', $this->user);
     View::share('current_user_companies', current_user_companies());
 }
コード例 #28
0
 private function routes()
 {
     // сохраняем куку кода приглашения и редиректим на главную
     Route::get('/welcome/{lang}/{code}.html', function ($lang, $code) {
         $invite = new InviteComponent();
         $lang = in_array($lang, ['ru', 'en']) ? $lang : 'ru';
         App::setLocale($lang);
         return $invite->storeEntry($code);
     });
     Route::get('/welcome/{code}.html', function ($code) {
         $invite = new InviteComponent();
         return $invite->storeEntry($code);
     });
 }
コード例 #29
0
ファイル: Gateway.php プロジェクト: tuanlq11/cms
 /**
  * @param Request $request
  * @param Closure $next
  * @param string  $module
  *
  * @return mixed
  */
 public function handle($request, Closure $next, $module)
 {
     $action = explode('@', Route::getCurrentRoute()->getActionName())[1];
     $this->config = Config::get(strtolower($module), [[]])[0];
     $credentials = (array) $this->getConfig('credentials', $action);
     $is_secure = $this->getConfig('is_secure', $action)[0];
     $logged = Auth::check();
     $rules = [];
     if ($is_secure) {
         if (!$logged) {
             return redirect('/login');
         }
         /** @var User $user */
         $user = Auth::user();
         if ($user->super_admin) {
             $rules = ['*'];
         } else {
             if ($credentials !== ['*']) {
                 $rules = array_pluck($user->roles()->I18N()->where('is_active', true)->get(['i18n.id', 'name'])->toArray(), 'name', 'id');
                 /** Get Group Role */
                 /** @var array $groupRules */
                 $groupRules = $user->groups()->where('is_active', true)->with(['roles' => function ($subQuery) {
                     $subQuery->I18N()->select(['i18n.id', 'name'])->where("is_active", true);
                     return $subQuery;
                 }])->get()->toArray();
                 foreach ($groupRules as $group) {
                     $rules = array_pluck($group['roles'], 'name', 'id') + $rules;
                 }
                 /** END */
                 $matchRules = array_intersect($credentials, array_keys($rules));
                 if (empty($matchRules)) {
                     abort(404, 'Permission deny');
                 }
             }
         }
     }
     Session::put(sprintf("%s-preload", strtolower($module)), ['rules' => $rules]);
     /** Apply locale to Laravel-Loacle */
     if ($locale = Session::get('cms.locale', null)) {
         App::setLocale($locale);
     }
     /** END */
     /** Apply Session Locale */
     if (Session::has('language')) {
         \App::setLocale(Session::get('language'));
     }
     /** End*/
     $response = $next($request);
     return $response;
 }
コード例 #30
0
 public function showNiceMap()
 {
     $lang = Session::get('lang');
     App::setLocale($lang);
     $code = $this->code->all();
     $coeff = $this->coeff->all();
     $currency = $this->currency->all();
     $cargotype = $this->cargotype->all();
     $ua = ['coeffs' => $this->uacoeffs->all(), 'areas' => $this->uaareas->all()];
     $inputs = array('start' => Input::get('start'), 'end' => Input::get('end'));
     if (Session::get('role') === 'admin') {
         return View::make('public.nicemapAdmin')->withCodes($code)->withCoeffs($coeff)->withInputs($inputs)->withCurrencies($currency)->withCargotypes($cargotype)->withUa($ua);
     }
     return View::make('public.nicemap')->withCodes($code)->withCoeffs($coeff)->withInputs($inputs)->withCurrencies($currency)->withCargotypes($cargotype)->withUa($ua);
 }