ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 public function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id = "")
25 {
26 global $DIC;
27
28 $this->tpl = $DIC["tpl"];
29 $this->ctrl = $DIC->ctrl();
30 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
31 }
32
36 public function executeCommand()
37 {
38 // get next class that processes or forwards current command
39 $next_class = $this->ctrl->getNextClass($this);
40
41 // get current command
42 $cmd = $this->ctrl->getCmd();
43
44 switch ($next_class) {
45 default:
46 $ret = $this->$cmd();
47 break;
48 }
49
50 return $ret;
51 }
52
58 public function insert(ilPropertyFormGUI $a_form = null)
59 {
61
63
64 if (!$a_form) {
65 $a_form = $this->initForm(true);
66 }
67 $tpl->setContent($a_form->getHTML());
68 }
69
75 public function edit(ilPropertyFormGUI $a_form = null)
76 {
78
80
81 if (!$a_form) {
82 $a_form = $this->initForm();
83 }
84 $tpl->setContent($a_form->getHTML());
85 }
86
93 protected function initForm($a_insert = false)
94 {
96
97 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
98 $form = new ilPropertyFormGUI();
99 $form->setFormAction($ilCtrl->getFormAction($this));
100 if ($a_insert) {
101 $form->setTitle($this->lng->txt("cont_insert_amd_page_list"));
102 } else {
103 $form->setTitle($this->lng->txt("cont_update_amd_page_list"));
104 }
105 $form->setDescription($this->lng->txt("wiki_page_list_form_info"));
106
107 $mode = new ilSelectInputGUI($this->lng->txt("wiki_page_list_mode"), "mode");
108 $mode->setOptions(array(
109 0 => $this->lng->txt("wiki_page_list_mode_unordered"),
110 1 => $this->lng->txt("wiki_page_list_mode_ordered")
111 ));
112 $mode->setRequired(true);
113 $form->addItem($mode);
114
115 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
116 $this->record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_SEARCH, 'wiki', $this->getPage()->getWikiId(), 'wpg', $this->getPage()->getId());
117 $this->record_gui->setPropertyForm($form);
118
119 if (!$a_insert) {
120 $mode->setValue($this->content_obj->getMode());
121 $this->record_gui->setSearchFormValues($this->content_obj->getFieldValues());
122 }
123
124 $this->record_gui->parse();
125
126 $no_fields = (count($form->getItems()) == 1);
127 if ($no_fields) {
128 ilUtil::sendFailure($this->lng->txt("wiki_pg_list_no_search_fields"));
129 }
130
131 if ($a_insert) {
132 if (!$no_fields) {
133 $form->addCommandButton("create_amd_page_list", $this->lng->txt("select"));
134 }
135 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
136 } else {
137 if (!$no_fields) {
138 $form->addCommandButton("update", $this->lng->txt("select"));
139 }
140 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
141 }
142
143 return $form;
144 }
145
149 public function create()
150 {
151 $form = $this->initForm(true);
152 if ($form->checkInput()) {
153 $elements = $this->record_gui->importSearchForm();
154 if (is_array($elements)) {
155 $this->content_obj = new ilPCAMDPageList($this->getPage());
156 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
157 $this->content_obj->setData($elements, $form->getInput("mode"));
158 $this->updated = $this->pg_obj->update();
159 if ($this->updated === true) {
160 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
161 }
162 }
163 }
164
165 // $form->setValuesByPost();
166 return $this->insert($form);
167 }
168
172 public function update()
173 {
174 $form = $this->initForm();
175 if ($form->checkInput()) {
176 $elements = $this->record_gui->importSearchForm();
177 if (is_array($elements)) {
178 $this->content_obj->setData($elements, $form->getInput("mode"));
179 $this->updated = $this->pg_obj->update();
180 if ($this->updated === true) {
181 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
182 }
183 }
184 }
185
186 $this->pg_obj->addHierIDs();
187 // $form->setValuesByPost();
188 return $this->edit($form);
189 }
190}
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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46