1 |
08ea5e99
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
// $Id: template.php,v 1.4.2.1 2007/04/18 03:38:59 drumm Exp $
|
3 |
|
|
|
4 |
|
|
/**
|
5 |
|
|
* Sets the body-tag class attribute.
|
6 |
|
|
*
|
7 |
|
|
* Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
|
8 |
|
|
*/
|
9 |
|
|
function phptemplate_body_class($sidebar_left, $sidebar_right) {
|
10 |
|
|
if ($sidebar_left != '' && $sidebar_right != '') {
|
11 |
|
|
$class = 'sidebars';
|
12 |
|
|
}
|
13 |
|
|
else {
|
14 |
|
|
if ($sidebar_left != '') {
|
15 |
|
|
$class = 'sidebar-left';
|
16 |
|
|
}
|
17 |
|
|
if ($sidebar_right != '') {
|
18 |
|
|
$class = 'sidebar-right';
|
19 |
|
|
}
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
if (isset($class)) {
|
23 |
|
|
print ' class="'. $class .'"';
|
24 |
|
|
}
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
/**
|
28 |
|
|
* Return a themed breadcrumb trail.
|
29 |
|
|
*
|
30 |
|
|
* @param $breadcrumb
|
31 |
|
|
* An array containing the breadcrumb links.
|
32 |
|
|
* @return a string containing the breadcrumb output.
|
33 |
|
|
*/
|
34 |
|
|
function phptemplate_breadcrumb($breadcrumb) {
|
35 |
|
|
if (!empty($breadcrumb)) {
|
36 |
|
|
return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
|
37 |
|
|
}
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
/**
|
41 |
|
|
* Allow themable wrapping of all comments.
|
42 |
|
|
*/
|
43 |
|
|
function phptemplate_comment_wrapper($content, $type = null) {
|
44 |
|
|
static $node_type;
|
45 |
|
|
if (isset($type)) $node_type = $type;
|
46 |
|
|
|
47 |
|
|
if (!$content || $node_type == 'forum') {
|
48 |
|
|
return '<div id="comments">'. $content . '</div>';
|
49 |
|
|
}
|
50 |
|
|
else {
|
51 |
|
|
return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
|
52 |
|
|
}
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
/**
|
56 |
|
|
* Override or insert PHPTemplate variables into the templates.
|
57 |
|
|
*/
|
58 |
|
|
function _phptemplate_variables($hook, $vars) {
|
59 |
|
|
if ($hook == 'page') {
|
60 |
|
|
|
61 |
|
|
if ($secondary = menu_secondary_local_tasks()) {
|
62 |
|
|
$output = '<span class="clear"></span>';
|
63 |
|
|
$output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
|
64 |
|
|
$vars['tabs2'] = $output;
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
// Hook into color.module
|
68 |
|
|
if (module_exists('color')) {
|
69 |
|
|
_color_page_alter($vars);
|
70 |
|
|
}
|
71 |
|
|
return $vars;
|
72 |
|
|
}
|
73 |
|
|
return array();
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
/**
|
77 |
|
|
* Returns the rendered local tasks. The default implementation renders
|
78 |
|
|
* them as tabs.
|
79 |
|
|
*
|
80 |
|
|
* @ingroup themeable
|
81 |
|
|
*/
|
82 |
|
|
function phptemplate_menu_local_tasks() {
|
83 |
|
|
$output = '';
|
84 |
|
|
|
85 |
|
|
if ($primary = menu_primary_local_tasks()) {
|
86 |
|
|
$output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
return $output;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
/**
|
93 |
|
|
* This function sort an array of description elements where all the elements
|
94 |
|
|
* are of type UUID_CITATION. The sorting is done based at first on the title
|
95 |
|
|
* cache of the author and second of the date of the publication.
|
96 |
|
|
* @param $x An element of the array
|
97 |
|
|
* @param $y An element of the array
|
98 |
|
|
* @return array The sortered description elements array
|
99 |
|
|
*/
|
100 |
|
|
function compare_citations($x, $y)
|
101 |
|
|
{
|
102 |
1b04a204
|
Andreas Kohlbecker
|
|
103 |
5f5e44b2
|
Andreas Kohlbecker
|
if( !$x->sources[0]->citation->uuid){// && !$y->sources[0]->citation->uuid){
|
104 |
|
|
$res = -1;
|
105 |
|
|
//var_dump($y->sources[0]->citation->uuid);
|
106 |
|
|
}elseif(!$y->sources[0]->citation->uuid){
|
107 |
|
|
$res = 1;
|
108 |
|
|
//var_dump($x->sources[0]->citation->uuid);
|
109 |
|
|
}
|
110 |
|
|
else{
|
111 |
1b04a204
|
Andreas Kohlbecker
|
|
112 |
|
|
|
113 |
08ea5e99
|
Andreas Kohlbecker
|
$author_team_x = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $x->sources[0]->citation->uuid);
|
114 |
|
|
$author_team_y = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $y->sources[0]->citation->uuid);
|
115 |
|
|
|
116 |
5f5e44b2
|
Andreas Kohlbecker
|
//same author, and different year
|
117 |
|
|
if($author_team_x->titleCache == $author_team_y->titleCache){
|
118 |
|
|
$x_year = substr(
|
119 |
|
|
$x->sources[0]->citation->datePublished->start,
|
120 |
|
|
0,
|
121 |
|
|
strpos($x->sources[0]->citation->datePublished->start,'-'));
|
122 |
|
|
$y_year = substr(
|
123 |
|
|
$y->sources[0]->citation->datePublished->start,
|
124 |
|
|
0,
|
125 |
|
|
strpos($y->sources[0]->citation->datePublished->start,'-'));
|
126 |
|
|
if ($x_year < $y_year){//the year of the first publication is smaller
|
127 |
|
|
$res = -1;
|
128 |
|
|
}
|
129 |
|
|
else if($x_year == $y_year){ //if same year check the page
|
130 |
|
|
$x_page = $x->sources[0]->citationMicroReference;
|
131 |
|
|
$y_page = $y->sources[0]->citationMicroReference;
|
132 |
|
|
if($x_page < $y_page){
|
133 |
|
|
$res = -1;
|
134 |
|
|
}
|
135 |
|
|
else{
|
136 |
|
|
$res = 1;
|
137 |
|
|
}
|
138 |
|
|
}else
|
139 |
|
|
$res = 1;
|
140 |
|
|
}
|
141 |
|
|
//different author and the first one is alphabetically smaller
|
142 |
1ce9afb7
|
Patric Plitzner
|
//else if($x->sources[0]->citation->authorship->teamMembers[0]->lastname <
|
143 |
|
|
//$y->sources[0]->citation->authorship->teamMembers[0]->lastname){
|
144 |
5f5e44b2
|
Andreas Kohlbecker
|
else if ($author_team_x->titleCache < $author_team_y->titleCache) {
|
145 |
|
|
$res = -1;
|
146 |
|
|
}
|
147 |
|
|
//different author and the second one is alphabetically smaller
|
148 |
|
|
else{
|
149 |
|
|
$res = 1;
|
150 |
|
|
}
|
151 |
1b04a204
|
Andreas Kohlbecker
|
|
152 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
153 |
5f5e44b2
|
Andreas Kohlbecker
|
//var_dump($res);
|
154 |
|
|
//var_dump(' ============ ');
|
155 |
|
|
return $res;
|
156 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
function garland_diptera_cdm_descriptionElements($descriptionElements){
|
160 |
|
|
|
161 |
|
|
$outArray = array();
|
162 |
|
|
$glue = '';
|
163 |
|
|
$sortOutArray = false;
|
164 |
|
|
$enclosingHtml = 'ul';
|
165 |
1b04a204
|
Andreas Kohlbecker
|
|
166 |
5f5e44b2
|
Andreas Kohlbecker
|
$citations = array();
|
167 |
08ea5e99
|
Andreas Kohlbecker
|
|
168 |
|
|
// only for diptera
|
169 |
|
|
if(isset($descriptionElements[0]) && $descriptionElements[0]->feature->uuid == UUID_CITATION ) {
|
170 |
|
|
foreach($descriptionElements as $element){
|
171 |
|
|
$tokens = split(":", $element->multilanguageText_L10n->text);
|
172 |
|
|
if(count($tokens) == 2){
|
173 |
1b04a204
|
Andreas Kohlbecker
|
// token[0]: taxon name; token[1]: note;
|
174 |
08ea5e99
|
Andreas Kohlbecker
|
$element->multilanguageText_L10n->text = $tokens[1] . ' [<span class="name">' . $tokens[0] . '</span>]';
|
175 |
|
|
}
|
176 |
|
|
if(isset($element->citation->datePublished->start)){
|
177 |
|
|
$elementMap[partialToYear($element->citation->datePublished->start)] = $element;
|
178 |
|
|
} else {
|
179 |
|
|
$elementMap[] = $element;
|
180 |
|
|
}
|
181 |
|
|
}
|
182 |
|
|
$success = ksort($elementMap);
|
183 |
|
|
$descriptionElements = $elementMap;
|
184 |
|
|
}
|
185 |
|
|
// ---
|
186 |
5f5e44b2
|
Andreas Kohlbecker
|
usort($descriptionElements, 'compare_citations');
|
187 |
08ea5e99
|
Andreas Kohlbecker
|
foreach($descriptionElements as $element){
|
188 |
|
|
if($element->class == 'TextData'){
|
189 |
|
|
$asListElement = true;
|
190 |
|
|
$outArray[] = theme('cdm_descriptionElementTextData', $element, $asListElement);
|
191 |
|
|
}else if($element->class == 'Distribution'){
|
192 |
|
|
if( !array_search($element->area->representation_L10n, $outArray)){
|
193 |
|
|
$outArray[] = $element->area->representation_L10n;
|
194 |
|
|
$glue = ', ';
|
195 |
|
|
$sortOutArray = true;
|
196 |
|
|
$enclosingHtml = 'p';
|
197 |
|
|
}
|
198 |
|
|
}else{
|
199 |
|
|
$outArray[] = '<li>No method for rendering unknown description class: '.$element->classType.'</li>';
|
200 |
|
|
}
|
201 |
|
|
}
|
202 |
|
|
|
203 |
c367b0ab
|
Andreas Kohlbecker
|
$feature = NULL;
|
204 |
|
|
// FIXME the below line was plain wrong before refactoring from theme to compose function
|
205 |
aa26f9f0
|
Andreas Kohlbecker
|
// it was like theme('compose_feature_block_elements', $outArray, $feature, $glue, $sortOutArray, $enclosingHtml);
|
206 |
c367b0ab
|
Andreas Kohlbecker
|
// which could never have worked
|
207 |
aa26f9f0
|
Andreas Kohlbecker
|
return compose_feature_block_elements($outArray, $feature, $glue, $sortOutArray, $enclosingHtml);
|
208 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
209 |
|
|
|
210 |
|
|
/**
|
211 |
|
|
* Allows theaming of the taxon page tabs
|
212 |
1b04a204
|
Andreas Kohlbecker
|
*
|
213 |
08ea5e99
|
Andreas Kohlbecker
|
* @param $tabname
|
214 |
|
|
* @return unknown_type
|
215 |
|
|
*/
|
216 |
|
|
function garland_diptera_cdm_taxonpage_tab($tabname){
|
217 |
|
|
switch($tabname){
|
218 |
|
|
case 'Synonymy' : return t('Nomenclature'); break;
|
219 |
1b04a204
|
Andreas Kohlbecker
|
default : return t($tabname);
|
220 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
function garland_diptera_cdm_feature_name($feature_name){
|
224 |
|
|
switch($feature_name){
|
225 |
|
|
case "Citation": return t("Citations");
|
226 |
5f5e44b2
|
Andreas Kohlbecker
|
case 'Has orthographic variant': return t("Misspellings");
|
227 |
08ea5e99
|
Andreas Kohlbecker
|
default: return t(ucfirst($feature_name));
|
228 |
|
|
}
|
229 |
|
|
}
|
230 |
|
|
|
231 |
1b04a204
|
Andreas Kohlbecker
|
function garland_diptera_cdm_OriginalSource($descriptionElementSource, $doLink = TRUE){
|
232 |
08ea5e99
|
Andreas Kohlbecker
|
|
233 |
|
|
//ev. delegate to theme_cdm_ReferencedEntityBase
|
234 |
|
|
$out = '';
|
235 |
|
|
if($descriptionElementSource->citation){
|
236 |
|
|
$datePublished = $descriptionElementSource->citation->datePublished;
|
237 |
|
|
if (strlen($datePublished->start) >0){
|
238 |
|
|
$year=substr($datePublished->start,0,strpos($datePublished->start,'-'));
|
239 |
|
|
}
|
240 |
|
|
|
241 |
|
|
$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $descriptionElementSource->citation->uuid);
|
242 |
|
|
$author_team_titlecache = $author_team->titleCache;
|
243 |
|
|
if (strlen($year)>0){
|
244 |
|
|
$reference = $author_team_titlecache.' '. $year;
|
245 |
|
|
}else {
|
246 |
|
|
$reference = $author_team_titlecache ;
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
if($doLink){
|
250 |
|
|
$out = l('<span class="reference">'.$reference.'</span>'
|
251 |
|
|
, path_to_reference($descriptionElementSource->citation->uuid)
|
252 |
|
|
, array("class"=>"reference")
|
253 |
|
|
, NULL, NULL, FALSE ,TRUE);
|
254 |
|
|
} else {
|
255 |
|
|
$out = $reference;
|
256 |
|
|
}
|
257 |
|
|
if($descriptionElementSource->citationMicroReference){
|
258 |
|
|
$out .= ': '. $descriptionElementSource->citationMicroReference;
|
259 |
|
|
}
|
260 |
|
|
}
|
261 |
|
|
return $out;
|
262 |
|
|
}
|