Exemplo n.º 1
0
Arquivo: Plugin.php Projeto: jiiis/ptn
 public function boot()
 {
     if ((bool) File::get(base_path() . '/plugins/indikator/backend/assets/gzip.txt')) {
         ob_start('ob_gzhandler');
     }
     Event::listen('backend.form.extendFields', function ($form) {
         if ($form->model instanceof Backend\Models\Preference) {
             $form->addTabFields(['rounded_avatar' => ['tab' => 'indikator.backend::lang.settings.tab_display', 'label' => 'indikator.backend::lang.settings.avatar_label', 'comment' => 'indikator.backend::lang.settings.avatar_comment', 'type' => 'switch', 'default' => false], 'topmenu_label' => ['tab' => 'indikator.backend::lang.settings.tab_display', 'label' => 'indikator.backend::lang.settings.topmenu_label', 'comment' => 'indikator.backend::lang.settings.topmenu_comment', 'type' => 'switch', 'default' => false], 'sidebar_description' => ['tab' => 'indikator.backend::lang.settings.tab_display', 'label' => 'indikator.backend::lang.settings.sidebar_desc_label', 'comment' => 'indikator.backend::lang.settings.sidebar_desc_comment', 'type' => 'switch', 'default' => false], 'sidebar_search' => ['tab' => 'indikator.backend::lang.settings.tab_display', 'label' => 'indikator.backend::lang.settings.sidebar_search_label', 'comment' => 'indikator.backend::lang.settings.sidebar_search_comment', 'type' => 'switch', 'default' => false], 'more_themes' => ['tab' => 'indikator.backend::lang.settings.tab_display', 'label' => 'indikator.backend::lang.settings.themes_label', 'comment' => 'indikator.backend::lang.settings.themes_comment', 'type' => 'switch', 'default' => false], 'focus_searchfield' => ['tab' => 'indikator.backend::lang.settings.tab_behavior', 'label' => 'indikator.backend::lang.settings.search_label', 'comment' => 'indikator.backend::lang.settings.search_comment', 'type' => 'switch', 'default' => false], 'context_menu' => ['tab' => 'indikator.backend::lang.settings.tab_behavior', 'label' => 'indikator.backend::lang.settings.context_menu_label', 'comment' => 'indikator.backend::lang.settings.context_menu_comment', 'type' => 'switch', 'default' => false], 'form_clearbutton' => ['tab' => 'indikator.backend::lang.settings.tab_behavior', 'label' => 'indikator.backend::lang.settings.clearbutton_label', 'comment' => 'indikator.backend::lang.settings.clearbutton_comment', 'type' => 'switch', 'default' => false], 'virtual_keyboard' => ['tab' => 'indikator.backend::lang.settings.tab_behavior', 'label' => 'indikator.backend::lang.settings.keyboard_label', 'comment' => 'indikator.backend::lang.settings.keyboard_comment', 'type' => 'switch', 'default' => false], 'enabled_gzip' => ['tab' => 'indikator.backend::lang.settings.tab_behavior', 'label' => 'indikator.backend::lang.settings.enabled_gzip_label', 'comment' => 'indikator.backend::lang.settings.enabled_gzip_comment', 'type' => 'switch', 'default' => false]]);
         }
     });
     BackendController::extend(function ($controller) {
         if (BackendAuth::check()) {
             /*
              * User settings
              */
             $preferenceModel = class_exists('Backend\\Models\\UserPreference') ? Backend\Models\UserPreference::forUser() : Backend\Models\UserPreferences::forUser();
             $preferences = $preferenceModel->get('backend::backend.preferences');
             /*
              * Display settings
              */
             if (isset($preferences['rounded_avatar']) && $preferences['rounded_avatar']) {
                 $controller->addCss('/plugins/indikator/backend/assets/css/rounded-avatar.css');
             }
             if (isset($preferences['topmenu_label']) && $preferences['topmenu_label']) {
                 $controller->addCss('/plugins/indikator/backend/assets/css/topmenu-label.css');
                 $controller->addJs('/plugins/indikator/backend/assets/js/topmenu-label.js');
             }
             if (isset($preferences['sidebar_search']) && $preferences['sidebar_search']) {
                 $controller->addCss('/plugins/indikator/backend/assets/css/sidebar-search.css');
             }
             if (isset($preferences['sidebar_description']) && $preferences['sidebar_description']) {
                 $controller->addCss('/plugins/indikator/backend/assets/css/sidebar-description.css');
             }
             if (isset($preferences['more_themes']) && $preferences['more_themes']) {
                 $controller->addJs('/plugins/indikator/backend/assets/js/setting-theme.js');
             }
             /*
              * Behavior settings
              */
             if (isset($preferences['focus_searchfield']) && $preferences['focus_searchfield']) {
                 $controller->addCss('/plugins/indikator/backend/assets/css/setting-search.css');
                 $controller->addJs('/plugins/indikator/backend/assets/js/setting-search.js');
             }
             if (isset($preferences['context_menu']) && $preferences['context_menu']) {
                 $controller->addCss('/plugins/indikator/backend/assets/css/context-menu.css');
                 $controller->addJs('/plugins/indikator/backend/assets/js/context-menu.js');
             }
             if (isset($preferences['form_clearbutton']) && $preferences['form_clearbutton']) {
                 $controller->addJs('/plugins/indikator/backend/assets/js/form-clearbutton.js');
             }
             if (isset($preferences['virtual_keyboard']) && $preferences['virtual_keyboard']) {
                 $controller->addCss('/plugins/indikator/backend/assets/css/ml-keyboard.css');
                 $controller->addJs('/plugins/indikator/backend/assets/js/ml-keyboard.js');
             }
             if (isset($preferences['enabled_gzip']) && $preferences['enabled_gzip']) {
                 File::put(base_path() . '/plugins/indikator/backend/assets/gzip.txt', 1);
             } else {
                 File::put(base_path() . '/plugins/indikator/backend/assets/gzip.txt', 0);
             }
         }
     });
 }
Exemplo n.º 2
0
 protected function resetWidgetsUserPreferences()
 {
     UserPreference::forUser()->reset($this->getUserPreferencesKey());
 }
Exemplo n.º 3
0
 /**
  * Checks if a hint has been hidden by the user.
  * @param  string $name Unique key name
  * @return boolean
  */
 public function isBackendHintHidden($name)
 {
     $hiddenHints = UserPreference::forUser()->get('backend::hints.hidden', []);
     return array_key_exists($name, $hiddenHints);
 }
 /**
  * Returns a cache key for this record.
  */
 protected function getCacheKey()
 {
     $item = UserPreference::forUser();
     $userId = $item->userContext ? $item->userContext->id : 0;
     return $this->recordCode . '-userpreference-' . $userId;
 }