Revision c367b0ab
Added by Andreas Kohlbecker over 9 years ago
7.x/themes/garland_cichorieae/template.php | ||
---|---|---|
18 | 18 |
$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text); |
19 | 19 |
} |
20 | 20 |
$sourceRefs = ''; |
21 |
$do_links = TRUE; |
|
21 |
|
|
22 |
// --------------------------------------------------------------------------- |
|
23 |
// CUSTOM CODE (1) the below neds to become configurable in the settings |
|
22 | 24 |
$default_theme = variable_get('theme_default', 'garland_cichorieae'); |
23 | 25 |
|
24 | 26 |
if (($default_theme == 'flora_malesiana' || $default_theme == 'flore_afrique_centrale' || $default_theme == 'flore_gabon') && $element->feature->titleCache == 'Citation') { |
... | ... | |
32 | 34 |
} |
33 | 35 |
|
34 | 36 |
// Printing annotations footnotes. |
35 |
$annotation_fkeys = theme('cdm_annotations_as_footnotekeys', array( |
|
36 |
'cdmBase_list' => $element, |
|
37 |
'footnote_list_key' => $feature_uuid, |
|
38 |
)); |
|
37 |
$annotation_fkeys = theme('cdm_annotations_as_footnotekeys', |
|
38 |
array( |
|
39 |
'cdmBase_list' => $element, |
|
40 |
'footnote_list_key' => $feature_uuid, |
|
41 |
) |
|
42 |
); |
|
39 | 43 |
|
40 |
if ($feature_uuid == UUID_NAME_USAGE || $feature_uuid == UUID_CHROMOSOMES) { |
|
41 |
$do_links = FALSE; |
|
42 |
} |
|
44 |
// END CUSTOM CODE (1) |
|
45 |
// --------------------------------------------------------------------------- |
|
43 | 46 |
|
44 | 47 |
if (is_array($element->sources)) { |
45 | 48 |
foreach ($element->sources as $source) { |
49 |
// --------------------------------------------------------------------------- |
|
50 |
// CUSTOM CODE (2) |
|
46 | 51 |
// Initialize some variables. |
47 |
if ($feature_uuid == UUID_NAME_USAGE) {
|
|
52 |
if ($feature_uuid == UUID_CITATION) {
|
|
48 | 53 |
$referenceCitation = cdm_ws_get( |
49 | 54 |
CDM_WS_NOMENCLATURAL_REFERENCE_CITATION, |
50 | 55 |
array($source->citation->uuid), |
... | ... | |
52 | 57 |
)); |
53 | 58 |
$referenceCitation = $referenceCitation->String; |
54 | 59 |
} |
60 |
// END CUSTOM CODE (2) |
|
61 |
// --------------------------------------------------------------------------- |
|
55 | 62 |
else { |
56 | 63 |
$referenceCitation = theme('cdm_OriginalSource', array( |
57 | 64 |
'source' => $source, |
58 |
'doLink' => $do_links,
|
|
65 |
'doLink' => ($feature_uuid != UUID_CITATION && $feature_uuid != UUID_CHROMOSOMES), // CUSTOM CODE (3): always show links exept for NAME_USAGE, CHROMOSOMES
|
|
59 | 66 |
)); |
60 | 67 |
} |
61 | 68 |
if ($description && strlen($description) > 0 && $referenceCitation) { |
... | ... | |
64 | 71 |
elseif ($referenceCitation) { |
65 | 72 |
$sourceRefs = $referenceCitation; |
66 | 73 |
} |
67 |
// Generate the output. |
|
74 |
|
|
68 | 75 |
if (strlen($sourceRefs) > 0) { |
69 | 76 |
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>'; |
70 | 77 |
} |
78 |
// ---------------------------------------------------------------------------- |
|
79 |
// CITATION special cases - needs to go into core code |
|
71 | 80 |
$name_used_in_source_link_to_show = ''; |
72 |
if (isset($source->nameUsedInSource->uuid) && ($feature_uuid != UUID_NAME_USAGE)) { |
|
81 |
if (isset($source->nameUsedInSource->uuid) && ($feature_uuid != UUID_CITATION)) { |
|
82 |
// It is a DescriptionElementSource && !CITATION |
|
73 | 83 |
// Do a link to name page. |
74 |
$name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache, path_to_name($source->nameUsedInSource->uuid), array(), NULL, NULL, FALSE, TRUE); |
|
84 |
$name_used_in_source_link_to_show = l( |
|
85 |
$source->nameUsedInSource->titleCache, |
|
86 |
path_to_name($source->nameUsedInSource->uuid), |
|
87 |
array( |
|
88 |
'attributes' => array(), |
|
89 |
'absolute' => TRUE, |
|
90 |
'html' => TRUE) |
|
91 |
); |
|
75 | 92 |
} |
76 |
elseif (isset($source->nameUsedInSource->uuid) && ($feature_uuid == UUID_NAME_USAGE)) { |
|
77 |
// Do not do link for NAME USAGE feature. |
|
93 |
else if (isset($source->nameUsedInSource->uuid) && ($feature_uuid == UUID_CITATION)) { |
|
94 |
// It is a DescriptionElementSource && CITATION |
|
95 |
// Do not do link for CITATION feature. |
|
78 | 96 |
$name_used_in_source_link_to_show = $source->nameUsedInSource->titleCache; |
79 | 97 |
} |
80 |
elseif (isset($source->nameUsedInSource->originalNameString) && strlen($source->nameUsedInSource->originalNameString) > 0) { |
|
98 |
elseif (isset($source->nameUsedInSource->originalNameString) |
|
99 |
&& strlen($source->nameUsedInSource->originalNameString) > 0) { |
|
100 |
// It is NOT a DescriptionElementSource! |
|
101 |
// ReferencedEntityBase.originalNameString |
|
81 | 102 |
// Show a text without link. |
82 | 103 |
$name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString; |
83 | 104 |
} |
105 |
// ---------------------------------------------------------------------------- |
|
84 | 106 |
|
85 |
if ($asListElement && ($feature_uuid == UUID_NAME_USAGE)) {
|
|
107 |
if ($asListElement && ($feature_uuid == UUID_CITATION)) {
|
|
86 | 108 |
$out = '<li class="descriptionText">' . $name_used_in_source_link_to_show; |
87 |
// Adding ":" if necesary. |
|
109 |
// Adding ":" if necessary.
|
|
88 | 110 |
if (!empty($name_used_in_source_link_to_show) && (!empty($description) || !empty($sourceRefs))) { |
89 | 111 |
$out .= ': '; |
90 | 112 |
} |
91 | 113 |
|
92 |
$out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array( |
|
93 |
'cdmBase_list' => $element, |
|
94 |
'footnote_list_key' => $feature_uuid, |
|
95 |
)) . $annotation_fkeys . '</li>'; |
|
114 |
$out .= $description . $sourceRefs |
|
115 |
// THIS IS NONSENSE, should be already in $annotation_fkeys: |
|
116 |
// . theme('cdm_annotations_as_footnotekeys', |
|
117 |
// array( |
|
118 |
// 'cdmBase_list' => $element, |
|
119 |
// 'footnote_list_key' => $feature_uuid, |
|
120 |
// ) |
|
121 |
// ) |
|
122 |
. $annotation_fkeys . '</li>'; |
|
96 | 123 |
} |
97 | 124 |
elseif ($asListElement) { |
125 |
// this for sure only accounts to UUID_CHROMOSOME and UUID_CHROMOSOMES_NUMBERS |
|
98 | 126 |
|
99 | 127 |
$out = '<li class="descriptionText DescriptionElement">'; |
128 |
// displayed like: Cerastium fontanum Baumg.: in Fl. Ceylon: 60. 1996 |
|
100 | 129 |
// Adding ":" if necessary. |
101 | 130 |
if (!empty($name_used_in_source_link_to_show)) { |
102 | 131 |
if ( (!empty($description)|| !empty($sourceRefs)) && $feature_uuid != UUID_CHROMOSOMES_NUMBERS) { |
... | ... | |
106 | 135 |
} |
107 | 136 |
} |
108 | 137 |
|
109 |
$out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array( |
|
110 |
'cdmBase_list' => $element, |
|
111 |
'footnote_list_key' => $feature_uuid, |
|
112 |
)) . $annotation_fkeys . '</li>'; |
|
138 |
$out .= $description . $sourceRefs |
|
139 |
// THIS IS NONSENSE, should be already in $annotation_fkeys: |
|
140 |
// . theme('cdm_annotations_as_footnotekeys', array( |
|
141 |
// 'cdmBase_list' => $element, |
|
142 |
// 'footnote_list_key' => $feature_uuid, |
|
143 |
// )) |
|
144 |
. $annotation_fkeys . '</li>'; |
|
113 | 145 |
// Special handling for flora malesiana. |
114 | 146 |
// TODO: possible better way to implement this case? |
115 | 147 |
} |
... | ... | |
117 | 149 |
if (isset($name_used_in_source_link_to_show)) { |
118 | 150 |
$name_used_in_source_link_to_show = ' (name in source: ' . $name_used_in_source_link_to_show . ')'; |
119 | 151 |
} |
120 |
if (!isset($description)) { |
|
121 |
$description = ''; |
|
122 |
} |
|
123 |
if (!isset($sourceRefs)) { |
|
124 |
$sourceRefs = ''; |
|
125 |
} |
|
126 |
if (!isset($name_used_in_source_link_to_show)) { |
|
127 |
$name_used_in_source_link_to_show = ''; |
|
128 |
} |
|
129 |
if (!isset($annotation_fkeys)) { |
|
130 |
$annotation_fkeys = ''; |
|
131 |
} |
|
132 | 152 |
$out = '<span class="' . html_class_attribute_ref($element) . '"> ' . $description . $sourceRefs . $name_used_in_source_link_to_show . $annotation_fkeys . '</span>'; |
133 | 153 |
} |
134 | 154 |
} |
... | ... | |
139 | 159 |
$out = '<span class="' . html_class_attribute_ref($element) . '"> ' . $description . $annotation_fkeys . '</span>'; |
140 | 160 |
} |
141 | 161 |
|
142 |
/* Dead code: |
|
143 |
* |
|
144 |
* Disabled code; can this be removed? |
|
145 |
if ($feature_uuid == UUID_NAME_USAGE){ foreach($element->sources as |
|
146 |
$source){ $referenceCitation = |
|
147 |
cdm_ws_get(CDM_WS_NOMENCLATURAL_REFERENCE_CITATION, |
|
148 |
array($source->citation->uuid), |
|
149 |
"microReference=".urlencode($source->citationMicroReference)); |
|
150 |
$referenceCitation = $referenceCitation->String; if($description && |
|
151 |
strlen($description) > 0 && $referenceCitation ){ $sourceRefs .= ' |
|
152 |
('.$referenceCitation.')' ; }else if ($referenceCitation){ $sourceRefs = |
|
153 |
$referenceCitation; } } }else{ foreach($element->sources as $source){ |
|
154 |
$referenceCitation = theme('cdm_OriginalSource', $source, |
|
155 |
($feature_uuid == UUID_NAME_USAGE) ? FALSE : TRUE); if($description && |
|
156 |
strlen($description) > 0 && $referenceCitation ){ $sourceRefs .= ' |
|
157 |
('.$referenceCitation.')' ; }else if ($referenceCitation){ $sourceRefs = |
|
158 |
$referenceCitation; } } } if(strlen($sourceRefs) > 0){ $sourceRefs = '<span |
|
159 |
class="sources">' . $sourceRefs . '</span>'; } if |
|
160 |
($source->nameUsedInSource->uuid && ($feature_uuid != UUID_NAME_USAGE)){ |
|
161 |
//do a link to name page $name_used_in_source_link_to_show = |
|
162 |
l($source->nameUsedInSource->titleCache, |
|
163 |
path_to_name($source->nameUsedInSource->uuid), array(), NULL, NULL, FALSE |
|
164 |
,TRUE); }else if ($source->nameUsedInSource->uuid && ($feature_uuid == |
|
165 |
UUID_NAME_USAGE)){ //do not do link for NAME USAGE feature |
|
166 |
$name_used_in_source_link_to_show = $source->nameUsedInSource->titleCache; |
|
167 |
}else if (strlen($source->nameUsedInSource->originalNameString) > 0){ |
|
168 |
//show a text without link $name_used_in_source_link_to_show = |
|
169 |
$source->nameUsedInSource->originalNameString; } if($asListElement && |
|
170 |
($feature_uuid == UUID_NAME_USAGE)){ $out = '<li class="descriptionText">' |
|
171 |
. $name_used_in_source_link_to_show; //adding ":" if necesary if |
|
172 |
($name_used_in_source_link_to_show && ($description || $sourceRefs)){ $out |
|
173 |
.= ': '; } $out .= $description . $sourceRefs . |
|
174 |
theme('cdm_annotations_as_footnotekeys', $element) . '</li>'; }else if |
|
175 |
($asListElement){ $out = '<li class="descriptionText">' . |
|
176 |
$name_used_in_source_link_to_show; //adding ":" if necesary if |
|
177 |
($name_used_in_source_link_to_show && ($description || $sourceRefs)){ $out |
|
178 |
.= ': '; } $out .= $description . $sourceRefs . |
|
179 |
theme('cdm_annotations_as_footnotekeys', $element) . '</li>'; //special |
|
180 |
handling for flora malesiana TODO: possible better way to implement this |
|
181 |
case? }else{ if ($name_used_in_source_link_to_show){ |
|
182 |
$name_used_in_source_link_to_show = ' (name in source: '. |
|
183 |
$name_used_in_source_link_to_show . ')'; } $out = $description . |
|
184 |
$sourceRefs . $name_used_in_source_link_to_show; $out .= |
|
185 |
theme('cdm_annotations_as_footnotekeys', $element); } |
|
186 |
*/ |
|
187 | 162 |
// Add annotations as footnote key. |
188 |
// $out .= theme('cdm_annotations_as_footnotekeys', $element); move above. |
|
189 |
return $out; |
|
190 |
} |
|
191 |
|
|
192 |
// NO LONGER NEEDED - since term representation is changed now in the cdm for |
|
193 |
// the cichorieae |
|
194 |
// ====> delete |
|
195 |
// /** |
|
196 |
// * @overrides theme_cdm_taggedtext2html in order to replace t.infr and |
|
197 |
// t.infgen. with '[unranked]' |
|
198 |
// */ |
|
199 |
// function garland_cichorieae_cdm_taggedtext2html(array &$taggedtxt, $tag = |
|
200 |
// 'span', $glue = ' ', $skiptags = array()){ |
|
201 |
// $out = ''; |
|
202 |
// $i = 0; |
|
203 |
// foreach($taggedtxt as $tt){ |
|
204 |
// if(!in_array($tt->type, $skiptags) && strlen($tt->text) > 0){ |
|
205 |
// $out .= (strlen($out) > 0 && ++$i < count($taggedtxt)? $glue : '').'<'.$tag.' |
|
206 |
// class="'.$tt->type.'">'; |
|
207 |
// if($tt->type == "rank" && ($tt->text == "t.infr." || $tt->text == |
|
208 |
// "t.infgen.")){ |
|
209 |
// $out .= t('[unranked]'); |
|
210 |
// }else{ |
|
211 |
// $out .= t($tt->text); |
|
212 |
// } |
|
213 |
// $out .= '</'.$tag.'>'; |
|
214 |
// } |
|
215 |
// } |
|
216 |
// return $out; |
|
217 |
// } |
|
218 |
/** |
|
219 |
* Returns HTML for a cdm_feature_block_elements. |
|
220 |
* |
|
221 |
* @param array $variables |
|
222 |
* An associative array containing: |
|
223 |
* - elementArray: The array with CDM description elements being formatted. |
|
224 |
* - feature: The description feature container object for the |
|
225 |
* description element array. |
|
226 |
* - glue: String for joining the description elements together. |
|
227 |
* - sortArray: Boolean, TRUE if the array should be sorted before themeing. |
|
228 |
* - enclosingHTML: HTML tag, e.g. 'div', in which to wrap the description. |
|
229 |
* |
|
230 |
* @ingroup themeable |
|
231 |
*/ |
|
232 |
function garland_cichorieae_cdm_feature_block_elements($variables) { |
|
233 |
$elementArray = $variables['elementArray']; |
|
234 |
$feature = $variables['feature']; |
|
235 |
$glue = $variables['glue']; |
|
236 |
$sortArray = $variables['sortArray']; |
|
237 |
$enclosingHtml = $variables['enclosingHtml']; |
|
238 |
|
|
239 |
$enclosingHtml = 'div'; |
|
240 |
$out = '<' . $enclosingHtml . ' class="feature-block-elements" id="' . $feature->representation_L10n . '">'; |
|
241 |
|
|
242 |
if ($sortArray) { |
|
243 |
sort($elementArray); |
|
244 |
} |
|
245 |
|
|
246 |
$out .= '<span class="feature-block-element">' . join($elementArray, '<span class="feature-block-element">' . $glue . '</span>') . '</span>'; |
|
247 |
|
|
248 |
$out .= '</' . $enclosingHtml . '>'; |
|
163 |
// $out .= theme('cdm_annotations_as_footnotekeys', $element); |
|
249 | 164 |
return $out; |
250 | 165 |
} |
251 | 166 |
|
... | ... | |
276 | 191 |
} |
277 | 192 |
} |
278 | 193 |
|
279 |
/** |
|
280 |
* Allow themable wrapping of all comments. |
|
281 |
*/ |
|
282 |
/* |
|
283 |
function phptemplate_comment_wrapper($content, $type = NULL) { |
|
284 |
static $node_type; |
|
285 |
if (isset($type)) $node_type = $type; |
|
286 |
|
|
287 |
if (! $content || $node_type == 'forum') { |
|
288 |
return '<div id="comments">' . $content . '</div>'; |
|
289 |
} |
|
290 |
else { |
|
291 |
return '<div id="comments"><h2 class="comments">' . t('Comments') . '</h2>' . $content . '</div>'; |
|
292 |
} |
|
293 |
} |
|
294 |
*/ |
|
295 | 194 |
|
296 | 195 |
/** |
297 | 196 |
* Override or insert PHPTemplate variables into the templates. |
Also available in: Unified diff
refactoring the feature node blocks - 2 + adapting test suite