| 1 |
<?php
|
| 2 |
// $Id: field_select.inc,v 1.11 2005/11/10 09:35:16 crunchywelch Exp $
|
| 3 |
|
| 4 |
function flexinode_field_select_name($field) {
|
| 5 |
return t('dropdown menu');
|
| 6 |
}
|
| 7 |
|
| 8 |
function flexinode_field_select_form($field, &$node) {
|
| 9 |
$fieldname = 'flexinode_'. $field->field_id;
|
| 10 |
$options = array(0 => '<'. t('none') .'>');
|
| 11 |
foreach ($field->options as $option) {
|
| 12 |
$options[] = $option;
|
| 13 |
}
|
| 14 |
if ($field->required) {
|
| 15 |
unset($options[0]);
|
| 16 |
}
|
| 17 |
return array($fieldname => array(
|
| 18 |
'#type' => 'select',
|
| 19 |
'#title' => t($field->label),
|
| 20 |
'#default_value' => $node->$fieldname,
|
| 21 |
'#options' => $options,
|
| 22 |
'#description' => t($field->description),
|
| 23 |
'#required' => $field->required,
|
| 24 |
'#weight' => $field->weight,
|
| 25 |
));
|
| 26 |
}
|
| 27 |
|
| 28 |
function flexinode_field_select_db_select($field) {
|
| 29 |
$fieldname = 'flexinode_'. $field->field_id;
|
| 30 |
return $fieldname .'.numeric_data AS '. $fieldname;
|
| 31 |
}
|
| 32 |
|
| 33 |
function flexinode_field_select_db_sort_column($field) {
|
| 34 |
return 'flexinode_'. $field->field_id .'.numeric_data';
|
| 35 |
}
|
| 36 |
|
| 37 |
function flexinode_field_select_insert($field, $node) {
|
| 38 |
$fieldname = 'flexinode_'. $field->field_id;
|
| 39 |
db_query('INSERT INTO {flexinode_data} (nid, field_id, numeric_data) VALUES (%d, %d, %d)', $node->nid, $field->field_id, $node->$fieldname);
|
| 40 |
}
|
| 41 |
|
| 42 |
function flexinode_field_select_format($field, $node, $brief = 0) {
|
| 43 |
$fieldname = 'flexinode_'. $field->field_id;
|
| 44 |
return $node->$fieldname ? $field->options[$node->$fieldname] : FALSE;
|
| 45 |
}
|
| 46 |
|
| 47 |
function flexinode_field_select_config($field, $edit) {
|
| 48 |
$field_options = (array) $field->options;
|
| 49 |
return array('options' => array(
|
| 50 |
'#type' => 'textarea',
|
| 51 |
'#default_value' => is_array($edit['options']) ? implode('|', $edit['options']) : implode('|', $field_options),
|
| 52 |
'#description' => t('Please enter a pipe delimited list of options with no carriage returns. For example: "Red|Blue|Green" or "Small|Medium|Large"'),
|
| 53 |
));
|
| 54 |
}
|
| 55 |
|
| 56 |
|
| 57 |
/**
|
| 58 |
* @addtogroup themeable
|
| 59 |
* @{
|
| 60 |
*/
|
| 61 |
|
| 62 |
/**
|
| 63 |
* Format a dropdown selection for display in a node.
|
| 64 |
*
|
| 65 |
* @param field_id
|
| 66 |
* Which field is being displayed (useful when overriding this function
|
| 67 |
* if you want to style one particular field differently).
|
| 68 |
* @param label
|
| 69 |
* The label for the field as displayed on the node form.
|
| 70 |
* @param value
|
| 71 |
* The value that the user entered for the field.
|
| 72 |
* @param formatted_value
|
| 73 |
* The displayed label for the selected value
|
| 74 |
*/
|
| 75 |
function theme_flexinode_select($field_id, $label, $value, $formatted_value) {
|
| 76 |
$output = theme('form_element', $label, $formatted_value);
|
| 77 |
$output = '<div class="flexinode-select-'. $field_id .'">'. $output .'</div>';
|
| 78 |
return $output;
|
| 79 |
}
|
| 80 |
|
| 81 |
/** @} End of addtogroup themeable */
|
| 82 |
|