예제 #1
0
 public function initializationModule()
 {
     $this->modulePath = app_path('Modules/' . $this->moduleName);
     //Config
     if (file_exists($this->modulePath . '/config.php')) {
         $this->mergeConfigFrom($this->modulePath . '/config.php', 'module' . $this->moduleName);
     }
     //Language
     if (is_dir($this->modulePath . '/Languages')) {
         $this->app->language->load($this->moduleName);
     }
     //Helper
     if (file_exists($this->modulePath . '/helpers.php')) {
         require $this->modulePath . '/helpers.php';
     }
     //View
     if (is_dir($this->modulePath . '/Views')) {
         $this->loadViewsFrom($this->modulePath . '/Views', $this->moduleName);
     }
     //Hook View
     if (isset($this->hookView)) {
         foreach ($this->hookView as $key => $value) {
             $this->app->config->set('hooks.' . $key, $value);
         }
     }
     //Widget
     if (isset($this->widget)) {
         foreach ($this->widget as $key => $value) {
             $this->app->widget->register($key, $value);
         }
     }
     //Cast
     if (isset($this->castPost)) {
         foreach ($this->castPost as $key => $value) {
             $this->app->config->set('site.cast.post.' . $key, $value);
         }
     }
     if (isset($this->castCategory)) {
         foreach ($this->castCategory as $key => $value) {
             $this->app->config->set('site.cast.category.' . $key, $value);
         }
     }
     //Permissions
     if (isset($this->permissions)) {
         foreach ($this->permissions as $key => $value) {
             $this->app->config->set('site.permissions.' . $key, $value);
         }
     }
     //Route
     if (file_exists($this->modulePath . '/Routes/web.php')) {
         Route::group(['middleware' => 'web', 'namespace' => 'App\\Modules\\' . $this->moduleName . '\\Controllers'], function ($router) {
             require $this->modulePath . '/Routes/web.php';
         });
     }
     if (file_exists($this->modulePath . '/Routes/api.php')) {
         Route::group(['middleware' => 'api', 'namespace' => $this->namespace, 'prefix' => 'api'], function ($router) {
             require $this->modulePath . '/Routes/api.php';
         });
     }
 }
예제 #2
0
 public static function _routes_status()
 {
     $_class = get_called_class();
     $_uri = static::$uri;
     $_as = static::$action;
     Route::post("{$_uri}/status/change", ['as' => "{$_as}.edit.status", 'uses' => "{$_class}@change_status"]);
 }
예제 #3
0
 private function loadPageTitle()
 {
     $pageTitles = config('forone.nav_titles');
     $curRouteName = Route::currentRouteName();
     if (array_key_exists($curRouteName, $pageTitles)) {
         return $pageTitles[$curRouteName];
     } else {
         // load menus title
         $url = URL::current();
         $menus = config('forone.menus');
         foreach ($menus as $title => $menu) {
             if (array_key_exists('children', $menu) && $menu['children']) {
                 foreach ($menu['children'] as $childTitle => $child) {
                     $pageTitle = $this->parseTitle($childTitle, $url, $child['active_uri']);
                     if ($pageTitle) {
                         return $pageTitle;
                     }
                 }
             } else {
                 $pageTitle = $this->parseTitle($title, $url, $menu['active_uri']);
                 if ($pageTitle) {
                     return $pageTitle;
                 }
             }
         }
     }
     return $curRouteName;
 }
예제 #4
0
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->package('mmanos/laravel-image');
     if ($route = Config::get('laravel-image::route')) {
         Route::get($route, 'Mmanos\\Image\\ImagesController@getIndex');
     }
 }
