1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* Overrides of generic themeing functions in cdm_dataportal.theme.php.
|
5
|
*/
|
6
|
|
7
|
/**
|
8
|
* @todo Please document this function.
|
9
|
* @see http://drupal.org/node/1354
|
10
|
*/
|
11
|
function garland_cichorieae_cdm_descriptionElementTextData($variables) {
|
12
|
$element = $variables['element'];
|
13
|
$asListElement = $variables['asListElement'];
|
14
|
$feature_uuid = $variables['feature_uuid'];
|
15
|
|
16
|
$description = '';
|
17
|
if (isset($element->multilanguageText_L10n->text)) {
|
18
|
$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
19
|
}
|
20
|
$sourceRefs = '';
|
21
|
$result = array();
|
22
|
$res_author;
|
23
|
$res_date;
|
24
|
$do_links = TRUE;
|
25
|
$default_theme = variable_get('theme_default', 'garland_cichorieae');
|
26
|
|
27
|
if (($default_theme == 'flora_malesiana' || $default_theme == 'flore_afrique_centrale' || $default_theme == 'flore_gabon') && $element->feature->titleCache == 'Citation') {
|
28
|
$asListElement = TRUE;
|
29
|
}
|
30
|
elseif ($element->feature->uuid == UUID_CHROMOSOMES_NUMBERS) {
|
31
|
$asListElement = TRUE;
|
32
|
}
|
33
|
else {
|
34
|
$asListElement = FALSE;
|
35
|
}
|
36
|
|
37
|
// Printing annotations footnotes.
|
38
|
$annotation_fkeys = theme('cdm_annotations_as_footnotekeys', array(
|
39
|
'cdmBase_list' => $element,
|
40
|
'footnote_list_key' => $feature_uuid,
|
41
|
));
|
42
|
|
43
|
if ($feature_uuid == UUID_NAME_USAGE || $feature_uuid == UUID_CHROMOSOMES) {
|
44
|
$do_links = FALSE;
|
45
|
}
|
46
|
|
47
|
if (is_array($element->sources)) {
|
48
|
foreach ($element->sources as $source) {
|
49
|
// Initialize some variables.
|
50
|
if ($feature_uuid == UUID_NAME_USAGE) {
|
51
|
$referenceCitation = cdm_ws_get(
|
52
|
CDM_WS_NOMENCLATURAL_REFERENCE_CITATION,
|
53
|
array($source->citation->uuid),
|
54
|
"microReference=" . urlencode($source->citationMicroReference
|
55
|
));
|
56
|
$referenceCitation = $referenceCitation->String;
|
57
|
}
|
58
|
else {
|
59
|
$referenceCitation = theme('cdm_OriginalSource', array(
|
60
|
'source' => $source,
|
61
|
'doLink' => $do_links,
|
62
|
));
|
63
|
}
|
64
|
if ($description && strlen($description) > 0 && $referenceCitation) {
|
65
|
$sourceRefs .= ' (' . $referenceCitation . ')';
|
66
|
}
|
67
|
elseif ($referenceCitation) {
|
68
|
$sourceRefs = $referenceCitation;
|
69
|
}
|
70
|
// Generate the output.
|
71
|
if (strlen($sourceRefs) > 0) {
|
72
|
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
|
73
|
}
|
74
|
$name_used_in_source_link_to_show = '';
|
75
|
if (isset($source->nameUsedInSource->uuid) && ($feature_uuid != UUID_NAME_USAGE)) {
|
76
|
// Do a link to name page.
|
77
|
$name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache, path_to_name($source->nameUsedInSource->uuid), array(), NULL, NULL, FALSE, TRUE);
|
78
|
}
|
79
|
elseif (isset($source->nameUsedInSource->uuid) && ($feature_uuid == UUID_NAME_USAGE)) {
|
80
|
// Do not do link for NAME USAGE feature.
|
81
|
$name_used_in_source_link_to_show = $source->nameUsedInSource->titleCache;
|
82
|
}
|
83
|
elseif (isset($source->nameUsedInSource->originalNameString) && strlen($source->nameUsedInSource->originalNameString) > 0) {
|
84
|
// Show a text without link.
|
85
|
$name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
|
86
|
}
|
87
|
|
88
|
if ($asListElement && ($feature_uuid == UUID_NAME_USAGE)) {
|
89
|
$out = '<li class="descriptionText">' . $name_used_in_source_link_to_show;
|
90
|
// Adding ":" if necesary.
|
91
|
if (!empty($name_used_in_source_link_to_show) && (!empty($description) || !empty($sourceRefs))) {
|
92
|
$out .= ': ';
|
93
|
}
|
94
|
|
95
|
$out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array(
|
96
|
'cdmBase_list' => $element,
|
97
|
'footnote_list_key' => $feature_uuid,
|
98
|
)) . $annotation_fkeys . '</li>';
|
99
|
}
|
100
|
elseif ($asListElement) {
|
101
|
|
102
|
$out = '<li class="descriptionText DescriptionElement">';
|
103
|
// Adding ":" if necessary.
|
104
|
if (!empty($name_used_in_source_link_to_show)) {
|
105
|
if ( (!empty($description)|| !empty($sourceRefs)) && $feature_uuid != UUID_CHROMOSOMES_NUMBERS) {
|
106
|
$out .= $name_used_in_source_link_to_show . ': ';
|
107
|
} else {
|
108
|
$out .= $name_used_in_source_link_to_show . ' ';
|
109
|
}
|
110
|
}
|
111
|
|
112
|
$out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array(
|
113
|
'cdmBase_list' => $element,
|
114
|
'footnote_list_key' => $feature_uuid,
|
115
|
)) . $annotation_fkeys . '</li>';
|
116
|
// Special handling for flora malesiana.
|
117
|
// TODO: possible better way to implement this case?
|
118
|
}
|
119
|
else {
|
120
|
if (isset($name_used_in_source_link_to_show)) {
|
121
|
$name_used_in_source_link_to_show = ' (name in source: ' . $name_used_in_source_link_to_show . ')';
|
122
|
}
|
123
|
if (!isset($description)) {
|
124
|
$description = '';
|
125
|
}
|
126
|
if (!isset($sourceRefs)) {
|
127
|
$sourceRefs = '';
|
128
|
}
|
129
|
if (!isset($name_used_in_source_link_to_show)) {
|
130
|
$name_used_in_source_link_to_show = '';
|
131
|
}
|
132
|
if (!isset($annotation_fkeys)) {
|
133
|
$annotation_fkeys = '';
|
134
|
}
|
135
|
$out = '<span class="' . html_class_atttibute_ref($element) . '"> ' . $description . $sourceRefs . $name_used_in_source_link_to_show . $annotation_fkeys . '</span>';
|
136
|
}
|
137
|
}
|
138
|
}
|
139
|
|
140
|
// If no sources, print the description.
|
141
|
if (!isset($out)) {
|
142
|
$out = '<span class="' . html_class_atttibute_ref($element) . '"> ' . $description . $annotation_fkeys . '</span>';
|
143
|
}
|
144
|
|
145
|
/* Dead code:
|
146
|
*
|
147
|
* Disabled code; can this be removed?
|
148
|
if ($feature_uuid == UUID_NAME_USAGE){ foreach($element->sources as
|
149
|
$source){ $referenceCitation =
|
150
|
cdm_ws_get(CDM_WS_NOMENCLATURAL_REFERENCE_CITATION,
|
151
|
array($source->citation->uuid),
|
152
|
"microReference=".urlencode($source->citationMicroReference));
|
153
|
$referenceCitation = $referenceCitation->String; if($description &&
|
154
|
strlen($description) > 0 && $referenceCitation ){ $sourceRefs .= '
|
155
|
('.$referenceCitation.')' ; }else if ($referenceCitation){ $sourceRefs =
|
156
|
$referenceCitation; } } }else{ foreach($element->sources as $source){
|
157
|
$referenceCitation = theme('cdm_OriginalSource', $source,
|
158
|
($feature_uuid == UUID_NAME_USAGE) ? FALSE : TRUE); if($description &&
|
159
|
strlen($description) > 0 && $referenceCitation ){ $sourceRefs .= '
|
160
|
('.$referenceCitation.')' ; }else if ($referenceCitation){ $sourceRefs =
|
161
|
$referenceCitation; } } } if(strlen($sourceRefs) > 0){ $sourceRefs = '<span
|
162
|
class="sources">' . $sourceRefs . '</span>'; } if
|
163
|
($source->nameUsedInSource->uuid && ($feature_uuid != UUID_NAME_USAGE)){
|
164
|
//do a link to name page $name_used_in_source_link_to_show =
|
165
|
l($source->nameUsedInSource->titleCache,
|
166
|
path_to_name($source->nameUsedInSource->uuid), array(), NULL, NULL, FALSE
|
167
|
,TRUE); }else if ($source->nameUsedInSource->uuid && ($feature_uuid ==
|
168
|
UUID_NAME_USAGE)){ //do not do link for NAME USAGE feature
|
169
|
$name_used_in_source_link_to_show = $source->nameUsedInSource->titleCache;
|
170
|
}else if (strlen($source->nameUsedInSource->originalNameString) > 0){
|
171
|
//show a text without link $name_used_in_source_link_to_show =
|
172
|
$source->nameUsedInSource->originalNameString; } if($asListElement &&
|
173
|
($feature_uuid == UUID_NAME_USAGE)){ $out = '<li class="descriptionText">'
|
174
|
. $name_used_in_source_link_to_show; //adding ":" if necesary if
|
175
|
($name_used_in_source_link_to_show && ($description || $sourceRefs)){ $out
|
176
|
.= ': '; } $out .= $description . $sourceRefs .
|
177
|
theme('cdm_annotations_as_footnotekeys', $element) . '</li>'; }else if
|
178
|
($asListElement){ $out = '<li class="descriptionText">' .
|
179
|
$name_used_in_source_link_to_show; //adding ":" if necesary if
|
180
|
($name_used_in_source_link_to_show && ($description || $sourceRefs)){ $out
|
181
|
.= ': '; } $out .= $description . $sourceRefs .
|
182
|
theme('cdm_annotations_as_footnotekeys', $element) . '</li>'; //special
|
183
|
handling for flora malesiana TODO: possible better way to implement this
|
184
|
case? }else{ if ($name_used_in_source_link_to_show){
|
185
|
$name_used_in_source_link_to_show = ' (name in source: '.
|
186
|
$name_used_in_source_link_to_show . ')'; } $out = $description .
|
187
|
$sourceRefs . $name_used_in_source_link_to_show; $out .=
|
188
|
theme('cdm_annotations_as_footnotekeys', $element); }
|
189
|
*/
|
190
|
// Add annotations as footnote key.
|
191
|
// $out .= theme('cdm_annotations_as_footnotekeys', $element); move above.
|
192
|
return $out;
|
193
|
}
|
194
|
|
195
|
// NO LONGER NEEDED - since term representation is changed now in the cdm for
|
196
|
// the cichorieae
|
197
|
// ====> delete
|
198
|
// /**
|
199
|
// * @overrides theme_cdm_taggedtext2html in order to replace t.infr and
|
200
|
// t.infgen. with '[unranked]'
|
201
|
// */
|
202
|
// function garland_cichorieae_cdm_taggedtext2html(array &$taggedtxt, $tag =
|
203
|
// 'span', $glue = ' ', $skiptags = array()){
|
204
|
// $out = '';
|
205
|
// $i = 0;
|
206
|
// foreach($taggedtxt as $tt){
|
207
|
// if(!in_array($tt->type, $skiptags) && strlen($tt->text) > 0){
|
208
|
// $out .= (strlen($out) > 0 && ++$i < count($taggedtxt)? $glue : '').'<'.$tag.'
|
209
|
// class="'.$tt->type.'">';
|
210
|
// if($tt->type == "rank" && ($tt->text == "t.infr." || $tt->text ==
|
211
|
// "t.infgen.")){
|
212
|
// $out .= t('[unranked]');
|
213
|
// }else{
|
214
|
// $out .= t($tt->text);
|
215
|
// }
|
216
|
// $out .= '</'.$tag.'>';
|
217
|
// }
|
218
|
// }
|
219
|
// return $out;
|
220
|
// }
|
221
|
/**
|
222
|
* Returns HTML for a cdm_descriptionElementArray.
|
223
|
*
|
224
|
* @param array $variables
|
225
|
* An associative array containing:
|
226
|
* - elementArray: The array with CDM description elements being formatted.
|
227
|
* - feature: The description feature container object for the
|
228
|
* description element array.
|
229
|
* - glue: String for joining the description elements together.
|
230
|
* - sortArray: Boolean, TRUE if the array should be sorted before themeing.
|
231
|
* - enclosingHTML: HTML tag, e.g. 'div', in which to wrap the description.
|
232
|
*
|
233
|
* @ingroup themeable
|
234
|
*/
|
235
|
function garland_cichorieae_cdm_descriptionElementArray($variables) {
|
236
|
$elementArray = $variables['elementArray'];
|
237
|
$feature = $variables['feature'];
|
238
|
$glue = $variables['glue'];
|
239
|
$sortArray = $variables['sortArray'];
|
240
|
$enclosingHtml = $variables['enclosingHtml'];
|
241
|
|
242
|
$enclosingHtml = 'div';
|
243
|
$out = '<' . $enclosingHtml . ' class="description" id="' . $feature->representation_L10n . '">';
|
244
|
|
245
|
if ($sortArray) {
|
246
|
sort($elementArray);
|
247
|
}
|
248
|
|
249
|
$out .= join($elementArray, $glue);
|
250
|
|
251
|
$out .= '</' . $enclosingHtml . '>';
|
252
|
return $out;
|
253
|
}
|
254
|
|
255
|
/*
|
256
|
***** GARLAND OVERRIDES *****
|
257
|
*/
|
258
|
|
259
|
/**
|
260
|
* Sets the body-tag class attribute.
|
261
|
*
|
262
|
* Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
|
263
|
*/
|
264
|
function phptemplate_body_class($sidebar_left, $sidebar_right) {
|
265
|
if ($sidebar_left != '' && $sidebar_right != '') {
|
266
|
$class = 'sidebars';
|
267
|
}
|
268
|
else {
|
269
|
if ($sidebar_left != '') {
|
270
|
$class = 'sidebar-left';
|
271
|
}
|
272
|
if ($sidebar_right != '') {
|
273
|
$class = 'sidebar-right';
|
274
|
}
|
275
|
}
|
276
|
|
277
|
if (isset($class)) {
|
278
|
print ' class="' . $class . '"';
|
279
|
}
|
280
|
}
|
281
|
|
282
|
/**
|
283
|
* Allow themable wrapping of all comments.
|
284
|
*/
|
285
|
/*
|
286
|
function phptemplate_comment_wrapper($content, $type = NULL) {
|
287
|
static $node_type;
|
288
|
if (isset($type)) $node_type = $type;
|
289
|
|
290
|
if (! $content || $node_type == 'forum') {
|
291
|
return '<div id="comments">' . $content . '</div>';
|
292
|
}
|
293
|
else {
|
294
|
return '<div id="comments"><h2 class="comments">' . t('Comments') . '</h2>' . $content . '</div>';
|
295
|
}
|
296
|
}
|
297
|
*/
|
298
|
|
299
|
/**
|
300
|
* Override or insert PHPTemplate variables into the templates.
|
301
|
*/
|
302
|
function _phptemplate_variables($hook, $vars) {
|
303
|
if ($hook == 'page') {
|
304
|
|
305
|
if ($secondary = menu_secondary_local_tasks()) {
|
306
|
$output = '<span class="clear"></span>';
|
307
|
$output .= "<ul class=\"tabs secondary\">\n" . $secondary . "</ul>\n";
|
308
|
$vars['tabs2'] = $output;
|
309
|
}
|
310
|
|
311
|
// Hook into color.module
|
312
|
if (module_exists('color')) {
|
313
|
_color_page_alter($vars);
|
314
|
}
|
315
|
return $vars;
|
316
|
}
|
317
|
return array();
|
318
|
}
|
319
|
|
320
|
/**
|
321
|
* Returns HTML for the rendered local tasks.
|
322
|
*
|
323
|
* The default implementation renders them as tabs.
|
324
|
*
|
325
|
* @ingroup themeable
|
326
|
*/
|
327
|
function phptemplate_menu_local_tasks() {
|
328
|
$output = '';
|
329
|
|
330
|
if ($primary = menu_primary_local_tasks()) {
|
331
|
$output .= "<ul class=\"tabs primary\">\n" . $primary . "</ul>\n";
|
332
|
}
|
333
|
|
334
|
return $output;
|
335
|
}
|
336
|
|
337
|
/**
|
338
|
* Returns HTML for taxon list thumbnails.
|
339
|
*
|
340
|
* Theme specific mods:
|
341
|
* $captionElements = array('title', '#uri'=>t('open Image'));
|
342
|
* $mediaLinkType:
|
343
|
* "NORMAL": link to the image page or to the $alternativeMediaUri if it is
|
344
|
* defined instead of
|
345
|
* "LIGHTBOX": open the link in a light box,
|
346
|
* TODO expose those in admin section, by adding 'em to gallery_settings see
|
347
|
* http://dev.e-taxonomy.eu/trac/ticket/2494.
|
348
|
*
|
349
|
* @param array $variables
|
350
|
* An associative array containing:
|
351
|
* - taxon: The taxon object for which to theme the thumbnails.
|
352
|
*
|
353
|
* @ingroup themeable
|
354
|
*/
|
355
|
function garland_cichorieae_cdm_taxon_list_thumbnails($variables) {
|
356
|
$out = '';
|
357
|
$taxon = $variables['taxon'];
|
358
|
|
359
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
|
360
|
|
361
|
$mediaLinkType = 'NORMAL';
|
362
|
$showCaption = $gallery_settings['cdm_dataportal_show_thumbnail_captions'];
|
363
|
$captionElements = array();
|
364
|
if ($showCaption) {
|
365
|
$captionElements = array('title', '#uri' => t('open Image'));
|
366
|
}
|
367
|
|
368
|
$gallery_name = $taxon->uuid;
|
369
|
|
370
|
$galleryLinkUri = path_to_taxon($taxon->uuid, 'images');
|
371
|
|
372
|
$mediaList = $mediaList = _load_media_for_taxon($taxon);
|
373
|
|
374
|
$out .= theme('cdm_media_gallerie', array(
|
375
|
'mediaList' => $mediaList,
|
376
|
'galleryName' => $gallery_name,
|
377
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
378
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
379
|
'maxRows' => $gallery_settings['cdm_dataportal_media_maxRows'],
|
380
|
'captionElements' => $captionElements,
|
381
|
'mediaLinkType' => $mediaLinkType,
|
382
|
'alternativeMediaUri' => $galleryLinkUri,
|
383
|
'showCaption' => NULL,
|
384
|
));
|
385
|
|
386
|
return $out;
|
387
|
}
|
388
|
|
389
|
/**
|
390
|
* @todo Please document this function.
|
391
|
* @see http://drupal.org/node/1354
|
392
|
*/
|
393
|
function garland_cichorieae_cdm_feature_name($variables) {
|
394
|
$feature_name = $variables['feature_name'];
|
395
|
switch ($feature_name) {
|
396
|
case "Protologue":
|
397
|
return t("Original Publication");
|
398
|
default:
|
399
|
return ucfirst($feature_name);
|
400
|
}
|
401
|
}
|
402
|
|
403
|
/*
|
404
|
======== Special functions for subtheme handling=============
|
405
|
*/
|
406
|
|
407
|
/**
|
408
|
* @todo Please document this function.
|
409
|
* @see http://drupal.org/node/1354
|
410
|
*/
|
411
|
function sub_theme() {
|
412
|
global $user, $custom_theme;
|
413
|
|
414
|
// Only select the user selected theme if it is available in the
|
415
|
// list of enabled themes.
|
416
|
$theme = $user->theme && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'garland');
|
417
|
|
418
|
// Allow modules to override the present theme... only select custom theme
|
419
|
// if it is available in the list of installed themes.
|
420
|
$theme = $custom_theme && $themes[$custom_theme] ? $custom_theme : $theme;
|
421
|
|
422
|
return $theme;
|
423
|
}
|
424
|
|
425
|
/**
|
426
|
* Return the path to the currently selected sub theme.
|
427
|
*/
|
428
|
function path_to_sub_theme() {
|
429
|
$themes = list_themes();
|
430
|
$theme = sub_theme();
|
431
|
return dirname($themes[$theme]->filename);
|
432
|
}
|
433
|
|
434
|
/**
|
435
|
* Implements hook_preprocess_HOOK() for theme_page().
|
436
|
*
|
437
|
* Assign the css classes primary-links and secondary-links to the menus.
|
438
|
* Modify primary-links if cdm_api module exists.
|
439
|
*/
|
440
|
function garland_cichorieae_preprocess_page(&$vars) {
|
441
|
if (isset($vars['main_menu'])) {
|
442
|
/*
|
443
|
obsolete, see http://dev.e-taxonomy.eu/trac/ticket/2191
|
444
|
if(module_exists('cdm_api')){ foreach($vars['main_menu'] as $key =>
|
445
|
$menu_item){ // nb this makes each menu item you click opening a new
|
446
|
browser window..
|
447
|
$menu_item['attributes']['target']=generalizeString($menu_item['title']);
|
448
|
$main_menu[] = $menu_item; }; }else{ $main_menu = $vars['main_menu'] ; };
|
449
|
*/
|
450
|
$vars['primary_nav'] = theme('links__system_main_menu', array(
|
451
|
'links' => $vars['main_menu'], 'attributes' => array(
|
452
|
'class' => array(
|
453
|
'links', 'inline', 'main-menu', 'primary-links',
|
454
|
)),
|
455
|
'heading' => array(
|
456
|
'text' => t('Main menu'), 'level' => 'h2', 'class' => array(
|
457
|
'element-invisible',
|
458
|
))));
|
459
|
}
|
460
|
else {
|
461
|
$vars['primary_nav'] = FALSE;
|
462
|
}
|
463
|
if (isset($vars['secondary_menu'])) {
|
464
|
$vars['secondary_nav'] = theme('links__system_secondary_menu', array(
|
465
|
'links' => $vars['secondary_menu'], 'attributes' => array(
|
466
|
'class' => array(
|
467
|
'links',
|
468
|
'inline',
|
469
|
'secondary-menu',
|
470
|
'secondary-links',
|
471
|
)),
|
472
|
'heading' => array(
|
473
|
'text' => t('Secondary menu'),
|
474
|
'level' => 'h2',
|
475
|
'class' => array('element-invisible'),
|
476
|
)));
|
477
|
}
|
478
|
else {
|
479
|
$vars['secondary_nav'] = FALSE;
|
480
|
}
|
481
|
|
482
|
/*
|
483
|
Display node title as page title for the comment form.
|
484
|
Comment @WA: it would probably be better to select $uuid from node_cdm
|
485
|
table and link to cdm_dataportal/taxon/%uuid instead.
|
486
|
*/
|
487
|
if (arg(0) == 'comment' && arg(1) == 'reply') {
|
488
|
$node = $vars['page']['content']['system_main']['comment_node']['#node'];
|
489
|
$vars['title'] = l(check_plain($node->title), 'node/' . $node->nid);
|
490
|
}
|
491
|
}
|
492
|
|
493
|
/**
|
494
|
* Implements hook_preprocess_HOOK() for theme_node().
|
495
|
*
|
496
|
* Fixes file urls in nodes. In nodes, relative urls are used to include files
|
497
|
* like <img src="/files/..
|
498
|
*
|
499
|
* Portals can be installed in configurations with
|
500
|
* sub-directories however, in which case these urls need to be adjusted.
|
501
|
* Examples: mysite.org, mysite.org/myportal, mysite.org/portals/myportal.
|
502
|
*
|
503
|
* Therefore preprocess nodes and replace these urls with a the appropriate url
|
504
|
* for the current setup.
|
505
|
*
|
506
|
* @author W.Addink <w.addink@eti.uva.nl>
|
507
|
*/
|
508
|
function garland_cichorieae_preprocess_node(&$vars) {
|
509
|
$body = '';
|
510
|
// Warning: use #markup value, for which filters like php, html etc are applied!
|
511
|
if (isset($vars['content']['body'][0]['#markup'])) {
|
512
|
$body = $vars['content']['body'][0]['#markup'];
|
513
|
}
|
514
|
else {
|
515
|
$vars['fixed_body'] = '';
|
516
|
return;
|
517
|
}
|
518
|
|
519
|
$file_path = '/' . variable_get('file_public_path', conf_path() . '/files');
|
520
|
global $base_url;
|
521
|
if ($base_url == '/') {
|
522
|
drupal_set_message(t('
|
523
|
The $base_url in this portal could not be set, please set the $base_url
|
524
|
manually your Drupal settings.php file.', 'error'
|
525
|
));
|
526
|
}
|
527
|
$fixed_file_path = $base_url . $file_path;
|
528
|
$preg_file_path = preg_quote($file_path, '/');
|
529
|
$body = preg_replace('/src\s*=\s*["]\s*' . $preg_file_path . '/', 'src="' . $fixed_file_path, $body);
|
530
|
$body = preg_replace('/src\s*=\s*[\']\s*' . $preg_file_path . '/', 'src=\'' . $fixed_file_path, $body);
|
531
|
$body = preg_replace('/href\s*=\s*["]\s*' . $preg_file_path . '/', 'href="' . $fixed_file_path, $body);
|
532
|
$body = preg_replace('/href\s*=\s*[\']\s*' . $preg_file_path . '/', 'href=\'' . $fixed_file_path, $body);
|
533
|
|
534
|
$vars['fixed_body'] = $body;
|
535
|
}
|
536
|
|
537
|
/**
|
538
|
* Implements hook_form_FORM_ID_alter() for comment_form().
|
539
|
*
|
540
|
* Alter the comment form to make it look like a D5 style comment form.
|
541
|
*
|
542
|
* @author W.Addink <w.addink@eti.uva.nl>
|
543
|
*/
|
544
|
function garland_cichorieae_form_comment_form_alter(&$form, &$form_state) {
|
545
|
|
546
|
if (!isset($form['comment_preview'])) {
|
547
|
$form['header'] = array(
|
548
|
'#markup' => '<h2>' . t('Reply') . '</h2>',
|
549
|
'#weight' => -2,
|
550
|
);
|
551
|
}
|
552
|
$form['subject']['#title'] = $form['subject']['#title'] . ':';
|
553
|
$form['comment_body']['und'][0]['#title'] = $form['comment_body']['und'][0]['#title'] . ':';
|
554
|
if (isset($form['author']['_author']['#title'])) {
|
555
|
$form['author']['_author']['#title'] = $form['author']['_author']['#title'] . ':';
|
556
|
}
|
557
|
$form['actions']['submit']['#value'] = t('Post comment');
|
558
|
$form['actions']['submit']['#weight'] = 1000;
|
559
|
$form['actions']['preview']['#value'] = t('Preview comment');
|
560
|
}
|
561
|
|
562
|
/**
|
563
|
* Implements hook_preprocess_HOOK() for theme_comment().
|
564
|
*
|
565
|
* Alter the comment display to make it look like a D5 style comment.
|
566
|
*
|
567
|
* @author W.Addink <w.addink@eti.uva.nl>
|
568
|
*/
|
569
|
function garland_cichorieae_preprocess_comment(&$variables) {
|
570
|
$comment = $variables['elements']['#comment'];
|
571
|
if (isset($comment->subject)) {
|
572
|
// Print title without link.
|
573
|
$variables['title'] = $comment->subject;
|
574
|
if ($variables['status'] == 'comment-preview') {
|
575
|
// Add 'new' to preview.
|
576
|
$variables['new'] = t('new');
|
577
|
}
|
578
|
}
|
579
|
}
|