From: Coleman Watts Date: Thu, 8 Jan 2015 15:35:49 +0000 (-0500) Subject: CRM-15789 - More consistent button classes and icons X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fdb0ca2cca69233415d948a2885de70903330739;p=civicrm-core.git CRM-15789 - More consistent button classes and icons --- diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index a155cc4447..8ccc7fda71 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -498,24 +498,19 @@ class CRM_Core_Form extends HTML_QuickForm_Page { public function addButtons($params) { $prevnext = $spacing = array(); foreach ($params as $button) { - $js = CRM_Utils_Array::value('js', $button); - $isDefault = CRM_Utils_Array::value('isDefault', $button, FALSE); - if ($isDefault) { - $attrs = array('class' => 'crm-form-submit default'); - } - else { - $attrs = array('class' => 'crm-form-submit'); - } + $attrs = array('class' => 'crm-form-submit') + (array) CRM_Utils_Array::value('js', $button); - if ($js) { - $attrs = array_merge($js, $attrs); + if (!empty($button['isDefault'])) { + $attrs['class'] .= ' default'; } - $defaultIcon = 'check'; - - if ($button['type'] === 'cancel') { + if (in_array($button['type'], array('upload', 'next', 'submit', 'done', 'process', 'refresh'))) { + $attrs['class'] .= ' validate'; + $defaultIcon = 'check'; + } + else { $attrs['class'] .= ' cancel'; - $defaultIcon = 'close'; + $defaultIcon = $button['type'] == 'back' ? 'triangle-1-w' : 'close'; } if ($button['type'] === 'reset') { @@ -526,19 +521,22 @@ class CRM_Core_Form extends HTML_QuickForm_Page { if ($button['subName'] == 'new') { $defaultIcon = 'plus'; } - $buttonName = $this->getButtonName($button['type'], $button['subName']); - } - else { - $buttonName = $this->getButtonName($button['type']); + if ($button['subName'] == 'done') { + $defaultIcon = 'circle-check'; + } + if ($button['subName'] == 'next') { + $defaultIcon = 'circle-triangle-e'; + } } if (in_array($button['type'], array('next', 'upload', 'done')) && $button['name'] === ts('Save')) { - $attrs = array_merge($attrs, (array('accesskey' => 'S'))); + $attrs['accesskey'] = 'S'; } $icon = CRM_Utils_Array::value('icon', $button, $defaultIcon); if ($icon) { $attrs['crm-icon'] = $icon; } + $buttonName = $this->getButtonName($button['type'], CRM_Utils_Array::value('subName', $button)); $prevnext[] = $this->createElement('submit', $buttonName, $button['name'], $attrs); } if (!empty($button['isDefault'])) { diff --git a/CRM/Core/Smarty/plugins/function.crmGetAttribute.php b/CRM/Core/Smarty/plugins/function.crmGetAttribute.php index 9fd1b74e32..e2db821a73 100644 --- a/CRM/Core/Smarty/plugins/function.crmGetAttribute.php +++ b/CRM/Core/Smarty/plugins/function.crmGetAttribute.php @@ -42,8 +42,14 @@ * @return string */ function smarty_function_crmGetAttribute($params, &$smarty) { + $ret = ''; if (preg_match('#\W' . $params['attr'] . '="([^"]+)#', $params['html'], $matches)) { - return $matches[1]; + $ret = $matches[1]; + } + if (!empty($params['assign'])) { + $smarty->assign($params['assign'], $ret); + } + else { + return $ret; } - return ''; } diff --git a/CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php b/CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php deleted file mode 100644 index 9d9c747c9f..0000000000 --- a/CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php +++ /dev/null @@ -1,56 +0,0 @@ - {if $icon} {/if} - {$html|crmAddClass:$validate} + {$html} {/if} {/foreach}