Skip to content

Commit

Permalink
Merge pull request #492 from FrozenNode/dev
Browse files Browse the repository at this point in the history
Merge 4.10.0 into master
  • Loading branch information
janhartigan committed Feb 17, 2014
2 parents 5d52c21 + 889bd85 commit 560d5c9
Show file tree
Hide file tree
Showing 50 changed files with 414 additions and 47 deletions.
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Changelog

### 4.10.0
- It's now possible to customize the "back to site" link at the top right of admin pages
- Closures can now be passed into the output option for columns
- New translations (se, si, uk)
- Bugfix: When navigating away from an item edit route and then hitting the back button, the browser would cache the dynamic json response. Proper headers have now been set to avoid this.
- Bugfix: When missing a rules option in a settings config file, an error would be thrown despite there being no explicit requirement for one
- Bugfix: The administrator base controller was being instantiated multiple times during unit tests in laravel 4.1

### 4.9.0
- Laravel 4.1 support
- New translations (ja, pt)
Expand Down
File renamed without changes.
14 changes: 12 additions & 2 deletions src/docs/columns.md → docs/columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,19 @@ Any SQL grouping function will work in the `select` statement. Much more is poss
<a name="custom-outputs"></a>
## Custom Outputs

If you want your column to show more than just text, you can use the `output` option. At any place in the `output` string, you can put `(:value)`. This will be replaced by the row's value for this column.
If you want your column to show more than just text, you can use the `output` option. This can either be a string or an anonymous function.

For instance, if you are using a [color](/docs/field-type-color) field and you want to clearly show the admin user what color a row is, you can do this:
If you provide an anonymous function, the only argument is the relevant column's value from the database. For instance, if you are using a [color](/docs/field-type-color) field and you want to clearly show the admin user what color a row is, you can do this:

'hex' => array(
'title' => 'Color',
'output' => function($value)
{
return '<div style="background-color: ' . $value . '; width: 200px; height: 20px; border-radius: 2px;"></div>';
},
),

Alternatively, you can also pass a string to the `output` option and Administrator will replace the string `(:value)` with the row's value for this column.

