From d674b8ead7e2ecdecb78a95d999105474f8e1939 Mon Sep 17 00:00:00 2001 From: guilhermeblanco Date: Thu, 21 Feb 2008 16:06:46 +0000 Subject: [PATCH] Added Doctrine_Pager_Range::isInRange, which checks if a given page is in the range --- lib/Doctrine/Pager/Range.php | 14 ++++++++++++++ .../pagination/controlling-range-styles.txt | 3 +++ 2 files changed, 17 insertions(+) diff --git a/lib/Doctrine/Pager/Range.php b/lib/Doctrine/Pager/Range.php index f3a0771ed..396cebfb1 100644 --- a/lib/Doctrine/Pager/Range.php +++ b/lib/Doctrine/Pager/Range.php @@ -141,6 +141,20 @@ abstract class Doctrine_Pager_Range } + /** + * isInRange + * + * Check if a given page is in the range + * + * @param $page Page to be checked + * @return boolean + */ + public function isInRange($page) + { + return (array_search($page, $this->rangeAroundPage()) !== false); + } + + /** * _initialize * diff --git a/manual/docs/en/utilities/pagination/controlling-range-styles.txt b/manual/docs/en/utilities/pagination/controlling-range-styles.txt index f74be3d4a..ba3070901 100644 --- a/manual/docs/en/utilities/pagination/controlling-range-styles.txt +++ b/manual/docs/en/utilities/pagination/controlling-range-styles.txt @@ -75,6 +75,9 @@ $pager_range->getOptions(); // Returns the custom Doctrine_Pager_Range implementation offset option $pager_range->getOption($option); +// Check if a given page is in the range +$pager_range->isInRange($page); + // Return the range around the current page (obtained from Doctrine_Pager // associated to the $pager_range instance) $pager_range->rangeAroundPage();