예제 #5
0
 /**
  * Track clicked links and form submissions.
  *
  * @param  Request $request
  * @return void
  */
 public function track(Request $request)
 {
     // Don't track if there is no active experiment.
     if (!$this->session->get('experiment')) {
         return;
     }
     // Since there is an ongoing experiment, increase the pageviews.
     // This will only be incremented once during the whole experiment.
     $this->pageview();
     // Check current and previous urls.
     $root = $request->root();
     $from = ltrim(str_replace($root, '', $request->headers->get('referer')), '/');
     $to = ltrim(str_replace($root, '', $request->getPathInfo()), '/');
     // Don't track refreshes.
     if ($from == $to) {
         return;
     }
     // Because the visitor is viewing a new page, trigger engagement.
     // This will only be incremented once during the whole experiment.
     $this->interact();
     $goals = $this->getGoals();
     // Detect goal completion based on the current url.
     if (in_array($to, $goals) or in_array('/' . $to, $goals)) {
         $this->complete($to);
     }
     // Detect goal completion based on the current route name.
     if ($route = Route::currentRouteName() and in_array($route, $goals)) {
         $this->complete($route);
     }
 }
 public function index()
 {
     $urls = [];
     $routes = Route::getRoutes();
     foreach ($routes as $route) {
         $path = $route->getPath();
         $actions = $route->getAction();
         $params = $route->parameterNames();
         $controller = $actions['controller'];
         if (starts_with($path, '_') or str_contains($controller, 'RedirectController') or count($params)) {
             continue;
         }
         $urls[] = url($path);
     }
     foreach (Campus::all() as $item) {
         $urls[] = url($item->url);
     }
     foreach (Event::all() as $item) {
         $urls[] = url($item->url);
     }
     foreach (Series::withDrafts()->get() as $item) {
         $urls[] = url($item->url);
     }
     foreach (Staff::all() as $item) {
         $urls[] = url($item->url);
     }
     foreach (MissionLocation::all() as $item) {
         $urls[] = url($item->url);
     }
     foreach (Video::withDrafts()->get() as $item) {
         $urls[] = url($item->url);
     }
     return response()->json($urls);
 }
