Cleanup phpdoc comments
[civicrm-core.git] / CRM / Utils / Pager.php
index cc92c5b397dfbe389327cb3f3cc8d503e492ed25..feab68279a7c86bd8b63de3e6782af6abf979ee3 100644 (file)
@@ -51,12 +51,12 @@ require_once 'Pager/Sliding.php';
 class CRM_Utils_Pager extends Pager_Sliding {
 
   /**
-   * constants for static parameters of the pager
+   * Constants for static parameters of the pager
    */
   CONST ROWCOUNT = 50, PAGE_ID = 'crmPID', PAGE_ID_TOP = 'crmPID', PAGE_ID_BOTTOM = 'crmPID_B', PAGE_ROWCOUNT = 'crmRowCount';
 
   /**
-   * the output of the pager. This is a name/value array with various keys
+   * The output of the pager. This is a name/value array with various keys
    * that an application could use to display the pager
    * @var array
    */
@@ -68,7 +68,7 @@ class CRM_Utils_Pager extends Pager_Sliding {
    * We have embedded some html in this class. Need to figure out how to export this
    * to the top level at some point in time
    *
-   * @param $params
+   * @param array $params
    *
    * @internal param \total $int the total count of items to be displayed
    * @internal param \currentPage $int the page currently being displayed
@@ -129,7 +129,7 @@ class CRM_Utils_Pager extends Pager_Sliding {
   }
 
   /**
-   * helper function to assign remaining pager options as good default
+   * Helper function to assign remaining pager options as good default
    * values
    *
    * @param array   $params      the set of options needed to initialize the parent
@@ -192,7 +192,7 @@ class CRM_Utils_Pager extends Pager_Sliding {
    *
    * @param int $defaultPageId defaultPageId   current pageId
    *
-   * @param $params
+   * @param array $params
    *
    * @return int                new pageId to display to the user
    * @access public
@@ -281,13 +281,9 @@ class CRM_Utils_Pager extends Pager_Sliding {
     if ($this->isFirstPage()) {
       return '';
     }
-
     $href = $this->makeURL(self::PAGE_ID, 1);
-    return sprintf('<a class="crm-pager-link" href="%s" title="%s">%s</a>',
-      $href,
-      str_replace('%d', 1, $this->_altFirst),
-      $this->_firstPagePre . $this->_firstPageText . $this->_firstPagePost
-    ) . $this->_spacesBefore . $this->_spacesAfter;
+    return $this->formatLink($href, str_replace('%d', 1, $this->_altFirst), $this->_firstPagePre . $this->_firstPageText . $this->_firstPagePost) .
+      $this->_spacesBefore . $this->_spacesAfter;
   }
 
   /**
@@ -297,13 +293,8 @@ class CRM_Utils_Pager extends Pager_Sliding {
     if ($this->isLastPage()) {
       return '';
     }
-
     $href = $this->makeURL(self::PAGE_ID, $this->_totalPages);
-    return sprintf('<a class="crm-pager-link" href="%s" title="%s">%s</a>',
-      $href,
-      str_replace('%d', $this->_totalPages, $this->_altLast),
-      $this->_lastPagePre . $this->_lastPageText . $this->_lastPagePost
-    );
+    return $this->formatLink($href, str_replace('%d', $this->_totalPages, $this->_altLast), $this->_lastPagePre . $this->_lastPageText . $this->_lastPagePost);
   }
 
   /**
@@ -312,10 +303,7 @@ class CRM_Utils_Pager extends Pager_Sliding {
   function getBackPageLink() {
     if ($this->_currentPage > 1) {
       $href = $this->makeURL(self::PAGE_ID, $this->getPreviousPageID());
-      return sprintf('<a class="crm-pager-link" href="%s" title="%s">%s</a>',
-        $href,
-        $this->_altPrev, $this->_prevImg
-      ) . $this->_spacesBefore . $this->_spacesAfter;
+      return $this->formatLink($href, $this->_altPrev, $this->_prevImg) . $this->_spacesBefore . $this->_spacesAfter;
     }
     return '';
   }
@@ -326,10 +314,9 @@ class CRM_Utils_Pager extends Pager_Sliding {
   function getNextPageLink() {
     if ($this->_currentPage < $this->_totalPages) {
       $href = $this->makeURL(self::PAGE_ID, $this->getNextPageID());
-      return $this->_spacesAfter . sprintf('<a class="crm-pager-link" href="%s" title="%s">%s</a>',
-        $href,
-        $this->_altNext, $this->_nextImg
-      ) . $this->_spacesBefore . $this->_spacesAfter;
+      return $this->_spacesAfter .
+        $this->formatLink($href, $this->_altNext, $this->_nextImg) .
+        $this->_spacesBefore . $this->_spacesAfter;
     }
     return '';
   }
@@ -338,12 +325,23 @@ class CRM_Utils_Pager extends Pager_Sliding {
    * Build a url for pager links
    */
   function makeURL($key, $value) {
-    $href = CRM_Utils_System::makeURL($key);
+    $href = CRM_Utils_System::makeURL($key, TRUE);
     // CRM-12212 Remove alpha sort param
     if (strpos($href, '&amp;sortByCharacter=')) {
       $href = preg_replace('#(.*)\&amp;sortByCharacter=[^&]*(.*)#', '\1\2', $href);
     }
     return $href . $value;
   }
+
+  /**
+   * Output the html pager link
+   * @param string $href
+   * @param string $title
+   * @param string $image
+   * @return string
+   */
+  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);
+  }
 }