diff --git a/app/controllers/my_courses.php b/app/controllers/my_courses.php index 8a4f4727c2fa0d369997bcd6d1c4d4fa3dd14daf..4892d54043c623af2ade08dc3198b72a674767e3 100644 --- a/app/controllers/my_courses.php +++ b/app/controllers/my_courses.php @@ -1003,7 +1003,7 @@ class MyCoursesController extends AuthenticatedController 'url' => $n->getURL(), 'icon' => $this->convertIcon($n->getImage()), 'attr' => $attr, - 'important' => in_array($n->getImage()->getRole(), [Icon::ROLE_ATTENTION, Icon::ROLE_STATUS_RED, Icon::ROLE_NEW]) + 'important' => $n->getImage()->signalsAttention(), ]; } $result[$key] = $item; diff --git a/app/views/admin/courses/_course.php b/app/views/admin/courses/_course.php index 590fc3b71e857db8b4d4627f258d9d20bd5125a7..a0fab915688cb8c910dd50beff05bd67c78c00a8 100644 --- a/app/views/admin/courses/_course.php +++ b/app/views/admin/courses/_course.php @@ -125,23 +125,26 @@ if (!$values['parent_course'] || !in_array($values['parent_course'], array_keys( <? endif ?> <? if (in_array('contents', $view_filter)) : ?> <td style="text-align: left; white-space: nowrap;"> - <? if (!empty($values['navigation'])) : ?> - <? foreach (MyRealmModel::array_rtrim($values['navigation']) as $key => $nav) : ?> - <? if ($nav instanceof Navigation && $nav->isVisible(true)) : ?> + <? if (!empty($values['navigation'])) : ?> + <ul class="my-courses-navigation" style="flex-wrap: nowrap"> + <? foreach (MyRealmModel::array_rtrim($values['navigation']) as $key => $nav) : ?> + <? if ($nav instanceof Navigation && $nav->isVisible(true)) : ?> + <li class="my-courses-navigation-item <? if ($nav->getImage()->signalsAttention()) echo 'my-courses-navigation-important'; ?>"> <a href="<?= - UrlHelper::getLink('seminar_main.php', + URLHelper::getLink('seminar_main.php', ['auswahl' => $semid, - 'redirect_to' => strtr($nav->getURL(), '?', '&')]) ?>" <?= $nav->hasBadgeNumber() ? 'class="badge" data-badge-number="' . intval($nav->getBadgeNumber()) . '"' : '' ?>> + 'redirect_to' => $nav->getURL()]) ?>" <?= $nav->hasBadgeNumber() ? 'class="badge" data-badge-number="' . intval($nav->getBadgeNumber()) . '"' : '' ?>> <?= $nav->getImage()->asImg(20, $nav->getLinkAttributes()) ?> </a> - <? elseif (is_string($key)) : ?> - <?= - Assets::img('blank.gif', ['width' => 20, - 'height' => 20]); ?> - <? endif ?> - <? echo ' ' ?> - <? endforeach ?> - <? endif ?> + </li> + <? elseif (is_string($key)) : ?> + <li class="my-courses-navigation-item"> + <span class="empty-slot" style="width: 20px"></span> + </li> + <? endif ?> + <? endforeach ?> + </ul> + <? endif ?> </td> <? endif ?> <? if (in_array('last_activity', $view_filter)) : ?> diff --git a/app/views/my_institutes/index.php b/app/views/my_institutes/index.php index e663d9e52953278981e76aba6d2b4ada4d51834c..cff61cea5d2b8f2d1f0415d24810491882f26283 100644 --- a/app/views/my_institutes/index.php +++ b/app/views/my_institutes/index.php @@ -1,11 +1,3 @@ -<?php -$is_important = function (?Navigation $nav): bool { - return $nav - && $nav->getImage() instanceof Icon - && in_array($nav->getImage()->getRole(), [Icon::ROLE_ATTENTION, Icon::ROLE_STATUS_RED]); -}; -?> - <? if (isset($flash['decline_inst'])) : ?> <?= QuestionBox::create( sprintf( @@ -64,19 +56,22 @@ $is_important = function (?Navigation $nav): bool { <? if (!empty($values['navigation'])) : ?> <ul class="my-courses-navigation"> <? foreach (MyRealmModel::array_rtrim($values['navigation']) as $key => $nav) : ?> - <li class="my-courses-navigation-item <? if ($is_important($nav)) echo 'my-courses-navigation-important'; ?>"> <? if (isset($nav) && $nav->isVisible(true)) : ?> - <a href="<?= - UrlHelper::getLink('dispatch.php/institute/overview', - ['auswahl' => $instid, - 'redirect_to' => strtr($nav->getURL(), '?', '&')]) ?>" <?= $nav->hasBadgeNumber() ? 'class="badge" data-badge-number="' . intval($nav->getBadgeNumber()) . '"' : '' ?>> - <?= $nav->getImage()->asImg(20, $nav->getLinkAttributes()) ?> - </a> + <li class="my-courses-navigation-item <? if ($nav->getImage()->signalsAttention()) echo 'my-courses-navigation-important'; ?>"> + <a href="<?= + URLHelper::getLink('dispatch.php/institute/overview', + ['auswahl' => $instid, + 'redirect_to' => $nav->getURL()]) ?>" <?= $nav->hasBadgeNumber() ? 'class="badge" data-badge-number="' . intval($nav->getBadgeNumber()) . '"' : '' ?>> + <?= $nav->getImage()->asImg(20, $nav->getLinkAttributes()) ?> + </a> + </li> <? else: ?> - <span class="empty-slot" style="width: 20px"></span> + <li class="my-courses-navigation-item"> + <span class="empty-slot" style="width: 20px"></span> + </li> <? endif ?> <? endforeach ?> - </li> + </ul> <? endif ?> </td> diff --git a/lib/classes/Icon.class.php b/lib/classes/Icon.class.php index 17fc1e3ee417478efa8e0983538ce06aa290a516..85b7b02ae49c4fe46b833d00e751143e0d1f4ee6 100644 --- a/lib/classes/Icon.class.php +++ b/lib/classes/Icon.class.php @@ -170,6 +170,21 @@ class Icon return $this->attributes; } + /** + * Returns whether this icon intends to signal attention. + * + * @todo This is currently just a heuristic based on the associated icon + * role. Although this is sufficient for the current requirements, + * it could probably in a better, more suitable way. + * + * @return bool + * @since Stud.IP 5.0 + */ + public function signalsAttention() + { + return $this->roleToColor($this->role) === 'red'; + } + /** * Function to be called whenever the object is converted to * string. Internally the same as calling Icon::asImg