예제 #7
0
 /**
  * 将数据绑定到视图。
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     //查询当前登录用户
     $admin = Auth::guard('admin')->user();
     if ($admin->admin_name == 'admin') {
         $menus = Menu::orderBy('sort', 'ASC')->get()->toTree();
     } else {
         if ($admin->role) {
             $ids = DB::table('sys_role_function')->where('sys_role_id', $admin->role[0]->id)->pluck('sys_fun_id');
             $menus = Menu::orderBy('sort', 'ASC')->whereIn('id', $ids)->get()->toTree();
         }
     }
     $currentRoute = Route::currentRouteName();
     $list = explode('.', $currentRoute);
     $route = '';
     for ($i = 0; $i < count($list) - 1; $i++) {
         if ($i == 0) {
             $route .= $list[$i];
         } else {
             $route .= '.' . $list[$i];
         }
     }
     $route = $route . '.index';
     $view->with('currentRoute', $route)->with('trees', $menus);
 }
예제 #8
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($user = $request->user()) {
         //判断是不是管理员
         $userRoles = Role::all();
         foreach ($userRoles as $r) {
             $roles[] = $r->name;
         }
         if (!$user->hasRole($roles)) {
             redirect()->guest('auth/login');
         }
         //创始人拥有所有权限
         if (!$user->hasRole('Founder')) {
             $can = Route::currentRouteName();
             //当前routeName  exp:user.test
             $res = $request->user()->can($can);
             if (!$res) {
                 return view('admin.noaccess');
             }
         }
     } else {
         return redirect()->guest('auth/login');
     }
     return $next($request);
 }
예제 #9
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     try {
         $inputs = array('des_name', 'des_coors', 'des_instruction', 'related_photos');
         $obj = array('message' => 'succeeded');
         foreach ($inputs as $field) {
             $obj[$field] = $request->input($field, '');
         }
         // TODO: cuối cùng vẫn phải chạy Raw SQL -_-
         $destination = DB::table('Destination')->insertGetId(array('des_name' => $obj['des_name'], 'des_instruction' => $obj['des_instruction'], 'coordinate' => DB::raw("GeomFromText(\"POINT(" . $obj['des_coors']['latitude'] . " " . $obj['des_coors']['longitude'] . ")\")")));
         // upload selected images too
         $images_uploaded = array();
         $relPhotos = $obj['related_photos'];
         if ($relPhotos) {
             foreach ($relPhotos as $photo) {
                 if ($photo['selected']) {
                     $rq = Request::create("/admin/destination/{$destination}/photo", "POST", [], [], [], [], array('photo_url' => $photo['url'], 'photo_like' => rand(0, 100)));
                     array_push($images_uploaded, Route::dispatch($rq)->getContent());
                 }
             }
         }
         return response()->json(array('addedObject' => Destination::find($destination), 'addedPhotos' => $images_uploaded));
     } catch (\Exception $e) {
         return response()->json($e);
     }
 }
예제 #10
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     Route::filter('admin', function () {
         if (Auth::guest()) {
             if (Request::ajax()) {
                 return Response::make('Unauthorized', 401);
             } else {
                 return redirect('/login');
             }
         }
         if (Auth::user()->level !== 10) {
             return redirect('/');
         }
     });
     Route::filter('muhtar', function () {
         if (Auth::guest()) {
             if (Request::ajax()) {
                 return Response::make('Unauthorized', 401);
             } else {
                 return redirect('/login');
             }
         }
         if (Auth::user()->level !== 5) {
             return redirect('/');
         }
     });
 }
예제 #11
0
 public function compose(View $view)
 {
     $documentForm = \Request::only('responsable_id');
     $route = Route::currentRouteName();
     $users = User::orderBy('name', 'ASC')->lists('name', 'id')->toArray();
     $view->with(compact('documentForm', 'users', 'route'));
 }
예제 #12
0
 public function boot()
 {
     $this->package('mrosati84/laradmin');
     $prefix = Config::get('laradmin::prefix');
     $namespace = Config::get('laradmin::namespace');
     $entities = Config::get('laradmin::entities');
     foreach ($entities as $entity => $properties) {
         $fullClassName = $namespace . '\\' . $entity . 'Admin';
         $baseAdminController = 'Mrosati84\\Laradmin\\BaseAdminController';
         // register admin classes bindings
         App::bind($fullClassName, function () use($fullClassName, $entity) {
             return new $fullClassName($entity);
         });
         // register custom filters classes
         App::bind('AuthenticationFilter', 'Mrosati84\\Laradmin\\Filters\\AuthenticationFilter');
         // register custom route filters
         Route::filter('laradmin.auth', 'AuthenticationFilter');
         // register laradmin index route (just a redirect to default entity)
         Route::get($prefix, array('as' => 'laradmin.index', function () use($prefix) {
             return Redirect::route($prefix . '.' . strtolower(Config::get('laradmin::defaultEntity')) . '.index');
         }));
         // register entities routes
         Route::group(array('prefix' => $prefix, 'before' => 'laradmin.auth'), function () use($entity, $fullClassName) {
             Route::resource(strtolower($entity), $fullClassName);
         });
     }
 }
예제 #13
0
 function __construct()
 {
     // share current route in all views
     View::share('current_url', Route::current()->getPath());
     // share current logged in user details all views
     View::share('current_user', $this->current_user());
 }
예제 #14
0
 /**
  * Handle an incoming request.
  * This Middleware checks for a 'tailnumber' parameter and converts it to all uppercase if it exists.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure $next
  * @param  String   $permission
  * @param  String   $enforce_same_crew
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Route::current()->hasParameter('tailnumber')) {
         Route::current()->setParameter('tailnumber', strtoupper(Route::current()->getParameter('tailnumber')));
     }
     return $next($request);
 }
 public function __construct()
 {
     //$this->beforeFilter(function(){  });
     $this->uriSegment = null;
     $this->modelName = null;
     $this->viewsPath = null;
     $this->resourceId = null;
     if (Route::input('alias') !== null) {
         $this->uriSegment = Route::input('alias');
         $this->viewsPath = File::exists(app_path('views/' . Config::get('reactiveadmin::uri') . '/' . $this->uriSegment)) ? Config::get('reactiveadmin::uri') . '.' . $this->uriSegment : 'reactiveadmin::default';
         $this->modelName = studly_case(str_singular(Route::input('alias')));
         $this->modelWrapper = App::make('model_wrapper');
         $this->modelWrapper->model($this->modelName);
         if (Route::input('id') !== null) {
             $this->resourceId = Route::input('id');
         }
         View::share('config', $this->modelWrapper->getConfig());
         // TODO: refactor this!
         // custom behavior
         switch ($this->uriSegment) {
             case 'settings':
                 View::composer(array('admin.' . $this->viewsPath . '.index'), function ($view) {
                     $view->with('settings', Settings::all());
                 });
                 break;
             default:
                 # code...
                 break;
         }
     }
     View::share('view', $this->uriSegment);
     View::share('model', $this->modelName);
 }
예제 #16
0
 protected function mapAuthRoutes()
 {
     Route::group(['middleware' => 'web', 'namespace' => $this->namespace], function ($router) {
         Route::auth();
         Route::get('/logout', 'Auth\\LoginController@logout');
     });
 }
 /**
  * Add the extra logic needed to finalize the config array before using it.
  *
  * @param $config
  *
  * @return mixed
  */
 public function decorate($config)
 {
     if (Route::is('role.user.index')) {
         unset($config['user.roles']);
     }
     return array_values($config);
 }
