From d339df0543d4a51f305fd4014e7f98cb639fa060 Mon Sep 17 00:00:00 2001 From: Gregor Gawol <gawol@gawol-optiplex-9020-aio.(none)> Date: Tue, 14 Jan 2020 13:31:49 +0100 Subject: [PATCH] refs #16630 [fid] refactored get it box * modified config * remove obsolete method * set comments * bug fixing hierarchy records * bug fixing local DE-15 with isbn --- module/fid/src/View/Helper/Root/GetIt.php | 523 ++++++++-------------- 1 file changed, 184 insertions(+), 339 deletions(-) diff --git a/module/fid/src/View/Helper/Root/GetIt.php b/module/fid/src/View/Helper/Root/GetIt.php index 7ecdc5dc614..a47a8c51c40 100644 --- a/module/fid/src/View/Helper/Root/GetIt.php +++ b/module/fid/src/View/Helper/Root/GetIt.php @@ -123,13 +123,15 @@ class GetIt extends AbstractHelper $this->accordeonColorDefault = 'azure'; $this->accordeonColorAlternative = 'amber'; - $this->accordeonHeadlineDefault = $this->translate('getit_links'); - $this->accordeonHeadlineAlternative = $this->translate('getit_infos'); + $this->accordeonHeadlineDefault = $this->translate('getit_infos'); + $this->accordeonHeadlineAlternative = $this->translate('getit_links'); return $this; } /** + * Retrieve SIDs from config (getit.ini) + * * @param $value * * @return array @@ -141,6 +143,8 @@ class GetIt extends AbstractHelper } /** + * Retrieve NonSIDs from config (getit.ini) + * * @param $value * * @return string @@ -152,326 +156,11 @@ class GetIt extends AbstractHelper } /** - * @param $defaultval - * @param $additionalval + * Read specific config of given record + * Set default Values of getit box * - * @return mixed - */ - private function _accordeon($defaultval, $additionalval) - { - if (in_array($this->sid, $this->_getSourceIds('source_idsV1'))) { - return $additionalval; - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV3'))) { - return $additionalval; - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV5'))) { - return $additionalval; - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV7'))) { - return $additionalval; - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV8'))) { - if (in_array('Free', $this->facetAvail)) { - return $additionalval; - } elseif (in_array('Online', $this->facetAvail) - && (preg_grep($this->_getNonSourceIds('source_idsV8_5'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format)) - ) { - return $additionalval; - } - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV10'))) { - return $additionalval; - } - return $defaultval; - } - - /** - * @return string - */ - public function getAccordeonColor() - { - return $this->_accordeon('azure', 'amber'); - } - - /** - * @return mixed - */ - public function getAccordeonHeadline() - { - $links = $this->translate('getit_links'); - $infos = $this->translate('getit_infos'); - return $this->_accordeon($infos, $links); - } - - /** - * @return string - */ - public function getBoxHeadline() - { - if (in_array($this->sid, $this->_getSourceIds('source_idsV3'))) { - if (!$this->fidClient->isLoggedOn()) { - return $this->translate('getit_logged_not'); - } - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV4'))) { - if (!$this->fidClient->isLoggedOn()) { - return $this->translate('getit_logged_not'); - } - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV5'))) { - if (!$this->fidClient->isLoggedOn()) { - return $this->translate('getit_logged_not'); - } - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV8'))) { - $isLogin = false; - if (in_array('Local', $this->facetAvail) - && ((preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - && !in_array($this->_getNonSourceIds('source_idsV8_9'), $this->institution)) - || preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format) - ) - ) { - $isLogin = true; - } elseif (in_array('Online', $this->facetAvail) - && !in_array('Free', $this->facetAvail) - && (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format)) - ) { - $isLogin = true; - } - if (in_array($this->sid, $this->_getSourceIds('source_idsV9')) - && preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->format) - ) { - $isLogin = true; - } - if ($isLogin && !$this->fidClient->isLoggedOn()) { - return $this->translate('getit_logged_not'); - } - } - return $this->translate('Get it'); - } - - /** - * @return string - */ - public function getNotices() - { - if (in_array($this->sid, $this->_getSourceIds('source_idsV1'))) { - return $this->translate('getit_text_1'); - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV3'))) { - return; - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV4'))) { - if (!$this->fidClient->isLoggedOn()) { - return $this->translate('getit_text_2'); - } else { - return $this->translate('getit_text_12'); - } - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV5'))) { - if (!$this->fidClient->isLoggedOn()) { - return $this->translate('getit_text_3_1'); - } else { - return $this->translate('getit_text_13'); - } - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV6'))) { - return $this->translate('getit_text_4'); - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV7'))) { - return $this->translate('getit_text_5'); - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV10'))) { - return $this->translate('getit_text_6'); - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV11'))) { - return $this->translate('getit_text_7'); - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV8'))) { - if (in_array($this->sid, $this->_getSourceIds('source_idsV9'))) { - if (preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection)) { - if (!$this->fidClient->isLoggedOn()) { - return $this->translate('getit_text_3_1'); - } else { - return $this->translate('getit_text_13'); - } - } - if ($this->isCollection) { - return $this->translate('getit_text_11',['%%hierarchy_tree%%' => $this->translate('hierarchy_tree')]); - } - if (preg_grep($this->_getNonSourceIds('source_idsV8_7'), $this->megacollection) - ) { - return $this->translate('getit_text_1'); - } - if (in_array('Local', $this->facetAvail) - && (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format)) - ) { - if (!$this->fidClient->isLoggedOn()) { - return $this->translate('getit_text_10'); - } elseif (preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format)) { - return $this->translate('getit_text_14'); - } else { - return ''; - } - } - if (in_array('Local', $this->facetAvail) - && preg_grep($this->_getNonSourceIds('source_idsV8_2'), $this->format) - ) { - return $this->translate('getit_text_8'); - } - if (in_array('Free', $this->facetAvail)) { - return $this->translate('getit_text_1'); - } - if (in_array('Online', $this->facetAvail) - && (preg_grep($this->_getNonSourceIds('source_idsV8_5'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format)) - ) { - return $this->translate('getit_text_9'); - } elseif (in_array('Online', $this->facetAvail) - && preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - ) { - if (!$this->fidClient->isLoggedOn()) { - return $this->translate('getit_text_10'); - } else { - return $this->translate('getit_text_15'); - } - } - } elseif ($this->isCollection) { - return $this->translate('getit_text_11',['%%hierarchy_tree%%' => $this->translate('hierarchy_tree')]); - } elseif (in_array('Local', $this->facetAvail) - && preg_grep($this->_getNonSourceIds('source_idsV8_2'), $this->format) - ) { - return $this->translate('getit_text_8'); - } elseif (in_array('Local', $this->facetAvail)) { - if (!$this->fidClient->isLoggedOn()) { - return $this->translate('getit_text_10'); - } elseif (preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format)) { - return $this->translate('getit_text_14'); - } else { - return ''; - } - } elseif (in_array('Free', $this->facetAvail)) { - return $this->translate('getit_text_1'); - } elseif (in_array('Online', $this->facetAvail) - && (preg_grep($this->_getNonSourceIds('source_idsV8_5'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format)) - ) { - return $this->translate('getit_text_9'); - } elseif (in_array('Online', $this->facetAvail) - && preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - ) { - if (!$this->fidClient->isLoggedOn()) { - return $this->translate('getit_text_10'); - } else { - return $this->translate('getit_text_15'); - } - } - } - return $this->translate('getit_text_default'); - } - - /** - * @return bool - */ - public function showLinks() - { - if (in_array($this->sid, $this->_getSourceIds('source_idsV5')) - || (in_array($this->sid, $this->_getSourceIds('source_idsV9')) - && preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection)) - ) { - if (!$this->fidClient->isLoggedOn()) { - return false; - } - } - return true; - } - - /** - * @return bool - */ - public function showOrderButton() - { - if (in_array($this->sid, $this->_getSourceIds('source_idsV9')) - && preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - && !in_array($this->_getNonSourceIds('source_idsV8_9'), $this->institution) - && !$this->isCollection - && !preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) - ) { - return true; - } - return false; - } - - /** - * @return bool - */ - public function showPartCopyButton() - { - if (!in_array('Free', $this->facetAvail) - && in_array($this->sid, $this->_getSourceIds('source_idsV8')) - && preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - && !$this->isCollection - && !preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) - ) { - return true; - } - return false; - } - - /** - * @return bool + * @return array config of given record */ - public function showBOSSData() - { - if (!in_array('Free', $this->facetAvail) - && in_array($this->sid, $this->_getSourceIds('source_idsV8')) - //&& (!empty($this->isbn) || !empty($this->issn)) - && !preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) - ) { - if (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - ) { - return true; - } elseif (in_array('Local', $this->facetAvail) - && preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format) - ) { - return true; - } - } - return false; - } - - public function isEBCEBooks() - { - if (in_array('Online', $this->facetAvail) - && in_array($this->sid, $this->_getSourceIds('source_idsV9')) - && preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) - ) { - return true; - } - return false; - } - - public function hideNotice() - { - if (in_array($this->sid, $this->_getSourceIds('source_idsV8'))) { - if (in_array('Online', $this->facetAvail) - && (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_5'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format)) - ) { - return false; - } elseif (in_array('Local', $this->facetAvail) - && (preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_2'), $this->format)) - ) { - return false; - } elseif (in_array('Local', $this->facetAvail) - && preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - ) { - return false; - } - } elseif (in_array($this->sid, $this->_getSourceIds('source_idsV3'))) { - return false; - } - return true; - } - - public function isAISIDRecord() - { - if (in_array($this->sid, $this->_getSourceIds('source_idsV3'))) { - return true; - } - return false; - } - public function getConfig() { //set default values @@ -484,7 +173,7 @@ class GetIt extends AbstractHelper $showPartCopyButton = false; $bossData = false; $isEBCEBooks = false; - $hideNotice = true; + $hideNotice = false; $isAiSidRecord = false; // let specific functions override defaults where necessary @@ -528,6 +217,21 @@ class GetIt extends AbstractHelper ); } + /** + * Configuration of SIDs 13,22,26,28,30,34,53,80,84,87,88,99,101,150,153,170 + * + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + */ public function get_config_source_idsV1( &$accordeonColor, &$accordeonHeadline, @@ -547,6 +251,21 @@ class GetIt extends AbstractHelper $notice = $this->translate('getit_text_1'); } + /** + * Configuration of SID 49,55,68,105 + * + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + */ public function get_config_source_idsV3( &$accordeonColor, &$accordeonHeadline, @@ -568,6 +287,21 @@ class GetIt extends AbstractHelper $isAiSidRecord = true; } + /** + * Configuration of SID 51 + * + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + */ public function get_config_source_idsV4( &$accordeonColor, &$accordeonHeadline, @@ -586,6 +320,21 @@ class GetIt extends AbstractHelper $notice = $this->fidClient->isLoggedOn() ? $this->translate('getit_text_12') : $this->translate('getit_text_2'); } + /** + * Configuration of SID 76 + * + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + */ public function get_config_source_idsV5( &$accordeonColor, &$accordeonHeadline, @@ -607,6 +356,21 @@ class GetIt extends AbstractHelper $showLinks = $this->fidClient->isLoggedOn(); } + /** + * Configuration of SID 78 + * + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + */ public function get_config_source_idsV6( &$accordeonColor, &$accordeonHeadline, @@ -624,6 +388,21 @@ class GetIt extends AbstractHelper $notice = $this->translate('getit_text_4'); } + /** + * Configuration of SID 103 + * + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + */ public function get_config_source_idsV7( &$accordeonColor, &$accordeonHeadline, @@ -643,6 +422,21 @@ class GetIt extends AbstractHelper $notice = $this->translate('getit_text_5'); } + /** + * Configuration of SID 0,109,117,119,127,142,148,151,155 + * + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + */ public function get_config_source_idsV8( &$accordeonColor, &$accordeonHeadline, @@ -691,7 +485,7 @@ class GetIt extends AbstractHelper $isLogin = true; } if ($isLogin && !$this->fidClient->isLoggedOn()) { - $headLine = $this->translate('getit_logged_not'); + $boxHeadline = $this->translate('getit_logged_not'); } //END boxheadline //notice @@ -755,7 +549,7 @@ class GetIt extends AbstractHelper $notice = $this->translate('getit_text_10'); } elseif (preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format)) { $notice = $this->translate('getit_text_14'); - } else { + } elseif (!preg_grep($this->_getNonSourceIds('source_idsV8_10'), $this->format)) { $notice = ''; } } elseif (in_array('Free', $this->facetAvail)) { @@ -794,26 +588,39 @@ class GetIt extends AbstractHelper } //END bossData //hideNotice - if (in_array('Online', $this->facetAvail)) - { - if (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_5'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format) - ) { - $hideNotice = false; - } - } elseif (in_array('Local', $this->facetAvail)) - { - if (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_2'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format) - ) { - $hideNotice = false; + if ($this->fidClient->isLoggedOn()) { + if (in_array('Local', $this->facetAvail)) + { + if (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) + && empty($this->isbn) + && !preg_grep($this->_getNonSourceIds('source_idsV8_9'), $this->institution) + && !preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) + ) { + $hideNotice = true; + } + if ($this->isCollection) { + $hideNotice = false; + } } } //END hideNotice } + /** + * Configuration of SID 0 (special cases) + * + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + */ public function get_config_source_idsV9( &$accordeonColor, &$accordeonHeadline, @@ -828,6 +635,14 @@ class GetIt extends AbstractHelper &$isAiSidRecord ) { + //accordeon + if (preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) + || preg_grep($this->_getNonSourceIds('source_idsV8_7'), $this->megacollection) + ) { + $accordeonHeadline = $this->accordeonHeadlineAlternative; + $accordeonColor = $this->accordeonColorAlternative; + } + //END accordeon //showLinks if ( preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) @@ -839,7 +654,7 @@ class GetIt extends AbstractHelper //END showLinks //orderButton if (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - && !in_array($this->_getNonSourceIds('source_idsV8_9'), $this->institution) + && !preg_grep($this->_getNonSourceIds('source_idsV8_9'), $this->institution) && !$this->isCollection && !preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) ) { @@ -855,6 +670,21 @@ class GetIt extends AbstractHelper //END EBCEbooks } + /** + * Configuration of SID 169 + * + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + */ public function get_config_source_idsV10( &$accordeonColor, &$accordeonHeadline, @@ -874,6 +704,21 @@ class GetIt extends AbstractHelper $notice = $this->translate('getit_text_6'); } + /** + * Configuration of SID 126 + * + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + */ public function get_config_source_idsV11( &$accordeonColor, &$accordeonHeadline, -- GitLab