/[drupal]/contributions/modules/I-Image/i_image.module
ViewVC logotype

Contents of /contributions/modules/I-Image/i_image.module

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


Revision 1.1 - (show annotations) (download) (as text)
Tue Jul 1 11:46:24 2008 UTC (16 months, 3 weeks ago) by interfacewebdesign
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-php
*** empty log message ***
1 <?php
2 // $Id: i_image.module,v 1.1 2008/03/28 07:16:00 evakoss Exp $
3
4 //hook_menu
5 function i_image_menu() {
6 $menu = Array();
7
8 $menu[] = array(
9 'path' => 'i_image/folders',
10 'callback' => 'i_image_folders',
11 'access' => user_access('Access I-Image'),
12 'type' => MENU_CALLBACK,
13 );
14
15 $menu[] = array(
16 'title' => 'I-Image',
17 'path' => 'i_image/show',
18 'description' => 'An Advanced Image Viewer.',
19 'callback' => 'i_image_show',
20 'access' => user_access('Access I-Image'),
21 );
22
23 $menu[] = array(
24 'title' => 'I-Image',
25 'description' => 'An Advanced Image Viewer.',
26 'path' => 'admin/settings/i_image',
27 'callback' => 'i_image_settings',
28 'access' => user_access('Administer I-Image'),
29 );
30
31 return $menu;
32 }
33
34 function i_image_perm() {
35 return array('Administer I-Image', 'Access I-Image');
36 }
37
38 function i_image_folders() {
39 $xml .= '<node>';
40 $xml .= i_image_get_parent_folders();
41 $xml .= '</node>';
42
43 $xml .= '<settings>';
44 $xml .= i_image_get_settings();
45 $xml .= '</settings>';
46
47 print $xml;
48
49 drupal_get_messages();
50
51 exit;
52 }
53
54 function i_image_get_parent_folders() {
55 $var = taxonomy_get_vocabularies('image');
56
57 foreach ($var as $id => $row) {
58 $row->is_parent = TRUE;
59 $xml .= i_image_folder_info($row);
60 }
61
62 return $xml;
63 }
64
65 function i_image_get_folders($vid = 0, $parent = 0, $parent_level = '') {
66 $parent_level .= $parent . '-';
67
68 $qr = db_query('select * from {term_data} t LEFT JOIN {term_hierarchy} h ON (t.tid = h.tid) where t.vid=%d AND h.parent=%d', $vid, $parent);
69
70 while ($mrow = db_fetch_object($qr)) {
71 $row = taxonomy_get_term($mrow->tid);
72 $row->parents = taxonomy_get_parents($mrow->tid);
73
74 $xml .= i_image_folder_info($row, $parent_level);
75 }
76
77 if ($parent > 0) {
78 $tid = Array();
79 $tid[0] = $parent;
80 $nodes = taxonomy_select_nodes($tid);
81
82 while ($row = db_fetch_object($nodes)) {
83 $xml .= i_image_image_info($row, $parent_level);
84 }
85 }
86
87 return $xml;
88 }
89
90 function i_image_image_info($frow, $parent_level = '') {
91 $frow = node_load($frow->nid);
92 global $base_url;
93 $xml .= '<node isBranch="true" thumbnail="' . $base_url . '/' . $frow->images['thumbnail'] . '" type="file" label="' . $frow->title . '" description="' . $frow->body . '"
94 path="' . $base_url . '/' . $frow->images['_original'] . '" />';
95
96 return $xml;
97 }
98
99 function i_image_get_folder_parents($array) {
100 if (count($array) > 0) {
101 foreach ($array as $pvalue) {
102 //print $pvalue;
103 $parents .= $pvalue->tid . ',';
104 }
105 }
106
107 return $parents;
108 }
109
110 function i_image_folder_info($row, $parent_level = '') {
111 if ($row->is_parent) {
112 $xml .= '<node type="folder" label="' . $row->name . '" description="' . $row->description . '">';
113 } else {
114 $parents = i_image_get_folder_parents($row->parents);
115 $xml .= '<node type="folder" label="' . $row->name . '" description="' . $row->description . '">';
116 }
117 if ($row->is_parent) {
118 $xml .= i_image_get_folders($row->vid, 0, $parent_level);
119 } else {
120 $xml .= i_image_get_folders($row->vid, $row->tid, $parent_level);
121 }
122 $xml .= '</node>';
123
124 return $xml;
125 }
126
127 function i_image_show_block($width = '', $height = '') {
128 global $base_url;
129 $swf = $base_url . '/' . drupal_get_path('module', 'i_image') . '/viewer.swf?url=' . $base_url . '/?q=i_image/folders';
130
131 return '
132 <div align="center" style="width:100%; height:100%;">
133 <div style="width:' . $width . '; height:' . $height . ';">
134 <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="viewer" align="middle">
135 <param name="allowScriptAccess" value="sameDomain" />
136 <param name="allowFullScreen" value="false" />
137 <param name="movie" value="' . $swf . '" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="salign" value="lt" /><param name="wmode" value="opaque" /><param name="bgcolor" value="#ffffff" /> <embed src="' . $swf . '" menu="false" quality="high" scale="noscale" salign="lt" wmode="opaque" bgcolor="#ffffff" width="100%" height="100%" name="viewer" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
138 </object>
139 </div>
140 </div>
141 ';
142 }
143
144 function i_image_show() {
145 return i_image_show_block(variable_get('i_image_width', '400px'), variable_get('i_image_height', '400px'));
146 }
147
148 function i_image_settings() {
149 return drupal_get_form('i_image_settings_form');
150 }
151
152 function i_image_settings_form() {
153 $form = Array();
154
155 $form['i_image_dimensions'] = array(
156 '#type' => 'fieldset',
157 '#title' => 'Dimensions',
158 '#collapsible' => TRUE,
159 '#collapsed' => TRUE,
160 );
161
162 $form['i_image_dimensions']['i_image_width'] = array(
163 '#type' => 'textfield',
164 '#title' => 'Flash Width',
165 '#default_value' => variable_get('i_image_width', '400px'),
166 );
167
168 $form['i_image_dimensions']['i_image_height'] = array(
169 '#type' => 'textfield',
170 '#title' => 'Flash Height',
171 '#default_value' => variable_get('i_image_height', '400px'),
172 );
173
174 $form['i_image_dimensions']['i_image_block_width'] = array(
175 '#type' => 'textfield',
176 '#title' => 'Flash Block Width',
177 '#default_value' => variable_get('i_image_block_width', '300px'),
178 );
179
180 $form['i_image_dimensions']['i_image_block_height'] = array(
181 '#type' => 'textfield',
182 '#title' => 'Flash Block Height',
183 '#default_value' => variable_get('i_image_block_height', '200px'),
184 );
185
186
187
188 $form['i_image_design'] = array(
189 '#type' => 'fieldset',
190 '#title' => 'Design',
191 '#collapsible' => TRUE,
192 '#collapsed' => FALSE,
193 );
194
195 $form['i_image_design']['i_image_backcolor'] = array(
196 '#type' => 'textfield',
197 '#title' => 'Back Color',
198 '#default_value' => variable_get('i_image_backcolor', '000000'),
199 );
200
201 $form['i_image_design']['i_image_toolboxcolor'] = array(
202 '#type' => 'textfield',
203 '#title' => 'Tool Box Color',
204 '#default_value' => variable_get('i_image_toolboxcolor', '000000'),
205 );
206
207 $form['i_image_design']['i_image_depthcolors'] = array(
208 '#type' => 'textfield',
209 '#title' => 'Depth Colors',
210 '#default_value' => variable_get('i_image_depthcolors', '444444, 555555, 666666, 777777'),
211 );
212
213 $form['i_image_design']['i_image_rollovercolor'] = array(
214 '#type' => 'textfield',
215 '#title' => 'RollOver Color',
216 '#default_value' => variable_get('i_image_rollovercolor', '333333'),
217 );
218
219 $form['i_image_design']['i_image_selectioncolor'] = array(
220 '#type' => 'textfield',
221 '#title' => 'Selection Color',
222 '#default_value' => variable_get('i_image_selectioncolor', '111111'),
223 );
224
225 $form['i_image_design']['i_image_textcolor'] = array(
226 '#type' => 'textfield',
227 '#title' => 'Text Color',
228 '#default_value' => variable_get('i_image_textcolor', '000000'),
229 );
230
231 $form['i_image_design']['i_image_textrollovercolor'] = array(
232 '#type' => 'textfield',
233 '#title' => 'Text RollOver Color',
234 '#default_value' => variable_get('i_image_textrollovercolor', 'FFFFFF'),
235 );
236
237 $form['i_image_design']['i_image_textselectioncolor'] = array(
238 '#type' => 'textfield',
239 '#title' => 'Text Selection Color',
240 '#default_value' => variable_get('i_image_textselectioncolor', 'FFFFFF'),
241 );
242
243 return system_settings_form($form);
244 }
245
246 function i_image_get_settings() {
247 $ar = explode(",", variable_get('i_image_depthcolors', '444444, 555555, 666666, 777777'));
248 for ($i=0; $i<=count($ar)-1; $i++) {
249 $str .= str_replace('#', '', trim($ar[$i]));
250 if ($i != count($ar) - 1) $str .= ',';
251 }
252
253 $xml .= '<setting name="backcolor" value="' . variable_get('i_image_backcolor', '000000') . '" />';
254 $xml .= '<setting name="toolbackcolor" value="' . variable_get('i_image_toolboxcolor', '000000') . '" />';
255 $xml .= '<setting name="depthcolors" value="' . $str . '" />';
256 $xml .= '<setting name="rollovercolor" value="' . variable_get('i_image_rollovercolor', '333333') . '" />';
257 $xml .= '<setting name="selectioncolor" value="' . variable_get('i_image_selectioncolor', '111111') . '" />';
258 $xml .= '<setting name="textcolor" value="' . variable_get('i_image_textcolor', '000000') . '" />';
259 $xml .= '<setting name="textrollovercolor" value="' . variable_get('i_image_textrollovercolor', 'FFFFFF') . '" />';
260 $xml .= '<setting name="textselectioncolor" value="' . variable_get('i_image_textselectioncolor', 'FFFFFF') . '" />';
261
262 return $xml;
263 }
264
265 function i_image_block($op = 'list', $delta = 0, $edit = array()) {
266 switch ($op) {
267 case 'list':
268 $blocks = array();
269
270 $blocks[0]['info'] = 'I-Image';
271 return $blocks;
272
273 case 'view':
274 $data['content'] = i_image_show_block(variable_get('i_image_block_width', '300px'), variable_get('i_image_block_height', '200px'));
275 return $data;
276 }
277 }

  ViewVC Help
Powered by ViewVC 1.1.2