ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
class.ilDataCollectionRecordViewViewdefinitionGUI.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 require_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
5 require_once("./Modules/DataCollection/classes/class.ilDataCollectionRecordViewViewdefinition.php");
6 
19 
23  protected $obj_id;
27  protected $table_id;
31  public $ctrl;
32 
33 
38  public function __construct($table_id, $a_definition_id = 0) {
39  global $tpl, $ilCtrl;
43  $this->ctrl = $ilCtrl;
44 
45  //TODO Permission-Check
46  $this->table_id = $table_id;
47 
48  if (! $a_definition_id) {
49  $a_definition_id = ilDataCollectionRecordViewViewdefinition::getIdByTableId($this->table_id);
50  }
51 
52  // we always need a page object - create on demand
53  if (! $a_definition_id) {
55  $viewdef->setTableId($this->table_id);
56  $viewdef->setActive(false);
57  $viewdef->create();
58  $a_definition_id = $viewdef->getId();
59  }
60 
61  parent::__construct("dclf", $a_definition_id);
62  $this->getPageObject()->setTableId($this->table_id);
63 
64  // content style (using system defaults)
65  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
66 
67  $tpl->setCurrentBlock("SyntaxStyle");
68  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
69  $tpl->parseCurrentBlock();
70 
71  $tpl->setCurrentBlock("ContentStyle");
72  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
73  $tpl->parseCurrentBlock();
74  }
75 
76 
80  public function executeCommand() {
81  global $ilLocator, $lng;
82 
83  $next_class = $this->ctrl->getNextClass($this);
84 
85  $viewdef = $this->getPageObject();
86  if ($viewdef) {
87  $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
88  $title = $lng->txt("dcl_view_viewdefinition");
89  }
90 
91  switch ($next_class) {
92  case "ilpageobjectgui":
93  throw new ilCOPageException("Deprecated. ilDataCollectionRecordViewViewdefinitionGUI gui forwarding to ilpageobject");
94  default:
95  if ($viewdef) {
96  $this->setPresentationTitle($title);
97  $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
98  }
99 
100  return parent::executeCommand();
101  }
102  }
103 
104 
105  public function showPage() {
106  global $lng, $ilToolbar;
110  // :TODO: temporary legend of available placeholders
111  if ($this->getOutputMode() == IL_PAGE_EDIT) {
112  $delete_button = ilLinkButton::getInstance();
113  $delete_button->setCaption('dcl_empty_view');
114  $delete_button->setUrl($this->ctrl->getLinkTarget($this, 'confirmDelete'));
115  $ilToolbar->addButtonInstance($delete_button);
116 
117  $activation_button = ilLinkButton::getInstance();
118  if ($this->getPageObject()->getActive()) {
119  $activation_button->setCaption('dcl_deactivate_view');
120  $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'deactivate'));
121  } else {
122  $activation_button->setCaption('dcl_activate_view');
123  $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'activate'));
124  }
125 
126  $ilToolbar->addButtonInstance($activation_button);
127 
129  if (sizeof($legend)) {
130  $this->setPrependingHtml("<span class=\"small\">" . $this->lng->txt("dcl_legend_placeholders") . ": " . implode(" ", $legend)
131  . "</span>");
132  }
133  }
134 
135  return parent::showPage();
136  }
137 
138 
139  protected function activate() {
140  $page = $this->getPageObject();
141  $page->setActive(true);
142  $page->update();
143  $this->ctrl->redirect($this, 'edit');
144  }
145 
146 
147  protected function deactivate() {
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  global $ilCtrl, $lng, $tpl;
160 
161  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
162  $conf = new ilConfirmationGUI();
163  $conf->setFormAction($ilCtrl->getFormAction($this));
164  $conf->setHeaderText($lng->txt('dcl_confirm_delete_view_title'));
165 
166  $conf->addItem('table', (int)$this->table_id, $lng->txt('dcl_confirm_delete_view_text'));
167 
168  $conf->setConfirm($lng->txt('delete'), 'deleteView');
169  $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
170 
171  $tpl->setContent($conf->getHTML());
172  }
173 
174 
178  public function cancelDelete() {
179  global $ilCtrl;
180 
181  $ilCtrl->redirect($this, "edit");
182  }
183 
184 
185  public function deleteView() {
186  global $ilCtrl, $lng;
187 
188  if ($this->table_id && ilDataCollectionRecordViewViewdefinition::getIdByTableId($this->table_id)) {
190  include_once("./Modules/DataCollection/classes/class.ilDataCollectionRecordViewViewdefinition.php");
191  $pageObject = new ilDataCollectionRecordViewViewdefinition($id);
192  $pageObject->removeDclView($this->table_id);
193  $pageObject->delete();
194  }
195 
196  ilUtil::sendSuccess($lng->txt("dcl_empty_view_success"), true);
197 
198  $ilCtrl->redirectByClass("ilDataCollectionFieldListGUI", "listFields");
199  }
200 
205  function releasePageLock()
206  {
207  global $ilCtrl, $lng;
208 
209  $this->getPageObject()->releasePageLock();
210  ilUtil::sendSuccess($lng->txt("cont_page_lock_released"), true);
211  $ilCtrl->redirectByClass('ilDataCollectionFieldListGUI', "listFields");
212  }
213 
221  public function postOutputProcessing($a_output) {
222  // You can use this to parse placeholders and the like before outputting
223 
224  // user view (IL_PAGE_PRESENTATION?)
225  if ($this->getOutputMode() == IL_PAGE_PREVIEW) {
226  //page preview is not being used inside DataCollections - if you are here, something's probably wrong
227 
228 // include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
229 //
230 // // :TODO: find a suitable presentation for matched placeholders
231 // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
232 // foreach ($allp as $id => $item) {
233 // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
234 // $parsed_item = $parsed_item->getToolbarHTML();
235 //
236 // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
237 // }
238  } // editor
239  else {
240  if ($this->getOutputMode() == IL_PAGE_EDIT) {
242 
243  // :TODO: find a suitable markup for matched placeholders
244  foreach ($allp as $item) {
245  $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
246  }
247  }
248  }
249 
250  return $a_output;
251  }
252 }
253 
254 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
const IL_PAGE_PREVIEW
static getIdByTableId($a_table_id)
Get view definition id by table id.
getPageObject()
Get Page Object.
$legend
Class ilPageObjectGUI.
releasePageLock()
Release page lock overwrite to redirect properly.
getSyntaxStylePath()
get syntax style path
global $ilCtrl
Definition: ilias.php:18
setPrependingHtml($a_prependinghtml)
Set Prepending HTML.
setPresentationTitle($a_title="")
const IL_PAGE_EDIT
static getAvailablePlaceholders($a_table_id, $a_verbose=false)
Get all placeholders for table id.
getContentStylePath($a_style_id)
get content style path
showPage()
display content of page
Base exception class for copage service.
Confirmation screen class.