예제 #1
0
파일: Menu.php 프로젝트: SerdarSanri/admin
 /**
  * Gets the menu items indexed by their name with a value of the title
  *
  * @param array		$configMenu (used for recursion)
  *
  * @return array
  */
 public static function getMenu($configMenu = null)
 {
     $menu = array();
     if (!$configMenu) {
         $configMenu = Config::get('administrator::administrator.menu', null);
     }
     //iterate over the menu to build the return array of valid menu items
     foreach ($configMenu as $key => $item) {
         //if the item is a string, find its config
         if (is_string($item)) {
             $isSettings = strpos($item, 'settings.') !== false;
             $config = $isSettings ? SettingsConfig::find($item) : ModelConfig::find($item);
             if ($config) {
                 $permission = array_get($config, 'permission');
                 if (is_callable($permission) && !$permission()) {
                     continue;
                 }
                 $menu[$item] = array_get($config, 'title', $item);
             }
         } else {
             if (is_array($item)) {
                 $menu[$key] = static::getMenu($item);
             }
         }
     }
     return $menu;
 }
예제 #2
0
        }
    }
    //get the admin check closure that should be supplied in the config
    $permission = Config::get('administrator::administrator.permission');
    if (!$permission()) {
        $loginUrl = URL::to(Config::get('administrator::administrator.login_path', 'user/login'));
        $redirectKey = Config::get('administrator::administrator.login_redirect_key', 'redirect');
        $redirectUri = URL::to_route('admin_dashboard');
        return Redirect::to($loginUrl)->with($redirectKey, $redirectUri);
    }
});
//validate_model filter
Route::filter('validate_model', function () {
    $modelName = Request::route()->parameters[0];
    $config = ModelConfig::get($modelName);
    //if the model doesn't exist at all, redirect to 404
    if (!$config) {
        return Response::error('404');
    }
    Request::route()->parameters[0] = $config;
});
//validate_settings filter
Route::filter('validate_settings', function () {
    $settingsName = Request::route()->parameters[0];
    $config = SettingsConfig::get(SettingsConfig::$prefix . $settingsName);
    //if the model doesn't exist at all, redirect to 404
    if (!$config) {
        return Response::error('404');
    }
    Request::route()->parameters[0] = $config;
});
예제 #3
0
파일: admin.php 프로젝트: SerdarSanri/admin
 /**
  * POST save settings method that accepts data via JSON POST and either saves an old item (if id is valid) or creates a new one
  *
  * @param SettingsConfig	$config
  *
  * @return JSON
  */
 public function action_settings_save($config)
 {
     return $config->save();
 }