예제 #18
0
 public static function validateRoute()
 {
     $route = Route::current();
     $route_name = $route->getName();
     if (!$route_name) {
         $route_name = $route->getActionName();
     }
     $params = $route->parametersWithoutNulls();
     $ids = [];
     if ($params) {
         $param = current($params);
         if (is_numeric($param)) {
             $ids[] = $param;
         }
     }
     $result = AclFacade::check($route_name, $ids);
     if (!$result) {
         $error_message = "No Permission for {$route_name}";
         if ($ids) {
             $error_message .= " for id: {$ids[0]}";
         }
         throw new NoPermissionsException($error_message);
     }
     return $result;
 }
예제 #19
0
 public static function _routes_show()
 {
     $_class = get_called_class();
     $_uri = static::$uri;
     $_as = static::$action;
     Route::get("{$_uri}/show/{id}", ['as' => "{$_as}.show.detail", 'uses' => "{$_class}@show"]);
 }
예제 #20
0
 public function test(Request $request)
 {
     //            $user = User::find(1);
     //
     //            if($user->hasRole('Founder')){
     //                return '您是创始人'.'ID:'.$user->id;
     //            };
     if ($request->user()) {
         //                $userRoles = $request->user()->roles()->get();
         //                foreach($userRoles as $r){
         //                    $roles[] = $r->name;
         //                }
         //                var_dump($roles);
         $userRoles = Role::all();
         foreach ($userRoles as $r) {
             $roles[] = $r->name;
         }
         if (!$request->user()->hasRole($roles)) {
             return redirect()->guest('auth/login');
         }
         //$can = Route::currentRouteName();//当前route-name  exp:user.test
         $can = Route::currentRouteAction();
         echo $can;
         $res = $request->user()->can($can);
         echo $res;
     }
 }
예제 #21
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     Route::bind('slug', function ($value) {
         return Project::where('slug', '=', $value)->firstOrFail();
     });
     parent::boot($router);
 }
예제 #22
0
 /**
  * Returns the initial HTML view for the admin interface.
  *
  * @param \Illuminate\Http\Request $request Laravel request object
  * @return \Illuminate\Contracts\View\View View for rendering the output
  */
 public function indexAction(Request $request)
 {
     if (config('shop.authorize', true)) {
         $this->authorize('admin');
     }
     $site = Route::input('site', 'default');
     $lang = Input::get('lang', config('app.locale', 'en'));
     $aimeos = app('\\Aimeos\\Shop\\Base\\Aimeos')->get();
     $cntlPaths = $aimeos->getCustomPaths('controller/extjs');
     $context = app('\\Aimeos\\Shop\\Base\\Context')->get(false);
     $context = $this->setLocale($context, $site, $lang);
     $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths);
     $cssFiles = array();
     foreach ($aimeos->getCustomPaths('admin/extjs') as $base => $paths) {
         foreach ($paths as $path) {
             $jsbAbsPath = $base . '/' . $path;
             if (!is_file($jsbAbsPath)) {
                 throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath));
             }
             $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path));
             $cssFiles = array_merge($cssFiles, $jsb2->getUrls('css'));
         }
     }
     $jqadmUrl = route('aimeos_shop_jqadm_search', array('site' => $site, 'resource' => 'product'));
     $jsonUrl = route('aimeos_shop_extadm_json', array('site' => $site, '_token' => csrf_token()));
     $adminUrl = route('aimeos_shop_extadm', array('site' => '<site>', 'lang' => '<lang>', 'tab' => '<tab>'));
     $vars = array('lang' => $lang, 'cssFiles' => $cssFiles, 'languages' => $this->getJsonLanguages($context), 'config' => $this->getJsonClientConfig($context), 'site' => $this->getJsonSiteItem($context, $site), 'i18nContent' => $this->getJsonClientI18n($aimeos->getI18nPaths(), $lang), 'searchSchemas' => $controller->getJsonSearchSchemas(), 'itemSchemas' => $controller->getJsonItemSchemas(), 'smd' => $controller->getJsonSmd($jsonUrl), 'urlTemplate' => str_replace(['<', '>'], ['{', '}'], urldecode($adminUrl)), 'uploaddir' => config('shop::uploaddir'), 'activeTab' => Input::get('tab', 0), 'version' => $this->getVersion(), 'jqadmurl' => $jqadmUrl);
     return View::make('shop::admin.extadm-index', $vars);
 }
