classificationUUID) {
$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 . '';
}
*/
/* ============================ 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
* - TaxonName
* - 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_entities_annotations_as_footnotekeys($variables) {
$cdm_entities = $variables['cdmBase_list'];
$footnote_list_key = $variables['footnote_list_key'];
// check if footnotes for annotations are disabled completely
if (variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
return '';
}
$out = '';
if(is_array($cdm_entities)){
// array of entities
$footNoteKeys = cdm_entities_annotations_as_footnotekeys($cdm_entities, $footnote_list_key);
} else {
// single entity
$footNoteKeys = cdm_entity_annotations_as_footnotekeys($cdm_entities, $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'];
$enclosing_tag = $variables['enclosing_tag'];
_add_js_footnotes();
$out = '<' . $enclosing_tag . ' class="footnote footnote-' . $footnoteKey . '">'
. ''
. ' ' . $footnoteText
. '' . $enclosing_tag . '>';
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;
}
/**
* Renders the footnotes for annotations and sources, etc.
*
* @param string $footnote_list_key
* RenderHints::getFootnoteListKey() will be used if this parameter is undefined.
* @param string $enclosingTag
* Default tag is 'span'
*
* @return string
* The markup string
*
*/
function render_cdm_footnotes(string $footnote_list_key = NULL, string $enclosingTag = 'span'){
if (variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
return '';
}
if(!$footnote_list_key){
$footnote_list_key = RenderHints::getFootnoteListKey();
}
$out = '<' . $enclosingTag . ' class="footnotes footnotes-' . $footnote_list_key . ' ">'
. FootnoteManager::renderFootnoteList($footnote_list_key . '-annotations') . ' ' . FootnoteManager::renderFootnoteList($footnote_list_key)
. '' . $enclosingTag . '>';
FootnoteManager::removeFootnoteList($footnote_list_key . '-annotations');
FootnoteManager::removeFootnoteList($footnote_list_key);
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;
}
}
/**
* Theme function for CDM marker instances
*
* @see compose_cdm_marker();
* @param array $variables
* - markerType_representation_l10n: the localized representation of the marker.markerType field
*/
function theme_cdm_marker($variables) {
$class_attribute = null;
//TODO class attribute hacked?, use generic drupal way?
if(isset($variables['attributes']['class'])){
$class_attribute = $variables['attributes']['class'];
}
return '' . $variables['label'] . '';
}
/* ============================ 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'];
// the parameters may still contain the q param,
// but this is already in the path variable
unset($parameters['q']);
$parameters['pager']['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_print_button() {
drupal_add_js('jQuery(document).ready(function() {
jQuery(\'#print_button\').click(function () {
window.print();
});
});', array('type' => 'inline'));
$output = '';
return $output;
}