ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilPCAMDPageListGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once("./Modules/Wiki/classes/class.ilPCAMDPageList.php");
6require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
7
19{
24 function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id = "")
25 {
26 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
27 }
28
32 function executeCommand()
33 {
34 // get next class that processes or forwards current command
35 $next_class = $this->ctrl->getNextClass($this);
36
37 // get current command
38 $cmd = $this->ctrl->getCmd();
39
40 switch($next_class)
41 {
42 default:
43 $ret = $this->$cmd();
44 break;
45 }
46
47 return $ret;
48 }
49
55 function insert(ilPropertyFormGUI $a_form = null)
56 {
57 global $tpl;
58
60
61 if(!$a_form)
62 {
63 $a_form = $this->initForm(true);
64 }
65 $tpl->setContent($a_form->getHTML());
66 }
67
73 function edit(ilPropertyFormGUI $a_form = null)
74 {
75 global $tpl;
76
78
79 if(!$a_form)
80 {
81 $a_form = $this->initForm();
82 }
83 $tpl->setContent($a_form->getHTML());
84 }
85
92 protected function initForm($a_insert = false)
93 {
94 global $ilCtrl;
95
96 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
97 $form = new ilPropertyFormGUI();
98 $form->setFormAction($ilCtrl->getFormAction($this));
99 if ($a_insert)
100 {
101 $form->setTitle($this->lng->txt("cont_insert_amd_page_list"));
102 }
103 else
104 {
105 $form->setTitle($this->lng->txt("cont_update_amd_page_list"));
106 }
107 $form->setDescription($this->lng->txt("wiki_page_list_form_info"));
108
109 $mode = new ilSelectInputGUI($this->lng->txt("wiki_page_list_mode"), "mode");
110 $mode->setOptions(array(
111 0 => $this->lng->txt("wiki_page_list_mode_unordered"),
112 1 => $this->lng->txt("wiki_page_list_mode_ordered")
113 ));
114 $mode->setRequired(true);
115 $form->addItem($mode);
116
117 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
118 $this->record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_SEARCH,'wiki',$this->getPage()->getWikiId(),'wpg',$this->getPage()->getId());
119 $this->record_gui->setPropertyForm($form);
120
121 if (!$a_insert)
122 {
123 $mode->setValue($this->content_obj->getMode());
124 $this->record_gui->setSearchFormValues($this->content_obj->getFieldValues());
125 }
126
127 $this->record_gui->parse();
128
129 $no_fields = (count($form->getItems()) == 1);
130 if ($no_fields)
131 {
132 ilUtil::sendFailure($this->lng->txt("wiki_pg_list_no_search_fields"));
133 }
134
135 if ($a_insert)
136 {
137 if (!$no_fields)
138 {
139 $form->addCommandButton("create_amd_page_list", $this->lng->txt("select"));
140 }
141 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
142 }
143 else
144 {
145 if (!$no_fields)
146 {
147 $form->addCommandButton("update", $this->lng->txt("select"));
148 }
149 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
150 }
151
152 return $form;
153 }
154
158 function create()
159 {
160 $form = $this->initForm(true);
161 if($form->checkInput())
162 {
163 $elements = $this->record_gui->importSearchForm();
164 if(is_array($elements))
165 {
166 $this->content_obj = new ilPCAMDPageList($this->getPage());
167 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
168 $this->content_obj->setData($elements, $form->getInput("mode"));
169 $this->updated = $this->pg_obj->update();
170 if ($this->updated === true)
171 {
172 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
173 }
174 }
175 }
176
177 // $form->setValuesByPost();
178 return $this->insert($form);
179 }
180
184 function update()
185 {
186 $form = $this->initForm();
187 if($form->checkInput())
188 {
189 $elements = $this->record_gui->importSearchForm();
190 if(is_array($elements))
191 {
192 $this->content_obj->setData($elements, $form->getInput("mode"));
193 $this->updated = $this->pg_obj->update();
194 if ($this->updated === true)
195 {
196 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
197 }
198 }
199 }
200
201 $this->pg_obj->addHierIDs();
202 // $form->setValuesByPost();
203 return $this->edit($form);
204 }
205}
206
207?>
An exception for terminatinating execution or to throw for unit testing.
Class ilPCAMDPageListGUI.
create()
Create new courses.
executeCommand()
execute command
__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
insert(ilPropertyFormGUI $a_form=null)
Insert courses form.
edit(ilPropertyFormGUI $a_form=null)
Edit courses form.
initForm($a_insert=false)
Init courses form.
Class ilPCAMDPageList.
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.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35