2acc04af1dc431edfb18b0869ebacb9247da792b
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
28 * Base class for most search forms
30 class CRM_Core_Form_Search
extends CRM_Core_Form
{
33 * Are we forced to run a search
41 * name of search button
46 protected $_searchButtonName;
49 * name of action button
54 protected $_actionButtonName;
57 * form values that we will be using
65 * have we already done this search
73 * what context are we being invoked from
78 protected $_context = NULL;
81 * Common buildform tasks required by all searches
83 function buildQuickform() {
84 $resources = CRM_Core_Resources
::singleton();
86 if ($resources->ajaxPopupsEnabled
) {
87 $resources->addScriptFile('civicrm', 'js/crm.livePage.js');
88 // Script needed by some popups
89 $this->assign('includeWysiwygEditor', TRUE);
92 $resources->addScriptFile('civicrm', 'js/crm.searchForm.js');
94 $this->addButtons(array(
97 'name' => ts('Search'),
102 $this->addClass('crm-search-form');
106 * Add checkboxes for each row plus a master checkbox
108 function addRowSelectors($rows) {
109 $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows'));
110 foreach ($rows as $row) {
111 $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('class' => 'select-row'));
116 * Add actions menu to search results form
119 function addTaskMenu($tasks) {
120 if (is_array($tasks) && !empty($tasks)) {
121 $tasks = array('' => ts('Actions')) +
$tasks;
122 $this->add('select', 'task', NULL, $tasks, FALSE, array('class' => 'crm-select2 crm-action-menu huge crm-search-result-actions'));
123 $this->add('submit', $this->_actionButtonName
, ts('Go'), array('class' => 'hiddenElement crm-search-go-button'));
125 // Radio to choose "All items" or "Selected items only"
126 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
127 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
128 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
129 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);