Skip to content

Commit

Permalink
Reduces amount of requests to API.
Browse files Browse the repository at this point in the history
  • Loading branch information
percolatorWitt committed May 10, 2024
1 parent bf3b7b0 commit 06f7bce
Showing 1 changed file with 13 additions and 43 deletions.
56 changes: 13 additions & 43 deletions Classes/Domain/Repository/EzbRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public function loadForm() {
$form = $ezb->detailSearchFormFields();

//Zugriffsinformationen holen
$form['colors'] = $this->getAccessInfos(true);
$form['colors'] = $this->getAccessInfos();

return $form;
}
Expand Down Expand Up @@ -522,65 +522,35 @@ public function getLongAccessInfos(){

/**
*
* @param boolean $short
* get licence information
*
* @return array
*/
public function getAccessInfos($short = FALSE){
public function getAccessInfos(){
$ezb = NEW \Sub\Libconnect\Lib\Ezb;

//get default texts
$LongAccessInfos = $ezb->getLongAccessInfos();
$AccessInfos = $this->ezb->getLongAccessInfos();

$colortext = array();
if((!empty($LongAccessInfos['longAccessInfos'])) && ($LongAccessInfos['longAccessInfos']!= FALSE)){
foreach($LongAccessInfos as $key =>$text){
$colortext[$key] = $text;
}
}

//get text from web
$form = $ezb->detailSearchFormFields();
$AccessInfos = array();

//own texts or from web
if((!isset($form['selected_colors'])) or (empty($form['selected_colors'])) or ($LongAccessInfos['force'] == 'true')){
$AccessInfos = $colortext['longAccessInfos'];
}else{
$AccessInfos = $form['selected_colors'];

if($short){
//if shorter form is will
$ShortAccessInfos = $ezb->getShortAccessInfos();

if((!empty($ShortAccessInfos)) && ($ShortAccessInfos!= FALSE)){
foreach($ShortAccessInfos['shortAccessInfos'] as $key => $text){
if(empty($AccessInfos[$key])){
$AccessInfos[$key] = $ShortAccessInfos['shortAccessInfos'][$key];
}
}
}
}else{
//if licence information is missing
foreach($colortext['longAccessInfos'] as $key => $text){
if(empty($AccessInfos[$key])){
$AccessInfos[$key] = $colortext['longAccessInfos'][$key];
}
}
$colortext = [];
if ((!empty($AccessInfos['longAccessInfos'])) && ($AccessInfos['longAccessInfos']!= false)) {
foreach ($AccessInfos['longAccessInfos'] as $key =>$text) {
$colortext[$key] = $text;
}
}

//reorginize array
foreach($AccessInfos as $colorkey => $value){
if ( $colorkey != 6 ){
$return = array();
foreach ($colortext as $colorkey => $value) {
if ($colorkey != 6) {
$key = $colorkey;
} else {
$key = 3;
}
$return[$key] = array(
$return[$key] = [
'colorkey' => $colorkey,
'value' => $value
);
];
}

ksort($return);
Expand Down

0 comments on commit 06f7bce

Please sign in to comment.