Merge branch 'develop'

This commit is contained in:
Sam Georges 2014-10-24 19:03:03 +11:00
commit 04059c20fc
5 changed files with 96 additions and 46 deletions

View File

@ -26,7 +26,7 @@ return array(
/*
|--------------------------------------------------------------------------
| Sepcific plugins to disable
| Specific plugins to disable
|--------------------------------------------------------------------------
|
| Specify plugin codes which will always be disabled in the application.

View File

@ -117,42 +117,38 @@ class ListController extends ControllerBehavior
$columnConfig = $this->makeConfig($listConfig->list);
$columnConfig->model = $model;
$columnConfig->alias = $definition;
if (isset($listConfig->recordUrl)) {
$columnConfig->recordUrl = $listConfig->recordUrl;
}
if (isset($listConfig->recordOnClick)) {
$columnConfig->recordOnClick = $listConfig->recordOnClick;
}
if (isset($listConfig->recordsPerPage)) {
$columnConfig->recordsPerPage = $listConfig->recordsPerPage;
}
if (isset($listConfig->noRecordsMessage)) {
$columnConfig->noRecordsMessage = $listConfig->noRecordsMessage;
}
if (isset($listConfig->defaultSort)) {
$columnConfig->defaultSort = $listConfig->defaultSort;
}
if (isset($listConfig->showSorting)) {
$columnConfig->showSorting = $listConfig->showSorting;
}
if (isset($listConfig->showSetup)) {
$columnConfig->showSetup = $listConfig->showSetup;
}
if (isset($listConfig->showCheckboxes)) {
$columnConfig->showCheckboxes = $listConfig->showCheckboxes;
}
if (isset($listConfig->showTree)) {
$columnConfig->showTree = $listConfig->showTree;
}
if (isset($listConfig->treeExpanded)) {
$columnConfig->treeExpanded = $listConfig->treeExpanded;
}
$widget = $this->makeWidget('Backend\Widgets\Lists', $columnConfig);
$widget->bindToController();
/*
* Extensibility helpers
* Prepare the columns configuration
*/
$configFieldsToTransfer = [
'recordUrl',
'recordOnClick',
'recordsPerPage',
'noRecordsMessage',
'defaultSort',
'showSorting',
'showSetup',
'showCheckboxes',
'showTree',
'treeExpanded',
];
foreach ($configFieldsToTransfer as $field) {
if (isset($listConfig->{$field})) {
$columnConfig->{$field} = $listConfig->{$field};
}
}
/*
* List Widget with extensibility
*/
$widget = $this->makeWidget('Backend\Widgets\Lists', $columnConfig);
$widget->bindEvent('list.extendColumns', function () use ($widget) {
$this->controller->listExtendColumns($widget);
});
$widget->bindEvent('list.extendQueryBefore', function ($query) use ($definition) {
$this->controller->listExtendQueryBefore($query, $definition);
});
@ -173,6 +169,8 @@ class ListController extends ControllerBehavior
return $this->controller->listOverrideHeaderValue($column->columnName, $definition);
});
$widget->bindToController();
/*
* Prepare the toolbar widget (optional)
*/
@ -306,6 +304,24 @@ class ListController extends ControllerBehavior
// Overrides
//
/**
* Called before the list columns are defined.
* @param Backend\Widgets\List $host The hosting list widget
* @return void
*/
// public function listExtendColumnsBefore($host)
// {
// }
/**
* Called after the list columns are defined.
* @param Backend\Widgets\List $host The hosting list widget
* @return void
*/
public function listExtendColumns($host)
{
}
/**
* Controller override: Extend supplied model
* @param Model $model
@ -366,7 +382,7 @@ class ListController extends ControllerBehavior
}
/**
* Static helper for extending form fields.
* Static helper for extending list columns.
* @param callable $callback
* @return void
*/

View File

