From a452aa99d33bb6e2d570c6c107774e80f8730fa9 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 2 Apr 2022 12:13:47 -0400 Subject: [PATCH] Update contactType form to support icons and deprecate image_URL --- CRM/Admin/Form/ContactType.php | 15 ++++++++++++++- templates/CRM/Admin/Form/ContactType.tpl | 15 ++++++++++++--- templates/CRM/Admin/Page/ContactType.hlp | 12 ------------ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/CRM/Admin/Form/ContactType.php b/CRM/Admin/Form/ContactType.php index ac90dbeace..386bd4785c 100644 --- a/CRM/Admin/Form/ContactType.php +++ b/CRM/Admin/Form/ContactType.php @@ -51,7 +51,15 @@ class CRM_Admin_Form_ContactType extends CRM_Admin_Form { $enabled->freeze(); } } - $this->addElement('text', 'image_URL', ts('Image URL')); + // TODO: Remove when dropping image_URL column + if ($this->_id) { + $imageUrl = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $this->_id, 'image_URL'); + if ($imageUrl) { + $this->addElement('text', 'image_URL', ts('Image URL')); + } + } + $this->assign('hasImageUrl', !empty($imageUrl)); + $this->add('text', 'icon', ts('Icon'), ['class' => 'crm-icon-picker', 'title' => ts('Choose Icon'), 'allowClear' => TRUE]); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_ContactType', 'description') ); @@ -122,6 +130,11 @@ class CRM_Admin_Form_ContactType extends CRM_Admin_Form { } } + // If icon is set, it overrides image_URL + if (!empty($params['icon'])) { + $params['image_URL'] = ''; + } + $contactType = CRM_Contact_BAO_ContactType::add($params); CRM_Core_Session::setStatus(ts("The Contact Type '%1' has been saved.", [1 => $contactType->label] diff --git a/templates/CRM/Admin/Form/ContactType.tpl b/templates/CRM/Admin/Form/ContactType.tpl index 4ecf601650..527eec758c 100644 --- a/templates/CRM/Admin/Form/ContactType.tpl +++ b/templates/CRM/Admin/Form/ContactType.tpl @@ -35,9 +35,18 @@ {ts}{$contactTypeName}{/ts} {ts}(built-in){/ts} {/if} - - {$form.image_URL.label} {help id="id-image_URL"} - {$form.image_URL.html|crmAddClass:'huge40'} + {if $hasImageUrl} + + {$form.image_URL.label} + {$form.image_URL.html|crmAddClass:'huge40'} + + + {ts}Support for Image URL will be dropped in the future. Please select an icon instead.{/ts} + + {/if} + + {$form.icon.label} + {$form.icon.html} {$form.description.label} diff --git a/templates/CRM/Admin/Page/ContactType.hlp b/templates/CRM/Admin/Page/ContactType.hlp index 0643d015d6..a0ce38eb24 100644 --- a/templates/CRM/Admin/Page/ContactType.hlp +++ b/templates/CRM/Admin/Page/ContactType.hlp @@ -13,15 +13,3 @@ {htxt id="id-contactSubtype-intro"} {ts}CiviCRM comes with 3 basic (built-in) contact types: Individual, Household, and Organization. You can create additional contact types based on these basic types to further differentiate contacts (for example you might create Student, Parent, Staff, and /or Volunteer "subtypes" from the basic Individual type...). You can also re-name the built-in types. Contact subtypes are especially useful when you need to collect and display different sets of custom data for different types of contacts.{/ts} {/htxt} - -{htxt id="id-image_URL-title"} - {ts}Contact Type Icon{/ts} -{/htxt} -{htxt id="id-image_URL"} -
{ts 1='sites/.../files' 2='media'}Use this field to set your own icon for this Contact Type. Icon images should be 16 x 16 pixels for best fit. Enter a relative or complete URL to the image file location. Use a location outside of your CiviCRM code directory to reduce the likelihood of losing your image files during an upgrade. (For Drupal sites, you might want to use the %1 directory. For Joomla sites, the consider using the %2 directory.){/ts}
- Examples: - -{/htxt} -- 2.25.1