ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDclDetailedViewDefinitionGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
16 {
17 
21  public $obj;
25  public $ctrl;
26 
27 
32  public function __construct($tableview_id, $a_definition_id = 0)
33  {
34  global $DIC;
35  $tpl = $DIC['tpl'];
36  $ilCtrl = $DIC['ilCtrl'];
40  $this->ctrl = $ilCtrl;
41  $this->tableview_id = $tableview_id;
42  //TODO Permission-Check
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($_GET['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  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
57 
58  $tpl->setCurrentBlock("SyntaxStyle");
59  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
60  $tpl->parseCurrentBlock();
61 
62  $tpl->setCurrentBlock("ContentStyle");
63  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
64  $tpl->parseCurrentBlock();
65  }
66 
67 
71  public function executeCommand()
72  {
73  global $DIC;
74  $ilLocator = $DIC['ilLocator'];
75  $lng = $DIC['lng'];
76 
77  $next_class = $this->ctrl->getNextClass($this);
78 
79  $viewdef = $this->getPageObject();
80  if ($viewdef) {
81  $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
82  $title = $lng->txt("dcl_view_viewdefinition");
83  }
84 
85  switch ($next_class) {
86  case "ilpageobjectgui":
87  throw new ilCOPageException("Deprecated. ilDclDetailedViewDefinitionGUI gui forwarding to ilpageobject");
88  default:
89  if ($viewdef) {
91  $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
92  }
93 
94  return parent::executeCommand();
95  }
96  }
97 
98 
99  public function showPage()
100  {
101  global $DIC;
102  $ilToolbar = $DIC['ilToolbar'];
106  // :TODO: temporary legend of available placeholders
107  if ($this->getOutputMode() == IL_PAGE_EDIT) {
108  $delete_button = ilLinkButton::getInstance();
109  $delete_button->setCaption('dcl_empty_detailed_view');
110  $delete_button->setUrl($this->ctrl->getLinkTarget($this, 'confirmDelete'));
111  $ilToolbar->addButtonInstance($delete_button);
112 
113  $activation_button = ilLinkButton::getInstance();
114  if ($this->getPageObject()->getActive()) {
115  $activation_button->setCaption('dcl_deactivate_view');
116  $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'deactivate'));
117  } else {
118  $activation_button->setCaption('dcl_activate_view');
119  $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'activate'));
120  }
121 
122  $ilToolbar->addButtonInstance($activation_button);
123 
124  $legend = $this->getPageObject()->getAvailablePlaceholders();
125  if (sizeof($legend)) {
126  $this->setPrependingHtml(
127  "<span class=\"small\">" . $this->lng->txt("dcl_legend_placeholders") . ": " . implode(" ", $legend)
128  . "</span>"
129  );
130  }
131  }
132 
133  return parent::showPage();
134  }
135 
136 
137  protected function activate()
138  {
139  $page = $this->getPageObject();
140  $page->setActive(true);
141  $page->update();
142  $this->ctrl->redirect($this, 'edit');
143  }
144 
145 
146  protected function deactivate()
147  {
148  $page = $this->getPageObject();
149  $page->setActive(false);
150  $page->update();
151  $this->ctrl->redirect($this, 'edit');
152  }
153 
154 
158  public function confirmDelete()
159  {
160  global $DIC;
161  $ilCtrl = $DIC['ilCtrl'];
162  $lng = $DIC['lng'];
163  $tpl = $DIC['tpl'];
164 
165  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
166  $conf = new ilConfirmationGUI();
167  $conf->setFormAction($ilCtrl->getFormAction($this));
168  $conf->setHeaderText($lng->txt('dcl_confirm_delete_detailed_view_title'));
169 
170  $conf->addItem('tableview', (int) $this->tableview_id, $lng->txt('dcl_confirm_delete_detailed_view_text'));
171 
172  $conf->setConfirm($lng->txt('delete'), 'deleteView');
173  $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
174 
175  $tpl->setContent($conf->getHTML());
176  }
177 
178 
182  public function cancelDelete()
183  {
184  global $DIC;
185  $ilCtrl = $DIC['ilCtrl'];
186 
187  $ilCtrl->redirect($this, "edit");
188  }
189 
190 
191  public function deleteView()
192  {
193  global $DIC;
194  $ilCtrl = $DIC['ilCtrl'];
195  $lng = $DIC['lng'];
196 
197  if ($this->tableview_id && ilDclDetailedViewDefinition::exists($this->tableview_id)) {
198  include_once("class.ilDclDetailedViewDefinition.php");
199  $pageObject = new ilDclDetailedViewDefinition($this->tableview_id);
200  $pageObject->delete();
201  }
202 
203  ilUtil::sendSuccess($lng->txt("dcl_empty_detailed_view_success"), true);
204 
205  // Bug fix for mantis 22537: Redirect to settings-tab instead of fields-tab. This solves the problem and is more intuitive.
206  $ilCtrl->redirectByClass("ilDclTableViewEditGUI", "editGeneralSettings");
207  }
208 
209 
214  public function releasePageLock()
215  {
216  global $DIC;
217  $ilCtrl = $DIC['ilCtrl'];
218  $lng = $DIC['lng'];
219 
220  $this->getPageObject()->releasePageLock();
221  ilUtil::sendSuccess($lng->txt("cont_page_lock_released"), true);
222  $ilCtrl->redirectByClass('ilDclTableViewGUI', "show");
223  }
224 
225 
233  public function postOutputProcessing($a_output)
234  {
235  // You can use this to parse placeholders and the like before outputting
236 
237  // user view (IL_PAGE_PRESENTATION?)
238  if ($this->getOutputMode() == IL_PAGE_PREVIEW) {
239  //page preview is not being used inside DataCollections - if you are here, something's probably wrong
240 
241  // include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
242  //
243  // // :TODO: find a suitable presentation for matched placeholders
244  // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
245  // foreach ($allp as $id => $item) {
246  // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
247  // $parsed_item = $parsed_item->getToolbarHTML();
248  //
249  // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
250  // }
251  } // editor
252  else {
253  if ($this->getOutputMode() == IL_PAGE_EDIT) {
254  $allp = $this->getPageObject()->getAvailablePlaceholders();
255 
256  // :TODO: find a suitable markup for matched placeholders
257  foreach ($allp as $item) {
258  $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
259  }
260  }
261  }
262 
263  return $a_output;
264  }
265 }
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
releasePageLock()
Release page lock overwrite to redirect properly.
const IL_PAGE_PREVIEW
getPageObject()
Get Page Object.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$legend
Class ilPageObjectGUI.
Class ilDclDetailedViewDefinitionGUI.
static _lookupObjectId($a_ref_id)
global $ilCtrl
Definition: ilias.php:18
setPrependingHtml($a_prependinghtml)
Set Prepending HTML.
setPresentationTitle($a_title="")
static getSyntaxStylePath()
get syntax style path
const IL_PAGE_EDIT
static getContentStylePath($a_style_id, $add_random=true)
get content style path
__construct( $a_parent_type, $a_id, $a_old_nr=0, $a_prevent_get_id=false, $a_lang="")
Constructor.
showPage()
display content of page
postOutputProcessing($a_output)
Finalizing output processing.
Base exception class for copage service.
Confirmation screen class.
Class ilDclDetailedViewDefinition.