protected function initStaticPart() { $this->layoutManager->initStaticPart(function ($layoutManager) { $menu_top = $layoutManager->getView()->make('expendable::admin.menu.top', ['languages' => Language::all()]); $menu_left = $layoutManager->getView()->make('expendable::admin.menu.left'); $layoutManager->add(['state.menu' => $layoutManager->getState()->getRenderStateMenu(), 'menu_top' => $menu_top, 'menu_left' => $menu_left]); }); }
public function addTranslationAction($template = 'expendable::admin.form.components.datatable.translations', $route = '') { $this->add('translation', function ($model) use($template, $route) { $languages = Language::withoutCurrentLanguage()->get(); $translations = Translation::byElement($model)->lists('id_element', 'iso')->toArray(); return view($template, array('languages' => $languages, 'translations' => $translations, 'data' => $model->toArray(), 'route' => !empty($route) ? $route . '@' : $this->getControllerNameForAction() . '@'))->render(); }); }
public function testScopeSearchWithNoResult() { try { list($data, $model) = $this->addContent(); $result = \Distilleries\Expendable\Models\Language::search(uniqid() . uniqid() . uniqid())->get()->last(); $this->assertTrue(empty($result)); } catch (Exception $error) { $this->assertEquals('Database driver not supported: sqlite', $error->getMessage()); } }
public function testLanguageOnlyAndOffline() { $this->addContent(); $result = \Distilleries\Expendable\Models\Language::offlineAndOnline()->get(); $count = []; foreach ($result as $lang) { $count[$lang->status] = true; } $this->assertTrue(array_key_exists(0, $count)); $this->assertTrue(array_key_exists(1, $count)); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { preg_match_all('/(\\W|^)([a-z]{2})([^a-z]|$)/six', $request->server->get('HTTP_ACCEPT_LANGUAGE'), $m, PREG_PATTERN_ORDER); $user_langs = $m[2]; if (!empty($user_langs[0])) { $total = Language::where('iso', '=', $user_langs[0])->count(); if ($total > 0) { return redirect()->to('/' . $user_langs[0]); } } return redirect()->to('/fr'); }
<!-- BEGIN LOGO --> <div class="page-logo"> <a href="/"> <img src="{{ asset('assets/admin/img/logo.jpg') }}" alt="" class="logo-default" height="24" /> </a> <div class="menu-toggler sidebar-toggler hide"></div> </div> <!-- END LOGO --> <!-- BEGIN RESPONSIVE MENU TOGGLER --> <a href="javascript:;" class="menu-toggler responsive-toggler" data-toggle="collapse" data-target=".navbar-collapse"></a> <!-- END RESPONSIVE MENU TOGGLER --> <!-- BEGIN TOP NAVIGATION MENU --> <div class="top-menu"> <ul class="nav navbar-nav pull-right"> <?php $languages = \Distilleries\Expendable\Models\Language::all(); ?> @if(!empty($languages)) <li class="dropdown dropdown-extended dropdown-notification"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true"> <?php $iso = app()->getLocale(); $iso = isset($iso[1]) ? strtolower($iso[1]) : strtolower($iso[0]); ?> <span class="flags-sprite flags-{{ $iso }}"></span> <span class="badge badge-grey">{{ count($languages) }}</span> </a> <ul class="dropdown-menu"> @foreach($languages as $language) <?php $iso = explode('_', $language['iso']);
public function testImportXls() { \DB::table('languages')->truncate(); copy(realpath(__DIR__ . '/../../../data/exports/2015-03-17 2015-03-19.csv'), storage_path('2015-03-17 2015-03-19.xls')); $this->call('POST', action('Admin\\LanguageController@postImport'), ['file' => storage_path('2015-03-17 2015-03-19.xls')]); $total = \Distilleries\Expendable\Models\Language::count(); $this->assertSessionHas(\Distilleries\Expendable\Formatter\Message::MESSAGE); $this->assertEquals(1, $total); }
public function run() { Language::create(['libelle' => 'English', 'iso' => 'en', 'status' => true, 'not_visible' => false, 'is_default' => true]); Language::create(['libelle' => 'French', 'iso' => 'fr', 'status' => true, 'not_visible' => true, 'is_default' => true]); }
public function testLanguage() { list($data, $model) = $this->addContent(); $language = \Distilleries\Expendable\Models\Language::find($model->id); $this->assertEquals($model, $language); }