'hex' => array(
'title' => 'Color',
Expand Down
33 changes: 23 additions & 10 deletions src/docs/configuration.md → docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Below is a list of all the available options:
- [Use Dashboard](#use-dashboard)
- [Dashboard View](#dashboard-view)
- [Home Page](#home-page)
- [Back To Site Path](#back-to-site-path)
- [Login Path](#login-path)
- [Logout Path](#logout-path)
- [Redirect Key](#redirect-key)
Expand Down Expand Up @@ -129,6 +130,22 @@ If you want to have a submenu, instead of passing in a string, pass in an array
> For a detailed description of all the settings configuration options, see the **[settings configuration docs](/docs/settings-configuration)**
<a name="permission"></a>
### Permission

/**
* The permission option is the highest-level authentication check that lets you define a closure that should return true if the current user
* is allowed to view the admin section. Any "falsey" response will send the user back to the 'login_path' defined below.
*
* @type closure
*/
'permission'=> function()
{
return Auth::check();
},

The permission option lets you define a closure that determines whether or not the current user can access all of Administrator. You can also define per-model permissions in each model's config. A user will only be given access if this resolves to a truthy value. If this fails, the user will be redirected to the `login_path`.

<a name="use-dashboard"></a>
### Use Dashboard

Expand Down Expand Up @@ -172,21 +189,17 @@ If the `use_dashboard` option is set to true, Administrator will attempt to load

If the `use_dashboard` option is set to false, Administrator will redirect the user to the above page when they visit the Administrator base URL. This must match an item in the `menu` option.

<a name="permission"></a>
### Permission
<a name="back-to-site-path"></a>
### Back To Site Path

/**
* The permission option is the highest-level authentication check that lets you define a closure that should return true if the current user
* is allowed to view the admin section. Any "falsey" response will send the user back to the 'login_path' defined below.
* The route to which the user will be taken when they click the "back to site" button
*
* @type closure
* @type string
*/
'permission'=> function()
{
return Auth::check();
},
'back_to_site_path' => '/',

The permission option lets you define a closure that determines whether or not the current user can access all of Administrator. You can also define per-model permissions in each model's config. A user will only be given access if this resolves to a truthy value. If this fails, the user will be redirected to the `login_path`.
Provide any value that would work with Laravel's `URL::to()` method.

<a name="login-path"></a>
### Login Path
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/docs/localization.md → docs/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ There are no special exceptions in the model config files...so you can localize

Administrator currently supports the following languages:

> ca da de en es eu fr hu it ja nl pl pt pt-BR ru sr tr zh-CN
> ca da de en es eu fr hu it ja nl pl pt pt-BR ru se si sr tr uk zh-CN
If you don't see the language you want, [contributing a new language is crazy easy](#contributing)!

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 8 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Administrator is an administrative interface builder for [Laravel](http://larave

- **Author:** Jan Hartigan
- **Website:** [http://frozennode.com](http://frozennode.com)
- **Version:** 4.9.0
- **Version:** 4.10.0

[![Build Status](https://travis-ci.org/FrozenNode/Laravel-Administrator.png?branch=master)](https://travis-ci.org/FrozenNode/Laravel-Administrator)

Expand Down Expand Up @@ -53,7 +53,10 @@ Administrator is released under the MIT License. See the LICENSE file for detail

## Changelog

### 4.9.0
- Laravel 4.1 support
- New translations (ja, pt)
- Bugfix: There was a PSR-0 filename/classname disagreement in on of the relatively unused classes (Fields\Relationships\HasOne)
### 4.10.0
- It's now possible to customize the "back to site" link at the top right of admin pages
- Closures can now be passed into the output option for columns
- New translations (se, si, uk)
- Bugfix: When navigating away from an item edit route and then hitting the back button, the browser would cache the dynamic json response. Proper headers have now been set to avoid this.
- Bugfix: When missing a rules option in a settings config file, an error would be thrown despite there being no explicit requirement for one
- Bugfix: The administrator base controller was being instantiated multiple times during unit tests in laravel 4.1
10 changes: 6 additions & 4 deletions src/Frozennode/Administrator/AdministratorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public function boot()
$this->app['administrator.4.1'] = version_compare(\Illuminate\Foundation\Application::VERSION, '4.1') > -1;

//set up an alias for the base laravel controller to accommodate >=4.1 and <4.1
if ($this->app['administrator.4.1'])
class_alias('Illuminate\Routing\Controller', 'AdministratorBaseController');
else
class_alias('Illuminate\Routing\Controllers\Controller', 'AdministratorBaseController');
if (!class_exists('AdministratorBaseController')){ // Verify alias is not already created
if ($this->app['administrator.4.1'])
class_alias('Illuminate\Routing\Controller', 'AdministratorBaseController');
else
class_alias('Illuminate\Routing\Controllers\Controller', 'AdministratorBaseController');
}

//include our filters, view composers, and routes
include __DIR__.'/../../filters.php';
Expand Down
2 changes: 1 addition & 1 deletion src/Frozennode/Administrator/Config/Settings/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Config extends ConfigBase implements ConfigInterface {
'permission' => true,
'before_save' => null,
'actions' => array(),
'rules' => false,
'rules' => array(),
'storage_path' => null,
);

Expand Down
15 changes: 10 additions & 5 deletions src/Frozennode/Administrator/DataTable/Columns/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class Column {
'column_name' => 'required|string',
'title' => 'string',
'relationship' => 'string',
'select' => 'required_with:relationship|string',
'output' => 'string',
'select' => 'required_with:relationship|string'
);

/**
Expand Down Expand Up @@ -241,13 +240,19 @@ public function getOption($key)
/**
* Takes a column output string and renders the column with it (replacing '(:value)' with the column's field value)
*
* @param string $output
* @param string $value
*
* @return string
*/
public function renderOutput($value)
{
return str_replace('(:value)', $value, $this->getOption('output'));
$output = $this->getOption('output');

if (is_callable($output)) {
return $output($value);
}

return str_replace('(:value)', $value, $output);
}

/**
Expand All @@ -269,4 +274,4 @@ public function getDefaults()
{
return array_merge($this->baseDefaults, $this->defaults);
}
}
}
9 changes: 8 additions & 1 deletion src/config/administrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
*/
'home_page' => '',

/**
* The route to which the user will be taken when they click the "back to site" button
*
* @type string
*/
'back_to_site_path' => '/',

/**
* The login path is the path where Administrator will send the user if they fail a permission check
*
Expand All @@ -101,7 +108,7 @@
'logout_path' => false,

/**
* This is the key of the return path that is sent with the redirection to your login_action. Input::get('redirect') will hold the return URL.
* This is the key of the return path that is sent with the redirection to your login_action. Session::get('redirect') will hold the return URL.
*
* @type string
*/
Expand Down
5 changes: 4 additions & 1 deletion src/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@ public function item($modelName, $itemId = 0)
$model = $config->updateModel($model, $fieldFactory, $actionFactory);
}

return $actionPermissions['view'] ? $model->toJson() : Response::json(array(
$response = $actionPermissions['view'] ? Response::json($model) : Response::json(array(
'success' => false,
'errors' => "You do not have permission to view this item",
));

//set the Vary : Accept header to avoid the browser caching the json response
return $response->header('Vary', 'Accept');
}
else
{
Expand Down
20 changes: 10 additions & 10 deletions src/lang/pl/administrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
'dashboard' => 'Panel',
'edit' => 'Edycja',
'filters' => 'Filtry',
'loading' => 'Ładuje...',
'loading' => 'Ładuję ...',
'createnew' => 'Stwórz nowy',
'new' => 'Nowy',
'viewitem' => 'wyświetl :single',
'id' => 'ID',
'uploadimage' => 'Dodaj zdjęcie',
'imageuploading' => 'Ładuje zdjęcie',
'uploadfile' => 'Upload File',
'fileuploading' => 'File Uploading',
'imageuploading' => 'Ładuję zdjęcie',
'uploadfile' => 'Dodaj plik',
'fileuploading' => 'Ładuję plik',
'none' => 'Żaden',
'all' => 'Wszystkie',
'itemsperpage' => 'pozycji na stronie',
'noresults' => 'Brak wynikow',
'noresults' => 'Brak wyników',
'backtosite' => 'Powrót do strony',
'logout' => 'Wyloguj',

Expand All @@ -39,17 +39,17 @@
'create' => 'Stwórz',
'cancel' => 'Anuluj',

'active' => 'Chwileczkę...',
'active' => 'Chwileczkę ...',
'success' => 'Sukces!',
'error' => 'Wystąpił błąd podczas wykonywania tej czynności',

'valid_columns' => "Musisz podać poprawna tablicę 'columns' dla każdego zdefiniowanego modelu",
'valid_title' => "Musisz podać poprawny tytuł i pojedynczą nazwę dla każdego zdefiniowanego modelu",
'valid_model' => "Dla każdego zdefiniowanego modelu musisz podać jego opcje",
'valid_edit' => "Musisz podać poprawną tablicę 'edit_fields' dla każdego zdefiniowanego modelu",
'valid_menu' => "Musisz podać poprawną opcję 'Menu' w pliku konfiguracyjnym administrator.php",
'valid_menu' => "Musisz podać poprawną opcję 'menu' w pliku konfiguracyjnym administrator.php",
'valid_config_path' => "Musisz podać poprawny 'model_config_path' w pliku konfiguracyjnym administrator.php. Katalog musi istnieć i mieć prawo do odczytu.",
'not_eloquent' => " nie jest Eloquent model",
'storage_path_permissions' => "You must make your storage path writable in order to make a settings page",
'valid_home_page' => "You must provide a valid menu item in the home_page option of your config",
);
'storage_path_permissions' => "Aby utworzyć stronę typu 'settings' katalog 'storage_path' musi istnieć i mieć prawo do zapisu",
'valid_home_page' => "Musisz podać poprawny element 'menu' dla opcji 'home_page' w pliku konfiguracyjnym administrator.php",
);
12 changes: 6 additions & 6 deletions src/lang/pl/knockout.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
|
*/

'delete_active_item' => 'Czy na pewno chcesz usunąć ten obiekt? Czynności tej nie można odwrócić.',
'saving' => 'Trwa zapisywanie...',
'delete_active_item' => 'Czy na pewno chcesz usunąć ten obiekt? Czynności tej nie można cofnąć.',
'saving' => 'Trwa zapisywanie ...',
'saved' => 'Obiekt zapisany.',
'deleting' => 'Usuwanie...',
'deleting' => 'Usuwanie ...',
'deleted' => 'Obiekt usunięty.',
'character_left' => ' znak pozostał',
'characters_left' => ' znaki pozostały',
'no_results' => 'No results matched',
'select_options' => 'Select Some Options',
'no_results' => 'Brak pasujących wyników',
'select_options' => 'Wybierz jakieś opcje',

);
);
55 changes: 55 additions & 0 deletions src/lang/se/administrator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

return array(

/*
|--------------------------------------------------------------------------
| Administrator Language Lines
|--------------------------------------------------------------------------
|
| se - Swedish
|
*/

'dashboard' => 'Kontrollpanel',
'edit' => 'Redigera',
'filters' => 'Filter',
'loading' => 'Laddar...',
'createnew' => 'Skapa ny',
'new' => 'Ny',
'viewitem' => 'Visa :enskild',
'id' => 'ID',
'uploadimage' => 'Ladda upp bild',
'imageuploading' => 'Bild laddas upp',
'uploadfile' => 'Ladda upp fil',
'fileuploading' => 'Fil laddas upp',
'none' => 'Ingen',
'all' => 'Alla',
'itemsperpage' => 'objekt per sida',
'noresults' => 'Inget resultat',
'backtosite' => 'Tillbaka till sajten',
'logout' => 'Logga ut',

'previous' => 'föregående',
'next' => 'nästa',

'close' => 'Stäng',
'delete' => 'Radera',
'save' => 'Spara',
'create' => 'Skapa',
'cancel' => 'Avbryt',

'active' => 'Ett ögonblick...',
'success' => 'Klart!',
'error' => 'Ett fel uppstod i samband med denna operation',

'valid_columns' => "Du måste ange en giltig 'columns'-array i varje modells konfiguration",
'valid_title' => "Du måste ange en giltig 'title' och 'single name' i varje modells konfiguration",
'valid_model' => "Du måste ange en 'model'-option i varje modells konfiguration",
'valid_edit' => "Du måste ange en giltig 'edit_fields'-array i varje modells konfiguration",
'valid_menu' => "Du måste ange en giltig 'menu'-option i administrator.php:s konfiguration",
'valid_config_path' => "Du måste ange en giltig 'model_config_path' i administrator.php:s konfiguration. Katalogen måste även existera samt vara skrivbar.",
'not_eloquent' => " är inte en Eloquent-modell",
'storage_path_permissions' => "Du måste göra din 'storage path' skrivbar för att skapa en inställningssida (settings page)",
'valid_home_page' => "Du måste ange en giltig 'menu item' i 'home_page'-inställningen i din konfiguration",
);
24 changes: 24 additions & 0 deletions src/lang/se/knockout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

return array(

/*
|--------------------------------------------------------------------------
| Administrator Language Lines for knockout
|--------------------------------------------------------------------------
|
| se - Swedish
|
*/

'delete_active_item' => 'Är du säker du vill radera detta? Raderingen är permanent.',
'saving' => 'Sparar...',
'saved' => 'Objektet sparat.',
'deleting' => 'Raderar...',
'deleted' => 'Objektet raderat.',
'character_left' => ' tecken kvar',
'characters_left' => ' tecken kvar',
'no_results' => 'Inga resultat matchade',
'select_options' => 'Gör några val',

);
Loading

0 comments on commit 560d5c9

Please sign in to comment.