Mercurial > defr > drupal > scald > dnd
comparison dnd_test/dnd_test.module @ 17:1a77f87927dd
Fixed :empty custom selector behavior in IE, a little refactoring, etc.
author | David Eads <eads@chicagotech.org> |
---|---|
date | Wed, 04 Mar 2009 13:29:31 -0600 |
parents | 7a5f74482ee3 |
children | 0d557e6e73f7 |
comparison
equal
deleted
inserted
replaced
16:bb68dc3ad56f | 17:1a77f87927dd |
---|---|
48 ), | 48 ), |
49 'dnd_library_item' => array( | 49 'dnd_library_item' => array( |
50 'arguments' => array('i' => NULL), | 50 'arguments' => array('i' => NULL), |
51 'template' => 'dnd-library-item', | 51 'template' => 'dnd-library-item', |
52 ), | 52 ), |
53 'dnd_library_preview' => array( | |
54 'arguments' => array('i' => NULL), | |
55 'template' => 'dnd-library-preview', | |
56 ), | |
53 ); | 57 ); |
54 } | 58 } |
55 | 59 |
56 /** | 60 /** |
57 * Page call back that returns some JSON | 61 * Page call back that returns some JSON |
61 $test_library = dnd_test_generate_library($page); | 65 $test_library = dnd_test_generate_library($page); |
62 return drupal_json(array( | 66 return drupal_json(array( |
63 'header' => '<h3>'. t('Test library: Page @page', array('@page' => $page)) .'</h3>', | 67 'header' => '<h3>'. t('Test library: Page @page', array('@page' => $page)) .'</h3>', |
64 'library' => $test_library['library'], | 68 'library' => $test_library['library'], |
65 'editor_representations' => $test_library['editor_representations'], | 69 'editor_representations' => $test_library['editor_representations'], |
70 'library_previews' => $test_library['library_previews'], | |
66 'footer' => '<div class="pager">'. l(t('1'), 'dnd-test/library') . ' '. l(t('2'), 'dnd-test/library', array('query' => array('page' => 2))) .'</div>', | 71 'footer' => '<div class="pager">'. l(t('1'), 'dnd-test/library') . ' '. l(t('2'), 'dnd-test/library', array('query' => array('page' => 2))) .'</div>', |
67 )); | 72 )); |
68 } | 73 } |
69 | 74 |
70 /** | 75 /** |
74 $start = ($page * $limit) - ($limit); | 79 $start = ($page * $limit) - ($limit); |
75 $end = $page * $limit; | 80 $end = $page * $limit; |
76 | 81 |
77 $library = ''; | 82 $library = ''; |
78 $editor_representations = array(); | 83 $editor_representations = array(); |
84 $library_previews = array(); | |
79 for ($i=$start + 1; $i < $end + 1; $i++) { | 85 for ($i=$start + 1; $i < $end + 1; $i++) { |
80 $library .= theme('dnd_library_item', $i); | 86 $library .= theme('dnd_library_item', $i); |
81 $editor_representations += dnd_editor_items($i); | 87 $editor_representations += dnd_editor_items($i); |
88 $library_previews['dnd-test-'. $i] = theme('dnd_library_preview', $i); | |
82 } | 89 } |
83 return array( | 90 return array( |
84 'library' => $library, | 91 'library' => $library, |
85 'editor_representations' => $editor_representations, | 92 'editor_representations' => $editor_representations, |
93 'library_previews' => $library_previews, | |
86 ); | 94 ); |
87 } | 95 } |
88 | 96 |
89 /** | 97 /** |
90 * Theme wrapper that spins out multiple library representations for a given | 98 * Theme wrapper that spins out multiple library representations for a given |
96 foreach(array(t('S'), t('M'), t('L')) as $size) { | 104 foreach(array(t('S'), t('M'), t('L')) as $size) { |
97 $item[$i .'-'. $size] = theme('dnd_editor_item', $i, $size); | 105 $item[$i .'-'. $size] = theme('dnd_editor_item', $i, $size); |
98 } | 106 } |
99 return $item; | 107 return $item; |
100 } | 108 } |
109 | |
110 /** | |
111 * Completely contrived library preview theme function | |
112 */ | |
113 function template_preprocess_dnd_library_preview(&$variables) { | |
114 template_preprocess_dnd_library_item($variables); | |
115 | |
116 $variables['id'] = 'dnd-preview-'. $variables['i']; | |
117 $variables['image'] = '<img src="http://'. $_SERVER['HTTP_HOST'] . base_path() . drupal_get_path('module', 'dnd_test') .'/img/item-'. $variables['img_num'] .'-M.jpg" class="drop" />'; | |
118 | |
119 $variables['description'] = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'; | |
120 } | |
121 | |
101 | 122 |
102 /** | 123 /** |
103 * Completely contrived edit item theme function | 124 * Completely contrived edit item theme function |
104 */ | 125 */ |
105 function template_preprocess_dnd_library_item(&$variables) { | 126 function template_preprocess_dnd_library_item(&$variables) { |
115 } | 136 } |
116 else { | 137 else { |
117 $img = 1; | 138 $img = 1; |
118 } | 139 } |
119 | 140 |
141 $variables['img_num'] = $img; | |
142 $variables['id'] = 'dnd-test-'. $i; | |
120 $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" />'; | 143 $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" />'; |
121 $variables['title'] = t('Lorem Ipsum @count', array('@count' => $i)); | 144 $variables['title'] = t('Lorem Ipsum @count', array('@count' => $i)); |
122 $variables['date'] = 'Feb 18 2009'; | 145 $variables['date'] = 'Feb 18 2009'; |
123 $variables['author'] = 'David Eads'; | 146 $variables['author'] = 'David Eads'; |
124 foreach(array(t('S'), t('M'), t('L')) as $size) { | 147 foreach(array(t('S'), t('M'), t('L')) as $size) { |