ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilDclDetailedViewDefinitionGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
28  protected int $tableview_id;
31 
32  public function __construct(int $tableview_id)
33  {
34  global $DIC;
35 
36  $this->tableview_id = $tableview_id;
37  $this->http = $DIC->http();
38  $this->refinery = $DIC->refinery();
39  $this->locator = $DIC['ilLocator'];
40 
41  $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
42  $this->setStyleId($DIC->contentStyle()->domain()->styleForRefId($ref_id)->getEffectiveStyleId());
43 
44  // we always need a page object - create on demand
45  if (!ilPageObject::_exists('dclf', $tableview_id)) {
46  $viewdef = new ilDclDetailedViewDefinition();
47  $viewdef->setId($tableview_id);
48  $viewdef->setParentId(ilObject2::_lookupObjectId($ref_id));
49  $viewdef->setActive(false);
50  $viewdef->create();
51  }
52 
53  parent::__construct("dclf", $tableview_id);
54 
55  // content style (using system defaults)
56  $this->tpl->setCurrentBlock("SyntaxStyle");
57  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
58  $this->tpl->parseCurrentBlock();
59 
60  $this->tpl->setCurrentBlock("ContentStyle");
61  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
62  $this->tpl->parseCurrentBlock();
63  }
64 
68  public function executeCommand(): string
69  {
70  $next_class = $this->ctrl->getNextClass($this);
71 
72  $viewdef = $this->getPageObject();
73  $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
74  $title = $this->lng->txt("dcl_view_viewdefinition");
75 
76  switch ($next_class) {
77  case "ilpageobjectgui":
78  throw new ilCOPageException("Deprecated. ilDclDetailedViewDefinitionGUI gui forwarding to ilpageobject");
79  default:
80  $this->setPresentationTitle($title);
81  $this->locator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
82 
83  return parent::executeCommand();
84  }
85  }
86 
87  public function showPage(): string
88  {
89  $this->tpl->addCss(ilObjStyleSheet::getContentStylePath($this->getStyleId()));
90  if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
91  $delete_button = $this->ui->factory()->button()->standard(
92  $this->lng->txt('dcl_empty_detailed_view'),
93  $this->ctrl->getLinkTarget($this, 'confirmDelete')
94  );
95  $this->toolbar->addComponent($delete_button);
96 
97  if ($this->getPageObject()->getActive()) {
98  $activation_button = $this->ui->factory()->button()->standard(
99  $this->lng->txt('dcl_deactivate_view'),
100  $this->ctrl->getLinkTarget($this, 'deactivate')
101  );
102  } else {
103  $activation_button = $this->ui->factory()->button()->standard(
104  $this->lng->txt('dcl_activate_view'),
105  $this->ctrl->getLinkTarget($this, 'activate')
106  );
107  }
108 
109  $this->toolbar->addComponent($activation_button);
110 
111  $legend = $this->getPageObject()->getAvailablePlaceholders();
112  if (sizeof($legend)) {
113  $this->setPrependingHtml(
114  "<span class=\"small\">" . $this->lng->txt("dcl_legend_placeholders") . ": " . implode(" ", $legend)
115  . "</span>"
116  );
117  }
118  }
119 
120  return parent::showPage();
121  }
122 
123  protected function activate(): void
124  {
125  $page = $this->getPageObject();
126  $page->setActive(true);
127  $page->update();
128  $this->ctrl->redirect($this, 'edit');
129  }
130 
131  protected function deactivate(): void
132  {
133  $page = $this->getPageObject();
134  $page->setActive(false);
135  $page->update();
136  $this->ctrl->redirect($this, 'edit');
137  }
138 
139  public function confirmDelete(): void
140  {
141  $conf = new ilConfirmationGUI();
142  $conf->setFormAction($this->ctrl->getFormAction($this));
143  $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_detailed_view_title'));
144 
145  $conf->addItem('tableview', (string) $this->tableview_id, $this->lng->txt('dcl_confirm_delete_detailed_view_text'));
146 
147  $conf->setConfirm($this->lng->txt('delete'), 'deleteView');
148  $conf->setCancel($this->lng->txt('cancel'), 'cancelDelete');
149 
150  $this->tpl->setContent($conf->getHTML());
151  }
152 
153  public function cancelDelete(): void
154  {
155  $this->ctrl->redirect($this, "edit");
156  }
157 
158  public function deleteView(): void
159  {
160  if ($this->tableview_id && ilDclDetailedViewDefinition::exists($this->tableview_id)) {
161  $pageObject = new ilDclDetailedViewDefinition($this->tableview_id);
162  $pageObject->delete();
163  }
164 
165  $this->tpl->setOnScreenMessage('success', $this->lng->txt("dcl_empty_detailed_view_success"), true);
166  $this->ctrl->redirectByClass(self::class, "edit");
167  }
168 
172  public function postOutputProcessing(string $a_output): string
173  {
174  // You can use this to parse placeholders and the like before outputting
175 
176  if ($this->getOutputMode() == ilPageObjectGUI::PREVIEW) {
177  //page preview is not being used inside DataCollections - if you are here, something's probably wrong
178 
179  //
180  // // :TODO: find a suitable presentation for matched placeholders
181  // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
182  // foreach ($allp as $id => $item) {
183  // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
184  // $parsed_item = $parsed_item->getToolbarHTML();
185  //
186  // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
187  // }
188  } // editor
189  else {
190  if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
191  $allp = $this->getPageObject()->getAvailablePlaceholders();
192 
193  // :TODO: find a suitable markup for matched placeholders
194  foreach ($allp as $item) {
195  $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
196  }
197  }
198  }
199 
200  return $a_output;
201  }
202 }
Class ilPageObjectGUI.
ilDclDetailedViewDefinitionGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector ilDcl...
setStyleId(int $a_styleid)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
static http()
Fetches the global http state from ILIAS.
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
global $DIC
Definition: shib_login.php:25
static _lookupObjectId(int $ref_id)
postOutputProcessing(string $a_output)
Finalizing output processing.
setPresentationTitle(string $a_title="")
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
__construct(Container $dic, ilPlugin $plugin)
setPrependingHtml(string $a_prependinghtml)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...