Project

General

Profile

« Previous | Next » 

Revision 6f4dd14a

Added by Andreas Kohlbecker about 16 years ago

cdm_muri module finished; ThickBox jQuery plugin working (bugfix in compat-1.0.js)

View differences:

modules/cdm_dataportal/INSTALL.txt
18 18
  cdm_dataportl requires jQuery version 1.2.1
19 19
  The contributed Drupal module 'jquery_update' however updates only to version 1.1.2, 
20 20
  thus a manual update as described in http://drupal.org/node/196140 is nessecary.  
21
  
22
  I addition you must edit compat-1.0.js: replace lines 24 - 26 by:
23
  
24
          /*
25
           * a.kohlbecker: unload is still a valid event type and must not be replaced! 
26
           *               compat-1.0.js breaks plugins wich are using this event e.g. thickbox
27
           *  => thus I removed load from var e.
28
           */ 
29
          var e = ("blur,focus, resize,scroll,unload,click,dblclick," +
30
            "mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," + 
31
            "submit,keydown,keypress,keyup,error").split(",");
21 32

  
22 33

  
23 34
Installation procedure:
modules/cdm_dataportal/cdm_dataportal.module
626 626
  }
627 627
  return $pstr;
628 628
}
629

  
modules/cdm_dataportal/cdm_dataportal.theme.php
381 381
  //$specimen->uuid
382 382
  
383 383
  // ---- jQuery ThickBox:
384
  // bug: thickbox.js line 237 .trigger("unload") -> event is not triggered
384
  /*
385
   * bug: compat-1.0.js && thickbox.js line 237 .trigger("unload")
386
   * -> event is not triggered because of problems with compat-1.0.js'
387
   * 
388
   */
389
  
385 390
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/thickbox.js');
386 391
  drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/js/thickbox.css');
387 392
  
......
407 412
    $meta_row = '<tr class="meta_data">';
408 413
    
409 414
    foreach($specimen->mediaURI as $uri){
415
      
410 416
      // get media uri conversion rules if the module is installed and activated
411 417
      if(module_exists('cdm_mediauri')){
412
        $muris = cdm_mediauri_mediaUri_conversion($uri->value);
418
        $muris = cdm_mediauri_conversion($uri->value);
413 419
      }
420
      // --- handle media preview rules
414 421
      if(isset($muris['preview'])){    
415 422
        
416 423
        $a_child = '<img src="'.$muris['preview']['uri'].'" '
......
420 427
      } else {
421 428
        $a_child = '<img src="'.$image_url.'" />';
422 429
      }
423
      $webapp_access = '';
430
      
431
      // --- handle web application rules
432
      $webapp = '';
433
      if(isset($muris['webapp'])){
434
        if($muris['webapp']['embed_html']){
435
          // embed in same page
436
          $webapp = $muris['webapp']['embed_html'];  
437
        } else {
438
          $webapp = l(t('web application'), $muris['webapp']['uri']);            
439
        }
440
      }
424 441
      $media_row .= '<td><a href="'.$uri->value.'" target="'.$uri->uuid.'">'.$a_child.'</a></td>';
425
      $meta_row .= '<td><span class="label">'.check_plain($specimen->specimenLabel).'</span>'.$webapp_access.'</td>';
442
      $meta_row .= '<td><span class="label">'.check_plain($specimen->specimenLabel).'</span><div class="webapp">'.$webapp.'</div></td>';
426 443
    }
427 444
    $out .= $media_row.'</tr>';
428 445
    $out .= $meta_row.'</tr>';
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