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/cdm_api/cdm_api.module
317 317
 */
318 318
function cdm_compose_url($uri_pattern, $pathParameters = array(), $query = NULL ){
319 319

  
320
	if(!isset($pathParameters)){
321
		$pathParameters = array();
322
	}
323

  
320 324
  $request_params = '';
321 325
  $path_params = '';
322 326

  
......
332 336

  
333 337
  $i = 0;
334 338
  while(strpos($uri_pattern, "$".$i) !== FALSE){
335
    if(count($pathParameters) <= $i && user_access('administer')){
336
      drupal_set_message('cdm_compose_url(): missing pathParameters', 'debug');
339
    if(count($pathParameters) <= $i){
340
    	if(user_access('administer')){
341
        drupal_set_message('cdm_compose_url(): missing pathParameters', 'debug');
342
    	}
343
      break;
337 344
    }
338 345
    $uri_pattern = str_replace("$".$i, rawurlencode($pathParameters[$i]), $uri_pattern);
339 346
    ++$i;
......
494 501
        case 'CategoricalData':
495 502
        	$ws_base_uri = CDM_WS_DESCRIPTIONELEMENT;
496 503
        	break;
504
        case 'PolytomousKey':
505
        case 'MediaKey':
506
        case 'MultiAccessKey':
507
          $ws_base_uri = CDM_WS_IDENTIFICATIONKEY;
508
          break;
497 509
        default:  trigger_error('Unsupported CDM Class - no annotations available for ' . $cdmBase->class, E_USER_ERROR);
498 510
            return;
499 511
    }
......
727 739
  $is_cdm_ws_uri = _is_cdm_ws_uri($uri);
728 740
  $use_cacheL2 = variable_get('cdm_webservice_cache', 1);
729 741

  
730
  $cacheL1_obj = $cacheL1[$uri];
742
  if(array_key_exists($uri, $cacheL1)){
743
    $cacheL1_obj = $cacheL1[$uri];
744
  }
731 745
  //print $cacheL1_obj;
732 746
  $set_cacheL1 = false;
733 747
  if($is_cdm_ws_uri && !$cacheL1_obj){
......
835 849

  
836 850
function cdm_load_obj($datastr){
837 851

  
838
  // NOTICE: the cdm dataportal currently does not support xml so the line below are commented out
839
  /*
840
   // if the web service delivers XML convert it into json
841
   if(variable_get('cdm_webservice_type', 'json') == 'xml'){
842
   $datastr = xml2json::transformXmlStringToJson($datastr);
843
   }
844
   */
845

  
846 852
  $obj = json_decode($datastr);
847 853

  
848 854
  if(!(is_object($obj) || is_array($obj)) ){
......
869 875
  static $acceptLanguage = null;
870 876

  
871 877
  if(!$acceptLanguage) {
872
  	$headers = getallheaders();
873
  	if($headers['Accept-Language']){
874
  		$acceptLanguage = $headers['Accept-Language'];
875
  	} else {
878
  	if(function_exists('apache_request_headers')){
879
  		$headers = apache_request_headers();
880
	  	if($headers['Accept-Language']){
881
	  		$acceptLanguage = $headers['Accept-Language'];
882
	  	}
883
  	}
884
  	if( !$acceptLanguage ) {
876 885
  		$acceptLanguage = "en"; // DEFAULT TODO make configurable
877 886
  	}
878 887
  }
modules/cdm_dataportal/cdm_api/webservice_uris.php
119 119

  
120 120
define('CDM_WS_DERIVEDUNIT_FACADE', 'derivedUnitFacade/$0');
121 121

  
122
define('CDM_WS_IDENTIFICATIONKEY', 'identificationKey');
122 123
define('CDM_WS_MEDIAKEY', 'mediaKey');
123 124
define('CDM_WS_MULTIACCESSKEY', 'multiAccessKey');
124 125
define('CDM_WS_POLYTOMOUSKEY', 'polytomousKey');
modules/cdm_dataportal/cdm_dataportal.css
375 375
	 font-size: 90%;
376 376
	 line-height: 1em;
377 377
	 color: #999999;
378
}
379

  
380
.polytomousKey_linkedStyle td{
381
	vertical-align: top;
382
	padding-top: 0;
383
}
384
.polytomousKey_linkedStyle tr.childCount_0 td{
385
  padding-top: 1em;
386
}
387
.polytomousKey_linkedStyle tr:hover {
388
  background-color: #eeeeee;
389
}
390
	
391
.polytomousKey_linkedStyle .nodeLink, .polytomousKey_linkedStyle .nodeNumber {
392
  width: 1.5em;
393
}
394
.polytomousKey_linkedStyle .nodeLink{
395
  text-align: right;
396
}
397

  
398
.polytomousKey_linkedStyle .nodeLinkToTaxon, .polytomousKey_linkedStyle .nodeLinkToSubkey {
399
	float: right;
400
  text-align: right;
378 401
}
modules/cdm_dataportal/cdm_dataportal.install
17 17
}
18 18

  
19 19

  
20

  
21 20
/**
22 21
 * Implementation of hook_api_update_N().
23 22
 *
modules/cdm_dataportal/cdm_dataportal.module
202 202
		// expected callback arguments: uuid, mediarepresentation_uuid, part_uuid or part#
203 203
		);
204 204

  
205
		$items[] = array(
206
      'path' => 'cdm_dataportal/polytomousKey',
207
      'callback' => 'cdm_dataportal_view_polytomousKey',
208
      'access' => true,
209
      'type' => MENU_CALLBACK,
210
    // expected callback arguments: polytomousKey->uuid
211
    );
212

  
205 213
		$items[] = array(
206 214
      'path' => 'cdm_dataportal/search',
207 215
      'callback' => 'cdm_dataportal_view_search_advanced',
......
884 892
	return theme('cdm_media_page', $media, $mediarepresentation_uuid, $part);
885 893
}
886 894

  
895
function _load_taxonBase(&$taxonBase){
896
	if(isset($taxonBase->uuid)){
897
	    $taxonBase->name = cdm_ws_get(CDM_WS_TAXON, array($taxonBase->uuid, "name"));
898
	    $taxonBase->name->taggedName = cdm_ws_get(CDM_WS_NAME, array($taxonBase->name->uuid, "taggedName"));
899
	    $taxonBase->name->nomenclaturalReference = cdm_ws_get(CDM_WS_NAME, array($taxonBase->name->uuid, "nomenclaturalReference"));
900
	  }
901
}
902

  
903
/**
904
 * Loads the subgraph of the given PolytomousKeyNode recursively from the cdm REST service.
905
 * @param PolytomousKeyNode $polytomousKeyNode passed by reference
906
 * @return nothing
907
 */
908
function _load_polytomousKeySubGraph(&$polytomousKeyNode){
909
	if(!$polytomousKeyNode){
910
		return;
911
	}
912
	$polytomousKeyNode = cdm_ws_get(CDM_WS_POLYTOMOUSKEY_NODE, $polytomousKeyNode->uuid);
913

  
914
  if(!$polytomousKeyNode){
915
  	//drupal_set_message("_load_polytomousKeyChildNodes() : could not load polytomousKeyNode", "error");
916
  	return;
917
  }
918

  
919
  // load children
920
  foreach($polytomousKeyNode->children as &$childNode){
921
    _load_polytomousKeySubGraph($childNode);
922
  }
923

  
924
  // load subkey
925
  $polytomousKeyNode->subkey = cdm_ws_get(CDM_WS_POLYTOMOUSKEY_NODE, array($polytomousKeyNode->uuid, "subkey"));
926

  
927
  // load taxon
928
  $polytomousKeyNode->taxon = cdm_ws_get(CDM_WS_POLYTOMOUSKEY_NODE, array($polytomousKeyNode->uuid, "taxon"));
929
  _load_taxonBase($polytomousKeyNode->taxon);
930
  return;
931
}
932

  
933
function cdm_dataportal_view_polytomousKey($polytomousKeyUuid){
934
  $polytomousKey = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, $polytomousKeyUuid);
935

  
936
  $sourcePager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, array($polytomousKeyUuid, "sources"));
937
  if(is_array($sourcePager->records)){
938
    $polytomousKey->sources =  $sourcePager->records;
939
  }
940

  
941
  $annotationPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, array($polytomousKeyUuid, "annotations"));
942
  if(is_array($annotationPager->records)){
943
    $polytomousKey->annotations = $annotationPager->records;
944
  }
945

  
946
  _load_polytomousKeySubGraph($polytomousKey->root);
947
  return theme('cdm_polytomousKey_page', $polytomousKey);
948
}
949

  
887 950
/**
888 951
 * The taxon page gives detailed information on a taxon, it shows:
889 952
 *  - Taxon name
modules/cdm_dataportal/test/phpUnit/bootstrap.php
5 5
// see http://pkp.sfu.ca/wiki/index.php/Configure_Eclipse_for_PHPUnit#Configure_XDebug_Debugger_to_work_with_PHPUnit
6 6
//
7 7
print("> bootstrapping Drupal for phpUnit ...\n");
8

  
9
//$phpUnitTestBaseDir = "test".DIRECTORY_SEPARATOR."phpUnit";
10
//
11
//while(!str_endsWith( getcwd(), $phpUnitTestBaseDir) || strlen(getcwd()) < strln($phpUnitTestBaseDir)){
12
//
13
//}
14

  
15
print(">".getcwd()."\n");
8
//print(">".getcwd()."\n");
16 9

  
17 10
// TestUtils.php must be included at the very first step
18 11
require_once ('TestUtils.php');
......
23 16
$_SERVER['HTTP_HOST']='127.0.0.1';
24 17
$_SERVER['REQUEST_METHOD'] = 'get';
25 18
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
26
$_SERVER['REQUEST_URI'] = "http://" . $_SERVER['HTTP_HOST'] . "/" . "cichorieae/";
19
$_SERVER['PHP_SELF'] = $_SERVER['SITE_BASE_PATH']."/index.php";
20
//$_SERVER['REQUEST_URI'] = "http://" . $_SERVER['HTTP_HOST'] . "/" . "flora-malesiana/";
27 21

  
28 22
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
29 23

  
modules/cdm_dataportal/test/phpUnit/resources/theme/cdm_dataportal.name.themeTest-taxon1.json
16 16
    "updated": "2011-04-01T17:31:18.795+02:00",
17 17
    "useNameCache": false,
18 18
    "uuid": "0ae4f7ab-f482-482c-ba57-cf0e4389a417",
19
    "name": [
20
        {
21
            "class": "TaggedText",
22
            "text": "Alectryon",
23
            "type": "name" 
24
        },
25
        {
26
            "class": "TaggedText",
27
            "text": "myrmecophilus",
28
            "type": "name" 
29
        },
30
        {
31
            "class": "TaggedText",
32
            "text": "Leenh.",
33
            "type": "authors" 
34
        } 
35
    ] 
19
    "name": {
20
      "taggedName": [
21
          {
22
              "class": "TaggedText",
23
              "text": "Alectryon",
24
              "type": "name" 
25
          },
26
          {
27
              "class": "TaggedText",
28
              "text": "myrmecophilus",
29
              "type": "name" 
30
          },
31
          {
32
              "class": "TaggedText",
33
              "text": "Leenh.",
34
              "type": "authors" 
35
          } 
36
      ]
37
    }
36 38
}
modules/cdm_dataportal/theme/cdm_dataportal.common.theme
12 12

  
13 13
define(FOOTNOTE_ANNOTATIONS, 'annotations');
14 14

  
15

  
15 16
/**
16 17
* Get the true path to the root of the Drupal site.
17 18
* Better than using DOCUMENT_ROOT and base_path().
......
361 362
}
362 363

  
363 364

  
365

  
366

  
364 367
/* ============================ java script functions ============================= */
365 368

  
366 369
function _add_js_thickbox(){
modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
205 205
	return $out;
206 206
}
207 207

  
208

  
208 209
/**
209 210
 * TODO: assign a new name to the function? because it is used for the citations
210 211
 *       textdata elements and not for all text data description elements
......
223 224

  
224 225
	if(is_array($element->sources)){
225 226
		foreach($element->sources as $source){
226
			$referenceCitation = theme('cdm_DescriptionElementSource', $source);
227
			if($description && strlen($description) > 0 && $referenceCitation ){
228
				$sourceRefs .= ' ('.$referenceCitation.')' ;
229
			}else if ($referenceCitation){
230
				$sourceRefs = $referenceCitation;
231
			}
227
		  $referenceCitation = theme('cdm_DescriptionElementSource', $source);
228
      if($description && strlen($description) > 0 && $referenceCitation ){
229
        $sourceRefs .= ' ('.$referenceCitation.')' ;
230
      }else if ($referenceCitation){
231
        $sourceRefs = $referenceCitation;
232
      }
232 233

  
233
			if(strlen($sourceRefs) > 0){
234
				$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
235
			}
234
      if(strlen($sourceRefs) > 0){
235
        $sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
236
      }
236 237

  
237
			if ($source->nameUsedInSource->uuid){ //do a link to name page
238
				$name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache,
239
				path_to_name($source->nameUsedInSource->uuid),
240
				array(), NULL, NULL, FALSE ,TRUE);
241
			}else if (strlen($source->nameUsedInSource->originalNameString) > 0){ //show a text without link
242
				$name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
243
			}
238
      if ($source->nameUsedInSource->uuid){ //do a link to name page
239
        $name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache,
240
        path_to_name($source->nameUsedInSource->uuid),
241
        array(), NULL, NULL, FALSE ,TRUE);
242
      }else if (strlen($source->nameUsedInSource->originalNameString) > 0){ //show a text without link
243
        $name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
244
      }
244 245

  
245
			if ($asListElement){
246
				$out = '<li class="descriptionText">' . $name_used_in_source_link_to_show;
247
				//adding ":" if necesary
248
				if ($name_used_in_source_link_to_show && ($description || $sourceRefs)){
249
					$out .= ': ';
250
				}
251
				$out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', $element) . '</li>';
252
			}else{
253
				if ($name_used_in_source_link_to_show){
254
					$name_used_in_source_link_to_show = ' (name in source: '. $name_used_in_source_link_to_show . ')';
255
				}
256
				$out = $description . $sourceRefs . $name_used_in_source_link_to_show;
257
			}
246
      if ($asListElement){
247
        $out = '<li class="descriptionText">' . $name_used_in_source_link_to_show;
248
        //adding ":" if necesary
249
        if ($name_used_in_source_link_to_show && ($description || $sourceRefs)){
250
          $out .= ': ';
251
        }
252
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', $element) . '</li>';
253
      }else{
254
        if ($name_used_in_source_link_to_show){
255
          $name_used_in_source_link_to_show = ' (name in source: '. $name_used_in_source_link_to_show . ')';
256
        }
257
        $out = $description . $sourceRefs . $name_used_in_source_link_to_show;
258
      }
258 259
		}
259 260
	}
260 261
	//if no sources, print the description
......
268 269
	return $out;
269 270
}
270 271

  
272

  
271 273
function theme_cdm_common_names($elements){
272 274
	$text_data_out = '';
273 275
	$common_name_out = '';
......
623 625
	return $out;
624 626
}
625 627

  
628
function theme_cdm_IdentifieableSource($source, $doLink = TRUE){
629

  
630
  if(isset($source->citation)){
631
    $out = theme('cdm_reference', $source->citation, $source->citationMicroReference, $doLink);
632
  }
633
  return $out;
634
}
635

  
636

  
637

  
638

  
626 639

  
627 640
/*
628 641
 function theme_cdm_descriptionElementDistribution($descriptionElements){
......
805 818
  return $pager->records;
806 819
}
807 820

  
821
function theme_cdm_IdentificationKey($identificationKey, $doLinkToKeyPage = true){
822

  
823
	 $parentRenderPath = RenderHints::getRenderPath();
824
	 RenderHints::pushToRenderStack("IdentificationKey");
825

  
826
	 if($doLinkToKeyPage) {
827
	   $out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
828
	 } else {
829
	   $out = $identificationKey->titleCache;
830
	 }
831
	 if(is_array($identificationKey->sources)){
832
	 	// display sources
833
	 	foreach($identificationKey->sources as $source){
834
      $out .= theme("cdm_IdentifieableSource", $source);
835
	 	}
836
	 	// display annotations
837
    $out .= theme("cdm_annotations_as_footnotekeys", $identificationKey, $parentRenderPath);
838
	 }
839
	 RenderHints::popFromRenderStack();
840
	 return $out;
841
}
842

  
843
function theme_cdm_polytomousKey(&$polytomousKey){
844

  
845
	$keyStyle = "linkedStyle"; // TODO settings needed
846

  
847
	RenderHints::pushToRenderStack("polytomousKey");
848
  // key nodes in linked style
849
  $out = '<table class="polytomousKey polytomousKey_'.$keyStyle.'">';
850
  $out .= theme('cdm_polytomousKey_'.$keyStyle.'_subgraph', $polytomousKey->root);
851
  $out .= '</table>';
852
  RenderHints::popFromRenderStack();
853
  return $out;
854
}
855

  
856
function theme_cdm_polytomousKey_linkedStyle_subgraph(&$polytomousKeyNode){
857

  
858
  static $statementCountCharacter = '\'';
859

  
860
  $out = "";
861

  
862
  if(is_array($polytomousKeyNode->children)){
863

  
864
    $childCount = 0;
865

  
866
    // render edges of the current node
867
    foreach($polytomousKeyNode->children as &$child){
868
      $out .= '<tr class="childCount_' . $childCount . '">';
869

  
870
      $out .= '<td class="nodeNumber">'. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childCount++ , $statementCountCharacter)) . "</td>";
871

  
872
      $islinkToTaxonOrSubkey = isset($child->taxon->uuid) || isset($child->subkey->uuid);
873

  
874
      $out .= '<td class="edge" colspan="'. ( $islinkToTaxonOrSubkey ? '2' : '1' )  .'">';
875
      if(isset($polytomousKeyNode->question->label_l10n)){
876
        $out .= $polytomousKeyNode->question->label_l10n .  ": ";
877
      }
878
      $out .= $child->statement->label_l10n;
879

  
880
      if(!$islinkToTaxonOrSubkey){
881
      	$out .= '</td>';
882
      	// link to a PolytomousKeyNode
883
        $out .= '<td class="nodeLink">' . l($child->nodeNumber, $_REQUEST["q"], null, null, $child->uuid) . '</td>';
884
      } else {
885
	      if(isset($child->taxon->uuid)){
886
	      	// link to a taxon
887
	      	$out .= '<div class="nodeLinkToTaxon">' . theme("cdm_taxonName", $child->taxon->name, path_to_taxon($child->taxon->uuid)) . '</div>';
888
	      } else if(isset($child->subkey->uuid)){
889
	        // link to a subkey
890
	        $out .= '<div class="nodeLinkToSubkey">'
891
	         . theme('cdm_IdentificationKey', $child->subkey) . '</div>';
892
	      }
893
	      $out .= '</td>';
894
      }
895

  
896
      $out .= '</tr>';
897

  
898
    }
899

  
900
    // recurse into child nodes
901
    foreach($polytomousKeyNode->children as &$child){
902
      $out .= theme('cdm_polytomousKey_linkedStyle_subgraph', $child);
903
    }
904

  
905
  }
906
  return $out;
907
}
908

  
808 909
/**
809 910
 * Renders a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
810 911
 * @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
......
822 923
  RenderHints::pushToRenderStack('list_IdentificationKeys');
823 924
  $out = '<ul>';
824 925
  foreach ($keyList as $key){
825
    $out .= '<li>'.l($key->titleCache, path_to_key($type, $key->uuid)).'</li>';
926
    $out .= '<li>';
927
    $out .= theme('cdm_IdentificationKey', $key);
928
    $out .= '</li>';
826 929
  }
827 930
  $out .= '</ul>';
931
  $out .= theme("cdm_annotation_footnotes", RenderHints::getRenderPath());
828 932
  RenderHints::popFromRenderStack();
829 933

  
830 934
  return $out;
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){
modules/cdm_dataportal/theme/cdm_dataportal.page.theme
905 905
	return $out;
906 906
}
907 907

  
908

  
909

  
910

  
911
function theme_cdm_polytomousKey_page($polytomousKey){
912

  
913
  drupal_set_title($polytomousKey->titleCache);
914

  
915
  $out = theme("cdm_IdentificationKey", $polytomousKey, false);
916

  
917
  // key nodes in linked style
918
  $out .= theme('cdm_polytomousKey', $polytomousKey);
919

  
920
  return $out;
921
}
922

  
908 923
/**
909 924
 * Allows theming of the taxon page tabs
910 925
 *
themes/diptera/template.php
7 7
  $glue = '';
8 8
  $sortOutArray = false;
9 9
  $enclosingHtml = 'ul';
10
  
11
  
10

  
11

  
12 12
   RenderHints::pushToRenderStack('cdm_descriptionElements');
13
    
14
  
13

  
14

  
15 15
  // only for diptera
16 16
  if(isset($descriptionElements[0]) && $descriptionElements[0]->feature->uuid == UUID_CITATION ) {
17 17
    foreach($descriptionElements as $element){
18 18
      $tokens = split(":", $element->multilanguageText_L10n->text);
19 19
      if(count($tokens) == 2){
20
        // token[0]: taxon name; token[1]: note; 
20
        // token[0]: taxon name; token[1]: note;
21 21
        $element->multilanguageText_L10n->text = $tokens[1] . ' [<span class="name">' . $tokens[0] . '</span>]';
22 22
      }
23 23
      if(isset($element->citation->datePublished->start)){
......
30 30
    $descriptionElements = $elementMap;
31 31
  }
32 32
  // ---
33
  
33

  
34 34
  foreach($descriptionElements as $element){
35 35
    if($element->class == 'TextData'){
36 36
      $outArray[] = theme('cdm_descriptionElementTextData', $element);
......
53 53

  
54 54
/**
55 55
 * Allows theaming of the taxon page tabs
56
 * 
56
 *
57 57
 * @param $tabname
58 58
 * @return unknown_type
59 59
 */
60 60
function diptera_cdm_taxonpage_tab($tabname){
61 61
  switch($tabname){
62 62
    case 'Synonymy' : return t('Nomenclature'); break;
63
    default : return t($tabname); 
63
    default : return t($tabname);
64 64
  }
65 65
}
66 66

  
......
73 73

  
74 74

  
75 75
function diptera_get_partDefinition($nameType){
76
  
76

  
77 77
  if($nameType == 'ZoologicalName'){
78 78
    return array(
79 79
        'namePart' => array(
......
99 99
}
100 100

  
101 101
function diptera_get_nameRenderTemplate($renderPath){
102
  
102

  
103 103
  switch ($renderPath){
104
    case 'taxon_page_title': 
104
    case 'taxon_page_title':
105 105
      $template = array(
106 106
          'namePart' => array('#uri'=>true),
107 107
        );
108 108
      break;
109 109
    case  'acceptedFor':
110
    case 'list_of_taxa': 
110
    case 'list_of_taxa':
111
    case 'polytomousKey':
111 112
      $template = array(
112 113
        'namePart' => array('#uri'=>true),
113 114
        'referencePart' => array('#uri'=>true),
114 115
      );
115 116
      break;
116
    case 'typedesignations': 
117
    case 'typedesignations':
117 118
      $template = array(
118 119
        'namePart' => array('#uri'=>true),
119 120
        'referencePart' => array('#uri'=>true)
......
121 122
      break;
122 123
    case 'taxon_page_synonymy':
123 124
    case 'related_taxon':
124
    default: 
125
    default:
125 126
      $template = array(
126 127
        'namePart' => array('#uri'=>true),
127 128
        'referencePart' => array('#uri'=>true),
themes/garland_cichorieae/template.php
69 69
 }
70 70
 */
71 71
function garland_cichorieae_cdm_descriptionElementTextData($element, $asListElement, $feature_uuid){
72
	
72

  
73 73
	$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
74 74
	$sourceRefs = '';
75 75
	$result = array();
......
77 77
	$res_date;
78 78
	$no_links = false;
79 79
	$default_theme = variable_get('theme_default', 'garland_cichorieae');
80
	
80

  
81 81
	if (($default_theme == 'flora_malesiana' || $default_theme == 'flore_afrique_centrale')
82 82
	    && $element->feature->titleCache == 'Citation'){
83
		$asListElement = true;	
83
		$asListElement = true;
84 84
	}elseif ($element->feature->uuid == UUID_CHROMOSOMES_NUMBERS){
85 85
	   	$asListElement = true;
86 86
	}else{
......
224 224
*/
225 225
	// add annotations as footnote key
226 226
	//$out .= theme('cdm_annotations_as_footnotekeys', $element); move above
227
    
227

  
228 228
	return $out;
229 229
}
230 230

  
......
493 493

  
494 494
	switch($renderPath) {
495 495
		case 'taxon_page_title':
496
		case 'polytomousKey':
496 497
			$template = array(
497 498
            'namePart' => array('#uri'=>true)
498 499
			);
themes/garland_cichorieae/theme-settings.php
1 1
<?php
2

  
2
/**
3
 * see http://drupal.org/node/177868
4
 */
3 5
/**
4 6
* Implementation of THEMEHOOK_settings() function.
5 7
*
......
10 12
*/
11 13
function phptemplate_settings($saved_settings) {
12 14

  
15
	$key = sub_theme();
13 16

  
14 17
	$defaults = array(
15 18
	    'default_banner_right' => 1,
......
22 25
  if ($file = file_check_upload('banner_right_upload')) {
23 26
    if ($info = image_get_info($file->filepath)) {
24 27
      $parts = pathinfo($file->filename);
25
      //$filename = ($key) ? str_replace('/', '_', $key) .'_logo.'. $parts['extension'] : 'logo.'. $parts['extension'];
26
      $filename = 'banner_right.'. $parts['extension'];
28
      $filename = ($key) ? str_replace('/', '_', $key) .'_banner_right.'. $parts['extension'] : '_banner_right.'. $parts['extension'];
27 29

  
28 30
      if ($file = file_save_upload('banner_right_upload', $filename, 1)) {
29 31
        $_POST['default_banner_right'] = 0;
30 32
        $_POST['banner_right_path'] = $file->filepath;
31
        //$_POST['toggle_banner_right'] = 1;
33
        $form["#after_build"][] = "banner_right_after_build";
32 34
      }
33 35
    }
34 36
    else {
......
36 38
    }
37 39
  }
38 40

  
39
	$form['default_banner_right'] = array(
40
      '#type' => 'checkbox',
41
      '#title' => t('Use the right default header image'),
42
      '#default_value' => $settings['default_banner_right'],
43
      '#tree' => FALSE,
44
      '#description' => t('Check here if you want the theme to use the right header image supplied with it.')
45
	 );
46

  
47
	$form['banner_right_path'] = array(
48
	  '#type' => 'textfield',
49
	  '#title' => t('Right banner image path'),
50
	  '#default_value' => $settings['banner_right_path'],
51
	  );
52

  
53
	$form['banner_right_upload'] = array(
54
	  '#type' => 'file',
55
	  '#title' => t('Upload new right banner image'),
56
	  );
41
  if (true || $file) {
42
		$form['default_banner_right'] = array(
43
	      '#type' => 'checkbox',
44
	      '#title' => t('Use the right default header image'),
45
	      '#default_value' => $settings['default_banner_right'],
46
	      '#tree' => FALSE,
47
	      '#description' => t('Check here if you want the theme to use the right header image supplied with it.')
48
		 );
49

  
50
		$form['banner_right_path'] = array(
51
		  '#type' => 'textfield',
52
		  '#title' => t('Right banner image path'),
53
		  '#default_value' => $settings['banner_right_path'],
54
		  '#maxlength' => 255
55
		  );
56

  
57
		$form['banner_right_upload'] = array(
58
		  '#type' => 'file',
59
		  '#title' => t('Upload new right banner image'),
60
		  );
61
  }
62

  
63
  return $form;
64
}
65

  
57 66

  
67
function banner_right_after_build(&$form, &$form_values) {
68
  $form["#post"]["banner_right_path"] = $_POST['banner_right_path'];
58 69
  return $form;
59
}
70
}
71

  
72

  
themes/palmweb_2/template.php
266 266
      case 'list_of_taxa':
267 267
      case 'taxon_page_synonymy':
268 268
      case 'related_taxon':
269
      case 'polytomousKey':
269 270
      case '#DEFAULT':
270 271
        $template = array(
271 272
          'namePart' => array('#uri'=>true),

Also available in: Unified diff