diff --git a/doc/changelog.txt b/doc/changelog.txt index b883571438..fcb57b9ba9 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -16,6 +16,7 @@ June 24th, 2013 11. Fixed Issue #121: exception messages were missed by ErrorStrategy template overwritten 12. Merged theme/template/error-exception.phtml to error.phtml 13. Modified config: var/config/config.application.php -- changed 'exception_template' value +14. Formulated return of Ajax/JSON request with format: array('status' => 1, 'message' => '', 'data' => array()) June 19th, 2013 diff --git a/usr/module/system/src/Controller/Admin/PageController.php b/usr/module/system/src/Controller/Admin/PageController.php index ed57b1f8ee..953f8ee7ac 100644 --- a/usr/module/system/src/Controller/Admin/PageController.php +++ b/usr/module/system/src/Controller/Admin/PageController.php @@ -274,7 +274,7 @@ public function addsaveAction() return array( 'status' => $status, 'message' => $message, - 'page' => $page, + 'data' => $page, ); } @@ -319,7 +319,6 @@ public function editAction() $this->view()->setTemplate('system:component/form-popup'); } - /** * AJAX for editing a page */ @@ -365,7 +364,7 @@ public function editsaveAction() return array( 'status' => $status, 'message' => $message, - 'page' => $page, + 'data' => $page, ); } @@ -400,12 +399,18 @@ public function deleteAction() // Remove page $row->delete(); Pi::service('registry')->page->clear($row->module); + $result = array( + 'status' => 0, + 'message' => __('Page is not found.'), + ); + } else { + $result = array( + 'status' => 1, + 'message' => __('Page is deleted.'), + ); } - /* - $this->view()->setTemplate(false); - $this->redirect()->toRoute('', array('action' => 'index', 'name' => $row->module)); - */ - return 1; + + return $result; } /** @@ -550,18 +555,27 @@ public function blocklistAction() * ), * ); * - * @return int 0 for false; 1 for success + * @return array */ public function saveAction() { + $result = array( + 'status' => 1, + 'message' => '', + 'data' => array(), + ); $page = $this->params()->fromPost('page'); $blocks = $this->params()->fromPost('blocks'); $row = Pi::model('page')->find($page); if (!$row) { - return 0; + $result = array( + 'status' => 0, + 'message' => __('Page is not found.'), + ); + return $result; } - +; // Remove all existent block links Pi::model('page_block')->delete(array('page' => $page)); // Add new block links @@ -579,7 +593,11 @@ public function saveAction() // Clear cache of the page module Pi::service('registry')->block->clear($row->module); - return 1; + $result = array( + 'status' => 1, + 'message' => __('Page block links are updated.'), + ); + return $result; } /**