ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPCVerificationGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 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
24require_once("./Services/COPage/classes/class.ilPCVerification.php");
25require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
26
38{
42 protected $user;
43
44
49 public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
50 {
51 global $DIC;
52
53 $this->tpl = $DIC["tpl"];
54 $this->ctrl = $DIC->ctrl();
55 $this->user = $DIC->user();
56 $this->lng = $DIC->language();
57 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
58 }
59
63 public function executeCommand()
64 {
65 // get next class that processes or forwards current command
66 $next_class = $this->ctrl->getNextClass($this);
67
68 // get current command
69 $cmd = $this->ctrl->getCmd();
70
71 switch ($next_class) {
72 default:
73 $ret = $this->$cmd();
74 break;
75 }
76
77 return $ret;
78 }
79
85 public function insert(ilPropertyFormGUI $a_form = null)
86 {
88
90
91 if (!$a_form) {
92 $a_form = $this->initForm(true);
93 }
94 $tpl->setContent($a_form->getHTML());
95 }
96
102 public function edit(ilPropertyFormGUI $a_form = null)
103 {
105
106 $this->displayValidationError();
107
108 if (!$a_form) {
109 $a_form = $this->initForm();
110 }
111 $tpl->setContent($a_form->getHTML());
112 }
113
120 protected function initForm($a_insert = false)
121 {
125
126 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
127 $form = new ilPropertyFormGUI();
128 $form->setFormAction($ilCtrl->getFormAction($this));
129 if ($a_insert) {
130 $form->setTitle($this->lng->txt("cont_insert_verification"));
131 } else {
132 $form->setTitle($this->lng->txt("cont_update_verification"));
133 }
134
135 $lng->loadLanguageModule("wsp");
136 $options = array();
137 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
138 $tree = new ilWorkspaceTree($ilUser->getId());
139 $root = $tree->getRootId();
140 if ($root) {
141 $root = $tree->getNodeData($root);
142 foreach ($tree->getSubTree($root) as $node) {
143 if (in_array($node["type"], array("excv", "tstv", "crsv", "scov"))) {
144 $options[$node["obj_id"]] = $node["title"] . " (" . $lng->txt("wsp_type_" . $node["type"]) . ")";
145 }
146 }
147 asort($options);
148 }
149 $obj = new ilSelectInputGUI($this->lng->txt("cont_verification_object"), "object");
150 $obj->setRequired(true);
151 $obj->setOptions($options);
152 $form->addItem($obj);
153
154 if ($a_insert) {
155 $form->addCommandButton("create_verification", $this->lng->txt("save"));
156 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
157 } else {
158 $data = $this->content_obj->getData();
159 $obj->setValue($data["id"]);
160
161 $form->addCommandButton("update", $this->lng->txt("save"));
162 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
163 }
164
165 return $form;
166 }
167
171 public function create()
172 {
173 $form = $this->initForm(true);
174 if ($form->checkInput()) {
175 $type = ilObject::_lookupType($form->getInput("object"));
176 if ($type) {
177 $this->content_obj = new ilPCVerification($this->getPage());
178 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
179 $this->content_obj->setData($type, $form->getInput("object"));
180 $this->updated = $this->pg_obj->update();
181 if ($this->updated === true) {
182 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
183 }
184 }
185 }
186
187 $this->insert($form);
188 }
189
193 public function update()
194 {
195 $form = $this->initForm(true);
196 if ($form->checkInput()) {
197 $type = ilObject::_lookupType($form->getInput("object"));
198 if ($type) {
199 $this->content_obj->setData($type, $form->getInput("object"));
200 $this->updated = $this->pg_obj->update();
201 if ($this->updated === true) {
202 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
203 }
204 }
205 }
206
207 $this->pg_obj->addHierIDs();
208 $this->edit($form);
209 }
210}
user()
Definition: user.php:4
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
An exception for terminatinating execution or to throw for unit testing.
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilPCVerificationGUI.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
insert(ilPropertyFormGUI $a_form=null)
Insert new verification form.
update()
Update verification.
edit(ilPropertyFormGUI $a_form=null)
Edit verification form.
initForm($a_insert=false)
Init verification form.
create()
Create new verification.
Class ilPCVerification.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
displayValidationError()
display validation errors
This class represents a property form user interface.
This class represents a selection list property in a property form.
Tree handler for personal workspace.
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$type
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18