Commit 7129049d authored by tinogo's avatar tinogo

- made the module name accessible via a class constant (first rough version -...

- made the module name accessible via a class constant (first rough version - need to think of a better solution for this)
- minor code quality improvements for the categories module
parent f16fee11
......@@ -7,6 +7,8 @@ namespace ACP3\Core\Modules\Installer;
*/
interface SchemaInterface
{
const MODULE_NAME = '';
/**
* Liefert ein Array mit den zu erstellenden Datenbanktabellen des Moduls zurück
*
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'acp';
/**
* @return array
*/
......@@ -55,7 +57,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'acp';
return static::MODULE_NAME;
}
/**
......
......@@ -10,12 +10,14 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'articles';
/**
* @return string
*/
public function getModuleName()
{
return 'articles';
return static::MODULE_NAME;
}
/**
......
......@@ -9,6 +9,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'captcha';
/**
* @return array
*/
......@@ -46,7 +48,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'captcha';
return static::MODULE_NAME;
}
/**
......
......@@ -9,6 +9,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'categories';
/**
* @return array
*/
......@@ -61,7 +63,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'categories';
return static::MODULE_NAME;
}
/**
......
......@@ -67,7 +67,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'comments';
return static::MODULE_NAME;
}
/**
......
......@@ -10,13 +10,14 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'contact';
/**
* @return string
*/
public function getModuleName()
{
return 'contact';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'emoticons';
/**
* @return array
*/
......@@ -59,7 +61,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'emoticons';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'errors';
/**
* @return array
*/
......@@ -47,7 +49,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'errors';
return static::MODULE_NAME;
}
/**
......
......@@ -46,10 +46,9 @@ class Index extends Core\Controller\AbstractFrontendAction
if ($this->acl->hasPermission('frontend/' . $feed) === true) {
$this->setCacheResponseCacheable($this->config->getSettings('system')['cache_lifetime']);
$module = $this->request->getParameters()->get('feed', '');
$this->feedGenerator
->setTitle($this->config->getSettings('seo')['title'])
->setDescription($this->translator->t($module, $module));
->setDescription($this->translator->t($feed, $feed));
$this->eventDispatcher->dispatch(
'feeds.events.displayFeed.' . strtolower($feed),
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'feeds';
/**
* @return array
*/
......@@ -56,7 +58,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'feeds';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'filemanager';
/**
* @return array
*/
......@@ -23,7 +25,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'filemanager';
return static::MODULE_NAME;
}
/**
......
......@@ -31,19 +31,26 @@ abstract class AbstractFormAction extends AbstractAdminAction
* @var \ACP3\Modules\ACP3\Seo\Helper\UriAliasManager
*/
protected $uriAliasManager;
/**
* @var \ACP3\Core\Helpers\Forms
*/
protected $formsHelper;
/**
* AbstractFormAction constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Categories\Helpers $categoriesHelpers
* @param \ACP3\Core\Helpers\Forms $formsHelper
* @param \ACP3\Modules\ACP3\Categories\Helpers $categoriesHelpers
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
Core\Helpers\Forms $formsHelper,
Categories\Helpers $categoriesHelpers
) {
parent::__construct($context);
$this->formsHelper = $formsHelper;
$this->categoriesHelpers = $categoriesHelpers;
}
......@@ -70,8 +77,9 @@ abstract class AbstractFormAction extends AbstractAdminAction
*/
protected function fetchCategoryId(array $formData)
{
return !empty($formData['cat_create']) ? $this->categoriesHelpers->categoriesCreate($formData['cat_create'],
'files') : $formData['cat'];
return !empty($formData['cat_create'])
? $this->categoriesHelpers->categoriesCreate($formData['cat_create'], Files\Installer\Schema::MODULE_NAME)
: $formData['cat'];
}
/**
......@@ -115,4 +123,16 @@ abstract class AbstractFormAction extends AbstractAdminAction
);
}
}
protected function getOptions(array $settings, array $file)
{
$options = [];
if ($settings['comments'] == 1 && $this->modules->isActive('comments') === true) {
$options[0]['name'] = 'comments';
$options[0]['checked'] = $this->formsHelper->selectEntry('comments', '1', $file['comments'], 'checked');
$options[0]['lang'] = $this->translator->t('system', 'allow_comments');
}
return $options;
}
}
......@@ -35,10 +35,6 @@ class Create extends AbstractFormAction
* @var \ACP3\Modules\ACP3\Comments\Helpers
*/
protected $commentsHelpers;
/**
* @var \ACP3\Core\Helpers\Forms
*/
protected $formsHelper;
/**
* Create constructor.
......@@ -60,10 +56,9 @@ class Create extends AbstractFormAction
Files\Validation\AdminFormValidation $adminFormValidation,
Categories\Helpers $categoriesHelpers)
{
parent::__construct($context, $categoriesHelpers);
parent::__construct($context, $formsHelper, $categoriesHelpers);
$this->date = $date;
$this->formsHelper = $formsHelper;
$this->formTokenHelper = $formTokenHelper;
$this->filesRepository = $filesRepository;
$this->adminFormValidation = $adminFormValidation;
......@@ -80,14 +75,6 @@ class Create extends AbstractFormAction
return $this->executePost($this->request->getPost()->all(), $settings);
}
if ($settings['comments'] == 1 && $this->modules->isActive('comments') === true) {
$options = [];
$options[0]['name'] = 'comments';
$options[0]['checked'] = $this->formsHelper->selectEntry('comments', '1', '0', 'checked');
$options[0]['lang'] = $this->translator->t('system', 'allow_comments');
$this->view->assign('options', $options);
}
$defaults = [
'title' => '',
'file_internal' => '',
......@@ -99,8 +86,9 @@ class Create extends AbstractFormAction
];
return [
'options' => $this->getOptions($settings, ['comments' => '0']),
'units' => $this->formsHelper->choicesGenerator('units', $this->getUnits(), ''),
'categories' => $this->categoriesHelpers->categoriesList('files', '', true),
'categories' => $this->categoriesHelpers->categoriesList(Files\Installer\Schema::MODULE_NAME, '', true),
'checked_external' => $this->request->getPost()->has('external') ? ' checked="checked"' : '',
'SEO_FORM_FIELDS' => $this->metaFormFieldsHelper ? $this->metaFormFieldsHelper->formFields() : [],
'form' => array_merge($defaults, $this->request->getPost()->all()),
......
......@@ -42,22 +42,18 @@ class Edit extends AbstractFormAction
* @var \ACP3\Modules\ACP3\Comments\Helpers
*/
protected $commentsHelpers;
/**
* @var \ACP3\Core\Helpers\Forms
*/
protected $formsHelper;
/**
* Edit constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Date $date
* @param \ACP3\Core\Helpers\Forms $formsHelper
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* @param \ACP3\Modules\ACP3\Files\Model\Repository\FilesRepository $filesRepository
* @param \ACP3\Modules\ACP3\Files\Cache $filesCache
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Date $date
* @param \ACP3\Core\Helpers\Forms $formsHelper
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* @param \ACP3\Modules\ACP3\Files\Model\Repository\FilesRepository $filesRepository
* @param \ACP3\Modules\ACP3\Files\Cache $filesCache
* @param \ACP3\Modules\ACP3\Files\Validation\AdminFormValidation $adminFormValidation
* @param \ACP3\Modules\ACP3\Categories\Helpers $categoriesHelpers
* @param \ACP3\Modules\ACP3\Categories\Helpers $categoriesHelpers
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
......@@ -69,10 +65,9 @@ class Edit extends AbstractFormAction
Files\Validation\AdminFormValidation $adminFormValidation,
Categories\Helpers $categoriesHelpers
) {
parent::__construct($context, $categoriesHelpers);
parent::__construct($context, $formsHelper, $categoriesHelpers);
$this->date = $date;
$this->formsHelper = $formsHelper;
$this->formTokenHelper = $formTokenHelper;
$this->filesRepository = $filesRepository;
$this->filesCache = $filesCache;
......@@ -100,18 +95,15 @@ class Edit extends AbstractFormAction
$file['filesize'] = substr($file['size'], 0, strpos($file['size'], ' '));
if ($settings['comments'] == 1 && $this->modules->isActive('comments') === true) {
$options = [];
$options[0]['name'] = 'comments';
$options[0]['checked'] = $this->formsHelper->selectEntry('comments', '1', $file['comments'], 'checked');
$options[0]['lang'] = $this->translator->t('system', 'allow_comments');
$this->view->assign('options', $options);
}
return [
'options' => $this->getOptions($settings, $file),
'units' => $this->formsHelper->choicesGenerator('units', $this->getUnits(),
trim(strrchr($file['size'], ' '))),
'categories' => $this->categoriesHelpers->categoriesList('files', $file['category_id'], true),
'categories' => $this->categoriesHelpers->categoriesList(
Files\Installer\Schema::MODULE_NAME,
$file['category_id'],
true
),
'checked_external' => $this->request->getPost()->has('external') ? ' checked="checked"' : '',
'current_file' => $file['file'],
'SEO_FORM_FIELDS' => $this->metaFormFieldsHelper
......@@ -129,7 +121,7 @@ class Edit extends AbstractFormAction
* @param array $formData
* @param array $settings
* @param array $dl
* @param int $fileId
* @param int $fileId
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
......@@ -178,8 +170,8 @@ class Edit extends AbstractFormAction
/**
* @param string|UploadedFile $file
* @param array $formData
* @param string $currentFileName
* @param array $formData
* @param string $currentFileName
*
* @return array
*/
......
......@@ -8,6 +8,7 @@ namespace ACP3\Modules\ACP3\Files\Controller\Frontend\Index;
use ACP3\Core;
use ACP3\Modules\ACP3\Categories;
use ACP3\Modules\ACP3\Files\Installer\Schema;
/**
* Class Index
......@@ -16,7 +17,7 @@ use ACP3\Modules\ACP3\Categories;
class Index extends Core\Controller\AbstractFrontendAction
{
use Core\Cache\CacheResponseTrait;
/**
* @var \ACP3\Modules\ACP3\Categories\Cache
*/
......@@ -45,7 +46,7 @@ class Index extends Core\Controller\AbstractFrontendAction
$this->setCacheResponseCacheable($this->config->getSettings('system')['cache_lifetime']);
return [
'categories' => $this->categoriesCache->getCache('files')
'categories' => $this->categoriesCache->getCache(Schema::MODULE_NAME)
];
}
}
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'files';
/**
* @return array
*/
......@@ -23,7 +25,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'files';
return static::MODULE_NAME;
}
/**
......
......@@ -12,6 +12,8 @@ use ACP3\Modules\ACP3\System;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'gallery';
/**
* @return array
*/
......@@ -25,7 +27,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'gallery';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'guestbook';
/**
* @return array
*/
......@@ -23,7 +25,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'guestbook';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'menus';
/**
* @return array
*/
......@@ -23,7 +25,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'menus';
return static::MODULE_NAME;
}
/**
......
......@@ -77,8 +77,9 @@ abstract class AbstractFormAction extends AbstractAdminAction
*/
protected function fetchCategoryIdForSave(array $formData)
{
return !empty($formData['cat_create']) ? $this->categoriesHelpers->categoriesCreate($formData['cat_create'],
'news') : $formData['cat'];
return !empty($formData['cat_create'])
? $this->categoriesHelpers->categoriesCreate($formData['cat_create'], News\Installer\Schema::MODULE_NAME)
: $formData['cat'];
}
/**
......
......@@ -85,7 +85,11 @@ class Create extends AbstractFormAction
];
return [
'categories' => $this->categoriesHelpers->categoriesList('news', '', true),
'categories' => $this->categoriesHelpers->categoriesList(
News\Installer\Schema::MODULE_NAME,
'',
true
),
'options' => $this->fetchNewsOptions($settings, 0, 0),
'target' => $this->formsHelper->linkTargetChoicesGenerator('target'),
'SEO_FORM_FIELDS' => $this->metaFormFieldsHelper ? $this->metaFormFieldsHelper->formFields() : [],
......
......@@ -91,7 +91,11 @@ class Edit extends AbstractFormAction
}
return [
'categories' => $this->categoriesHelpers->categoriesList('news', $news['category_id'], true),
'categories' => $this->categoriesHelpers->categoriesList(
News\Installer\Schema::MODULE_NAME,
$news['category_id'],
true
),
'options' => $this->fetchNewsOptions($settings, $news['readmore'], $news['comments']),
'target' => $this->formsHelper->linkTargetChoicesGenerator('target', $news['target']),
'SEO_FORM_FIELDS' => $this->metaFormFieldsHelper
......
......@@ -108,7 +108,7 @@ class Index extends AbstractAction
$news[$i]['text'] = $this->view->fetchStringAsTemplate($news[$i]['text']);
if ($this->commentsActive === true && $news[$i]['comments'] == 1) {
$news[$i]['comments_count'] = $this->get('comments.helpers')->commentsCount(
'news',
News\Installer\Schema::MODULE_NAME,
$news[$i]['id']
);
}
......@@ -136,15 +136,15 @@ class Index extends AbstractAction
{
if (!empty($categoryId)) {
$news = $this->newsRepository->getAllByCategoryId(
$categoryId,
$categoryId,
$time,
$this->pagination->getResultsStartOffset(),
$this->pagination->getResultsStartOffset(),
$this->user->getEntriesPerPage()
);
} else {
$news = $this->newsRepository->getAll(
$time,
$this->pagination->getResultsStartOffset(),
$this->pagination->getResultsStartOffset(),
$this->user->getEntriesPerPage()
);
}
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'news';
/**
* @return array
*/
......@@ -23,7 +25,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'news';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'newsletter';
/**
* @return array
*/
......@@ -29,7 +31,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'newsletter';
return static::MODULE_NAME;
}
/**
......
......@@ -11,6 +11,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'permissions';
/**
* @return array
*/
......@@ -24,7 +26,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'permissions';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'polls';
/**
* @return array
*/
......@@ -23,7 +25,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'polls';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'search';
/**
* @return array
*/
......@@ -23,7 +25,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'search';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'seo';
/**
* @return array
*/
......@@ -23,7 +25,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'seo';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'system';
/**
* @return array
*/
......@@ -38,7 +40,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'system';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'users';
/**
* @return array
*/
......@@ -23,7 +25,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'users';
return static::MODULE_NAME;
}
/**
......
......@@ -10,6 +10,8 @@ use ACP3\Core\Modules;
*/
class Schema implements Modules\Installer\SchemaInterface
{
const MODULE_NAME = 'wysiwygckeditor';
/**
* @return array
*/
......@@ -23,7 +25,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getModuleName()
{
return 'wysiwygckeditor';
return static::MODULE_NAME;
}
/**
......