/[drupal]/contributions/modules/flexinode/field_checkbox.inc
ViewVC logotype

Contents of /contributions/modules/flexinode/field_checkbox.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.9 - (show annotations) (download) (as text)
Thu Nov 10 09:35:15 2005 UTC (4 years ago) by crunchywelch
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-4-7
Changes since 1.8: +15 -16 lines
File MIME type: text/x-php
port to 4.7, re-implemented the admin UI, moved them to tabs and made the field adds dropdown instead of links, removed search cruft since it was not being utilized, and broken, general code cleanup
1 <?php
2 // $Id: field_checkbox.inc,v 1.8 2005/09/23 04:28:06 chx Exp $
3
4 function flexinode_field_checkbox_name($field) {
5 return t('checkbox');
6 }
7
8 function flexinode_field_checkbox_form($field, $node) {
9 $fieldname = 'flexinode_'. $field->field_id;
10
11 return array($fieldname => array(
12 '#type' => 'checkbox',
13 '#title' => t($field->label),
14 '#default_value' => isset($node->$fieldname) ? $node->$fieldname : $field->default_value,
15 '#description' => t($field->description),
16 '#required' => $field->required,
17 '#weight' => $field->weight,
18 ));
19 }
20
21 function flexinode_field_checkbox_db_select($field) {
22 $fieldname = 'flexinode_'. $field->field_id;
23 return $fieldname .'.numeric_data AS '. $fieldname;
24 }
25
26 function flexinode_field_checkbox_db_sort_column($field) {
27 return 'flexinode_'. $field->field_id .'.numeric_data';
28 }
29
30 function flexinode_field_checkbox_insert($field, $node) {
31 $fieldname = 'flexinode_'. $field->field_id;
32 db_query('INSERT INTO {flexinode_data} (nid, field_id, numeric_data) VALUES (%d, %d, %d)', $node->nid, $field->field_id, $node->$fieldname);
33 }
34
35 function flexinode_field_checkbox_format($field, $node, $brief = 0) {
36 $fieldname = 'flexinode_'. $field->field_id;
37 return $node->$fieldname ? t('Yes') : t('No');
38 }
39
40 function flexinode_field_checkbox_config($field, $edit) {
41 return array('default_value' => array(
42 '#type' => 'checkbox',
43 '#title' => t('Checked by default'),
44 '#default_value' => $field->default_value,
45 ));
46 }
47
48
49 /**
50 * @addtogroup themeable
51 * @{
52 */
53
54 /**
55 * Format a checkbox value for display in a node.
56 *
57 * @param field_id
58 * Which field is being displayed (useful when overriding this function
59 * if you want to style one particular field differently).
60 * @param label
61 * The label for the field as displayed on the node form.
62 * @param value
63 * The value that the user entered for the field.
64 * @param formatted_value
65 * The value that the user entered for the field as pre-formatted by the module.
66 */
67 function theme_flexinode_checkbox($field_id, $label, $value, $formatted_value) {
68 $output = theme('form_element', $label, $formatted_value);
69 $output = '<div class="flexinode-checkbox-'. $field_id .'">'. $output .'</div>';
70 return $output;
71 }
72
73 /** @} End of addtogroup themeable */
74
75 ?>

  ViewVC Help
Powered by ViewVC 1.1.2