/** * @todo. */ protected function prepare($entity_type, $entity_id, $field, Request $request) { $this->entity = entity_load($entity_type, $entity_id); $this->langcode = field_language($this->entity, $field); $day_delta = check_plain($request->request->get('day_delta')); $minute_delta = check_plain($request->request->get('minute_delta')); $this->delta = " {$day_delta} days {$minute_delta} minutes"; }
/** * Implementation of template_preprocess_node() */ function kay2_preprocess_node(&$vars) { $vars['language_fields'] = field_language('node', $vars['node']); // Need to overwrite field_image style preset for only this theme. if ($vars['elements']['#view_mode'] == 'full') { if (isset($vars['content']['field_image'])) { $vars['content']['field_image'][0]['#item']['width'] = '250'; $vars['content']['field_image'][0]['#item']['height'] = 'auto'; $vars['content']['field_image'][0]['#image_style'] = 'node_image'; } } }
public static function viewValue($entity_type, $entity, $field_name, $delta = 0, $display = array(), $langcode = NULL) { $output = array(); if ($item = static::getValue($entity_type, $entity, $field_name, NULL, $delta)) { // Determine the langcode that will be used by language fallback. $langcode = field_language($entity_type, $entity, $field_name, $langcode); // Push the item as the single value for the field, and defer to // field_view_field() to build the render array for the whole field. $clone = clone $entity; $clone->{$field_name}[$langcode] = array($item); $elements = static::viewValues($entity_type, $clone, $field_name, $display, $langcode); // Extract the part of the render array we need. $output = isset($elements[0]) ? $elements[0] : array(); if (isset($elements['#access'])) { $output['#access'] = $elements['#access']; } } return $output; }
/** * Fills default atom data. * * When a form is uploaded, one or more atoms are created, but it is not saved. * This is a last chance for atom provider to add default data, maybe from the * form, into atoms. * * @param mixed $atoms * An array of atoms if the provider implements hook_scald_add_atom_count(), * otherwise a single atom. * * @param array $form * * @param array $form_state */ function hook_scald_add_form_fill(&$atoms, $form, $form_state) { foreach ($atoms as $delta => $atom) { if (is_array($form_state['values']['file']) && module_exists('plupload')) { module_load_include('inc', 'scald', 'includes/scald.plupload'); $file = scald_plupload_save_file($form_state['values']['file'][$delta]['tmppath'], $form['file']['#upload_location'] . $form_state['values']['file'][$delta]['name']); } else { $file = file_load($form_state['values']['file']); } $atom->title = $file->filename; $atom->base_id = $file->fid; $langcode = field_language('scald_atom', $atom, 'scald_thumbnail'); $atom->scald_thumbnail[$langcode][0] = (array) $file; } }
/** * Implementation of template_preprocess_node() */ function kaykay_preprocess_node(&$vars) { $vars['language_fields'] = field_language('node', $vars['node']); }
public function fieldLanguage($field) { return field_language($this->type(), $this->definition, $field); }
/** * Given information about an entity, sets a field value. * * @param string $entity_type The entity type. * @param object $stub_entity The stub entity. * @param string $field_name The name of the field to set. * @param int $delta The delta (index) of the value to set. * @param mixed $value The value itself. */ protected function setFieldValue($entity_type, $stub_entity, $field_name, $delta, $value) { $language = field_language($entity_type, $stub_entity, $field_name); $stub_entity->{$field_name}[$language][$delta] = $value; field_attach_update($entity_type, $stub_entity); }
<?php print $term->safe_description; ?> <?php } ?> <?php if (isset($term->field_source) && !empty($term->field_source)) { ?> <div class="lexicon-source"> <span><?php print t('Source') . ': '; ?> </span> <?php $field_language = field_language('taxonomy_term', $term, 'field_source'); print $term->field_source[$field_language][0]['safe_value']; ?> </div> <?php } ?> <?php if (isset($term->related)) { ?> <p class="lexicon-related"> <span><?php print t('See also') . ': '; ?> </span> <?php
<?php $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'volunteers'); $result = $query->execute(); if (isset($result['node'])) { foreach ($result['node'] as $nid => $info) { $volunteer = node_load($nid); $language = field_language('node', $volunteer, 'field_cpr_number'); $cpr =& $volunteer->field_cpr_number[$language][0]['value']; if (!strstr($cpr, '-')) { $format_cpr = substr($cpr, 0, 6); $format_cpr .= '-'; $format_cpr .= substr($cpr, 6, 4); $cpr = $format_cpr; error_log(__FILE__ . ' : ' . __LINE__ . ': ' . print_r($volunteer->field_cpr_number, 1)); node_save($volunteer); } } }