@ -3,7 +3,6 @@
use BackendMenu;
use Backend\Classes\Controller;
use Backend\Widgets\ReportContainer;
use Backend\Traits\InspectableContainer;
/**
* Dashboard controller
@ -14,7 +13,7 @@ use Backend\Traits\InspectableContainer;
*/
class Index extends Controller
{
use InspectableContainer;
use \Backend\Traits\InspectableContainer;
public $requiredPermissions = ['backend.access_dashboard'];

View File

@ -12,6 +12,7 @@ use October\Rain\Database\Model;
class DebugExtension extends Twig_Extension
{
const PAGE_CAPTION = 'Page variables';
const ARRAY_CAPTION = 'Array variables';
const OBJECT_CAPTION = 'Object variables';
const COMPONENT_CAPTION = 'Component variables';
@ -100,11 +101,18 @@ class DebugExtension extends Twig_Extension
$this->variablePrefix = false;
for ($i = 2; $i < $count; $i++) {
$var = func_get_arg($i);
$caption = $var instanceof ComponentBase
? static::COMPONENT_CAPTION
: static::OBJECT_CAPTION;
$subcaption = null;
$result .= $this->dump($var, $caption);
if ($var instanceof ComponentBase) {
$caption = static::COMPONENT_CAPTION;
} elseif (is_array($var)) {
$caption = static::ARRAY_CAPTION;
} else {
$caption = static::OBJECT_CAPTION;
$subcaption = get_class($var);
}
$result .= $this->dump($var, $caption, $subcaption);
}
}
@ -126,9 +134,10 @@ class DebugExtension extends Twig_Extension
*
* @param mixed $variable Variable to dump
* @param string $caption Caption of the dump
* @param string $subcaption Subcaption of the dump
* @return void
*/
public function dump($variables = null, $caption = null)
public function dump($variables = null, $caption = null, $subcaption = null)
{
$this->commentMap = [];
$this->zebra = 1;
@ -148,7 +157,7 @@ class DebugExtension extends Twig_Extension
$output[] = '<table>';
if ($caption) {
$output[] = $this->makeTableHeader($caption);
$output[] = $this->makeTableHeader($caption, $subcaption);
}
foreach ($variables as $key => $item) {
@ -164,13 +173,21 @@ class DebugExtension extends Twig_Extension
/**
* Builds the HTML used for the table header.
* @param string $caption
* @param string $subcaption
* @return string
*/
protected function makeTableHeader($caption)
protected function makeTableHeader($caption, $subcaption = null)
{
$output = [];
$output[] = '<tr>';
$output[] = '<th colspan="100" style="'.$this->getHeaderCss().'">'.$caption.'</td>';
$output[] = '<th colspan="3" colspan="100" style="'.$this->getHeaderCss().'">';
$output[] = $caption;
if ($subcaption) {
$output[] = '<div style="'.$this->getSubheaderCss().'">'.$subcaption.'</div>';
}
$output[] = '</td>';
$output[] = '</tr>';
return implode(PHP_EOL, $output);
}
@ -499,6 +516,24 @@ class DebugExtension extends Twig_Extension
]);
}
/**
* Get the CSS string for the output subheader
*
* @return string
*/
protected function getSubheaderCss()
{
return $this->arrayToCss([
'font-size' => '12px',
'font-weight' => 'normal',
'font-style' => 'italic',
'margin' => '0',
'padding' => '0',
'background-color' => '#7B8892',
'color' => '#FFF',
]);
}
/**
* Convert a key/value pair array into a CSS string
*

View File

@ -179,7 +179,7 @@ class ServiceProvider extends ModuleServiceProvider
$manager->registerMenuItems('October.System', [
'system' => [
'label' => 'system::lang.settings.menu_label',
'icon' => 'icon-tune',
'icon' => 'icon-cog',
'url' => Backend::url('system/settings'),
'permissions' => ['backend.manage_users', 'system.*'],
'order' => 1000