Skip to content

Commit

Permalink
Improve Navigation / Mobile View
Browse files Browse the repository at this point in the history
  • Loading branch information
alex40724 committed Oct 3, 2023
1 parent db3faac commit f2738aa
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 25 deletions.
30 changes: 20 additions & 10 deletions Modules/LearningModule/Presentation/class.ilLMMenuRendererGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function render(): string
$ilCtrl = $this->ctrl;
$ilAccess = $this->access;
$ilTabs = $this->tabs;
$actions = [];

$getcmd = "getHTML";

Expand All @@ -115,7 +116,7 @@ public function render(): string
if (!$this->offline && $ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
$ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id);
if (!$content_active) {
$this->toolbar->addComponent(
$this->toolbar->addStickyItem(
$this->ui_factory->button()->standard($this->lng->txt("content"), $ilCtrl->getLinkTargetByClass("illmpresentationgui", "layout"))
);
}
Expand All @@ -135,9 +136,12 @@ public function render(): string
array("illmpresentationgui", "ilinfoscreengui"),
"showSummary"
);
/*
$this->toolbar->addComponent(
$this->ui_factory->button()->standard($this->lng->txt("info_short"), $link)
);
);*/
$actions[] =
$this->ui_factory->button()->shy($this->lng->txt("info_short"), $link);
}
}
if (!$this->offline &&
Expand Down Expand Up @@ -172,10 +176,15 @@ public function render(): string
$menu = new \ILIAS\LearningModule\Menu\ilLMMenuGUI($this->lm_pres_service);
foreach ($menu->getEntries() as $entry) {
if (is_object($entry["signal"])) {
$this->toolbar->addComponent(
$this->ui_factory->button()->standard($entry["label"], '')
->withOnClick($entry["signal"])
);
if ($this->lm_pres_service->getPresentationStatus()->getEmbedMode()) {
$this->toolbar->addComponent(
$this->ui_factory->button()->standard($entry["label"], '')
->withOnClick($entry["signal"])
);
} else {
$actions[] = $this->ui_factory->button()->shy($entry["label"], '')
->withOnClick($entry["signal"]);
}
}
if (is_object($entry["modal"])) {
($this->additional_content_collector)($entry["modal"]);
Expand All @@ -188,7 +197,6 @@ public function render(): string
// edit learning module
if (!$this->offline) {
if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
$actions = [];

if ($this->current_page > 0) {
$actions[] = $this->ui_factory->button()->shy(
Expand All @@ -205,11 +213,13 @@ public function render(): string
$this->lng->txt("lm_edit_lm_settings"),
$this->ctrl->getLinkTargetByClass(["ilLMEditorGUI", "ilobjlearningmodulegui"], "properties")
);
$this->toolbar->addComponent(
$this->ui_factory->dropdown()->standard($actions)
);
}
}
if (count($actions) > 0) {
$this->toolbar->addStickyItem(
$this->ui_factory->dropdown()->standard($actions)
);
}

return $tabs_gui->$getcmd();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/
class ilLMNavigationRendererGUI
{
protected ilToolbarGUI $toolbar;
protected \ILIAS\DI\UIServices $ui;
protected string $requested_frame;
protected int $requested_back_pg;
protected int $requested_obj_id;
Expand Down Expand Up @@ -48,9 +50,13 @@ public function __construct(
ilGlobalTemplateInterface $main_tpl,
int $requested_obj_id,
string $requested_back_pg,
string $requested_frame
string $requested_frame,
ilToolbarGUI $toolbar,
\ILIAS\DI\UIServices $ui
) {
$this->user = $user;
$this->toolbar = $toolbar;
$this->ui = $ui;
$this->lm_tree = $service->getLMTree();
$this->current_page = $service->getNavigationStatus()->getCurrentPage();
$this->lm = $service->getLearningModule();
Expand Down Expand Up @@ -113,6 +119,13 @@ protected function render(bool $top = true): string
? "images/spacer.png"
: ilUtil::getImagePath("spacer.png"));
$tpl->parseCurrentBlock();
if ($top) {
$b = $this->ui->factory()->button()->standard(
"<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>",
$back_href
);
$this->toolbar->addStickyItem($b);
}
} else {
$pre_id = $this->navigation_status->getPredecessorPageId();
if ($pre_id > 0) {
Expand Down Expand Up @@ -160,7 +173,26 @@ protected function render(bool $top = true): string
$tpl->setVariable("SPACER_PREV", $this->offline
? "images/spacer.png"
: ilUtil::getImagePath("spacer.png"));

if ($top) {
$b = $this->ui->factory()->button()->standard(
"<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>",
$prev_href
);
$this->toolbar->addStickyItem($b);
}
}
else {
if ($top) {
$b = $this->ui->factory()->button()->standard(
"<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>",
"#"
)->withUnavailableAction();
$this->toolbar->addStickyItem($b);
}
}

$this->addDropdown();

$succ_id = $this->navigation_status->getSuccessorPageId();
if ($succ_id > 0) {
Expand Down Expand Up @@ -217,11 +249,163 @@ protected function render(bool $top = true): string
}
}
}
if ($top) {
$b = $this->ui->factory()->button()->standard(
"<span class=\"glyphicon glyphicon-chevron-right \" aria-hidden=\"true\"></span>",
$succ_href
);
$this->toolbar->addStickyItem($b);
}
} else {
if ($top) {
$b = $this->ui->factory()->button()->standard(
"<span class=\"glyphicon glyphicon-chevron-right \" aria-hidden=\"true\"></span>",
"#"
)->withUnavailableAction();
$this->toolbar->addStickyItem($b);
}
}
}

