@@ -41,31 +41,31 @@ |
||
| 41 | 41 | |
| 42 | 42 | // Now update values, options, etc. to those selected in the imported view. |
| 43 | 43 | switch ($type) { |
| 44 | - case 'field': |
|
| 45 | - $view->display[$display]->display_options['fields'][$views_field['field']]['format'] = $views_field['options']; |
|
| 46 | - if ($views_field['handler'] == 'content_views_field_handler_group') { |
|
| 47 | - $view->display[$display]->display_options['fields'][$views_field['field']]['multiple']['group'] = 1; |
|
| 48 | - } |
|
| 49 | - else { |
|
| 50 | - $view->display[$display]->display_options['fields'][$views_field['field']]['multiple']['group'] = 0; |
|
| 51 | - } |
|
| 52 | - return; |
|
| 44 | + case 'field': |
|
| 45 | + $view->display[$display]->display_options['fields'][$views_field['field']]['format'] = $views_field['options']; |
|
| 46 | + if ($views_field['handler'] == 'content_views_field_handler_group') { |
|
| 47 | + $view->display[$display]->display_options['fields'][$views_field['field']]['multiple']['group'] = 1; |
|
| 48 | + } |
|
| 49 | + else { |
|
| 50 | + $view->display[$display]->display_options['fields'][$views_field['field']]['multiple']['group'] = 0; |
|
| 51 | + } |
|
| 52 | + return; |
|
| 53 | 53 | |
| 54 | - case 'filter': |
|
| 55 | - // TODO |
|
| 56 | - return; |
|
| 54 | + case 'filter': |
|
| 55 | + // TODO |
|
| 56 | + return; |
|
| 57 | 57 | |
| 58 | - case 'exposed_filter': |
|
| 59 | - // TODO |
|
| 60 | - return; |
|
| 58 | + case 'exposed_filter': |
|
| 59 | + // TODO |
|
| 60 | + return; |
|
| 61 | 61 | |
| 62 | - case 'argument': |
|
| 63 | - // TODO |
|
| 64 | - return; |
|
| 62 | + case 'argument': |
|
| 63 | + // TODO |
|
| 64 | + return; |
|
| 65 | 65 | |
| 66 | - case 'sort': |
|
| 67 | - // TODO |
|
| 68 | - break; |
|
| 66 | + case 'sort': |
|
| 67 | + // TODO |
|
| 68 | + break; |
|
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | return; |
@@ -221,27 +221,27 @@ |
||
| 221 | 221 | |
| 222 | 222 | // Identify likely filters and arguments for each column based on field type. |
| 223 | 223 | switch ($attributes['type']) { |
| 224 | - case 'int': |
|
| 225 | - case 'mediumint': |
|
| 226 | - case 'tinyint': |
|
| 227 | - case 'bigint': |
|
| 228 | - case 'serial': |
|
| 229 | - $filters[] = 'content_handler_filter_numeric'; |
|
| 230 | - $arguments[] = 'content_handler_argument_numeric'; |
|
| 231 | - break; |
|
| 232 | - case 'numeric': |
|
| 233 | - case 'float': |
|
| 234 | - $filters[] = 'content_handler_filter_float'; |
|
| 235 | - $arguments[] = 'content_handler_argument_numeric'; |
|
| 236 | - break; |
|
| 224 | + case 'int': |
|
| 225 | + case 'mediumint': |
|
| 226 | + case 'tinyint': |
|
| 227 | + case 'bigint': |
|
| 228 | + case 'serial': |
|
| 229 | + $filters[] = 'content_handler_filter_numeric'; |
|
| 230 | + $arguments[] = 'content_handler_argument_numeric'; |
|
| 231 | + break; |
|
| 232 | + case 'numeric': |
|
| 233 | + case 'float': |
|
| 234 | + $filters[] = 'content_handler_filter_float'; |
|
| 235 | + $arguments[] = 'content_handler_argument_numeric'; |
|
| 236 | + break; |
|
| 237 | 237 | |
| 238 | - case 'text': |
|
| 239 | - case 'blob': |
|
| 240 | - // TODO add markup handlers for these types |
|
| 241 | - default: |
|
| 242 | - $filters[] = 'content_handler_filter_string'; |
|
| 243 | - $arguments[] = 'content_handler_argument_string'; |
|
| 244 | - break; |
|
| 238 | + case 'text': |
|
| 239 | + case 'blob': |
|
| 240 | + // TODO add markup handlers for these types |
|
| 241 | + default: |
|
| 242 | + $filters[] = 'content_handler_filter_string'; |
|
| 243 | + $arguments[] = 'content_handler_argument_string'; |
|
| 244 | + break; |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | function options_submit($form, &$form_state) { |
| 104 | 104 | switch ($form_state['values']['options']['label_type']) { |
| 105 | - case 'none': |
|
| 106 | - $form_state['values']['options']['label'] = ''; |
|
| 107 | - break; |
|
| 108 | - case 'widget': |
|
| 109 | - $form_state['values']['options']['label'] = $this->content_field['widget']['label']; |
|
| 110 | - break; |
|
| 105 | + case 'none': |
|
| 106 | + $form_state['values']['options']['label'] = ''; |
|
| 107 | + break; |
|
| 108 | + case 'widget': |
|
| 109 | + $form_state['values']['options']['label'] = $this->content_field['widget']['label']; |
|
| 110 | + break; |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
@@ -125,12 +125,12 @@ discard block |
||
| 125 | 125 | function label() { |
| 126 | 126 | $field = $this->content_field; |
| 127 | 127 | switch ($this->options['label_type']) { |
| 128 | - case 'none': |
|
| 129 | - return ''; |
|
| 130 | - case 'widget': |
|
| 131 | - return $field['widget']['label']; |
|
| 132 | - default: |
|
| 133 | - return $this->options['label']; |
|
| 128 | + case 'none': |
|
| 129 | + return ''; |
|
| 130 | + case 'widget': |
|
| 131 | + return $field['widget']['label']; |
|
| 132 | + default: |
|
| 133 | + return $this->options['label']; |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
@@ -151,23 +151,23 @@ |
||
| 151 | 151 | $field_name = $field['field_name']; |
| 152 | 152 | |
| 153 | 153 | switch ($field['multiple']) { |
| 154 | - case 0: |
|
| 155 | - $max = 0; |
|
| 156 | - break; |
|
| 157 | - case 1: |
|
| 158 | - $filled_items = content_set_empty($field, $items); |
|
| 159 | - $current_item_count = isset($form_state['item_count'][$field_name]) |
|
| 160 | - ? $form_state['item_count'][$field_name] |
|
| 161 | - : count($items); |
|
| 162 | - // We always want at least one empty icon for the user to fill in. |
|
| 163 | - $max = ($current_item_count > count($filled_items)) |
|
| 164 | - ? $current_item_count - 1 |
|
| 165 | - : $current_item_count; |
|
| 166 | - |
|
| 167 | - break; |
|
| 168 | - default: |
|
| 169 | - $max = $field['multiple'] - 1; |
|
| 170 | - break; |
|
| 154 | + case 0: |
|
| 155 | + $max = 0; |
|
| 156 | + break; |
|
| 157 | + case 1: |
|
| 158 | + $filled_items = content_set_empty($field, $items); |
|
| 159 | + $current_item_count = isset($form_state['item_count'][$field_name]) |
|
| 160 | + ? $form_state['item_count'][$field_name] |
|
| 161 | + : count($items); |
|
| 162 | + // We always want at least one empty icon for the user to fill in. |
|
| 163 | + $max = ($current_item_count > count($filled_items)) |
|
| 164 | + ? $current_item_count - 1 |
|
| 165 | + : $current_item_count; |
|
| 166 | + |
|
| 167 | + break; |
|
| 168 | + default: |
|
| 169 | + $max = $field['multiple'] - 1; |
|
| 170 | + break; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $title = check_plain(t($field['widget']['label'])); |
@@ -32,15 +32,15 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | else { |
| 34 | 34 | switch ($field['multiple']) { |
| 35 | - case 0: |
|
| 36 | - $max = 0; |
|
| 37 | - break; |
|
| 38 | - case 1: |
|
| 39 | - $max = rand(0, 3); //just an arbitrary number for 'unlimited' |
|
| 40 | - break; |
|
| 41 | - default: |
|
| 42 | - $max = $field['multiple']; |
|
| 43 | - break; |
|
| 35 | + case 0: |
|
| 36 | + $max = 0; |
|
| 37 | + break; |
|
| 38 | + case 1: |
|
| 39 | + $max = rand(0, 3); //just an arbitrary number for 'unlimited' |
|
| 40 | + break; |
|
| 41 | + default: |
|
| 42 | + $max = $field['multiple']; |
|
| 43 | + break; |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | for ($i = 0; $i <= $max; $i++) { |
@@ -73,15 +73,15 @@ discard block |
||
| 73 | 73 | $node_field = array(); |
| 74 | 74 | if (function_exists($function)) { |
| 75 | 75 | switch ($field['multiple']) { |
| 76 | - case 0: |
|
| 77 | - $max = 0; |
|
| 78 | - break; |
|
| 79 | - case 1: |
|
| 80 | - $max = rand(0, 3); //just an arbitrary number for 'unlimited' |
|
| 81 | - break; |
|
| 82 | - default: |
|
| 83 | - $max = $field['multiple']; |
|
| 84 | - break; |
|
| 76 | + case 0: |
|
| 77 | + $max = 0; |
|
| 78 | + break; |
|
| 79 | + case 1: |
|
| 80 | + $max = rand(0, 3); //just an arbitrary number for 'unlimited' |
|
| 81 | + break; |
|
| 82 | + default: |
|
| 83 | + $max = $field['multiple']; |
|
| 84 | + break; |
|
| 85 | 85 | } |
| 86 | 86 | for ($i = 0; $i <= $max; $i++) { |
| 87 | 87 | $node_field[$i] = $function($node, $field); |
@@ -145,25 +145,25 @@ discard block |
||
| 145 | 145 | else { |
| 146 | 146 | $min = is_numeric($field['min']) ? $field['min'] : 0; |
| 147 | 147 | switch ($field['type']) { |
| 148 | - case 'number_integer': |
|
| 149 | - $max = is_numeric($field['max']) ? $field['max'] : 10000; |
|
| 150 | - $decimal = 0; |
|
| 151 | - $scale = 0; |
|
| 152 | - break; |
|
| 148 | + case 'number_integer': |
|
| 149 | + $max = is_numeric($field['max']) ? $field['max'] : 10000; |
|
| 150 | + $decimal = 0; |
|
| 151 | + $scale = 0; |
|
| 152 | + break; |
|
| 153 | 153 | |
| 154 | - case 'number_decimal': |
|
| 155 | - $precision = is_numeric($field['precision']) ? $field['precision'] : 10; |
|
| 156 | - $scale = is_numeric($field['scale']) ? $field['scale'] : 2; |
|
| 157 | - $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale)); |
|
| 158 | - $decimal = rand(0, (10 * $scale)) / 100; |
|
| 159 | - break; |
|
| 154 | + case 'number_decimal': |
|
| 155 | + $precision = is_numeric($field['precision']) ? $field['precision'] : 10; |
|
| 156 | + $scale = is_numeric($field['scale']) ? $field['scale'] : 2; |
|
| 157 | + $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale)); |
|
| 158 | + $decimal = rand(0, (10 * $scale)) / 100; |
|
| 159 | + break; |
|
| 160 | 160 | |
| 161 | - case 'number_float': |
|
| 162 | - $precision = rand(10, 32); |
|
| 163 | - $scale = rand(0, 2); |
|
| 164 | - $decimal = rand(0, (10 * $scale)) / 100; |
|
| 165 | - $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale)); |
|
| 166 | - break; |
|
| 161 | + case 'number_float': |
|
| 162 | + $precision = rand(10, 32); |
|
| 163 | + $scale = rand(0, 2); |
|
| 164 | + $decimal = rand(0, (10 * $scale)) / 100; |
|
| 165 | + $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale)); |
|
| 166 | + break; |
|
| 167 | 167 | } |
| 168 | 168 | $node_field['value'] = round((rand($min, $max) + $decimal), $scale); |
| 169 | 169 | } |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | function fieldgroup_content_fieldapi($op, $field) { |
| 95 | 95 | switch ($op) { |
| 96 | - case 'delete instance': |
|
| 97 | - db_query("DELETE FROM {". fieldgroup_fields_tablename() ."} WHERE field_name = '%s' AND type_name = '%s'", $field['field_name'], $field['type_name']); |
|
| 98 | - cache_clear_all('fieldgroup_data:', content_cache_tablename(), TRUE); |
|
| 99 | - break; |
|
| 96 | + case 'delete instance': |
|
| 97 | + db_query("DELETE FROM {". fieldgroup_fields_tablename() ."} WHERE field_name = '%s' AND type_name = '%s'", $field['field_name'], $field['type_name']); |
|
| 98 | + cache_clear_all('fieldgroup_data:', content_cache_tablename(), TRUE); |
|
| 99 | + break; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
@@ -540,15 +540,15 @@ discard block |
||
| 540 | 540 | */ |
| 541 | 541 | function fieldgroup_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
| 542 | 542 | switch ($op) { |
| 543 | - case 'view': |
|
| 544 | - // Prevent against invalid 'nodes' built by broken 3rd party code. |
|
| 545 | - if (isset($node->type)) { |
|
| 546 | - // Build the node content element needed to render each fieldgroup. |
|
| 547 | - foreach (fieldgroup_groups($node->type) as $group) { |
|
| 548 | - fieldgroup_build_content($group, $node, $teaser, $page); |
|
| 549 | - } |
|
| 543 | + case 'view': |
|
| 544 | + // Prevent against invalid 'nodes' built by broken 3rd party code. |
|
| 545 | + if (isset($node->type)) { |
|
| 546 | + // Build the node content element needed to render each fieldgroup. |
|
| 547 | + foreach (fieldgroup_groups($node->type) as $group) { |
|
| 548 | + fieldgroup_build_content($group, $node, $teaser, $page); |
|
| 550 | 549 | } |
| 551 | - break; |
|
| 550 | + } |
|
| 551 | + break; |
|
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | |
@@ -591,22 +591,22 @@ discard block |
||
| 591 | 591 | $format = isset($group['settings']['display'][$context]['format']) ? $group['settings']['display'][$context]['format'] : 'fieldset'; |
| 592 | 592 | |
| 593 | 593 | switch ($format) { |
| 594 | - case 'simple': |
|
| 595 | - $element['#type'] = 'fieldgroup_simple'; |
|
| 596 | - $element['#group_name'] = $group_name; |
|
| 597 | - $element['#node'] = $node; |
|
| 598 | - break; |
|
| 599 | - case 'hidden': |
|
| 600 | - $element['#access'] = FALSE; |
|
| 601 | - break; |
|
| 602 | - case 'fieldset_collapsed': |
|
| 603 | - $element['#collapsed'] = TRUE; |
|
| 604 | - case 'fieldset_collapsible': |
|
| 605 | - $element['#collapsible'] = TRUE; |
|
| 606 | - case 'fieldset': |
|
| 607 | - $element['#type'] = 'fieldgroup_fieldset'; |
|
| 608 | - $element['#attributes'] = array('class' => 'fieldgroup '. strtr($group['group_name'], '_', '-')); |
|
| 609 | - break; |
|
| 594 | + case 'simple': |
|
| 595 | + $element['#type'] = 'fieldgroup_simple'; |
|
| 596 | + $element['#group_name'] = $group_name; |
|
| 597 | + $element['#node'] = $node; |
|
| 598 | + break; |
|
| 599 | + case 'hidden': |
|
| 600 | + $element['#access'] = FALSE; |
|
| 601 | + break; |
|
| 602 | + case 'fieldset_collapsed': |
|
| 603 | + $element['#collapsed'] = TRUE; |
|
| 604 | + case 'fieldset_collapsible': |
|
| 605 | + $element['#collapsible'] = TRUE; |
|
| 606 | + case 'fieldset': |
|
| 607 | + $element['#type'] = 'fieldgroup_fieldset'; |
|
| 608 | + $element['#attributes'] = array('class' => 'fieldgroup '. strtr($group['group_name'], '_', '-')); |
|
| 609 | + break; |
|
| 610 | 610 | } |
| 611 | 611 | foreach ($group['fields'] as $field_name => $field) { |
| 612 | 612 | if (isset($node->content[$field_name])) { |
@@ -79,102 +79,102 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | function nodereference_field_settings($op, $field) { |
| 81 | 81 | switch ($op) { |
| 82 | - case 'form': |
|
| 83 | - $form = array(); |
|
| 84 | - $form['referenceable_types'] = array( |
|
| 85 | - '#type' => 'checkboxes', |
|
| 86 | - '#title' => t('Content types that can be referenced'), |
|
| 87 | - '#multiple' => TRUE, |
|
| 88 | - '#default_value' => is_array($field['referenceable_types']) ? $field['referenceable_types'] : array(), |
|
| 89 | - '#options' => array_map('check_plain', node_get_types('names')), |
|
| 90 | - ); |
|
| 91 | - if (module_exists('views')) { |
|
| 92 | - $views = array('--' => '--'); |
|
| 93 | - $all_views = views_get_all_views(); |
|
| 94 | - foreach ($all_views as $view) { |
|
| 95 | - // Only 'node' views that have fields will work for our purpose. |
|
| 96 | - if ($view->base_table == 'node' && !empty($view->display['default']->display_options['fields'])) { |
|
| 97 | - if ($view->type == 'Default') { |
|
| 98 | - $views[t('Default Views')][$view->name] = $view->name; |
|
| 99 | - } |
|
| 100 | - else { |
|
| 101 | - $views[t('Existing Views')][$view->name] = $view->name; |
|
| 102 | - } |
|
| 82 | + case 'form': |
|
| 83 | + $form = array(); |
|
| 84 | + $form['referenceable_types'] = array( |
|
| 85 | + '#type' => 'checkboxes', |
|
| 86 | + '#title' => t('Content types that can be referenced'), |
|
| 87 | + '#multiple' => TRUE, |
|
| 88 | + '#default_value' => is_array($field['referenceable_types']) ? $field['referenceable_types'] : array(), |
|
| 89 | + '#options' => array_map('check_plain', node_get_types('names')), |
|
| 90 | + ); |
|
| 91 | + if (module_exists('views')) { |
|
| 92 | + $views = array('--' => '--'); |
|
| 93 | + $all_views = views_get_all_views(); |
|
| 94 | + foreach ($all_views as $view) { |
|
| 95 | + // Only 'node' views that have fields will work for our purpose. |
|
| 96 | + if ($view->base_table == 'node' && !empty($view->display['default']->display_options['fields'])) { |
|
| 97 | + if ($view->type == 'Default') { |
|
| 98 | + $views[t('Default Views')][$view->name] = $view->name; |
|
| 99 | + } |
|
| 100 | + else { |
|
| 101 | + $views[t('Existing Views')][$view->name] = $view->name; |
|
| 103 | 102 | } |
| 104 | - } |
|
| 105 | - |
|
| 106 | - $form['advanced'] = array( |
|
| 107 | - '#type' => 'fieldset', |
|
| 108 | - '#title' => t('Advanced - Nodes that can be referenced (View)'), |
|
| 109 | - '#collapsible' => TRUE, |
|
| 110 | - '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--', |
|
| 111 | - ); |
|
| 112 | - if (count($views) > 1) { |
|
| 113 | - $form['advanced']['advanced_view'] = array( |
|
| 114 | - '#type' => 'select', |
|
| 115 | - '#title' => t('View used to select the nodes'), |
|
| 116 | - '#options' => $views, |
|
| 117 | - '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--', |
|
| 118 | - '#description' => t('<p>Choose the "Views module" view that selects the nodes that can be referenced.<br />Note:</p>') . |
|
| 119 | - t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Content types" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate nodes on node creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate nodes will be displayed.</li></ul>'), |
|
| 120 | - ); |
|
| 121 | - $form['advanced']['advanced_view_args'] = array( |
|
| 122 | - '#type' => 'textfield', |
|
| 123 | - '#title' => t('View arguments'), |
|
| 124 | - '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '', |
|
| 125 | - '#required' => FALSE, |
|
| 126 | - '#description' => t('Provide a comma separated list of arguments to pass to the view.'), |
|
| 127 | - ); |
|
| 128 | - } |
|
| 129 | - else { |
|
| 130 | - $form['advanced']['no_view_help'] = array( |
|
| 131 | - '#value' => t('<p>The list of nodes that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') . |
|
| 132 | - t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Content types" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate nodes on node creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate nodes will be displayed.</li></ul>'), |
|
| 133 | - ); |
|
| 134 | 103 | } |
| 135 | 104 | } |
| 136 | - return $form; |
|
| 137 | 105 | |
| 138 | - case 'save': |
|
| 139 | - $settings = array('referenceable_types'); |
|
| 140 | - if (module_exists('views')) { |
|
| 141 | - $settings[] = 'advanced_view'; |
|
| 142 | - $settings[] = 'advanced_view_args'; |
|
| 106 | + $form['advanced'] = array( |
|
| 107 | + '#type' => 'fieldset', |
|
| 108 | + '#title' => t('Advanced - Nodes that can be referenced (View)'), |
|
| 109 | + '#collapsible' => TRUE, |
|
| 110 | + '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--', |
|
| 111 | + ); |
|
| 112 | + if (count($views) > 1) { |
|
| 113 | + $form['advanced']['advanced_view'] = array( |
|
| 114 | + '#type' => 'select', |
|
| 115 | + '#title' => t('View used to select the nodes'), |
|
| 116 | + '#options' => $views, |
|
| 117 | + '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--', |
|
| 118 | + '#description' => t('<p>Choose the "Views module" view that selects the nodes that can be referenced.<br />Note:</p>') . |
|
| 119 | + t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Content types" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate nodes on node creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate nodes will be displayed.</li></ul>'), |
|
| 120 | + ); |
|
| 121 | + $form['advanced']['advanced_view_args'] = array( |
|
| 122 | + '#type' => 'textfield', |
|
| 123 | + '#title' => t('View arguments'), |
|
| 124 | + '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '', |
|
| 125 | + '#required' => FALSE, |
|
| 126 | + '#description' => t('Provide a comma separated list of arguments to pass to the view.'), |
|
| 127 | + ); |
|
| 128 | + } |
|
| 129 | + else { |
|
| 130 | + $form['advanced']['no_view_help'] = array( |
|
| 131 | + '#value' => t('<p>The list of nodes that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') . |
|
| 132 | + t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Content types" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate nodes on node creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate nodes will be displayed.</li></ul>'), |
|
| 133 | + ); |
|
| 143 | 134 | } |
| 144 | - return $settings; |
|
| 135 | + } |
|
| 136 | + return $form; |
|
| 145 | 137 | |
| 146 | - case 'database columns': |
|
| 147 | - $columns = array( |
|
| 148 | - 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE), |
|
| 149 | - ); |
|
| 150 | - return $columns; |
|
| 151 | - |
|
| 152 | - case 'views data': |
|
| 153 | - $data = content_views_field_views_data($field); |
|
| 154 | - $db_info = content_database_info($field); |
|
| 155 | - $table_alias = content_views_tablename($field); |
|
| 156 | - |
|
| 157 | - // Filter: swap the handler to the 'in' operator. |
|
| 158 | - $data[$table_alias][$field['field_name'] .'_nid']['filter']['handler'] = 'content_handler_filter_many_to_one'; |
|
| 159 | - // Argument: use node.title for summaries. |
|
| 160 | - $data["node_$table_alias"]['table']['join']['node'] = array( |
|
| 161 | - 'table' => 'node', |
|
| 162 | - 'field' => 'nid', |
|
| 163 | - 'left_table' => $table_alias, |
|
| 164 | - 'left_field' => $field['field_name'] .'_nid', |
|
| 165 | - ); |
|
| 166 | - $data[$table_alias][$field['field_name'] .'_nid']['argument']['handler'] = 'content_handler_argument_reference'; |
|
| 167 | - $data[$table_alias][$field['field_name'] .'_nid']['argument']['name table'] = "node_$table_alias"; |
|
| 168 | - $data[$table_alias][$field['field_name'] .'_nid']['argument']['name field'] = 'title'; |
|
| 169 | - // Relationship: add a relationship for related node. |
|
| 170 | - $data[$table_alias][$field['field_name'] .'_nid']['relationship'] = array( |
|
| 171 | - 'base' => 'node', |
|
| 172 | - 'field' => $db_info['columns']['nid']['column'], |
|
| 173 | - 'handler' => 'content_handler_relationship', |
|
| 174 | - 'label' => t($field['widget']['label']), |
|
| 175 | - 'content_field_name' => $field['field_name'], |
|
| 176 | - ); |
|
| 177 | - return $data; |
|
| 138 | + case 'save': |
|
| 139 | + $settings = array('referenceable_types'); |
|
| 140 | + if (module_exists('views')) { |
|
| 141 | + $settings[] = 'advanced_view'; |
|
| 142 | + $settings[] = 'advanced_view_args'; |
|
| 143 | + } |
|
| 144 | + return $settings; |
|
| 145 | + |
|
| 146 | + case 'database columns': |
|
| 147 | + $columns = array( |
|
| 148 | + 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE), |
|
| 149 | + ); |
|
| 150 | + return $columns; |
|
| 151 | + |
|
| 152 | + case 'views data': |
|
| 153 | + $data = content_views_field_views_data($field); |
|
| 154 | + $db_info = content_database_info($field); |
|
| 155 | + $table_alias = content_views_tablename($field); |
|
| 156 | + |
|
| 157 | + // Filter: swap the handler to the 'in' operator. |
|
| 158 | + $data[$table_alias][$field['field_name'] .'_nid']['filter']['handler'] = 'content_handler_filter_many_to_one'; |
|
| 159 | + // Argument: use node.title for summaries. |
|
| 160 | + $data["node_$table_alias"]['table']['join']['node'] = array( |
|
| 161 | + 'table' => 'node', |
|
| 162 | + 'field' => 'nid', |
|
| 163 | + 'left_table' => $table_alias, |
|
| 164 | + 'left_field' => $field['field_name'] .'_nid', |
|
| 165 | + ); |
|
| 166 | + $data[$table_alias][$field['field_name'] .'_nid']['argument']['handler'] = 'content_handler_argument_reference'; |
|
| 167 | + $data[$table_alias][$field['field_name'] .'_nid']['argument']['name table'] = "node_$table_alias"; |
|
| 168 | + $data[$table_alias][$field['field_name'] .'_nid']['argument']['name field'] = 'title'; |
|
| 169 | + // Relationship: add a relationship for related node. |
|
| 170 | + $data[$table_alias][$field['field_name'] .'_nid']['relationship'] = array( |
|
| 171 | + 'base' => 'node', |
|
| 172 | + 'field' => $db_info['columns']['nid']['column'], |
|
| 173 | + 'handler' => 'content_handler_relationship', |
|
| 174 | + 'label' => t($field['widget']['label']), |
|
| 175 | + 'content_field_name' => $field['field_name'], |
|
| 176 | + ); |
|
| 177 | + return $data; |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -186,91 +186,91 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | switch ($op) { |
| 188 | 188 | // When preparing a translation, load any translations of existing references. |
| 189 | - case 'prepare translation': |
|
| 190 | - $addition = array(); |
|
| 191 | - $addition[$field['field_name']] = array(); |
|
| 192 | - if (isset($node->translation_source->$field['field_name']) && is_array($node->translation_source->$field['field_name'])) { |
|
| 193 | - foreach ($node->translation_source->$field['field_name'] as $key => $reference) { |
|
| 194 | - $reference_node = node_load($reference['nid']); |
|
| 195 | - // Test if the referenced node type is translatable and, if so, |
|
| 196 | - // load translations if the reference is not for the current language. |
|
| 197 | - // We can assume the translation module is present because it invokes 'prepare translation'. |
|
| 198 | - if (translation_supported_type($reference_node->type) && !empty($reference_node->language) && $reference_node->language != $node->language && $translations = translation_node_get_translations($reference_node->tnid)) { |
|
| 199 | - // If there is a translation for the current language, use it. |
|
| 200 | - $addition[$field['field_name']][] = array( |
|
| 201 | - 'nid' => isset($translations[$node->language]) ? $translations[$node->language]->nid : $reference['nid'], |
|
| 202 | - ); |
|
| 203 | - } |
|
| 189 | + case 'prepare translation': |
|
| 190 | + $addition = array(); |
|
| 191 | + $addition[$field['field_name']] = array(); |
|
| 192 | + if (isset($node->translation_source->$field['field_name']) && is_array($node->translation_source->$field['field_name'])) { |
|
| 193 | + foreach ($node->translation_source->$field['field_name'] as $key => $reference) { |
|
| 194 | + $reference_node = node_load($reference['nid']); |
|
| 195 | + // Test if the referenced node type is translatable and, if so, |
|
| 196 | + // load translations if the reference is not for the current language. |
|
| 197 | + // We can assume the translation module is present because it invokes 'prepare translation'. |
|
| 198 | + if (translation_supported_type($reference_node->type) && !empty($reference_node->language) && $reference_node->language != $node->language && $translations = translation_node_get_translations($reference_node->tnid)) { |
|
| 199 | + // If there is a translation for the current language, use it. |
|
| 200 | + $addition[$field['field_name']][] = array( |
|
| 201 | + 'nid' => isset($translations[$node->language]) ? $translations[$node->language]->nid : $reference['nid'], |
|
| 202 | + ); |
|
| 204 | 203 | } |
| 205 | 204 | } |
| 206 | - return $addition; |
|
| 207 | - |
|
| 208 | - case 'validate': |
|
| 209 | - // Extract nids to check. |
|
| 210 | - $ids = array(); |
|
| 211 | - foreach ($items as $delta => $item) { |
|
| 212 | - if (is_array($item) && !empty($item['nid'])) { |
|
| 213 | - if (is_numeric($item['nid'])) { |
|
| 214 | - $ids[] = $item['nid']; |
|
| 215 | - } |
|
| 216 | - else { |
|
| 217 | - $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
| 218 | - if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
| 219 | - form_set_error($error_element, t("%name: invalid input.", array('%name' => t($field['widget']['label'])))); |
|
| 220 | - } |
|
| 205 | + } |
|
| 206 | + return $addition; |
|
| 207 | + |
|
| 208 | + case 'validate': |
|
| 209 | + // Extract nids to check. |
|
| 210 | + $ids = array(); |
|
| 211 | + foreach ($items as $delta => $item) { |
|
| 212 | + if (is_array($item) && !empty($item['nid'])) { |
|
| 213 | + if (is_numeric($item['nid'])) { |
|
| 214 | + $ids[] = $item['nid']; |
|
| 221 | 215 | } |
| 222 | - } |
|
| 223 | - // Prevent performance hog if there are no ids to check. |
|
| 224 | - if ($ids) { |
|
| 225 | - $refs = _nodereference_potential_references($field, '', NULL, $ids); |
|
| 226 | - foreach ($items as $delta => $item) { |
|
| 227 | - if (is_array($item)) { |
|
| 228 | - $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
| 229 | - if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
| 230 | - if (!empty($item['nid']) && !isset($refs[$item['nid']])) { |
|
| 231 | - form_set_error($error_element, t("%name: this post can't be referenced.", array('%name' => t($field['widget']['label'])))); |
|
| 232 | - } |
|
| 233 | - } |
|
| 216 | + else { |
|
| 217 | + $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
| 218 | + if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
| 219 | + form_set_error($error_element, t("%name: invalid input.", array('%name' => t($field['widget']['label'])))); |
|
| 234 | 220 | } |
| 235 | 221 | } |
| 236 | - return $items; |
|
| 237 | - |
|
| 238 | - case 'sanitize': |
|
| 239 | - // We can't just check the node is 'referenceable', because Views-mode |
|
| 240 | - // could rely on 'current user' (at edit time). |
|
| 241 | - |
|
| 242 | - // Extract nids to check. |
|
| 243 | - $ids = array(); |
|
| 222 | + } |
|
| 223 | + // Prevent performance hog if there are no ids to check. |
|
| 224 | + if ($ids) { |
|
| 225 | + $refs = _nodereference_potential_references($field, '', NULL, $ids); |
|
| 244 | 226 | foreach ($items as $delta => $item) { |
| 245 | 227 | if (is_array($item)) { |
| 246 | - // Default to 'non accessible'. |
|
| 247 | - $items[$delta]['safe'] = array(); |
|
| 248 | - if (!empty($item['nid']) && is_numeric($item['nid'])) { |
|
| 249 | - $ids[] = $item['nid']; |
|
| 228 | + $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
| 229 | + if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
| 230 | + if (!empty($item['nid']) && !isset($refs[$item['nid']])) { |
|
| 231 | + form_set_error($error_element, t("%name: this post can't be referenced.", array('%name' => t($field['widget']['label'])))); |
|
| 250 | 232 | } |
| 251 | 233 | } |
| 252 | 234 | } |
| 253 | - if ($ids) { |
|
| 254 | - // Load information about nids that we haven't already loaded during |
|
| 255 | - // this page request. |
|
| 256 | - $missing_ids = array_diff($ids, array_keys($sanitized_nodes)); |
|
| 257 | - if (!empty($missing_ids)) { |
|
| 258 | - $where = array('n.nid in ('. db_placeholders($missing_ids) . ')'); |
|
| 259 | - if (!user_access('administer nodes')) { |
|
| 260 | - $where[] = 'n.status = 1'; |
|
| 261 | - } |
|
| 262 | - $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status FROM {node} n WHERE '. implode(' AND ', $where)), $missing_ids); |
|
| 263 | - while ($row = db_fetch_array($result)) { |
|
| 264 | - $sanitized_nodes[$row['nid']] = $row; |
|
| 265 | - } |
|
| 235 | + } |
|
| 236 | + return $items; |
|
| 237 | + |
|
| 238 | + case 'sanitize': |
|
| 239 | + // We can't just check the node is 'referenceable', because Views-mode |
|
| 240 | + // could rely on 'current user' (at edit time). |
|
| 241 | + |
|
| 242 | + // Extract nids to check. |
|
| 243 | + $ids = array(); |
|
| 244 | + foreach ($items as $delta => $item) { |
|
| 245 | + if (is_array($item)) { |
|
| 246 | + // Default to 'non accessible'. |
|
| 247 | + $items[$delta]['safe'] = array(); |
|
| 248 | + if (!empty($item['nid']) && is_numeric($item['nid'])) { |
|
| 249 | + $ids[] = $item['nid']; |
|
| 266 | 250 | } |
| 267 | - foreach ($items as $delta => $item) { |
|
| 268 | - if (is_array($item) && !empty($item['nid']) && isset($sanitized_nodes[$item['nid']])) { |
|
| 269 | - $items[$delta]['safe'] = $sanitized_nodes[$item['nid']]; |
|
| 270 | - } |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + if ($ids) { |
|
| 254 | + // Load information about nids that we haven't already loaded during |
|
| 255 | + // this page request. |
|
| 256 | + $missing_ids = array_diff($ids, array_keys($sanitized_nodes)); |
|
| 257 | + if (!empty($missing_ids)) { |
|
| 258 | + $where = array('n.nid in ('. db_placeholders($missing_ids) . ')'); |
|
| 259 | + if (!user_access('administer nodes')) { |
|
| 260 | + $where[] = 'n.status = 1'; |
|
| 261 | + } |
|
| 262 | + $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status FROM {node} n WHERE '. implode(' AND ', $where)), $missing_ids); |
|
| 263 | + while ($row = db_fetch_array($result)) { |
|
| 264 | + $sanitized_nodes[$row['nid']] = $row; |
|
| 271 | 265 | } |
| 272 | 266 | } |
| 273 | - return $items; |
|
| 267 | + foreach ($items as $delta => $item) { |
|
| 268 | + if (is_array($item) && !empty($item['nid']) && isset($sanitized_nodes[$item['nid']])) { |
|
| 269 | + $items[$delta]['safe'] = $sanitized_nodes[$item['nid']]; |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + return $items; |
|
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | |
@@ -465,37 +465,37 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function nodereference_widget_settings($op, $widget) { |
| 467 | 467 | switch ($op) { |
| 468 | - case 'form': |
|
| 469 | - $form = array(); |
|
| 470 | - $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains'; |
|
| 471 | - $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60; |
|
| 472 | - if ($widget['type'] == 'nodereference_autocomplete') { |
|
| 473 | - $form['autocomplete_match'] = array( |
|
| 474 | - '#type' => 'select', |
|
| 475 | - '#title' => t('Autocomplete matching'), |
|
| 476 | - '#default_value' => $match, |
|
| 477 | - '#options' => array( |
|
| 478 | - 'starts_with' => t('Starts with'), |
|
| 479 | - 'contains' => t('Contains'), |
|
| 480 | - ), |
|
| 481 | - '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of nodes.'), |
|
| 482 | - ); |
|
| 483 | - $form['size'] = array( |
|
| 484 | - '#type' => 'textfield', |
|
| 485 | - '#title' => t('Size of textfield'), |
|
| 486 | - '#default_value' => $size, |
|
| 487 | - '#element_validate' => array('_element_validate_integer_positive'), |
|
| 488 | - '#required' => TRUE, |
|
| 489 | - ); |
|
| 490 | - } |
|
| 491 | - else { |
|
| 492 | - $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match); |
|
| 493 | - $form['size'] = array('#type' => 'hidden', '#value' => $size); |
|
| 494 | - } |
|
| 495 | - return $form; |
|
| 468 | + case 'form': |
|
| 469 | + $form = array(); |
|
| 470 | + $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains'; |
|
| 471 | + $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60; |
|
| 472 | + if ($widget['type'] == 'nodereference_autocomplete') { |
|
| 473 | + $form['autocomplete_match'] = array( |
|
| 474 | + '#type' => 'select', |
|
| 475 | + '#title' => t('Autocomplete matching'), |
|
| 476 | + '#default_value' => $match, |
|
| 477 | + '#options' => array( |
|
| 478 | + 'starts_with' => t('Starts with'), |
|
| 479 | + 'contains' => t('Contains'), |
|
| 480 | + ), |
|
| 481 | + '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of nodes.'), |
|
| 482 | + ); |
|
| 483 | + $form['size'] = array( |
|
| 484 | + '#type' => 'textfield', |
|
| 485 | + '#title' => t('Size of textfield'), |
|
| 486 | + '#default_value' => $size, |
|
| 487 | + '#element_validate' => array('_element_validate_integer_positive'), |
|
| 488 | + '#required' => TRUE, |
|
| 489 | + ); |
|
| 490 | + } |
|
| 491 | + else { |
|
| 492 | + $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match); |
|
| 493 | + $form['size'] = array('#type' => 'hidden', '#value' => $size); |
|
| 494 | + } |
|
| 495 | + return $form; |
|
| 496 | 496 | |
| 497 | - case 'save': |
|
| 498 | - return array('autocomplete_match', 'size'); |
|
| 497 | + case 'save': |
|
| 498 | + return array('autocomplete_match', 'size'); |
|
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | |
@@ -532,27 +532,27 @@ discard block |
||
| 532 | 532 | */ |
| 533 | 533 | function nodereference_widget(&$form, &$form_state, $field, $items, $delta = 0) { |
| 534 | 534 | switch ($field['widget']['type']) { |
| 535 | - case 'nodereference_select': |
|
| 536 | - $element = array( |
|
| 537 | - '#type' => 'nodereference_select', |
|
| 538 | - '#default_value' => $items, |
|
| 539 | - ); |
|
| 540 | - break; |
|
| 535 | + case 'nodereference_select': |
|
| 536 | + $element = array( |
|
| 537 | + '#type' => 'nodereference_select', |
|
| 538 | + '#default_value' => $items, |
|
| 539 | + ); |
|
| 540 | + break; |
|
| 541 | 541 | |
| 542 | - case 'nodereference_buttons': |
|
| 543 | - $element = array( |
|
| 544 | - '#type' => 'nodereference_buttons', |
|
| 545 | - '#default_value' => $items, |
|
| 546 | - ); |
|
| 547 | - break; |
|
| 542 | + case 'nodereference_buttons': |
|
| 543 | + $element = array( |
|
| 544 | + '#type' => 'nodereference_buttons', |
|
| 545 | + '#default_value' => $items, |
|
| 546 | + ); |
|
| 547 | + break; |
|
| 548 | 548 | |
| 549 | - case 'nodereference_autocomplete': |
|
| 550 | - $element = array( |
|
| 551 | - '#type' => 'nodereference_autocomplete', |
|
| 552 | - '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL, |
|
| 553 | - '#value_callback' => 'nodereference_autocomplete_value', |
|
| 554 | - ); |
|
| 555 | - break; |
|
| 549 | + case 'nodereference_autocomplete': |
|
| 550 | + $element = array( |
|
| 551 | + '#type' => 'nodereference_autocomplete', |
|
| 552 | + '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL, |
|
| 553 | + '#value_callback' => 'nodereference_autocomplete_value', |
|
| 554 | + ); |
|
| 555 | + break; |
|
| 556 | 556 | } |
| 557 | 557 | return $element; |
| 558 | 558 | } |
@@ -985,29 +985,29 @@ discard block |
||
| 985 | 985 | */ |
| 986 | 986 | function nodereference_node_type($op, $info) { |
| 987 | 987 | switch ($op) { |
| 988 | - case 'update': |
|
| 989 | - // Reflect type name changes to the 'referenceable types' settings. |
|
| 990 | - if (!empty($info->old_type) && $info->old_type != $info->type) { |
|
| 991 | - // content.module's implementaion of hook_node_type() has already |
|
| 992 | - // refreshed _content_type_info(). |
|
| 993 | - $fields = content_fields(); |
|
| 994 | - $rebuild = FALSE; |
|
| 995 | - foreach ($fields as $field_name => $field) { |
|
| 996 | - if ($field['type'] == 'nodereference' && isset($field['referenceable_types'][$info->old_type])) { |
|
| 997 | - $field['referenceable_types'][$info->type] = empty($field['referenceable_types'][$info->old_type]) ? 0 : $info->type; |
|
| 998 | - unset($field['referenceable_types'][$info->old_type]); |
|
| 999 | - content_field_instance_update($field, FALSE); |
|
| 1000 | - $rebuild = TRUE; |
|
| 1001 | - } |
|
| 988 | + case 'update': |
|
| 989 | + // Reflect type name changes to the 'referenceable types' settings. |
|
| 990 | + if (!empty($info->old_type) && $info->old_type != $info->type) { |
|
| 991 | + // content.module's implementaion of hook_node_type() has already |
|
| 992 | + // refreshed _content_type_info(). |
|
| 993 | + $fields = content_fields(); |
|
| 994 | + $rebuild = FALSE; |
|
| 995 | + foreach ($fields as $field_name => $field) { |
|
| 996 | + if ($field['type'] == 'nodereference' && isset($field['referenceable_types'][$info->old_type])) { |
|
| 997 | + $field['referenceable_types'][$info->type] = empty($field['referenceable_types'][$info->old_type]) ? 0 : $info->type; |
|
| 998 | + unset($field['referenceable_types'][$info->old_type]); |
|
| 999 | + content_field_instance_update($field, FALSE); |
|
| 1000 | + $rebuild = TRUE; |
|
| 1002 | 1001 | } |
| 1002 | + } |
|
| 1003 | 1003 | |
| 1004 | - // Clear caches and rebuild menu only if any field has been updated. |
|
| 1005 | - if ($rebuild) { |
|
| 1006 | - content_clear_type_cache(TRUE); |
|
| 1007 | - menu_rebuild(); |
|
| 1008 | - } |
|
| 1004 | + // Clear caches and rebuild menu only if any field has been updated. |
|
| 1005 | + if ($rebuild) { |
|
| 1006 | + content_clear_type_cache(TRUE); |
|
| 1007 | + menu_rebuild(); |
|
| 1009 | 1008 | } |
| 1010 | - break; |
|
| 1009 | + } |
|
| 1010 | + break; |
|
| 1011 | 1011 | } |
| 1012 | 1012 | } |
| 1013 | 1013 | |
@@ -54,142 +54,142 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function number_field_settings($op, $field) { |
| 56 | 56 | switch ($op) { |
| 57 | - case 'form': |
|
| 58 | - $form = array(); |
|
| 59 | - $form['min'] = array( |
|
| 60 | - '#type' => 'textfield', |
|
| 61 | - '#title' => t('Minimum'), |
|
| 62 | - '#element_validate' => array('_element_validate_number'), |
|
| 63 | - '#default_value' => is_numeric($field['min']) ? $field['min'] : '', |
|
| 57 | + case 'form': |
|
| 58 | + $form = array(); |
|
| 59 | + $form['min'] = array( |
|
| 60 | + '#type' => 'textfield', |
|
| 61 | + '#title' => t('Minimum'), |
|
| 62 | + '#element_validate' => array('_element_validate_number'), |
|
| 63 | + '#default_value' => is_numeric($field['min']) ? $field['min'] : '', |
|
| 64 | + ); |
|
| 65 | + $form['max'] = array( |
|
| 66 | + '#type' => 'textfield', |
|
| 67 | + '#title' => t('Maximum'), |
|
| 68 | + '#element_validate' => array('_element_validate_number'), |
|
| 69 | + '#default_value' => is_numeric($field['max']) ? $field['max'] : '', |
|
| 70 | + ); |
|
| 71 | + if ($field['type'] == 'number_decimal') { |
|
| 72 | + $form['precision'] = array( |
|
| 73 | + '#type' => 'select', |
|
| 74 | + '#options' => drupal_map_assoc(range(10, 32)), |
|
| 75 | + '#title' => t('Precision'), |
|
| 76 | + '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'), |
|
| 77 | + '#default_value' => is_numeric($field['precision']) ? $field['precision'] : 10, |
|
| 64 | 78 | ); |
| 65 | - $form['max'] = array( |
|
| 66 | - '#type' => 'textfield', |
|
| 67 | - '#title' => t('Maximum'), |
|
| 68 | - '#element_validate' => array('_element_validate_number'), |
|
| 69 | - '#default_value' => is_numeric($field['max']) ? $field['max'] : '', |
|
| 79 | + $form['scale'] = array( |
|
| 80 | + '#type' => 'select', |
|
| 81 | + '#options' => drupal_map_assoc(range(0, 10)), |
|
| 82 | + '#title' => t('Scale'), |
|
| 83 | + '#description' => t('The number of digits to the right of the decimal.'), |
|
| 84 | + '#default_value' => is_numeric($field['scale']) ? $field['scale'] : 2, |
|
| 70 | 85 | ); |
| 71 | - if ($field['type'] == 'number_decimal') { |
|
| 72 | - $form['precision'] = array( |
|
| 73 | - '#type' => 'select', |
|
| 74 | - '#options' => drupal_map_assoc(range(10, 32)), |
|
| 75 | - '#title' => t('Precision'), |
|
| 76 | - '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'), |
|
| 77 | - '#default_value' => is_numeric($field['precision']) ? $field['precision'] : 10, |
|
| 78 | - ); |
|
| 79 | - $form['scale'] = array( |
|
| 80 | - '#type' => 'select', |
|
| 81 | - '#options' => drupal_map_assoc(range(0, 10)), |
|
| 82 | - '#title' => t('Scale'), |
|
| 83 | - '#description' => t('The number of digits to the right of the decimal.'), |
|
| 84 | - '#default_value' => is_numeric($field['scale']) ? $field['scale'] : 2, |
|
| 85 | - ); |
|
| 86 | - $form['decimal'] = array( |
|
| 87 | - '#type' => 'select', |
|
| 88 | - '#options' => array('.' => 'decimal point', ',' => 'comma', ' ' => 'space'), |
|
| 89 | - '#title' => t('Decimal marker'), |
|
| 90 | - '#description' => t('The character users will input to mark the decimal point in forms.'), |
|
| 91 | - '#default_value' => !empty($field['decimal']) ? $field['decimal'] : '.', |
|
| 92 | - ); |
|
| 93 | - } |
|
| 94 | - $form['append']['prefix'] = array( |
|
| 95 | - '#type' => 'textfield', |
|
| 96 | - '#title' => t('Prefix'), |
|
| 97 | - '#size' => 60, |
|
| 98 | - '#default_value' => !empty($field['prefix']) ? $field['prefix'] : '', |
|
| 99 | - '#description' => t('Define a string that should be prefixed to the value, like $ or €. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'), |
|
| 100 | - ); |
|
| 101 | - $form['append']['suffix'] = array( |
|
| 102 | - '#type' => 'textfield', |
|
| 103 | - '#title' => t('Suffix'), |
|
| 104 | - '#size' => 60, |
|
| 105 | - '#default_value' => !empty($field['suffix']) ? $field['suffix'] : '', |
|
| 106 | - '#description' => t('Define a string that should suffixed to the value, like m², m/s², kb/s. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'), |
|
| 86 | + $form['decimal'] = array( |
|
| 87 | + '#type' => 'select', |
|
| 88 | + '#options' => array('.' => 'decimal point', ',' => 'comma', ' ' => 'space'), |
|
| 89 | + '#title' => t('Decimal marker'), |
|
| 90 | + '#description' => t('The character users will input to mark the decimal point in forms.'), |
|
| 91 | + '#default_value' => !empty($field['decimal']) ? $field['decimal'] : '.', |
|
| 107 | 92 | ); |
| 108 | - $form['allowed_values_fieldset'] = array( |
|
| 109 | - '#type' => 'fieldset', |
|
| 110 | - '#title' => t('Allowed values'), |
|
| 111 | - '#collapsible' => TRUE, |
|
| 112 | - '#collapsed' => TRUE, |
|
| 113 | - ); |
|
| 114 | - $form['allowed_values_fieldset']['allowed_values'] = array( |
|
| 93 | + } |
|
| 94 | + $form['append']['prefix'] = array( |
|
| 95 | + '#type' => 'textfield', |
|
| 96 | + '#title' => t('Prefix'), |
|
| 97 | + '#size' => 60, |
|
| 98 | + '#default_value' => !empty($field['prefix']) ? $field['prefix'] : '', |
|
| 99 | + '#description' => t('Define a string that should be prefixed to the value, like $ or €. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'), |
|
| 100 | + ); |
|
| 101 | + $form['append']['suffix'] = array( |
|
| 102 | + '#type' => 'textfield', |
|
| 103 | + '#title' => t('Suffix'), |
|
| 104 | + '#size' => 60, |
|
| 105 | + '#default_value' => !empty($field['suffix']) ? $field['suffix'] : '', |
|
| 106 | + '#description' => t('Define a string that should suffixed to the value, like m², m/s², kb/s. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'), |
|
| 107 | + ); |
|
| 108 | + $form['allowed_values_fieldset'] = array( |
|
| 109 | + '#type' => 'fieldset', |
|
| 110 | + '#title' => t('Allowed values'), |
|
| 111 | + '#collapsible' => TRUE, |
|
| 112 | + '#collapsed' => TRUE, |
|
| 113 | + ); |
|
| 114 | + $form['allowed_values_fieldset']['allowed_values'] = array( |
|
| 115 | + '#type' => 'textarea', |
|
| 116 | + '#title' => t('Allowed values list'), |
|
| 117 | + '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '', |
|
| 118 | + '#required' => FALSE, |
|
| 119 | + '#rows' => 10, |
|
| 120 | + '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())), |
|
| 121 | + ); |
|
| 122 | + $form['allowed_values_fieldset']['advanced_options'] = array( |
|
| 123 | + '#type' => 'fieldset', |
|
| 124 | + '#title' => t('PHP code'), |
|
| 125 | + '#collapsible' => TRUE, |
|
| 126 | + '#collapsed' => empty($field['allowed_values_php']), |
|
| 127 | + ); |
|
| 128 | + if (user_access('Use PHP input for field settings (dangerous - grant with care)')) { |
|
| 129 | + $form['allowed_values_fieldset']['advanced_options']['allowed_values_php'] = array( |
|
| 115 | 130 | '#type' => 'textarea', |
| 116 | - '#title' => t('Allowed values list'), |
|
| 117 | - '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '', |
|
| 118 | - '#required' => FALSE, |
|
| 119 | - '#rows' => 10, |
|
| 120 | - '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())), |
|
| 131 | + '#title' => t('Code'), |
|
| 132 | + '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '', |
|
| 133 | + '#rows' => 6, |
|
| 134 | + '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include <?php ?> delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'), |
|
| 121 | 135 | ); |
| 122 | - $form['allowed_values_fieldset']['advanced_options'] = array( |
|
| 123 | - '#type' => 'fieldset', |
|
| 124 | - '#title' => t('PHP code'), |
|
| 125 | - '#collapsible' => TRUE, |
|
| 126 | - '#collapsed' => empty($field['allowed_values_php']), |
|
| 136 | + } |
|
| 137 | + else { |
|
| 138 | + $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array( |
|
| 139 | + '#type' => 'item', |
|
| 140 | + '#title' => t('Code'), |
|
| 141 | + '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('<none>'), |
|
| 142 | + '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'), |
|
| 127 | 143 | ); |
| 128 | - if (user_access('Use PHP input for field settings (dangerous - grant with care)')) { |
|
| 129 | - $form['allowed_values_fieldset']['advanced_options']['allowed_values_php'] = array( |
|
| 130 | - '#type' => 'textarea', |
|
| 131 | - '#title' => t('Code'), |
|
| 132 | - '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '', |
|
| 133 | - '#rows' => 6, |
|
| 134 | - '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include <?php ?> delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'), |
|
| 135 | - ); |
|
| 136 | - } |
|
| 137 | - else { |
|
| 138 | - $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array( |
|
| 139 | - '#type' => 'item', |
|
| 140 | - '#title' => t('Code'), |
|
| 141 | - '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('<none>'), |
|
| 142 | - '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'), |
|
| 143 | - ); |
|
| 144 | - } |
|
| 145 | - return $form; |
|
| 144 | + } |
|
| 145 | + return $form; |
|
| 146 | 146 | |
| 147 | - case 'save': |
|
| 148 | - $values = array('prefix', 'suffix', 'min', 'max', 'allowed_values', 'allowed_values_php'); |
|
| 149 | - if ($field['type'] == 'number_decimal') { |
|
| 150 | - $values = array_merge($values, array('precision', 'scale', 'decimal')); |
|
| 151 | - } |
|
| 152 | - return $values; |
|
| 147 | + case 'save': |
|
| 148 | + $values = array('prefix', 'suffix', 'min', 'max', 'allowed_values', 'allowed_values_php'); |
|
| 149 | + if ($field['type'] == 'number_decimal') { |
|
| 150 | + $values = array_merge($values, array('precision', 'scale', 'decimal')); |
|
| 151 | + } |
|
| 152 | + return $values; |
|
| 153 | 153 | |
| 154 | - case 'database columns': |
|
| 155 | - if ($field['type'] == 'number_integer') { |
|
| 156 | - return array( |
|
| 157 | - 'value' => array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE), |
|
| 158 | - ); |
|
| 159 | - } |
|
| 160 | - if ($field['type'] == 'number_float') { |
|
| 161 | - return array( |
|
| 162 | - 'value' => array('type' => 'float', 'not null' => FALSE, 'sortable' => TRUE), |
|
| 163 | - ); |
|
| 164 | - } |
|
| 165 | - if ($field['type'] == 'number_decimal') { |
|
| 166 | - $precision = isset($field['precision']) ? $field['precision'] : 10; |
|
| 167 | - $scale = isset($field['scale']) ? $field['scale'] : 2; |
|
| 168 | - return array( |
|
| 169 | - 'value' => array('type' => 'numeric', 'precision' => $precision, 'scale' => $scale, 'not null' => FALSE, 'sortable' => TRUE), |
|
| 170 | - ); |
|
| 171 | - } |
|
| 154 | + case 'database columns': |
|
| 155 | + if ($field['type'] == 'number_integer') { |
|
| 156 | + return array( |
|
| 157 | + 'value' => array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE), |
|
| 158 | + ); |
|
| 159 | + } |
|
| 160 | + if ($field['type'] == 'number_float') { |
|
| 161 | + return array( |
|
| 162 | + 'value' => array('type' => 'float', 'not null' => FALSE, 'sortable' => TRUE), |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | + if ($field['type'] == 'number_decimal') { |
|
| 166 | + $precision = isset($field['precision']) ? $field['precision'] : 10; |
|
| 167 | + $scale = isset($field['scale']) ? $field['scale'] : 2; |
|
| 168 | + return array( |
|
| 169 | + 'value' => array('type' => 'numeric', 'precision' => $precision, 'scale' => $scale, 'not null' => FALSE, 'sortable' => TRUE), |
|
| 170 | + ); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - case 'views data': |
|
| 174 | - $allowed_values = content_allowed_values($field); |
|
| 175 | - if (count($allowed_values)) { |
|
| 176 | - $data = content_views_field_views_data($field); |
|
| 177 | - $db_info = content_database_info($field); |
|
| 178 | - $table_alias = content_views_tablename($field); |
|
| 179 | - |
|
| 180 | - // Filter: Add a 'many to one' filter. |
|
| 181 | - $copy = $data[$table_alias][$field['field_name'] .'_value']; |
|
| 182 | - $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name'])); |
|
| 183 | - $copy['filter']['handler'] = 'content_handler_filter_many_to_one'; |
|
| 184 | - $copy['filter']['numeric'] = TRUE; |
|
| 185 | - unset($copy['field'], $copy['argument'], $copy['sort']); |
|
| 186 | - $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy; |
|
| 187 | - // Argument: swap the handler to the 'many to one' operator |
|
| 188 | - $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one'; |
|
| 189 | - $data[$table_alias][$field['field_name'] .'_value']['argument']['numeric'] = TRUE; |
|
| 190 | - return $data; |
|
| 191 | - } |
|
| 192 | - break; |
|
| 173 | + case 'views data': |
|
| 174 | + $allowed_values = content_allowed_values($field); |
|
| 175 | + if (count($allowed_values)) { |
|
| 176 | + $data = content_views_field_views_data($field); |
|
| 177 | + $db_info = content_database_info($field); |
|
| 178 | + $table_alias = content_views_tablename($field); |
|
| 179 | + |
|
| 180 | + // Filter: Add a 'many to one' filter. |
|
| 181 | + $copy = $data[$table_alias][$field['field_name'] .'_value']; |
|
| 182 | + $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name'])); |
|
| 183 | + $copy['filter']['handler'] = 'content_handler_filter_many_to_one'; |
|
| 184 | + $copy['filter']['numeric'] = TRUE; |
|
| 185 | + unset($copy['field'], $copy['argument'], $copy['sort']); |
|
| 186 | + $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy; |
|
| 187 | + // Argument: swap the handler to the 'many to one' operator |
|
| 188 | + $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one'; |
|
| 189 | + $data[$table_alias][$field['field_name'] .'_value']['argument']['numeric'] = TRUE; |
|
| 190 | + return $data; |
|
| 191 | + } |
|
| 192 | + break; |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
@@ -212,37 +212,37 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | function number_field($op, &$node, $field, &$items, $teaser, $page) { |
| 214 | 214 | switch ($op) { |
| 215 | - case 'validate': |
|
| 216 | - $allowed_values = content_allowed_values($field); |
|
| 217 | - if (is_array($items)) { |
|
| 218 | - foreach ($items as $delta => $item) { |
|
| 219 | - $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
| 220 | - if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
| 221 | - if ($item['value'] != '') { |
|
| 222 | - if (is_numeric($field['min']) && $item['value'] < $field['min']) { |
|
| 223 | - form_set_error($error_element, t('%name: the value may be no smaller than %min.', array('%name' => t($field['widget']['label']), '%min' => $field['min']))); |
|
| 224 | - } |
|
| 225 | - if (is_numeric($field['max']) && $item['value'] > $field['max']) { |
|
| 226 | - form_set_error($error_element, t('%name: the value may be no larger than %max.', array('%name' => t($field['widget']['label']), '%max' => $field['max']))); |
|
| 227 | - } |
|
| 228 | - if (count($allowed_values)) { |
|
| 229 | - // We cannot use array_key_exists() because allowed values are |
|
| 230 | - // stored as strings, and we need to compare numeric equality. |
|
| 231 | - $valid = FALSE; |
|
| 232 | - foreach ($allowed_values as $kay => $value) { |
|
| 233 | - if ((float) $item['value'] == (float) $kay) { |
|
| 234 | - $valid = TRUE; |
|
| 235 | - break; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - if (!$valid) { |
|
| 239 | - form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label'])))); |
|
| 215 | + case 'validate': |
|
| 216 | + $allowed_values = content_allowed_values($field); |
|
| 217 | + if (is_array($items)) { |
|
| 218 | + foreach ($items as $delta => $item) { |
|
| 219 | + $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
| 220 | + if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
| 221 | + if ($item['value'] != '') { |
|
| 222 | + if (is_numeric($field['min']) && $item['value'] < $field['min']) { |
|
| 223 | + form_set_error($error_element, t('%name: the value may be no smaller than %min.', array('%name' => t($field['widget']['label']), '%min' => $field['min']))); |
|
| 224 | + } |
|
| 225 | + if (is_numeric($field['max']) && $item['value'] > $field['max']) { |
|
| 226 | + form_set_error($error_element, t('%name: the value may be no larger than %max.', array('%name' => t($field['widget']['label']), '%max' => $field['max']))); |
|
| 227 | + } |
|
| 228 | + if (count($allowed_values)) { |
|
| 229 | + // We cannot use array_key_exists() because allowed values are |
|
| 230 | + // stored as strings, and we need to compare numeric equality. |
|
| 231 | + $valid = FALSE; |
|
| 232 | + foreach ($allowed_values as $kay => $value) { |
|
| 233 | + if ((float) $item['value'] == (float) $kay) { |
|
| 234 | + $valid = TRUE; |
|
| 235 | + break; |
|
| 240 | 236 | } |
| 241 | 237 | } |
| 238 | + if (!$valid) { |
|
| 239 | + form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label'])))); |
|
| 240 | + } |
|
| 242 | 241 | } |
| 243 | 242 | } |
| 244 | 243 | } |
| 245 | - return $items; |
|
| 244 | + } |
|
| 245 | + return $items; |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
@@ -300,36 +300,36 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | switch ($element['#formatter']) { |
| 303 | - case 'us_0': |
|
| 304 | - $output = number_format($value, 0, '.', ','); |
|
| 305 | - break; |
|
| 306 | - case 'us_1': |
|
| 307 | - $output = number_format($value, 1, '.', ','); |
|
| 308 | - break; |
|
| 309 | - case 'us_2': |
|
| 310 | - $output = number_format($value, 2, '.', ','); |
|
| 311 | - break; |
|
| 312 | - case 'be_0': |
|
| 313 | - $output = number_format($value, 0, ',', '.'); |
|
| 314 | - break; |
|
| 315 | - case 'be_1': |
|
| 316 | - $output = number_format($value, 1, ',', '.'); |
|
| 317 | - break; |
|
| 318 | - case 'be_2': |
|
| 319 | - $output = number_format($value, 2, ',', '.'); |
|
| 320 | - break; |
|
| 321 | - case 'fr_0': |
|
| 322 | - $output = number_format($value, 0, ', ', ' '); |
|
| 323 | - break; |
|
| 324 | - case 'fr_1': |
|
| 325 | - $output = number_format($value, 1, ', ', ' '); |
|
| 326 | - break; |
|
| 327 | - case 'fr_2': |
|
| 328 | - $output = number_format($value, 2, ', ', ' '); |
|
| 329 | - break; |
|
| 330 | - default: |
|
| 331 | - $output = $value; |
|
| 332 | - break; |
|
| 303 | + case 'us_0': |
|
| 304 | + $output = number_format($value, 0, '.', ','); |
|
| 305 | + break; |
|
| 306 | + case 'us_1': |
|
| 307 | + $output = number_format($value, 1, '.', ','); |
|
| 308 | + break; |
|
| 309 | + case 'us_2': |
|
| 310 | + $output = number_format($value, 2, '.', ','); |
|
| 311 | + break; |
|
| 312 | + case 'be_0': |
|
| 313 | + $output = number_format($value, 0, ',', '.'); |
|
| 314 | + break; |
|
| 315 | + case 'be_1': |
|
| 316 | + $output = number_format($value, 1, ',', '.'); |
|
| 317 | + break; |
|
| 318 | + case 'be_2': |
|
| 319 | + $output = number_format($value, 2, ',', '.'); |
|
| 320 | + break; |
|
| 321 | + case 'fr_0': |
|
| 322 | + $output = number_format($value, 0, ', ', ' '); |
|
| 323 | + break; |
|
| 324 | + case 'fr_1': |
|
| 325 | + $output = number_format($value, 1, ', ', ' '); |
|
| 326 | + break; |
|
| 327 | + case 'fr_2': |
|
| 328 | + $output = number_format($value, 2, ', ', ' '); |
|
| 329 | + break; |
|
| 330 | + default: |
|
| 331 | + $output = $value; |
|
| 332 | + break; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | $prefixes = isset($field['prefix']) ? array_map('content_filter_xss', explode('|', $field['prefix'])) : array(''); |
@@ -475,18 +475,18 @@ discard block |
||
| 475 | 475 | $element[$field_key]['#field_suffix'] = content_filter_xss(array_pop($suffixes)); |
| 476 | 476 | } |
| 477 | 477 | switch ($field['type']) { |
| 478 | - case 'number_float': |
|
| 479 | - $element['#element_validate'][] = 'number_float_validate'; |
|
| 480 | - break; |
|
| 481 | - case 'number_integer': |
|
| 482 | - $element['#element_validate'][] = 'number_integer_validate'; |
|
| 483 | - break; |
|
| 484 | - case 'number_decimal': |
|
| 485 | - $element['#element_validate'][] = 'number_decimal_validate'; |
|
| 486 | - $element['#decimal'] = isset($field['decimal']) ? $field['decimal'] : '.'; |
|
| 487 | - $element['#precision'] = isset($field['precision']) ? $field['precision'] : 10; |
|
| 488 | - $element['#scale'] = isset($field['scale']) ? $field['scale'] : 2; |
|
| 489 | - break; |
|
| 478 | + case 'number_float': |
|
| 479 | + $element['#element_validate'][] = 'number_float_validate'; |
|
| 480 | + break; |
|
| 481 | + case 'number_integer': |
|
| 482 | + $element['#element_validate'][] = 'number_integer_validate'; |
|
| 483 | + break; |
|
| 484 | + case 'number_decimal': |
|
| 485 | + $element['#element_validate'][] = 'number_decimal_validate'; |
|
| 486 | + $element['#decimal'] = isset($field['decimal']) ? $field['decimal'] : '.'; |
|
| 487 | + $element['#precision'] = isset($field['precision']) ? $field['precision'] : 10; |
|
| 488 | + $element['#scale'] = isset($field['scale']) ? $field['scale'] : 2; |
|
| 489 | + break; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | // Used so that hook_field('validate') knows where to flag an error. |
@@ -419,16 +419,16 @@ |
||
| 419 | 419 | */ |
| 420 | 420 | function theme_optionwidgets_none($field) { |
| 421 | 421 | switch ($field['widget']['type']) { |
| 422 | - case 'optionwidgets_buttons': |
|
| 423 | - case 'nodereference_buttons': |
|
| 424 | - case 'userreference_buttons': |
|
| 425 | - return t('N/A'); |
|
| 426 | - case 'optionwidgets_select': |
|
| 427 | - case 'nodereference_select': |
|
| 428 | - case 'userreference_select': |
|
| 429 | - return t('- None -'); |
|
| 430 | - default : |
|
| 431 | - return ''; |
|
| 422 | + case 'optionwidgets_buttons': |
|
| 423 | + case 'nodereference_buttons': |
|
| 424 | + case 'userreference_buttons': |
|
| 425 | + return t('N/A'); |
|
| 426 | + case 'optionwidgets_select': |
|
| 427 | + case 'nodereference_select': |
|
| 428 | + case 'userreference_select': |
|
| 429 | + return t('- None -'); |
|
| 430 | + default : |
|
| 431 | + return ''; |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | |