ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCSectionGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/COPage/classes/class.ilPCSection.php");
25 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
26 
38 {
39 
44  function ilPCSectionGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
45  {
46  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
47  }
48 
52  function &executeCommand()
53  {
54  // get next class that processes or forwards current command
55  $next_class = $this->ctrl->getNextClass($this);
56 
57  // get current command
58  $cmd = $this->ctrl->getCmd();
59 
60  switch($next_class)
61  {
62  default:
63  $ret =& $this->$cmd();
64  break;
65  }
66 
67  return $ret;
68  }
69 
73  function insert()
74  {
75  $this->edit(true);
76  }
77 
81  function edit($a_insert = false)
82  {
83  global $ilCtrl, $tpl, $lng;
84 
85  $this->displayValidationError();
86 
87  // edit form
88  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
89  $form = new ilPropertyFormGUI();
90  $form->setFormAction($ilCtrl->getFormAction($this));
91  if ($a_insert)
92  {
93  $form->setTitle($this->lng->txt("cont_insert_section"));
94  }
95  else
96  {
97  $form->setTitle($this->lng->txt("cont_update_section"));
98  }
99 
100  // characteristic selection
101  require_once("./Services/Form/classes/class.ilRadioMatrixInputGUI.php");
102  $char_prop = new ilRadioMatrixInputGUI($this->lng->txt("cont_characteristic"),
103  "characteristic");
104  $chars = array("ilc_Block" => $this->lng->txt("cont_Block"),
105  "ilc_Mnemonic" => $this->lng->txt("cont_Mnemonic"),
106  "ilc_Remark" => $this->lng->txt("cont_Remark"),
107  "ilc_Example" => $this->lng->txt("cont_Example"),
108  "ilc_Additional" => $this->lng->txt("cont_Additional"),
109  "ilc_Special" => $this->lng->txt("cont_Special"),
110  "ilc_Excursus" => $this->lng->txt("cont_Excursus"));
111  $selected = ($a_insert)
112  ? "ilc_Block"
113  : $this->content_obj->getCharacteristic();
114 
115  foreach($chars as $k => $char)
116  {
117  $chars[$k] = '<div class="'.$k.'">'.
118  $char.'</div>';
119  }
120 
121  $char_prop->setValue($selected);
122  $char_prop->setOptions($chars);
123  $form->addItem($char_prop);
124 
125  // save/cancel buttons
126  if ($a_insert)
127  {
128  $form->addCommandButton("create_section", $lng->txt("save"));
129  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
130  }
131  else
132  {
133  $form->addCommandButton("update_section", $lng->txt("save"));
134  $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
135  }
136  $html = $form->getHTML();
137  $tpl->setContent($html);
138  return $ret;
139 
140  }
141 
142 
146  function create()
147  {
148  $this->content_obj = new ilPCSection($this->dom);
149  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
150  $this->content_obj->setCharacteristic($_POST["characteristic"]);
151  $this->updated = $this->pg_obj->update();
152  if ($this->updated === true)
153  {
154  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
155  }
156  else
157  {
158  $this->insert();
159  }
160  }
161 
165  function update()
166  {
167  $this->content_obj->setCharacteristic($_POST["characteristic"]);
168  $this->updated = $this->pg_obj->update();
169  if ($this->updated === true)
170  {
171  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
172  }
173  else
174  {
175  $this->pg_obj->addHierIDs();
176  $this->edit();
177  }
178  }
179 }
180 ?>