From e611e12bda4372d96d1431bce40bd89482735511 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Fri, 8 May 2020 23:54:02 -0400 Subject: [PATCH] Get rid of unused CRM_Core_ShowHideBlocks::links() --- CRM/Contact/Form/CustomData.php | 7 -- CRM/Contact/Form/Edit/Individual.php | 1 - CRM/Contact/Form/Search/Criteria.php | 1 - CRM/Core/BAO/CustomGroup.php | 1 - CRM/Core/ShowHideBlocks.php | 130 --------------------------- 5 files changed, 140 deletions(-) diff --git a/CRM/Contact/Form/CustomData.php b/CRM/Contact/Form/CustomData.php index 86dc621b46..87849e1b28 100644 --- a/CRM/Contact/Form/CustomData.php +++ b/CRM/Contact/Form/CustomData.php @@ -52,13 +52,6 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { */ //protected $_groupTree; - /** - * Which blocks should we show and hide. - * - * @var CRM_Core_ShowHideBlocks - */ - protected $_showHide; - /** * Array group titles. * diff --git a/CRM/Contact/Form/Edit/Individual.php b/CRM/Contact/Form/Edit/Individual.php index 29d8dc0a5f..f4d933933a 100644 --- a/CRM/Contact/Form/Edit/Individual.php +++ b/CRM/Contact/Form/Edit/Individual.php @@ -88,7 +88,6 @@ class CRM_Contact_Form_Edit_Individual { 'objectExists', ['CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'] ); - CRM_Core_ShowHideBlocks::links($form, 'demographics', '', ''); } } diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index d4d711296c..024a8305cc 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -605,7 +605,6 @@ class CRM_Contact_Form_Search_Criteria { foreach ($groupDetails as $key => $group) { $_groupTitle[$key] = $group['name']; - CRM_Core_ShowHideBlocks::links($form, $group['name'], '', ''); foreach ($group['fields'] as $field) { $fieldId = $field['id']; diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 4dc6d36f3f..d9c3dab0e0 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -1533,7 +1533,6 @@ ORDER BY civicrm_custom_group.weight, $form->assign_by_ref("{$prefix}groupTree", $groupTree); foreach ($groupTree as $id => $group) { - CRM_Core_ShowHideBlocks::links($form, $group['title'], '', ''); foreach ($group['fields'] as $field) { $required = $field['is_required'] ?? NULL; //fix for CRM-1620 diff --git a/CRM/Core/ShowHideBlocks.php b/CRM/Core/ShowHideBlocks.php index 934eb317a3..1b4786987c 100644 --- a/CRM/Core/ShowHideBlocks.php +++ b/CRM/Core/ShowHideBlocks.php @@ -16,14 +16,6 @@ */ class CRM_Core_ShowHideBlocks { - /** - * The icons prefixed to block show and hide links. - * - * @var string - */ - public static $_showIcon; - public static $_hideIcon; - /** * The array of ids of blocks that will be shown. * @@ -64,17 +56,6 @@ class CRM_Core_ShowHideBlocks { } } - /** - * Load icon vars used in hide and show links. - */ - public static function setIcons() { - if (!isset(self::$_showIcon)) { - $config = CRM_Core_Config::singleton(); - self::$_showIcon = '' . ts('show field or section') . ''; - self::$_hideIcon = '' . ts('hide field or section') . ''; - } - } - /** * Add the values from this class to the template. */ @@ -130,115 +111,4 @@ class CRM_Core_ShowHideBlocks { } } - /** - * Create a well formatted html link from the smaller pieces. - * - * @param string $name - * Name of the link. - * @param string $href - * @param string $text - * @param string $js - * - * @return string - * the formatted html link - */ - public static function linkHtml($name, $href, $text, $js) { - return '$text"; - } - - /** - * Create links that we can use in the form. - * - * @param CRM_Core_Form $form - * The form object. - * @param string $prefix - * The attribute that we are referencing. - * @param string $showLinkText - * The text to be shown for the show link. - * @param string $hideLinkText - * The text to be shown for the hide link. - * - * @param bool $assign - * - * @return array - */ - public static function links(&$form, $prefix, $showLinkText, $hideLinkText, $assign = TRUE) { - $showCode = "if(event.preventDefault) event.preventDefault(); else event.returnValue = false; cj('#id_{$prefix}').show(); cj('#id_{$prefix}_show').hide();"; - $hideCode = "if(event.preventDefault) event.preventDefault(); else event.returnValue = false; cj('#id_{$prefix}').hide(); cj('#id_{$prefix}_show').show();"; - - self::setIcons(); - $values = []; - $values['show'] = self::linkHtml("${prefix}_show", "#${prefix}_hide", self::$_showIcon . $showLinkText, "onclick=\"$showCode\""); - $values['hide'] = self::linkHtml("${prefix}_hide", "#${prefix}", self::$_hideIcon . $hideLinkText, "onclick=\"$hideCode\""); - - if ($assign) { - $form->assign($prefix, $values); - } - else { - return $values; - } - } - - /** - * Create html link elements that we can use in the form. - * - * @param CRM_Core_Form $form - * The form object. - * @param int $index - * The current index of the element being processed. - * @param int $maxIndex - * The max number of elements that will be processed. - * @param string $prefix - * The attribute that we are referencing. - * @param string $showLinkText - * The text to be shown for the show link. - * @param string $hideLinkText - * The text to be shown for the hide link. - * @param string $elementType - * The set the class. - * @param string $hideLink - * The hide block string. - */ - public function linksForArray(&$form, $index, $maxIndex, $prefix, $showLinkText, $hideLinkText, $elementType = NULL, $hideLink = NULL) { - $showHidePrefix = str_replace(["]", "["], ["", "_"], $prefix); - $showHidePrefix = "id_" . $showHidePrefix; - if ($index == $maxIndex) { - $showCode = $hideCode = "return false;"; - } - else { - $next = $index + 1; - if ($elementType) { - $showCode = "cj('#${prefix}_${next}_show').show(); return false;"; - if ($hideLink) { - $hideCode = $hideLink; - } - else { - $hideCode = "cj('#${prefix}_${next}_show, #${prefix}_${next}').hide(); return false;"; - } - } - else { - $showCode = "cj('#{$showHidePrefix}_{$next}_show').show(); return false;"; - $hideCode = "cj('#{$showHidePrefix}_{$next}_show, #{$showHidePrefix}_{$next}').hide(); return false;"; - } - } - - self::setIcons(); - if ($elementType) { - $form->addElement('link', "${prefix}[${index}][show]", NULL, "#${prefix}_${index}", self::$_showIcon . $showLinkText, - ['onclick' => "cj('#${prefix}_${index}_show').hide(); cj('#${prefix}_${index}').show();" . $showCode] - ); - $form->addElement('link', "${prefix}[${index}][hide]", NULL, "#${prefix}_${index}", self::$_hideIcon . $hideLinkText, - ['onclick' => "cj('#${prefix}_${index}').hide(); cj('#${prefix}_${index}_show').show();" . $hideCode] - ); - } - else { - $form->addElement('link', "${prefix}[${index}][show]", NULL, "#${prefix}_${index}", self::$_showIcon . $showLinkText, - ['onclick' => "cj('#{$showHidePrefix}_{$index}_show').hide(); cj('#{$showHidePrefix}_{$index}').show();" . $showCode] - ); - $form->addElement('link', "${prefix}[${index}][hide]", NULL, "#${prefix}_${index}", self::$_hideIcon . $hideLinkText, - ['onclick' => "cj('#{$showHidePrefix}_{$index}').hide(); cj('#{$showHidePrefix}_{$index}_show').show();" . $hideCode] - ); - } - } - } -- 2.25.1