comparison dnd_test/dnd_test.module @ 14:ef7ad7b5baa4

Slightly changed matching mechanism to handle Firefox's crazy desire to make dropped src attributes relative.
author David Eads <eads@chicagotech.org>
date Fri, 27 Feb 2009 12:30:42 -0600
parents a5b2b9fa2a1a
children 7a5f74482ee3
comparison
equal deleted inserted replaced
13:d0e7287c7a55 14:ef7ad7b5baa4
24 * Implementation of hook_form_alter(). 24 * Implementation of hook_form_alter().
25 * 25 *
26 * This demonstrates how to attach Drag and Drop to a given textarea. 26 * This demonstrates how to attach Drag and Drop to a given textarea.
27 */ 27 */
28 function dnd_test_form_alter(&$form, &$form_state) { 28 function dnd_test_form_alter(&$form, &$form_state) {
29
30 //global $_SERVER;
31 //dpm($_SERVER);
32
33 if ($form['#id'] == 'node-form' && $form['type']['#value'] == 'page') { 29 if ($form['#id'] == 'node-form' && $form['type']['#value'] == 'page') {
34 drupal_add_css(drupal_get_path('module', 'dnd_test') .'/dnd_test.css'); 30 drupal_add_css(drupal_get_path('module', 'dnd_test') .'/dnd_test.css');
35 $form['body_field']['body']['#dnd-enabled'] = TRUE; 31 $form['body_field']['body']['#dnd-enabled'] = TRUE;
36 $form['body_field']['body']['#dnd-settings'] = array( 32 $form['body_field']['body']['#dnd-settings'] = array(
37 'drop_selector' => '#edit-body-dnd-library .drop', 33 'drop_selector' => '#edit-body-dnd-library .drop',
90 ); 86 );
91 } 87 }
92 88
93 /** 89 /**
94 * Theme wrapper that spins out multiple library representations for a given 90 * Theme wrapper that spins out multiple library representations for a given
95 ;[''''* editor representation. This is because we want to demonstrate how to allow 91 * editor representation. This is because we want to demonstrate how to allow
96 * for multiple versions (i.e. different sizes) of a single item 92 * for multiple versions (i.e. different sizes) of a single item
97 */ 93 */
98 function dnd_editor_items($i) { 94 function dnd_editor_items($i) {
99 $item = array(); 95 $item = array();
100 foreach(array(t('S'), t('M'), t('L')) as $size) { 96 foreach(array(t('S'), t('M'), t('L')) as $size) {
120 else { 116 else {
121 $img = 1; 117 $img = 1;
122 } 118 }
123 119
124 //$variables['image'] = theme('image', drupal_get_path('module', 'dnd_test') .'/img/item-'. $img .'-thumb.jpg'); 120 //$variables['image'] = theme('image', drupal_get_path('module', 'dnd_test') .'/img/item-'. $img .'-thumb.jpg');
125 $variables['image'] = '<img src="http://'. $_SERVER['SERVER_ADDR'] . base_path() . drupal_get_path('module', 'dnd_test') .'/img/item-'. $img .'-thumb.jpg?dnd_id='. $i .'-M" class="drop" />'; 121 $variables['image'] = '<img src="http://'. $_SERVER['HTTP_HOST'] . base_path() . drupal_get_path('module', 'dnd_test') .'/img/item-'. $img .'-thumb.jpg?dnd_id='. $i .'-M" class="drop" />';
126 $variables['title'] = t('Lorem Ipsum @count', array('@count' => $i)); 122 $variables['title'] = t('Lorem Ipsum @count', array('@count' => $i));
127 $variables['date'] = 'Feb 18 2009'; 123 $variables['date'] = 'Feb 18 2009';
128 $variables['author'] = 'David Eads'; 124 $variables['author'] = 'David Eads';
129 foreach(array(t('S'), t('M'), t('L')) as $size) { 125 foreach(array(t('S'), t('M'), t('L')) as $size) {
130 $sizes[] = '<img src="http://'. $_SERVER['SERVER_ADDR'] . base_path() . drupal_get_path('module', 'dnd_test') .'/img/icon/'. $size .'.png?dnd_id='. $i .'-'. $size .'" class="drop" />'; 126 $sizes[] = '<img src="http://'. $_SERVER['HTTP_HOST'] . base_path() . drupal_get_path('module', 'dnd_test') .'/img/icon/'. $size .'.png?dnd_id='. $i .'-'. $size .'" class="drop" />';
131 } 127 }
132 $variables['sizes'] = '<ul><li>'. implode('</li><li>', $sizes) .'</li></ul>'; 128 $variables['sizes'] = '<ul><li>'. implode('</li><li>', $sizes) .'</li></ul>';
133 } 129 }
134 130
135 131