Permalink
Browse files

MINOR Updated docblocks for GridFieldPaginator

  • Loading branch information...
1 parent ed88952 commit 07029138bf2f4c837751b831402cab2f8992bc8c @stojg stojg committed Jan 23, 2012
Showing with 50 additions and 17 deletions.
  1. +50 −17 forms/gridfield/GridFieldPaginator.php
View
67 forms/gridfield/GridFieldPaginator.php 100644 → 100755
@@ -1,35 +1,57 @@
<?php
-
/**
- * GridFieldPaginator decorates the GridFieldPresenter with the possibility to
- * paginate the GridField.
- *
- * @see GridField
+ * GridFieldPaginator paginates the gridfields list and adds controlls to the
+ * bottom of the gridfield.
*
* @package sapphire
* @subpackage fields-relational
*/
class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipulator, GridField_ActionProvider {
+ /**
+ *
+ * @var int
+ */
protected $currentPage = 1;
+ /**
+ *
+ * @var int
+ */
protected $itemsPerPage = 25;
/**
* Which template to use for rendering
*
- * @var string $itemClass
+ * @var string
*/
protected $itemClass = 'GridFieldPaginator_Row';
+ /**
+ *
+ * @param int $itemsPerPage - How many items should be displayed per page
+ */
public function __construct($itemsPerPage=25) {
$this->itemsPerPage = $itemsPerPage;
}
+ /**
+ *
+ * @param GridField $gridField
+ * @return array
+ */
public function getActions($gridField) {
return array('paginate');
}
+ /**
+ *
+ * @param GridField $gridField
+ * @param string $actionName
+ * @param string $arguments
+ * @param array $data
+ * @return void
+ */
public function handleAction(GridField $gridField, $actionName, $arguments, $data) {
if($actionName !== 'paginate') {
return;
@@ -38,17 +60,12 @@ public function handleAction(GridField $gridField, $actionName, $arguments, $dat
$this->currentPage = $state->currentPage = (int)$arguments;
}
- /** Duck check to see if list support methods we need to paginate */
- protected function getListPaginatable(SS_List $list) {
- // If no list yet, not paginatable
- if (!$list) return false;
- // Check for methods we use
- if(!method_exists($list, 'getRange')) return false;
- if(!method_exists($list, 'limit')) return false;
- // Default it true
- return true;
- }
-
+ /**
+ *
+ * @param GridField $gridField
+ * @param SS_List $dataList
+ * @return SS_List
+ */
public function getManipulatedData(GridField $gridField, SS_List $dataList) {
if(!$this->getListPaginatable($dataList)) {
return $dataList;
@@ -60,6 +77,11 @@ public function getManipulatedData(GridField $gridField, SS_List $dataList) {
return $dataList->getRange((int)$startRow, (int)$this->itemsPerPage);
}
+ /**
+ *
+ * @param GridField $gridField
+ * @return array
+ */
public function getHTMLFragments($gridField) {
Requirements::javascript(SAPPHIRE_DIR.'/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript(SAPPHIRE_DIR.'/javascript/GridField.js');
@@ -87,4 +109,15 @@ public function getHTMLFragments($gridField) {
'footer' => $forTemplate->renderWith('GridFieldPaginator_Row', array('Colspan'=>count($gridField->getColumns()))),
);
}
+
+ /** Duck check to see if list support methods we need to paginate */
+ protected function getListPaginatable(SS_List $list) {
+ // If no list yet, not paginatable
+ if (!$list) return false;
+ // Check for methods we use
+ if(!method_exists($list, 'getRange')) return false;
+ if(!method_exists($list, 'limit')) return false;
+ // Default it true
+ return true;
+ }
}

0 comments on commit 0702913

Please sign in to comment.