ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 public $filter = array();
40
41 public function __construct($content, $a_rbac_id, $a_obj_id, $a_obj_type)
42 {
43 $this->setMDObject(new ilMD($a_rbac_id, $a_obj_id, $a_obj_type));
44
45 parent::__construct();
46 $this->setXMLContent($content);
47
48 // set filter of tags which are handled in this class
49 $this->__setFilter();
50 }
51 public function setHandlers($a_xml_parser)
52 {
53 xml_set_object($a_xml_parser, $this);
54 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
55 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
56 }
57
58 public function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
59 {
60 if ($this->in_meta_data and !$this->__inFilter($a_name)) {
61 parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
62 return true;
63 }
64
65
66 switch ($a_name) {
67 case 'MetaData':
68 $this->in_meta_data = true;
69 parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
70 break;
71
72 case 'Identifier':
73 $par = &$this->__getParent();
74 $this->md_ide = &$par->addIdentifier();
75 $this->md_ide->setCatalog($a_attribs['Catalog']);
76 $this->md_ide->setEntry('il__' . $this->md->getObjType() . '_' . $this->md->getObjId());
77 $this->md_ide->save();
78 $this->__pushParent($this->md_ide);
79 break;
80 }
81 return true;
82 }
83 public function handlerEndTag($a_xml_parser, $a_name)
84 {
85 if ($this->in_meta_data and !$this->__inFilter($a_name)) {
86 parent::handlerEndTag($a_xml_parser, $a_name);
87 return true;
88 }
89 switch ($a_name) {
90 case 'Identifier':
91 $par = &$this->__getParent();
92 $par->update();
93 $this->__popParent();
94 break;
95
96
97 case 'MetaData':
98 $this->in_meta_data = false;
99 parent::handlerEndTag($a_xml_parser, $a_name);
100 break;
101 }
102 return true;
103 }
104
105 public function handlerCharacterData($a_xml_parser, $a_data)
106 {
107 if ($this->in_meta_data) {
108 parent::handlerCharacterData($a_xml_parser, $a_data);
109 return true;
110 }
111 }
112 /*
113 * Set filter of tags which are handled in this class.
114 * @access protected
115 *
116 */
117 public function __setFilter()
118 {
119 $this->filter[] = 'Identifier';
120 }
121 /*
122 * Check if tag is filtered
123 * @access protected
124 *
125 */
126 public function __inFilter($a_tag_name)
127 {
128 return in_array($a_tag_name, $this->filter);
129 }
130}
An exception for terminatinating execution or to throw for unit testing.
__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
__construct($content, $a_rbac_id, $a_obj_id, $a_obj_type)
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
setHandlers($a_xml_parser)
set event handlers
setXMLContent($a_xml_content)