Commit 2b2805fc authored by Tino Goratsch's avatar Tino Goratsch

Added the new data grid column renderer `RouteColumnRenderer` which makes it...

Added the new data grid column renderer `RouteColumnRenderer` which makes it possible specify and open routes in new tabs
parent a8126238
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Core\Helpers\DataGrid\ColumnRenderer;
use ACP3\Core\I18n\Translator;
use ACP3\Core\Router\RouterInterface;
class RouteColumnRenderer extends AbstractColumnRenderer
{
/**
* @var RouterInterface
*/
private $router;
/**
* @var Translator
*/
private $translator;
/**
* RouteColumnRenderer constructor.
* @param RouterInterface $router
* @param Translator $translator
*/
public function __construct(RouterInterface $router, Translator $translator)
{
$this->router = $router;
$this->translator = $translator;
}
/**
* @inheritdoc
*/
protected function getValue(array $column, array $dbResultRow)
{
$value = parent::getValue($column, $dbResultRow);
if (!empty($column['custom']['path'])) {
$route = $this->router->route(sprintf($column['custom']['path'], $value));
$value = '<a href="' . $route . '" target="_blank" title="' . $this->translator->t('system', 'open_in_new_window') . '">' . $value . '</a>';
}
return $value;
}
}
......@@ -73,6 +73,15 @@ services:
- { name: core.helpers.data_grid.column_renderer }
public: false
core.helpers.data_grid.column_renderer.route_column_renderer:
class: ACP3\Core\Helpers\DataGrid\ColumnRenderer\RouteColumnRenderer
arguments:
- '@core.router'
- '@core.i18n.translator'
tags:
- { name: core.helpers.data_grid.column_renderer }
public: false
core.helpers.data_grid.column_renderer.sort_column_renderer:
class: ACP3\Core\Helpers\DataGrid\ColumnRenderer\SortColumnRenderer
arguments:
......
......@@ -8,6 +8,7 @@ namespace ACP3\Modules\ACP3\Articles\Controller\Admin\Index;
use ACP3\Core;
use ACP3\Modules\ACP3\Articles;
use ACP3\Modules\ACP3\Articles\Helpers;
use ACP3\Modules\ACP3\System\Installer\Schema;
/**
......@@ -86,9 +87,12 @@ class Index extends Core\Controller\AbstractFrontendAction
], 20)
->addColumn([
'label' => $this->translator->t('system', 'id'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\IntegerColumnRenderer::class,
'type' => Core\Helpers\DataGrid\ColumnRenderer\RouteColumnRenderer::class,
'fields' => ['id'],
'primary' => true
'primary' => true,
'custom' => [
'path' => Helpers::URL_KEY_PATTERN
]
], 10);
}
}
......@@ -8,6 +8,7 @@ namespace ACP3\Modules\ACP3\Files\Controller\Admin\Index;
use ACP3\Core;
use ACP3\Modules\ACP3\Files;
use ACP3\Modules\ACP3\Files\Helpers;
use ACP3\Modules\ACP3\System\Installer\Schema;
/**
......@@ -102,9 +103,12 @@ class Index extends Core\Controller\AbstractFrontendAction
], 20)
->addColumn([
'label' => $this->translator->t('system', 'id'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\IntegerColumnRenderer::class,
'type' => Core\Helpers\DataGrid\ColumnRenderer\RouteColumnRenderer::class,
'fields' => ['id'],
'primary' => true
'primary' => true,
'custom' => [
'path' => Helpers::URL_KEY_PATTERN
],
], 10);
if ($this->acl->hasPermission('admin/files/index/sort') && $settings['order_by'] === 'custom') {
......
......@@ -8,6 +8,7 @@ namespace ACP3\Modules\ACP3\Gallery\Controller\Admin\Index;
use ACP3\Core;
use ACP3\Modules\ACP3\Gallery;
use ACP3\Modules\ACP3\Gallery\Helpers;
use ACP3\Modules\ACP3\System\Installer\Schema;
/**
......@@ -82,9 +83,12 @@ class Index extends Core\Controller\AbstractFrontendAction
], 20)
->addColumn([
'label' => $this->translator->t('system', 'id'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\IntegerColumnRenderer::class,
'type' => Core\Helpers\DataGrid\ColumnRenderer\RouteColumnRenderer::class,
'fields' => ['id'],
'primary' => true
'primary' => true,
'custom' => [
'path' => Helpers::URL_KEY_PATTERN_GALLERY
],
], 10);
}
}
......@@ -8,6 +8,7 @@ namespace ACP3\Modules\ACP3\Gallery\Controller\Admin\Pictures;
use ACP3\Core;
use ACP3\Modules\ACP3\Gallery;
use ACP3\Modules\ACP3\Gallery\Helpers;
use ACP3\Modules\ACP3\System\Installer\Schema;
use ACP3\Core\Controller\AbstractFrontendAction;
......@@ -98,9 +99,12 @@ class Index extends AbstractFrontendAction
], 30)
->addColumn([
'label' => $this->translator->t('system', 'id'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\IntegerColumnRenderer::class,
'type' => Core\Helpers\DataGrid\ColumnRenderer\RouteColumnRenderer::class,
'fields' => ['id'],
'primary' => true
'primary' => true,
'custom' => [
'path' => Helpers::URL_KEY_PATTERN_PICTURE
]
], 10);
if ($this->acl->hasPermission('admin/gallery/pictures/order')) {
......
......@@ -8,6 +8,7 @@ namespace ACP3\Modules\ACP3\News\Controller\Admin\Index;
use ACP3\Core;
use ACP3\Modules\ACP3\News;
use ACP3\Modules\ACP3\News\Helpers;
use ACP3\Modules\ACP3\System\Installer\Schema;
/**
......@@ -92,9 +93,12 @@ class Index extends Core\Controller\AbstractFrontendAction
], 20)
->addColumn([
'label' => $this->translator->t('system', 'id'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\IntegerColumnRenderer::class,
'type' => Core\Helpers\DataGrid\ColumnRenderer\RouteColumnRenderer::class,
'fields' => ['id'],
'primary' => true
'primary' => true,
'custom' => [
'path' => Helpers::URL_KEY_PATTERN
],
], 10);
}
}
......@@ -73,9 +73,12 @@ class Index extends Core\Controller\AbstractFrontendAction
$dataGrid
->addColumn([
'label' => $this->translator->t('seo', 'uri'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\TextColumnRenderer::class,
'type' => Core\Helpers\DataGrid\ColumnRenderer\RouteColumnRenderer::class,
'fields' => ['uri'],
'default_sort' => true
'default_sort' => true,
'custom' => [
'path' => '%s'
],
], 60)
->addColumn([
'label' => $this->translator->t('seo', 'alias'),
......
......@@ -231,6 +231,7 @@
<item key="no_entries_short">Keine Einträge vorhanden.</item>
<item key="no_modules_available_for_installation">Es sind bereits alle lokal verfügbaren Module installiert!</item>
<item key="not_installable_module_description">Dieses Modul benötigt keine Installation.</item>
<item key="open_in_new_window">In neuem Fenster öffnen</item>
<item key="order">Reihenfolge</item>
<item key="order_error">Beim Bearbeiten der Reihenfolge ist ein Fehler aufgetreten.</item>
<item key="order_success">Die Reihenfolge wurde erfolgreich bearbeitet.</item>
......
......@@ -231,6 +231,7 @@
<item key="no_entries_short">No entries available.</item>
<item key="no_modules_available_for_installation">Currently there are no new modules available for installation!</item>
<item key="not_installable_module_description">This module does not need any installation.</item>
<item key="open_in_new_window">Open in new window</item>
<item key="order">Order</item>
<item key="order_error">While editing the order an error has occurred.</item>
<item key="order_success">The order has been successfully edited.</item>
......
......@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] - 2017-xx-yy
### Added
- Added the new data grid column renderer `RouteColumnRenderer` which makes it possible specify and open routes in new tabs
## [4.16.0] - 2017-10-24
### Added
- Added a new option which completely disables the site subtitle program logic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment