CRM-13863 - Fix wysiwyg in searchForm popups and make a parent class so this stuff...
authorColeman Watts <coleman@civicrm.org>
Wed, 19 Mar 2014 20:09:50 +0000 (16:09 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 19 Mar 2014 20:09:50 +0000 (16:09 -0400)
CRM/Activity/Form/Search.php
CRM/Campaign/Form/Search.php
CRM/Case/Form/Search.php
CRM/Contact/Form/Search.php
CRM/Contribute/Form/Search.php
CRM/Core/Form/Search.php [new file with mode: 0644]
CRM/Event/Form/Search.php
CRM/Grant/Form/Search.php
CRM/Member/Form/Search.php
CRM/Pledge/Form/Search.php

index 315a14aaecfdcfd08dd0a00b5e01feeaf0efcd6d..13624426e9000885d863fe72e033ef069ae08828 100644 (file)
@@ -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,
-        ),
-      ));
   }
 
   /**
index c00be64fffe2bfe5546fd280e12d07a111e6eeb7..865576756514793cfaa1b1ce760de3a9c2161550 100755 (executable)
@@ -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,
-        ),
-      )
-    );
   }
 
   /**
index bdec2c5f321a945816c5b59df4d90cc58c6a590f..405fa510a1abf52f23a1b259b76265b8c04163c3 100644 (file)
@@ -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,
-        ),
-      ));
   }
 
   /**
index ae34675f611747cb7e4ae09cb8c6e56ca1d5be9b..a82bdce83fce630e3abf898ce6e2040d55102dd0 100644 (file)
@@ -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');
   }
 
   /**
index 9af148eb673ebfb4de893cf16c50b78e7e1c4a58..f11aaeee110c5ef7af9965fee858808cd0ec347c 100644 (file)
@@ -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 (file)
index 0000000..790d59e
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007.                                       |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License along with this program; if not, contact CiviCRM LLC       |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | 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
+ */
+class CRM_Core_Form_Search extends CRM_Core_Form {
+
+  function buildQuickform() {
+    $resources = CRM_Core_Resources::singleton();
+
+    if ($resources->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,
+      ),
+    ));
+  }
+}
index bd707d7498f266a16aee7c163eb1bd10db7438cf..412563ae6855880e9a90cbc4b39c4d34de055117 100644 (file)
@@ -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,
-        ),
-      ));
   }
 
   /**
index ec286c1516b4971c71af73a06690c375a48f0882..79dfc7c267caaedbc215c5393d37f60e9cd98ba3 100644 (file)
@@ -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,
-        ),
-      ));
   }
 
   /**
index f4c6e9638a8e295978ee4c4ff55e36126308be4d..2634e1b678e64209ffb64a66d2f4435d2b91b59c 100644 (file)
@@ -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,
-        ),
-      ));
   }
 
   /**
index 3986a579638a3dccd08d0ae7f86e1199e088c88e..dbe955d3dc8d7e6a67bc31ba08c2e27602acaac8 100644 (file)
@@ -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,
-        ),
-      ));
   }
 
   /**