ILIAS  release_4-4 Revision
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  {
46  $viewdef->setTableId($this->table_id);
47  $viewdef->create();
48  $a_definition_id = $viewdef->getId();
49  }
50 
51  parent::__construct("dclf", $a_definition_id);
52  $this->getPageObject()->setTableId($this->table_id);
53 
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  }
69 
73  public function executeCommand()
74  {
75  global $ilCtrl, $ilLocator, $tpl, $lng;
76 
77  $next_class = $ilCtrl->getNextClass($this);
78  $cmd = $ilCtrl->getCmd();
79 
80  $viewdef = $this->getPageObject();
81  if($viewdef)
82  {
83  $ilCtrl->setParameter($this, "dclv", $viewdef->getId());
84  $title = $lng->txt("dcl_view_viewdefinition");
85  }
86 
87  switch($next_class)
88  {
89  case "ilpageobjectgui":
90  die("Deprecated. ilDataCollectionRecordViewViewdefinitionGUI gui forwarding to ilpageobject");
91  return;
92 
93  default:
94  if($viewdef)
95  {
96  $this->setPresentationTitle($title);
97  // $tpl->setTitle($title);
98 
99  $ilLocator->addItem($title,
100  $ilCtrl->getLinkTarget($this, "preview"));
101  }
102  return parent::executeCommand();
103  }
104  }
105 
106  public function showPage()
107  {
108  global $ilCtrl, $lng;
109  // :TODO: temporary legend of available placeholders
110  if($this->getOutputMode() == IL_PAGE_EDIT)
111  {
113  if(sizeof($legend))
114  {
115  $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").
116  ": ".implode(" ", $legend)."</span>");
117  }
118  }
119 
120  return parent::showPage();
121  }
122 
126  public function confirmDelete()
127  {
128  global $ilCtrl, $lng, $tpl;
129 
130  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
131  $conf = new ilConfirmationGUI();
132  $conf->setFormAction($ilCtrl->getFormAction($this));
133  $conf->setHeaderText($lng->txt('dcl_confirm_delete_view_title'));
134 
135  $conf->addItem('table', (int) $this->table_id, $lng->txt('dcl_confirm_delete_view_text'));
136 
137  $conf->setConfirm($lng->txt('delete'), 'deleteView');
138  $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
139 
140  $tpl->setContent($conf->getHTML());
141  }
142 
146  public function cancelDelete()
147  {
148  global $ilCtrl;
149 
150  $ilCtrl->redirect($this, "edit");
151  }
152 
153  public function deleteView(){
154  global $ilCtrl, $lng;
155 
156  if($this->table_id && ilDataCollectionRecordViewViewdefinition::getIdByTableId($this->table_id)){
157  global $ilDB;
159  include_once("./Modules/DataCollection/classes/class.ilDataCollectionRecordViewViewdefinition.php");
160  $pageObject = new ilDataCollectionRecordViewViewdefinition($id);
161  $pageObject->delete();
162 
163  $query = "DELETE FROM il_dcl_view WHERE table_id = ".$this->table_id." AND type = ".$ilDB->quote(0, "integer")." AND formtype = ".$ilDB->quote(0, "integer");
164  $ilDB->manipulate($query);
165  }
166 
167  ilUtil::sendSuccess($lng->txt("dcl_empty_view_success"), true);
168 
169  $ilCtrl->redirectByClass("ilDataCollectionFieldListGUI", "listFields");
170  }
171 
178  public function postOutputProcessing($a_output)
179  {
180  // You can use this to parse placeholders and the like before outputting
181 
182  // user view (IL_PAGE_PRESENTATION?)
183  if($this->getOutputMode() == IL_PAGE_PREVIEW)
184  {
185  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
186 
187  // :TODO: find a suitable presentation for matched placeholders
189  foreach($allp as $id => $item)
190  {
191  $parsed_item = new ilTextInputGUI("", "fields[".$item->getId()."]");
192  $parsed_item = $parsed_item->getToolbarHTML();
193 
194  $a_output = str_replace($id, $item->getTitle().": ".$parsed_item, $a_output);
195  }
196  }
197  // editor
198  else if($this->getOutputMode() == IL_PAGE_EDIT)
199  {
201 
202  // :TODO: find a suitable markup for matched placeholders
203  foreach($allp as $item)
204  {
205  $a_output = str_replace($item, "<span style=\"color:green\">".$item."</span>", $a_output);
206  }
207  }
208 
209  return $a_output;
210  }
211 }
212 
213 ?>
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.
Class ilPageObjectGUI.
$cmd
Definition: sahs_server.php:35
getSyntaxStylePath()
get syntax style path
global $ilCtrl
Definition: ilias.php:18
setPrependingHtml($a_prependinghtml)
Set Prepending HTML.
This class represents a text property in a property form.
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
Confirmation screen class.