Mercurial > defr > drupal > scald > mee
changeset 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 |
| files | mee.module |
| diffstat | 1 files changed, 25 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mee.module Fri Jun 05 09:56:08 2009 +0200 +++ b/mee.module Mon Jun 08 18:33:19 2009 +0200 @@ -89,6 +89,7 @@ case 'database columns': $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE); + $columns['short'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE); $columns['dnd_callback_url'] = array('type' => 'text', 'size' => 'small', 'not null' => FALSE); if (!empty($field['mee_processing'])) { $columns['format'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE); @@ -108,15 +109,19 @@ switch ($op) { case 'presave': foreach ($items as $delta => &$item) { - if (!empty($item['value'])) { - $item['value'] = scald_rendered_to_sas($item['value']); + if (!empty($item['mee']['value'])) { + $item['mee']['value'] = scald_rendered_to_sas($item['mee']['value']); } } break; // end 'submit' case 'insert': foreach ($items as $delta => $item) { - $scald_included = scald_included($item['value']); + // Let CCK store the value and short fields + $items[$delta]['value'] = $item['mee']['value']; + $items[$delta]['short'] = $item['mee']['short']; + // Process the value and generate an atom + $scald_included = scald_included($item['mee']['value']); $temp_atom = new stdClass; $temp_atom->type = 'composite'; @@ -128,12 +133,23 @@ $temp_atom->relationships = empty($scald_included) ? array() : array('includes' => $scald_included); $sid = scald_register_atom($temp_atom); + // Short content + $short = $item['mee']['short']; + // TODO: Store the short content value + // Ressource manager associations + foreach ($item['mee']['ressource_manager'] as $sid => $ressource) { + // TODO: Store the assocation + } } break; // end 'insert' case 'update': foreach ($items as $delta => $item) { - $scald_included = scald_included($item['value']); + // Let CCK store the value and short fields + $items[$delta]['value'] = $item['mee']['value']; + $items[$delta]['short'] = $item['mee']['short']; + // Process the value + $scald_included = scald_included($item['mee']['value']); // @@@TODO: Handle failure of fetch $atom = scald_fetch(scald_search(array('base_id' => $node->nid . ':' . $delta), FALSE, TRUE)); @@ -156,10 +172,10 @@ foreach ($items as $delta => $item) { if (!empty($field['mee_processing'])) { $check = is_null($node) || (isset($node->build_mode) && $node->build_mode == NODE_BUILD_PREVIEW); - $text = isset($item['value']) ? check_markup($item['value'], $item['format'], $check) : ''; + $text = isset($item['mee']['value']) ? check_markup($item['mee']['value'], $item['format'], $check) : ''; } else { - $text = check_plain($item['value']); + $text = check_plain($item['mee']['value']); } $items[$delta]['safe'] = $text; } @@ -171,7 +187,7 @@ * Implementation of hook_content_is_empty(). */ function mee_content_is_empty($item, $field) { - if (empty($item['value']) && (string)$item['value'] !== '0') { + if (empty($item['mee']['value']) && (string)$item['mee']['value'] !== '0') { return TRUE; } return FALSE; @@ -380,8 +396,6 @@ '#type_name' => $element['#type_name'], '#delta' => $element['#delta'], '#columns' => $element['#columns'], -# '#prefix' => '<div class="mee-wrap-editor-library">', -# '#suffix' => '</div>', '#dnd-enabled' => TRUE, '#dnd-settings' => array( 'drop_selector' => '#'. $element['#id'] .' .drop', @@ -407,7 +421,8 @@ '#type' => 'textarea', '#title' => 'Contenu court', '#rows' => 5, - '#weight' => 100 + '#weight' => 100, + '#default_value' => $element['#value']['short'] );
