classification->uuid) {
$taxon_in_current_tree = TRUE;
break;
}
}
}
return $taxon_in_current_tree;
}
/**
* TODO if getting fragment from request is possible remove
* $_REQUEST['highlite'] HACK
* NOT WORKING since fragments are not available to the server
* function fragment(){
* global $fragment;
* if(!$fragment){
* $fragment = substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'],
* '#'));
* }
* return $fragment;
* }
*/
function uuid_anchor($uuid, $innerHTML) {
$highlite = FALSE;
$params = drupal_get_query_parameters();
if (isset($params['highlite']) && $params['highlite'] == $uuid) {
$highlite = TRUE;
}
return '' . $innerHTML . '';
}
/**
* @todo Enter description here...
* @deprecated looks like this is not used anymore
*/
/*
function tagNameParts($name, $numOfNameTokens) {
$out = '';
$token = strtok($name, " \n\t");
$i = 0;
$noSpace = TRUE;
while ($token != FALSE) {
if ($i == $numOfNameTokens) {
$out .= ' ';
$noSpace = TRUE;
}
$out .= ($noSpace ? '' : ' ') . $token;
$noSpace = FALSE;
$token = strtok(" \n\t");
$i++;
}
return $out . '';
}
*/
/**
* Returns HTML for an array of TaggedText items.
*
* Converts an array of TaggedText items into a sequence of corresponding html
* tags whereas each item will provided with a class attribute which set to
* the key of the TaggedText item.
*
* @param array $variables
* An associative array containing:
* - taggedtxt: The array to format into html.
* - tag: The html tag to use.
* - glue: The string by which the chained text tokens are
* concatenated together. Default is a blank character.
* - skiptags: tags to skip.
*
* @ingroup themeable
*/
function theme_cdm_taggedtext2html($variables) {
$taggedtxt = $variables['taggedtxt'];
$tag = $variables['tag'];
$glue = $variables['glue'];
$skiptags = $variables['skiptags'];
$out = '';
$i = 0;
foreach ($taggedtxt as $tt) {
if (!in_array($tt->type, $skiptags) && strlen($tt->text) > 0) {
$out .= (strlen($out) > 0 && ++$i < count($taggedtxt) ? $glue : '') . '<' . $tag . ' class="' . $tt->type . '">' . t($tt->text) . '' . $tag . '>';
}
}
return $out;
}
/* ============================ annotations ============================= */
/**
* Returns HTML for annotations to cdm objects.
*
* Almost any cdmObject may be annotated. Therefore we provide a generic way to
* display as well as create or update annotations. The following cdm classes
* are annotatable:
*
* - DescriptionElementBase
* - EventBase
* - HomotypicalGroup
* - IdentifiableEntity
* - DescriptionBase
* - IdentifiableMediaEntity
* - Media
* - Sequence
* - TaxonBase
* - TaxonNameBase
* - TaxonomicTree
* - TermBase
* - LanguageStringBase
* - ReferencedEntityBase
* - NomenclaturalStatus
* - OriginalSourceBase
* - RelationshipBase
* - TypeDesignationBase
* - TaxonNode
* - WorkingSet
*
* @param array $variables
* An associative array containing:
* - cdmBase_list: An array of CdmBase instances or a single instance.
* - footnote_list_key
*
* @ingroup themeable
*/
function theme_cdm_annotations_as_footnotekeys($variables) {
$cdmBase_list = $variables['cdmBase_list'];
$footnote_list_key = $variables['footnote_list_key'];
if (variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
return '';
}
$out = '';
$footNoteKeys = cdm_annotations_as_footnotekeys($cdmBase_list, $footnote_list_key);
foreach ($footNoteKeys as $a) {
// $out .= theme('cdm_footnote_key', $a, $a->footnoteListKey, (isset($out)?
// ',' : ''));
$out .= theme('cdm_footnote_key', array('footnoteKey' => $a, 'separator' => ($out ? ',' : '')));
}
return $out;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_annotation_footnotes($variables) {
$footnoteListKey = $variables['footnoteListKey'];
$enclosingTag = $variables['enclosingTag'];
if (variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
return '';
}
return theme('cdm_footnotes', array('footnoteListKey' => $footnoteListKey . '-annotations', 'enclosingTag' => $enclosingTag));
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_annotation_content($variables) {
$AnnotationTO = $variables['AnnotationTO'];
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/cdm_annotations.js');
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/jquery.form.js');
$out .= theme('cdm_list_of_annotations', array('annotationElements' => $AnnotationTO->annotationElements));
$annotationUrl = cdm_compose_url(CDM_WS_ANNOTATIONS, array(
$AnnotationTO->uuid,
));
$annotationProxyUrl = url('cdm_api/proxy/' . urlencode($annotationUrl) . '/cdm_annotation_post');
// TODO users have to be authenticated to the dataportal to be able to write
// annotations.
$out .= '
';
return $out;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_list_of_annotations($variables) {
$annotationElements = $variables['annotationElements'];
$out = '';
foreach ($annotationElements as $key => $row) {
$created[$key] = $row;
}
array_multisort($created, SORT_ASC, $annotationElements);
foreach ($annotationElements as $annotation) {
$out .= '- ' . $annotation->text . '
';
}
$out .= '
';
return $out;
}
/* ============================ footnotes ============================= */
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_footnote_key($variables) {
$footnoteKey = $variables['footnoteKey'];
$separator = $variables['separator'];
$highlightable = $variables['highlightable'];
$separator_off = $variables['separator_off'];
if (!is_object($footnoteKey) or !isset($footnoteKey->footnoteListKey)) {
return '';
}
if (variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
return '';
}
if ($separator_off) {
$separator = '';
}
$out = '';
return $out;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_footnote($variables) {
$footnoteKey = $variables['footnoteKey'];
$footnoteText = $variables['footnoteText'];
_add_js_footnotes();
$out = '';
return $out;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_footnotes($variables) {
$footnoteListKey = $variables['footnoteListKey'];
$enclosingTag = $variables['enclosingTag'];
if (variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
return '';
}
$out = '<' . $enclosingTag . ' class="footnotes footnotes-' . $footnoteListKey . ' ">' . FootnoteManager::renderFootnoteList($footnoteListKey) . '' . $enclosingTag . '>';
FootnoteManager::removeFootnoteList($footnoteListKey);
return $out;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_annotations($variables) {
$annotations = $variables['annotations'];
$enclosingTag = $variables['enclosingTag'];
if (!is_array($annotations)) {
return;
}
$out = '<' . $enclosingTag . ' class="annotations">';
$i = 0;
foreach ($annotations as $annotation) {
$out .= ($i++ > 0 ? ', ' : '') . $annotation->text;
}
$out .= '' . $enclosingTag . '>';
return $out;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function cdm_exist_footnote($footnote_list, $footnote) {
$result = FALSE;
if (is_array($footnote_list)) {
foreach ($footnote_list as $element) {
if ($element == $footnote) {
$result = TRUE;
}
}
}
return $result;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function cdm_add_footnote_to_array(&$footnote_list, $footnote) {
if (!cdm_exist_footnote($footnote_list, $footnote)) {
$footnote_list[] = $footnote;
}
}
/* ============================ pager ============================= */
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_pager($variables) {
$pager = $variables['pager'];
$path = $variables['path'];
$parameters = $variables['parameters'];
$out = '';
if ($pager->pagesAvailable > 1) {
$out .= '';
return $out;
}
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_pager_link($variables) {
$text = $variables['text'];
$linkIndex = $variables['linkIndex'];
$pager = $variables['pager'];
$path = $variables['path'];
$parameters = $variables['parameters'];
$attributes = $variables['attributes'];
$out = '';
$parameters['search']['pageNumber'] = $linkIndex;
if ($linkIndex == $pager->currentIndex) {
$out = '' . $text . '';
}
else {
// $queryString = drupal_query_string_encode($parameters);
$queryString = $parameters;
$out = l($text, $path, array(
'attributes' => $attributes,
'query' => $queryString,
));
}
return $out;
}
/* ============================ special buttons ============================= */
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_back_to_search_result_button() {
$out = '';
$show_button = variable_get('cdm_dataportal_show_back_to_search_results');
if (isset($_SESSION['cdm']['search']) && isset($show_button)) {
/* ['cdm']['last_search'] */
// $out .= ''.l(t('Back to search result'), $_SESSION
// ).'
';
$out .= '' . l(t('Back to search result'), "http://" . $_SERVER['SERVER_NAME'] . $_SESSION['cdm']['last_search']) . '
';
}
return $out;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_back_to_image_gallery_button() {
$out = '' . l(t('Back to Images'), $_SESSION['cdm']['last_gallery']) . '
';
return $out;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_cdm_print_button() {
global $base_url;
drupal_add_js('jQuery(document).ready(function() {
jQuery(\'#print_button\').click(function () {
window.print();
});
});', array('type' => 'inline'));
$output = '';
return $output;
}
/* ============================ java script functions ============================= */
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function _add_js_thickbox() {
// ---- jQuery thickbox:
/*
* bug: compat-1.0.js && thickbox.js line 237 .trigger("unload") -> event is
* not triggered because of problems with compat-1.0.js' see INSTALL.txt
*/
// drupal_add_js(drupal_get_path('module',
// 'cdm_dataportal').'/js/jquery.imagetool.min.js');
//
// Add a setting for the path to cdm_dataportal module, used to find the path
// for the loading animation image in thickbox.
drupal_add_js(array('cdm_dataportal' => array(
'cdm_dataportal_path' => drupal_get_path('module', 'cdm_dataportal'),
)), 'setting');
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/thickbox/thickbox.js');
drupal_add_css(drupal_get_path('module', 'cdm_dataportal') . '/js/thickbox/cdm_thickbox.css');
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function _add_js_lightbox($galleryID) {
/*
* Important Notice: The jquery.lightbox-0.5.js has been modified in order to
* allow using the "alt" attribute for captions instead of the "title"
* attribute
*/
$lightBoxBasePath = drupal_get_path('module', 'cdm_dataportal') . '/js/jquery-lightbox-0.5';
drupal_add_js($lightBoxBasePath . '/js/jquery.lightbox-0.5.js');
drupal_add_css($lightBoxBasePath . '/css/jquery.lightbox-0.5.css');
drupal_add_js('jQuery(document).ready(function() {
jQuery(\'#' . $galleryID . ' a.lightbox\').lightBox({
fixedNavigation: true,
imageLoading: \'' . $lightBoxBasePath . '/images/lightbox-ico-loading.gif\',
imageBtnPrev: \'' . $lightBoxBasePath . '/images/lightbox-btn-prev.gif\',
imageBtnNext: \'' . $lightBoxBasePath . '/images/lightbox-btn-next.gif\',
imageBtnClose: \'' . $lightBoxBasePath . '/images/lightbox-btn-close.gif\',
imageBlank: \'' . $lightBoxBasePath . '/images/lightbox-blank.gif\',
adjustToWindow: true
});
});
', array('type' => 'inline'));
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function _add_js_footnotes() {
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/footnotes.js');
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function _add_js_cluetip() {
// TODO replace by
// @see http://www.socialembedded.com/labs/jQuery-Tooltip-Plugin/jQuery-Tooltip-Plugin.html
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/cluetip/jquery.cluetip.js');
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/jquery.dimensions.js');
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/cluetip/jquery.hoverIntent.js');
drupal_add_css(drupal_get_path('module', 'cdm_dataportal') . '/js/cluetip/jquery.cluetip.css');
drupal_add_js("jQuery(document).ready(function(){
jQuery('.cluetip').css({color: '#0062C2'}).cluetip({
splitTitle: '|',
showTitle: true,
activation: 'hover',
sicky: true,
arrows: true,
dropShadow: false,
cluetipClass: 'rounded'
});
});", array('type' => 'inline'));
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function _add_js_ahah() {
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/ahah-content.js');
}