ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 
17 {
18 
22  public $obj;
26  public $ctrl;
27 
28 
33  public function __construct($tableview_id, $a_definition_id = 0)
34  {
35  global $DIC;
36  $tpl = $DIC['tpl'];
37  $ilCtrl = $DIC['ilCtrl'];
41  $this->ctrl = $ilCtrl;
42  $this->tableview_id = $tableview_id;
43  //TODO Permission-Check
44 
45  // we always need a page object - create on demand
46  if (!ilPageObject::_exists('dclf', $tableview_id)) {
47  $viewdef = new ilDclDetailedViewDefinition();
48  $viewdef->setId($tableview_id);
49  $viewdef->setParentId(ilObject2::_lookupObjectId($_GET['ref_id']));
50  $viewdef->setActive(false);
51  $viewdef->create();
52  }
53 
54  parent::__construct("dclf", $tableview_id);
55 
56  // content style (using system defaults)
57  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
58 
59  $tpl->setCurrentBlock("SyntaxStyle");
60  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
61  $tpl->parseCurrentBlock();
62 
63  $tpl->setCurrentBlock("ContentStyle");
64  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
65  $tpl->parseCurrentBlock();
66  }
67 
68 
72  public function executeCommand()
73  {
74  global $DIC;
75  $ilLocator = $DIC['ilLocator'];
76  $lng = $DIC['lng'];
77 
78  $next_class = $this->ctrl->getNextClass($this);
79 
80  $viewdef = $this->getPageObject();
81  if ($viewdef) {
82  $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
83  $title = $lng->txt("dcl_view_viewdefinition");
84  }
85 
86  switch ($next_class) {
87  case "ilpageobjectgui":
88  throw new ilCOPageException("Deprecated. ilDclDetailedViewDefinitionGUI gui forwarding to ilpageobject");
89  default:
90  if ($viewdef) {
92  $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
93  }
94 
95  return parent::executeCommand();
96  }
97  }
98 
99 
100  public function showPage()
101  {
102  global $DIC;
103  $ilToolbar = $DIC['ilToolbar'];
107  // :TODO: temporary legend of available placeholders
108  if ($this->getOutputMode() == IL_PAGE_EDIT) {
109  $delete_button = ilLinkButton::getInstance();
110  $delete_button->setCaption('dcl_empty_detailed_view');
111  $delete_button->setUrl($this->ctrl->getLinkTarget($this, 'confirmDelete'));
112  $ilToolbar->addButtonInstance($delete_button);
113 
114  $activation_button = ilLinkButton::getInstance();
115  if ($this->getPageObject()->getActive()) {
116  $activation_button->setCaption('dcl_deactivate_view');
117  $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'deactivate'));
118  } else {
119  $activation_button->setCaption('dcl_activate_view');
120  $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'activate'));
121  }
122 
123  $ilToolbar->addButtonInstance($activation_button);
124 
125  $legend = $this->getPageObject()->getAvailablePlaceholders();
126  if (sizeof($legend)) {
127  $this->setPrependingHtml("<span class=\"small\">" . $this->lng->txt("dcl_legend_placeholders") . ": " . implode(" ", $legend)
128  . "</span>");
129  }
130  }
131 
132  return parent::showPage();
133  }
134 
135 
136  protected function activate()
137  {
138  $page = $this->getPageObject();
139  $page->setActive(true);
140  $page->update();
141  $this->ctrl->redirect($this, 'edit');
142  }
143 
144 
145  protected function deactivate()
146  {
147  $page = $this->getPageObject();
148  $page->setActive(false);
149  $page->update();
150  $this->ctrl->redirect($this, 'edit');
151  }
152 
153 
157  public function confirmDelete()
158  {
159  global $DIC;
160  $ilCtrl = $DIC['ilCtrl'];
161  $lng = $DIC['lng'];
162  $tpl = $DIC['tpl'];
163 
164  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
165  $conf = new ilConfirmationGUI();
166  $conf->setFormAction($ilCtrl->getFormAction($this));
167  $conf->setHeaderText($lng->txt('dcl_confirm_delete_detailed_view_title'));
168 
169  $conf->addItem('tableview', (int) $this->tableview_id, $lng->txt('dcl_confirm_delete_detailed_view_text'));
170 
171  $conf->setConfirm($lng->txt('delete'), 'deleteView');
172  $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
173 
174  $tpl->setContent($conf->getHTML());
175  }
176 
177 
181  public function cancelDelete()
182  {
183  global $DIC;
184  $ilCtrl = $DIC['ilCtrl'];
185 
186  $ilCtrl->redirect($this, "edit");
187  }
188 
189 
190  public function deleteView()
191  {
192  global $DIC;
193  $ilCtrl = $DIC['ilCtrl'];
194  $lng = $DIC['lng'];
195 
196  if ($this->tableview_id && ilDclDetailedViewDefinition::exists($this->tableview_id)) {
197  include_once("class.ilDclDetailedViewDefinition.php");
198  $pageObject = new ilDclDetailedViewDefinition($this->tableview_id);
199  $pageObject->delete();
200  }
201 
202  ilUtil::sendSuccess($lng->txt("dcl_empty_detailed_view_success"), true);
203 
204  // Bug fix for mantis 22537: Redirect to settings-tab instead of fields-tab. This solves the problem and is more intuitive.
205  $ilCtrl->redirectByClass("ilDclTableViewEditGUI", "editGeneralSettings");
206  }
207 
212  public function releasePageLock()
213  {
214  global $DIC;
215  $ilCtrl = $DIC['ilCtrl'];
216  $lng = $DIC['lng'];
217 
218  $this->getPageObject()->releasePageLock();
219  ilUtil::sendSuccess($lng->txt("cont_page_lock_released"), true);
220  $ilCtrl->redirectByClass('ilDclTableViewGUI', "show");
221  }
222 
230  public function postOutputProcessing($a_output)
231  {
232  // You can use this to parse placeholders and the like before outputting
233 
234  // user view (IL_PAGE_PRESENTATION?)
235  if ($this->getOutputMode() == IL_PAGE_PREVIEW) {
236  //page preview is not being used inside DataCollections - if you are here, something's probably wrong
237 
238 // include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
239 //
240 // // :TODO: find a suitable presentation for matched placeholders
241 // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
242 // foreach ($allp as $id => $item) {
243 // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
244 // $parsed_item = $parsed_item->getToolbarHTML();
245 //
246 // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
247 // }
248  } // editor
249  else {
250  if ($this->getOutputMode() == IL_PAGE_EDIT) {
251  $allp = $this->getPageObject()->getAvailablePlaceholders();
252 
253  // :TODO: find a suitable markup for matched placeholders
254  foreach ($allp as $item) {
255  $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
256  }
257  }
258  }
259 
260  return $a_output;
261  }
262 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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"]
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.