123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- function tripal_ds_field_group_formatter_info() {
- return array(
- 'form' => array(
- 'tripalpane' => array(
- 'label' => t('Tripal Pane'),
- 'description' => t('This fieldgroup renders the inner content in a Tripal Pane with the title as legend.'),
- 'instance_settings' => array('description' => '', 'classes' => '', 'id' => '', 'hide' => 1),
- ),
- ),
- 'display' => array(
- 'tripalpane' => array(
- 'label' => t('Tripal Pane'),
- 'description' => t('This fieldgroup renders the inner content in a Tripal Pane with the title as legend.'),
- 'instance_settings' => array('description' => '', 'classes' => '', 'id' => '', 'hide' => 1),
- ),
- ),
- );
- }
- function tripal_ds_field_group_format_settings($group) {
-
- $form = array(
- 'instance_settings' => array(
- '#tree' => TRUE,
- '#weight' => 2,
- ),
- );
- $field_group_types = field_group_formatter_info();
- $mode = $group->mode == 'form' ? 'form' : 'display';
- $formatter = $field_group_types [$mode][$group->format_type];
-
- switch ($group->format_type) {
- case 'tripalpane':
- $form['instance_settings']['hide'] = array(
- '#title' => t('Hide panel on page load'),
- '#type' => 'checkbox',
- '#default_value' => isset($group->format_settings['instance_settings']['hide']) ? $group->format_settings['instance_settings']['hide'] : $formatter['instance_settings']['hide'],
- '#weight' => 2,
- );
- break;
- }
- return $form;
- }
- function tripal_ds_field_group_pre_render(&$element, $group, &$form) {
- switch ($group->format_type) {
- case 'tripalpane':
- $group_name = $group->group_name;
-
- $description = $group->format_settings['instance_settings']['description'];
- $hide = isset($group->format_settings['instance_settings']['hide']) ? $group->format_settings['instance_settings']['hide'] : 'none';
- $classes = $group->format_settings['instance_settings']['classes'];
- if ($hide == '1') {
- $element['#prefix'] = '<div class="tripal_pane-fieldset-'.$group_name.' '.$group_name.' tripal_pane '.$classes.' hideTripalPane"> <span class="field-group-format-title">' . check_plain(t($group->label)) . '</span>';
- }
- else {
- $element['#prefix'] = '<div class="tripal_pane-fieldset-'.$group_name.' '.$group_name.' tripal_pane '.$classes.'"> <span class="field-group-format-title">' . check_plain(t($group->label)) . '</span>';
- }
- if (!empty($description)) {
- $element['#prefix'] .= '<div class="description">' . $description . '</div>';
- }
- $element['#suffix'] = '</div>';
- break;
- }
- }
- function tripal_ds_field_group_update_weight($field_name, $bundle, $weight) {
-
- $result = db_select('field_group', 'fg')
- ->fields('fg')
- ->condition('bundle', $bundle,'=')
- ->condition('group_name', $field_name,'=')
- ->execute()
- ->fetchAssoc();
-
- if(!empty($result)){
- $data = unserialize($result['data']);
- $data['weight'] = $weight;
- $data = serialize($data);
- }
-
- db_update('field_group')
- ->fields(array(
- 'data' => $data
- ))
- ->condition('bundle', $bundle,'=')
- ->condition('group_name', $field_name,'=')
- ->execute();
- }
|