From c69ed5813027b02ae0c3693916606aad21785f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Sch=C3=BCttl=C3=B6ffel?= Date: Fri, 8 Jan 2021 09:59:22 +0100 Subject: [PATCH 1/2] async image --- EvasysPlugin.class.php | 10 +++------- controllers/icon.php | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 controllers/icon.php diff --git a/EvasysPlugin.class.php b/EvasysPlugin.class.php index 384d739..d01086b 100644 --- a/EvasysPlugin.class.php +++ b/EvasysPlugin.class.php @@ -326,13 +326,9 @@ public function getIconNavigation($course_id, $last_visit, $user_id = null) if (Config::get()->EVASYS_RED_ICONS_STOP_UNTIL > time()) { $tab->setImage(Icon::create("evaluation", "new"), array('title' => _("Neue Evaluation"))); } else { - $number = 0; - foreach ($evasys_seminars as $evasys_seminar) { - $number += $evasys_seminar->getEvaluationStatus(); - } - if ($number > 0) { - $tab->setImage(Icon::create("evaluation", "new"), ['title' => sprintf(_("%s neue Evaluation"), $number)]); - } + + $tab->setImage(null, ['style' => 'background-image: ' . PluginEngine::getLink($this, array(), "icon/get/" . $course_id) ,'title' => _("Evaluationen")]); + } } return $tab; diff --git a/controllers/icon.php b/controllers/icon.php new file mode 100644 index 0000000..b4a057c --- /dev/null +++ b/controllers/icon.php @@ -0,0 +1,23 @@ +getEvaluationStatus(); + + if ($number > 0) break; + } + + $icon = Icon::create("evaluation", ($number > 0)?"new":"inactive")->asImagePath(); + $fp = fopen($icon, 'rb'); + header("Content-Type: svg/xml"); + header("Content-Length: " . filesize($icon)); + + fpassthru($fp); + exit; + } + +} From fc4a455c96eb62da130e0022265767815e41ad15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Sch=C3=BCttl=C3=B6ffel?= Date: Fri, 8 Jan 2021 12:05:11 +0100 Subject: [PATCH 2/2] async images now with js --- EvasysPlugin.class.php | 8 +++++++- controllers/icon.php | 10 +++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/EvasysPlugin.class.php b/EvasysPlugin.class.php index d01086b..2a368e5 100644 --- a/EvasysPlugin.class.php +++ b/EvasysPlugin.class.php @@ -327,7 +327,13 @@ public function getIconNavigation($course_id, $last_visit, $user_id = null) $tab->setImage(Icon::create("evaluation", "new"), array('title' => _("Neue Evaluation"))); } else { - $tab->setImage(null, ['style' => 'background-image: ' . PluginEngine::getLink($this, array(), "icon/get/" . $course_id) ,'title' => _("Evaluationen")]); + $icon_link = PluginEngine::getLink($this, array(), "icon/get/" . $course_id); + $tab->setImage( + Icon::create("evaluation", "inactive"), + [ + 'onload' => 'if(this.src != \'' . $icon_link .'\'){ this.src = \'' . $icon_link .'\';}', + 'title' => _("Evaluationen") + ]); } } diff --git a/controllers/icon.php b/controllers/icon.php index b4a057c..4563b17 100644 --- a/controllers/icon.php +++ b/controllers/icon.php @@ -11,12 +11,12 @@ public function get_action($course_id) if ($number > 0) break; } - $icon = Icon::create("evaluation", ($number > 0)?"new":"inactive")->asImagePath(); - $fp = fopen($icon, 'rb'); - header("Content-Type: svg/xml"); - header("Content-Length: " . filesize($icon)); + $icon_url = Icon::create("evaluation", ($number > 0)?"new":"inactive")->asImagePath(); + $icon_path = $GLOBALS['STUDIP_BASE_PATH'] . '/public' . parse_url($icon_url, PHP_URL_PATH); + + header("Content-Type: image/svg+xml"); + readfile($icon_path); - fpassthru($fp); exit; }