Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Controller/Component/AppPaginatorComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* NetCommons用に拡張したページネーション Component
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @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 <nakajimashouhei@gmail.com>
* @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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function testCancelAndSaveAndSaveTemp($status, $contentPublishable, $canc
*/
private function __assertButtons($result, $cancelUrl, $backUrl, $disapproval, $approval) {
//キャンセルのチェック
$expected = '<a href="' . $cancelUrl . '" class="btn btn-default btn-workflow">' .
$expected = '<a href="' . $cancelUrl . '" class="btn btn-default btn-workflow" ng-class="{disabled: sending}" ng-click="sending=true">' .
'<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> ' . __d('net_commons', 'Cancel') .
'</a>';
$this->assertTextContains($expected, $result);
Expand All @@ -156,7 +156,7 @@ private function __assertButtons($result, $cancelUrl, $backUrl, $disapproval, $a
}

//一時保存のチェック
$expected = '<button class="btn btn-info btn-workflow" name="save_3" type="submit">' .
$expected = '<button class="btn btn-info btn-workflow" name="save_3" ng-class="{disabled: sending}" type="submit">' .
__d('net_commons', 'Save temporally') .
'</button>';
if ($disapproval) {
Expand All @@ -166,7 +166,7 @@ private function __assertButtons($result, $cancelUrl, $backUrl, $disapproval, $a
}

//差し戻しのチェック
$expected = '<button class="btn btn-warning btn-workflow" name="save_4" type="submit">' .
$expected = '<button class="btn btn-warning btn-workflow" name="save_4" ng-class="{disabled: sending}" type="submit">' .
__d('net_commons', 'Disapproval') .
'</button>';
if ($disapproval) {
Expand All @@ -176,7 +176,7 @@ private function __assertButtons($result, $cancelUrl, $backUrl, $disapproval, $a
}

//公開のチェック
$expected = '<button class="btn btn-primary btn-workflow" name="save_1" type="submit">' .
$expected = '<button class="btn btn-primary btn-workflow" name="save_1" ng-class="{disabled: sending}" type="submit">' .
__d('net_commons', 'OK') .
'</button>';
if ($approval) {
Expand All @@ -186,7 +186,7 @@ private function __assertButtons($result, $cancelUrl, $backUrl, $disapproval, $a
}

//申請のチェック
$expected = '<button class="btn btn-primary btn-workflow" name="save_2" type="submit">' .
$expected = '<button class="btn btn-primary btn-workflow" name="save_2" ng-class="{disabled: sending}" type="submit">' .
__d('net_commons', 'OK') .
'</button>';
if ($approval) {
Expand Down
48 changes: 48 additions & 0 deletions View/Helper/AppPaginatorHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* NetCommons用に拡張したページネーション Helper
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @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 <nakajimashouhei@gmail.com>
* @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;
}

}