Пример #1
0
 public function boot()
 {
     Event::listen('backend.form.extendFields', function ($form) {
         if ($form->model instanceof Backend\Models\BackendPreferences) {
             $form->addFields(['focus_searchfield' => ['label' => 'indikator.backend::lang.settings.search_label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.search_comment'], 'sidebar_description' => ['label' => 'indikator.backend::lang.settings.sidebar_label', 'type' => 'switch', 'span' => 'right', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.sidebar_comment'], 'rounded_avatar' => ['label' => 'indikator.backend::lang.settings.avatar_label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.avatar_comment'], 'virtual_keyboard' => ['label' => 'indikator.backend::lang.settings.keyboard_label', 'type' => 'switch', 'span' => 'right', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.keyboard_comment'], 'media_menu' => ['label' => 'indikator.backend::lang.settings.media_label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.media_comment'], 'more_themes' => ['label' => 'indikator.backend::lang.settings.themes_label', 'type' => 'switch', 'span' => 'right', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.themes_comment']]);
         }
     });
     BackendController::extend(function ($controller) {
         if (BackendAuth::check()) {
             $preferences = UserPreferences::forUser()->get('backend::backend.preferences');
             if (isset($preferences['focus_searchfield']) && $preferences['focus_searchfield']) {
                 $controller->addJs('/plugins/indikator/backend/assets/js/setting-search.js');
             }
             if (isset($preferences['rounded_avatar']) && $preferences['rounded_avatar']) {
                 $controller->addCss('/plugins/indikator/backend/assets/css/rounded-avatar.css');
             }
             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['media_menu']) && $preferences['media_menu']) {
                 $controller->addCss('/plugins/indikator/backend/assets/css/media-menu.css');
             }
             if (isset($preferences['more_themes']) && $preferences['more_themes']) {
                 $controller->addJs('/plugins/indikator/backend/assets/js/setting-theme.js');
             }
         }
     });
     BackendMenu::registerContextSidenavPartial('October.System', 'system', '~/plugins/indikator/backend/partials/_system_sidebar.htm');
 }
Пример #2
0
 public function beforeSave()
 {
     if (!isset($this->slug) || empty($this->slug)) {
         $this->slug = Str::slug($this->title);
     }
     if ($this->send && $this->send != '') {
         $preferences = UserPreferences::forUser()->get('backend::backend.preferences');
         if (!File::exists('plugins/indikator/news/views/mail/email_' . $preferences['locale'] . '.htm')) {
             $preferences['locale'] = 'en';
         }
         $users = DB::table('news_subscribers')->get();
         foreach ($users as $user) {
             $params = ['name' => $user->name, 'email' => $user->email, 'title' => $this->title, 'slug' => $this->slug, 'introductory' => $this->introductory, 'content' => $this->content, 'image' => $this->image];
             $this->email = $user->email;
             $this->name = $user->name;
             Mail::send('indikator.news::mail.email_' . $preferences['locale'], $params, function ($message) {
                 $message->to($this->email, $this->name)->subject($this->title);
             });
             DB::table('news_subscribers')->where('id', $user->id)->update(array('statistics' => $user->statistics + 1));
         }
         unset($this->email, $this->name);
     }
     if ($this->send) {
         $this->send = 1;
     } else {
         $this->send = 2;
     }
 }
Пример #3
0
 /**
  * Before the model is saved, ensure the record code is set
  * and the jsonable field values
  */
 public function beforeModelSave()
 {
     $preferences = UserPreferences::forUser();
     list($namespace, $group, $item) = $preferences->parseKey($this->recordCode);
     $this->model->item = $item;
     $this->model->group = $group;
     $this->model->namespace = $namespace;
     $this->model->user_id = $preferences->userContext->id;
     if ($this->fieldValues) {
         $this->model->value = $this->fieldValues;
     }
 }
Пример #4
0
 public function __construct()
 {
     parent::__construct();
     $preferences = UserPreferences::forUser()->get('backend::backend.preferences');
     if (PluginManager::instance()->hasPlugin('AnandPatel.WysiwygEditors')) {
         $this->addCss('http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css');
         $this->addCss('/plugins/anandpatel/wysiwygeditors/resources/assets/css/elfinder.min.css');
         $this->addCss('/plugins/anandpatel/wysiwygeditors/resources/assets/css/theme.css');
         $this->addJs('http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js');
         $this->addJs('/plugins/anandpatel/wysiwygeditors/resources/assets/js/elfinder.min.js');
         if ($preferences['locale'] != 'en' && File::exists('plugins/anandpatel/wysiwygeditors/resources/assets/js/i18n/elfinder.' . $preferences['locale'] . '.js')) {
             $this->addJs('/plugins/anandpatel/wysiwygeditors/resources/assets/js/i18n/elfinder.' . $preferences['locale'] . '.js');
         }
     }
     BackendMenu::setContext('Indikator.Filemanager', 'pages');
 }
Пример #5
0
 /**
  * Checks if a hint has been hidden by the user.
  * @param  string $name Unique key name
  * @return boolean
  */
 public function isBackendHintHidden($name)
 {
     $hiddenHints = UserPreferences::forUser()->get('backend::hints.hidden', []);
     return array_key_exists($name, $hiddenHints);
 }
Пример #6
0
 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);
             }
         }
     });
 }
Пример #7
0
 protected function setWidgetsToUserPreferences($widgets)
 {
     UserPreferences::forUser()->set($this->getUserPreferencesKey(), $widgets);
 }
Пример #8
0
 /**
  * Returns a cache key for this record.
  */
 protected function getCacheKey()
 {
     $item = UserPreferences::forUser();
     $userId = $item->userContext ? $item->userContext->id : 0;
     return $this->recordCode . '-userpreference-' . $userId;
 }