ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ModeManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Container\Content;
22 
27 {
28  protected int $user_id;
29  protected bool $ordering_mode = false;
30  protected \ILIAS\Repository\Clipboard\ClipboardManager $clipboard;
32  protected \ilContainer $container;
33 
34  public function __construct(
35  \ilContainer $container,
36  ModeSessionRepository $mode_repo,
37  \ILIAS\Repository\Clipboard\ClipboardManager $clipboard,
38  int $user_id
39  ) {
40  $this->container = $container;
41  $this->mode_repo = $mode_repo;
42  $this->clipboard = $clipboard;
43  $this->user_id = $user_id;
44  }
45 
46  public function setAdminMode(): void
47  {
48  if (in_array($this->user_id, [ANONYMOUS_USER_ID, 0], true)) {
49  return;
50  }
51  $this->mode_repo->setAdminMode();
52  }
53 
54  public function setContentMode(): void
55  {
56  $this->mode_repo->setContentMode();
57  }
58 
59  public function setOrderingMode(): void
60  {
61  $this->mode_repo->setContentMode();
62  $this->ordering_mode = true;
63  }
64 
65  public function isAdminMode(): bool
66  {
67  return $this->mode_repo->isAdminMode();
68  }
69 
70  public function isContentMode(): bool
71  {
72  return $this->mode_repo->isContentMode();
73  }
74 
75  public function isOrderingMode(): bool
76  {
77  return $this->ordering_mode;
78  }
79 
80  public function showAdminCheckboxes(): bool
81  {
82  return ($this->isAdminMode() && !$this->clipboard->hasEntries());
83  }
84 
85  public function isActiveItemOrdering(): bool
86  {
87  if ($this->isOrderingMode()) {
88  if ($this->container->getViewMode() == \ilContainer::VIEW_OBJECTIVE) {
89  return false;
90  }
91  return (\ilContainerSortingSettings::_lookupSortMode($this->container->getId()) === \ilContainer::SORT_MANUAL);
92  }
93  return false;
94  }
95 }
const ANONYMOUS_USER_ID
Definition: constants.php:27
Interface Observer Contains several chained tasks and infos about them.
ILIAS Repository Clipboard ClipboardManager $clipboard
Class ilContainer.
__construct(\ilContainer $container, ModeSessionRepository $mode_repo, \ILIAS\Repository\Clipboard\ClipboardManager $clipboard, int $user_id)