/[drupal]/contributions/modules/computed_field/computed_field.module
ViewVC logotype

Diff of /contributions/modules/computed_field/computed_field.module

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

revision 1.18, Tue Oct 7 17:26:12 2008 UTC revision 1.19, Fri Jul 31 21:52:51 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: computed_field.module,v 1.17.2.3 2008/09/29 04:08:21 moonshine Exp $  // $Id: computed_field.module,v 1.17.2.6 2009/05/19 00:44:17 moonshine Exp $
3    
4  /**  /**
5   * Implementation of cck hook_field_info()   * Implementation of cck hook_field_info()
# Line 95  function computed_field_field_settings($ Line 95  function computed_field_field_settings($
95      case 'database columns':      case 'database columns':
96        if ($field['store']) {        if ($field['store']) {
97          $columns = array('value' => array());          $columns = array('value' => array());
98          $columns['value']['type'] = isset($field['data_type']) ? $field['data_type'] : 'varchar';          if ($field['data_type'] == 'longtext') {
99              $columns['value']['type'] = 'text';
100              $columns['value']['size'] = 'big';
101            }
102            else {
103              $columns['value']['type'] = isset($field['data_type']) ? $field['data_type'] : 'varchar';
104            }
105          // text and longtext should not have a length, so we ignore it          // text and longtext should not have a length, so we ignore it
106          if (!($field['data_type'] == 'text' || $field['data_type'] == 'longtext')) {          if (!($field['data_type'] == 'text' || $field['data_type'] == 'longtext')) {
107            $columns['value']['length'] = isset($field['data_length']) ? $field['data_length'] : 32;            $columns['value']['length'] = isset($field['data_length']) ? $field['data_length'] : 32;
# Line 151  function computed_field_field($op, &$nod Line 157  function computed_field_field($op, &$nod
157          return array($field['field_name'] => $node_field);          return array($field['field_name'] => $node_field);
158        }        }
159        break;        break;
160        case 'sanitize':
161          // compute field for node previews
162          if ($node->build_mode == NODE_BUILD_PREVIEW) {
163            _computed_field_compute_value($node, $field, $node_field);
164          }
165          break;
166      case 'view':      case 'view':
167        if ($field['display']) {        if ($field['display']) {
168          $items = array();          $items = array();
# Line 185  function computed_field_widget_info() { Line 197  function computed_field_widget_info() {
197  /**  /**
198   * Implementation of cck hook_widget()   * Implementation of cck hook_widget()
199   */   */
200  function computed_field_widget($op, &$node, $field, &$node_field) {  function computed_field_widget(&$form, &$form_state, $field, $items, $delta = 0) {
201    switch ($op) {    $elements = array();
202      case 'form':    foreach($items as $delta => $item) {
203        $form = array();      $elements[$delta]['value'] = array (
204          '#type' => 'value',
205        $form[$field['field_name']] = array('#tree' => TRUE);        '#tree' => TRUE,
206          '#default_value' => isset($item['value']) ? $item['value'] : NULL,
207        $form[$field['field_name']][0]['value'] = array(      );
         '#type' => 'value',  
         '#title' => t($field['widget']['label']),  
         '#default_value' => isset($node_field[0]['value']) ? $node_field[0]['value'] : '',  
       );  
       return $form;  
208    }    }
209      return $elements;
210  }  }
211    
212  /**  /**

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

  ViewVC Help
Powered by ViewVC 1.1.2