Commit c6067d5c authored by Tino Goratsch's avatar Tino Goratsch

adapted some more controller actions to new capabilities

parent 59428518
......@@ -83,11 +83,11 @@ class Index extends Core\Modules\AdminController
$this->formTokenHelper->generateFormToken($this->request->getQuery());
}
public function actionDelete()
public function actionDelete($action = '')
{
$items = $this->_deleteItem();
if ($this->request->getParameters()->get('action') === 'confirmed') {
if ($action === 'confirmed') {
$bool = $bool2 = false;
foreach ($items as $item) {
......@@ -115,20 +115,25 @@ class Index extends Core\Modules\AdminController
}
}
public function actionEdit()
/**
* @param int $id
*
* @throws \ACP3\Core\Exceptions\ResultNotExists
*/
public function actionEdit($id)
{
if ($this->galleryModel->galleryExists((int)$this->request->getParameters()->get('id')) === true) {
$gallery = $this->galleryModel->getGalleryById((int)$this->request->getParameters()->get('id'));
if ($this->galleryModel->galleryExists($id) === true) {
$gallery = $this->galleryModel->getGalleryById($id);
$this->view->assign('SEO_FORM_FIELDS', $this->seo->formFields(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $this->request->getParameters()->get('id'))));
$this->view->assign('SEO_FORM_FIELDS', $this->seo->formFields(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $id)));
$this->breadcrumb->setTitlePostfix($gallery['title']);
if ($this->request->getPost()->isEmpty() === false) {
$this->_editPost($this->request->getPost()->getAll());
$this->_editPost($this->request->getPost()->getAll(), $id);
}
$this->view->assign('gallery_id', $this->request->getParameters()->get('id'));
$this->view->assign('gallery_id', $id);
$this->view->assign('publication_period', $this->get('core.helpers.date')->datepicker(['start', 'end'], [$gallery['start'], $gallery['end']]));
$this->view->assign('form', array_merge($gallery, $this->request->getPost()->getAll()));
......@@ -241,13 +246,14 @@ class Index extends Core\Modules\AdminController
/**
* @param array $formData
* @param int $id
*/
protected function _editPost(array $formData)
protected function _editPost(array $formData, $id)
{
try {
$this->galleryValidator->validate(
$formData,
sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $this->request->getParameters()->get('id'))
sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $id)
);
$updateValues = [
......@@ -257,16 +263,16 @@ class Index extends Core\Modules\AdminController
'user_id' => $this->auth->getUserId(),
];
$bool = $this->galleryModel->update($updateValues, $this->request->getParameters()->get('id'));
$bool = $this->galleryModel->update($updateValues, $id);
$this->seo->insertUriAlias(
sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $this->request->getParameters()->get('id')),
sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $id),
$formData['alias'],
$formData['seo_keywords'],
$formData['seo_description'],
(int)$formData['seo_robots']
);
$this->galleryHelpers->generatePictureAliases($this->request->getParameters()->get('id'));
$this->galleryHelpers->generatePictureAliases($id);
$this->formTokenHelper->unsetFormToken($this->request->getQuery());
......
......@@ -62,10 +62,15 @@ class Index extends Core\Modules\FrontendController
$this->settings = $this->config->getSettings('gallery');
}
public function actionDetails()
/**
* @param int $id
*
* @throws \ACP3\Core\Exceptions\ResultNotExists
*/
public function actionDetails($id)
{
if ($this->galleryModel->pictureExists((int)$this->request->getParameters()->get('id'), $this->date->getCurrentDateTime()) === true) {
$picture = $this->galleryModel->getPictureById((int)$this->request->getParameters()->get('id'));
if ($this->galleryModel->pictureExists($id, $this->date->getCurrentDateTime()) === true) {
$picture = $this->galleryModel->getPictureById($id);
// Brotkrümelspur
$this->breadcrumb
......@@ -123,27 +128,29 @@ class Index extends Core\Modules\FrontendController
}
}
public function actionImage()
/**
* @param int $id
* @param string $action
*/
public function actionImage($id, $action = '')
{
$this->setNoOutput(true);
if ($this->get('core.validator.rules.misc')->isNumber($this->request->getParameters()->get('id')) === true) {
set_time_limit(20);
$picture = $this->galleryModel->getFileById($this->request->getParameters()->get('id'));
$action = $this->request->getParameters()->get('action') === 'thumb' ? 'thumb' : '';
$options = [
'enable_cache' => $this->config->getSettings('system')['cache_images'] == 1,
'cache_prefix' => 'gallery_' . $action,
'max_width' => $this->settings[$action . 'width'],
'max_height' => $this->settings[$action . 'height'],
'file' => UPLOADS_DIR . 'gallery/' . $picture,
'prefer_height' => $action === 'thumb'
];
$image = new Core\Image($options);
$image->output();
}
set_time_limit(20);
$picture = $this->galleryModel->getFileById($id);
$action = $action === 'thumb' ? 'thumb' : '';
$options = [
'enable_cache' => $this->config->getSettings('system')['cache_images'] == 1,
'cache_prefix' => 'gallery_' . $action,
'max_width' => $this->settings[$action . 'width'],
'max_height' => $this->settings[$action . 'height'],
'file' => UPLOADS_DIR . 'gallery/' . $picture,
'prefer_height' => $action === 'thumb'
];
$image = new Core\Image($options);
$image->output();
}
public function actionIndex()
......@@ -157,15 +164,20 @@ class Index extends Core\Modules\FrontendController
$this->view->assign('dateformat', $this->settings['dateformat']);
}
public function actionPics()
/**
* @param int $id
*
* @throws \ACP3\Core\Exceptions\ResultNotExists
*/
public function actionPics($id)
{
if ($this->galleryModel->galleryExists((int)$this->request->getParameters()->get('id'), $this->date->getCurrentDateTime()) === true) {
if ($this->galleryModel->galleryExists($id, $this->date->getCurrentDateTime()) === true) {
// Brotkrümelspur
$this->breadcrumb
->append($this->lang->t('gallery', 'gallery'), 'gallery')
->append($this->galleryModel->getGalleryTitle($this->request->getParameters()->get('id')));
->append($this->galleryModel->getGalleryTitle($id));
$this->view->assign('pictures', $this->galleryCache->getCache($this->request->getParameters()->get('id')));
$this->view->assign('pictures', $this->galleryCache->getCache($id));
$this->view->assign('overlay', (int)$this->settings['overlay']);
} else {
throw new Core\Exceptions\ResultNotExists();
......
......@@ -67,11 +67,16 @@ class Index extends Core\Modules\AdminController
return $this;
}
public function actionDelete()
/**
* @param string $action
*
* @throws \ACP3\Core\Exceptions\ResultNotExists
*/
public function actionDelete($action = '')
{
$items = $this->_deleteItem();
if ($this->request->getParameters()->get('action') === 'confirmed') {
if ($$action === 'confirmed') {
$bool = false;
foreach ($items as $item) {
$bool = $this->guestbookModel->delete($item);
......@@ -83,16 +88,21 @@ class Index extends Core\Modules\AdminController
}
}
public function actionEdit()
/**
* @param int $id
*
* @throws \ACP3\Core\Exceptions\ResultNotExists
*/
public function actionEdit($id)
{
$guestbook = $this->guestbookModel->getOneById($this->request->getParameters()->get('id'));
$guestbook = $this->guestbookModel->getOneById($id);
if (empty($guestbook) === false) {
$settings = $this->config->getSettings('guestbook');
$this->breadcrumb->setTitlePostfix($guestbook['name']);
if ($this->request->getPost()->isEmpty() === false) {
$this->_editPost($this->request->getPost()->getAll(), $settings);
$this->_editPost($this->request->getPost()->getAll(), $settings, $id);
}
if ($settings['emoticons'] == 1 && $this->emoticonsHelpers) {
......@@ -184,8 +194,9 @@ class Index extends Core\Modules\AdminController
/**
* @param array $formData
* @param array $settings
* @param int $id
*/
protected function _editPost(array $formData, array $settings)
protected function _editPost(array $formData, array $settings, $id)
{
try {
$this->guestbookValidator->validateEdit($formData, $settings);
......@@ -196,7 +207,7 @@ class Index extends Core\Modules\AdminController
'active' => $settings['notify'] == 2 ? $formData['active'] : 1,
];
$bool = $this->guestbookModel->update($updateValues, $this->request->getParameters()->get('id'));
$bool = $this->guestbookModel->update($updateValues, $id);
$this->formTokenHelper->unsetFormToken($this->request->getQuery());
......
......@@ -75,11 +75,11 @@ class Index extends Core\Modules\AdminController
$this->formTokenHelper->generateFormToken($this->request->getQuery());
}
public function actionDelete()
public function actionDelete($action = '')
{
$items = $this->_deleteItem();
if ($this->request->getParameters()->get('action') === 'confirmed') {
if ($action === 'confirmed') {
$bool = false;
$nestedSet = new Core\NestedSet($this->db, Menus\Model::TABLE_NAME_ITEMS, true);
......@@ -105,15 +105,20 @@ class Index extends Core\Modules\AdminController
}
}
public function actionEdit()
/**
* @param int $id
*
* @throws \ACP3\Core\Exceptions\ResultNotExists
*/
public function actionEdit($id)
{
$menu = $this->menusModel->getOneById($this->request->getParameters()->get('id'));
$menu = $this->menusModel->getOneById($id);
if (empty($menu) === false) {
$this->breadcrumb->setTitlePostfix($menu['title']);
if ($this->request->getPost()->isEmpty() === false) {
$this->_editPost($this->request->getPost()->getAll());
$this->_editPost($this->request->getPost()->getAll(), $id);
}
$this->view->assign('form', array_merge($menu, $this->request->getPost()->getAll()));
......@@ -178,18 +183,19 @@ class Index extends Core\Modules\AdminController
/**
* @param array $formData
* @param int $id
*/
protected function _editPost(array $formData)
protected function _editPost(array $formData, $id)
{
try {
$this->menusValidator->validate($formData, (int)$this->request->getParameters()->get('id'));
$this->menusValidator->validate($formData, $id);
$updateValues = [
'index_name' => $formData['index_name'],
'title' => Core\Functions::strEncode($formData['title']),
];
$bool = $this->menusModel->update($updateValues, $this->request->getParameters()->get('id'));
$bool = $this->menusModel->update($updateValues, $id);
$this->menusCache->setMenuItemsCache();
......
......@@ -135,11 +135,16 @@ class Items extends Core\Modules\AdminController
$this->formTokenHelper->generateFormToken($this->request->getQuery());
}
public function actionDelete()
/**
* @param string $action
*
* @throws \ACP3\Core\Exceptions\ResultNotExists
*/
public function actionDelete($action = '')
{
$items = $this->_deleteItem(null, 'acp/menus');
if ($this->request->getParameters()->get('action') === 'confirmed') {
if ($action === 'confirmed') {
$bool = false;
$nestedSet = new Core\NestedSet($this->db, Menus\Model::TABLE_NAME_ITEMS, true);
foreach ($items as $item) {
......@@ -157,9 +162,14 @@ class Items extends Core\Modules\AdminController
}
}
public function actionEdit()
/**
* @param int $id
*
* @throws \ACP3\Core\Exceptions\ResultNotExists
*/
public function actionEdit($id)
{
$menuItem = $this->menusModel->getOneMenuItemById($this->request->getParameters()->get('id'));
$menuItem = $this->menusModel->getOneMenuItemById($id);
if (empty($menuItem) === false) {
$this->breadcrumb->setTitlePostfix($menuItem['title']);
......@@ -169,7 +179,7 @@ class Items extends Core\Modules\AdminController
$menuItem['seo_description'] = $this->seo->getDescription($menuItem['uri']);
if ($this->request->getPost()->isEmpty() === false) {
$this->_editPost($this->request->getPost()->getAll(), $menuItem);
$this->_editPost($this->request->getPost()->getAll(), $menuItem, $id);
}
// Seitentyp
......@@ -301,8 +311,9 @@ class Items extends Core\Modules\AdminController
/**
* @param array $formData
* @param array $menuItem
* @param int $id
*/
protected function _editPost(array $formData, array $menuItem)
protected function _editPost(array $formData, array $menuItem, $id)
{
try {
$this->menusValidator->validateItem($formData);
......@@ -322,7 +333,7 @@ class Items extends Core\Modules\AdminController
];
$nestedSet = new Core\NestedSet($this->db, Menus\Model::TABLE_NAME_ITEMS, true);
$bool = $nestedSet->editNode($this->request->getParameters()->get('id'), (int)$formData['parent_id'], (int)$formData['block_id'], $updateValues);
$bool = $nestedSet->editNode($id, (int)$formData['parent_id'], (int)$formData['block_id'], $updateValues);
// Verhindern, dass externen URIs Aliase, Keywords, etc. zugewiesen bekommen
if ($formData['mode'] != 3) {
......
......@@ -162,7 +162,7 @@ class Index extends Core\Modules\AdminController
}
/**
* @param $id
* @param int $id
*
* @throws \ACP3\Core\Exceptions\ResultNotExists
*/
......
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