Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00034 include_once 'Services/MetaData/classes/class.ilMDSaxParser.php';
00035
00036 class ilMDXMLCopier extends ilMDSaxParser
00037 {
00038 var $filter = array();
00039
00040 function ilMDXMLCopier($content,$a_rbac_id,$a_obj_id,$a_obj_type)
00041 {
00042
00043 $this->setMDObject(new ilMD($a_rbac_id,$a_obj_id,$a_obj_type));
00044
00045 parent::ilMDSaxParser();
00046 $this->setXMLContent($content);
00047
00048
00049 $this->__setFilter();
00050
00051 }
00052 function setHandlers($a_xml_parser)
00053 {
00054 xml_set_object($a_xml_parser,$this);
00055 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00056 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00057 }
00058
00059 function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
00060 {
00061 if($this->in_meta_data and !$this->__inFilter($a_name))
00062 {
00063 parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
00064 return true;
00065 }
00066
00067
00068 switch($a_name)
00069 {
00070 case 'MetaData':
00071 $this->in_meta_data = true;
00072 parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
00073 break;
00074
00075 case 'Identifier':
00076 $par =& $this->__getParent();
00077 $this->md_ide =& $par->addIdentifier();
00078 $this->md_ide->setCatalog($a_attribs['Catalog']);
00079 $this->md_ide->setEntry('il__'.$this->md->getObjType().'_'.$this->md->getObjId());
00080 $this->md_ide->save();
00081 $this->__pushParent($this->md_ide);
00082 break;
00083 }
00084 return true;
00085 }
00086 function handlerEndTag($a_xml_parser,$a_name)
00087 {
00088 if($this->in_meta_data and !$this->__inFilter($a_name))
00089 {
00090 parent::handlerEndTag($a_xml_parser,$a_name);
00091 return true;
00092 }
00093 switch($a_name)
00094 {
00095 case 'Identifier':
00096 $par =& $this->__getParent();
00097 $par->update();
00098 $this->__popParent();
00099 break;
00100
00101
00102 case 'MetaData':
00103 $this->in_meta_data = false;
00104 parent::handlerEndTag($a_xml_parser,$a_name);
00105 break;
00106 }
00107 return true;
00108 }
00109
00110 function handlerCharacterData($a_xml_parser,$a_data)
00111 {
00112 if($this->in_meta_data)
00113 {
00114 parent::handlerCharacterData($a_xml_parser,$a_data);
00115 return true;
00116 }
00117 }
00118
00119
00120
00121
00122
00123 function __setFilter()
00124 {
00125 $this->filter[] = 'Identifier';
00126 }
00127
00128
00129
00130
00131
00132 function __inFilter($a_tag_name)
00133 {
00134 return in_array($a_tag_name,$this->filter);
00135 }
00136 }
00137 ?>