ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.BlockSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
30 use ILIAS\Data\URI;
32 
34 {
36 
37  public function __construct(
38  protected InternalDataService $data,
39  protected InternalDomainService $domain,
40  protected InternalGUIService $gui,
41  protected int $obj_id,
42  protected bool $in_repository
43  ) {
44  $this->settings = $domain->blogSettings();
45  }
46 
47  public function executeCommand(): void
48  {
49  $ctrl = $this->gui->ctrl();
50  $next_class = $ctrl->getNextClass($this);
51  $cmd = $ctrl->getCmd("edit");
52 
53  switch ($next_class) {
54  default:
55  if (in_array($cmd, ["edit", "saveOrder"])) {
56  $this->$cmd();
57  }
58  }
59  }
60 
61  protected function edit(): void
62  {
63  $mt = $this->gui->ui()->mainTemplate();
64  $r = $this->gui->ui()->renderer();
65  $mt->setContent($r->render($this->getTable()));
66  }
67 
68  protected function getTable(): Ordering
69  {
70  $f = $this->gui->ui()->factory();
71  $lng = $this->domain->lng();
72  $settings = $this->settings;
73  $ctrl = $this->gui->ctrl();
74 
75  $request = $this->gui->http()->request();
76 
77  $columns = [
78  'block' => $f->table()->column()->text($lng->txt("blog_side_blocks"))
79  ->withHighlight(true)
80  ];
81 
82  $actions = [];
83 
84  $data_retrieval = new class (
85  $settings,
86  $this->obj_id,
87  $this->in_repository
88  ) implements OrderingRetrieval {
89  protected array $records;
90 
91  public function __construct(
92  protected SettingsManager $settings,
93  protected int $blog_id,
94  protected bool $in_repository
95  ) {
96  }
97 
98  public function getRows(
99  OrderingRowBuilder $row_builder,
100  array $visible_column_ids
101  ): \Generator {
102  foreach ($this->settings->getOrderingOptions(
103  $this->settings->getByObjId(
104  $this->blog_id
105  ),
106  $this->in_repository
107  ) as $id => $option) {
108  yield $row_builder->buildOrderingRow(
109  $id,
110  ["block" => $option]
111  );
112  }
113  }
114  };
115 
116  $target = $ctrl->getLinkTargetByClass([self::class], "saveOrder");
117  $target = (new URI(ILIAS_HTTP_PATH . "/" . $target));
118  $table = $f->table()->ordering($data_retrieval, $target, $lng->txt("blog_nav_sortorder"), $columns)
119  ->withActions($actions)
120  ->withRequest($request);
121 
122  return $table;
123  }
124 
125  protected function saveOrder(): void
126  {
127  $mt = $this->gui->ui()->mainTemplate();
128  $lng = $this->domain->lng();
129  $ctrl = $this->gui->ctrl();
130 
131  $this->settings->saveOrder(
132  $this->obj_id,
133  $this->getTable()->getData()
134  );
135 
136  $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
137  $ctrl->redirectByClass(self::class, "edit");
138  }
139 }
__construct(protected InternalDataService $data, protected InternalDomainService $domain, protected InternalGUIService $gui, protected int $obj_id, protected bool $in_repository)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
global $lng
Definition: privfeed.php:31
$r