| 1 |
<?php
|
| 2 |
// $Id: field_textarea.inc,v 1.18 2006/02/07 18:35:56 morbus Exp $
|
| 3 |
|
| 4 |
function flexinode_field_textarea_name($field) {
|
| 5 |
return t('text area');
|
| 6 |
}
|
| 7 |
|
| 8 |
function flexinode_field_textarea_form($field, &$node) {
|
| 9 |
$fieldname = 'flexinode_'. $field->field_id;
|
| 10 |
$formatname = 'flexinode_'. $field->field_id .'_format';
|
| 11 |
$form[$fieldname.'_filter'] = array(
|
| 12 |
'#weight' => $field->weight,
|
| 13 |
);
|
| 14 |
|
| 15 |
$form[$fieldname.'_filter'][$fieldname] = array(
|
| 16 |
'#type' => 'textarea',
|
| 17 |
'#title' => t($field->label),
|
| 18 |
'#default_value' => isset($node->$fieldname) ? $node->$fieldname : $field->default_value,
|
| 19 |
'#rows' => $field->rows,
|
| 20 |
'#description' => t($field->description),
|
| 21 |
'#required' => $field->required,
|
| 22 |
'#weight' => $field->weight,
|
| 23 |
);
|
| 24 |
$form[$fieldname.'_filter'][$formatname] = filter_form($node->$formatname, $field->weight + 1, array($formatname));
|
| 25 |
return $form;
|
| 26 |
}
|
| 27 |
|
| 28 |
function flexinode_field_textarea_db_select($field) {
|
| 29 |
$fieldname = 'flexinode_'. $field->field_id;
|
| 30 |
$formatname = 'flexinode_'. $field->field_id .'_format';
|
| 31 |
return $fieldname .'.textual_data AS '. $fieldname .', '. $fieldname .'.numeric_data AS '. $formatname;
|
| 32 |
}
|
| 33 |
|
| 34 |
function flexinode_field_textarea_insert($field, $node) {
|
| 35 |
$fieldname = 'flexinode_'. $field->field_id;
|
| 36 |
$formatname = 'flexinode_'. $field->field_id .'_format';
|
| 37 |
db_query("INSERT INTO {flexinode_data} (nid, field_id, textual_data, numeric_data) VALUES (%d, %d, '%s', %d)", $node->nid, $field->field_id, $node->$fieldname, $node->$formatname);
|
| 38 |
}
|
| 39 |
|
| 40 |
function flexinode_field_textarea_validate($field, $node) {
|
| 41 |
$fieldname = 'flexinode_'. $field->field_id;
|
| 42 |
$formatname = 'flexinode_'. $field->field_id .'_format';
|
| 43 |
if (!filter_access($node->$formatname)) {
|
| 44 |
form_set_error($fieldname, t('The supplied input format is invalid.'));
|
| 45 |
}
|
| 46 |
}
|
| 47 |
|
| 48 |
function flexinode_field_textarea_format($field, $node, $brief = 0) {
|
| 49 |
$fieldname = 'flexinode_'. $field->field_id;
|
| 50 |
$formatname = 'flexinode_'. $field->field_id .'_format';
|
| 51 |
if ($node->$fieldname) {
|
| 52 |
if ($brief) {
|
| 53 |
return check_markup(node_teaser($node->$fieldname, $node->$formatname), $node->$formatname, FALSE);
|
| 54 |
}
|
| 55 |
else {
|
| 56 |
return check_markup($node->$fieldname, $node->$formatname, FALSE);
|
| 57 |
}
|
| 58 |
}
|
| 59 |
}
|
| 60 |
|
| 61 |
function flexinode_field_textarea_config($field) {
|
| 62 |
$form['default_value'] = array(
|
| 63 |
'#type' => 'textarea',
|
| 64 |
'#title' => t('Default value'),
|
| 65 |
'#default_value' => $field->default_value,
|
| 66 |
);
|
| 67 |
$form['rows'] = array(
|
| 68 |
'#type' => 'textfield',
|
| 69 |
'#title' => t('Lines'),
|
| 70 |
'#default_value' => $field->rows ? $field->rows : 5,
|
| 71 |
'#maxlength' => 10,
|
| 72 |
'#description' => t('How large the text area will be.')
|
| 73 |
);
|
| 74 |
return $form;
|
| 75 |
}
|
| 76 |
|
| 77 |
|
| 78 |
/**
|
| 79 |
* @addtogroup themeable
|
| 80 |
* @{
|
| 81 |
*/
|
| 82 |
|
| 83 |
/**
|
| 84 |
* Format a text area for display in a node.
|
| 85 |
*
|
| 86 |
* @param field_id
|
| 87 |
* Which field is being displayed (useful when overriding this function
|
| 88 |
* if you want to style one particular field differently).
|
| 89 |
* @param label
|
| 90 |
* The label for the field as displayed on the node form.
|
| 91 |
* @param value
|
| 92 |
* The value that the user entered for the field.
|
| 93 |
* @param formatted_value
|
| 94 |
* The value that the user entered for the field as pre-formatted by the module.
|
| 95 |
*/
|
| 96 |
function theme_flexinode_textarea($field_id, $label, $value, $formatted_value) {
|
| 97 |
$output = theme('form_element', $label, $formatted_value);
|
| 98 |
$output = '<div class="flexinode-textarea-'. $field_id .'">'. $output .'</div>';
|
| 99 |
return $output;
|
| 100 |
}
|
| 101 |
|
| 102 |
/** @} End of addtogroup themeable */
|
| 103 |
|