19 declare(strict_types=1);
47 public function __construct(
object $a_slm_object,
string $a_xml_file)
51 $this->current_element = array();
52 $this->slm_object = $a_slm_object;
53 $this->tree_created =
false;
54 $this->parent_stack = array();
55 $this->item_stack = array();
76 parent::startParsing();
94 $this->current_element[count($this->current_element)] = $a_name;
103 unset($this->current_element[count($this->current_element) - 1]);
111 return ($this->current_element[count($this->current_element) - 1]);
116 return ($this->current_element[count($this->current_element) - 1 - $nr]);
134 public function buildTag(
string $type,
string $name, ?array $attr =
null): string
138 if ($type ===
"end") {
144 if (is_array($attr)) {
145 foreach ($attr as $k => $v) {
146 $tag .=
" " . $k .
"=\"$v\"";
157 return $this->parent_stack[count($this->parent_stack) - 1];
167 public function handlerBeginTag(XMLParser $a_xml_parser,
string $a_name, array $a_attribs): void
173 if (isset($a_attribs[
"version"])) {
174 $mVersion = $a_attribs[
"version"];
177 $manifest->setSLMId($this->slm_object->getId());
178 $manifest->setImportId($a_attribs[
"identifier"]);
179 $manifest->setVersion($mVersion);
180 if (isset($a_attribs[
"xml:base"])) {
181 $manifest->setXmlBase($a_attribs[
"xml:base"]);
184 if (!$this->tree_created) {
185 $this->sc_tree =
new ilSCORMTree($this->slm_object->getId());
186 $this->sc_tree->
addTree($this->slm_object->getId(), $manifest->getId());
190 $this->parent_stack[] = $manifest->getId();
193 case "organizations":
195 $organizations->setSLMId($this->slm_object->getId());
196 if (isset($a_attribs[
"default"])) {
197 $organizations->setDefaultOrganization($a_attribs[
"default"]);
199 $organizations->setDefaultOrganization(
"");
201 $organizations->create();
202 $this->sc_tree->insertNode($organizations->getId(), $this->
getCurrentParent());
203 $this->parent_stack[] = $organizations->getId();
208 $organization->setSLMId($this->slm_object->getId());
209 $organization->setImportId($a_attribs[
"identifier"]);
210 if (isset($a_attribs[
"structure"])) {
211 $organization->setStructure($a_attribs[
"structure"]);
213 $organization->create();
214 $this->current_organization = &$organization;
215 $this->sc_tree->insertNode($organization->getId(), $this->
getCurrentParent());
216 $this->parent_stack[] = $organization->getId();
221 $item->setSLMId($this->slm_object->getId());
222 $item->setImportId($a_attribs[
"identifier"]);
223 $item->setIdentifierRef((
string) $a_attribs[
"identifierref"]);
224 if (isset($a_attribs[
"isvisible"])) {
225 if (strtolower((
string) $a_attribs[
"isvisible"]) !==
"false") {
226 $item->setVisible(
true);
228 $item->setVisible(
false);
231 if (isset($a_attribs[
"parameters"])) {
232 $item->setParameters($a_attribs[
"parameters"]);
236 $this->parent_stack[] = $item->getId();
237 $this->item_stack[count($this->item_stack)] = &$item;
240 case "adlcp:prerequisites":
241 $this->item_stack[count($this->item_stack) - 1]->setPrereqType($a_attribs[
"type"]);
246 $resources->setSLMId($this->slm_object->getId());
247 if (isset($a_attribs[
"xml:base"])) {
248 $resources->setXmlBase($a_attribs[
"xml:base"]);
257 $resource->setSLMId($this->slm_object->getId());
258 $resource->setImportId($a_attribs[
"identifier"]);
259 $resource->setResourceType($a_attribs[
"type"]);
260 if (isset($a_attribs[
"adlcp:scormtype"])) {
261 $resource->setScormType($a_attribs[
"adlcp:scormtype"]);
263 if (isset($a_attribs[
"xml:base"])) {
264 $resource->setXmlBase($a_attribs[
"xml:base"]);
266 if (isset($a_attribs[
"href"])) {
267 $resource->setHRef($a_attribs[
"href"]);
270 $this->current_resource = &$resource;
272 $this->parent_stack[] = $resource->getId();
277 $file->setHRef($a_attribs[
"href"]);
278 $this->current_resource->addFile($file);
283 $dependency->setIdentifierRef($a_attribs[
"identifierref"]);
284 $this->current_resource->addDependency($dependency);
297 public function handlerEndTag(XMLParser $a_xml_parser,
string $a_name): void
303 case "organizations":
305 array_pop($this->parent_stack);
309 $this->current_organization->update();
310 array_pop($this->parent_stack);
314 $this->item_stack[count($this->item_stack) - 1]->update();
315 unset($this->item_stack[count($this->item_stack) - 1]);
316 array_pop($this->parent_stack);
320 $this->current_resource->update();
321 array_pop($this->parent_stack);
338 $a_data = preg_replace(
"/\n/",
"", $a_data);
339 $a_data = preg_replace(
"/\t+/",
"", $a_data);
340 if (!empty($a_data)) {
345 $this->current_organization->setTitle(
352 $this->item_stack[count($this->item_stack) - 1]->setTitle(
359 case "adlcp:prerequisites":
360 $this->item_stack[count($this->item_stack) - 1]->setPrerequisites($a_data);
363 case "adlcp:maxtimeallowed":
364 $this->item_stack[count($this->item_stack) - 1]->setMaxTimeAllowed($a_data);
367 case "adlcp:timelimitaction":
368 $this->item_stack[count($this->item_stack) - 1]->setTimeLimitAction($a_data);
371 case "adlcp:datafromlms":
372 $this->item_stack[count($this->item_stack) - 1]->setDataFromLms($a_data);
375 case "adlcp:masteryscore":
376 $this->item_stack[count($this->item_stack) - 1]->setMasteryScore($a_data);
setHandlers($a_xml_parser)
set event handler should be overwritten by inherited class
SCORM Resource Dependency, DB accesses are done in ilSCORMResource.
__construct(object $a_slm_object, string $a_xml_file)
Constructor.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
getAncestorElement(int $nr=1)
addTree(int $a_tree_id, int $a_node_id=-1)
create a new tree to do: ???
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
handlerCharacterData(XMLParser $a_xml_parser, ?string $a_data)
handler for character data
getCurrentElement()
returns current element
handlerEndTag(XMLParser $a_xml_parser, string $a_name)
handler for end of element
handlerBeginTag(XMLParser $a_xml_parser, string $a_name, array $a_attribs)
handler for begin of element
endElement(string $a_name)
update parsing status for an element ending
buildTag(string $type, string $name, ?array $attr=null)
generate a tag with given name and attributes
beginElement(string $a_name)
update parsing status for a element begin
SCORM Resource File, DB accesses are done in ilSCORMResource.
__construct(Container $dic, ilPlugin $plugin)
object $current_organization