Mercurial > defr > drupal > scald > mee
comparison mee.module @ 3:d52c1baec6fb
Implemented Scald CRUD triggers based on field value updates.
| author | Tom Wolf <tom@t-dub.net> |
|---|---|
| date | Wed, 22 Apr 2009 23:32:15 -0500 |
| parents | 3d3d533f9eff |
| children | e2bf7cf37972 |
comparison
equal
deleted
inserted
replaced
| 2:3d3d533f9eff | 3:d52c1baec6fb |
|---|---|
| 62 '#type' => 'textfield', | 62 '#type' => 'textfield', |
| 63 '#title' => t('Library callback URL'), | 63 '#title' => t('Library callback URL'), |
| 64 '#default_value' => url($field['mee_dnd_callback_url']) ? $field['mee_dnd_callback_url'] : '', | 64 '#default_value' => url($field['mee_dnd_callback_url']) ? $field['mee_dnd_callback_url'] : '', |
| 65 '#description' => t('The absolute URL or relative path of a callback URL that provides proper JSON to the drag and drop library.'), | 65 '#description' => t('The absolute URL or relative path of a callback URL that provides proper JSON to the drag and drop library.'), |
| 66 ); | 66 ); |
| 67 // @TODO: Add an "Editor Context" option on a per-field basis | |
| 67 return $form; | 68 return $form; |
| 68 | 69 |
| 69 case 'save': | 70 case 'save': |
| 70 return array('mee_processing', 'mee_dnd_callback_url'); | 71 return array('mee_processing', 'mee_dnd_callback_url'); |
| 71 | 72 |
| 90 case 'presave': | 91 case 'presave': |
| 91 // @@@TODO: parse the field & replace editor reps with SAS | 92 // @@@TODO: parse the field & replace editor reps with SAS |
| 92 break; // end 'submit' | 93 break; // end 'submit' |
| 93 | 94 |
| 94 case 'insert': | 95 case 'insert': |
| 95 // @@@TODO: register a new Atom based on this textarea | |
| 96 foreach ($items as $delta => $item) { | 96 foreach ($items as $delta => $item) { |
| 97 $temp_atom = new stdClass; | 97 $scald_included = scald_included($item); |
| 98 $temp_atom->type = 'composite'; | 98 |
| 99 $temp_atom->provider = 'mee'; | 99 $temp_atom = new stdClass; |
| 100 $temp_atom->base_id = $node->nid . ':' . $delta; | 100 $temp_atom->type = 'composite'; |
| 101 $temp_atom->uid = $node->uid; | 101 $temp_atom->provider = 'mee'; |
| 102 $temp_atom->title = $node->title; | 102 $temp_atom->base_id = $node->nid . ':' . $delta; |
| 103 $temp_atom->authors = array(scald_uid_to_aid($node->uid)); | 103 $temp_atom->publisher = $node->uid; |
| 104 $scald_included = scald_included($node->body); | 104 $temp_atom->title = $node->title; |
| 105 $temp_atom->authors = array(scald_uid_to_aid($node->uid)); | |
| 105 $temp_atom->relationships = empty($scald_included) ? array() : array('includes' => $scald_included); | 106 $temp_atom->relationships = empty($scald_included) ? array() : array('includes' => $scald_included); |
| 107 | |
| 106 $sid = scald_register_atom($temp_atom); | 108 $sid = scald_register_atom($temp_atom); |
| 107 } | 109 } |
| 108 break; // end 'insert' | 110 break; // end 'insert' |
| 109 | 111 |
| 110 case 'update': | 112 case 'update': |
| 111 foreach ($items as $delta => $item) { | 113 foreach ($items as $delta => $item) { |
| 112 | 114 $scald_included = scald_included($item); |
| 115 | |
| 116 // @@@TODO: Handle failure of fetch | |
| 117 $atom = scald_fetch(scald_search(array('base_id' => $node->nid . ':' . $delta), FALSE, TRUE)); | |
| 118 $atom->publisher = $node->uid; | |
| 119 $atom->title = $node->title; | |
| 120 $atom->authors = array( | |
| 121 $temp_atom->relationships = empty($scald_included) ? array() : array('includes' => $scald_included); | |
| 122 | |
| 123 scald_update_atom($atom); | |
| 113 } | 124 } |
| 114 // @@@TODO: Update the existing Atom | |
| 115 break; // end 'update' | 125 break; // end 'update' |
| 116 | 126 |
| 117 case 'delete': | 127 case 'delete': |
| 118 // @@@TODO: Remove the Atom based on this instance of the field | 128 foreach ($items as $delta => $item) { |
| 129 scald_unregister_atom(scald_search(array('base_id' => $node->nid . ':' . $delta), FALSE, TRUE)); | |
| 130 } | |
| 119 break; // end 'delete' | 131 break; // end 'delete' |
| 120 | 132 |
| 121 case 'sanitize': | 133 case 'sanitize': |
| 122 foreach ($items as $delta => $item) { | 134 foreach ($items as $delta => $item) { |
| 123 if (!empty($field['mee_processing'])) { | 135 if (!empty($field['mee_processing'])) { |
