/** * Gets Admin classes based on the current users permissions * which have been set. If a Admin class has not had the * Permissions provided, it will be displayed by default. * * @return */ public function getAdminClasses() { $classCollection = []; if (!defined('static::ADMIN_KEY')) { return $classCollection; } $classCollection = $this->getSubAdminClasses(\Flare::config(static::ADMIN_KEY)); return $classCollection; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle(Request $request, Closure $next) { if ($this->auth->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } return redirect()->guest(\Flare::adminUrl('login')); } return $next($request); }
/** * Register the Default Routes. * * This registers all the default routes which are included * with Flare. These consist of things which will probably * be included with every application such as the login, * logout and password reset forms. * * The login form can however be hidden by setting the * 'show' config for 'login' to false. * * @param Router $router */ protected function registerDefaultRoutes(Router $router) { $router->group(['prefix' => \Flare::config('admin_url'), 'as' => 'flare::', 'middleware' => ['web', 'flarebase']], function ($router) { // Logout route... $router->get('logout', $this->adminController('getLogout'))->name('logout'); if (\Flare::show('login')) { // Login request reoutes... $router->get('login', $this->adminController('getLogin'))->name('login'); $router->post('login', $this->adminController('postLogin'))->name('login'); // Password reset link request routes... $router->get('email', $this->adminController('getEmail'))->name('email'); $router->post('email', $this->adminController('postEmail'))->name('email'); // Password reset routes... $router->get('reset/{token}', $this->adminController('getReset'))->name('reset'); $router->post('reset', $this->adminController('postReset'))->name('reset'); } }); }
public function test_full_url_is_returned_using_defined_url_prefix() { $testAndResultArray = ['Admin', 'users', 'Models', 'perhaps123', 'Another-Example', 'user-defined-prefix', 'mix-and_match_or-dont', 'several_different_separators']; foreach ($testAndResultArray as $expectedResult) { $stub = $this->getMockForAbstractClass(Admin::class, [], 'SampleClassName'); $reflection = new ReflectionClass($stub); $reflection_property = $reflection->getProperty('urlPrefix'); $reflection_property->setAccessible(true); $reflection_property->setValue($stub, $expectedResult); $expectedResult = url(\Flare::config('admin_url') . '/' . $expectedResult); $this->assertEquals($stub->url(), $expectedResult); $reflection_property->setValue($stub, null); // Need to reset this afterwards. } }
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ Flare::constants(); class Flare { static $namespace = "flare"; static $label = "Flare"; // Default plugin options var $defaults = array('iconstyle' => "round", 'backgroundcolor' => "light", 'post_types' => array('post'), 'positions' => array('top', 'left'), 'follow_iconstyle' => "round", 'enablecounters' => true, 'enabletotal' => true, 'enablehumbleflare' => false, 'humbleflarecount' => 5, 'closablevertical' => true, 'filamenticon' => true); var $iconstyles = array('round-bevel' => "Round (Beveled)", 'round-flat' => "Round (Flat)", 'round-flat-nostroke' => "Round (Flat, No Stroke)", 'rounded-square-bevel' => "Rounded Square (Beveled)", 'rounded-square-flat' => "Rounded Square (Flat)", 'rounded-square-flat-nostroke' => "Rounded Square (Flat, No Stroke)", 'square-bevel' => "Square (Beveled)", 'square-flat' => "Square (Flat)", 'square-flat-nostroke' => "Square (Flat, No Stroke)"); var $available_positions = array('top' => "At top of the post", 'top-left' => "At top of the post (left aligned)", 'bottom' => "At bottom of the post", 'bottom-left' => "At bottom of the post (left aligned)", 'left' => "Floating left of the post", 'right' => "Floating right of the post"); // Menu item hook var $menu_hooks = array(); // Has the top been output yet? var $top_output = false; // Has the bottom been output yet? var $bottom_output = false; /**
/** * Menu Items. * * @return array */ public function menuItems() { return \Flare::settings()->menu(); }
/** * Register the application's policies. * * @param \Illuminate\Contracts\Auth\Access\Gate $gate */ public function registerPolicies(GateContract $gate) { foreach (array_merge($this->policies, \Flare::config('policies')) as $key => $value) { $gate->policy($key, $value); } }
/** * Relative URL to an Admin Top Level Page. * * @param string $path * * @return string */ public function relativeUrl($path = '') { return \Flare::relativeAdminUrl($this->urlPrefix() . ($path ? '/' . $path : '')); }