Skip to content
Snippets Groups Projects
Commit bfe4b0ec authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Elmar Ludwig
Browse files

fixes #368

parent 61846383
No related branches found
No related tags found
No related merge requests found
...@@ -1003,7 +1003,7 @@ class MyCoursesController extends AuthenticatedController ...@@ -1003,7 +1003,7 @@ class MyCoursesController extends AuthenticatedController
'url' => $n->getURL(), 'url' => $n->getURL(),
'icon' => $this->convertIcon($n->getImage()), 'icon' => $this->convertIcon($n->getImage()),
'attr' => $attr, '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; $result[$key] = $item;
......
...@@ -125,23 +125,26 @@ if (!$values['parent_course'] || !in_array($values['parent_course'], array_keys( ...@@ -125,23 +125,26 @@ if (!$values['parent_course'] || !in_array($values['parent_course'], array_keys(
<? endif ?> <? endif ?>
<? if (in_array('contents', $view_filter)) : ?> <? if (in_array('contents', $view_filter)) : ?>
<td style="text-align: left; white-space: nowrap;"> <td style="text-align: left; white-space: nowrap;">
<? if (!empty($values['navigation'])) : ?> <? if (!empty($values['navigation'])) : ?>
<? foreach (MyRealmModel::array_rtrim($values['navigation']) as $key => $nav) : ?> <ul class="my-courses-navigation" style="flex-wrap: nowrap">
<? if ($nav instanceof Navigation && $nav->isVisible(true)) : ?> <? 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="<?= <a href="<?=
UrlHelper::getLink('seminar_main.php', URLHelper::getLink('seminar_main.php',
['auswahl' => $semid, ['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()) ?> <?= $nav->getImage()->asImg(20, $nav->getLinkAttributes()) ?>
</a> </a>
<? elseif (is_string($key)) : ?> </li>
<?= <? elseif (is_string($key)) : ?>
Assets::img('blank.gif', ['width' => 20, <li class="my-courses-navigation-item">
'height' => 20]); ?> <span class="empty-slot" style="width: 20px"></span>
<? endif ?> </li>
<? echo ' ' ?> <? endif ?>
<? endforeach ?> <? endforeach ?>
<? endif ?> </ul>
<? endif ?>
</td> </td>
<? endif ?> <? endif ?>
<? if (in_array('last_activity', $view_filter)) : ?> <? if (in_array('last_activity', $view_filter)) : ?>
......
<?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'])) : ?> <? if (isset($flash['decline_inst'])) : ?>
<?= QuestionBox::create( <?= QuestionBox::create(
sprintf( sprintf(
...@@ -64,19 +56,22 @@ $is_important = function (?Navigation $nav): bool { ...@@ -64,19 +56,22 @@ $is_important = function (?Navigation $nav): bool {
<? if (!empty($values['navigation'])) : ?> <? if (!empty($values['navigation'])) : ?>
<ul class="my-courses-navigation"> <ul class="my-courses-navigation">
<? foreach (MyRealmModel::array_rtrim($values['navigation']) as $key => $nav) : ?> <? 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)) : ?> <? if (isset($nav) && $nav->isVisible(true)) : ?>
<a href="<?= <li class="my-courses-navigation-item <? if ($nav->getImage()->signalsAttention()) echo 'my-courses-navigation-important'; ?>">
UrlHelper::getLink('dispatch.php/institute/overview', <a href="<?=
['auswahl' => $instid, URLHelper::getLink('dispatch.php/institute/overview',
'redirect_to' => strtr($nav->getURL(), '?', '&')]) ?>" <?= $nav->hasBadgeNumber() ? 'class="badge" data-badge-number="' . intval($nav->getBadgeNumber()) . '"' : '' ?>> ['auswahl' => $instid,
<?= $nav->getImage()->asImg(20, $nav->getLinkAttributes()) ?> 'redirect_to' => $nav->getURL()]) ?>" <?= $nav->hasBadgeNumber() ? 'class="badge" data-badge-number="' . intval($nav->getBadgeNumber()) . '"' : '' ?>>
</a> <?= $nav->getImage()->asImg(20, $nav->getLinkAttributes()) ?>
</a>
</li>
<? else: ?> <? 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 ?> <? endif ?>
<? endforeach ?> <? endforeach ?>
</li> </ul>
<? endif ?> <? endif ?>
</td> </td>
......
...@@ -170,6 +170,21 @@ class Icon ...@@ -170,6 +170,21 @@ class Icon
return $this->attributes; 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 * Function to be called whenever the object is converted to
* string. Internally the same as calling Icon::asImg * string. Internally the same as calling Icon::asImg
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment