Merge pull request #5060 from eileenmcnaughton/api-comment-fixes
[civicrm-core.git] / CRM / Contribute / Selector / Search.php
index 153963e8a57d18a09e202ea64c46592c0ca5115e..ed22579c57b9bd8e4853903fbfae977ce286f82d 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -45,7 +45,6 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
    * This defines two actions- View and Edit.
    *
    * @var array
-   * @static
    */
   static $_links = NULL;
 
@@ -53,14 +52,12 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
    * We use desc to remind us what that column is, name is used in the tpl
    *
    * @var array
-   * @static
    */
   static $_columnHeaders;
 
   /**
    * Properties of contact we're interested in displaying
    * @var array
-   * @static
    */
   static $_properties = array(
     'contact_id',
@@ -151,33 +148,37 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
   /**
    * Class constructor
    *
-   * @param array $queryParams array of parameters for query
+   * @param array $queryParams
+   *   Array of parameters for query.
    * @param \const|int $action - action of search basic or advanced.
-   * @param string $contributionClause if the caller wants to further restrict the search (used in contributions)
-   * @param boolean $single are we dealing only with one contact?
-   * @param int $limit how many contributions do we want returned
+   * @param string $contributionClause
+   *   If the caller wants to further restrict the search (used in contributions).
+   * @param bool $single
+   *   Are we dealing only with one contact?.
+   * @param int $limit
+   *   How many contributions do we want returned.
    *
    * @param string $context
    * @param null $compContext
    *
    * @return \CRM_Contribute_Selector_Search
-  @access public
    */
-  function __construct(&$queryParams,
-    $action             = CRM_Core_Action::NONE,
+  public function __construct(
+    &$queryParams,
+    $action = CRM_Core_Action::NONE,
     $contributionClause = NULL,
-    $single             = FALSE,
-    $limit              = NULL,
-    $context            = 'search',
-    $compContext        = NULL
+    $single = FALSE,
+    $limit = NULL,
+    $context = 'search',
+    $compContext = NULL
   ) {
 
     // submitted form values
     $this->_queryParams = &$queryParams;
 
-    $this->_single      = $single;
-    $this->_limit       = $limit;
-    $this->_context     = $context;
+    $this->_single = $single;
+    $this->_limit = $limit;
+    $this->_context = $context;
     $this->_compContext = $compContext;
 
     $this->_contributionClause = $contributionClause;
@@ -198,7 +199,8 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     if ($this->_includeSoftCredits) {
       $this->_query->_rowCountClause = " count(civicrm_contribution.id)";
       $this->_query->_groupByComponentClause = " GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id ";
-    } else {
+    }
+    else {
       $this->_query->_distinctComponentClause = " civicrm_contribution.id";
       $this->_query->_groupByComponentClause = " GROUP BY civicrm_contribution.id ";
     }
@@ -278,9 +280,10 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
   /**
    * Returns total number of rows for the query.
    *
-   * @param
+   * @param string $action
    *
-   * @return int Total number of rows
+   * @return int
+   *   Total number of rows
    */
   public function getTotalCount($action) {
     return $this->_query->searchQuery(0, 0, NULL,
@@ -294,13 +297,19 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
   /**
    * Returns all the rows in the given offset and rowCount
    *
-   * @param enum   $action   the action being performed
-   * @param int    $offset   the row number to start from
-   * @param int    $rowCount the number of rows to return
-   * @param string $sort     the sql string that describes the sort order
-   * @param enum   $output   what should the result set include (web/email/csv)
+   * @param string $action
+   *   The action being performed.
+   * @param int $offset
+   *   The row number to start from.
+   * @param int $rowCount
+   *   The number of rows to return.
+   * @param string $sort
+   *   The sql string that describes the sort order.
+   * @param string $output
+   *   What should the result set include (web/email/csv).
    *
-   * @return int   the total number of rows for this action
+   * @return int
+   *   the total number of rows for this action
    */
   public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
     if ($this->_includeSoftCredits) {
@@ -329,9 +338,9 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     $qfKey = $this->_key;
     $componentId = $componentContext = NULL;
     if ($this->_context != 'contribute') {
-      $qfKey            = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
-      $componentId      = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
-      $componentAction  = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
+      $qfKey = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
+      $componentId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
+      $componentAction = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
       $componentContext = CRM_Utils_Request::retrieve('compContext', 'String', CRM_Core_DAO::$_nullObject);
 
       if (!$componentContext &&
@@ -350,7 +359,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     //get all campaigns.
     $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
 
-    While ($result->fetch()) {
+    while ($result->fetch()) {
       $row = array();
       // the columns we are interested in
       foreach (self::$_properties as $property) {
@@ -401,8 +410,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
         $result->contribution_id
       );
 
-      $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ?
-          $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id
+      $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id
       );
 
       if (!empty($row['amount_level'])) {
@@ -416,11 +424,8 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
   }
 
   /**
-   * @return array   $qill         which contains an array of strings
+   * @inheritDoc
    */
-
-  // the current internationalisation is bad, but should more or less work
-  // for most of "European" languages
   public function getQILL() {
     return $this->_query->qill();
   }
@@ -429,10 +434,13 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
    * Returns the column headers as an array of tuples:
    * (name, sortName (key to the sort array))
    *
-   * @param string $action the action being performed
-   * @param enum   $output what should the result set include (web/email/csv)
+   * @param string $action
+   *   The action being performed.
+   * @param string $output
+   *   What should the result set include (web/email/csv).
    *
-   * @return array the column headers that need to be displayed
+   * @return array
+   *   the column headers that need to be displayed
    */
   public function &getColumnHeaders($action = NULL, $output = NULL) {
     self::$_columnHeaders = array(
@@ -443,25 +451,25 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
       ),
     );
     if ($this->_includeSoftCredits) {
-      self::$_columnHeaders =
-        array_merge(
+      self::$_columnHeaders
+        array_merge(
           self::$_columnHeaders,
           array(
             array(
               'name' => ts('Soft Credit Amount'),
               'sort' => 'contribution_soft_credit_amount',
               'direction' => CRM_Utils_Sort::DONTCARE,
-            )
+            ),
           )
         );
     }
-    self::$_columnHeaders =
-      array_merge(
+    self::$_columnHeaders
+      array_merge(
         self::$_columnHeaders,
         array(
           array(
             'name' => ts('Type'),
-            'sort'      => 'financial_type',
+            'sort' => 'financial_type',
             'direction' => CRM_Utils_Sort::DONTCARE,
           ),
           array(
@@ -503,27 +511,26 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
       self::$_columnHeaders = array_merge($pre, self::$_columnHeaders);
     }
     if ($this->_includeSoftCredits) {
-      self::$_columnHeaders =
-        array_merge(
-          self::$_columnHeaders,
+      self::$_columnHeaders = array_merge(
+        self::$_columnHeaders,
+        array(
           array(
-            array(
-              'name' => ts('Soft Credit For'),
-              'sort' => 'contribution_soft_credit_name',
-              'direction' => CRM_Utils_Sort::DONTCARE,
-            ),
-            array(
-              'name' => ts('Soft Credit Type'),
-              'sort' => 'contribution_soft_credit_type',
-              'direction' => CRM_Utils_Sort::ASCENDING,
-            ),
-          )
-        );
+            'name' => ts('Soft Credit For'),
+            'sort' => 'contribution_soft_credit_name',
+            'direction' => CRM_Utils_Sort::DONTCARE,
+          ),
+          array(
+            'name' => ts('Soft Credit Type'),
+            'sort' => 'contribution_soft_credit_type',
+            'direction' => CRM_Utils_Sort::ASCENDING,
+          ),
+        )
+      );
     }
-    self::$_columnHeaders =
-      array_merge(
+    self::$_columnHeaders
+      array_merge(
         self::$_columnHeaders, array(
-          array('desc' => ts('Actions'))
+          array('desc' => ts('Actions')),
         )
       );
     return self::$_columnHeaders;
@@ -546,9 +553,11 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
   /**
    * Name of export file.
    *
-   * @param string $output type of output
+   * @param string $output
+   *   Type of output.
    *
-   * @return string name of the file
+   * @return string
+   *   name of the file
    */
   public function getExportFileName($output = 'csv') {
     return ts('CiviCRM Contribution Search');
@@ -560,4 +569,5 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
   public function getSummary() {
     return $this->_query->summaryContribution($this->_context);
   }
+
 }