From 3efb5b86007aee4130c6842a2d3b6bb1561e28cc Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 19 Mar 2014 16:09:50 -0400 Subject: [PATCH] CRM-13863 - Fix wysiwyg in searchForm popups and make a parent class so this stuff is easier to deal with --- CRM/Activity/Form/Search.php | 13 ++------- CRM/Campaign/Form/Search.php | 14 ++-------- CRM/Case/Form/Search.php | 13 ++------- CRM/Contact/Form/Search.php | 16 ++--------- CRM/Contribute/Form/Search.php | 14 ++-------- CRM/Core/Form/Search.php | 51 ++++++++++++++++++++++++++++++++++ CRM/Event/Form/Search.php | 13 ++------- CRM/Grant/Form/Search.php | 13 ++------- CRM/Member/Form/Search.php | 14 ++-------- CRM/Pledge/Form/Search.php | 13 ++------- 10 files changed, 69 insertions(+), 105 deletions(-) create mode 100644 CRM/Core/Form/Search.php diff --git a/CRM/Activity/Form/Search.php b/CRM/Activity/Form/Search.php index 315a14aaec..13624426e9 100644 --- a/CRM/Activity/Form/Search.php +++ b/CRM/Activity/Form/Search.php @@ -39,7 +39,7 @@ /** * This file is for activity search */ -class CRM_Activity_Form_Search extends CRM_Core_Form { +class CRM_Activity_Form_Search extends CRM_Core_Form_Search { /** * Are we forced to run a search @@ -223,6 +223,7 @@ class CRM_Activity_Form_Search extends CRM_Core_Form { * @return void */ function buildQuickForm() { + parent::buildQuickForm(); $this->addElement('text', 'sort_name', ts('Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); CRM_Activity_BAO_Query::buildSearchForm($this); @@ -234,8 +235,6 @@ class CRM_Activity_Form_Search extends CRM_Core_Form { $rows = $this->get('rows'); if (is_array($rows)) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js'); if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows') @@ -268,14 +267,6 @@ class CRM_Activity_Form_Search extends CRM_Core_Form { ); } - // add buttons - $this->addButtons(array( - array( - 'type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - )); } /** diff --git a/CRM/Campaign/Form/Search.php b/CRM/Campaign/Form/Search.php index c00be64fff..8655767565 100755 --- a/CRM/Campaign/Form/Search.php +++ b/CRM/Campaign/Form/Search.php @@ -36,7 +36,7 @@ /** * Files required */ -class CRM_Campaign_Form_Search extends CRM_Core_Form { +class CRM_Campaign_Form_Search extends CRM_Core_Form_Search { /** * Are we forced to run a search @@ -249,6 +249,7 @@ class CRM_Campaign_Form_Search extends CRM_Core_Form { * @return void */ function buildQuickForm() { + parent::buildQuickForm(); //build the search form. CRM_Campaign_BAO_Query::buildSearchForm($this); @@ -260,8 +261,6 @@ class CRM_Campaign_Form_Search extends CRM_Core_Form { $rows = $this->get('rows'); if (is_array($rows)) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js'); if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows')); foreach ($rows as $row) { @@ -313,15 +312,6 @@ class CRM_Campaign_Form_Search extends CRM_Core_Form { $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );")); } - // add buttons - $this->addButtons(array( - array( - 'type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - ) - ); } /** diff --git a/CRM/Case/Form/Search.php b/CRM/Case/Form/Search.php index bdec2c5f32..405fa510a1 100644 --- a/CRM/Case/Form/Search.php +++ b/CRM/Case/Form/Search.php @@ -36,7 +36,7 @@ /** * This file is for Case search */ -class CRM_Case_Form_Search extends CRM_Core_Form { +class CRM_Case_Form_Search extends CRM_Core_Form_Search { /** * Are we forced to run a search @@ -227,6 +227,7 @@ class CRM_Case_Form_Search extends CRM_Core_Form { * @return void */ function buildQuickForm() { + parent::buildQuickForm(); $this->addElement('text', 'sort_name', ts('Client Name or Email'), @@ -241,8 +242,6 @@ class CRM_Case_Form_Search extends CRM_Core_Form { */ $rows = $this->get('rows'); if (is_array($rows)) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js'); if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', @@ -286,14 +285,6 @@ class CRM_Case_Form_Search extends CRM_Core_Form { $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );")); } - // add buttons - $this->addButtons(array( - array( - 'type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - )); } /** diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index ae34675f61..a82bdce83f 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -41,7 +41,7 @@ * Base Search / View form for *all* listing of multiple * contacts */ -class CRM_Contact_Form_Search extends CRM_Core_Form { +class CRM_Contact_Form_Search extends CRM_Core_Form_Search { /* * list of valid contexts @@ -371,9 +371,8 @@ class CRM_Contact_Form_Search extends CRM_Core_Form { * @return void */ function buildQuickForm() { + parent::buildQuickForm(); CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'js/crm.livePage.js') - ->addScriptFile('civicrm', 'js/crm.searchForm.js') // jsTree is needed for tags popup ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE) ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header'); @@ -545,17 +544,6 @@ class CRM_Contact_Form_Search extends CRM_Core_Form { $this->assign_by_ref('unselectedContactIds', $unselectedContactIds); } - // add buttons - $this->addButtons(array( - array( - 'type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - ) - ); - - $this->setDefaultAction('refresh'); } /** diff --git a/CRM/Contribute/Form/Search.php b/CRM/Contribute/Form/Search.php index 9af148eb67..f11aaeee11 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -40,7 +40,7 @@ /** * advanced search, extends basic search */ -class CRM_Contribute_Form_Search extends CRM_Core_Form { +class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { /** * Are we forced to run a search @@ -229,6 +229,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form { * @return void */ function buildQuickForm() { + parent::buildQuickForm(); // text for sort_name $this->addElement('text', 'sort_name', @@ -265,8 +266,6 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form { $rows = $this->get('rows'); if (is_array($rows)) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js'); if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', @@ -306,15 +305,6 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form { $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );")); } - // add buttons - $this->addButtons(array( - array( - 'type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - ) - ); } /** diff --git a/CRM/Core/Form/Search.php b/CRM/Core/Form/Search.php new file mode 100644 index 0000000000..790d59ec06 --- /dev/null +++ b/CRM/Core/Form/Search.php @@ -0,0 +1,51 @@ +ajaxPopupsEnabled) { + $resources->addScriptFile('civicrm', 'js/crm.livePage.js'); + // Script needed by some popups + $this->assign('includeWysiwygEditor', TRUE); + } + + $resources->addScriptFile('civicrm', 'js/crm.searchForm.js'); + + $this->addButtons(array( + array( + 'type' => 'refresh', + 'name' => ts('Search'), + 'isDefault' => TRUE, + ), + )); + } +} diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index bd707d7498..412563ae68 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -40,7 +40,7 @@ /** * This file is for civievent search */ -class CRM_Event_Form_Search extends CRM_Core_Form { +class CRM_Event_Form_Search extends CRM_Core_Form_Search { /** * Are we forced to run a search @@ -224,6 +224,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form { * @return void */ function buildQuickForm() { + parent::buildQuickForm(); $this->addElement('text', 'sort_name', ts('Participant Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); CRM_Event_BAO_Query::buildSearchForm($this); @@ -234,8 +235,6 @@ class CRM_Event_Form_Search extends CRM_Core_Form { */ $rows = $this->get('rows'); if (is_array($rows)) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js'); $lineItems = $eventIds = array(); if (!$this->_single) { $this->addElement('checkbox', @@ -322,14 +321,6 @@ class CRM_Event_Form_Search extends CRM_Core_Form { ); } - // add buttons - $this->addButtons(array( - array( - 'type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - )); } /** diff --git a/CRM/Grant/Form/Search.php b/CRM/Grant/Form/Search.php index ec286c1516..79dfc7c267 100644 --- a/CRM/Grant/Form/Search.php +++ b/CRM/Grant/Form/Search.php @@ -40,7 +40,7 @@ /** * This file is for civigrant search */ -class CRM_Grant_Form_Search extends CRM_Core_Form { +class CRM_Grant_Form_Search extends CRM_Core_Form_Search { /** * Are we forced to run a search @@ -216,6 +216,7 @@ class CRM_Grant_Form_Search extends CRM_Core_Form { * @return void */ function buildQuickForm() { + parent::buildQuickForm(); $this->addElement('text', 'sort_name', ts('Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); CRM_Grant_BAO_Query::buildSearchForm($this); @@ -228,8 +229,6 @@ class CRM_Grant_Form_Search extends CRM_Core_Form { $rows = $this->get('rows'); if (is_array($rows)) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js'); if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onchange' => "toggleTaskAction( true );", 'class' => 'select-rows')); foreach ($rows as $row) { @@ -264,14 +263,6 @@ class CRM_Grant_Form_Search extends CRM_Core_Form { $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onchange' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );")); } - // add buttons - $this->addButtons(array( - array( - 'type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - )); } /** diff --git a/CRM/Member/Form/Search.php b/CRM/Member/Form/Search.php index f4c6e9638a..2634e1b678 100644 --- a/CRM/Member/Form/Search.php +++ b/CRM/Member/Form/Search.php @@ -40,7 +40,7 @@ /** * This file is for civimember search */ -class CRM_Member_Form_Search extends CRM_Core_Form { +class CRM_Member_Form_Search extends CRM_Core_Form_Search { /** * Are we forced to run a search @@ -213,6 +213,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form { * @return void */ function buildQuickForm() { + parent::buildQuickForm(); $this->addElement('text', 'sort_name', ts('Member Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); CRM_Member_BAO_Query::buildSearchForm($this); @@ -224,8 +225,6 @@ class CRM_Member_Form_Search extends CRM_Core_Form { $rows = $this->get('rows'); if (is_array($rows)) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js'); if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows')); foreach ($rows as $row) { @@ -255,15 +254,6 @@ class CRM_Member_Form_Search extends CRM_Core_Form { $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );")); } - - // add buttons - $this->addButtons(array( - array( - 'type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - )); } /** diff --git a/CRM/Pledge/Form/Search.php b/CRM/Pledge/Form/Search.php index 3986a57963..dbe955d3dc 100644 --- a/CRM/Pledge/Form/Search.php +++ b/CRM/Pledge/Form/Search.php @@ -36,7 +36,7 @@ /** * This file is for Pledge search */ -class CRM_Pledge_Form_Search extends CRM_Core_Form { +class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { /** * Are we forced to run a search @@ -212,6 +212,7 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form { * @return void */ function buildQuickForm() { + parent::buildQuickForm(); $this->addElement('text', 'sort_name', ts('Pledger Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); CRM_Pledge_BAO_Query::buildSearchForm($this); @@ -222,8 +223,6 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form { */ $rows = $this->get('rows'); if (is_array($rows)) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js'); if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows')); @@ -255,14 +254,6 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form { $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );")); } - // add buttons - $this->addButtons(array( - array( - 'type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - )); } /** -- 2.25.1