Mercurial > defr > drupal > scald > mee
changeset 2:3d3d533f9eff
Added skeletal Scald Provider API implementation. Added basics for Atom registration, update, etc.
| author | Tom Wolf <tom@chicagotech.org> |
|---|---|
| date | Tue, 07 Apr 2009 11:19:03 -0500 |
| parents | 814c6ce77297 |
| children | d52c1baec6fb |
| files | mee.module |
| diffstat | 1 files changed, 110 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mee.module Tue Mar 10 14:05:38 2009 -0500 +++ b/mee.module Tue Apr 07 11:19:03 2009 -0500 @@ -19,13 +19,14 @@ 'arguments' => array('element' => NULL), ), ); - // @TODO enable! - //foreach (scald_contexts() as $context) { - // $theme['mee_formatter_'. $context] = array( - // 'arguments' => array('element' => NULL), - // 'function' => 'theme_mee_context_formatter', - // ); - //} + + $scald_config = variable_get('scald_config', 0); + foreach ($scald_config->contexts as $context => $details) { + $theme['mee_formatter_'. $context] = array( + 'arguments' => array('element' => NULL), + 'function' => 'theme_mee_context_formatter', + ); + } return $theme; } @@ -86,6 +87,37 @@ */ function mee_field($op, &$node, $field, &$items, $teaser, $page) { switch ($op) { + case 'presave': + // @@@TODO: parse the field & replace editor reps with SAS + break; // end 'submit' + + case 'insert': + // @@@TODO: register a new Atom based on this textarea + foreach ($items as $delta => $item) { + $temp_atom = new stdClass; + $temp_atom->type = 'composite'; + $temp_atom->provider = 'mee'; + $temp_atom->base_id = $node->nid . ':' . $delta; + $temp_atom->uid = $node->uid; + $temp_atom->title = $node->title; + $temp_atom->authors = array(scald_uid_to_aid($node->uid)); + $scald_included = scald_included($node->body); + $temp_atom->relationships = empty($scald_included) ? array() : array('includes' => $scald_included); + $sid = scald_register_atom($temp_atom); + } + break; // end 'insert' + + case 'update': + foreach ($items as $delta => $item) { + + } + // @@@TODO: Update the existing Atom + break; // end 'update' + + case 'delete': + // @@@TODO: Remove the Atom based on this instance of the field + break; // end 'delete' + case 'sanitize': foreach ($items as $delta => $item) { if (!empty($field['mee_processing'])) { @@ -97,6 +129,7 @@ } $items[$delta]['safe'] = $text; } + break; // end 'sanitize' } } @@ -328,3 +361,73 @@ function theme_mee_textarea($element) { return $element['#children']; } + + + + + + +/******************************************************************************* + * SCALD HOOK IMPLEMENTATIONS + ******************************************************************************/ + +/** + * Implementation of hook_scald_provider(). + */ +function mee_scald_provider() { + return array( + 'atoms' => array( + 'composite' => t('The MEE CCK field.'), + ), + ); +} + + + +/** + * Implementation of hook_scald_register_atom(). + */ +function mee_scald_register_atom($atom, $mode) { + +} // end mee_scald_register_atom() + + + +/** + * Implementation of hook_scald_update_atom(). + */ +function mee_scald_update_atom($atom, $mode) { + +} // end mee_scald_update_atom() + + + +/** + * Implementation of hook_scald_unregister_atom(). + */ +function mee_scald_unregister_atom($atom, $mode) { + +} // end mee_scald_unregister_atom() + + + +/** + * Implementation of hook_scald_fetch(). + */ +function mee_scald_fetch(&$atom) { + list($nid, $delta) = split(':', $atom->base_id); + $node = node_load($nid); + $atom->title = $node->title . '(' . $delta . ')'; + $atom->description = $atom->title; // @@@TODO: Maybe make this a better description? + $atom->thumbnail_source = drupal_get_path('module', 'scald_composites') . '/assets/thumbnail_composite.png'; +} // end mee_scald_fetch() + + + +/** + * Implementation of hook_scald_prerender(). + */ +function mee_scald_prerender(&$atom, $mode) { + +} // end mee_scald_prerender() +