예제 #23
0
 /**
  * Create a Destroy Link
  *
  * @return string
  */
 public function getDestroyLink()
 {
     $route = $this->getPrefix() . $this->getResourceName() . '.forcedestroy';
     if (Route::has($route)) {
         return Form::open(['route' => [$route, $this->id], 'method' => 'post', 'style' => 'display: inline;']) . Form::submit('Delete', ['class' => 'btn btn-xs btn-danger']) . Form::close();
     }
 }
예제 #24
0
 /**
  * Define the "api" routes for the application.
  *
  * These routes are typically stateless.
  *
  * @return void
  */
 protected function mapApiRoutes()
 {
     Route::group(['middleware' => 'api', 'namespace' => $this->namespace, 'prefix' => 'api'], function () {
         /** @noinspection PhpIncludeInspection */
         require base_path('routes/api.php');
     });
 }
예제 #25
0
 public function setUp()
 {
     parent::setUp();
     Route::get('login-success', function () {
         return 'Login success';
     });
 }
 /**
  * Validates the user, password combination against the request.
  *
  * @param \Illuminate\Http\Request $request
  * @param string                   $user
  * @param string                   $password
  *
  * @return bool
  */
 protected function validate($request, $user, $password)
 {
     // Get current route name
     // Note: we do not have access to the current route in middleware, because
     // it has not been fully dispatched, therefore we must use the backwards
     // method of finding the route which matches the current request.
     $routeName = null;
     foreach (Route::getRoutes() as $route) {
         if ($route->matches($request)) {
             $routeName = $route->getName();
         }
     }
     // If we have a named route
     if ($routeName) {
         // Check if route username and password are set
         if ($routeUsername = env('ROUTE_RESTRICTOR_ROUTE_' . strtoupper($routeName) . '_USERNAME') && ($routePassword = env('ROUTE_RESTRICTOR_ROUTE_' . strtoupper($routeName) . '_PASSWORD'))) {
             // Check against route password
             if (trim($user) == $routeUsername && trim($password) == $routePassword) {
                 return true;
             } else {
                 return false;
             }
         }
     }
     // Check if global username and password are set
     if ($globalUsername = env('ROUTE_RESTRICTOR_GLOBAL_USERNAME') && ($globalPassword = env('ROUTE_RESTRICTOR_GLOBAL_PASSWORD'))) {
         // Check against global password
         if (trim($user) == $globalUsername && trim($password) == $globalPassword) {
             return true;
         } else {
             return false;
         }
     }
     return true;
 }
예제 #27
0
 public static function _routes_index()
 {
     $_class = get_called_class();
     $_uri = static::$uri;
     $_as = static::$action;
     Route::get("{$_uri}/index", ['as' => "{$_as}.show.index", 'uses' => "{$_class}@index"]);
 }
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->package('mmanos/laravel-casset');
     if ($route = Config::get('laravel-casset::route')) {
         Route::get(trim($route, '/') . '/{type}', 'Mmanos\\Casset\\CassetController@getIndex');
     }
 }
예제 #29
0
 static function areActiveRoutes(array $routes, $output = "active")
 {
     foreach ($routes as $route) {
         if (Route::currentRouteName() == $route) {
             return $output;
         }
     }
 }
예제 #30
0
 /**
  * Returns the initial HTML view for the admin interface.
  *
  * @param \Illuminate\Http\Request $request Laravel request object
  * @return \Illuminate\Contracts\View\View View for rendering the output
  */
 public function indexAction(Request $request)
 {
     if (config('shop.authorize', true) && (Auth::check() === false || $request->user()->can('admin', ['admin', 'editor'])) === false) {
         return View::make('shop::admin.index');
     }
     $param = array('resource' => 'dashboard', 'site' => Route::input('site', Input::get('site', 'default')), 'lang' => Route::input('lang', Input::get('lang', config('app.locale', 'en'))));
     return redirect()->route('aimeos_shop_jqadm_search', $param);
 }