From 44216e3dd1d43b5b6e32ead647e6700cc7a1103a Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 5 Aug 2016 23:37:33 +0900 Subject: [PATCH 1/2] =?UTF-8?q?PHPUnit=E3=82=A8=E3=83=A9=E3=83=BC=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ButtonHelper/CancelAndSaveAndSaveTempTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Test/Case/View/Helper/ButtonHelper/CancelAndSaveAndSaveTempTest.php b/Test/Case/View/Helper/ButtonHelper/CancelAndSaveAndSaveTempTest.php index 24701515..16eec8ea 100644 --- a/Test/Case/View/Helper/ButtonHelper/CancelAndSaveAndSaveTempTest.php +++ b/Test/Case/View/Helper/ButtonHelper/CancelAndSaveAndSaveTempTest.php @@ -139,7 +139,7 @@ public function testCancelAndSaveAndSaveTemp($status, $contentPublishable, $canc */ private function __assertButtons($result, $cancelUrl, $backUrl, $disapproval, $approval) { //キャンセルのチェック - $expected = '' . + $expected = '' . ' ' . __d('net_commons', 'Cancel') . ''; $this->assertTextContains($expected, $result); @@ -156,7 +156,7 @@ private function __assertButtons($result, $cancelUrl, $backUrl, $disapproval, $a } //一時保存のチェック - $expected = ''; if ($disapproval) { @@ -166,7 +166,7 @@ private function __assertButtons($result, $cancelUrl, $backUrl, $disapproval, $a } //差し戻しのチェック - $expected = ''; if ($disapproval) { @@ -176,7 +176,7 @@ private function __assertButtons($result, $cancelUrl, $backUrl, $disapproval, $a } //公開のチェック - $expected = ''; if ($approval) { @@ -186,7 +186,7 @@ private function __assertButtons($result, $cancelUrl, $backUrl, $disapproval, $a } //申請のチェック - $expected = ''; if ($approval) { From d28aa7fd47c6acd1037d0552f322fab84568e39c Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 5 Aug 2016 23:38:34 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=AB=E3=83=BC=E3=83=86=E3=82=A3?= =?UTF-8?q?=E3=83=B3=E3=82=B0=E3=81=97=E3=81=9F=E3=81=93=E3=81=A8=E3=81=AB?= =?UTF-8?q?=E3=82=88=E3=82=8A=E3=83=9A=E3=83=BC=E3=82=B8=E3=83=8D=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=8C=E5=8B=95=E4=BD=9C=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=8F=E3=81=AA=E3=81=A3=E3=81=9F=E3=81=9F=E3=82=81?= =?UTF-8?q?=E3=80=81=E6=8B=A1=E5=BC=B5=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/AppPaginatorComponent.php | 48 +++++++++++++++++++ View/Helper/AppPaginatorHelper.php | 48 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 Controller/Component/AppPaginatorComponent.php create mode 100644 View/Helper/AppPaginatorHelper.php diff --git a/Controller/Component/AppPaginatorComponent.php b/Controller/Component/AppPaginatorComponent.php new file mode 100644 index 00000000..54722a7f --- /dev/null +++ b/Controller/Component/AppPaginatorComponent.php @@ -0,0 +1,48 @@ + + * @author Shohei Nakajima + * @link http://www.netcommons.org NetCommons Project + * @license http://www.netcommons.org/license.txt NetCommons License + * @copyright Copyright 2014, NetCommons Project + */ + +App::uses('PaginatorComponent', 'Controller/Component'); + +/** + * NetCommons用に拡張したページネーション Component + * + * @author Shohei Nakajima + * @package NetCommons\NetCommons\Controller\Component + */ +class AppPaginatorComponent extends PaginatorComponent { + +/** + * Handles automatic pagination of model records. + * + * @param Model|string $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel') + * @param string|array $scope Additional find conditions to use while paginating + * @param array $whitelist List of allowed fields for ordering. This allows you to prevent ordering + * on non-indexed, or undesirable columns. See PaginatorComponent::validateSort() for additional details + * on how the whitelisting and sort field validation works. + * @return array Model query results + * @throws MissingModelException + * @throws NotFoundException + */ + public function paginate($object = null, $scope = array(), $whitelist = array()) { + $results = parent::paginate($object, $scope, $whitelist); + + if (in_array('Paginator', $this->Controller->helpers, true)) { + $index = array_search('Paginator', $this->Controller->helpers, true); + unset($this->Controller->helpers[$index]); + } elseif (array_key_exists('Paginator', $this->Controller->helpers, true)) { + unset($this->Controller->helpers['Paginator']); + } + $this->Controller->helpers['Paginator'] = array('className' => 'NetCommons.AppPaginator'); + + return $results; + } + +} diff --git a/View/Helper/AppPaginatorHelper.php b/View/Helper/AppPaginatorHelper.php new file mode 100644 index 00000000..bf682fb1 --- /dev/null +++ b/View/Helper/AppPaginatorHelper.php @@ -0,0 +1,48 @@ + + * @author Shohei Nakajima + * @link http://www.netcommons.org NetCommons Project + * @license http://www.netcommons.org/license.txt NetCommons License + * @copyright Copyright 2014, NetCommons Project + */ + +App::uses('PaginatorHelper', 'View/Helper'); +App::uses('NetCommonsUrl', 'NetCommons.Utility'); + +/** + * NetCommons用に拡張したページネーション Helper + * + * @author Shohei Nakajima + * @package NetCommons\NetCommons\View\Helper + */ +class AppPaginatorHelper extends PaginatorHelper { + +/** + * Converts the keys being used into the format set by options.paramType + * + * @param array $url Array of URL params to convert + * @param string $type Keys type. + * @return array converted URL params. + */ + protected function _convertUrlKeys($url, $type) { + $url = parent::_convertUrlKeys($url, $type); + if (array_key_exists('block_id', $this->request->params)) { + $url['block_id'] = $this->request->params['block_id']; + } + if (array_key_exists('key', $this->request->params)) { + $url['key'] = $this->request->params['key']; + } + + if (array_key_exists('block_id', $this->request->params)) { + $url = NetCommonsUrl::blockUrl($url); + } else { + $url = NetCommonsUrl::actionUrlAsArray($url); + } + + return $url; + } + +}