ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 {
20  protected $obj_id; // [int]
21  protected $table_id; // [int]
22 
30  public function __construct($table_id, $a_definition_id = 0)
31  {
32  global $tpl;
33 
34  //TODO Permission-Check
35  $this->table_id = $table_id;
36 
37  if(!$a_definition_id)
38  {
39  $a_definition_id = ilDataCollectionRecordViewViewdefinition::getIdByTableId($this->table_id);
40  }
41 
42  // we always need a page object - create on demand
43  if(!$a_definition_id)
44  {
45 
46 
47  $viewdef = new ilDataCollectionRecordViewViewdefinition(0, $this->table_id);
48  $viewdef->create();
49  $a_definition_id = $viewdef->getId();
50 
51  }
52 
53  parent::__construct("dclf", $a_definition_id);
54 
55  // content style (using system defaults)
56  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
57 
58  $tpl->setCurrentBlock("SyntaxStyle");
59  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
61  $tpl->parseCurrentBlock();
62 
63  $tpl->setCurrentBlock("ContentStyle");
64  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
66  $tpl->parseCurrentBlock();
67 
68  // config
69  $this->setPreventHTMLUnmasking(true);
70  $this->setEnabledPCTabs(true);
71  $this->setEnabledMaps(false);
72  $this->setEnabledInternalLinks(false);
73  $this->setEnabledWikiLinks(false);
74  $this->setEnabledActivation(false);
75  }
76 
84  public function initPageObject($a_parent_type, $a_id, $a_old_nr)
85  {
86  $this->setPageObject(new ilDataCollectionRecordViewViewdefinition($a_id, $this->table_id));
87  }
88 
92  public function executeCommand()
93  {
94  global $ilCtrl, $ilLocator, $tpl, $lng;
95 
96  $next_class = $ilCtrl->getNextClass($this);
97  $cmd = $ilCtrl->getCmd();
98 
99  $viewdef = $this->getPageObject();
100  if($viewdef)
101  {
102  $ilCtrl->setParameter($this, "dclv", $viewdef->getId());
103  $title = $lng->txt("dcl_view_viewdefinition");
104  }
105 
106  switch($next_class)
107  {
108  case "ilpageobjectgui":
109  $page_gui = new ilPageObjectGUI("dclf",
110  $this->getPageObject()->getId(),
111  $this->getPageObject()->old_nr);
112  if($viewdef)
113  {
115  }
116  return $ilCtrl->forwardCommand($page_gui);
117 
118  default:
119  if($viewdef)
120  {
121  $this->setPresentationTitle($title);
122  // $tpl->setTitle($title);
123 
124  $ilLocator->addItem($title,
125  $ilCtrl->getLinkTarget($this, "preview"));
126  }
127  return parent::executeCommand();
128  }
129  }
130 
131  public function showPage()
132  {
133  global $ilCtrl, $lng;
134  // :TODO: temporary legend of available placeholders
135  if($this->getOutputMode() == IL_PAGE_EDIT)
136  {
138  if(sizeof($legend))
139  {
140  $this->setPrependingHtml(" <form action=".$ilCtrl->getFormAction($this, "confirmDelete")." method='post'> <input class='submit' type='submit' value='".$lng->txt("dcl_empty_view")."'></form> <span class=\"small\">".$this->lng->txt("dcl_legend_placeholders").
141  ": ".implode(" ", $legend)."</span>");
142  }
143  }
144 
145  return parent::showPage();
146  }
147 
151  public function confirmDelete()
152  {
153  global $ilCtrl, $lng, $tpl;
154 
155  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
156  $conf = new ilConfirmationGUI();
157  $conf->setFormAction($ilCtrl->getFormAction($this));
158  $conf->setHeaderText($lng->txt('dcl_confirm_delete_view_title'));
159 
160  $conf->addItem('table', (int) $this->table_id, $lng->txt('dcl_confirm_delete_view_text'));
161 
162  $conf->setConfirm($lng->txt('delete'), 'deleteView');
163  $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
164 
165  $tpl->setContent($conf->getHTML());
166  }
167 
171  public function cancelDelete()
172  {
173  global $ilCtrl;
174 
175  $ilCtrl->redirect($this, "edit");
176  }
177 
178  public function deleteView(){
179  global $ilCtrl, $lng;
180 
181  if($this->table_id && ilDataCollectionRecordViewViewdefinition::getIdByTableId($this->table_id)){
182  global $ilDB;
184  $pageObject = new ilPageObject("dclf", $id);
185  $pageObject->delete();
186 
187  $query = "DELETE FROM il_dcl_view WHERE table_id = ".$this->table_id." AND type = ".$ilDB->quote(0, "integer")." AND formtype = ".$ilDB->quote(0, "integer");
188  $ilDB->manipulate($query);
189  }
190 
191  ilUtil::sendSuccess($lng->txt("dcl_empty_view_success"), true);
192 
193  $ilCtrl->redirectByClass("ilDataCollectionFieldListGUI", "listFields");
194  }
195 
202  public function postOutputProcessing($a_output)
203  {
204  // You can use this to parse placeholders and the like before outputting
205 
206  // user view (IL_PAGE_PRESENTATION?)
207  if($this->getOutputMode() == IL_PAGE_PREVIEW)
208  {
209  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
210 
211  // :TODO: find a suitable presentation for matched placeholders
213  foreach($allp as $id => $item)
214  {
215  $parsed_item = new ilTextInputGUI("", "fields[".$item->getId()."]");
216  $parsed_item = $parsed_item->getToolbarHTML();
217 
218  $a_output = str_replace($id, $item->getTitle().": ".$parsed_item, $a_output);
219  }
220  }
221  // editor
222  else if($this->getOutputMode() == IL_PAGE_EDIT)
223  {
225 
226  // :TODO: find a suitable markup for matched placeholders
227  foreach($allp as $item)
228  {
229  $a_output = str_replace($item, "<span style=\"color:green\">".$item."</span>", $a_output);
230  }
231  }
232 
233  return $a_output;
234  }
235 }
236 
237 ?>