ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilLMChapterImportForm Class Reference

LM Chapter. More...

+ Collaboration diagram for ilLMChapterImportForm:

Public Member Functions

 __construct ($a_slm, $a_node_id, $a_first_child, $a_confirm=false)
 Constructor. More...
 
 isCorrect ()
 Is correct? More...
 
 performInserts ()
 
 processHierarchy ()
 
 getHTML ()
 Get html. More...
 
 addNode ($a_node, $a_parent, $a_depth)
 Add node. More...
 

Protected Attributes

 $user
 
 $lng
 
 $tree = null
 
 $node_id = null
 
 $confirm = false
 
 $perform = false
 

Detailed Description

LM Chapter.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilLMChapterImportForm.php.

Constructor & Destructor Documentation

◆ __construct()

ilLMChapterImportForm::__construct (   $a_slm,
  $a_node_id,
  $a_first_child,
  $a_confirm = false 
)

Constructor.

Parameters

return

Definition at line 35 of file class.ilLMChapterImportForm.php.

36 {
37 global $DIC;
38
39 $this->user = $DIC->user();
40 $this->lng = $DIC->language();
41 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php");
42 $this->slm = $a_slm;
43 $this->tree = new ilSCORM2004Tree($this->slm->getId());
44 $this->node_id = $a_node_id;
45 $this->node = $this->tree->getNodeData($this->node_id);
46 $this->current_depth = $this->node["depth"];
47 if ($a_first_child) {
48 $this->current_depth++;
49 $this->current_parent = $this->node;
50 } else {
51 $this->current_parent = $this->tree->getNodeData($this->node["parent"]);
52 }
53 if ($this->current_parent["child"] == $this->tree->readRootId()) {
54 $this->current_parent["title"] = ilObject::_lookupTitle($this->slm->getId());
55 $this->current_parent["type"] = "sahs";
56 }
57 $this->first_child = $a_first_child;
58 $this->confirm = $a_confirm;
59 $this->correct = true;
60 }
user()
Definition: user.php:4
static _lookupTitle($a_id)
lookup object title
SCORM 2004 Editing tree.
$DIC
Definition: xapitoken.php:46

