ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMDXMLCopier.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
34include_once 'Services/MetaData/classes/class.ilMDSaxParser.php';
35include_once 'Services/MetaData/classes/class.ilMD.php';
36
38{
39 var $filter = array();
40
41 function ilMDXMLCopier($content,$a_rbac_id,$a_obj_id,$a_obj_type)
42 {
43
44 $this->setMDObject(new ilMD($a_rbac_id,$a_obj_id,$a_obj_type));
45
46 parent::ilMDSaxParser();
47 $this->setXMLContent($content);
48
49 // set filter of tags which are handled in this class
50 $this->__setFilter();
51
52 }
53 function setHandlers($a_xml_parser)
54 {
55 xml_set_object($a_xml_parser,$this);
56 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
57 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
58 }
59
60 function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
61 {
62 if($this->in_meta_data and !$this->__inFilter($a_name))
63 {
64 parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
65 return true;
66 }
67
68
69 switch($a_name)
70 {
71 case 'MetaData':
72 $this->in_meta_data = true;
73 parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
74 break;
75
76 case 'Identifier':
77 $par =& $this->__getParent();
78 $this->md_ide =& $par->addIdentifier();
79 $this->md_ide->setCatalog($a_attribs['Catalog']);
80 $this->md_ide->setEntry('il__'.$this->md->getObjType().'_'.$this->md->getObjId());
81 $this->md_ide->save();
82 $this->__pushParent($this->md_ide);
83 break;
84 }
85 return true;
86 }
87 function handlerEndTag($a_xml_parser,$a_name)
88 {
89 if($this->in_meta_data and !$this->__inFilter($a_name))
90 {
91 parent::handlerEndTag($a_xml_parser,$a_name);
92 return true;
93 }
94 switch($a_name)
95 {
96 case 'Identifier':
97 $par =& $this->__getParent();
98 $par->update();
99 $this->__popParent();
100 break;
101
102
103 case 'MetaData':
104 $this->in_meta_data = false;
105 parent::handlerEndTag($a_xml_parser,$a_name);
106 break;
107 }
108 return true;
109 }
110
111 function handlerCharacterData($a_xml_parser,$a_data)
112 {
113 if($this->in_meta_data)
114 {
115 parent::handlerCharacterData($a_xml_parser,$a_data);
116 return true;
117 }
118 }
119 /*
120 * Set filter of tags which are handled in this class.
121 * @access protected
122 *
123 */
124 function __setFilter()
125 {
126 $this->filter[] = 'Identifier';
127 }
128 /*
129 * Check if tag is filtered
130 * @access protected
131 *
132 */
133 function __inFilter($a_tag_name)
134 {
135 return in_array($a_tag_name,$this->filter);
136 }
137}
138?>
__inFilter($a_tag_name)
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
ilMDXMLCopier($content, $a_rbac_id, $a_obj_id, $a_obj_type)
setHandlers($a_xml_parser)
set event handlers
setXMLContent($a_xml_content)