Revision 6f4dd14a
Added by Andreas Kohlbecker about 16 years ago
modules/cdm_dataportal/cdm_mediauri/cdm_mediauri.module | ||
---|---|---|
67 | 67 |
'callback arguments' => array('cdm_mediauri_rule_delete'), |
68 | 68 |
'type' => MENU_CALLBACK, |
69 | 69 |
); |
70 |
|
|
71 |
$rules = cdm_mediauri_rules(); |
|
72 |
foreach($rules as $rule){ |
|
73 |
if($rule['embed_html'] && $rule['path']){ |
|
74 |
$items[] = array( |
|
75 |
'path' => $rule['path'], |
|
76 |
'access' => true, //TODO restrict access |
|
77 |
'callback' => 'cdm_mediauri_view_embed', |
|
78 |
'type' => MENU_CALLBACK, |
|
79 |
); |
|
80 |
} |
|
81 |
} |
|
70 | 82 |
|
71 | 83 |
} |
72 | 84 |
return $items; |
... | ... | |
133 | 145 |
|
134 | 146 |
if(is_numeric($form_values['rid'])){ |
135 | 147 |
$rules = cdm_mediauri_rules(); |
148 |
// determine if the menu has changed |
|
149 |
if($rules[$form_values['rid']]['embed'] != $form_values['rule']['embed'] || $rules[$form_values['rid']]['path'] != $form_values['rule']['path']) { |
|
150 |
menu_rebuild(); |
|
151 |
drupal_set_message('Menu Rebuild'); |
|
152 |
} |
|
136 | 153 |
$rules[$form_values['rid']] = $form_values['rule']; |
137 | 154 |
variable_set('cdm_mediauri_rules', $rules); |
138 | 155 |
drupal_set_message('Rule saved'); |
... | ... | |
188 | 205 |
$rule['affix'] = ''; |
189 | 206 |
$rule['url_encode'] = 0; |
190 | 207 |
$rule['embed_html'] = 0; |
208 |
$rule['path'] = ''; |
|
209 |
$rule['title'] = ''; |
|
191 | 210 |
} |
192 | 211 |
} else { |
193 | 212 |
$rules = cdm_mediauri_rules(); |
... | ... | |
246 | 265 |
'#rows' => 1, |
247 | 266 |
); |
248 | 267 |
|
249 |
$form['rule']['url_encode'] = array( |
|
250 |
'#type' => 'checkbox', |
|
251 |
'#title' => t('Url Encode'), |
|
252 |
'#default_value' => $rule['url_encode'], |
|
253 |
'#description' => t('Whether the converted url is to be url encoded') |
|
254 |
); |
|
255 |
|
|
256 | 268 |
// ['embed_html'] = 1; |
257 | 269 |
|
258 | 270 |
$form['rule']['embed_html'] = array( |
... | ... | |
261 | 273 |
'#default_value' => $rule['embed_html'], |
262 | 274 |
'#description' => t('Embed the construct of prefix + url + affix into the page as plain html') |
263 | 275 |
); |
276 |
|
|
277 |
$form['rule']['url_encode'] = array( |
|
278 |
'#type' => 'checkbox', |
|
279 |
'#title' => t('Url Encode'), |
|
280 |
'#default_value' => $rule['url_encode'], |
|
281 |
'#description' => t('Whether the converted url is to be url encoded') |
|
282 |
); |
|
283 |
|
|
284 |
|
|
285 |
$form['rule']['path'] = array( |
|
286 |
'#type' => 'textfield', |
|
287 |
'#title' => t('Drupal Path'), |
|
288 |
'#default_value' => $rule['path'], |
|
289 |
'#description' => t('Drupal Path under which the media is to be embedded into a page') |
|
290 |
); |
|
291 |
|
|
292 |
|
|
293 |
$form['rule']['title'] = array( |
|
294 |
'#type' => 'textfield', |
|
295 |
'#title' => t('Page Title'), |
|
296 |
'#default_value' => $rule['title'], |
|
297 |
'#description' => t('Page Title') |
|
298 |
); |
|
264 | 299 |
|
265 | 300 |
|
266 | 301 |
$form['rule']['prefix'] = array( |
... | ... | |
323 | 358 |
$rule1['size_x'] = 125; |
324 | 359 |
$rule1['size_Y'] = 200; |
325 | 360 |
|
361 |
|
|
326 | 362 |
$rule2 = array(); |
327 | 363 |
$rule2['type'] = 'webapp'; |
328 | 364 |
$rule2['pattern'] = '/^http:\/\/ww2.bgbm.org\/herbarium\/images\/((?:\w+\/)(?:\d+\/){4}[\w_]+?\.)(.*)$/'; |
329 | 365 |
$rule2['replace'] = '$1fpx'; |
330 |
$rule2['prefix'] = '<embed width="490" height="700" align="middle" type="application/x-shockwave-flash" |
|
366 |
$rule2['prefix'] = '<div style="float: left; width: 10em;"> |
|
367 |
<p>© BGBM: <br> |
|
368 |
Access is granted under the following conditions:<br> |
|
369 |
The images may not passed on to any third party without our written |
|
370 |
consent and due mention of the copyright restrictions, and may not be |
|
371 |
used for commercial or non-scientific purposes. Reproduction in |
|
372 |
scientific publications is authorized on the condition that the source |
|
373 |
and the copyright are fully acknowledged:<br> |
|
374 |
© Botanischer Garten und Botanisches Museum Berlin-Dahlem, FU Berlin.</li> |
|
375 |
</p> |
|
376 |
<p><a href="http://www.bgbm.org/bgbm/verantwo_e.htm" |
|
377 |
class="leftnavi" title="Contact">Contact</a> | <a href="http://www.bgbm.org/bgbm/imprint.htm" |
|
378 |
class="leftnavi" title="Impressum">Imprint</a> | <a href="http://www.bgbm.org/disclaim_e.htm" class="leftnavi" |
|
379 |
title="Disclaimer">Disclaimer</a> |
|
380 |
</p> |
|
381 |
</div><div><embed width="490" height="700" align="middle" type="application/x-shockwave-flash" |
|
331 | 382 |
pluginspage="http://www.macromedia.com/go/getflashplayer" name="FSIViewer" |
332 | 383 |
bgcolor="black" quality="high" play="true" |
333 | 384 |
src="http://ww2.bgbm.org/fsi/fsi.swf?cfg=plugin2&FPXSrc='; |
334 |
$rule2['affix'] = '&FPXWidth=2801&FPXHeight=4478&Effects=qlt%3D85&InitialView=&Measure_ImageWidth=270.0&Measure_Suffix=%20mm"/>'; |
|
385 |
$rule2['affix'] = '&FPXWidth=2801&FPXHeight=4478&Effects=qlt%3D85&InitialView=&Measure_ImageWidth=270.0&Measure_Suffix=%20mm"/></div>';
|
|
335 | 386 |
$rule2['url_encode'] = 1; |
336 | 387 |
$rule2['embed_html'] = 1; |
337 |
return array($rule1, $rule2); |
|
388 |
$rule2['path'] = 'bgbm.org/herbarium'; |
|
389 |
|
|
390 |
return array($rule1, $rule2); |
|
338 | 391 |
|
339 | 392 |
} else { |
340 | 393 |
return variable_get('cdm_mediauri_rules', array()); |
... | ... | |
350 | 403 |
* $return_array[{type}] { // values for {type}:(preview, webapp, media, original) |
351 | 404 |
* ['size_x'], // dimensions of preview image in px |
352 | 405 |
* ['size_y'], // dimensions of preview image in px |
353 |
* ['uri'] //the uri |
|
406 |
* ['uri'] // the uri possibly prefixed with path |
|
407 |
* ['embed_html'] // the uri embedded into some string |
|
354 | 408 |
* } |
355 | 409 |
* |
356 | 410 |
* @return returns an associative array of the original media uri and all convered |
... | ... | |
372 | 426 |
$uri_converted = urlencode($uri_converted); |
373 | 427 |
} |
374 | 428 |
$muris[$rule['type']] = array('uri'=>$uri_converted, 'size_x'=>$rule['size_x'], 'size_y'=>$rule['size_y']); |
429 |
if(isset($rule['embed_html']) && $rule['embed_html']){ |
|
430 |
if($rule['path']){ |
|
431 |
// embed later on other page |
|
432 |
$muris[$rule['type']]['uri'] = $rule['path'].'/'.$uri_converted; |
|
433 |
} else { |
|
434 |
// direct embed |
|
435 |
$muris[$rule['type']]['embed_html'] = $rule['prefix'].$uri_converted.$rule['affix']; |
|
436 |
} |
|
437 |
} |
|
375 | 438 |
} |
376 | 439 |
} |
377 | 440 |
return $muris; |
378 | 441 |
} |
442 |
|
|
443 |
function cdm_mediauri_view_embed($uri){ |
|
444 |
|
|
445 |
$path = ''; |
|
446 |
for($i = 0; ($arg = arg($i)); $i++){ |
|
447 |
if($arg == $uri){ |
|
448 |
break; |
|
449 |
} else { |
|
450 |
$path .= ($path ? '/': '').$arg; |
|
451 |
} |
|
452 |
} |
|
453 |
|
|
454 |
$rule = false; |
|
455 |
foreach(cdm_mediauri_rules() as $r){ |
|
456 |
if($r['embed_html'] && $r['path'] == $path){ |
|
457 |
$rule = $r; |
|
458 |
break; |
|
459 |
} |
|
460 |
} |
|
461 |
|
|
462 |
if($rule){ |
|
463 |
drupal_set_title($rule['title']); |
|
464 |
return $rule['prefix'].$uri.$rule['affix']; |
|
465 |
} |
|
466 |
|
|
467 |
return 'ERROR:'.$path.$uri; |
|
468 |
} |
Also available in: Unified diff
cdm_muri module finished; ThickBox jQuery plugin working (bugfix in compat-1.0.js)