|
|
|
@ -24,11 +24,11 @@ class scormOrganization |
|
|
|
|
* @param string Type of construction needed ('db' or 'manifest', default = 'manifest') |
|
|
|
|
* @param mixed Depending on the type given, DB id for the lp_item or reference to the DOM element |
|
|
|
|
*/ |
|
|
|
|
public function __construct($type = 'manifest', &$element, $scorm_charset = 'UTF-8') { |
|
|
|
|
public function __construct($type = 'manifest', &$element, $scorm_charset = 'UTF-8') |
|
|
|
|
{ |
|
|
|
|
if (isset($element)) { |
|
|
|
|
|
|
|
|
|
// Parsing using PHP5 DOMXML methods. |
|
|
|
|
|
|
|
|
|
switch ($type) { |
|
|
|
|
case 'db': |
|
|
|
|
// TODO: Implement this way of metadata object creation. |
|
|
|
@ -39,29 +39,30 @@ class scormOrganization |
|
|
|
|
$children = $element->childNodes; |
|
|
|
|
foreach ($children as $child) { |
|
|
|
|
switch ($child->nodeType) { |
|
|
|
|
case XML_ELEMENT_NODE: |
|
|
|
|
case XML_ELEMENT_NODE: |
|
|
|
|
switch ($child->tagName) { |
|
|
|
|
case 'item': |
|
|
|
|
case 'item': |
|
|
|
|
$oItem = new scormItem('manifest', $child); |
|
|
|
|
if ($oItem->identifier != '') { |
|
|
|
|
$this->items[$oItem->identifier] = $oItem; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'metadata': |
|
|
|
|
$this->metadata = new scormMetadata('manifest', $child); |
|
|
|
|
break; |
|
|
|
|
case 'title': |
|
|
|
|
$tmp_children = $child->childNodes; |
|
|
|
|
if ($tmp_children->length == 1 && $child->firstChild->nodeValue != '') { |
|
|
|
|
$this->title = api_utf8_decode(api_html_entity_decode($child->firstChild->nodeValue, ENT_QUOTES, 'UTF-8')); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'metadata': |
|
|
|
|
$this->metadata = new scormMetadata('manifest', $child); |
|
|
|
|
break; |
|
|
|
|
case 'title': |
|
|
|
|
$tmp_children = $child->childNodes; |
|
|
|
|
if ($tmp_children->length == 1 && $child->firstChild->nodeValue != '') { |
|
|
|
|
$this->title = api_utf8_decode(api_html_entity_decode($child->firstChild->nodeValue, ENT_QUOTES, 'UTF-8')); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case XML_TEXT_NODE: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($element->hasAttributes()) { |
|
|
|
|
$attributes = $element->attributes; |
|
|
|
|
//$keep_href = ''; |
|
|
|
@ -76,12 +77,13 @@ class scormOrganization |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// End parsing using PHP5 DOMXML methods. |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -89,14 +91,17 @@ class scormOrganization |
|
|
|
|
* Get a flat list of items in the organization |
|
|
|
|
* @return array Array containing an ordered list of all items with their level and all information related to each item |
|
|
|
|
*/ |
|
|
|
|
public function get_flat_items_list() { |
|
|
|
|
public function get_flat_items_list() |
|
|
|
|
{ |
|
|
|
|
$list = array(); |
|
|
|
|
$i = 1; |
|
|
|
|
foreach ($this->items as $id => $dummy) { |
|
|
|
|
$abs_order = 0; |
|
|
|
|
$this->items[$id]->get_flat_list($list,$abs_order, $i, 0); // Passes the array as a pointer so it is modified in $list directly. |
|
|
|
|
// Passes the array as a pointer so it is modified in $list directly. |
|
|
|
|
$this->items[$id]->get_flat_list($list,$abs_order, $i, 0); |
|
|
|
|
$i++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -104,7 +109,8 @@ class scormOrganization |
|
|
|
|
* Name getter |
|
|
|
|
* @return string Name or empty string |
|
|
|
|
*/ |
|
|
|
|
public function get_name() { |
|
|
|
|
public function get_name() |
|
|
|
|
{ |
|
|
|
|
if (!empty($this->title)) { |
|
|
|
|
return Database::escape_string($this->title); |
|
|
|
|
} else { |
|
|
|
@ -116,7 +122,8 @@ class scormOrganization |
|
|
|
|
* Reference identifier getter |
|
|
|
|
* @return string Identifier or empty string |
|
|
|
|
*/ |
|
|
|
|
public function get_ref() { |
|
|
|
|
public function get_ref() |
|
|
|
|
{ |
|
|
|
|
if (!empty($this->identifier)) { |
|
|
|
|
return Database::escape_string($this->identifier); |
|
|
|
|
} else { |
|
|
|
@ -126,9 +133,10 @@ class scormOrganization |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets the title element |
|
|
|
|
* @param string New title to set |
|
|
|
|
* @param string $title New title to set |
|
|
|
|
*/ |
|
|
|
|
public function set_name($title) { |
|
|
|
|
public function set_name($title) |
|
|
|
|
{ |
|
|
|
|
if (!empty($title)) { |
|
|
|
|
$this->title = Database::escape_string($title); |
|
|
|
|
} |
|
|
|
|