t('Data key'), '#type' => 'radios', '#options' => drupal_map_assoc($opts), '#required' => TRUE, '#default_value' => $this->options['data_key'], '#description' => t('The data column may (or may not) contain any of the following data. Select the data that should be output for this field.'), '#weight' => 4, ); } function admin_summary() { // Display the data to be displayed return $this->options['data_key']; } function render($values) { $values = drupal_clone($values); // Prevent affecting the original. $data = unserialize($values->{$this->field_alias}); // check if this has an array for a value (imagefield_extended uses an array, there may be others as well) if (!is_array($data[$this->options['data_key']])) $values->{$this->field_alias} = $data[$this->options['data_key']]; // here we use the array and use formatting options if it is set elseif (isset($data[$this->options['data_key']]['body']) && isset($data[$this->options['data_key']]['format'])) { $values->{$this->field_alias} = ($data[$this->options['data_key']]['format'] === '') ? check_plain($data[$this->options['data_key']]['body']) : check_markup($data[$this->options['data_key']]['body'], $data[$this->options['data_key']]['format']); } return parent::render($values); } } /** * Utility function to pull necessary labels from the db * @returns $options - array of labels */ function _filefield_get_field_data() { $result = db_query("SELECT field_name FROM {content_node_field} WHERE type = 'filefield'"); $options = array(); while ($field = db_fetch_array($result)) { $field = $field['field_name']; $fdata = $field . '_data'; // we check for %s <> 'b:0;' since this is what an empty serialized string looks like (empty strings won't work) $row = db_fetch_array(db_query("SELECT %s FROM %s WHERE %s <> 'b:0;' LIMIT 1", $fdata, 'content_' . $field, $fdata)); $data = unserialize($row[$fdata]); foreach ($data as $key => $val) { // push all the keys into an array $output = check_plain($key); array_push($options, $output); } } return $options; // our list of labels }