Merge pull request #5580 from eileenmcnaughton/CRM-16247
[civicrm-core.git] / CRM / Core / Form / Search.php
index cd650775fa541bc56cbc31f61ad6bc82abdad951..9aba90f82489f07ab4f47dd399dc42b192b66a51 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.                                    |
  |                                                                    |
@@ -22,7 +22,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  * Base class for most search forms
@@ -71,6 +71,25 @@ class CRM_Core_Form_Search extends CRM_Core_Form {
    */
   protected $_context = NULL;
 
+  /**
+   * The list of tasks or actions that a searcher can perform on a result set.
+   *
+   * @var array
+   */
+  protected $_taskList = array();
+
+  /**
+   * Builds the list of tasks or actions that a searcher can perform on a result set.
+   *
+   * To modify the task list, child classes should alter $this->_taskList,
+   * preferably by extending this method.
+   *
+   * @return array
+   */
+  protected function buildTaskList() {
+    return $this->_taskList;
+  }
+
   /**
    * Common buildform tasks required by all searches
    */
@@ -82,7 +101,9 @@ class CRM_Core_Form_Search extends CRM_Core_Form {
       $this->assign('includeWysiwygEditor', TRUE);
     }
 
-    $resources->addScriptFile('civicrm', 'js/crm.searchForm.js', 1, 'html-header');
+    $resources
+      ->addScriptFile('civicrm', 'js/crm.searchForm.js', 1, 'html-header')
+      ->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
 
     $this->addButtons(array(
       array(
@@ -93,6 +114,11 @@ class CRM_Core_Form_Search extends CRM_Core_Form {
     ));
 
     $this->addClass('crm-search-form');
+
+    // for backwards compatibility we pass an argument to addTaskMenu even though
+    // it could just as well access $this->_taskList internally
+    $tasks = $this->buildTaskList();
+    $this->addTaskMenu($tasks);
   }
 
   /**
@@ -122,4 +148,5 @@ class CRM_Core_Form_Search extends CRM_Core_Form {
       $this->assign('ts_all_id', $allRowsRadio->_attributes['id']);
     }
   }
+
 }