Skip to content

Commit

Permalink
getPage 1.2.4-pl
Browse files Browse the repository at this point in the history
Merge branch 'develop'

* develop:
  Bump version for 1.2.4-pl release
  Cache total results number into correct variable name
  Fix for previous commit. (:
  Fix: multiple using of getPage overwites cache
  • Loading branch information
opengeek committed Mar 25, 2014
2 parents 83eebfa + ab2d0c9 commit ec41b57
Showing 4 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions _build/build.transport.php
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
*
* @package getpage
* @subpackage build
* @version 1.2.3-pl
* @version 1.2.4-pl
* @author Jason Coward <[email protected]>
*/
$mtime = microtime();
@@ -25,7 +25,7 @@

/* package defines */
define('PKG_NAME','getPage');
define('PKG_VERSION','1.2.3');
define('PKG_VERSION','1.2.4');
define('PKG_RELEASE','pl');
define('PKG_LNAME',strtolower(PKG_NAME));

7 changes: 6 additions & 1 deletion core/components/getpage/docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Changelog for getPage.

getPage 1.2.4-pl (March 24, 2014)
====================================
- [#19] Add scriptProperties to cachePageKey signature
- [#24] Cache total results number into correct variable name

getPage 1.2.3-pl (June 20, 2012)
====================================
- [#15] Add ability to specify pageNavScheme for navigation links
@@ -43,4 +48,4 @@ getPage 1.0.0-beta2 (May 28, 2010)

getPage 1.0.0-beta1 (March 19, 2010)
====================================
- Initial release
- Initial release
6 changes: 3 additions & 3 deletions core/components/getpage/docs/readme.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
--------------------
Snippet: getPage
--------------------
Version: 1.2.3-pl
Released: June 20, 2012
Version: 1.2.4-pl
Released: March 24, 2014
Since: March 19, 2010
Author: Jason Coward <[email protected]>

A generic wrapper snippet for returning paged results and navigation from snippets that return limitable collections. This release requires MODX Revolution 2.1+.

Official Documentation:
http://rtfm.modx.com/display/ADDON/getPage
http://rtfm.modx.com/display/ADDON/getPage
16 changes: 8 additions & 8 deletions core/components/getpage/snippet.getpage.php
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
}
$properties['offset'] = (!empty($properties['limit']) && !empty($properties['page'])) ? ($properties['limit'] * ($properties['page'] - 1)) : 0;
$properties['totalVar'] = empty($totalVar) ? "total" : $totalVar;
$properties['total'] = !empty($properties['total']) && $total = intval($properties['total']) ? $total : 0;
$properties[$properties['totalVar']] = !empty($properties[$properties['totalVar']]) && $total = intval($properties[$properties['totalVar']]) ? $total : 0;
$properties['pageOneLimit'] = (!empty($pageOneLimit) && $pageOneLimit = intval($pageOneLimit)) ? $pageOneLimit : $properties['limit'];
$properties['actualLimit'] = $properties['limit'];
$properties['pageLimit'] = isset($pageLimit) && is_numeric($pageLimit) ? intval($pageLimit) : 5;
@@ -40,7 +40,7 @@
}

if ($properties['cache']) {
$properties['cachePageKey'] = $modx->resource->getCacheKey() . '/' . $properties['page'] . '/' . md5(http_build_query($modx->request->getParameters()));
$properties['cachePageKey'] = $modx->resource->getCacheKey() . '/' . $properties['page'] . '/' . md5(http_build_query($modx->request->getParameters()) . http_build_query($scriptProperties));
$properties['cacheOptions'] = array(
xPDO::OPT_CACHE_KEY => $properties[xPDO::OPT_CACHE_KEY],
xPDO::OPT_CACHE_HANDLER => $properties[xPDO::OPT_CACHE_HANDLER],
@@ -71,18 +71,18 @@
$properties['qs'] =& $qs;

$totalSet = $modx->getPlaceholder($properties['totalVar']);
$properties['total'] = (($totalSet = intval($totalSet)) ? $totalSet : $properties['total']);
if (!empty($properties['total']) && !empty($properties['actualLimit'])) {
$properties[$properties['totalVar']] = (($totalSet = intval($totalSet)) ? $totalSet : $properties[$properties['totalVar']]);
if (!empty($properties[$properties['totalVar']]) && !empty($properties['actualLimit'])) {
if ($properties['pageOneLimit'] !== $properties['actualLimit']) {
$adjustedTotal = $properties['total'] - $properties['pageOneLimit'];
$adjustedTotal = $properties[$properties['totalVar']] - $properties['pageOneLimit'];
$properties['pageCount'] = $adjustedTotal > 0 ? ceil($adjustedTotal / $properties['actualLimit']) + 1 : 1;
} else {
$properties['pageCount'] = ceil($properties['total'] / $properties['actualLimit']);
$properties['pageCount'] = ceil($properties[$properties['totalVar']] / $properties['actualLimit']);
}
} else {
$properties['pageCount'] = 1;
}
if (empty($properties['total']) || empty($properties['actualLimit']) || $properties['total'] <= $properties['actualLimit'] || ($properties['page'] == 1 && $properties['total'] <= $properties['pageOneLimit'])) {
if (empty($properties[$properties['totalVar']]) || empty($properties['actualLimit']) || $properties[$properties['totalVar']] <= $properties['actualLimit'] || ($properties['page'] == 1 && $properties[$properties['totalVar']] <= $properties['pageOneLimit'])) {
$properties['page'] = 1;
} else {
$pageNav = getpage_buildControls($modx, $properties);
@@ -91,7 +91,7 @@
$qs[$properties['pageVarKey']] = $properties['page'];
}
}

$properties['firstItem'] = $properties['offset'] + 1;
$properties['lastItem'] = ($properties['offset'] + $properties['limit']) < $totalSet ? ($properties['offset'] + $properties['limit']) : $totalSet;

0 comments on commit ec41b57

Please sign in to comment.