References $DIC, ilObject\_lookupTitle(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addNode()

ilLMChapterImportForm::addNode (   $a_node,
  $a_parent,
  $a_depth 
)

Add node.

Parameters

return

Definition at line 135 of file class.ilLMChapterImportForm.php.

136 {
139
140 //$tpl = new ilTemplate("tpl.lm_chap_import_node.html", true, true, "Modules/Scorm2004");
141 $lng->loadLanguageModule("content");
142
143 $options = array(
144 "" => $lng->txt("cont_assign_to_parent"),
145 "chap" => $lng->txt("obj_chap"),
146 "sco" => $lng->txt("obj_sco"),
147 "ass" => $lng->txt("obj_ass")
148 );
149
150 if (!$this->confirm) {
151 $sel = ($a_node["type"] != "pg")
152 ? $sel = ilUtil::formSelect($_POST["node"][$a_node["id"]], "node[" . $a_node["id"] . "]", $options, false, true)
153 : "";
154 $img = ilUtil::img(ilUtil::getImagePath("icon_" . $a_node["type"] . ".svg"));
155 } else {
156 // if scos/assets are nested in scos/assets, put the tree one level up
157 //echo "<br>-".$a_node["title"]."-".$_POST["node"][$a_node["id"]]."-".$_POST["node"][$a_parent["id"]]."-";
158 if (in_array($_POST["node"][$a_node["id"]], array("sco", "ass")) && in_array($_POST["node"][$a_parent["id"]], array("sco", "ass"))) {
159 //echo "j";
160 //var_dump($a_parent);
161 // echo "<br>getting-from-".$a_parent["title"]."-".$a_parent["id"]."-".$a_target."-";
162 $a_parent = $a_parent["parent"];
163 $a_depth--;
164 }
165
166 $sel = ($a_node["type"] != "pg")
167 ? $sel = "<strong>" . $lng->txt("obj_" . $_POST["node"][$a_node["id"]]) . "</strong>"
168 : "";
169 $ctype = ($a_node["type"] != "pg")
170 ? $_POST["node"][$a_node["id"]]
171 : "pg";
172
173 $parent_type = $a_parent["type"];
174 if (isset($_POST["node"][$a_parent["id"]])) {
175 $parent_type = $_POST["node"][$a_parent["id"]];
176 }
177 //echo "<br>-".$a_node["title"]."-".$parent_type."-";
178 $img = ilUtil::img(ilUtil::getImagePath("icon_" . $ctype . ".svg"));
179
180 $error = "";
181 switch ($a_depth) {
182 case 0:
183 case 1:
184 $this->correct = false;
185 break;
186
187 case 2:
188 if (!in_array($ctype, array("", "chap", "sco", "ass"))) {
189 $error = '<span class="alert">' . $lng->txt("cont_type_not_allowed") . ": " . $lng->txt("obj_" . $ctype) . "</span>";
190 if ($_POST["node"][$a_node["id"]] != "" || $a_node["type"] == "pg") {
191 $this->correct = false;
192 }
193 }
194 break;
195
196 default:
197 if ($parent_type == "chap" && !in_array($ctype, array("sco", "ass")) ||
198 ($parent_type != "chap" && !in_array($ctype, array("pg")))) {
199 $error = '<span class="alert">' . $lng->txt("cont_type_not_allowed") . ": " . $lng->txt("obj_" . $ctype) . "</span>";
200 if ($_POST["node"][$a_node["id"]] != "" || $a_node["type"] == "pg") {
201 $this->correct = false;
202 }
203 }
204 break;
205 }
206 }
207
208 // if node should be inserted, increase depth
209 if (!$this->confirm || $_POST["node"][$a_node["id"]] != "" || $a_node["type"] == "pg") {
210 if (!$this->perform) {
211 $this->list->addListNode(
212 $img . " " .
213 $a_node["title"] . " " .
214 $sel . " " . $error,
215 $a_node["id"],
216 $a_parent["id"]
217 );
218 } else {
219 if ($a_parent["insert_id"] > 0) {
220 $target = $this->target[$a_parent["insert_id"]];
221
222 // create new node of ctype, put it under parent (respect after node from hierarchy)
223 switch ($ctype) {
224 case "chap":
225 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php");
226 $chap = new ilSCORM2004Chapter($this->slm);
227 $chap->setTitle($a_node["title"]);
228 $chap->setSLMId($this->slm->getId());
229 $chap->create();
230 ilSCORM2004Node::putInTree($chap, $a_parent["insert_id"], $target);
231 $a_node["insert_id"] = $chap->getId();
232 break;
233
234 case "ass":
235 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
236 $ass = new ilSCORM2004Asset($this->slm);
237 $ass->setTitle($a_node["title"]);
238 $ass->setSLMId($this->slm->getId());
239 $ass->create();
240 ilSCORM2004Node::putInTree($ass, $a_parent["insert_id"], $target);
241 $a_node["insert_id"] = $ass->getId();
242 break;
243
244 case "sco":
245 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
246 $sco = new ilSCORM2004Sco($this->slm);
247 $sco->setTitle($a_node["title"]);
248 $sco->setSLMId($this->slm->getId());
249 $sco->create();
250 ilSCORM2004Node::putInTree($sco, $a_parent["insert_id"], $target);
251 $a_node["insert_id"] = $sco->getId();
252 break;
253
254 case "pg":
255 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
256 $copied_nodes = array();
257 $a_node["insert_id"] = ilSCORM2004Node::pasteTree(
258 $this->slm,
259 $a_node["id"],
260 $a_parent["insert_id"],
261 $target,
262 $a_node["insert_time"],
263 $copied_nodes,
264 true,
265 true,
266 "lm"
267 );
268 break;
269 }
270
271 $this->target[$a_parent["insert_id"]] = $a_node["insert_id"];
272
273 // set $a_node["insert_id"] to new id
274 }
275 }
276
277 $a_depth++;
278 $parent = $a_node;
279 } else {
280 $parent = $a_parent;
281 }
282
283 $childs = $ilUser->getClipboardChilds($a_node["id"], $a_node["insert_time"]);
284 foreach ($childs as $c) {
285 $c["parent"] = $a_node;
286 // $c["parent_target"] = rand(1,100);
287 // echo "<br>setting-".$c["parent_target"]."-into-".$c["id"]."-".$c["title"]."-";
288 $this->addNode($c, $parent, $a_depth);
289 }
290 }
$_POST["username"]
addNode($a_node, $a_parent, $a_depth)
Add node.
Class ilSCORM2004Asset.
Class ilSCORM2004Chapter.
static pasteTree( $a_target_slm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_from_clipboard=true, $a_source_parent_type="")
Paste item (tree) from clipboard or other learning module to target scorm learning module.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
Class ilSCORM2004Sco.
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$ilUser
Definition: imgupload.php:18

References $_POST, Vendor\Package\$c, $ilUser, $img, $lng, $user, addNode(), ilUtil\formSelect(), ilUtil\getImagePath(), ilUtil\img(), ilSCORM2004Node\pasteTree(), and ilSCORM2004Node\putInTree().

Referenced by addNode(), and processHierarchy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilLMChapterImportForm::getHTML ( )

Get html.

Parameters

return

Definition at line 108 of file class.ilLMChapterImportForm.php.

109 {
111
112 include_once("./Services/UIComponent/NestedList/classes/class.ilNestedList.php");
113 $this->list = new ilNestedList();
114 $this->list->setListClass("noStyle");
115
116 $this->list->addListNode(
117 ilUtil::img(ilUtil::getImagePath("icon_" . $this->current_parent["type"] . ".svg")) . " " .
118 $this->current_parent["title"] . " " .
119 "",
120 $this->current_parent["id"],
121 0
122 );
123
124 $this->processHierarchy();
125
126 return $this->list->getHTML();
127 }

References $ilUser, $user, ilUtil\getImagePath(), ilUtil\img(), and processHierarchy().

+ Here is the call graph for this function:

◆ isCorrect()

ilLMChapterImportForm::isCorrect ( )

Is correct?

Parameters

return

Definition at line 68 of file class.ilLMChapterImportForm.php.

69 {
70 return $this->correct;
71 }

◆ performInserts()

ilLMChapterImportForm::performInserts ( )

Definition at line 73 of file class.ilLMChapterImportForm.php.

74 {
75 // act like in confirm mode
76 $this->confirm = true;
77 $this->perform = true;
78 $this->processHierarchy();
79 }

References processHierarchy().

+ Here is the call graph for this function:

◆ processHierarchy()

ilLMChapterImportForm::processHierarchy ( )

Definition at line 81 of file class.ilLMChapterImportForm.php.

82 {
84
85 $target = ($this->first_child)
87 : $this->node_id;
88
89 // get chapters
90 $chapters = $ilUser->getClipboardObjects("st", true);
91
92 if ($this->perform) {
93 $this->current_parent["insert_id"] = $this->current_parent["child"];
94 $this->target[$this->current_parent["insert_id"]] = $target;
95 }
96 foreach ($chapters as $chap) {
97 $chap["parent"] = $this->current_parent;
98 $this->addNode($chap, $this->current_parent, $this->current_depth);
99 }
100 }
const IL_FIRST_NODE
Definition: class.ilTree.php:5

References $ilUser, $user, addNode(), and IL_FIRST_NODE.

Referenced by getHTML(), and performInserts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $confirm

ilLMChapterImportForm::$confirm = false
protected

Definition at line 26 of file class.ilLMChapterImportForm.php.

◆ $lng

ilLMChapterImportForm::$lng
protected

Definition at line 22 of file class.ilLMChapterImportForm.php.

Referenced by addNode().

◆ $node_id

ilLMChapterImportForm::$node_id = null
protected

Definition at line 25 of file class.ilLMChapterImportForm.php.

◆ $perform

ilLMChapterImportForm::$perform = false
protected

Definition at line 27 of file class.ilLMChapterImportForm.php.

◆ $tree

ilLMChapterImportForm::$tree = null
protected

Definition at line 24 of file class.ilLMChapterImportForm.php.

◆ $user

ilLMChapterImportForm::$user
protected

Definition at line 17 of file class.ilLMChapterImportForm.php.

Referenced by addNode(), getHTML(), and processHierarchy().


The documentation for this class was generated from the following file: