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

content/classes/class.ilContObjParser.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 require_once("content/classes/class.ilLMPageObject.php");
00025 require_once("content/classes/Pages/class.ilPageObject.php");
00026 require_once("content/classes/class.ilStructureObject.php");
00027 require_once("content/classes/class.ilObjLearningModule.php");
00028 require_once("classes/class.ilMetaData.php");
00029 require_once("content/classes/Pages/class.ilPCParagraph.php");
00030 require_once("content/classes/Pages/class.ilPCTable.php");
00031 require_once("content/classes/Media/class.ilObjMediaObject.php");
00032 require_once("content/classes/Media/class.ilMediaItem.php");
00033 require_once("content/classes/Media/class.ilMapArea.php");
00034 require_once("content/classes/class.ilBibItem.php");
00035 require_once("content/classes/class.ilObjGlossary.php");
00036 require_once("content/classes/class.ilGlossaryTerm.php");
00037 require_once("content/classes/class.ilGlossaryDefinition.php");
00038 require_once("content/classes/Pages/class.ilInternalLink.php");
00039 require_once("classes/class.ilObjFile.php");
00040 
00050 class ilContObjParser extends ilSaxParser
00051 {
00052         var $lng;
00053         var $tree;
00054         var $cnt;                               // counts open elements
00055         var $current_element;   // store current element type
00056         var $learning_module;   // current learning module
00057         var $page_object;               // current page object
00058         var $lm_page_object;
00059         var $structure_objects; // array of current structure objects
00060         var $media_object;
00061         var $current_object;    // at the time a LearningModule, PageObject or StructureObject
00062         var $meta_data;                 // current meta data object
00063         var $paragraph;
00064         var $table;
00065         var $lm_tree;
00066         var $pg_into_tree;
00067         var $st_into_tree;
00068         var $container;
00069         var $in_page_object;    // are we currently within a PageObject? true/false
00070         var $in_meta_data;              // are we currently within MetaData? true/false
00071         var $in_media_object;
00072         var $in_file_item;
00073         var $in_glossary;
00074         var $in_map_area;
00075         var $content_object;
00076         var $glossary_object;
00077         var $file_item;
00078         var $keyword_language;
00079         var $pages_to_parse;
00080         var $mob_mapping;
00081         var $file_item_mapping;
00082         var $subdir;
00083         var $media_item;                // current media item
00084         var $loc_type;                  // current location type
00085         var $bib_item;                  // current bib item object
00086         var $map_area;                  // current map area
00087         var $in_bib_item;               // are we currently within BibItem? true/false
00088         var $link_targets;              // stores all objects by import id
00089         var $qst_mapping;
00090 
00099         function ilContObjParser(&$a_content_object, $a_xml_file, $a_subdir)
00100         {
00101                 global $lng, $tree;
00102 
00103                 parent::ilSaxParser($a_xml_file);
00104                 $this->cnt = array();
00105                 $this->current_element = array();
00106                 $this->structure_objects = array();
00107                 $this->content_object =& $a_content_object;
00108                 //$this->lm_id = $a_lm_id;
00109                 $this->st_into_tree = array();
00110                 $this->pg_into_tree = array();
00111                 $this->pages_to_parse = array();
00112                 $this->mobs_with_int_links = array();
00113                 $this->mob_mapping = array();
00114                 $this->file_item_mapping = array();
00115                 $this->pg_mapping = array();
00116                 $this->link_targets = array();
00117                 $this->subdir = $a_subdir;
00118                 $this->lng =& $lng;
00119                 $this->tree =& $tree;
00120                 $this->inside_code = false;
00121                 $this->qst_mapping = array();
00122                 $this->coType = $this->content_object->getType();
00123 
00124                 if (($this->coType != "tst") and ($this->coType != "qpl"))
00125                 {
00126                         $this->lm_tree = new ilTree($this->content_object->getId());
00127                         $this->lm_tree->setTreeTablePK("lm_id");
00128                         $this->lm_tree->setTableNames('lm_tree','lm_data');
00129                 }
00130                 //$this->lm_tree->addTree($a_lm_id, 1); happens in ilObjLearningModuleGUI
00131 
00132         }
00133 
00139         function setHandlers($a_xml_parser)
00140         {
00141                 xml_set_object($a_xml_parser,$this);
00142                 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00143                 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00144         }
00145 
00146         function startParsing()
00147         {
00148 //echo "<b>start parsing</b><br>";
00149                 parent::startParsing();
00150 //echo "<b>storeTree</b><br>";
00151                 $this->storeTree();
00152 //echo "<b>processIntLinks</b><br>";
00153                 $this->processPagesToParse();
00154 //echo "<b>copyMobFiles</b><br>";
00155                 $this->copyMobFiles();
00156 //echo "<b>copyFileItems</b><br>";
00157                 $this->copyFileItems();
00158         }
00159 
00163         function storeTree()
00164         {
00165                 global $ilLog;
00166 
00167 //echo "<b>Storing the tree</b><br>";
00168                 foreach($this->st_into_tree as $st)
00169                 {
00170 //echo "insert st id: ".$st["id"].", parent:".$st["parent"]."<br>";
00171                         $this->lm_tree->insertNode($st["id"], $st["parent"]);
00172 //echo "done<br>";
00173                         if (is_array($this->pg_into_tree[$st["id"]]))
00174                         {
00175                                 foreach($this->pg_into_tree[$st["id"]] as $pg)
00176                                 {
00177                                         switch ($pg["type"])
00178                                         {
00179                                                 case "pg_alias":
00180                                                         if ($this->pg_mapping[$pg["id"]] == "")
00181                                                         {
00182                                                                 $ilLog->write("LM Import: No PageObject for PageAlias ".$pg["id"]." found! (Please update export installation to ILIAS 3.3.0)");
00183                                                                 continue;
00184                                                         }
00185                                                         $pg_id = $this->pg_mapping[$pg["id"]];
00186                                                         break;
00187 
00188                                                 case "pg":
00189                                                         $pg_id = $pg["id"];
00190                                                         break;
00191                                         }
00192                                         if (!$this->lm_tree->isInTree($pg_id))
00193                                         {
00194                                                 $this->lm_tree->insertNode($pg_id, $st["id"]);
00195                                         }
00196                                 }
00197                         }
00198                 }
00199 //echo "6";
00200 //echo "<b>END: storing the tree</b>";
00201         }
00202 
00203 
00207         function processPagesToParse()
00208         {
00209                 /*
00210                 $pg_mapping = array();
00211                 foreach($this->pg_mapping as $key => $value)
00212                 {
00213                         $pg_mapping[$key] = "il__pg_".$value;
00214                 }*/
00215 //echo "<br><b>processIntLinks</b>"; flush();
00216                 // outgoin internal links
00217                 foreach($this->pages_to_parse as $page_id)
00218                 {
00219                         $page_arr = explode(":", $page_id);
00220 //echo "<br>resolve:".$this->content_object->getType().":".$page_id; flush();
00221                         switch($page_arr[0])
00222                         {
00223                                 case "lm":
00224                                         $page_obj =& new ilPageObject($this->content_object->getType(), $page_arr[1]);
00225                                         break;
00226 
00227                                 case "gdf":
00228                                         $page_obj =& new ilPageObject("gdf", $page_arr[1]);
00229                                         break;
00230                         }
00231                         $page_obj->buildDom();
00232                         $page_obj->resolveIntLinks();
00233                         $page_obj->update(false);
00234 
00235                         if ($page_arr[0] == "gdf")
00236                         {
00237                                 $def =& new ilGlossaryDefinition($page_arr[1]);
00238                                 $def->updateShortText();
00239                         }
00240 
00241                         unset($page_obj);
00242                 }
00243 
00244 //echo "<br><b>map area internal links</b>"; flush();
00245                 // outgoins map area (mob) internal links
00246                 foreach($this->mobs_with_int_links as $mob_id)
00247                 {
00248                         ilMediaItem::_resolveMapAreaLinks($mob_id);
00249                 }
00250 
00251 //echo "<br><b>incoming interna links</b>"; flush();
00252                 // incoming internal links
00253                 $done = array();
00254                 foreach ($this->link_targets as $link_target)
00255                 {
00256 //echo "doin link target:".$link_target.":<br>";
00257                         $link_arr = explode("_", $link_target);
00258                         $target_inst = $link_arr[1];
00259                         $target_type = $link_arr[2];
00260                         $target_id = $link_arr[3];
00261                         $sources = ilInternalLink::_getSourcesOfTarget($target_type, $target_id, $target_inst);
00262                         foreach($sources as $key => $source)
00263                         {
00264 //echo "got source:".$key.":<br>";
00265                                 if(in_array($key, $done))
00266                                 {
00267                                         continue;
00268                                 }
00269                                 $type_arr = explode(":", $source["type"]);
00270 
00271                                 // content object pages
00272                                 if ($type_arr[1] == "pg")
00273                                 {
00274                                         $page_object = new ilPageObject($type_arr[0], $source["id"]);
00275                                         $page_object->buildDom();
00276                                         $page_object->resolveIntLinks();
00277                                         $page_object->update();
00278                                         unset($page_object);
00279                                 }
00280                                 // eventually correct links in questions to learning modules
00281                                 if ($type_arr[0] == "qst")
00282                                 {
00283                                         require_once "./assessment/classes/class.assQuestion.php";
00284                                         ASS_Question::_resolveIntLinks($source["id"]);
00285                                 }
00286                                 // eventually correct links in survey questions to learning modules
00287                                 if ($type_arr[0] == "sqst")
00288                                 {
00289                                         require_once "./survey/classes/class.SurveyQuestion.php";
00290                                         ASS_Question::_resolveIntLinks($source["id"]);
00291                                 }
00292                                 $done[$key] = $key;
00293                         }
00294                 }
00295         }
00296 
00297 
00301         function copyMobFiles()
00302         {
00303                 $imp_dir = $this->content_object->getImportDirectory();
00304                 foreach ($this->mob_mapping as $origin_id => $mob_id)
00305                 {
00306                         if(empty($origin_id))
00307                         {
00308                                 continue;
00309                         }
00310 
00311                         /*
00312                         $origin_arr = explode("_", $origin_id);
00313                         if ($origin_arr[2] == "el") // imagemap
00314                         {
00315                                 $obj_dir = "imagemap".$origin_arr[3];
00316                         }
00317                         else // normal media object
00318                         {
00319                                 $obj_dir = "mm".$origin_arr[3];
00320                         }*/
00321 
00322                         $obj_dir = $origin_id;
00323                         $source_dir = $imp_dir."/".$this->subdir."/objects/".$obj_dir;
00324                         $target_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$mob_id;
00325 
00326 //echo "copy from $source_dir to $target_dir <br>";
00327                         if (@is_dir($source_dir))
00328                         {
00329                                 // make target directory
00330                                 ilUtil::makeDir($target_dir);
00331                                 //@mkdir($target_dir);
00332                                 //@chmod($target_dir, 0755);
00333 
00334                                 if (@is_dir($target_dir))
00335                                 {
00336                                         ilUtil::rCopy($source_dir, $target_dir);
00337                                 }
00338                         }
00339                 }
00340         }
00341 
00345         function copyFileItems()
00346         {
00347                 $imp_dir = $this->content_object->getImportDirectory();
00348                 foreach ($this->file_item_mapping as $origin_id => $file_id)
00349                 {
00350                         if(empty($origin_id))
00351                         {
00352                                 continue;
00353                         }
00354                         $obj_dir = $origin_id;
00355                         $source_dir = $imp_dir."/".$this->subdir."/objects/".$obj_dir;
00356                         $target_dir = ilUtil::getDataDir()."/files/file_".$file_id;
00357 
00358 //echo "copy from $source_dir to $target_dir <br>";
00359                         if (@is_dir($source_dir))
00360                         {
00361                                 // make target directory
00362                                 ilUtil::makeDir($target_dir);
00363                                 //@mkdir($target_dir);
00364                                 //@chmod($target_dir, 0755);
00365 
00366                                 if (@is_dir($target_dir))
00367                                 {
00368                                         ilUtil::rCopy($source_dir, $target_dir);
00369                                 }
00370                         }
00371                 }
00372         }
00373         
00377         function setQuestionMapping($a_map)
00378         {
00379                 $this->qst_mapping = $a_map;
00380         }
00381 
00382 
00383         /*
00384         * update parsing status for a element begin
00385         */
00386         function beginElement($a_name)
00387         {
00388                 if(!isset($this->status["$a_name"]))
00389                 {
00390                         $this->cnt[$a_name] == 1;
00391                 }
00392                 else
00393                 {
00394                         $this->cnt[$a_name]++;
00395                 }
00396                 $this->current_element[count($this->current_element)] = $a_name;
00397         }
00398 
00399         /*
00400         * update parsing status for an element ending
00401         */
00402         function endElement($a_name)
00403         {
00404                 $this->cnt[$a_name]--;
00405                 unset ($this->current_element[count($this->current_element) - 1]);
00406         }
00407 
00408         /*
00409         * returns current element
00410         */
00411         function getCurrentElement()
00412         {
00413                 return ($this->current_element[count($this->current_element) - 1]);
00414         }
00415 
00416         /*
00417         * returns number of current open elements of type $a_name
00418         */
00419         function getOpenCount($a_name)
00420         {
00421                 if (isset($this->cnt[$a_name]))
00422                 {
00423                         return $this->cnt[$a_name];
00424                 }
00425                 else
00426                 {
00427                         return 0;
00428                 }
00429 
00430         }
00431 
00439         function buildTag ($type, $name, $attr="")
00440         {
00441                 $tag = "<";
00442 
00443                 if ($type == "end")
00444                         $tag.= "/";
00445 
00446                 $tag.= $name;
00447 
00448                 if (is_array($attr))
00449                 {
00450                         while (list($k,$v) = each($attr))
00451                                 $tag.= " ".$k."=\"$v\"";
00452                 }
00453 
00454                 $tag.= ">";
00455 
00456                 return $tag;
00457         }
00458 
00462         function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
00463         {
00464 //echo "<b>BEGIN TAG: $a_name <br></b>"; flush();
00465                 switch($a_name)
00466                 {
00467                         case "ContentObject":
00468                                 $this->current_object =& $this->content_object;
00469 //echo "<br>Parser:CObjType:".$a_attribs["Type"];
00470                                 if ($a_attribs["Type"] == "Glossary")
00471                                 {
00472                                         $this->glossary_object =& $this->content_object;
00473                                 }
00474                                 break;
00475 
00476                         case "StructureObject":
00477 //echo "<br><br>StructureOB-SET-".count($this->structure_objects)."<br>";
00478                                 $this->structure_objects[count($this->structure_objects)]
00479                                         =& new ilStructureObject($this->content_object);
00480                                 $this->current_object =& $this->structure_objects[count($this->structure_objects) - 1];
00481                                 $this->current_object->setLMId($this->content_object->getId());
00482                                 break;
00483 
00484                         case "PageObject":
00485                                 $this->in_page_object = true;
00486                                 $this->cur_qid = "";
00487                                 if (($this->coType != "tst") and ($this->coType != "qpl"))
00488                                 {
00489                                         $this->lm_page_object =& new ilLMPageObject($this->content_object);
00490                                         $this->page_object =& new ilPageObject($this->content_object->getType());
00491                                         $this->lm_page_object->setLMId($this->content_object->getId());
00492                                         $this->lm_page_object->assignPageObject($this->page_object);
00493                                         $this->current_object =& $this->lm_page_object;
00494                                 }
00495                                 else
00496                                 {
00497                                         $this->page_object =& new ilPageObject("qpl");
00498                                 }
00499                                 break;
00500 
00501                         case "PageAlias":
00502                                 if (($this->coType != "tst") and ($this->coType != "qpl"))
00503                                 {
00504                                         $this->lm_page_object->setAlias(true);
00505                                         $this->lm_page_object->setOriginID($a_attribs["OriginId"]);
00506                                 }
00507                                 break;
00508 
00509                         case "MediaObject":
00510                                 $this->in_media_object = true;
00511                                 $this->media_object =& new ilObjMediaObject();
00512                                 break;
00513 
00514                         case "MediaAlias":
00515 //echo "<br>---NEW MEDIAALIAS---<br>";
00516                                 $this->media_object->setAlias(true);
00517                                 $this->media_object->setOriginID($a_attribs["OriginId"]);
00518                                 if (is_object($this->page_object))
00519                                 {
00520                                         $this->page_object->needsImportParsing(true);
00521                                 }
00522                                 break;
00523 
00524                         case "MediaItem":
00525                         case "MediaAliasItem":
00526                                 $this->in_media_item = true;
00527                                 $this->media_item =& new ilMediaItem();
00528                                 $this->media_item->setPurpose($a_attribs["Purpose"]);
00529                                 break;
00530 
00531                         case "Layout":
00532                                 if (is_object($this->media_object) && $this->in_media_object)
00533                                 {
00534                                         $this->media_item->setWidth($a_attribs["Width"]);
00535                                         $this->media_item->setHeight($a_attribs["Height"]);
00536                                         $this->media_item->setHAlign($a_attribs["HorizontalAlign"]);
00537                                 }
00538                                 break;
00539 
00540                         case "Parameter":
00541                                 if (is_object($this->media_object) && $this->in_media_object)
00542                                 {
00543                                         $this->media_item->setParameter($a_attribs["Name"], $a_attribs["Value"]);
00544                                 }
00545                                 break;
00546 
00547                         case "MapArea":
00548                                 $this->in_map_area = true;
00549                                 $this->map_area =& new ilMapArea();
00550                                 $this->map_area->setShape($a_attribs["Shape"]);
00551                                 $this->map_area->setCoords($a_attribs["Coords"]);
00552                                 break;
00553 
00554                         case "Glossary":
00555                                 $this->in_glossary = true;
00556                                 if ($this->content_object->getType() != "glo")
00557                                 {
00558                                         $this->glossary_object =& new ilObjGlossary();
00559                                         $this->glossary_object->setTitle("");
00560                                         $this->glossary_object->setDescription("");
00561                                         $this->glossary_object->create();
00562                                         $this->glossary_object->createReference();
00563                                         $parent =& $this->tree->getParentNodeData($this->content_object->getRefId());
00564                                         $this->glossary_object->putInTree($parent["child"]);
00565                                         $this->glossary_object->setPermissions($parent["child"]);
00566                                         $this->glossary_object->notify("new", $_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$this->glossary_object->getRefId());
00567                                 }
00568                                 $this->current_object =& $this->glossary_object;
00569                                 break;
00570 
00571                         case "GlossaryItem":
00572                                 $this->glossary_term =& new ilGlossaryTerm();
00573                                 $this->glossary_term->setGlossaryId($this->glossary_object->getId());
00574                                 $this->glossary_term->setLanguage($a_attribs["Language"]);
00575                                 $this->glossary_term->setImportId($a_attribs["Id"]);
00576                                 $this->link_targets[$a_attribs["Id"]] = $a_attribs["Id"];
00577                                 break;
00578 
00579                         case "Definition":
00580                                 $this->in_glossary_definition = true;
00581                                 $this->glossary_definition =& new ilGlossaryDefinition();
00582                                 $this->page_object =& new ilPageObject("gdf");
00583                                 $this->glossary_definition->setTermId($this->glossary_term->getId());
00584                                 $this->glossary_definition->assignPageObject($this->page_object);
00585                                 $this->current_object =& $this->glossary_definition;
00586                                 break;
00587 
00588                         case "FileItem":
00589                                 $this->in_file_item = true;
00590                                 $this->file_item =& new ilObjFile();
00591                                 $this->file_item->setTitle("dummy");
00592                                 if (is_object($this->page_object))
00593                                 {
00594                                         $this->page_object->needsImportParsing(true);
00595                                 }
00596                                 break;
00597 
00598                         case "Paragraph":
00599                                 if ($a_attribs["Characteristic"] == "Code")
00600                                 {
00601                                         $this->inside_code = true;
00602                                 }
00603                                 break;
00604 
00605 
00609                         case "MetaData":
00610                                 $this->in_meta_data = true;
00611 //echo "<br>---NEW METADATA---<br>";
00612                                 $this->meta_data =& new ilMetaData();
00613                                 if(!$this->in_media_object)
00614                                 {
00615 //echo "<br><b>assign to current object</b>";
00616                                         if (($this->coType != "tst") and ($this->coType != "qpl"))
00617                                         {
00618                                                 $this->current_object->assignMetaData($this->meta_data);
00619                                                 if (strtolower(get_class($this->current_object)) == "ilobjlearningmodule")
00620                                                 {
00621                                                         $this->meta_data->setId($this->content_object->getId());
00622                                                         $this->meta_data->setType("lm");
00623                                                 }
00624                                         }
00625                                 }
00626                                 else
00627                                 {
00628                                         $this->media_object->assignMetaData($this->meta_data);
00629                                 }
00630                                 break;
00631 
00632                         // GENERAL: Identifier
00633                         case "Identifier":
00634                                 if ($this->in_meta_data)
00635                                 {
00636                                         $this->meta_data->setImportIdentifierEntryID($a_attribs["Entry"]);
00637                                         $this->link_targets[$a_attribs["Entry"]] = $a_attribs["Entry"];
00638                                 }
00639                                 if ($this->in_file_item)
00640                                 {
00641                                         if ($this->file_item_mapping[$a_attribs["Entry"]] == "")
00642                                         {
00643                                                 $this->file_item->create();
00644                                                 $this->file_item->setImportId($a_attribs["Entry"]);
00645                                                 $this->file_item_mapping[$a_attribs["Entry"]] = $this->file_item->getId();
00646                                         }
00647                                 }
00648                                 break;
00649 
00650                         // GENERAL: Keyword
00651                         case "Keyword":
00652 //echo "<b>>>".count($this->meta_data->technicals)."</b><br>";
00653                                 $this->keyword_language = $a_attribs["Language"];
00654                                 break;
00655 
00656                         // Internal Link
00657                         case "IntLink":
00658                                 if (is_object($this->page_object))
00659                                 {
00660                                         $this->page_object->setContainsIntLink(true);
00661                                 }
00662                                 if ($this->in_map_area)
00663                                 {
00664 //echo "intlink:maparea:<br>";
00665                                         $this->map_area->setLinkType(IL_INT_LINK);
00666                                         $this->map_area->setTarget($a_attribs["Target"]);
00667                                         $this->map_area->setType($a_attribs["Type"]);
00668                                         $this->map_area->setTargetFrame($a_attribs["TargetFrame"]);
00669                                         if (is_object($this->media_object))
00670                                         {
00671 //echo ":setContainsLink:<br>";
00672                                                 $this->media_object->setContainsIntLink(true);
00673                                         }
00674                                 }
00675                                 break;
00676 
00677                         // External Link
00678                         case "ExtLink":
00679                                 if ($this->in_map_area)
00680                                 {
00681                                         $this->map_area->setLinkType(IL_EXT_LINK);
00682                                         $this->map_area->setHref($a_attribs["Href"]);
00683                                         $this->map_area->setExtTitle($a_attribs["Title"]);
00684                                 }
00685                                 break;
00686                                 
00687                         // Question
00688                         case "Question":
00689                                 $this->cur_qid = $a_attribs["QRef"];
00690                                 break;
00691 
00692                         // TECHNICAL
00693                         case "Technical":
00694                                 $this->meta_technical =& new ilMetaTechnical($this->meta_data);
00695                                 $this->meta_data->addTechnicalSection($this->meta_technical);
00696 //echo "<b>>>".count($this->meta_data->technicals)."</b><br>";
00697                                 break;
00698 
00699                         // TECHNICAL: Size
00700                         case "Size":
00701                                 $this->meta_technical->setSize($a_attribs["Size"]);
00702                                 break;
00703 
00704                         case "Location":
00705                                 $this->loc_type = $a_attribs["Type"];
00706                                 break;
00707 
00708                         // TECHNICAL: Requirement
00709                         case "Requirement":
00710                                 if (!is_object($this->requirement_set))
00711                                 {
00712                                         $this->requirement_set =& new ilMetaTechnicalRequirementSet();
00713                                 }
00714                                 $this->requirement =& new ilMetaTechnicalRequirement();
00715                                 break;
00716 
00717                         // TECHNICAL: OperatingSystem
00718                         case "OperatingSystem":
00719                                 $this->requirement->setType("OperatingSystem");
00720                                 $this->requirement->setName($a_attribs["Name"]);
00721                                 $this->requirement->setMinVersion($a_attribs["MinimumVersion"]);
00722                                 $this->requirement->setMaxVersion($a_attribs["MaximumVersion"]);
00723                                 break;
00724 
00725                         // TECHNICAL: Browser
00726                         case "Browser":
00727                                 $this->requirement->setType("Browser");
00728                                 $this->requirement->setName($a_attribs["Name"]);
00729                                 $this->requirement->setMinVersion($a_attribs["MinimumVersion"]);
00730                                 $this->requirement->setMaxVersion($a_attribs["MaximumVersion"]);
00731                                 break;
00732 
00733                         // TECHNICAL: OrComposite
00734                         case "OrComposite":
00735                                 $this->meta_technical->addRequirementSet($this->requirement_set);
00736                                 unset($this->requirement_set);
00737                                 break;
00738 
00739                         // TECHNICAL: InstallationRemarks
00740                         case "InstallationRemarks":
00741                                 $this->meta_technical->setInstallationRemarksLanguage($a_attribs["Language"]);
00742                                 break;
00743 
00744                         // TECHNICAL: InstallationRemarks
00745                         case "OtherPlatformRequirements":
00746                                 $this->meta_technical->setOtherRequirementsLanguage($a_attribs["Language"]);
00747                                 break;
00748 
00749                         case "Bibliography":
00750                                 $this->in_bib_item = true;
00751 #echo "<br>---NEW BIBLIOGRAPHY---<br>";
00752                                 $this->bib_item =& new ilBibItem();
00753                                 break;
00754 
00755                 }
00756                 $this->beginElement($a_name);
00757 //echo "Begin Tag: $a_name<br>";
00758 
00759                 // append content to page xml content
00760                 if(($this->in_page_object || $this->in_glossary_definition)
00761                         && !$this->in_meta_data && !$this->in_media_object)
00762                 {
00763                         if ($a_name == "Definition")
00764                         {
00765                                 $app_name = "PageObject";
00766                                 $app_attribs = array();
00767                         }
00768                         else
00769                         {
00770                                 $app_name = $a_name;
00771                                 $app_attribs = $a_attribs;
00772                         }
00773 
00774                         // change identifier entry of file items to new local file id
00775                         if ($this->in_file_item && $app_name == "Identifier")
00776                         {
00777                                 $app_attribs["Entry"] = "il__file_".$this->file_item_mapping[$a_attribs["Entry"]];
00778                                 //$app_attribs["Entry"] = "il__file_".$this->file_item->getId();
00779                         }
00780 
00781                         $this->page_object->appendXMLContent($this->buildTag("start", $app_name, $app_attribs));
00782 //echo "&nbsp;&nbsp;after append, xml:".$this->page_object->getXMLContent().":<br>";
00783                 }
00784                 // append content to meta data xml content
00785                 if ($this->in_meta_data )   // && !$this->in_page_object && !$this->in_media_object
00786                 {
00787                         $this->meta_data->appendXMLContent("\n".$this->buildTag("start", $a_name, $a_attribs));
00788                 }
00789                 // append content to bibitem xml content
00790                 if ($this->in_bib_item)   // && !$this->in_page_object && !$this->in_media_object
00791                 {
00792                         $this->bib_item->appendXMLContent("\n".$this->buildTag("start", $a_name, $a_attribs));
00793                 }
00794         }
00795 
00796 
00800         function handlerEndTag($a_xml_parser,$a_name)
00801         {
00802 //echo "<b>END TAG: $a_name <br></b>"; flush();
00803                 // append content to page xml content
00804                 if (($this->in_page_object || $this->in_glossary_definition)
00805                         && !$this->in_meta_data && !$this->in_media_object)
00806                 {
00807                         $app_name = ($a_name == "Definition")
00808                                 ? "PageObject"
00809                                 : $a_name;
00810                         $this->page_object->appendXMLContent($this->buildTag("end", $app_name));
00811                 }
00812 
00813                 if ($this->in_meta_data)        //  && !$this->in_page_object && !$this->in_media_object
00814 
00815                 // append content to metadataxml content
00816                 if($a_name == "MetaData")
00817                 {
00818                         $this->meta_data->appendXMLContent("\n".$this->buildTag("end", $a_name));
00819                 }
00820                 else
00821                 {
00822                         $this->meta_data->appendXMLContent($this->buildTag("end", $a_name));
00823                 }
00824 
00825                 // append content to bibitemxml content
00826                 if ($this->in_bib_item) // && !$this->in_page_object && !$this->in_media_object
00827                 {
00828                         if($a_name == "BibItem")
00829                         {
00830                                 $this->bib_item->appendXMLContent("\n".$this->buildTag("end", $a_name));
00831                         }
00832                         else
00833                         {
00834                                 $this->bib_item->appendXMLContent($this->buildTag("end", $a_name));
00835                         }
00836 
00837                 }
00838 
00839                 switch($a_name)
00840                 {
00841                         case "StructureObject":
00842                                 unset($this->meta_data);
00843                                 unset($this->structure_objects[count($this->structure_objects) - 1]);
00844                                 break;
00845 
00846                         case "PageObject":
00847 
00848                                 $this->in_page_object = false;
00849                                 if (($this->coType != "tst") and ($this->coType != "qpl"))
00850                                 {
00851                                         if (!$this->lm_page_object->isAlias())
00852                                         {
00853                                                 //$this->page_object->createFromXML();
00854                                                 $this->page_object->updateFromXML();
00855                                                 $this->pg_mapping[$this->lm_page_object->getImportId()]
00856                                                         = $this->lm_page_object->getId();
00857         
00858                                                 // collect pages with internal links
00859                                                 if ($this->page_object->containsIntLink())
00860                                                 {
00861                                                         //echo "<br>Page contains Int Link:".$this->page_object->getId();
00862                                                         $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
00863                                                 }
00864                                                 if ($this->page_object->needsImportParsing())
00865                                                 {
00866                                                         //echo "<br>Page needs import parsing:".$this->page_object->getId();
00867                                                         $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
00868                                                 }
00869                                         }
00870                                 }
00871                                 else
00872                                 {
00873                                         $xml = $this->page_object->getXMLContent();
00874                                         if ($this->cur_qid != "")
00875                                         {
00876                                                 $ids = $this->qst_mapping[$this->cur_qid];
00877                                                 if ($ids["pool"] > 0)
00878                                                 {
00879                                                         // question pool question
00880                                                         $page = new ilPageObject("qpl", $ids["pool"]);
00881                                                         $xmlcontent = str_replace($this->cur_qid, 
00882                                                                 "il__qst_".$ids["pool"], $xml);
00883                                                         $page->setXMLContent($xmlcontent);
00884                                                         $page->saveMobUsage($xmlcontent);
00885                                                         $page->updateFromXML();
00886                                                         unset($page);
00887                                                 }
00888                                                 if ($ids["test"] > 0)
00889                                                 {
00890                                                         // test question
00891                                                         $page = new ilPageObject("qpl", $ids["test"]);
00892                                                         $xmlcontent = str_replace($this->cur_qid, 
00893                                                                 "il__qst_".$ids["test"], $xml);
00894                                                         $page->setXMLContent($xmlcontent);
00895                                                         $page->saveMobUsage($xmlcontent);
00896                                                         $page->updateFromXML();
00897                                                         unset($page);
00898                                                 }
00899                                         }
00900                                 }
00901 
00902                                 // if we are within a structure object: put page in tree
00903                                 $cnt = count($this->structure_objects);
00904                                 if ($cnt > 0)
00905                                 {
00906                                         $parent_id = $this->structure_objects[$cnt - 1]->getId();
00907                                         if ($this->lm_page_object->isAlias())
00908                                         {
00909                                                 $this->pg_into_tree[$parent_id][] = array("type" => "pg_alias", "id" => $this->lm_page_object->getOriginId());
00910                                         }
00911                                         else
00912                                         {
00913                                                 $this->pg_into_tree[$parent_id][] = array("type" => "pg", "id" => $this->lm_page_object->getId());
00914                                         }
00915                                 }
00916 
00917                                 // if we are within a structure object: put page in tree
00918                                 unset($this->meta_data);        
00919                                 unset($this->page_object);
00920                                 unset($this->lm_page_object);
00921                                 unset ($this->container[count($this->container) - 1]);
00922                                 break;
00923 
00924                         case "MediaObject":
00925                                 $this->in_media_object = false;
00926 //echo "ENDMediaObject:ImportId:".$this->media_object->getImportId()."<br>";
00927                                 // create media object on first occurence of an Id
00928                                 if(empty($this->mob_mapping[$this->media_object->getImportId()]))
00929                                 {
00930                                         if ($this->media_object->isAlias())
00931                                         {
00932                                                 // this data will be overwritten by the "real" mob
00933                                                 // see else section below
00934                                                 $dummy_meta =& new ilMetaData();
00935                                                 $this->media_object->assignMetaData($dummy_meta);
00936                                                 $this->media_object->setTitle("dummy");
00937 //echo "<br>mob create (alias):";
00938                                         }
00939                                         else
00940                                         {
00941 //echo "<br>mob create (real):";
00942                                                 $this->media_object->setTitle($this->meta_data->getTitle());
00943                                         }
00944 
00945                                         // create media object
00946 //echo "creating media object:title:".$this->media_object->getTitle().":".
00947 //      $this->meta_data->getTitle().":<br>";
00948                                         $this->media_object->create();
00949 //echo $this->media_object->getId().":".$this->media_object->getTitle().":".
00950 //      $this->media_object->meta_data->getTitle().":";
00951                                         // collect mobs with internal links
00952                                         if ($this->media_object->containsIntLink())
00953                                         {
00954 //echo "got int link :".$this->media_object->getId().":<br>";
00955                                                 $this->mobs_with_int_links[] = $this->media_object->getId();
00956                                         }
00957 
00958                                         $this->mob_mapping[$this->media_object->getImportId()]
00959                                                         = $this->media_object->getId();
00960 //echo "create:import_id:".$this->media_object->getImportId().":ID:".$this->mob_mapping[$this->media_object->getImportId()]."<br>";
00961                                 }
00962                                 else
00963                                 {
00964                                         // get the id from mapping
00965                                         $this->media_object->setId($this->mob_mapping[$this->media_object->getImportId()]);
00966 
00967                                         // update "real" (no alias) media object
00968                                         // (note: we overwrite any data from the dummy mob
00969                                         // created by an MediaAlias, only the data of the real
00970                                         // object is stored in db separately; data of the
00971                                         // MediaAliases are within the page XML
00972                                         if (!$this->media_object->isAlias())
00973                                         {
00974 //echo "<b>REAL UPDATING STARTS HERE</b><br>";
00975 //echo "<b>>>".count($this->meta_data->technicals)."</b><br>";
00976 //echo "origin:".$this->media_object->getImportId().":ID:".$this->mob_mapping[$this->media_object->getImportId()]."<br>";
00977 
00978                                                 // update media object
00979 
00980                                                 $this->meta_data->setId($this->media_object->getId());
00981                                                 $this->meta_data->setType("mob");
00982                                                 $this->media_object->assignMetaData($this->meta_data);
00983                                                 $this->media_object->setTitle($this->meta_data->getTitle());
00984                                                 $this->media_object->setDescription($this->meta_data->getDescription());
00985 
00986                                                 $this->media_object->update();
00987 //echo "<br>update media object :".$this->media_object->getId().":".
00988 //                                              $this->media_object->getTitle().":".
00989 //                                              $this->meta_data->getTitle();
00990 
00991                                                 // collect mobs with internal links
00992                                                 if ($this->media_object->containsIntLink())
00993                                                 {
00994 //echo "got int link :".$this->media_object->getId().":<br>";
00995                                                         $this->mobs_with_int_links[] = $this->media_object->getId();
00996                                                 }
00997                                         }
00998                                 }
00999 
01000                                 // append media alias to page, if we are in a page
01001                                 if ($this->in_page_object || $this->in_glossary_definition)
01002                                 {
01003                                         $this->page_object->appendXMLContent($this->media_object->getXML(IL_MODE_ALIAS));
01004 //echo "Appending:".htmlentities($this->media_object->getXML(IL_MODE_ALIAS))."<br>";
01005                                 }
01006 
01007                                 break;
01008 
01009                         case "MediaItem":
01010                         case "MediaAliasItem":
01011                                 $this->in_media_item = false;
01012                                 $this->media_object->addMediaItem($this->media_item);
01013 //echo "adding media item";
01014                                 break;
01015 
01016                         case "MapArea":
01017                                 $this->in_map_area = false;
01018                                 $this->media_item->addMapArea($this->map_area);
01019                                 break;
01020 
01021 
01022                         case "MetaData":
01023                                 $this->in_meta_data = false;
01024                                 if(strtolower(get_class($this->current_object)) == "illmpageobject" && !$this->in_media_object)
01025                                 {
01026                                         // Metadaten eines PageObjects sichern in NestedSet
01027                                         if (is_object($this->lm_page_object))
01028                                         {
01029                                                 $this->lm_page_object->create(true);
01030                                                 //$this->page_object->createFromXML();
01031 
01032                                                 include_once("./classes/class.ilNestedSetXML.php");
01033                                                 $nested = new ilNestedSetXML();
01034                                                 $xml = $this->meta_data->getXMLContent();
01035 //echo "<br><br>".htmlentities($xml);
01036                                                 $nested->dom = domxml_open_mem($xml);
01037                                                 $nodes = $nested->getDomContent("//MetaData/General", "Identifier");
01038                                                 if (is_array($nodes))
01039                                                 {
01040                                                         $nodes[0]["Entry"] = "il__" . $this->current_object->getType() . "_" . $this->current_object->getId();
01041                                                         $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]);
01042                                                 }
01043                                                 $xml = $nested->dom->dump_mem(0);
01044 //$xml = str_replace("&quot;", "\"", $xml);
01045 //echo "<br><br>".htmlentities($xml);
01046                                                 $nested->import($xml,$this->lm_page_object->getId(),"pg");
01047                                         }
01048         }
01049                                 else if((strtolower(get_class($this->current_object)) == "ilobjquestionpool" ||
01050                                         strtolower(get_class($this->current_object)) == "ilobjtest") &&
01051                                         !$this->in_media_object && !$this->in_page_object)
01052                                 {
01053                                         // Metadaten eines Questionpool-Objekts sichern in NestedSet
01054                                         include_once("./classes/class.ilNestedSetXML.php");
01055                                         $nested = new ilNestedSetXML();
01056                                         $xml = $this->meta_data->getXMLContent();
01057 //echo "<br><br>".htmlentities($xml);
01058                                         $nested->dom = domxml_open_mem($xml);
01059                                         $nodes = $nested->getDomContent("//MetaData/General", "Identifier");
01060                                         if (is_array($nodes))
01061                                         {
01062                                                 $nodes[0]["Entry"] = "il__" . $this->current_object->getType() . "_" . $this->current_object->getId();
01063                                                 $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]);
01064                                         }
01065                                         $xml = $nested->dom->dump_mem(0);
01066 //$xml = str_replace("&quot;", "\"", $xml);
01067 //echo "<br><br>".htmlentities($xml);
01068                                         $nested->import($xml, $this->current_object->getId(), $this->current_object->getType());
01069                                 }
01070                                 else if(strtolower(get_class($this->current_object)) == "ilstructureobject")
01071                                 {    // save structure object at the end of its meta block
01072                                         // determine parent
01073                                         $cnt = count($this->structure_objects);
01074                                         if ($cnt > 1)
01075                                         {
01076                                                 $parent_id = $this->structure_objects[$cnt - 2]->getId();
01077                                         }
01078                                         else
01079                                         {
01080                                                 $parent_id = $this->lm_tree->getRootId();
01081                                         }
01082 
01083                                         // create structure object and put it in tree
01084                                         $this->current_object->create(true);
01085                                         $this->st_into_tree[] = array ("id" => $this->current_object->getId(),
01086                                                 "parent" => $parent_id);
01087 
01088                                         // Metadaten eines StructureObjects sichern in NestedSet
01089                                         include_once("./classes/class.ilNestedSetXML.php");
01090                                         $nested = new ilNestedSetXML();
01091                                         $xml = $this->meta_data->getXMLContent();
01092                                         $nested->dom = domxml_open_mem($xml);
01093                                         $nodes = $nested->getDomContent("//MetaData/General", "Identifier");
01094                                         if (is_array($nodes))
01095                                         {
01096                                                 $nodes[0]["Entry"] = "il__" . $this->current_object->getType() . "_" . $this->current_object->getId();
01097                                                 $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]);
01098                                         }
01099                                         $xml = $nested->dom->dump_mem(0);
01100                                         $nested->import($xml,$this->current_object->getId(),"st");
01101                                 }
01102                                 else if(strtolower(get_class($this->current_object)) == "ilobjdlbook" || strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
01103                                         strtolower(get_class($this->current_object)) == "ilobjcontentobject" ||
01104                                         (strtolower(get_class($this->current_object)) == "ilobjglossary" && $this->in_glossary))
01105                                 {
01106                                         // Metadaten eines ContentObjects sichern in NestedSet
01107                                         include_once("./classes/class.ilNestedSetXML.php");
01108                                         $nested = new ilNestedSetXML();
01109                                         $xml = $this->meta_data->getXMLContent();
01110                                         $nested->dom = domxml_open_mem($xml);
01111                                         $nodes = $nested->getDomContent("//MetaData/General", "Identifier");
01112                                         if (is_array($nodes))
01113                                         {
01114                                                 $nodes[0]["Entry"] = "il__" . $this->current_object->getType() . "_" . $this->current_object->getId();
01115                                                 $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]);
01116                                         }
01117                                         $xml = $nested->dom->dump_mem(0);
01118 //echo "<br><br>class:".get_class($this->current_object).":".htmlentities($xml).":<br>";
01119 //echo "<br>ID:".$this->current_object->getId().":Type:".$this->current_object->getType();
01120 //echo $this->in_glossary;
01121                                         $nested->import($xml,$this->current_object->getId(),$this->current_object->getType());
01122                                 }
01123                                 else if(strtolower(get_class($this->current_object)) == "ilglossarydefinition" && !$this->in_media_object)
01124                                 {
01125 //echo "<br><br>class:".get_class($this->current_object).":".htmlentities($this->meta_data->getXMLContent()).":<br>";
01126                                         $this->glossary_definition->create();
01127 //echo "<br>ID:".$this->current_object->getId().":Type:".$this->current_object->getType();
01128                                         $this->page_object->setId($this->glossary_definition->getId());
01129                                         $this->page_object->updateFromXML();
01130 //echo "saving page_object, xml:".$this->page_object->getXMLContent().":<br>";
01131                                         // save glossary term definition to nested set
01132                                         include_once("./classes/class.ilNestedSetXML.php");
01133                                         $nested = new ilNestedSetXML();
01134                                         $xml = $this->meta_data->getXMLContent();
01135                                         $nested->dom = domxml_open_mem($xml);
01136                                         $nodes = $nested->getDomContent("//MetaData/General", "Identifier");
01137                                         if (is_array($nodes))
01138                                         {
01139                                                 $nodes[0]["Entry"] = "il__" . $this->current_object->getType() . "_" . $this->current_object->getId();
01140                                                 $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]);
01141                                         }
01142                                         $xml = $nested->dom->dump_mem(0);
01143 //echo "<br><br>class:".get_class($this->current_object).":".htmlentities($xml).":<br>";
01144 //echo "<br>ID:".$this->glossary_definition->getId().":Type:gdf";
01145                                         $nested->import($xml,$this->glossary_definition->getId(),"gdf");
01146                                 }
01147 
01148 
01149                                 if(strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
01150                                         strtolower(get_class($this->current_object)) == "ilobjdlbook" ||
01151                                         strtolower(get_class($this->current_object)) == "ilobjglossary")
01152                                 {
01153                                         if (strtolower(get_class($this->current_object)) == "ilobjglossary" &&
01154                                                 $this->content_object->getType() != "glo")
01155                                         {
01156 //echo "<br><b>getting2: ".$this->content_object->getTitle()."</b>";
01157                                                 $this->current_object->setTitle($this->content_object->getTitle()." - ".
01158                                                         $this->lng->txt("glossary"));
01159                                         }
01160                                         $this->current_object->update();
01161                                 }
01162 
01163 #                               echo "Type: " . $this->current_object->getType() . "<br>\n";
01164 #                               echo "Obj.-ID: " . $this->current_object->getId() . "<br>\n";
01165                                 break;
01166 
01167                         case "FileItem":
01168                                 $this->in_file_item = false;
01169                                 // only update new file items
01170                                 if ($this->file_item->getImportId($a_attribs["Entry"] != ""))
01171                                 {
01172                                         $this->file_item->update();
01173                                 }
01174                                 break;
01175 
01176                         case "Bibliography":
01177 
01178                                 $this->in_bib_item = false;
01179 
01180                                 $nested = new ilNestedSetXML();
01181                                 $nested->import($this->bib_item->getXMLContent(),$this->content_object->getId(),"bib");
01182                                 break;
01183 
01184                         case "Table":
01185                                 unset ($this->container[count($this->container) - 1]);
01186                                 break;
01187 
01188                         case "Glossary":
01189                                 $this->in_glossary = false;
01190                                 break;
01191 
01192                         case "GlossaryTerm":
01193                                 $this->glossary_term->setTerm(trim($this->chr_data));
01194                                 $this->glossary_term->create();
01195                                 break;
01196 
01197                         case "Paragraph":
01198                                 $this->inside_code = false;
01199                                 break;
01200 
01201                         case "Definition":
01202                                 $this->in_glossary_definition = false;
01203                                 $this->page_object->updateFromXML();
01204                                 $this->page_object->buildDom();
01205                                 $this->glossary_definition->setShortText($this->page_object->getFirstParagraphText());
01206                                 $this->glossary_definition->update();
01207                                 //$this->pg_mapping[$this->lm_page_object->getImportId()]
01208                                 //      = $this->lm_page_object->getId();
01209                                 if ($this->page_object->containsIntLink())
01210                                 {
01211 //echo "<br>Definition contains Int Link:".$this->page_object->getId();
01212                                         $this->pages_to_parse["gdf:".$this->page_object->getId()] = "gdf:".$this->page_object->getId();
01213                                 }
01214                                 break;
01215 
01216                         case "Format":
01217                                 if ($this->in_media_item)
01218                                 {
01219                                         $this->media_item->setFormat(trim($this->chr_data));
01220                                 }
01221                                 if ($this->in_meta_data)
01222                                 {
01223                                         $this->meta_technical->addFormat($this->chr_data);
01224                                 }
01225                                 if ($this->in_file_item)
01226                                 {
01227                                         $this->file_item->setFileType(trim($this->chr_data));
01228                                 }
01229                                 break;
01230 
01231                         case "Title":
01232                                 if (!$this->in_media_object)
01233                                 {
01234                                         $this->current_object->setTitle(trim($this->chr_data));
01235                                         $this->meta_data->setTitle(trim($this->chr_data));
01236                                 }
01237                                 else
01238                                 {
01239                                         $this->media_object->setTitle(trim($this->chr_data));
01240                                         $this->meta_data->setTitle(trim($this->chr_data));
01241                                 }
01242                                 break;
01243 
01244                         case "Language":
01245                                 if (is_object($this->meta_data))
01246                                 {
01247                                         $this->meta_data->setLanguage(trim($this->chr_data));
01248                                 }
01249                                 else if (is_object($this->bib_item))
01250                                 {
01251                                         $this->bib_item->setLanguage(trim($this->chr_data));
01252                                 }
01253                                 break;
01254 
01255                         case "Description":
01256                                 $this->meta_data->setDescription(trim($this->chr_data));
01257                                 break;
01258 
01259                         case "Caption":
01260                                 if ($this->in_media_object)
01261                                 {
01262                                         $this->media_item->setCaption(trim($this->chr_data));
01263                                 }
01264                                 break;
01265 
01266                         // Location
01267                         case "Location":
01268                                 // TODO: adapt for files in "real" subdirectories
01269                                 if ($this->in_media_item)
01270                                 {
01271                                         $this->media_item->setLocationType($this->loc_type);
01272                                         $this->media_item->setLocation(trim($this->chr_data));
01273                                 }
01274                                 if ($this->in_meta_data)
01275                                 {
01276                                         //$this->meta_technical->addLocation($this->loc_type, $a_data);
01277                                 }
01278                                 if ($this->in_file_item)
01279                                 {
01280                                         // set file name from xml file
01281                                         $this->file_item->setFileName(trim($this->chr_data));
01282                                         
01283                                         // special handling for file names with special characters
01284                                         // (e.g. "&gt;")
01285                                         if ($this->file_item->getType() == "file" &&
01286                                                 is_int(strpos($this->chr_data, "&")) &&
01287                                                 is_int(strpos($this->chr_data, ";")))
01288                                         {
01289                                                 $imp_dir = $this->content_object->getImportDirectory();
01290                                                 $source_dir = $imp_dir."/".$this->subdir."/objects/".
01291                                                         $this->file_item->getImportId();
01292                                                 
01293                                                 // read "physical" file name from directory
01294                                                 if ($dir = opendir($source_dir))
01295                                                 {
01296                                                    while (false !== ($file = readdir($dir)))
01297                                                    {
01298                                                            if ($file != "." && $file != "..")
01299                                                            {
01300                                                                    $this->file_item->setFileName($file);
01301                                                            }
01302                                                    }
01303                                                    closedir($dir);
01304                                                 }
01305                                         }
01306                                         
01307                                         // set file item title
01308                                         $this->file_item->setTitle(trim($this->chr_data));
01309                                 }
01310                                 break;
01311 
01315                         // TECHNICAL: Requirement
01316                         /*
01317                         case "Requirement":
01318                                 $this->requirement_set->addRequirement($this->requirement);
01319                                 break;*/
01320 
01321 
01322                 }
01323                 $this->endElement($a_name);
01324                 $this->chr_data = "";
01325         }
01326 
01330         function handlerCharacterData($a_xml_parser,$a_data)
01331         {
01332                 // i don't know why this is necessary, but
01333                 // the parser seems to convert "&gt;" to ">" and "&lt;" to "<"
01334                 // in character data, but we don't want that, because it's the
01335                 // way we mask user html in our content, so we convert back...
01336 
01337                 if ($this->in_meta_data)
01338                 {
01339                         $a_data = preg_replace("/&(?!amp;)/","&amp;",$a_data);
01340                 }
01341 
01342                 $a_data = str_replace("<","&lt;",$a_data);
01343                 $a_data = str_replace(">","&gt;",$a_data);
01344 
01345 
01346                 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
01347                 $a_data = preg_replace("/\n/","",$a_data);
01348                 if (!$this->inside_code)
01349                 {
01350                         $a_data = preg_replace("/\t+/","",$a_data);
01351                 }
01352 
01353                 $this->chr_data .= $a_data;
01354 
01355                 if(!empty($a_data))
01356                 {
01357                         // append all data to page, if we are within PageObject,
01358                         // but not within MetaData or MediaObject
01359                         if (($this->in_page_object || $this->in_glossary_definition)
01360                                 && !$this->in_meta_data && !$this->in_media_object)
01361                         {
01362                                 $this->page_object->appendXMLContent($a_data);
01363                         }
01364 
01365                         if ($this->in_meta_data  )
01366                         {
01367                                 $this->meta_data->appendXMLContent($a_data);
01368 //echo "<br>".$a_data;
01369                         }
01370 
01371                         if ($this->in_bib_item  )
01372                         {
01373                                 $this->bib_item->appendXMLContent($a_data);
01374                         }
01375 
01376                         switch($this->getCurrentElement())
01377                         {
01378 
01379                                 case "IntLink":
01380                                 case "ExtLink":
01381                                         if($this->in_map_area)
01382                                         {
01383                                                 $this->map_area->appendTitle($a_data);
01384                                         }
01385                                         break;
01386 
01387                         }
01388                 }
01389 
01390         }
01391 
01392 }
01393 ?>

Generated on Fri Dec 13 2013 09:06:35 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1