Project

General

Profile

« Previous | Next » 

Revision 2264b60d

Added by Andreas Kohlbecker about 13 years ago

displaying polytomous keys (fixes #2152)

View differences:

modules/cdm_dataportal/theme/cdm_dataportal.name.theme
369 369
  // find best matching default RenderTemplate in theme
370 370
  //echo "<br/><br/>RENDER PATH:  ".$renderPath;
371 371
  //var_dump('RENDER PATH: ' . $renderPath);
372
  while(!is_array($template) && strlen($renderPath) > 0){
373
    $template = theme('get_nameRenderTemplate', $renderPath);
374
    $renderPath = substr($renderPath, 0, strrpos($renderPath, '.'));
375
    //     if(!is_array($template)){
376
    //         echo "<br/>->".$renderPath;
377
    //     }
372

  
373
  // preserve renderPath_base
374
  if( ($separatorPos =  strpos($renderPath, '.')) >= 0 ){
375
  } else {
376
  	$separatorPos = strlen($renderPath);
377
  }
378
  $renderPath_base = substr($renderPath, 0, $separatorPos);
379

  
380
  // find in theme function if it exists
381
  if(theme_get_function('get_nameRenderTemplate')){
382
	  while(!is_array($template) && strlen($renderPath) > 0){
383
	    $template = theme('get_nameRenderTemplate', $renderPath);
384
	    $renderPath = substr($renderPath, 0, strrpos($renderPath, '.'));
385
	    //     if(!is_array($template)){
386
	    //         echo "<br/>->".$renderPath;
387
	    //     }
388
	  }
378 389
  }
379 390

  
380 391
  // otherwise get default RenderTemplate from theme
......
383 394
  }
384 395
  // otherwise get system default RenderTemplate
385 396
  if(!is_array($template)){
386
    switch($renderPath){
397
    switch($renderPath_base){
387 398
      case 'list_of_taxa':
388
      case  'acceptedFor':
399
      case 'acceptedFor':
389 400
      case 'taxon_page_synonymy':
390 401
      case 'typedesignations':
391 402
      case 'taxon_page_title':
403
      case 'polytomousKey':
392 404
      case 'na': $template = array(
393 405
              'namePart' => array('#uri'=>true),
394 406
      //'authorshipPart' => true,
......
434 446
}
435 447

  
436 448
function get_partDefinition($taxonNameType){
449

  
437 450
  //TODO implement admin user interface to allow specify the partdefinitions for any type
438 451
  //     preliminar solution: using themes
439 452

  
......
459 472
      ),
460 473
      );
461 474
      break;
462
      case 'BotanicalName': $partdef = array(
475
      case 'BotanicalName':
476
      default: $partdef = array(
463 477
        'namePart' => array(
464 478
          'name' => true,
465 479
          'authors' => true
......
476 490
      ),
477 491
      );
478 492
      break;
479
      default: $partdef = array(
480
        'namePart' => array(
481
          'name' => true,
482
          'authorTeam' => true
483
      ),
484
      'referencePart' => array(
485
          'reference' => true
486
      ),
487
        'microreferencePart' => array(
488
          'microreference' => true,
489
      ),
490
        'statusPart' => array(
491
          'status' => true,
492
      ),
493
        'descriptionPart' => array(
494
          'description' => true,
495
      ),
496
      );
493
//      default: $partdef = array(
494
//        'namePart' => array(
495
//          'name' => true,
496
//          'authorTeam' => true
497
//      ),
498
//      'referencePart' => array(
499
//          'reference' => true
500
//      ),
501
//        'microreferencePart' => array(
502
//          'microreference' => true,
503
//      ),
504
//        'statusPart' => array(
505
//          'status' => true,
506
//      ),
507
//        'descriptionPart' => array(
508
//          'description' => true,
509
//      ),
510
//      );
497 511
    }
498 512
  }
499 513
  return $partdef;
......
503 517

  
504 518
function theme_cdm_taxonName($taxonName, $nameLink = NULL, $refenceLink = NULL,
505 519
	$show_annotations = true, $is_type_designation = false, $skiptags = array()){
506

  
507 520
	$renderTemplate = get_nameRenderTemplate(RenderHints::getRenderPath(), $nameLink, $refenceLink);
508 521
	$partDefinition = get_partDefinition($taxonName->class);
509 522

  
......
518 531
	}
519 532

  
520 533
	$firstEntryIsValidNamePart = is_array($taxonName->taggedName)
521
	&& is_string($taxonName->taggedName[0]->text)
522
	&& $taxonName->taggedName[0]->text != ''
523
	&& $taxonName->taggedName[0]->type == 'name';
534
			&& is_string($taxonName->taggedName[0]->text)
535
			&& $taxonName->taggedName[0]->text != ''
536
			&& $taxonName->taggedName[0]->type == 'name';
524 537

  
525 538
	// got to use second entry as first one, see ToDo comment below ...
526 539
	if($firstEntryIsValidNamePart){

Also available in: Unified diff