public function index()
 {
     $options = array();
     foreach (\Option::all() as $option) {
         $options[$option->key] = $option->value;
     }
     return View::make('admin.option.index')->with('options', $options);
 }
Exemple #2
0
<?php

if (Schema::hasTable('options')) {
    return Cache::rememberForever('options', function () {
        $get_options = Option::all();
        $options = array();
        foreach ($get_options as $option) {
            $options[$option->key] = $option->value;
        }
        return $options;
    });
}
// If the table doesnt exist we return a empty array
return array();
Exemple #3
0
    public function initCache()
    {
        // !!! DATABASE CACHE !!!
        //Cache Model::Menu
        //Cache::forget('DB_Menu');
        /*Cache::rememberForever('DB_Menu', function()
        		{
        		    return Menu::where('parent_id','=',0)->orderBy('order','ASC')->get();
        		});*/
        //Cache Model::Locale
        Cache::rememberForever('DB_LocaleFrontEnable', function () {
            //Get all data in database
            $locales = Locale::where('enable', '=', 1)->where('is_publish', '=', 1)->get();
            //Preapre data to extract by id
            $data = array();
            foreach ($locales as $l) {
                $data[] = $l->id;
            }
            return $data;
        });
        //Cache Model::Nav
        Cache::rememberForever('DB_Nav', function () {
            return Nav::where('parent_id', '=', 0)->orderBy('order', 'ASC')->get();
        });
        //Cache Model::Resource('name')
        Cache::rememberForever('DB_AdminResourceName', function () {
            //Get all data in database
            $resources = Resource::where('in_admin_ui', '=', 1)->get();
            //Preapre data to extract by id
            $data = array();
            foreach ($resources as $r) {
                $data[$r->id] = $r->name;
            }
            return $data;
        });
        Cache::rememberForever('DB_AdminResource', function () {
            //Get all data in database
            return Resource::where('in_admin_ui', '=', 1)->get();
        });
        Cache::rememberForever('DB_AdminResourceNavigable', function () {
            //Get all data in database
            return Resource::where('navigable', '=', 1)->where('in_admin_ui', '=', 1)->get();
        });
        // Get all Locales enableds in the table
        Cache::rememberForever('DB_LocalesEnabled', function () {
            return Locale::where('enable', 1)->where('is_publish', 1)->get();
        });
        Cache::rememberForever('DB_AdminBlockTypes', function () {
            //Get all data in database
            return BlockType::all();
        });
        //Cache Model::Mosaique('name')
        //Cache::forget('DB_Mosaique');
        /*Cache::rememberForever('DB_Mosaique', function()
        		{
        			//Get all data in database
        		    return Mosaique::all();
        		});*/
        //Cache Model::Option
        Cache::rememberForever('DB_Option', function () {
            return Option::all();
        });
        //Cache Model::Urls
        Cache::rememberForever('DB_Urls', function () {
            $data = DB::select('
		    	SELECT translations.i18n_id , translations.text , translations.locale_id 
				FROM translations
				INNER JOIN i18n_types ON i18n_types.name = ?
				INNER JOIN i18n ON i18n.i18n_type_id = i18n_types.id AND translations.i18n_id = i18n.id
		    ', array('url'));
            //$data = Translation::i18n()->where('i18n_type_id','=',I18nType::where('name','=','url')->first()->id)->get
            $datas = array();
            foreach ($data as $d) {
                $datas[] = array('i18n_id' => $d->i18n_id, 'url' => $d->text, 'locale_id' => $d->locale_id);
            }
            return $datas;
        });
    }
 public function tags()
 {
     $tags = Option::all();
     return View::make('admin.tags')->with('title', 'Product Tags')->with('tags', $tags);
 }
Exemple #5
0
 /**
  * post All Option in base
  *
  * @return Response
  */
 public function postOption()
 {
     //Making adaptive rules for site_name
     $site_name_rules = array();
     $site_name_locales = array();
     foreach (Input::all() as $k => $v) {
         if (strpos($k, 'site_name_') !== false) {
             $site_name_rules[$k] = Config::get('validator.admin.option_site_name');
             $site_name_locales[] = mb_substr($k, strlen('site_name_'), strlen($k) - strpos($k, 'site_name_'));
         }
     }
     //Making adaptive rules for social_title
     $social_title_rules = array();
     $social_title_locales = array();
     foreach (Input::all() as $k => $v) {
         if (strpos($k, 'social_title_') !== false) {
             $social_title_rules[$k] = Config::get('validator.admin.option_social_title');
             $social_title_locales[] = mb_substr($k, strlen('social_title_'), strlen($k) - strpos($k, 'social_title_'));
         }
     }
     //Making adaptive rules for social_description
     $social_description_rules = array();
     $social_description_locales = array();
     foreach (Input::all() as $k => $v) {
         if (strpos($k, 'social_description_') !== false) {
             $social_description_rules[$k] = Config::get('validator.admin.option_social_description');
             $social_description_locales[] = mb_substr($k, strlen('social_description_'), strlen($k) - strpos($k, 'social_description_'));
         }
     }
     $rules = array_merge($site_name_rules, $social_title_locales, $social_description_locales, Config::get('validator.admin.option'));
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         //Themes
         $activeThemePublic = Theme::where('type', 'public')->where('active', 1)->first();
         $activeThemeAdmin = Theme::where('type', 'admin')->where('active', 1)->first();
         //Change or not?
         if ($activeThemePublic->id != Input::get('theme_public')) {
             $activeThemePublic->active = false;
             $activeThemePublic->save();
             $newThemePublic = Theme::find(Input::get('theme_public'));
             $newThemePublic->active = true;
             $newThemePublic->save();
         }
         if ($activeThemeAdmin->id != Input::get('theme_admin')) {
             $activeThemeAdmin->active = false;
             $activeThemeAdmin->save();
             $newThemeAdmin = Theme::find(Input::get('theme_public'));
             $newThemeAdmin->active = true;
             $newThemeAdmin->save();
         }
         //Delete Cache
         Cache::forget('DB_ThemeByType');
         //Options
         $options = Option::all();
         foreach ($options as $option) {
             if ($option->key == "site_url") {
                 $option->value = Input::get('site_url');
             }
             if ($option->key == "cover_path") {
                 $option->value = Input::get('cover_path');
             }
             if ($option->key == "admin_email") {
                 $option->value = Input::get('admin_email');
             }
             if ($option->key == "analytics") {
                 $option->value = Input::get('analytics');
             }
             if ($option->key == "i18n_site_name") {
                 //Update translations
                 foreach ($site_name_locales as $locale) {
                     if (!I18n::find($option->value)->updateText($locale, Input::get('site_name_' . $locale))) {
                         return Redirect::to('admin/option')->with('error', Lang::get('admin.option_site_name_update_error'));
                     }
                 }
             }
             if ($option->key == "i18n_social_title") {
                 //Update translations
                 foreach ($social_title_locales as $locale) {
                     if (!I18n::find($option->value)->updateText($locale, Input::get('social_title_' . $locale))) {
                         return Redirect::to('admin/option')->with('error', Lang::get('admin.option_social_title_update_error'));
                     }
                 }
             }
             if ($option->key == "i18n_social_description") {
                 //Update translations
                 foreach ($social_description_locales as $locale) {
                     if (!I18n::find($option->value)->updateText($locale, Input::get('social_description_' . $locale))) {
                         return Redirect::to('admin/option')->with('error', Lang::get('admin.option_social_description_update_error'));
                     }
                 }
             }
             $option->save();
         }
         // Clear cache
         Cache::forget('options');
         //track user
         parent::track('update', 'Option', null);
         return Redirect::to('admin/option')->with('success', Lang::get('admin.option_success'));
     }
     // Show the page
     return Redirect::to('/admin/option')->withInput()->withErrors($validator);
 }