123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <?php
- class scormOrganization {
- var $identifier = '';
- var $structure = '';
- var $title = '';
- var $items = array();
- var $metadata;
-
- function scormOrganization($type='manifest',&$element,$scorm_charset='UTF-8') {
- if(isset($element))
- {
- $v = substr(phpversion(),0,1);
- if($v == 4){
- switch($type){
- case 'db':
-
- return false;
- case 'manifest':
- default:
-
- $children = $element->children();
- foreach($children as $a => $dummy)
- {
- $child =& $children[$a];
- switch($child->type)
- {
- case XML_ELEMENT_NODE:
- switch($child->tagname){
- 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->children();
- if(count($tmp_children)==1 and $tmp_children[0]->content!='' )
- {
- $this->title = $tmp_children[0]->content;
- }
- break;
- }
- break;
- case XML_TEXT_NODE:
- break;
- }
- }
- $attributes = $element->attributes();
-
- foreach($attributes as $a1 => $dummy)
- {
- $attrib =& $attributes[$a1];
- switch($attrib->name){
- case 'identifier':
- $this->identifier = $attrib->value;
- break;
- case 'structure':
- $this->structure = $attrib->value;
- break;
- }
- }
- return true;
- }
- }elseif($v == 5){
-
- switch($type){
- case 'db':
-
- return false;
- case 'manifest':
- default:
-
- $children = $element->childNodes;
- foreach($children as $child)
- {
- switch($child->nodeType)
- {
- case XML_ELEMENT_NODE:
- switch($child->tagName){
- 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 and $child->firstChild->nodeValue != '' )
- {
- $this->title = html_entity_decode(html_entity_decode($child->firstChild->nodeValue,ENT_QUOTES,$scorm_charset));
- }
- break;
- }
- break;
- case XML_TEXT_NODE:
- break;
- }
- }
- if($element->hasAttributes()){
- $attributes = $element->attributes;
-
- foreach($attributes as $attrib)
- {
- switch($attrib->name){
- case 'identifier':
- $this->identifier = $attrib->value;
- break;
- case 'structure':
- $this->structure = $attrib->value;
- break;
- }
- }
- }
- return true;
- }
- }else{
-
- return false;
- }
- }
- return false;
- }
-
- 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);
- $i++;
- }
- return $list;
- }
-
- function get_name()
- {
- if(!empty($this->title)){
- return Database::escape_string($this->title);
- }else{
- return '';
- }
- }
-
- function get_ref()
- {
- if(!empty($this->identifier)){
- return Database::escape_string($this->identifier);
- }else{
- return '';
- }
- }
-
- function set_name($title){
- if(!empty($title)){
- $this->title = Database::escape_string($title);
- }
- }
- }
- ?>
|