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

Diff of /contributions/modules/flexinode/field_email.inc

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

revision 1.1, Tue Feb 6 08:56:53 2007 UTC revision 1.1.2.1, Tue Feb 6 08:56:53 2007 UTC
# Line 0  Line 1 
1    <?php
2    // $Id: field_email.inc,v 1.10 2005/11/10 09:32:14 crunchywelch Exp $
3    
4    function flexinode_field_email_name($field) {
5      return t('e-mail address');
6    }
7    
8    function flexinode_field_email_form($field, &$node, $error) {
9      $fieldname = 'flexinode_'. $field->field_id;
10    
11      if (isset($node->$fieldname) && strpos($node->$fieldname, '&#') === 0) {
12        $value = flexinode_unhtmlentities($node->$fieldname);
13      }
14      else {
15        $value = $node->$fieldname;
16      }
17      return array($fieldname => array(
18        '#type' => 'textfield',
19        '#title' => t($field->label),
20        '#default_value' => $value ? $value : $field->default_value,
21        '#description' => t($field->description),
22        '#weight' => $field->weight,
23        ));
24    }
25    
26    function flexinode_field_email_db_select($field) {
27      $fieldname = 'flexinode_'. $field->field_id;
28      return $fieldname .'.textual_data AS '. $fieldname;
29    }
30    
31    function flexinode_field_email_db_sort_column($field) {
32      return 'flexinode_'. $field->field_id .'.textual_data';
33    }
34    
35    function flexinode_field_email_insert($field, $node) {
36      $fieldname = 'flexinode_'. $field->field_id;
37      $node->$fieldname = htmlentities($node->$fieldname);
38      db_query("INSERT INTO {flexinode_data} (nid, field_id, textual_data) VALUES (%d, %d, '%s')", $node->nid, $field->field_id, $node->$fieldname);
39    }
40    
41    function flexinode_field_email_validate($field, $node) {
42      $fieldname = 'flexinode_'. $field->field_id;
43      if(!(empty($node->$fieldname) || valid_email_address($node->$fieldname))) {
44       form_set_error($fieldname, t('The email address is not valid.'));
45      }
46    }
47    
48    function flexinode_field_email_format($field, $node, $brief = 0) {
49      $fieldname = 'flexinode_'. $field->field_id;
50      $output = check_plain($node->$fieldname);
51      return $output ? '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;'. $output .'">'. $output .'</a>' : '';
52    }
53    
54    function flexinode_field_email_config($field, $edit) {
55      return array('default_value' => array(
56        '#type' => 'textfield',
57        '#title' => t('Default value'),
58        '#default_value' => $field->default_value,
59        ));
60    }
61    
62    
63    /**
64     * @addtogroup themeable
65     * @{
66     */
67    
68    /**
69     * Format a single-line text field for display in a node.
70     *
71     * @param field_id
72     *   Which field is being displayed (useful when overriding this function
73     *   if you want to style one particular field differently).
74     * @param label
75     *   The label for the field as displayed on the node form.
76     * @param value
77     *   The value that the user entered for the field.
78     * @param formatted_value
79     *   The value that the user entered for the field as pre-formatted by the module.
80     */
81    function theme_flexinode_email($field_id, $label, $value, $formatted_value) {
82      return theme('form_element', $label, $formatted_value);
83    }
84    
85    /** @} End of addtogroup themeable */
86    
87    function flexinode_unhtmlentities($string) {
88       $trans_tbl = get_html_translation_table(HTML_ENTITIES);
89       $trans_tbl = array_flip($trans_tbl);
90       return strtr($string, $trans_tbl);
91    }
92    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2