$tpl->setVariable("CLASS", ($top) ? "tnav_Top" : "bnav_Bottom");

return $tpl->get();
}

protected function addDropdown()
{
$nodes = $this->lm_tree->getSubTree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
//$nodes = $this->filterNonAccessibleNode($nodes);

foreach ($nodes as $node) {
$disabled = false;

// check page activation
$active = ilLMPage::_lookupActive(
$node["obj_id"],
$this->lm->getType(),
$this->lm_set->get("time_scheduled_page_activation")
);

if ($node["type"] === "pg" &&
!$active) {
continue;
}

$text = "";
$checked = false;

switch ($node["type"]) {
// page
case "pg":
if ($this->lm->getTOCMode() != "pages") {
continue 2;
}
$text =
ilLMPageObject::_getPresentationTitle(
$node["obj_id"],
$this->lm->getPageHeader(),
$this->lm->isActiveNumbering(),
$this->lm_set->get("time_scheduled_page_activation"),
false,
0,
$this->lang
);

if ($this->user->getId() === ANONYMOUS_USER_ID &&
$this->lm_gui->getObject()->getPublicAccessMode() === "selected") {
if (!ilLMObject::_isPagePublic($node["obj_id"])) {
$disabled = true;
$text .= " (" . $this->lng->txt("cont_no_access") . ")";
}
}
break;

// learning module
case "du":
$text = "";
break;

// chapter
case "st":
$text =
ilStructureObject::_getPresentationTitle(
$node["obj_id"],
ilLMObject::CHAPTER_TITLE,
$this->lm->isActiveNumbering(),
$this->lm_set->get("time_scheduled_page_activation"),
false,
0,
$this->lang
);
if ($this->user->getId() === ANONYMOUS_USER_ID &&
$this->lm_gui->getObject()->getPublicAccessMode() === "selected") {
if (!ilLMObject::_isPagePublic($node["obj_id"])) {
$disabled = true;
$text .= " (" . $this->lng->txt("cont_no_access") . ")";
}
}
break;
}

if (!ilObjContentObject::_checkPreconditionsOfPage(
$this->lm->getRefId(),
$this->lm->getId(),
$node["obj_id"]
)) {
$disabled = true;
$text .= " (" . $this->lng->txt("cont_no_access") . ")";
}

$href = $this->linker->getLink("layout", $node["obj_id"]);

if ($text !== "") {
if ($this->lm->getTOCMode() === "pages" && $this->current_page == $node["obj_id"]) {
$text = "» " . $text;
}
if ($this->lm->getTOCMode() !== "pages") {
if ($this->lm_tree->getParentId($this->current_page) == $node["obj_id"]) {
$text = "» " . $text;
}
}
$text = str_pad("", ($node["depth"] - 1) * 12, "&nbsp;").$text;
$actions[] = $this->ui->factory()->button()->shy(
$text,
$href
);
}
}

if ($this->lm->getTOCMode() === "pages") {
$title = ilLMPageObject::_getPresentationTitle(
$this->current_page,
$this->lm->getPageHeader(),
$this->lm->isActiveNumbering(),
$this->lm_set->get("time_scheduled_page_activation"),
false,
0,
$this->lang
);
} else {
$st_id = $this->lm_tree->getParentId($this->current_page);
if ($st_id > 0) {
$title = ilStructureObject::_getPresentationTitle(
$st_id,
ilLMObject::CHAPTER_TITLE,
$this->lm->isActiveNumbering(),
$this->lm_set->get("time_scheduled_page_activation"),
false,
0,
$this->lang
);
}
}

$title = "<span style='vertical-align: bottom; max-width:60px; display: inline-block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;'>" . $title . "</span>";


$this->toolbar->addStickyItem(
$this->ui->factory()->dropdown()->standard($actions)->withLabel($title)
);
}
}
31 changes: 17 additions & 14 deletions Modules/LearningModule/Presentation/class.ilLMPresentationGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ public function layout(
case "ilPage":
$this->renderPageTitle();
$this->setHeader();
$this->ilLMMenu();
$this->addHeaderAction();
$content = $this->getContent();
$this->ilLMMenu();
$content .= $this->ilLMNotes();
$additional = $this->ui->renderer()->render($this->additional_content);
$this->tpl->setContent($content . $additional);
Expand Down Expand Up @@ -1120,20 +1120,23 @@ public function getContent(

$tpl = new ilTemplate("tpl.lm_content.html", true, true, "Modules/LearningModule/Presentation");

$navigation_renderer = new ilLMNavigationRendererGUI(
$this->service,
$this,
$this->lng,
$this->user,
$this->tpl,
$this->requested_obj_id,
$this->requested_back_pg,
$this->requested_frame
);

if (!$skip_nav) {
$tpl->setVariable("TOP_NAVIGATION", $navigation_renderer->renderTop());
$tpl->setVariable("BOTTOM_NAVIGATION", $navigation_renderer->renderBottom());
$navigation_renderer = new ilLMNavigationRendererGUI(
$this->service,
$this,
$this->lng,
$this->user,
$this->tpl,
$this->requested_obj_id,
$this->requested_back_pg,
$this->requested_frame,
$this->toolbar,
$this->ui
);

$navigation_renderer->renderTop();
//$tpl->setVariable("TOP_NAVIGATION", $navigation_renderer->renderTop());
//$tpl->setVariable("BOTTOM_NAVIGATION", $navigation_renderer->renderBottom());
}
$tpl->setVariable("PAGE_CONTENT", $this->getPageContent());
$tpl->setVariable("RATING", $this->renderRating());
Expand Down

0 comments on commit f2738aa

Please sign in to comment.