/** * Helper function : given a node, return the list of referrers the * current user is allowed to create as an array defining : * * 'name' : Name of the referrer field * 'field' : Details of the referer field * 'referrence' : Detail of the reference field * */ function _nodereferrer_create_get_referrers($node) { $list = array(); if (!variable_get('nodereferrer_create_show_on_nodereferrer', 1)) { return $list; } $type = content_types($node->type); foreach ($type['fields'] as $name => $field) { if ($field['type'] != 'nodereferrer' || !is_array($field['referrer_types'])) { continue; } foreach (array_filter($field['referrer_types']) as $reftype) { if (!node_access('create', $reftype)) { continue; } $with_field = array(); foreach (array_filter($field['referrer_fields']) as $reffield) { $cf = content_fields($reffield, $reftype); if ($cf) { $with_field[$reftype][] = $cf; } } if (count($with_field) == 0) { continue; } $list[] = array('name' => substr($name, strlen('field_')), 'field' => $field, 'referrence' => $with_field); } } return $list; }
/** * Implements hook_wysiwyg_fields_wysiwyg_plugins(). */ function hook_wysiwyg_fields_wysiwyg_plugins($content_type) { $plugins = array(); foreach (content_fields() as $field) { if (!in_array(TRUE, module_invoke_all('wysiwyg_fields_field_bypass', $field)) && !is_null(content_fields($field['field_name'], $content_type)) && isset($field['widget']['wysiwyg_fields_status']) && $field['widget']['wysiwyg_fields_status']) { $plugins[$field['field_name']] = array('label' => $field['widget']['label'], 'icon' => $field['widget']['wysiwyg_fields_icon']); } } return $plugins; }
/** * Override of theme_content_multiple_values(). * Adds a generic wrapper. */ function ginkgo_content_multiple_values($element) { $output = theme_content_multiple_values($element); $field_name = $element['#field_name']; $field = content_fields($field_name); if ($field['multiple'] >= 1) { return "<div class='content-multiple-values'>{$output}</div>"; } return $output; }
} // dsm($rows); // dsm($view); // Get all the flags for the user. $flagged = flag_get_user_flags('node'); // dsm($flagged); // Build a grid that we can use for our table. foreach ($rows as $id => $row) { $results[$view->result[$id]->node_data_field_session_day_field_session_day_value][$view->result[$id]->node_data_field_session_room_field_session_time_value][$view->result[$id]->node_data_field_session_day_field_session_room_value] = array('content' => $row, 'nid' => $view->result[$id]->nid, 'id' => 'node-' . $view->result[$id]->nid); } dsm($results); // Sorting so that time goes ASC. ksort($results['saturday']); ksort($results['sunday']); // Gather the room cck field values for the table headers $field_rooms = content_fields('field_session_room'); $allowed = content_allowed_values($field_rooms); $saturday_header = array($allowed[1], $allowed[2], $allowed[3], $allowed[4], $allowed[5], $allowed[8]); $sunday_header = array($allowed[2], $allowed[3], $allowed[4], $allowed[5], $allowed[8]); // Add some js magic to catch a vote request and then update the td class drupal_add_js("\$(document).ready(function() {\n \$(window).bind('flagGlobalAfterLinkUpdate', function(e, data) {\n var selector = '#node-' + data.contentId;\n if (data.flagStatus == 'flagged') {\n \$(selector).addClass('flagged').removeClass('not-flagged');\n }\n else {\n \$(selector).addClass('not-flagged').removeClass('flagged');\n }\n });\n });", 'inline'); // dsm($results); ?> <?php if (user_access('manage schedule')) { ?> <div class="manage-link"><?php echo l('Manage Schedule', 'manage/schedule', array('query' => 'destination=schedule')); ?> </div>
function city_magazine_custom_content_multiple_values($element) { $field_name = $element['#field_name']; $field = content_fields($field_name); $output = ''; if ($field['multiple'] >= 1) { $table_id = $element['#field_name'] . '_values'; $order_class = $element['#field_name'] . '-delta-order'; $required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : ''; $header = array(array('data' => t('!title: !required', array('!title' => $element['#title'], '!required' => $required)) . '<br /><div class="description">' . $element['#description'] . '</div>', 'colspan' => 2), t('Order')); $rows = array(); // Sort items according to '_weight' (needed when the form comes back after // preview or failed validation) $items = array(); foreach (element_children($element) as $key) { if ($key !== $element['#field_name'] . '_add_more') { $items[] =& $element[$key]; } } usort($items, '_content_sort_items_value_helper'); // Add the items as table rows. foreach ($items as $key => $item) { $item['_weight']['#attributes']['class'] = $order_class; $delta_element = drupal_render($item['_weight']); $cells = array(array('data' => '', 'class' => 'content-multiple-drag'), drupal_render($item), array('data' => $delta_element, 'class' => 'delta-order')); $rows[] = array('data' => $cells, 'class' => 'draggable'); } $output .= theme('table', $header, $rows, array('id' => $table_id, 'class' => 'content-multiple-table')); $output .= drupal_render($element[$element['#field_name'] . '_add_more']); drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class); } else { foreach (element_children($element) as $key) { $output .= drupal_render($element[$key]); } } return $output; }
/** * {@inheritdoc} */ public function isField($entity_type, $field_name) { if ($field_name === 'taxonomy') { return TRUE; } if (!module_exists('content')) { return FALSE; } $map = content_fields(); return isset($map[$field_name]); }
/** * Recurses through forms for input filter fieldsets and alters them. */ function _rubik_filter_form_alter(&$form) { $found = FALSE; $multiple_fields = FALSE; // Unlimited value CCK fields should not be altered // to avoid breaking the AHAH drag n drop and 'Add more' // functionality. if (isset($form['#field_name'])) { $field_name = $form['#field_name']; $field = content_fields($field_name); if ($field['multiple'] > 0) { $multiple_fields = TRUE; } } foreach (element_children($form) as $id) { // Filter form element found if (isset($form[$id]['#element_validate']) && is_array($form[$id]['#element_validate']) && in_array('filter_form_validate', $form[$id]['#element_validate'])) { if ($multiple_fields === TRUE) { continue; } $form[$id]['#type'] = 'markup'; $form[$id]['#theme'] = 'filter_form'; $found = TRUE; } elseif ($id == 'format' && !empty($form[$id]['format']['guidelines'])) { if ($multiple_fields === TRUE) { continue; } $form[$id]['#theme'] = 'filter_form'; $found = TRUE; } else { _rubik_filter_form_alter($form[$id]); } } // If filter elements found, adjust parent element. if ($found) { foreach (element_children($form) as $element) { $form[$element]['#rubik_filter_form'] = TRUE; } $form = array('#type' => 'item', '#weight' => isset($form['#weight']) ? $form['#weight'] : 0, $form); } }
/** * Gets available fields. * * Supplies the fields supported by the module if the module supports fields. * * @param $current * An array with the currently used fields keyed by field. * @param $type * An array containing the current type. * @return * An associative array with two keys: * - "fields": Required. An array keyed by field name of fields as * associative arrays containing: * - "title": The title of the field * - "weight": The weight of the field * - "selected": A boolean value of whether the field is slected or not * - "links": Required. An array of field labels keyed by field name */ function hook_realname_get_fields($current, $type = NULL) { $fields = $links = array(); $all_fields = content_fields(NULL, $type); if ($all_fields) { foreach ($all_fields as $field_name => $field_attributes) { // If it's not they type we are looking for, then skip the field. if ($field_attributes['type_name'] != $type) { continue; } switch ($field_attributes['type']) { case 'text': if ($field_attributes['multiple']) { drupal_set_message(t('The RealName module does not currently support fields with multiple values, such as @fld.', array('@fld' => $field_name)), 'warning'); } else { $selected = array_key_exists($field_name, $current); $fields[$field_name] = array('title' => $field_attributes['widget']['label'], 'weight' => $selected ? $current[$field_name] : 0, 'selected' => $selected); } break; case 'link': $links[$field_name] = $field_attributes['widget']['label']; } } } else { drupal_set_message(t('The !type content type has no fields to use.', array('!type' => $type)), 'error'); } if (variable_get('realname_use_title', FALSE)) { $fields['title'] = array('title' => t('Node title'), 'weight' => isset($current['title']) ? $current['title']['weight'] : 0, 'selected' => array_key_exists('title', $current)); } return array('fields' => $fields, 'links' => $links); }
function LCNG_bd_video_formatter_default($element) { $field = content_fields($element['#field_name'], $element['#type_name']); $video = _bd_video_load($element['#item']['video_id']); if (module_exists('bd_video_ads')) { $video['advert'] = bd_video_ads_select_ad($field); } _bd_video_set_render_settings($field); return _bd_video_render_video($video, 'default'); }
/** * Theme from/to date combination on form. */ function arquideasprod_date_combo($element) { $field = content_fields($element['#field_name'], $element['#type_name']); if (!$field['todate']) { return $element['#children']; } // Group from/to items together in fieldset. $fieldset = array('#title' => check_plain($element['#title']) . ' ' . ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''), '#value' => $element['#children'], '#collapsible' => FALSE, '#collapsed' => FALSE, '#description' => $element['#fieldset_description'], '#attributes' => array()); return theme('fieldset', $fieldset); }
/** * Drupal 6 */ protected function readDrupal6SiteProperties() { $node_types = node_get_types(); $fields = content_fields(); foreach ($node_types as $bundle => $entity_info) { $field_types = content_types($bundle); $instances = array(); foreach ($field_types['fields'] as $fieldName => $fieldInfo) { $instance = array('entity_type' => 'node', 'bundle' => $bundle, 'field_name' => $fieldName, 'label' => $fieldInfo['widget']['label'], 'description' => $fieldInfo['widget']['description'], 'widget' => array('type' => $fieldInfo['widget']['type'], 'settings' => array())); $instances[$fieldName] = $this->processInstance($instance); } $this->entityTypes[] = new NodeTypeBuilder($bundle, $entity_info->name, $entity_info->description, $instances); } $vocs = taxonomy_get_vocabularies(); foreach ($vocs as $bundle => $entity_info) { $this->entityTypes[] = new VocabularyBuilder($entity_info->vid, $entity_info->name, $entity_info->description); } foreach ($fields as $fieldName => $fieldInfo) { $this->fields[] = new FieldBuilder($fieldName, $fieldInfo['type']); } $this->parseDefinition(); }
<?php /** * This template is used to print a single field in a view. It is not * actually used in default Views, as this is registered as a theme * function which has better performance. For single overrides, the * template is perfectly okay. * * Variables available: * - $view: The view object * - $field: The field handler object that can process the input * - $row: The raw SQL result that can be used * - $output: The processed output that will normally be used. * * When fetching output from the $row, this construct should be used: * $data = $row->{$field->field_alias} * * The above will guarantee that you'll always get the correct data, * regardless of any changes in the aliasing that might happen if * the view is modified. */ ?> <?php $options = content_allowed_values(content_fields('field_active_flag'), FALSE); print $options[$output]; ?>