/** * Execute the controller action. * @param string $action The action name. * @param array $params Routing parameters to pass to the action. * @return mixed The action result. */ public function run($action = null, $params = []) { $this->action = $action; $this->params = $params; /* * Check security token. */ if (!$this->verifyCsrfToken()) { return Response::make(Lang::get('backend::lang.page.invalid_token.label'), 403); } /* * Extensibility */ if (($event = $this->fireEvent('page.beforeDisplay', [$action, $params], true)) || ($event = Event::fire('backend.page.beforeDisplay', [$this, $action, $params], true))) { return $event; } /* * Determine if this request is a public action. */ $isPublicAction = in_array($action, $this->publicActions); // Create a new instance of the admin user $this->user = BackendAuth::getUser(); /* * Check that user is logged in and has permission to view this page */ if (!$isPublicAction) { /* * Not logged in, redirect to login screen or show ajax error. */ if (!BackendAuth::check()) { return Request::ajax() ? Response::make(Lang::get('backend::lang.page.access_denied.label'), 403) : Backend::redirectGuest('backend/auth'); } /* * Check access groups against the page definition */ if ($this->requiredPermissions && !$this->user->hasAnyAccess($this->requiredPermissions)) { return Response::make(View::make('backend::access_denied'), 403); } } /* * Set the admin preference locale */ BackendPreference::setAppLocale(); BackendPreference::setAppFallbackLocale(); /* * Execute AJAX event */ if ($ajaxResponse = $this->execAjaxHandlers()) { return $ajaxResponse; } /* * Execute postback handler */ if (($handler = post('_handler')) && ($handlerResponse = $this->runAjaxHandler($handler)) && $handlerResponse !== true) { return $handlerResponse; } /* * Execute page action */ $result = $this->execPageAction($action, $params); if (!is_string($result)) { return $result; } return Response::make($result, $this->statusCode); }
public function formFindModelObject() { return PreferenceModel::instance(); }
/** * Looks at the user preferences and overrides any set values. * @return void */ protected function applyEditorPreferences() { // Load the editor system settings $preferences = BackendPreference::instance(); $this->fontSize = $preferences->editor_font_size; $this->wordWrap = $preferences->editor_word_wrap; $this->codeFolding = $preferences->editor_code_folding; $this->autoClosing = $preferences->editor_auto_closing; $this->tabSize = $preferences->editor_tab_size; $this->theme = $preferences->editor_theme; $this->showInvisibles = $preferences->editor_show_invisibles; $this->highlightActiveLine = $preferences->editor_highlight_active_line; $this->useSoftTabs = !$preferences->editor_use_hard_tabs; $this->showGutter = $preferences->editor_show_gutter; $this->autocompletion = $preferences->editor_autocompletion; $this->enableSnippets = $preferences->editor_enable_snippets; $this->displayIndentGuides = $preferences->editor_display_indent_guides; $this->showPrintMargin = $preferences->editor_show_print_margin; }