/[drupal]/contributions/modules/media/media_ahah.inc
ViewVC logotype

Contents of /contributions/modules/media/media_ahah.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Tue Jul 21 04:34:45 2009 UTC (4 months ago) by jmstacey
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-7--1
Changes since 1.2: +21 -17 lines
File MIME type: text/x-php
Some blind styling cleanup in preparation for work.
1 <?php
2 // $Id: media_ahah.inc,v 1.2 2009/07/20 22:58:02 jmstacey Exp $
3
4 /**
5 * @file
6 * Media AHAH
7 *
8 * AHAH functions for the Media module.
9 */
10
11 /**
12 * This function builds the form elements for the file formater based
13 * on the node type and field for settings and the file extension to get the
14 * formatters.
15 *
16 * @param string $registration_id
17 * The id of the registration creating this formatter.
18 * @param string $node_type
19 * The kind of node.
20 * @param string $field
21 * The machine name of the field being operated on.
22 * @param string $uri
23 * (optional) The uri to the item, or file://path if it is being uploaded.
24 * @param string $file_extension
25 * (optional) The kind of file that will be operated on.
26 */
27 function media_ahah_formatter_load() { //$registration_id, $node_type, $field, $uri = NULL, $file_extension = NULL) {
28 // The form is generated in an include file which we need to include manually.
29 include_once 'modules/node/node.pages.inc';
30
31 // We're starting in step #3, preparing for #4.
32 $form_state = array('storage' => NULL, 'submitted' => FALSE);
33 $form_build_id = $_POST['form_build_id'];
34
35 // Step #4.
36 $form = form_get_cache($form_build_id, $form_state);
37
38 // Preparing for #5.
39 $args = $form['#parameters'];
40 $form_id = array_shift($args);
41 $form_state['post'] = $form['#post'] = $_POST;
42 $form['#programmed'] = $form['#redirect'] = FALSE;
43
44 // Step #5.
45 drupal_process_form($form_id, $form, $form_state);
46
47 // Step #6 and #7 and #8.
48 $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
49
50 // Do whatever we need here for Step #9.
51 drupal_set_message('media_ahah_formatter_load can add anything here (if necessary).');
52
53 // Step #10: Output any drupal messages and the new form.
54 $media_tabs = $form[$field]['media']['media_tabs'];
55 $output = theme('status_messages') . drupal_render($media_tabs);
56
57 // Ensure any changes to Drupal.settings js are preserved.
58 $javascript = drupal_add_js(NULL, NULL, 'header');
59
60 // Final rendering callback.
61 drupal_json(array(
62 'status' => TRUE,
63 'data' => $output,
64 'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']),
65 ));
66 }
67
68 /**
69 * TODO: Document
70 */
71 function media_ahah_metadata_ahah() {
72 // The form is generated in an include file which we need to include manually.
73 include_once 'modules/node/node.pages.inc';
74
75 // We're starting in step #3, preparing for #4.
76 $form_state = array('storage' => NULL, 'submitted' => FALSE);
77 $form_build_id = $_POST['form_build_id'];
78
79 // Step #4.
80 $form = form_get_cache($form_build_id, $form_state);
81
82 // Preparing for #5.
83 $args = $form['#parameters'];
84 $form_id = array_shift($args);
85 $form_state['post'] = $form['#post'] = $_POST;
86 $form['#programmed'] = $form['#redirect'] = FALSE;
87
88 // Step #5.
89 drupal_process_form($form_id, $form, $form_state);
90
91 // Step #6 and #7 and #8.
92 $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
93
94 // Do whatever we need here for Step #9.
95 drupal_set_message('final submission: media_ahah_metadata_ahah can do something here, maybe display a new add file form?');
96
97 // Step #10: Output any drupal messages and the new form.
98 $media_tabs = $form[$field]['media']['media_tabs'];
99 $output = theme('status_messages') . drupal_render($media_tabs);
100
101 // Ensure any changes to Drupal.settings js are preserved.
102 $javascript = drupal_add_js(NULL, NULL, 'header');
103
104 // Final rendering callback.
105 drupal_json(array(
106 'status' => TRUE,
107 'data' => $output,
108 'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']),
109 ));
110 }

  ViewVC Help
Powered by ViewVC 1.1.2