phpcs fix
[civicrm-core.git] / CRM / Utils / Pager.php
index aa184a1469bdbed757b65ea5a2431f1b7288cb63..873392017bb401cf66edc8bcee765d59c09b6c39 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -70,15 +70,7 @@ class CRM_Utils_Pager extends Pager_Sliding {
    *
    * @param array $params
    *
-   * @internal param \total $int the total count of items to be displayed
-   * @internal param \currentPage $int the page currently being displayed
-   * @internal param \status $string the status message to be displayed. It embeds a token
-   *                             %%statusMessage%% that will be replaced with which items
-   *                             are currently being displayed
-   * @internal param \csvString $string the title of the link to be displayed for the export
-   * @internal param \perPage $int the number of items displayed per page
-   *
-   * @return \CRM_Utils_Pager the newly created and initialized pager object@access public
+   * @return \CRM_Utils_Pager the newly created and initialized pager object
    */
   public function __construct($params) {
     if ($params['status'] === NULL) {
@@ -124,20 +116,26 @@ class CRM_Utils_Pager extends Pager_Sliding {
      * page variable, but a different form element for one at the bottom
      *
      */
-    $this->_response['titleTop'] = ts('Page %1 of %2', array(1 => '<input size="2" maxlength="3" name="' . self::PAGE_ID . '" type="text" value="' . $this->_response['currentPage'] . '" />', 2 => $this->_response['numPages']));
-    $this->_response['titleBottom'] = ts('Page %1 of %2', array(1 => '<input size="2" maxlength="3" name="' . self::PAGE_ID_BOTTOM . '" type="text" value="' . $this->_response['currentPage'] . '" />', 2 => $this->_response['numPages']));
+    $this->_response['titleTop'] = ts('Page %1 of %2', array(
+        1 => '<input size="2" maxlength="3" name="' . self::PAGE_ID . '" type="text" value="' . $this->_response['currentPage'] . '" />',
+        2 => $this->_response['numPages'],
+      ));
+    $this->_response['titleBottom'] = ts('Page %1 of %2', array(
+        1 => '<input size="2" maxlength="3" name="' . self::PAGE_ID_BOTTOM . '" type="text" value="' . $this->_response['currentPage'] . '" />',
+        2 => $this->_response['numPages'],
+      ));
   }
 
   /**
    * Helper function to assign remaining pager options as good default
-   * values
+   * values.
    *
-   * @param array   $params      the set of options needed to initialize the parent
+   * @param array $params
+   *   The set of options needed to initialize the parent.
    *                             constructor
    *
    *
    * @return void
-   *
    */
   public function initialize(&$params) {
     /* set the mode for the pager to Sliding */
@@ -164,7 +162,6 @@ class CRM_Utils_Pager extends Pager_Sliding {
     $params['prevImg'] = ' ' . ts('&lt; Previous');
     $params['nextImg'] = ts('Next &gt;') . ' ';
 
-
     // set first and last text fragments
     $params['firstPagePre'] = '';
     $params['firstPageText'] = ' ' . ts('&lt;&lt; First');
@@ -189,11 +186,13 @@ class CRM_Utils_Pager extends Pager_Sliding {
    * POST over-rides a GET, a POST at the top overrides
    * a POST at the bottom (of the page)
    *
-   * @param int $defaultPageId defaultPageId   current pageId
+   * @param int $defaultPageId
+   *   DefaultPageId current pageId.
    *
    * @param array $params
    *
-   * @return int                new pageId to display to the user
+   * @return int
+   *   new pageId to display to the user
    */
   public function getPageID($defaultPageId = 1, &$params) {
     // POST has higher priority than GET vars
@@ -201,20 +200,20 @@ class CRM_Utils_Pager extends Pager_Sliding {
     $currentPage = $defaultPageId;
     if (!empty($_POST)) {
       if (isset($_POST[CRM_Utils_Array::value('buttonTop', $params)]) && isset($_POST[self::PAGE_ID])) {
-        $currentPage = max((int )@$_POST[self::PAGE_ID], 1);
+        $currentPage = max((int ) @$_POST[self::PAGE_ID], 1);
       }
       elseif (isset($_POST[$params['buttonBottom']]) && isset($_POST[self::PAGE_ID_BOTTOM])) {
-        $currentPage = max((int )@$_POST[self::PAGE_ID_BOTTOM], 1);
+        $currentPage = max((int ) @$_POST[self::PAGE_ID_BOTTOM], 1);
       }
       elseif (isset($_POST[self::PAGE_ID])) {
-        $currentPage = max((int )@$_POST[self::PAGE_ID], 1);
+        $currentPage = max((int ) @$_POST[self::PAGE_ID], 1);
       }
       elseif (isset($_POST[self::PAGE_ID_BOTTOM])) {
-        $currentPage = max((int )@$_POST[self::PAGE_ID_BOTTOM]);
+        $currentPage = max((int ) @$_POST[self::PAGE_ID_BOTTOM]);
       }
     }
     elseif (isset($_GET[self::PAGE_ID])) {
-      $currentPage = max((int )@$_GET[self::PAGE_ID], 1);
+      $currentPage = max((int ) @$_GET[self::PAGE_ID], 1);
     }
     return $currentPage;
   }
@@ -222,18 +221,19 @@ class CRM_Utils_Pager extends Pager_Sliding {
   /**
    * Get the number of rows to display from either a GET / POST variable
    *
-   * @param int $defaultPageRowCount the default value if not set
-   *
-   * @return int                     the rowCount value to use
+   * @param int $defaultPageRowCount
+   *   The default value if not set.
    *
+   * @return int
+   *   the rowCount value to use
    */
   public function getPageRowCount($defaultPageRowCount = self::ROWCOUNT) {
     // POST has higher priority than GET vars
     if (isset($_POST[self::PAGE_ROWCOUNT])) {
-      $rowCount = max((int )@$_POST[self::PAGE_ROWCOUNT], 1);
+      $rowCount = max((int ) @$_POST[self::PAGE_ROWCOUNT], 1);
     }
     elseif (isset($_GET[self::PAGE_ROWCOUNT])) {
-      $rowCount = max((int )@$_GET[self::PAGE_ROWCOUNT], 1);
+      $rowCount = max((int ) @$_GET[self::PAGE_ROWCOUNT], 1);
     }
     else {
       $rowCount = $defaultPageRowCount;
@@ -242,13 +242,10 @@ class CRM_Utils_Pager extends Pager_Sliding {
   }
 
   /**
-   * Use the pager class to get the pageId and Offset
-   *
-   * @param void
-   *
-   * @return array: an array of the pageID and offset
-   *
+   * Use the pager class to get the pageId and Offset.
    *
+   * @return array
+   *   an array of the pageID and offset
    */
   public function getOffsetAndRowCount() {
     $pageId = $this->getCurrentPageID();
@@ -279,7 +276,7 @@ class CRM_Utils_Pager extends Pager_Sliding {
     }
     $href = $this->makeURL(self::PAGE_ID, 1);
     return $this->formatLink($href, str_replace('%d', 1, $this->_altFirst), $this->_firstPagePre . $this->_firstPageText . $this->_firstPagePost) .
-      $this->_spacesBefore . $this->_spacesAfter;
+    $this->_spacesBefore . $this->_spacesAfter;
   }
 
   /**
@@ -311,14 +308,14 @@ class CRM_Utils_Pager extends Pager_Sliding {
     if ($this->_currentPage < $this->_totalPages) {
       $href = $this->makeURL(self::PAGE_ID, $this->getNextPageID());
       return $this->_spacesAfter .
-        $this->formatLink($href, $this->_altNext, $this->_nextImg) .
-        $this->_spacesBefore . $this->_spacesAfter;
+      $this->formatLink($href, $this->_altNext, $this->_nextImg) .
+      $this->_spacesBefore . $this->_spacesAfter;
     }
     return '';
   }
 
   /**
-   * Build a url for pager links
+   * Build a url for pager links.
    */
   public function makeURL($key, $value) {
     $href = CRM_Utils_System::makeURL($key, TRUE);
@@ -330,7 +327,7 @@ class CRM_Utils_Pager extends Pager_Sliding {
   }
 
   /**
-   * Output the html pager link
+   * Output the html pager link.
    * @param string $href
    * @param string $title
    * @param string $image
@@ -339,4 +336,5 @@ class CRM_Utils_Pager extends Pager_Sliding {
   private function formatLink($href, $title, $image) {
     return sprintf('<a class="crm-pager-link action-item crm-hover-button" href="%s" title="%s">%s</a>', $href, $title, $image);
   }
+
 }