From a2cb374bf552350bc0382dbeb06eaf62e9d59ab0 Mon Sep 17 00:00:00 2001 From: Marton Kiss Date: Tue, 17 Sep 2013 16:56:42 +0200 Subject: [PATCH] Resource fieldset UX Add formatting to resource fieldset output. Convert http links to html markup in value field. Change-Id: Ic9a0b34f04df4ebd0d71125c98fa3b1750e1a4c9 --- .../field_property_list.css | 12 ++++++++++ .../field_property_list.module | 22 ++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 modules/groups/field_property_list/field_property_list.css diff --git a/modules/groups/field_property_list/field_property_list.css b/modules/groups/field_property_list/field_property_list.css new file mode 100644 index 0000000..cdbdebe --- /dev/null +++ b/modules/groups/field_property_list/field_property_list.css @@ -0,0 +1,12 @@ +.field-type-field-property-list .field-item { + width: 50%; + float: left; + padding-bottom: 0.5em; +} + +.field-type-field-property-list .field-item .property-title { + font-size: 80%; + font-weight: bold; + text-transform:uppercase; + color: #333333; +} diff --git a/modules/groups/field_property_list/field_property_list.module b/modules/groups/field_property_list/field_property_list.module index ce6788e..2e830eb 100644 --- a/modules/groups/field_property_list/field_property_list.module +++ b/modules/groups/field_property_list/field_property_list.module @@ -80,16 +80,32 @@ function field_property_list_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); + $module_path = drupal_get_path('module', 'field_property_list'); + drupal_add_css($module_path . '/field_property_list.css'); + $key_lookup = field_property_list_key_lookup(); switch ($display['type']) { // This formatter simply outputs the field as text and with a color. case 'field_property_list_raw': foreach ($items as $delta => $item) { + $value = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.-]*'. + '(\?\S+)?)?)?)@', '$1', $item['value']); + $element[$delta] = array( - '#type' => 'html_tag', - '#tag' => 'div', - '#value' => $key_lookup[$item['key']].': '.$item['value'], + 'title' => array( + '#type' => 'html_tag', + '#tag' => 'div', + '#value' => $key_lookup[$item['key']], + '#attributes' => array('class' => array('property-title', + 'property-type-'.$item['key'])), + ), + 'value' => array( + '#type' => 'html_tag', + '#tag' => 'div', + '#value' => $value, + '#attributes' => array('class' => array('property-value')), + ), ); } break;