comparison mee.module @ 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 548f63d8a41b
children d52c1baec6fb
comparison
equal deleted inserted replaced
1:814c6ce77297 2:3d3d533f9eff
17 ), 17 ),
18 'mee_formatter_default' => array( 18 'mee_formatter_default' => array(
19 'arguments' => array('element' => NULL), 19 'arguments' => array('element' => NULL),
20 ), 20 ),
21 ); 21 );
22 // @TODO enable! 22
23 //foreach (scald_contexts() as $context) { 23 $scald_config = variable_get('scald_config', 0);
24 // $theme['mee_formatter_'. $context] = array( 24 foreach ($scald_config->contexts as $context => $details) {
25 // 'arguments' => array('element' => NULL), 25 $theme['mee_formatter_'. $context] = array(
26 // 'function' => 'theme_mee_context_formatter', 26 'arguments' => array('element' => NULL),
27 // ); 27 'function' => 'theme_mee_context_formatter',
28 //} 28 );
29 }
29 return $theme; 30 return $theme;
30 } 31 }
31 32
32 /** 33 /**
33 * Implementation of hook_field_info(). 34 * Implementation of hook_field_info().
84 /** 85 /**
85 * Implementation of hook_field(). 86 * Implementation of hook_field().
86 */ 87 */
87 function mee_field($op, &$node, $field, &$items, $teaser, $page) { 88 function mee_field($op, &$node, $field, &$items, $teaser, $page) {
88 switch ($op) { 89 switch ($op) {
90 case 'presave':
91 // @@@TODO: parse the field & replace editor reps with SAS
92 break; // end 'submit'
93
94 case 'insert':
95 // @@@TODO: register a new Atom based on this textarea
96 foreach ($items as $delta => $item) {
97 $temp_atom = new stdClass;
98 $temp_atom->type = 'composite';
99 $temp_atom->provider = 'mee';
100 $temp_atom->base_id = $node->nid . ':' . $delta;
101 $temp_atom->uid = $node->uid;
102 $temp_atom->title = $node->title;
103 $temp_atom->authors = array(scald_uid_to_aid($node->uid));
104 $scald_included = scald_included($node->body);
105 $temp_atom->relationships = empty($scald_included) ? array() : array('includes' => $scald_included);
106 $sid = scald_register_atom($temp_atom);
107 }
108 break; // end 'insert'
109
110 case 'update':
111 foreach ($items as $delta => $item) {
112
113 }
114 // @@@TODO: Update the existing Atom
115 break; // end 'update'
116
117 case 'delete':
118 // @@@TODO: Remove the Atom based on this instance of the field
119 break; // end 'delete'
120
89 case 'sanitize': 121 case 'sanitize':
90 foreach ($items as $delta => $item) { 122 foreach ($items as $delta => $item) {
91 if (!empty($field['mee_processing'])) { 123 if (!empty($field['mee_processing'])) {
92 $check = is_null($node) || (isset($node->build_mode) && $node->build_mode == NODE_BUILD_PREVIEW); 124 $check = is_null($node) || (isset($node->build_mode) && $node->build_mode == NODE_BUILD_PREVIEW);
93 $text = isset($item['value']) ? check_markup($item['value'], $item['format'], $check) : ''; 125 $text = isset($item['value']) ? check_markup($item['value'], $item['format'], $check) : '';
95 else { 127 else {
96 $text = check_plain($item['value']); 128 $text = check_plain($item['value']);
97 } 129 }
98 $items[$delta]['safe'] = $text; 130 $items[$delta]['safe'] = $text;
99 } 131 }
132 break; // end 'sanitize'
100 } 133 }
101 } 134 }
102 135
103 /** 136 /**
104 * Implementation of hook_content_is_empty(). 137 * Implementation of hook_content_is_empty().
326 * $element['#delta] is the position of this element in the group 359 * $element['#delta] is the position of this element in the group
327 */ 360 */
328 function theme_mee_textarea($element) { 361 function theme_mee_textarea($element) {
329 return $element['#children']; 362 return $element['#children'];
330 } 363 }
364
365
366
367
368
369
370 /*******************************************************************************
371 * SCALD HOOK IMPLEMENTATIONS
372 ******************************************************************************/
373
374 /**
375 * Implementation of hook_scald_provider().
376 */
377 function mee_scald_provider() {
378 return array(
379 'atoms' => array(
380 'composite' => t('The MEE CCK field.'),
381 ),
382 );
383 }
384
385
386
387 /**
388 * Implementation of hook_scald_register_atom().
389 */
390 function mee_scald_register_atom($atom, $mode) {
391
392 } // end mee_scald_register_atom()
393
394
395
396 /**
397 * Implementation of hook_scald_update_atom().
398 */
399 function mee_scald_update_atom($atom, $mode) {
400
401 } // end mee_scald_update_atom()
402
403
404
405 /**
406 * Implementation of hook_scald_unregister_atom().
407 */
408 function mee_scald_unregister_atom($atom, $mode) {
409
410 } // end mee_scald_unregister_atom()
411
412
413
414 /**
415 * Implementation of hook_scald_fetch().
416 */
417 function mee_scald_fetch(&$atom) {
418 list($nid, $delta) = split(':', $atom->base_id);
419 $node = node_load($nid);
420 $atom->title = $node->title . '(' . $delta . ')';
421 $atom->description = $atom->title; // @@@TODO: Maybe make this a better description?
422 $atom->thumbnail_source = drupal_get_path('module', 'scald_composites') . '/assets/thumbnail_composite.png';
423 } // end mee_scald_fetch()
424
425
426
427 /**
428 * Implementation of hook_scald_prerender().
429 */
430 function mee_scald_prerender(&$atom, $mode) {
431
432 } // end mee_scald_prerender()
433