Revision 48a6d7e8
Added by Andreas Kohlbecker over 5 years ago
modules/cdm_dataportal/includes/pages.inc | ||
---|---|---|
468 | 468 |
|
469 | 469 |
|
470 | 470 |
if (!isset($media[0]) || ($tabsToDisplay["Images"] == '0')) { |
471 |
taxon_page_tabs_hidden('images'); |
|
471 |
taxon_page_tabs_hidden_add('images');
|
|
472 | 472 |
} |
473 | 473 |
|
474 | 474 |
// --- GET specimensOrObservations --- // |
... | ... | |
476 | 476 |
|
477 | 477 |
$specimensOrObservationsCount = is_array($specimensOrObservations) ? count($specimensOrObservations) : 0; |
478 | 478 |
if ($specimensOrObservationsCount == 0 || ($tabsToDisplay["Specimens"] == '0')) { |
479 |
taxon_page_tabs_hidden('specimens'); |
|
479 |
taxon_page_tabs_hidden_add('specimens');
|
|
480 | 480 |
} |
481 | 481 |
|
482 | 482 |
// --- GET polytomousKeys --- // |
... | ... | |
486 | 486 |
$identificationKeyCount += $polytomousKeysPager->count; |
487 | 487 |
} |
488 | 488 |
if ($identificationKeyCount == 0 || ($tabsToDisplay["Keys"] == '0')) { |
489 |
taxon_page_tabs_hidden('keys'); |
|
489 |
taxon_page_tabs_hidden_add('keys');
|
|
490 | 490 |
} |
491 | 491 |
|
492 | 492 |
// --- GET TaxonNodeAgentRelations --- // |
... | ... | |
499 | 499 |
"pageSize=1&pageIndex=0"// we are only interested into the count so we are fetching only one item, o is not possible! |
500 | 500 |
); |
501 | 501 |
if (!$taxon_node_agent_relations_pager || $taxon_node_agent_relations_pager->count == 0){ |
502 |
taxon_page_tabs_hidden('experts'); |
|
502 |
taxon_page_tabs_hidden_add('experts');
|
|
503 | 503 |
} |
504 | 504 |
|
505 | 505 |
if (!isset($tabsToDisplay["Synonymy"]) || $tabsToDisplay["Synonymy"] == '0') { |
506 |
taxon_page_tabs_hidden('synonymy'); |
|
506 |
taxon_page_tabs_hidden_add('synonymy');
|
|
507 | 507 |
} |
508 | 508 |
|
509 | 509 |
// -------------------------------------------- // |
... | ... | |
513 | 513 |
} |
514 | 514 |
|
515 | 515 |
// --- PAGE PART: DESCRIPTION --- // |
516 |
if ($page_part == 'description' || $page_part == 'all') {
|
|
516 |
if (!taxon_page_tabs_hidden_check('description') && ($page_part == 'description' || $page_part == 'all')) {
|
|
517 | 517 |
|
518 | 518 |
$merged_tree = merged_taxon_feature_tree($taxon); |
519 | 519 |
|
... | ... | |
525 | 525 |
} |
526 | 526 |
|
527 | 527 |
// --- PAGE PART: IMAGES --- // |
528 |
if (array_search('images', taxon_page_tabs_hidden()) === FALSE && ($page_part == 'images' || $page_part == 'all')) {
|
|
528 |
if (!taxon_page_tabs_hidden_check('images') && ($page_part == 'images' || $page_part == 'all')) {
|
|
529 | 529 |
$images_html = '<div id="images" class="page-part">'; |
530 | 530 |
if ($page_part == 'all') { |
531 | 531 |
$images_html .= '<h2>' . t(cdm_taxonpage_tab_label('Images')) . '</h2>'; |
... | ... | |
558 | 558 |
} |
559 | 559 |
|
560 | 560 |
// --- PAGE PART: SYNONYMY --- // |
561 |
if ((($page_part == 'synonymy' || $page_part == 'all') && $synonymy_as_tab)) { |
|
561 |
if (!taxon_page_tabs_hidden_check('synonymy') && (($page_part == 'synonymy' || $page_part == 'all') && $synonymy_as_tab)) {
|
|
562 | 562 |
$synonymy_html = '<div id="synonymy" class="page-part">'; |
563 | 563 |
if ($page_part == 'all') { |
564 | 564 |
$synonymy_html .= '<h2>' . t(cdm_taxonpage_tab_label('Synonymy')) . '</h2>'; |
... | ... | |
573 | 573 |
} |
574 | 574 |
|
575 | 575 |
// --- PAGE PART: SPECIMENS --- // |
576 |
if ($specimensOrObservationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all')) {
|
|
576 |
if (!taxon_page_tabs_hidden_check('specimens') && ($specimensOrObservationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all'))) {
|
|
577 | 577 |
$render_array['specimens'] = array( |
578 | 578 |
'#prefix' => '<div id="specimens" class="page-part">' . ($page_part == 'all' ? '<h2>' . t(cdm_taxonpage_tab_label('Specimens')) . '</h2>' : ''), |
579 | 579 |
'content' => cdm_dataportal_taxon_page_specimens($taxon), // returns render array |
... | ... | |
582 | 582 |
} |
583 | 583 |
|
584 | 584 |
// --- PAGE PART: KEYS --- // |
585 |
if ($identificationKeyCount == 1 && $page_part == 'keys'){ |
|
586 |
drupal_goto(path_to_key($polytomousKeysPager->records[0]->class, $polytomousKeysPager->records[0]->uuid)); |
|
587 |
} |
|
588 |
else if ($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all')) { |
|
589 |
$keys_html = '<div id="keys" class="page-part">'; |
|
590 |
if ($page_part == 'all') { |
|
591 |
$keys_html .= '<h2>' . t(cdm_taxonpage_tab_label('Keys')) . '</h2>'; |
|
585 |
if(!taxon_page_tabs_hidden_check('keys')){ |
|
586 |
if ($identificationKeyCount == 1 && $page_part == 'keys'){ |
|
587 |
drupal_goto(path_to_key($polytomousKeysPager->records[0]->class, $polytomousKeysPager->records[0]->uuid)); |
|
588 |
} |
|
589 |
else if ($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all')) { |
|
590 |
$keys_html = '<div id="keys" class="page-part">'; |
|
591 |
if ($page_part == 'all') { |
|
592 |
$keys_html .= '<h2>' . t(cdm_taxonpage_tab_label('Keys')) . '</h2>'; |
|
593 |
} |
|
594 |
$keys_html .= theme('cdm_block_IdentificationKeys', array('taxonUuid' => $taxon->uuid)); |
|
595 |
$keys_html .= '</div>'; |
|
596 |
$render_array['keys'] = markup_to_render_array($keys_html, $weight++); |
|
592 | 597 |
} |
593 |
$keys_html .= theme('cdm_block_IdentificationKeys', array('taxonUuid' => $taxon->uuid)); |
|
594 |
$keys_html .= '</div>'; |
|
595 |
$render_array['keys'] = markup_to_render_array($keys_html, $weight++); |
|
596 | 598 |
} |
597 | 599 |
|
598 | 600 |
// --- PAGE PART: EXPERTS --- // |
599 | 601 |
|
600 |
if (array_search('experts', taxon_page_tabs_hidden()) === FALSE && ($page_part == 'experts' || $page_part == 'all')) {
|
|
602 |
if (!taxon_page_tabs_hidden_check('experts') && ($page_part == 'experts' || $page_part == 'all')) {
|
|
601 | 603 |
$render_array['experts'] = array( |
602 | 604 |
'#prefix' => '<div id="experts" class="page-part">' . ($page_part == 'all' ? '<h2>' . t(cdm_taxonpage_tab_label('Experts')) . '</h2>' : ''), |
603 | 605 |
'content' => compose_cdm_taxon_page_experts($taxon), // returns render array |
... | ... | |
925 | 927 |
* @return |
926 | 928 |
* The array of tabs |
927 | 929 |
*/ |
928 |
function taxon_page_tabs_hidden($add_tab = NULL) { |
|
929 |
$tabs = &drupal_static(__FUNCTION__);
|
|
930 |
function taxon_page_tabs_hidden_add($add_tab = NULL) {
|
|
931 |
$tabs = &drupal_static('taxon_page_tabs_hidden');
|
|
930 | 932 |
|
931 | 933 |
if(!isset($tabs)){ |
932 | 934 |
$tabs = array(); |
... | ... | |
940 | 942 |
} |
941 | 943 |
|
942 | 944 |
/** |
945 |
* Manages the tabs to be hidden in the taxon page. |
|
946 |
* |
|
947 |
* The tabs names are identified by their last menu link path element: |
|
948 |
* - description |
|
949 |
* - synonymy |
|
950 |
* - images |
|
951 |
* - specimens |
|
952 |
* - key |
|
953 |
* |
|
954 |
* Internally the tabs are stored in a static variable which is |
|
955 |
* managed by drupal_static(). |
|
956 |
* |
|
957 |
* @param string $tabname |
|
958 |
* The name of the tab to check |
|
959 |
* |
|
960 |
* @return boolean |
|
961 |
* True if the tab or section is to be hidden |
|
962 |
*/ |
|
963 |
function taxon_page_tabs_hidden_check($tabname) { |
|
964 |
|
|
965 |
$tabs = &drupal_static('taxon_page_tabs_hidden'); |
|
966 |
|
|
967 |
if(!isset($tabs)){ |
|
968 |
$tabs = array(); |
|
969 |
} |
|
970 |
|
|
971 |
return array_search($tabname, $tabs) !== FALSE; |
|
972 |
} |
|
973 |
|
|
974 |
/** |
|
943 | 975 |
* Implements the hook_preprocess_HOOK() for theme_menu_local_tasks() |
944 | 976 |
* |
945 |
* - Removes the tabs to be hidden, @see taxon_page_tabs_hidden() |
|
977 |
* - Removes the tabs to be hidden, @see taxon_page_tabs_hidden_add()
|
|
946 | 978 |
* - Renames tabs according to the settings // TODO (this will replace the theme_cdm_taxonpage_tab() function !!!) |
947 | 979 |
* |
948 | 980 |
* @param array $variables |
... | ... | |
950 | 982 |
*/ |
951 | 983 |
function cdm_dataportal_preprocess_menu_local_tasks(&$variables) { |
952 | 984 |
|
953 |
$hidden_tabs = taxon_page_tabs_hidden(); |
|
985 |
$hidden_tabs = taxon_page_tabs_hidden_add();
|
|
954 | 986 |
|
955 | 987 |
if (is_array($variables['primary'])) { |
956 | 988 |
foreach ($variables['primary'] as $key => &$element) { |
Also available in: Unified diff
fix #7294 fixing broken tab/page-section disabling