Mercurial > defr > drupal > scald > mee
comparison mee.module @ 13:842d89897cb4
Stockage en base correct des champs contenu et contenu court.
| author | Franck Deroche <franck@defr.org> |
|---|---|
| date | Mon, 08 Jun 2009 18:33:19 +0200 |
| parents | da5d54d099b1 |
| children | 50a57b1517cb |
comparison
equal
deleted
inserted
replaced
| 12:da5d54d099b1 | 13:842d89897cb4 |
|---|---|
| 87 case 'save': | 87 case 'save': |
| 88 return array('mee_processing', 'mee_dnd_callback_url', 'mee_scald_editor_context'); | 88 return array('mee_processing', 'mee_dnd_callback_url', 'mee_scald_editor_context'); |
| 89 | 89 |
| 90 case 'database columns': | 90 case 'database columns': |
| 91 $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE); | 91 $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE); |
| 92 $columns['short'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE); | |
| 92 $columns['dnd_callback_url'] = array('type' => 'text', 'size' => 'small', 'not null' => FALSE); | 93 $columns['dnd_callback_url'] = array('type' => 'text', 'size' => 'small', 'not null' => FALSE); |
| 93 if (!empty($field['mee_processing'])) { | 94 if (!empty($field['mee_processing'])) { |
| 94 $columns['format'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE); | 95 $columns['format'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE); |
| 95 } | 96 } |
| 96 $columns['mee_scald_editor_context'] = array('type' => 'text', 'size' => 'small', 'not null' => FALSE); | 97 $columns['mee_scald_editor_context'] = array('type' => 'text', 'size' => 'small', 'not null' => FALSE); |
| 106 */ | 107 */ |
| 107 function mee_field($op, &$node, $field, &$items, $teaser, $page) { | 108 function mee_field($op, &$node, $field, &$items, $teaser, $page) { |
| 108 switch ($op) { | 109 switch ($op) { |
| 109 case 'presave': | 110 case 'presave': |
| 110 foreach ($items as $delta => &$item) { | 111 foreach ($items as $delta => &$item) { |
| 111 if (!empty($item['value'])) { | 112 if (!empty($item['mee']['value'])) { |
| 112 $item['value'] = scald_rendered_to_sas($item['value']); | 113 $item['mee']['value'] = scald_rendered_to_sas($item['mee']['value']); |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 break; // end 'submit' | 116 break; // end 'submit' |
| 116 | 117 |
| 117 case 'insert': | 118 case 'insert': |
| 118 foreach ($items as $delta => $item) { | 119 foreach ($items as $delta => $item) { |
| 119 $scald_included = scald_included($item['value']); | 120 // Let CCK store the value and short fields |
| 121 $items[$delta]['value'] = $item['mee']['value']; | |
| 122 $items[$delta]['short'] = $item['mee']['short']; | |
| 123 // Process the value and generate an atom | |
| 124 $scald_included = scald_included($item['mee']['value']); | |
| 120 | 125 |
| 121 $temp_atom = new stdClass; | 126 $temp_atom = new stdClass; |
| 122 $temp_atom->type = 'composite'; | 127 $temp_atom->type = 'composite'; |
| 123 $temp_atom->provider = 'mee'; | 128 $temp_atom->provider = 'mee'; |
| 124 $temp_atom->base_id = $node->nid . ':' . $delta; | 129 $temp_atom->base_id = $node->nid . ':' . $delta; |
| 126 $temp_atom->title = $node->title . ' - ' . $field['widget']['label'] . ' (#' . $delta . ')'; | 131 $temp_atom->title = $node->title . ' - ' . $field['widget']['label'] . ' (#' . $delta . ')'; |
| 127 $temp_atom->authors = array(scald_uid_to_aid($node->uid)); | 132 $temp_atom->authors = array(scald_uid_to_aid($node->uid)); |
| 128 $temp_atom->relationships = empty($scald_included) ? array() : array('includes' => $scald_included); | 133 $temp_atom->relationships = empty($scald_included) ? array() : array('includes' => $scald_included); |
| 129 | 134 |
| 130 $sid = scald_register_atom($temp_atom); | 135 $sid = scald_register_atom($temp_atom); |
| 136 // Short content | |
| 137 $short = $item['mee']['short']; | |
| 138 // TODO: Store the short content value | |
| 139 // Ressource manager associations | |
| 140 foreach ($item['mee']['ressource_manager'] as $sid => $ressource) { | |
| 141 // TODO: Store the assocation | |
| 142 } | |
| 131 } | 143 } |
| 132 break; // end 'insert' | 144 break; // end 'insert' |
| 133 | 145 |
| 134 case 'update': | 146 case 'update': |
| 135 foreach ($items as $delta => $item) { | 147 foreach ($items as $delta => $item) { |
| 136 $scald_included = scald_included($item['value']); | 148 // Let CCK store the value and short fields |
| 149 $items[$delta]['value'] = $item['mee']['value']; | |
| 150 $items[$delta]['short'] = $item['mee']['short']; | |
| 151 // Process the value | |
| 152 $scald_included = scald_included($item['mee']['value']); | |
| 137 | 153 |
| 138 // @@@TODO: Handle failure of fetch | 154 // @@@TODO: Handle failure of fetch |
| 139 $atom = scald_fetch(scald_search(array('base_id' => $node->nid . ':' . $delta), FALSE, TRUE)); | 155 $atom = scald_fetch(scald_search(array('base_id' => $node->nid . ':' . $delta), FALSE, TRUE)); |
| 140 $atom->publisher = $node->uid; | 156 $atom->publisher = $node->uid; |
| 141 $atom->title = $node->title; | 157 $atom->title = $node->title; |
| 154 | 170 |
| 155 case 'sanitize': | 171 case 'sanitize': |
| 156 foreach ($items as $delta => $item) { | 172 foreach ($items as $delta => $item) { |
| 157 if (!empty($field['mee_processing'])) { | 173 if (!empty($field['mee_processing'])) { |
| 158 $check = is_null($node) || (isset($node->build_mode) && $node->build_mode == NODE_BUILD_PREVIEW); | 174 $check = is_null($node) || (isset($node->build_mode) && $node->build_mode == NODE_BUILD_PREVIEW); |
| 159 $text = isset($item['value']) ? check_markup($item['value'], $item['format'], $check) : ''; | 175 $text = isset($item['mee']['value']) ? check_markup($item['mee']['value'], $item['format'], $check) : ''; |
| 160 } | 176 } |
| 161 else { | 177 else { |
| 162 $text = check_plain($item['value']); | 178 $text = check_plain($item['mee']['value']); |
| 163 } | 179 } |
| 164 $items[$delta]['safe'] = $text; | 180 $items[$delta]['safe'] = $text; |
| 165 } | 181 } |
| 166 break; // end 'sanitize' | 182 break; // end 'sanitize' |
| 167 } | 183 } |
| 169 | 185 |
| 170 /** | 186 /** |
| 171 * Implementation of hook_content_is_empty(). | 187 * Implementation of hook_content_is_empty(). |
| 172 */ | 188 */ |
| 173 function mee_content_is_empty($item, $field) { | 189 function mee_content_is_empty($item, $field) { |
| 174 if (empty($item['value']) && (string)$item['value'] !== '0') { | 190 if (empty($item['mee']['value']) && (string)$item['mee']['value'] !== '0') { |
| 175 return TRUE; | 191 return TRUE; |
| 176 } | 192 } |
| 177 return FALSE; | 193 return FALSE; |
| 178 } | 194 } |
| 179 | 195 |
| 378 '#required' => $element['#required'], | 394 '#required' => $element['#required'], |
| 379 '#field_name' => $element['#field_name'], | 395 '#field_name' => $element['#field_name'], |
| 380 '#type_name' => $element['#type_name'], | 396 '#type_name' => $element['#type_name'], |
| 381 '#delta' => $element['#delta'], | 397 '#delta' => $element['#delta'], |
| 382 '#columns' => $element['#columns'], | 398 '#columns' => $element['#columns'], |
| 383 # '#prefix' => '<div class="mee-wrap-editor-library">', | |
| 384 # '#suffix' => '</div>', | |
| 385 '#dnd-enabled' => TRUE, | 399 '#dnd-enabled' => TRUE, |
| 386 '#dnd-settings' => array( | 400 '#dnd-settings' => array( |
| 387 'drop_selector' => '#'. $element['#id'] .' .drop', | 401 'drop_selector' => '#'. $element['#id'] .' .drop', |
| 388 'url' => $field['mee_dnd_callback_url'], | 402 'url' => $field['mee_dnd_callback_url'], |
| 389 ), | 403 ), |
| 405 ); | 419 ); |
| 406 $element['mee']['short'] = array( | 420 $element['mee']['short'] = array( |
| 407 '#type' => 'textarea', | 421 '#type' => 'textarea', |
| 408 '#title' => 'Contenu court', | 422 '#title' => 'Contenu court', |
| 409 '#rows' => 5, | 423 '#rows' => 5, |
| 410 '#weight' => 100 | 424 '#weight' => 100, |
| 425 '#default_value' => $element['#value']['short'] | |
| 411 ); | 426 ); |
| 412 | 427 |
| 413 | 428 |
| 414 return $element; | 429 return $element; |
| 415 } | 430 } |
