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
'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;
......
......@@ -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)) : ?>
......
<?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>
......
......@@ -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
......
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