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

Diff of /contributions/modules/flexinode/field_url.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_url.inc,v 1.10 2005/11/10 09:32:14 crunchywelch Exp $
3    
4    function flexinode_field_url_name($field) {
5      return t('URL');
6    }
7    
8    function flexinode_field_url_form($field, &$node, $error) {
9      $fieldname = 'flexinode_'. $field->field_id;
10      return array($fieldname => array(
11        '#type' => 'textfield',
12        '#title' => t($field->label),
13        '#default_value' => isset($node->$fieldname) ? $node->$fieldname : $field->default_value,
14        '#description' => t($field->description),
15        '#required' => $field->required,
16        '#weight' => $field->weight,
17        ));
18    }
19    
20    function flexinode_field_url_db_select($field) {
21      $fieldname = 'flexinode_'. $field->field_id;
22      return $fieldname .'.textual_data AS '. $fieldname;
23    }
24    
25    function flexinode_field_url_db_sort_column($field) {
26      return 'flexinode_'. $field->field_id .'.textual_data';
27    }
28    
29    function flexinode_field_url_insert($field, $node) {
30      $fieldname = 'flexinode_'. $field->field_id;
31      db_query("INSERT INTO {flexinode_data} (nid, field_id, textual_data) VALUES (%d, %d, '%s')", $node->nid, $field->field_id, $node->$fieldname);
32    }
33    
34    function flexinode_field_url_validate($field, $node) {
35      $fieldname = 'flexinode_'. $field->field_id;
36    
37      // If the URL is empty, or it validates as an absolute URL, or it validates
38      // as a relative URL, the URL is considered valid.
39      if (!(empty($node->$fieldname) || valid_url($node->$fieldname, true) || valid_url($node->$fieldname))) {
40        form_set_error($node->$fieldname, t('The url is not valid.'));
41      }
42    }
43    
44    function flexinode_field_url_format($field, $node, $brief = 0) {
45      $fieldname = 'flexinode_'. $field->field_id;
46      $output = check_plain($node->$fieldname);
47      return $output ? '<a href="'.(ERegI('^[a-z0-9_]+://', $output) ? $output:'http://'.$output) .'">'. $output .'</a>' : '';
48    }
49    
50    function flexinode_field_url_config($field) {
51      return array('default_value' => array(
52        '#type' => 'textfield',
53        '#title' => t('Default value'),
54        '#default_value' => $field->default_value,
55        ));
56    }
57    
58    
59    /**
60     * @addtogroup themeable
61     * @{
62     */
63    
64    /**
65     * Format a single-line text field for display in a node.
66     *
67     * @param field_id
68     *   Which field is being displayed (useful when overriding this function
69     *   if you want to style one particular field differently).
70     * @param label
71     *   The label for the field as displayed on the node form.
72     * @param value
73     *   The value that the user entered for the field.
74     * @param formatted_value
75     *   The value that the user entered for the field as pre-formatted by the module.
76     */
77    function theme_flexinode_url($field_id, $label, $value, $formatted_value) {
78      return theme('form_element', $label, $formatted_value);
79    }
80    
81    /** @} End of addtogroup themeable */
82    

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

  ViewVC Help
Powered by ViewVC 1.1.2