Changeset 0ee680ad0e905220841bba9a9b62ebae5a380115
- Timestamp:
- 01/28/12 20:20:26 (4 months ago)
- Author:
- Xemle <xemle@phtagr.org>
- Children:
- b243ec7e35d1927db9132cdb0c1f9473054612d2
- Parents:
- 1286d8885552a162d63c77c03b988eba30d8eb8e
- git-committer:
- Xemle <xemle@phtagr.org> / 2012-01-28T20:20:26Z+0100
- Message:
-
Fix paging of explorer
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r3605ef4
|
r0ee680a
|
|
| 184 | 184 | } |
| 185 | 185 | |
| | 186 | function decode($input) { |
| | 187 | $out = ''; |
| | 188 | $input = (string)$input; |
| | 189 | $len = strlen($input); |
| | 190 | for ($i = 0; $i < $len; $i++) { |
| | 191 | $c = substr($input, $i, 1); |
| | 192 | if ($c == '=') { |
| | 193 | if ($i + 2 >= $len) { |
| | 194 | break; |
| | 195 | } |
| | 196 | $c1 = substr($input, $i + 1, 1); |
| | 197 | $c2 = substr($input, $i + 2, 1); |
| | 198 | $c = $this->_dechex($c1, $c2); |
| | 199 | if ($c !== false) { |
| | 200 | $out .= $c; |
| | 201 | } |
| | 202 | $i += 2; |
| | 203 | } else { |
| | 204 | $out .= $c; |
| | 205 | } |
| | 206 | } |
| | 207 | return $out; |
| | 208 | } |
| | 209 | |
| 186 | 210 | function __call($name, $args) { |
| 187 | 211 | if (!preg_match('/^(get|set|add|del|delete)(.*)$/', $name, $matches)) { |
| … |
… |
|
| 454 | 478 | |
| 455 | 479 | if ($count == 0) { |
| 456 | | $this->controller->params['search'] = $params; |
| | 480 | $this->controller->request->params['search'] = $params; |
| 457 | 481 | return array(); |
| 458 | 482 | } |
| … |
… |
|
| 479 | 503 | |
| 480 | 504 | // Set data for search helper |
| 481 | | $this->controller->params['search'] = $params; |
| | 505 | $this->controller->request->params['search'] = $params; |
| 482 | 506 | |
| 483 | 507 | return $data; |
| … |
… |
|
| 498 | 522 | 'data' => $this->getParams() |
| 499 | 523 | ); |
| 500 | | $this->controller->params['search'] = $params; |
| | 524 | $this->controller->request->params['search'] = $params; |
| 501 | 525 | } |
| 502 | 526 | |
| … |
… |
|
| 536 | 560 | Logger::verbose("Deny access to media $id"); |
| 537 | 561 | } |
| 538 | | $this->controller->params['search'] = $params; |
| | 562 | $this->controller->request->params['search'] = $params; |
| 539 | 563 | return array(); |
| 540 | 564 | } |
| … |
… |
|
| 590 | 614 | |
| 591 | 615 | // Set data for search helper |
| 592 | | $this->controller->params['search'] = $params; |
| | 616 | $this->controller->request->params['search'] = $params; |
| 593 | 617 | |
| 594 | 618 | return $data; |
-
|
ree4c2b7f
|
r0ee680a
|
|
| 37 | 37 | |
| 38 | 38 | parent::beforeFilter(); |
| 39 | | $this->crumbs = $this->Search->urlToCrumbs($this->params['url']['url'], 2); |
| | 39 | $this->crumbs = $this->Search->urlToCrumbs($this->request->url, 2); |
| 40 | 40 | } |
| 41 | 41 | |
| … |
… |
|
| 58 | 58 | } |
| 59 | 59 | $this->set('crumbs', $this->crumbs); |
| 60 | | $this->params['crumbs'] = $this->crumbs; |
| | 60 | $this->request->params['crumbs'] = $this->crumbs; |
| 61 | 61 | $this->Feed->add('/explorer/media/' . join('/', $this->Search->encodeCrumbs($this->crumbs)), array('title' => __('Slideshow Media RSS'), 'id' => 'slideshow')); |
| 62 | 62 | parent::beforeRender(); |
-
|
ree4c2b7f
|
r0ee680a
|
|
| 22 | 22 | */ |
| 23 | 23 | |
| | 24 | App::uses('Folder', 'Utility'); |
| | 25 | |
| 24 | 26 | class UsersController extends AppController |
| 25 | 27 | { |
-
|
ree4c2b7f
|
r0ee680a
|
|
| 55 | 55 | $path = Folder::slashTerm(dirname($filename)); |
| 56 | 56 | $file = basename($filename); |
| 57 | | $size = filesize($filename); |
| | 57 | if (is_readable($filename)) { |
| | 58 | $size = filesize($filename); |
| | 59 | } else { |
| | 60 | $size = 0; |
| | 61 | Logger::info("Could not read file: " . $filename); |
| | 62 | } |
| 58 | 63 | $type = $this->_getTypeFromFilename($filename); |
| 59 | 64 | } |
| … |
… |
|
| 64 | 69 | 'file' => $file, |
| 65 | 70 | 'size' => $size, |
| 66 | | 'time' => date("Y-m-d H:i:s", filemtime($filename)), |
| | 71 | 'time' => date("Y-m-d H:i:s"), |
| 67 | 72 | 'flag' => $flag, |
| 68 | 73 | 'type' => $type, |
| … |
… |
|
| 71 | 76 | ) |
| 72 | 77 | ); |
| | 78 | if (is_readable($filename)) { |
| | 79 | $new['File']['time'] = date("Y-m-d H:i:s", filemtime($filename)); |
| | 80 | } |
| 73 | 81 | $new = parent::create($new, true); |
| 74 | 82 | |
-
|
r0fb8d7c
|
r0ee680a
|
|
| 30 | 30 | |
| 31 | 31 | function getPageCount() { |
| 32 | | if (isset($this->params['search'])) { |
| 33 | | return $this->params['search']['pageCount']; |
| | 32 | if (isset($this->request->params['search'])) { |
| | 33 | return $this->request->params['search']['pageCount']; |
| 34 | 34 | } |
| 35 | 35 | return 0; |
| … |
… |
|
| 37 | 37 | |
| 38 | 38 | function getCurrentPage() { |
| 39 | | if (isset($this->params['search']['page'])) { |
| 40 | | return $this->params['search']['page']; |
| | 39 | if (isset($this->request->params['search']['page'])) { |
| | 40 | return $this->request->params['search']['page']; |
| 41 | 41 | } |
| 42 | 42 | return 0; |
| … |
… |
|
| 44 | 44 | |
| 45 | 45 | function hasPages() { |
| 46 | | return (isset($this->params['search']) && $this->params['search']['pageCount'] > 1); |
| | 46 | return (isset($this->request->params['search']) && $this->request->params['search']['pageCount'] > 1); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | function hasPrev() { |
| 50 | | if (isset($this->params['search']) && |
| 51 | | $this->params['search']['prevPage']) { |
| | 50 | if (isset($this->request->params['search']) && |
| | 51 | $this->request->params['search']['prevPage']) { |
| 52 | 52 | return true; |
| 53 | 53 | } |
| … |
… |
|
| 56 | 56 | |
| 57 | 57 | function prev() { |
| 58 | | if (!isset($this->params['search']) || |
| 59 | | !$this->params['search']['prevPage']) { |
| | 58 | if (!isset($this->request->params['search']) || |
| | 59 | !$this->request->params['search']['prevPage']) { |
| 60 | 60 | return false; |
| 61 | 61 | } |
| 62 | | $prev = $this->params['search']['page'] - 1; |
| 63 | | $crumbs = $this->params['crumbs']; |
| | 62 | $prev = $this->request->params['search']['page'] - 1; |
| | 63 | $crumbs = $this->request->params['crumbs']; |
| 64 | 64 | $link = $this->Breadcrumb->crumbUrl($this->Breadcrumb->replace($crumbs, 'page', $prev)); |
| 65 | 65 | return $this->Html->link(__('prev'), $link, array('class' => 'prev')); |
| … |
… |
|
| 67 | 67 | |
| 68 | 68 | function numbers() { |
| 69 | | if (!isset($this->params['search'])) { |
| | 69 | if (!isset($this->request->params['search'])) { |
| 70 | 70 | return; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | | $params = $this->params['search']; |
| 74 | | $crumbs = $this->params['crumbs']; |
| | 73 | $params = $this->request->params['search']; |
| | 74 | $crumbs = $this->request->params['crumbs']; |
| 75 | 75 | $output = ''; |
| 76 | 76 | |
| … |
… |
|
| 98 | 98 | |
| 99 | 99 | function hasNext() { |
| 100 | | if (isset($this->params['search']) && |
| 101 | | $this->params['search']['nextPage']) { |
| | 100 | if (isset($this->request->params['search']) && |
| | 101 | $this->request->params['search']['nextPage']) { |
| 102 | 102 | return true; |
| 103 | 103 | } |
| … |
… |
|
| 106 | 106 | |
| 107 | 107 | function next() { |
| 108 | | if (!isset($this->params['search']) || |
| 109 | | !$this->params['search']['nextPage']) { |
| | 108 | if (!isset($this->request->params['search']) || |
| | 109 | !$this->request->params['search']['nextPage']) { |
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | | $next = $this->params['search']['page'] + 1; |
| 113 | | $crumbs = $this->params['crumbs']; |
| | 112 | $next = $this->request->params['search']['page'] + 1; |
| | 113 | $crumbs = $this->request->params['crumbs']; |
| 114 | 114 | $link = $this->Breadcrumb->crumbUrl($this->Breadcrumb->replace($crumbs, 'page', $next)); |
| 115 | 115 | return $this->Html->link(__('next'), $link, array('class' => 'next')); |
| … |
… |
|
| 117 | 117 | |
| 118 | 118 | function hasPrevMedia() { |
| 119 | | return !empty($this->params['search']['prevMedia']); |
| | 119 | return !empty($this->request->params['search']['prevMedia']); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | function prevMedia() { |
| 123 | | if (!isset($this->params['search']) || |
| 124 | | !$this->params['search']['prevMedia']) { |
| | 123 | if (!isset($this->request->params['search']) || |
| | 124 | !$this->request->params['search']['prevMedia']) { |
| 125 | 125 | return; |
| 126 | 126 | } |
| 127 | | $params = $this->params['search']; |
| 128 | | $crumbs = $this->params['crumbs']; |
| | 127 | $params = $this->request->params['search']; |
| | 128 | $crumbs = $this->request->params['crumbs']; |
| 129 | 129 | $pos = $this->Search->getPos(1) - 1; |
| 130 | 130 | $page = ceil($pos / $this->Search->getShow()); |
| 131 | 131 | $baseUri = '/images/view/'.$params['prevMedia'] . '/'; |
| 132 | | $crumbs = $this->params['crumbs']; |
| | 132 | $crumbs = $this->request->params['crumbs']; |
| 133 | 133 | $crumbParams = $this->Breadcrumb->params($this->Breadcrumb->replace($this->Breadcrumb->replace($crumbs, 'page', $page), 'pos', $pos)); |
| 134 | 134 | $link = $baseUri . $crumbParams; |
| … |
… |
|
| 137 | 137 | |
| 138 | 138 | function up() { |
| 139 | | if (!isset($this->params['search'])) { |
| | 139 | if (!isset($this->request->params['search'])) { |
| 140 | 140 | return; |
| 141 | 141 | } |
| 142 | | $params = $this->params['search']; |
| 143 | | $link = $this->Breadcrumb->crumbUrl($this->params['crumbs'], false, array('pos')); |
| | 142 | $params = $this->request->params['search']; |
| | 143 | $link = $this->Breadcrumb->crumbUrl($this->request->params['crumbs'], false, array('pos')); |
| 144 | 144 | $link .= '#media-'.$params['current']; |
| 145 | 145 | return $this->Html->link(__('overview'), $link, array('class' => 'up')); |
| … |
… |
|
| 147 | 147 | |
| 148 | 148 | function hasNextMedia() { |
| 149 | | return !empty($this->params['search']['nextMedia']); |
| | 149 | return !empty($this->request->params['search']['nextMedia']); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | function getNextMediaUrl() { |
| 153 | | $params = $this->params['search']; |
| | 153 | $params = $this->request->params['search']; |
| 154 | 154 | $pos = $this->Search->getPos(1) + 1; |
| 155 | 155 | $page = ceil($pos / $this->Search->getShow()); |
| 156 | 156 | $baseUri = '/images/view/'.$params['nextMedia'] . '/'; |
| 157 | | $crumbs = $this->params['crumbs']; |
| | 157 | $crumbs = $this->request->params['crumbs']; |
| 158 | 158 | $crumbParams = $this->Breadcrumb->params($this->Breadcrumb->replace($this->Breadcrumb->replace($crumbs, 'page', $page), 'pos', $pos)); |
| 159 | 159 | $link = $baseUri . $crumbParams; |
| … |
… |
|
| 162 | 162 | |
| 163 | 163 | function nextMedia() { |
| 164 | | if (!isset($this->params['search']) || |
| 165 | | !$this->params['search']['nextMedia']) { |
| | 164 | if (!isset($this->request->params['search']) || |
| | 165 | !$this->request->params['search']['nextMedia']) { |
| 166 | 166 | return; |
| 167 | 167 | } |
-
|
ree4c2b7f
|
r0ee680a
|
|
| 49 | 49 | * this function. All previous changes are overritten */ |
| 50 | 50 | function initialize($config = array()) { |
| 51 | | if (isset($this->params['search'])) { |
| 52 | | $params = $this->params['search']; |
| | 51 | if (isset($this->request->params['search'])) { |
| | 52 | $params = $this->request->params['search']; |
| 53 | 53 | $this->_data = $params['data']; |
| 54 | 54 | $this->config['baseUri'] = $params['baseUri']; |