• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/MetaData/classes/class.ilMDXMLCopier.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 // set filter of tags which are handled in this class
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          * Set filter of tags which are handled in this class.
00120          * @access protected
00121          * 
00122          */
00123         function __setFilter()
00124         {
00125                 $this->filter[] = 'Identifier';
00126         }
00127         /*
00128          * Check if tag is filtered
00129          * @access protected
00130          * 
00131          */
00132         function __inFilter($a_tag_name)
00133         {
00134                 return in_array($a_tag_name,$this->filter);
00135         }
00136 }
00137 ?>

Generated on Fri Dec 13 2013 10:18:31 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1