Commit fe7a9f39 authored by Tino Goratsch's avatar Tino Goratsch

The feeds module settings have been moved into its own controller action to...

The feeds module settings have been moved into its own controller action to match the structure of the other modules
parent 77f66571
......@@ -15,78 +15,8 @@ use ACP3\Modules\ACP3\Feeds;
*/
class Index extends Core\Controller\AbstractAdminAction
{
/**
* @var \ACP3\Core\Helpers\FormToken
*/
protected $formTokenHelper;
/**
* @var \ACP3\Modules\ACP3\Feeds\Validation\AdminFormValidation
*/
protected $adminFormValidation;
/**
* @var \ACP3\Core\Helpers\Forms
*/
protected $formsHelper;
/**
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Helpers\Forms $formsHelper
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* @param \ACP3\Modules\ACP3\Feeds\Validation\AdminFormValidation $adminFormValidation
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
Core\Helpers\Forms $formsHelper,
Core\Helpers\FormToken $formTokenHelper,
Feeds\Validation\AdminFormValidation $adminFormValidation
) {
parent::__construct($context);
$this->formsHelper = $formsHelper;
$this->formTokenHelper = $formTokenHelper;
$this->adminFormValidation = $adminFormValidation;
}
/**
* @return array|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function execute()
{
if ($this->request->getPost()->count() !== 0) {
return $this->executePost($this->request->getPost()->all());
}
$settings = $this->config->getSettings(Feeds\Installer\Schema::MODULE_NAME);
$feedTypes = [
'RSS 1.0' => 'RSS 1.0',
'RSS 2.0' => 'RSS 2.0',
'ATOM' => 'ATOM'
];
return [
'feed_types' => $this->formsHelper->choicesGenerator('feed_type', $feedTypes, $settings['feed_type']),
'form' => array_merge($settings, $this->request->getPost()->all()),
'form_token' => $this->formTokenHelper->renderFormToken()
];
}
/**
* @param array $formData
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleSettingsPostAction(function () use ($formData) {
$this->adminFormValidation->validate($formData);
$data = [
'feed_image' => $this->get('core.helpers.secure')->strEncode($formData['feed_image']),
'feed_type' => $formData['feed_type']
];
return $this->config->saveSettings($data, Feeds\Installer\Schema::MODULE_NAME);
});
return;
}
}
<?php
/**
* Copyright (c) 2016 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Modules\ACP3\Feeds\Controller\Admin\Index;
use ACP3\Core;
use ACP3\Modules\ACP3\Feeds;
/**
* Class Settings
* @package ACP3\Modules\ACP3\Feeds\Controller\Admin\Index
*/
class Settings extends Core\Controller\AbstractAdminAction
{
/**
* @var \ACP3\Core\Helpers\FormToken
*/
protected $formTokenHelper;
/**
* @var \ACP3\Modules\ACP3\Feeds\Validation\AdminFormValidation
*/
protected $adminFormValidation;
/**
* @var \ACP3\Core\Helpers\Forms
*/
protected $formsHelper;
/**
* @var Core\Helpers\Secure
*/
protected $secureHelper;
/**
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param Core\Helpers\Secure $secureHelper
* @param \ACP3\Core\Helpers\Forms $formsHelper
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* @param \ACP3\Modules\ACP3\Feeds\Validation\AdminFormValidation $adminFormValidation
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
Core\Helpers\Secure $secureHelper,
Core\Helpers\Forms $formsHelper,
Core\Helpers\FormToken $formTokenHelper,
Feeds\Validation\AdminFormValidation $adminFormValidation
) {
parent::__construct($context);
$this->formsHelper = $formsHelper;
$this->formTokenHelper = $formTokenHelper;
$this->adminFormValidation = $adminFormValidation;
$this->secureHelper = $secureHelper;
}
/**
* @return array|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function execute()
{
if ($this->request->getPost()->count() !== 0) {
return $this->executePost($this->request->getPost()->all());
}
$settings = $this->config->getSettings(Feeds\Installer\Schema::MODULE_NAME);
$feedTypes = [
'RSS 1.0' => 'RSS 1.0',
'RSS 2.0' => 'RSS 2.0',
'ATOM' => 'ATOM'
];
return [
'feed_types' => $this->formsHelper->choicesGenerator('feed_type', $feedTypes, $settings['feed_type']),
'form' => array_merge($settings, $this->request->getPost()->all()),
'form_token' => $this->formTokenHelper->renderFormToken()
];
}
/**
* @param array $formData
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleSettingsPostAction(function () use ($formData) {
$this->adminFormValidation->validate($formData);
$data = [
'feed_image' => $this->secureHelper->strEncode($formData['feed_image']),
'feed_type' => $formData['feed_type']
];
return $this->config->saveSettings($data, Feeds\Installer\Schema::MODULE_NAME);
});
}
}
......@@ -22,6 +22,10 @@ class Migration implements Modules\Installer\MigrationInterface
"INSERT INTO `{pre}acl_resources` (`id`, `module_id`, `page`, `params`, `privilege_id`) VALUES('', '{moduleId}', 'acp_list', '', 7);",
"INSERT INTO `{pre}settings` (`id`, `module_id`, `name`, `value`) VALUES ('', '{moduleId}', 'feed_image', '');",
"INSERT INTO `{pre}settings` (`id`, `module_id`, `name`, `value`) VALUES ('', '{moduleId}', 'feed_type', 'RSS 2.0');",
],
32 => [
"UPDATE `{pre}acl_resources` SET `privilege_id` = 3 WHERE `module_id` = '{moduleId}' AND `area` = 'admin' AND `controller` = 'index' AND `page` = 'index';",
"INSERT INTO `{pre}acl_resources` (`module_id`, `area`, `controller`, `page`, `params`, `privilege_id`) VALUES ('{moduleId}', 'admin', 'index', 'settings', '', 7);",
]
];
}
......
......@@ -44,13 +44,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function specialResources()
{
return [
'Admin' => [
'Index' => [
'index' => 7
]
]
];
return [];
}
/**
......@@ -66,6 +60,6 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getSchemaVersion()
{
return 31;
return 32;
}
}
{extends file="asset:System/layout.ajax-form.tpl"}
{extends file="asset:System/layout.header-bar.tpl"}
{block CONTENT_BEFORE_AJAX_FORM}
{redirect_message}
{block HEADER_BAR_OPTIONS}
{check_access mode="link" path="acp/feeds/index/settings" class="glyphicon glyphicon-cog"}
{/block}
{block CONTENT_AJAX_FORM}
{include file="asset:System/Partials/form_group.input_text.tpl" name="feed_image" value=$form.feed_image maxlength=120 label={lang t="feeds|feed_image"}}
{include file="asset:System/Partials/form_group.select.tpl" options=$feed_types required=true label={lang t="feeds|feed_type"}}
{include file="asset:System/Partials/form_group.submit.tpl" form_token=$form_token back_url={uri args="acp/feeds"}}
{block CONTENT_AFTER_HEADER_BAR}
{redirect_message}
{include file="asset:System/Partials/no_results.tpl" no_results_text={lang t="system|select_menu_item"}}
{/block}
{extends file="asset:System/layout.ajax-form.tpl"}
{block CONTENT_AJAX_FORM}
{include file="asset:System/Partials/form_group.input_text.tpl" name="feed_image" value=$form.feed_image maxlength=120 label={lang t="feeds|feed_image"}}
{include file="asset:System/Partials/form_group.select.tpl" options=$feed_types required=true label={lang t="feeds|feed_type"}}
{include file="asset:System/Partials/form_group.submit.tpl" form_token=$form_token back_url={uri args="acp/feeds"}}
{/block}
services:
feeds.controller.admin.index.index:
class: ACP3\Modules\ACP3\Feeds\Controller\Admin\Index\Index
parent: core.controller.admin
feeds.controller.admin.index.settings:
class: ACP3\Modules\ACP3\Feeds\Controller\Admin\Index\Settings
arguments:
- '@core.context.admin'
- '@core.helpers.secure'
- '@core.helpers.forms'
- '@core.helpers.formToken'
- '@feeds.validator'
......
......@@ -5,6 +5,7 @@
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_settings">Einstellungen</item>
<item key="feed_image">Feed Bild</item>
<item key="feed_type">Typ des Newsfeeds</item>
<item key="feeds">Feeds</item>
......
......@@ -5,6 +5,7 @@
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_settings">Settings</item>
<item key="feed_image">Feed image</item>
<item key="feed_type">Feed type</item>
<item key="feeds">Feeds</item>
......
......@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [#49](https://github.com/ACP3/cms/issues/49) Added the ability to use a custom menu item title when creating a menu item via the articles module
- [#52](https://github.com/ACP3/cms/issues/52) Added a new system config option to select, whether the page cache is getting purged automatically or manually
- [#8](https://github.com/ACP3/cms/issues/8) Added the foundation to get module specific results per page
- Extended the contact module's settings with the following new options:
- Extended the contact module settings with the following new options:
- Mobile phone
- Picture credits
......@@ -19,7 +19,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Updated the [mibe/feedwriter](https://github.com/mibe/FeedWriter) library to version v1.1.0
- [#55](https://github.com/ACP3/cms/pull/55) Changed the argument order of the \FeedWriter\Feed::setImage() method (thanks @mibe)
- [#54](https://github.com/ACP3/cms/issues/54) Moved the password form fields from the users account profile action to the user account settings action
- The contact module's settings has been moved into its own controller action to match the structure of the other modules
- The contact module settings have been moved into its own controller action to match the structure of the other modules
- The feeds module settings have been moved into its own controller action to match the structure of the other modules
### Fixed
- Fixed the pictures count of the gallery data grid
......
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