diff --git a/administrator/components/com_categories/Controller/CategoriesController.php b/administrator/components/com_categories/Controller/CategoriesController.php index bc5a5ccfd135b..6583c23a874b8 100644 --- a/administrator/components/com_categories/Controller/CategoriesController.php +++ b/administrator/components/com_categories/Controller/CategoriesController.php @@ -96,65 +96,16 @@ public function rebuild() } /** - * Deletes and returns correctly. + * Gets the URL arguments to append to a list redirect. * - * @return void + * @return string The arguments to append to the redirect URL. * - * @since 3.1.2 + * @since __DEPLOY_VERSION__ */ - public function delete() + protected function getRedirectToListAppend() { - $this->checkToken(); - - // Get items to remove from the request. - $cid = $this->input->get('cid', array(), 'array'); $extension = $this->input->getCmd('extension', null); - if (!is_array($cid) || count($cid) < 1) - { - $this->app->enqueueMessage(Text::_($this->text_prefix . '_NO_ITEM_SELECTED'), 'warning'); - } - else - { - // Get the model. - /** @var \Joomla\Component\Categories\Administrator\Model\CategoryModel $model */ - $model = $this->getModel(); - - // Make sure the item ids are integers - $cid = ArrayHelper::toInteger($cid); - - // Remove the items. - if ($model->delete($cid)) - { - $this->setMessage(Text::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); - } - else - { - $this->setMessage($model->getError()); - } - } - - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&extension=' . $extension, false)); - } - - /** - * Check in of one or more records. - * - * Overrides \JControllerAdmin::checkin to redirect to URL with extension. - * - * @return boolean True on success - * - * @since 3.6.0 - */ - public function checkin() - { - // Process parent checkin method. - $result = parent::checkin(); - - // Override the redirect Uri. - $redirectUri = 'index.php?option=' . $this->option . '&view=' . $this->view_list . '&extension=' . $this->input->get('extension', '', 'CMD'); - $this->setRedirect(Route::_($redirectUri, false), $this->message, $this->messageType); - - return $result; + return '&extension=' . $extension; } } diff --git a/administrator/components/com_contenthistory/Controller/HistoryController.php b/administrator/components/com_contenthistory/Controller/HistoryController.php index 1f030ae291533..96785b00aca7e 100644 --- a/administrator/components/com_contenthistory/Controller/HistoryController.php +++ b/administrator/components/com_contenthistory/Controller/HistoryController.php @@ -24,52 +24,6 @@ */ class HistoryController extends AdminController { - /** - * Deletes and returns correctly. - * - * @return void - * - * @since 3.2 - */ - public function delete() - { - $this->checkToken(); - - // Get items to remove from the request. - $cid = $this->input->get('cid', array(), 'array'); - - if (!is_array($cid) || count($cid) < 1) - { - $this->app->enqueueMessage(Text::_('COM_CONTENTHISTORY_NO_ITEM_SELECTED'), 'warning'); - } - else - { - // Get the model. - $model = $this->getModel(); - - // Make sure the item ids are integers - $cid = ArrayHelper::toInteger($cid); - - // Remove the items. - if ($model->delete($cid)) - { - $this->setMessage(Text::plural('COM_CONTENTHISTORY_N_ITEMS_DELETED', count($cid))); - } - else - { - $this->setMessage($model->getError(), 'error'); - } - } - - $this->setRedirect( - Route::_( - 'index.php?option=com_contenthistory&view=history&layout=modal&tmpl=component&item_id=' - . $this->input->getInt('item_id') . '&type_id=' . $this->input->getInt('type_id') - . '&type_alias=' . $this->input->getCmd('type_alias') . '&' . Session::getFormToken() . '=1', false - ) - ); - } - /** * Proxy for getModel. * @@ -131,4 +85,18 @@ public function keep() ) ); } + + /** + * Gets the URL arguments to append to a list redirect. + * + * @return string The arguments to append to the redirect URL. + * + * @since __DEPLOY_VERSION__ + */ + protected function getRedirectToListAppend() + { + return '&layout=modal&tmpl=component&item_id=' + . $this->input->getInt('item_id') . '&type_id=' . $this->input->getInt('type_id') + . '&type_alias=' . $this->input->getCmd('type_alias') . '&' . Session::getFormToken() . '=1'; + } } diff --git a/administrator/components/com_menus/Controller/ItemsController.php b/administrator/components/com_menus/Controller/ItemsController.php index 6e7c94101bf52..d489bd230bbeb 100644 --- a/administrator/components/com_menus/Controller/ItemsController.php +++ b/administrator/components/com_menus/Controller/ItemsController.php @@ -261,52 +261,14 @@ public function publish() } /** - * Check in of one or more records. + * Gets the URL arguments to append to a list redirect. * - * @return boolean True on success + * @return string The arguments to append to the redirect URL. * - * @since 3.6.0 + * @since __DEPLOY_VERSION__ */ - public function checkin() + protected function getRedirectToListAppend() { - // Check for request forgeries. - $this->checkToken(); - - $ids = $this->input->post->get('cid', array(), 'array'); - - $model = $this->getModel(); - $return = $model->checkin($ids); - - if ($return === false) - { - // Checkin failed. - $message = Text::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()); - $this->setRedirect( - Route::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list - . '&menutype=' . $this->app->getUserState('com_menus.items.menutype'), - false - ), - $message, - 'error' - ); - - return false; - } - else - { - // Checkin succeeded. - $message = Text::plural($this->text_prefix . '_N_ITEMS_CHECKED_IN', count($ids)); - $this->setRedirect( - Route::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list - . '&menutype=' . $this->app->getUserState('com_menus.items.menutype'), - false - ), - $message - ); - - return true; - } + return '&menutype=' . $this->app->getUserState('com_menus.items.menutype'); } } diff --git a/administrator/components/com_workflow/Controller/StagesController.php b/administrator/components/com_workflow/Controller/StagesController.php index f63e4623f93e1..c1a705129d08c 100644 --- a/administrator/components/com_workflow/Controller/StagesController.php +++ b/administrator/components/com_workflow/Controller/StagesController.php @@ -166,62 +166,14 @@ public function setDefault() } /** - * Check in of one or more records. + * Gets the URL arguments to append to a list redirect. * - * @return boolean True on success + * @return string The arguments to append to the redirect URL. * - * @since 4.0.0 + * @since __DEPLOY_VERSION__ */ - public function checkin() + protected function getRedirectToListAppend() { - $result = parent::checkin(); - - $this->setRedirect( - Route::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list - . '&extension=' . $this->extension - . '&workflow_id=' . $this->workflowId, false - ) - ); - - return $result; - } - - /** - * Deletes and returns correctly. - * - * @return void - * - * @since 4.0.0 - */ - public function delete() - { - parent::delete(); - $this->setRedirect( - Route::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list - . '&extension=' . $this->extension - . '&workflow_id=' . $this->workflowId, false - ) - ); - } - - /** - * Method to publish a list of items - * - * @return void - * - * @since 4.0.0 - */ - public function publish() - { - parent::publish(); - - $this->setRedirect( - Route::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list - . '&extension=' . $this->extension . '&workflow_id=' . $this->workflowId, false - ) - ); + return '&extension=' . $this->extension . '&workflow_id=' . $this->workflowId; } } diff --git a/administrator/components/com_workflow/Controller/TransitionsController.php b/administrator/components/com_workflow/Controller/TransitionsController.php index 4be096d3762a2..6497372802bb5 100644 --- a/administrator/components/com_workflow/Controller/TransitionsController.php +++ b/administrator/components/com_workflow/Controller/TransitionsController.php @@ -95,41 +95,15 @@ public function getModel($name = 'Transition', $prefix = 'Administrator', $confi } /** - * Deletes and returns correctly. + * Gets the URL arguments to append to a list redirect. * - * @return void + * @return string The arguments to append to the redirect URL. * - * @since 4.0.0 - */ - public function delete() - { - parent::delete(); - $this->setRedirect( - Route::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list - . '&extension=' . $this->extension - . '&workflow_id=' . $this->workflowId, false - ) - ); - } - - /** - * Method to publish a list of items - * - * @return void - * - * @since 4.0.0 + * @since __DEPLOY_VERSION__ */ - public function publish() + protected function getRedirectToListAppend() { - parent::publish(); - - $this->setRedirect( - Route::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list - . '&extension=' . $this->extension - . '&workflow_id=' . $this->workflowId, false - ) - ); + return '&extension=' . $this->extension + . '&workflow_id=' . $this->workflowId; } } diff --git a/administrator/components/com_workflow/Controller/WorkflowsController.php b/administrator/components/com_workflow/Controller/WorkflowsController.php index 0cc593e24237d..8501da329764b 100644 --- a/administrator/components/com_workflow/Controller/WorkflowsController.php +++ b/administrator/components/com_workflow/Controller/WorkflowsController.php @@ -171,4 +171,16 @@ public function delete() ) ); } + + /** + * Gets the URL arguments to append to a list redirect. + * + * @return string The arguments to append to the redirect URL. + * + * @since __DEPLOY_VERSION__ + */ + protected function getRedirectToListAppend() + { + return '&extension=' . $this->extension; + } } diff --git a/libraries/src/MVC/Controller/AdminController.php b/libraries/src/MVC/Controller/AdminController.php index 047ef507ca590..fa2d16aa56c8a 100644 --- a/libraries/src/MVC/Controller/AdminController.php +++ b/libraries/src/MVC/Controller/AdminController.php @@ -160,7 +160,12 @@ public function delete() $this->postDeleteHook($model, $cid); } - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . '&view=' . $this->view_list + . $this->getRedirectToListAppend(), false + ) + ); } /** @@ -250,9 +255,12 @@ public function publish() } } - $extension = $this->input->get('extension'); - $extensionURL = $extension ? '&extension=' . $extension : ''; - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $extensionURL, false)); + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . '&view=' . $this->view_list + . $this->getRedirectToListAppend(), false + ) + ); } /** @@ -273,11 +281,13 @@ public function reorder() $model = $this->getModel(); $return = $model->reorder($ids, $inc); + $redirect = Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false); + if ($return === false) { // Reorder failed. $message = Text::sprintf('JLIB_APPLICATION_ERROR_REORDER_FAILED', $model->getError()); - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message, 'error'); + $this->setRedirect($redirect, $message, 'error'); return false; } @@ -285,7 +295,7 @@ public function reorder() { // Reorder succeeded. $message = Text::_('JLIB_APPLICATION_SUCCESS_ITEM_REORDERED'); - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message); + $this->setRedirect($redirect, $message); return true; } @@ -317,11 +327,13 @@ public function saveorder() // Save the ordering $return = $model->saveorder($pks, $order); + $redirect = Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false); + if ($return === false) { // Reorder failed $message = Text::sprintf('JLIB_APPLICATION_ERROR_REORDER_FAILED', $model->getError()); - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message, 'error'); + $this->setRedirect($redirect, $message, 'error'); return false; } @@ -329,7 +341,7 @@ public function saveorder() { // Reorder succeeded. $this->setMessage(Text::_('JLIB_APPLICATION_SUCCESS_ORDERING_SAVED')); - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); + $this->setRedirect($redirect); return true; } @@ -356,7 +368,11 @@ public function checkin() { // Checkin failed. $message = Text::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()); - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message, 'error'); + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false + ), $message, 'error' + ); return false; } @@ -364,7 +380,11 @@ public function checkin() { // Checkin succeeded. $message = Text::plural($this->text_prefix . '_N_ITEMS_CHECKED_IN', count($ids)); - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message); + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false + ), $message + ); return true; } @@ -405,7 +425,7 @@ public function saveOrderAjax() /** * Method to run Transition by id of item. * - * @return void + * @return boolean Indicates whether the transition was succesful. * * @since 4.0.0 */ @@ -427,23 +447,33 @@ public function runTransition() $model = $this->getModel(); $return = $model->runTransition($pk, $transitionId); + $redirect = Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false); + if ($return === false) { // Transition change failed. $message = Text::sprintf('JLIB_APPLICATION_ERROR_RUN_TRANSITION', $model->getError()); - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message, 'error'); + $this->setRedirect($redirect, $message, 'error'); return false; } - else - { - // Transition change succeeded. - $message = Text::_('JLIB_APPLICATION_SUCCESS_RUN_TRANSITION'); - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message); - return true; - } + // Transition change succeeded. + $message = Text::_('JLIB_APPLICATION_SUCCESS_RUN_TRANSITION'); + $this->setRedirect($redirect, $message); - $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $extensionURL, false)); + return true; + } + + /** + * Gets the URL arguments to append to a list redirect. + * + * @return string The arguments to append to the redirect URL. + * + * @since __DEPLOY_VERSION__ + */ + protected function getRedirectToListAppend() + { + return ''; } }