• Main Page
  • Related Pages
  • Modules
  • 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-2006 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 
00041 include_once("Services/MetaData/classes/class.ilMDSaxParser.php");
00042 include_once("Services/MetaData/classes/class.ilMD.php");
00043 
00052 class ilContObjParser extends ilMDSaxParser
00053 {
00054         var $lng;
00055         var $tree;
00056         var $cnt;                               // counts open elements
00057         var $current_element;   // store current element type
00058         var $learning_module;   // current learning module
00059         var $page_object;               // current page object
00060         var $lm_page_object;
00061         var $structure_objects; // array of current structure objects
00062         var $media_object;
00063         var $current_object;    // at the time a LearningModule, PageObject or StructureObject
00064         var $meta_data;                 // current meta data object
00065         var $paragraph;
00066         var $table;
00067         var $lm_tree;
00068         var $pg_into_tree;
00069         var $st_into_tree;
00070         var $container;
00071         var $in_page_object;    // are we currently within a PageObject? true/false
00072         var $in_meta_data;              // are we currently within MetaData? true/false
00073         var $in_media_object;
00074         var $in_file_item;
00075         var $in_glossary;
00076         var $in_map_area;
00077         var $content_object;
00078         var $glossary_object;
00079         var $file_item;
00080         var $keyword_language;
00081         var $pages_to_parse;
00082         var $mob_mapping;
00083         var $file_item_mapping;
00084         var $subdir;
00085         var $media_item;                // current media item
00086         var $loc_type;                  // current location type
00087         var $bib_item;                  // current bib item object
00088         var $map_area;                  // current map area
00089         var $in_bib_item;               // are we currently within BibItem? true/false
00090         var $link_targets;              // stores all objects by import id
00091         var $qst_mapping;
00092         var $metadata_parsing_disabled;
00093         var $in_meta_meta_data = false;
00094 
00104         function ilContObjParser(&$a_content_object, $a_xml_file, $a_subdir)
00105         {
00106                 global $lng, $tree;
00107 
00108                 parent::ilMDSaxParser($a_xml_file);
00109                 $this->cnt = array();
00110                 $this->current_element = array();
00111                 $this->structure_objects = array();
00112                 $this->content_object =& $a_content_object;
00113                 //$this->lm_id = $a_lm_id;
00114                 $this->st_into_tree = array();
00115                 $this->pg_into_tree = array();
00116                 $this->pages_to_parse = array();
00117                 $this->mobs_with_int_links = array();
00118                 $this->mob_mapping = array();
00119                 $this->file_item_mapping = array();
00120                 $this->pg_mapping = array();
00121                 $this->link_targets = array();
00122                 $this->subdir = $a_subdir;
00123                 $this->lng =& $lng;
00124                 $this->tree =& $tree;
00125                 $this->inside_code = false;
00126                 $this->qst_mapping = array();
00127                 $this->coType = $this->content_object->getType();
00128                 $this->metadata_parsing_disabled = false;
00129 
00130                 if (($this->coType != "tst") and ($this->coType != "qpl"))
00131                 {
00132                         $this->lm_tree = new ilTree($this->content_object->getId());
00133                         $this->lm_tree->setTreeTablePK("lm_id");
00134                         $this->lm_tree->setTableNames('lm_tree','lm_data');
00135                 }
00136                 //$this->lm_tree->addTree($a_lm_id, 1); happens in ilObjLearningModuleGUI
00137 
00138         }
00139 
00146         function setHandlers($a_xml_parser)
00147         {
00148                 xml_set_object($a_xml_parser,$this);
00149                 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00150                 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00151         }
00152 
00153         
00157         function startParsing()
00158         {
00159 //echo "<b>start parsing</b><br>";
00160                 parent::startParsing();
00161 //echo "<b>storeTree</b><br>";
00162                 $this->storeTree();
00163 //echo "<b>processPagesToParse</b><br>";
00164                 $this->processPagesToParse();
00165 //echo "<b>copyMobFiles</b><br>";
00166                 $this->copyMobFiles();
00167 //echo "<b>copyFileItems</b><br>";
00168                 $this->copyFileItems();
00169         }
00170 
00171         
00175         function storeTree()
00176         {
00177                 global $ilLog;
00178 
00179 //echo "<b>Storing the tree</b><br>";
00180                 foreach($this->st_into_tree as $st)
00181                 {
00182 //echo "insert st id: ".$st["id"].", parent:".$st["parent"]."<br>";
00183                         $this->lm_tree->insertNode($st["id"], $st["parent"]);
00184 //echo "done<br>";
00185                         if (is_array($this->pg_into_tree[$st["id"]]))
00186                         {
00187                                 foreach($this->pg_into_tree[$st["id"]] as $pg)
00188                                 {
00189                                         switch ($pg["type"])
00190                                         {
00191                                                 case "pg_alias":
00192                                                         if ($this->pg_mapping[$pg["id"]] == "")
00193                                                         {
00194                                                                 $ilLog->write("LM Import: No PageObject for PageAlias ".
00195                                                                                           $pg["id"]." found! (Please update export installation to ILIAS 3.3.0)");
00196 
00197                                                                 // Jump two levels up. First level is switch
00198                                                                 continue 2;
00199                                                         }
00200                                                         $pg_id = $this->pg_mapping[$pg["id"]];
00201                                                         break;
00202 
00203                                                 case "pg":
00204                                                         $pg_id = $pg["id"];
00205                                                         break;
00206                                         }
00207                                         if (!$this->lm_tree->isInTree($pg_id))
00208                                         {
00209                                                 $this->lm_tree->insertNode($pg_id, $st["id"]);
00210                                         }
00211                                 }
00212                         }
00213                 }
00214 //echo "<b>END: storing the tree</b>";
00215         }
00216 
00217 
00221         function processPagesToParse()
00222         {
00223                 /*
00224                 $pg_mapping = array();
00225                 foreach($this->pg_mapping as $key => $value)
00226                 {
00227                         $pg_mapping[$key] = "il__pg_".$value;
00228                 }*/
00229 //echo "<br><b>processIntLinks</b>"; flush();
00230 
00231                 // outgoin internal links
00232                 foreach($this->pages_to_parse as $page_id)
00233                 {
00234                         $page_arr = explode(":", $page_id);
00235 //echo "<br>resolve:".$this->content_object->getType().":".$page_id; flush();
00236                         switch($page_arr[0])
00237                         {
00238                                 case "lm":
00239                                         $page_obj =& new ilPageObject($this->content_object->getType(), $page_arr[1]);
00240                                         break;
00241 
00242                                 case "gdf":
00243                                         $page_obj =& new ilPageObject("gdf", $page_arr[1]);
00244                                         break;
00245                         }
00246                         $page_obj->buildDom();
00247                         $page_obj->resolveIntLinks();
00248                         $page_obj->update(false);
00249 
00250                         if ($page_arr[0] == "gdf")
00251                         {
00252                                 $def =& new ilGlossaryDefinition($page_arr[1]);
00253                                 $def->updateShortText();
00254                         }
00255 
00256                         unset($page_obj);
00257                 }
00258 
00259 //echo "<br><b>map area internal links</b>"; flush();
00260                 // outgoins map area (mob) internal links
00261                 foreach($this->mobs_with_int_links as $mob_id)
00262                 {
00263                         ilMediaItem::_resolveMapAreaLinks($mob_id);
00264                 }
00265 
00266 //echo "<br><b>incoming interna links</b>"; flush();
00267                 // incoming internal links
00268                 $done = array();
00269                 foreach ($this->link_targets as $link_target)
00270                 {
00271 //echo "doin link target:".$link_target.":<br>";
00272                         $link_arr = explode("_", $link_target);
00273                         $target_inst = $link_arr[1];
00274                         $target_type = $link_arr[2];
00275                         $target_id = $link_arr[3];
00276                         $sources = ilInternalLink::_getSourcesOfTarget($target_type, $target_id, $target_inst);
00277                         foreach($sources as $key => $source)
00278                         {
00279 //echo "got source:".$key.":<br>";
00280                                 if(in_array($key, $done))
00281                                 {
00282                                         continue;
00283                                 }
00284                                 $type_arr = explode(":", $source["type"]);
00285 
00286                                 // content object pages
00287                                 if ($type_arr[1] == "pg")
00288                                 {
00289                                         $page_object = new ilPageObject($type_arr[0], $source["id"]);
00290                                         $page_object->buildDom();
00291                                         $page_object->resolveIntLinks();
00292                                         $page_object->update();
00293                                         unset($page_object);
00294                                 }
00295                                 // eventually correct links in questions to learning modules
00296                                 if ($type_arr[0] == "qst")
00297                                 {
00298                                         require_once "./assessment/classes/class.assQuestion.php";
00299                                         assQuestion::_resolveIntLinks($source["id"]);
00300                                 }
00301                                 // eventually correct links in survey questions to learning modules
00302                                 if ($type_arr[0] == "sqst")
00303                                 {
00304                                         require_once "./survey/classes/class.SurveyQuestion.php";
00305                                         assQuestion::_resolveIntLinks($source["id"]);
00306                                 }
00307                                 $done[$key] = $key;
00308                         }
00309                 }
00310         }
00311 
00312 
00316         function copyMobFiles()
00317         {
00318                 $imp_dir = $this->content_object->getImportDirectory();
00319                 foreach ($this->mob_mapping as $origin_id => $mob_id)
00320                 {
00321                         if(empty($origin_id))
00322                         {
00323                                 continue;
00324                         }
00325 
00326                         /*
00327                         $origin_arr = explode("_", $origin_id);
00328                         if ($origin_arr[2] == "el") // imagemap
00329                         {
00330                                 $obj_dir = "imagemap".$origin_arr[3];
00331                         }
00332                         else // normal media object
00333                         {
00334                                 $obj_dir = "mm".$origin_arr[3];
00335                         }*/
00336 
00337                         $obj_dir = $origin_id;
00338                         $source_dir = $imp_dir."/".$this->subdir."/objects/".$obj_dir;
00339                         $target_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$mob_id;
00340 
00341 //echo "copy from $source_dir to $target_dir <br>";
00342                         if (@is_dir($source_dir))
00343                         {
00344                                 // make target directory
00345                                 ilUtil::makeDir($target_dir);
00346                                 //@mkdir($target_dir);
00347                                 //@chmod($target_dir, 0755);
00348 
00349                                 if (@is_dir($target_dir))
00350                                 {
00351                                         ilUtil::rCopy($source_dir, $target_dir);
00352                                 }
00353                         }
00354                 }
00355         }
00356 
00360         function copyFileItems()
00361         {
00362                 $imp_dir = $this->content_object->getImportDirectory();
00363                 foreach ($this->file_item_mapping as $origin_id => $file_id)
00364                 {
00365                         if(empty($origin_id))
00366                         {
00367                                 continue;
00368                         }
00369                         $obj_dir = $origin_id;
00370                         $source_dir = $imp_dir."/".$this->subdir."/objects/".$obj_dir;
00371                         $target_dir = ilUtil::getDataDir()."/files/file_".$file_id;
00372 
00373 //echo "copy from $source_dir to $target_dir <br>";
00374                         if (@is_dir($source_dir))
00375                         {
00376                                 // make target directory
00377                                 ilUtil::makeDir($target_dir);
00378                                 //@mkdir($target_dir);
00379                                 //@chmod($target_dir, 0755);
00380 
00381                                 if (@is_dir($target_dir))
00382                                 {
00383                                         ilUtil::rCopy($source_dir, $target_dir);
00384                                 }
00385                         }
00386                 }
00387         }
00388         
00392         function setQuestionMapping($a_map)
00393         {
00394                 $this->qst_mapping = $a_map;
00395         }
00396 
00397 
00398         /*
00399         * update parsing status for a element begin
00400         */
00401         function beginElement($a_name)
00402         {
00403                 if(!isset($this->status["$a_name"]))
00404                 {
00405                         $this->cnt[$a_name] == 1;
00406                 }
00407                 else
00408                 {
00409                         $this->cnt[$a_name]++;
00410                 }
00411                 $this->current_element[count($this->current_element)] = $a_name;
00412         }
00413 
00414         /*
00415         * update parsing status for an element ending
00416         *
00417         * @param        string  $a_name         element name
00418         */
00419         function endElement($a_name)
00420         {
00421                 $this->cnt[$a_name]--;
00422                 unset ($this->current_element[count($this->current_element) - 1]);
00423         }
00424 
00425         /*
00426         * returns current element
00427         */
00428         function getCurrentElement()
00429         {
00430                 return ($this->current_element[count($this->current_element) - 1]);
00431         }
00432 
00433         /*
00434         * returns number of current open elements of type $a_name
00435         *
00436         * @param        string  $a_name         element name
00437         */
00438         function getOpenCount($a_name)
00439         {
00440                 if (isset($this->cnt[$a_name]))
00441                 {
00442                         return $this->cnt[$a_name];
00443                 }
00444                 else
00445                 {
00446                         return 0;
00447                 }
00448 
00449         }
00450 
00458         function buildTag ($type, $name, $attr="")
00459         {
00460                 $tag = "<";
00461 
00462                 if ($type == "end")
00463                         $tag.= "/";
00464 
00465                 $tag.= $name;
00466 
00467                 if (is_array($attr))
00468                 {
00469                         while (list($k,$v) = each($attr))
00470                                 $tag.= " ".$k."=\"$v\"";
00471                 }
00472 
00473                 $tag.= ">";
00474 
00475                 return $tag;
00476         }
00477 
00485         function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
00486         {
00487 //echo "<b>BEGIN TAG: $a_name <br></b>"; flush();
00488                 switch($a_name)
00489                 {
00490                         case "ContentObject":
00491                                 $this->current_object =& $this->content_object;
00492 //echo "<br>Parser:CObjType:".$a_attribs["Type"];
00493                                 if ($a_attribs["Type"] == "Glossary")
00494                                 {
00495                                         $this->glossary_object =& $this->content_object;
00496                                 }
00497                                 break;
00498 
00499                         case "StructureObject":
00500 //echo "<br><br>StructureOB-SET-".count($this->structure_objects)."<br>";
00501                                 $this->structure_objects[count($this->structure_objects)]
00502                                         =& new ilStructureObject($this->content_object);
00503                                 $this->current_object =& $this->structure_objects[count($this->structure_objects) - 1];
00504                                 $this->current_object->setLMId($this->content_object->getId());
00505                                 // new meta data handling: we create the structure
00506                                 // object already here, this should also create a
00507                                 // md entry
00508                                 $this->current_object->create(true);
00509                                 break;
00510 
00511                         case "PageObject":
00512                                 $this->in_page_object = true;
00513                                 $this->cur_qid = "";
00514                                 if (($this->coType != "tst") and ($this->coType != "qpl"))
00515                                 {
00516                                         $this->lm_page_object =& new ilLMPageObject($this->content_object);
00517                                         $this->page_object =& new ilPageObject($this->content_object->getType());
00518                                         $this->lm_page_object->setLMId($this->content_object->getId());
00519                                         $this->lm_page_object->assignPageObject($this->page_object);
00520                                         $this->current_object =& $this->lm_page_object;                                 
00521                                 }
00522                                 else
00523                                 {
00524                                         $this->page_object =& new ilPageObject("qpl");
00525                                 }
00526                                 break;
00527 
00528                         case "PageAlias":
00529                                 if (($this->coType != "tst") and ($this->coType != "qpl"))
00530                                 {
00531                                         $this->lm_page_object->setAlias(true);
00532                                         $this->lm_page_object->setOriginID($a_attribs["OriginId"]);
00533                                 }
00534                                 break;
00535 
00536                         case "MediaObject":
00537                                 $this->in_media_object = true;
00538                                 $this->media_meta_start = true;
00539                                 $this->media_meta_cache = array();
00540                                 $this->media_object =& new ilObjMediaObject();
00541                                 break;
00542 
00543                         case "MediaAlias":
00544 //echo "<br>---NEW MEDIAALIAS---<br>";
00545                                 $this->media_object->setAlias(true);
00546                                 $this->media_object->setImportId($a_attribs["OriginId"]);
00547                                 if (is_object($this->page_object))
00548                                 {
00549                                         $this->page_object->needsImportParsing(true);
00550                                 }
00551                                 break;
00552 
00553                         case "MediaItem":
00554                         case "MediaAliasItem":
00555                                 $this->in_media_item = true;
00556                                 $this->media_item =& new ilMediaItem();
00557                                 $this->media_item->setPurpose($a_attribs["Purpose"]);
00558                                 break;
00559 
00560                         case "Layout":
00561                                 if (is_object($this->media_object) && $this->in_media_object)
00562                                 {
00563                                         $this->media_item->setWidth($a_attribs["Width"]);
00564                                         $this->media_item->setHeight($a_attribs["Height"]);
00565                                         $this->media_item->setHAlign($a_attribs["HorizontalAlign"]);
00566                                 }
00567                                 break;
00568 
00569                         case "Parameter":
00570                                 if (is_object($this->media_object) && $this->in_media_object)
00571                                 {
00572                                         $this->media_item->setParameter($a_attribs["Name"], $a_attribs["Value"]);
00573                                 }
00574                                 break;
00575 
00576                         case "MapArea":
00577                                 $this->in_map_area = true;
00578                                 $this->map_area =& new ilMapArea();
00579                                 $this->map_area->setShape($a_attribs["Shape"]);
00580                                 $this->map_area->setCoords($a_attribs["Coords"]);
00581                                 break;
00582 
00583                         case "Glossary":
00584                                 $this->in_glossary = true;
00585                                 if ($this->content_object->getType() != "glo")
00586                                 {
00587                                         $this->glossary_object =& new ilObjGlossary();
00588                                         $this->glossary_object->setTitle("");
00589                                         $this->glossary_object->setDescription("");
00590                                         $this->glossary_object->create(true);
00591                                         $this->glossary_object->createReference();
00592                                         $parent =& $this->tree->getParentNodeData($this->content_object->getRefId());
00593                                         $this->glossary_object->putInTree($parent["child"]);
00594                                         $this->glossary_object->setPermissions($parent["child"]);
00595                                         $this->glossary_object->notify("new", $_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$this->glossary_object->getRefId());
00596                                 }
00597                                 $this->current_object =& $this->glossary_object;
00598                                 break;
00599 
00600                         case "GlossaryItem":
00601                                 $this->glossary_term =& new ilGlossaryTerm();
00602                                 $this->glossary_term->setGlossaryId($this->glossary_object->getId());
00603                                 $this->glossary_term->setLanguage($a_attribs["Language"]);
00604                                 $this->glossary_term->setImportId($a_attribs["Id"]);
00605                                 $this->link_targets[$a_attribs["Id"]] = $a_attribs["Id"];
00606                                 break;
00607 
00608                         case "Definition":
00609                                 $this->in_glossary_definition = true;
00610                                 $this->glossary_definition =& new ilGlossaryDefinition();
00611                                 $this->page_object =& new ilPageObject("gdf");
00612                                 $this->page_object->setParentId($this->glossary_term->getGlossaryId());
00613                                 $this->glossary_definition->setTermId($this->glossary_term->getId());
00614                                 $this->glossary_definition->assignPageObject($this->page_object);
00615                                 $this->current_object =& $this->glossary_definition;
00616                                 $this->glossary_definition->create(true);
00617                                 break;
00618 
00619                         case "FileItem":
00620                                 $this->in_file_item = true;
00621                                 $this->file_item =& new ilObjFile();
00622                                 $this->file_item->setTitle("dummy");
00623                                 $this->file_item->setMode("filelist");
00624                                 if (is_object($this->page_object))
00625                                 {
00626                                         $this->page_object->needsImportParsing(true);
00627                                 }
00628                                 break;
00629 
00630                         case "Paragraph":
00631                                 if ($a_attribs["Characteristic"] == "Code")
00632                                 {
00633                                         $this->inside_code = true;
00634                                 }
00635                                 break;
00636 
00637                         case "Properties":
00638                                 $this->in_properties = true;
00639                                 break;
00640                                 
00641                         case "Property":
00642                                 if ($this->content_object->getType() == "lm"
00643                                         || $this->content_object->getType() == "dbk")
00644                                 {
00645                                         switch($a_attribs["Name"])
00646                                         {
00647                                                 case "Layout":
00648                                                         $this->content_object->setLayout($a_attribs["Value"]);
00649                                                         break;
00650 
00651                                                 case "PageHeader":
00652                                                         $this->content_object->setPageHeader($a_attribs["Value"]);
00653                                                         break;
00654                                                         
00655                                                 case "TOCMode":
00656                                                         $this->content_object->setTOCMode($a_attribs["Value"]);
00657                                                         break;
00658                                                         
00659                                                 case "ActiveLMMenu":
00660                                                         $this->content_object->setActiveLMMenu(
00661                                                                 ilUtil::yn2tf($a_attribs["Value"]));
00662                                                         break;
00663                                                         
00664                                                 case "ActiveNumbering":
00665                                                         $this->content_object->setActiveNumbering(
00666                                                                 ilUtil::yn2tf($a_attribs["Value"]));
00667                                                         break;
00668                                                 
00669                                                 case "ActiveTOC":
00670                                                         $this->content_object->setActiveTOC(
00671                                                                 ilUtil::yn2tf($a_attribs["Value"]));
00672                                                         break;
00673                                                         
00674                                                 case "ActivePrintView":
00675                                                         $this->content_object->setActivePrintView(
00676                                                                 ilUtil::yn2tf($a_attribs["Value"]));
00677                                                         break;
00678                                                         
00679                                                 case "CleanFrames":
00680                                                         $this->content_object->setCleanFrames(
00681                                                                 ilUtil::yn2tf($a_attribs["Value"]));
00682                                                         break;
00683                                                         
00684                                                 case "PublicNotes":
00685                                                         $this->content_object->setPublicNotes(
00686                                                                 ilUtil::yn2tf($a_attribs["Value"]));
00687                                                         break;
00688                                                         
00689                                                 case "HistoryUserComments":
00690                                                         $this->content_object->setHistoryUserComments(
00691                                                                 ilUtil::yn2tf($a_attribs["Value"]));
00692                                                         break;
00693                                                         
00694                                                 case "HeaderPage":
00695                                                         if ($a_attribs["Value"] != "")
00696                                                         {
00697                                                                 if ($this->pg_mapping[$a_attribs["Value"]] > 0)
00698                                                                 {
00699                                                                         $this->content_object->setHeaderPage(
00700                                                                                 $this->pg_mapping[$a_attribs["Value"]]);
00701                                                                 }
00702                                                         }
00703                                                         break;
00704 
00705                                                 case "FooterPage":
00706                                                         if ($a_attribs["Value"] != "")
00707                                                         {
00708                                                                 if ($this->pg_mapping[$a_attribs["Value"]] > 0)
00709                                                                 {
00710                                                                         $this->content_object->setFooterPage(
00711                                                                                 $this->pg_mapping[$a_attribs["Value"]]);
00712                                                                 }
00713                                                         }
00714                                                         break;
00715                                         }
00716                         //echo "<br>+".$a_attribs["Name"]."+";
00717                                 }
00718                                 break;
00719 
00723                         case "MetaData":
00724                                 $this->in_meta_data = true;
00725 //echo "<br>begin meta data section -".$this->current_object->getType()."-";
00726                                 // media obejct meta data handling
00727                                 // is done in the "Identifier" begin tag processing
00728                                 // the rest is done here
00729                                 if(!$this->in_media_object)
00730                                 {
00731                                         if (($this->coType != "tst") and ($this->coType != "qpl"))
00732                                         {
00733                                                 // type pg/st
00734                                                 if ($this->current_object->getType() == "st" ||
00735                                                         $this->current_object->getType() == "pg")
00736                                                 {
00737                                                         // late creation of page object
00738                                                         if ($this->current_object->getType() == "pg")
00739                                                         {
00740                                                                 $this->lm_page_object->create(true);
00741                                                         }
00742                                                         $this->md =& new ilMD($this->content_object->getId() ,
00743                                                                 $this->current_object->getId(),
00744                                                                 $this->current_object->getType());
00745                                                 }
00746                                                 // type gdf
00747                                                 else if ($this->current_object->getType() == "gdf")
00748                                                 {
00749                                                         $this->md =& new ilMD($this->glossary_object->getId() ,
00750                                                                 $this->current_object->getId(),
00751                                                                 $this->current_object->getType());
00752                                                 }
00753                                                 // type lm, dbk, glo
00754                                                 else
00755                                                 {
00756                                                         if ($this->processMeta())
00757                                                         {
00758                                                                 $this->md =& new ilMD($this->current_object->getId() ,
00759                                                                         0,
00760                                                                         $this->current_object->getType());
00761                                                         }
00762                                                 }
00763                                         }
00764                                         else
00765                                         {
00766                                                 // type qpl or tst
00767                                                 $this->md =& new ilMD($this->content_object->getId() ,
00768                                                         0,
00769                                                         $this->current_object->getType()
00770                                                 );
00771                                                 if ($this->md->getGeneral() != false)
00772                                                 {
00773                                                         $this->metadata_parsing_disabled = true;
00774                                                         $this->enableMDParsing(false);
00775                                                 }
00776                                         }
00777                                 }
00778                                 break;
00779 
00780                         // Identifier
00781                         case "Identifier":
00782                         
00783                                 // please note: Meta-Metadata and MetaData are different tags!
00784                                 if (!$this->in_meta_meta_data)
00785                                 {
00786                                         if ($this->in_meta_data && !$this->in_glossary_definition)
00787                                         {
00788                                                 if (!$this->in_media_object)
00789                                                 {
00790                                                         $this->current_object->setImportId($a_attribs["Entry"]);
00791                                                 }
00792                                                 $this->link_targets[$a_attribs["Entry"]] = $a_attribs["Entry"];
00793                                         }
00794                                         if ($this->in_file_item)
00795                                         {
00796                                                 if ($this->file_item_mapping[$a_attribs["Entry"]] == "")
00797                                                 {
00798                                                         $this->file_item->create();
00799                                                         $this->file_item->setImportId($a_attribs["Entry"]);
00800                                                         $this->file_item_mapping[$a_attribs["Entry"]] = $this->file_item->getId();
00801                                                 }
00802                                         }
00803                                         if ($this->in_meta_data && $this->in_media_object)
00804                                         {
00805 //echo "looking for -".$a_attribs["Entry"]."-<br>";
00806 
00807                                                 $mob_id = $this->mob_mapping[$a_attribs["Entry"]];
00808                                         
00809                                                 // within learning module import, usually a media object
00810                                                 // has already been created with a media alias tag
00811                                                 if ($mob_id > 0)
00812                                                 {
00813                                                         $this->media_object = new ilObjMediaObject($mob_id);
00814                                                 }
00815                                                 else    // in glossaries the media objects precede the definitions
00816                                                                 // so we don't have an object already
00817                                                 {
00818                                                         $this->media_object = new ilObjMediaObject();
00819                                                         $this->media_object->create(true, false);
00820                                                         $this->mob_mapping[$a_attribs["Entry"]]
00821                                                                 = $this->media_object->getId();
00822                                                 }
00823                                                 $this->media_object->setImportId($a_attribs["Entry"]);
00824                                                 $this->md =& new ilMD(0 ,
00825                                                         $this->media_object->getId(),
00826                                                         "mob");
00827                                                 $this->emptyMediaMetaCache($a_xml_parser);
00828                                         }
00829                                 }
00830                                 break;
00831 
00832                         case "Meta-Metadata":
00833                                 $this->in_meta_meta_data = true;
00834                                 break;
00835 
00836                         // Internal Link
00837                         case "IntLink":
00838                                 if (is_object($this->page_object))
00839                                 {
00840                                         $this->page_object->setContainsIntLink(true);
00841                                 }
00842                                 if ($this->in_map_area)
00843                                 {
00844 //echo "intlink:maparea:<br>";
00845                                         $this->map_area->setLinkType(IL_INT_LINK);
00846                                         $this->map_area->setTarget($a_attribs["Target"]);
00847                                         $this->map_area->setType($a_attribs["Type"]);
00848                                         $this->map_area->setTargetFrame($a_attribs["TargetFrame"]);
00849                                         if (is_object($this->media_object))
00850                                         {
00851 //echo ":setContainsLink:<br>";
00852                                                 $this->media_object->setContainsIntLink(true);
00853                                         }
00854                                 }
00855                                 break;
00856 
00857                         // External Link
00858                         case "ExtLink":
00859                                 if ($this->in_map_area)
00860                                 {
00861                                         $this->map_area->setLinkType(IL_EXT_LINK);
00862                                         $this->map_area->setHref($a_attribs["Href"]);
00863                                         $this->map_area->setExtTitle($a_attribs["Title"]);
00864                                 }
00865                                 break;
00866                                 
00867                         // Question
00868                         case "Question":
00869                                 $this->cur_qid = $a_attribs["QRef"];
00870                                 break;
00871 
00872                         case "Location":
00873                                 $this->loc_type = $a_attribs["Type"];
00874                                 break;
00875 
00876                         case "Bibliography":
00877                                 $this->in_bib_item = true;
00878 //echo "<br>---NEW BIBLIOGRAPHY---<br>";
00879                                 $this->bib_item =& new ilBibItem();
00880                                 break;
00881 
00882                 }
00883                 $this->beginElement($a_name);
00884 
00885                 // append content to page xml content
00886                 if(($this->in_page_object || $this->in_glossary_definition)
00887                         && !$this->in_meta_data && !$this->in_media_object)
00888                 {
00889                         if ($a_name == "Definition")
00890                         {
00891                                 $app_name = "PageObject";
00892                                 $app_attribs = array();
00893                         }
00894                         else
00895                         {
00896                                 $app_name = $a_name;
00897                                 $app_attribs = $a_attribs;
00898                         }
00899 
00900                         // change identifier entry of file items to new local file id
00901                         if ($this->in_file_item && $app_name == "Identifier")
00902                         {
00903                                 $app_attribs["Entry"] = "il__file_".$this->file_item_mapping[$a_attribs["Entry"]];
00904                                 //$app_attribs["Entry"] = "il__file_".$this->file_item->getId();
00905                         }
00906 
00907                         $this->page_object->appendXMLContent($this->buildTag("start", $app_name, $app_attribs));
00908 //echo "&nbsp;&nbsp;after append, xml:".$this->page_object->getXMLContent().":<br>";
00909                 }
00910 
00911                 // append content to bibitem xml content
00912                 if ($this->in_bib_item)   // && !$this->in_page_object && !$this->in_media_object
00913                 {
00914                         $this->bib_item->appendXMLContent("\n".$this->buildTag("start", $a_name, $a_attribs));
00915                 }
00916                 
00917                 // call meta data handler
00918                 if ($this->in_meta_data && $this->processMeta())
00919                 {
00920                         // cache beginning of meta data within media object tags
00921                         // (we need to know the id at the begin of meta elements within
00922                         // media objects, after the "Identifier" tag has been processed
00923                         // we send the cached data to the meta xml handler)
00924                         if ($this->in_media_object && $this->media_meta_start)
00925                         {
00926                                 $this->media_meta_cache[] =
00927                                         array("type" => "handlerBeginTag", "par1" => $a_name, "par2" => $a_attribs);
00928                         }
00929                         else
00930                         {
00931                                 if ($a_name == "Identifier")
00932                                 {
00933                                         if (!$this->in_media_object)
00934                                         {
00935                                                 $a_attribs["Entry"] = "il__".$this->current_object->getType().
00936                                                         "_".$this->current_object->getId();
00937                                         }
00938                                         else
00939                                         {
00940                                                 $a_attribs["Entry"] = "il__mob".
00941                                                         "_".$this->media_object->getId();
00942                                         }
00943                                         $a_attribs["Catalog"] = "ILIAS";
00944                                 }
00945 
00946                                 parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
00947                         }
00948                 }
00949         }
00950 
00954         function processMeta()
00955         {
00956                 // do not process second meta block in (ilias3) glossaries
00957                 // which comes right after the "Glossary" tag
00958                 if ($this->content_object->getType() == "glo" &&
00959                         $this->in_glossary && !$this->in_media_object
00960                         && !$this->in_glossary_definition)
00961                 {
00962                         return false;
00963                 }
00964                 
00965                 return true;
00966         }
00967 
00968 
00975         function handlerEndTag($a_xml_parser,$a_name)
00976         {
00977                 // call meta data handler
00978                 if ($this->in_meta_data && $this->processMeta())
00979                 {
00980                         // cache beginning of meta data within media object tags
00981                         // (we need to know the id, after that we send the cached data
00982                         // to the meta xml handler)
00983                         if ($this->in_media_object && $this->media_meta_start)
00984                         {
00985                                 $this->media_meta_cache[] =
00986                                         array("type" => "handlerEndTag", "par1" => $a_name);
00987                         }
00988                         else
00989                         {
00990                                 parent::handlerEndTag($a_xml_parser,$a_name);
00991                         }
00992                 }
00993 
00994 //echo "<b>END TAG: $a_name <br></b>"; flush();
00995                 // append content to page xml content
00996                 if (($this->in_page_object || $this->in_glossary_definition)
00997                         && !$this->in_meta_data && !$this->in_media_object)
00998                 {
00999                         $app_name = ($a_name == "Definition")
01000                                 ? "PageObject"
01001                                 : $a_name;
01002                         $this->page_object->appendXMLContent($this->buildTag("end", $app_name));
01003                 }
01004 
01005                 // append content to bibitemxml content
01006                 if ($this->in_bib_item) // && !$this->in_page_object && !$this->in_media_object
01007                 {
01008                         if($a_name == "BibItem")
01009                         {
01010                                 $this->bib_item->appendXMLContent("\n".$this->buildTag("end", $a_name));
01011                         }
01012                         else
01013                         {
01014                                 $this->bib_item->appendXMLContent($this->buildTag("end", $a_name));
01015                         }
01016 
01017                 }
01018 
01019                 switch($a_name)
01020                 {
01021                         case "StructureObject":
01022                                 //unset($this->meta_data);
01023                                 unset($this->structure_objects[count($this->structure_objects) - 1]);
01024                                 break;
01025 
01026                         case "PageObject":
01027 
01028                                 $this->in_page_object = false;
01029                                 if (($this->coType != "tst") and ($this->coType != "qpl"))
01030                                 {
01031                                         if (!$this->lm_page_object->isAlias())
01032                                         {
01033                                                 //$this->page_object->createFromXML();
01034                                                 $this->page_object->updateFromXML();
01035                                                 $this->pg_mapping[$this->lm_page_object->getImportId()]
01036                                                         = $this->lm_page_object->getId();
01037         
01038                                                 // collect pages with internal links
01039                                                 if ($this->page_object->containsIntLink())
01040                                                 {
01041                                                         $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
01042                                                 }
01043                                                 
01044                                                 // collect pages with mobs or files
01045                                                 if ($this->page_object->needsImportParsing())
01046                                                 {
01047                                                         $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
01048                                                 }
01049                                                 
01050                                         }
01051                                 }
01052                                 else
01053                                 {
01054                                         $xml = $this->page_object->getXMLContent();
01055                                         if ($this->cur_qid != "")
01056                                         {
01057                                                 $ids = $this->qst_mapping[$this->cur_qid];
01058                                                 if ($ids["pool"] > 0)
01059                                                 {
01060                                                         // question pool question
01061                                                         $page = new ilPageObject("qpl", $ids["pool"]);
01062                                                         $xmlcontent = str_replace($this->cur_qid, 
01063                                                                 "il__qst_".$ids["pool"], $xml);
01064                                                         $page->setXMLContent($xmlcontent);
01065                                                         $page->saveMobUsage($xmlcontent);
01066                                                         $page->updateFromXML();
01067                                                         unset($page);
01068                                                 }
01069                                                 if ($ids["test"] > 0)
01070                                                 {
01071                                                         // test question
01072                                                         $page = new ilPageObject("qpl", $ids["test"]);
01073                                                         $xmlcontent = str_replace($this->cur_qid, 
01074                                                                 "il__qst_".$ids["test"], $xml);
01075                                                         $page->setXMLContent($xmlcontent);
01076                                                         $page->saveMobUsage($xmlcontent);
01077                                                         $page->updateFromXML();
01078                                                         unset($page);
01079                                                 }
01080                                         }
01081                                 }
01082 
01083                                 // if we are within a structure object: put page in tree
01084                                 $cnt = count($this->structure_objects);
01085                                 if ($cnt > 0)
01086                                 {
01087                                         $parent_id = $this->structure_objects[$cnt - 1]->getId();
01088                                         if ($this->lm_page_object->isAlias())
01089                                         {
01090                                                 $this->pg_into_tree[$parent_id][] = array("type" => "pg_alias", "id" => $this->lm_page_object->getOriginId());
01091                                         }
01092                                         else
01093                                         {
01094                                                 $this->pg_into_tree[$parent_id][] = array("type" => "pg", "id" => $this->lm_page_object->getId());
01095                                         }
01096                                 }
01097 
01098                                 unset($this->page_object);
01099                                 unset($this->lm_page_object);
01100                                 unset ($this->container[count($this->container) - 1]);
01101                                 break;
01102 
01103                         case "MediaObject":
01104                                 $this->in_media_object = false;
01105 //echo "ENDMediaObject:ImportId:".$this->media_object->getImportId()."<br>";
01106                                 // create media object on first occurence of an Id
01107                                 
01108                                 
01109                                 if(empty($this->mob_mapping[$this->media_object->getImportId()]))
01110                                 {
01111 //echo "No mapping found --creating media object:title:".$this->media_object->getTitle().":<br>";
01112 
01113                                         // create media object
01114                                         // media items are saves for mobs outside of
01115                                         // pages only
01116                                         $this->media_object->create(true, false);
01117                                         
01118 //echo "<br>creating mob ".$this->media_object->getId().":".$this->media_object->getTitle().":";
01119 
01120                                         // collect mobs with internal links
01121                                         if ($this->media_object->containsIntLink())
01122                                         {
01123 //echo "got int link :".$this->media_object->getId().":<br>";
01124                                                 $this->mobs_with_int_links[] = $this->media_object->getId();
01125                                         }
01126 
01127                                         $this->mob_mapping[$this->media_object->getImportId()]
01128                                                         = $this->media_object->getId();
01129 //echo "create:import_id:".$this->media_object->getImportId().":ID:".$this->mob_mapping[$this->media_object->getImportId()]."<br>";
01130                                 }
01131                                 else
01132                                 {
01133 //echo "Mapping found<br>";
01134                                         // get the id from mapping
01135                                         $this->media_object->setId($this->mob_mapping[$this->media_object->getImportId()]);
01136 
01137                                         // update "real" (no alias) media object
01138                                         // (note: we overwrite any data from the media object
01139                                         // created by an MediaAlias, only the data of the real
01140                                         // object is stored in db separately; data of the
01141                                         // MediaAliases are within the page XML
01142                                         if (!$this->media_object->isAlias())
01143                                         {                                               
01144                                                 // now the media items are saved within the db
01145                                                 $this->media_object->update();
01146                                                 
01147 //echo "<br>update media object :".$this->media_object->getId().":";
01148 
01149                                                 // collect mobs with internal links
01150                                                 if ($this->media_object->containsIntLink())
01151                                                 {
01152 //echo "got int link :".$this->media_object->getId().":<br>";
01153                                                         $this->mobs_with_int_links[] = $this->media_object->getId();
01154                                                 }
01155                                         }
01156                                 }
01157 
01158                                 // append media alias to page, if we are in a page
01159                                 if ($this->in_page_object || $this->in_glossary_definition)
01160                                 {
01161                                         $this->page_object->appendXMLContent($this->media_object->getXML(IL_MODE_ALIAS));
01162 //echo "Appending:".htmlentities($this->media_object->getXML(IL_MODE_ALIAS))."<br>";
01163                                 }
01164 
01165                                 break;
01166 
01167                         case "MediaItem":
01168                         case "MediaAliasItem":
01169                                 $this->in_media_item = false;
01170                                 $this->media_object->addMediaItem($this->media_item);
01171 //echo "adding media item -".$this->media_item->getId()."-".$this->media_item->getLocation()."- to object -".$this->media_object->getId()."-";
01172                                 break;
01173 
01174                         case "MapArea":
01175                                 $this->in_map_area = false;
01176                                 $this->media_item->addMapArea($this->map_area);
01177                                 break;
01178 
01179                         case "Properties":
01180                                 $this->in_properties = false;
01181                                 if ($this->content_object->getType() == "lm"
01182                                         || $this->content_object->getType() == "dbk")
01183                                 {
01184                                         $this->content_object->update();
01185                                 }
01186                                 break;
01187 
01188                         case "MetaData":
01189                                 $this->in_meta_data = false;
01190                                 if(strtolower(get_class($this->current_object)) == "illmpageobject" && !$this->in_media_object)
01191                                 {
01192                                         // Metadaten eines PageObjects sichern in NestedSet
01193                                         if (is_object($this->lm_page_object))
01194                                         {
01195                                                 // update title/description of page object
01196                                                 $this->current_object->MDUpdateListener('General');
01197                                                 ilLMObject::_writeImportId($this->current_object->getId(),
01198                                                         $this->current_object->getImportId());
01199                                         }
01200                                 }
01201                                 else if((strtolower(get_class($this->current_object)) == "ilobjquestionpool" ||
01202                                         strtolower(get_class($this->current_object)) == "ilobjtest") &&
01203                                         !$this->in_media_object)
01204 //                                      !$this->in_media_object && !$this->in_page_object)
01205 // changed for imports of ILIAS 2 Tests where PageObjects could have
01206 // Metadata sections (Helmut Schottmüller, 2005-12-02)
01207                                 {
01208                                         if ($this->metadata_parsing_disabled)
01209                                         {
01210                                                 $this->enableMDParsing(true);
01211                                         }
01212                                         else
01213                                         {
01214                                                 if ($this->in_page_object)
01215                                                 {
01216                                                         $this->page_object->MDUpdateListener('General');
01217                                                         ilLMObject::_writeImportId($this->page_object->getId(),
01218                                                                         $this->page_object->getImportId());
01219                                                 }
01220                                                 else
01221                                                 {
01222                                                         $this->current_object->MDUpdateListener('General');
01223                                                         ilLMObject::_writeImportId($this->current_object->getId(),
01224                                                                         $this->current_object->getImportId());
01225                                                 }
01226                                         }
01227                                 }
01228                                 else if(strtolower(get_class($this->current_object)) == "ilstructureobject")
01229                                 {    // save structure object at the end of its meta block
01230                                         // determine parent
01231                                         $cnt = count($this->structure_objects);
01232                                         if ($cnt > 1)
01233                                         {
01234                                                 $parent_id = $this->structure_objects[$cnt - 2]->getId();
01235                                         }
01236                                         else
01237                                         {
01238                                                 $parent_id = $this->lm_tree->getRootId();
01239                                         }
01240 
01241                                         // create structure object and put it in tree
01242                                         //$this->current_object->create(true); // now on top
01243                                         $this->st_into_tree[] = array ("id" => $this->current_object->getId(),
01244                                                 "parent" => $parent_id);
01245 
01246                                         // update title/description of structure object
01247                                         $this->current_object->MDUpdateListener('General');
01248                                         ilLMObject::_writeImportId($this->current_object->getId(),
01249                                                         $this->current_object->getImportId());
01250                                 }
01251                                 else if(strtolower(get_class($this->current_object)) == "ilobjdlbook" || strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
01252                                         strtolower(get_class($this->current_object)) == "ilobjcontentobject" ||
01253                                         (strtolower(get_class($this->current_object)) == "ilobjglossary" && $this->in_glossary))
01254                                 {
01255                                         // todo: saving of md? getting title/descr and
01256                                         // set it for current object
01257                                 }
01258                                 else if(strtolower(get_class($this->current_object)) == "ilglossarydefinition" && !$this->in_media_object)
01259                                 {
01260                                         // now on top
01261                                         //$this->glossary_definition->create();
01262 
01263                                         $this->page_object->setId($this->glossary_definition->getId());
01264                                         $this->page_object->updateFromXML();
01265 
01266                                         // todo: saving of md? getting title/descr and
01267                                         // set it for current object
01268                                 }
01269 
01270 
01271                                 if(strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
01272                                         strtolower(get_class($this->current_object)) == "ilobjdlbook" ||
01273                                         strtolower(get_class($this->current_object)) == "ilobjglossary")
01274                                 {
01275                                         if (strtolower(get_class($this->current_object)) == "ilobjglossary" &&
01276                                                 $this->content_object->getType() != "glo")
01277                                         {
01278 //echo "<br><b>getting2: ".$this->content_object->getTitle()."</b>";
01279                                                 $this->current_object->setTitle($this->content_object->getTitle()." - ".
01280                                                         $this->lng->txt("glossary"));
01281                                         }
01282 
01283                                         $this->current_object->MDUpdateListener('General');
01284                                         /*
01285                                         if (!$this->in_media_object && $this->processMeta())
01286                                         {
01287                                                 $this->current_object->update();
01288                                         }
01289                                         */
01290                                 }
01291                                 
01292                                 if ($this->in_media_object)
01293                                 {
01294 //echo "<br>call media object update listener";
01295                                         $this->media_object->MDUpdateListener('General');
01296                                 }
01297                                 
01298                                 if ($this->in_glossary_definition)
01299                                 {
01300                                         $this->glossary_definition->MDUpdateListener('General');
01301                                 }
01302 
01303                                 break;
01304 
01305                         case "Meta-Metadata":
01306                                 $this->in_meta_meta_data = false;
01307                                 break;
01308 
01309                         case "FileItem":
01310                                 $this->in_file_item = false;
01311                                 // only update new file items
01312                                 if ($this->file_item->getImportId($a_attribs["Entry"] != ""))
01313                                 {
01314                                         $this->file_item->update();
01315                                 }
01316                                 break;
01317 
01318                         case "Bibliography":
01319 
01320                                 $this->in_bib_item = false;
01321 
01322                                 $nested = new ilNestedSetXML();
01323                                 $nested->import($this->bib_item->getXMLContent(),$this->content_object->getId(),"bib");
01324                                 break;
01325 
01326                         case "Table":
01327                                 unset ($this->container[count($this->container) - 1]);
01328                                 break;
01329 
01330                         case "Glossary":
01331                                 $this->in_glossary = false;
01332                                 break;
01333 
01334                         case "GlossaryTerm":
01335                                 $this->glossary_term->setTerm(trim($this->chr_data));
01336                                 $this->glossary_term->create();
01337                                 break;
01338 
01339                         case "Paragraph":
01340                                 $this->inside_code = false;
01341                                 break;
01342 
01343                         case "Definition":
01344                                 $this->in_glossary_definition = false;
01345                                 $this->page_object->updateFromXML();
01346                                 $this->page_object->buildDom();
01347                                 $this->glossary_definition->setShortText($this->page_object->getFirstParagraphText());
01348                                 $this->glossary_definition->update();
01349                                 //$this->pg_mapping[$this->lm_page_object->getImportId()]
01350                                 //      = $this->lm_page_object->getId();
01351                                 if ($this->page_object->containsIntLink())
01352                                 {
01353 //echo "<br>Definition contains Int Link:".$this->page_object->getId();
01354                                         $this->pages_to_parse["gdf:".$this->page_object->getId()] = "gdf:".$this->page_object->getId();
01355                                 }
01356                                 if ($this->page_object->needsImportParsing())
01357                                 {
01358                                         $this->pages_to_parse["gdf:".$this->page_object->getId()] = "gdf:".$this->page_object->getId();
01359                                 }
01360                                 break;
01361 
01362                         case "Format":
01363                                 if ($this->in_media_item)
01364                                 {
01365                                         $this->media_item->setFormat(trim($this->chr_data));
01366                                 }
01367                                 if ($this->in_file_item)
01368                                 {
01369                                         $this->file_item->setFileType(trim($this->chr_data));
01370                                 }
01371                                 break;
01372 
01373                         case "Title":
01374                                 if (!$this->in_media_object)
01375                                 {
01376                                         $this->current_object->setTitle(trim($this->chr_data));
01377                                         //$this->meta_data->setTitle(trim($this->chr_data));
01378                                 }
01379                                 else
01380                                 {
01381                                         $this->media_object->setTitle(trim($this->chr_data));
01382                                         //$this->meta_data->setTitle(trim($this->chr_data));
01383                                 }
01384                                 break;
01385 
01386                         case "Language":
01387                                 /*
01388                                 if (is_object($this->meta_data))
01389                                 {
01390                                         $this->meta_data->setLanguage(trim($this->chr_data));
01391                                 }*/
01392                                 
01393                                 if (is_object($this->bib_item))
01394                                 {
01395                                         $this->bib_item->setLanguage(trim($this->chr_data));
01396                                 }
01397                                 break;
01398 
01399                         case "Description":
01400                                 //$this->meta_data->setDescription(trim($this->chr_data));
01401                                 break;
01402 
01403                         case "Caption":
01404                                 if ($this->in_media_object)
01405                                 {
01406                                         $this->media_item->setCaption(trim($this->chr_data));
01407                                 }
01408                                 break;
01409 
01410                         // Location
01411                         case "Location":
01412                                 // TODO: adapt for files in "real" subdirectories
01413                                 if ($this->in_media_item)
01414                                 {
01415                                         $this->media_item->setLocationType($this->loc_type);
01416                                         $this->media_item->setLocation(trim($this->chr_data));
01417                                 }
01418                                 if ($this->in_file_item)
01419                                 {
01420                                         // set file name from xml file
01421                                         $this->file_item->setFileName(trim($this->chr_data));
01422                                         
01423                                         // special handling for file names with special characters
01424                                         // (e.g. "&gt;")
01425                                         if ($this->file_item->getType() == "file" &&
01426                                                 is_int(strpos($this->chr_data, "&")) &&
01427                                                 is_int(strpos($this->chr_data, ";")))
01428                                         {
01429                                                 $imp_dir = $this->content_object->getImportDirectory();
01430                                                 $source_dir = $imp_dir."/".$this->subdir."/objects/".
01431                                                         $this->file_item->getImportId();
01432                                                 
01433                                                 // read "physical" file name from directory
01434                                                 if ($dir = opendir($source_dir))
01435                                                 {
01436                                                    while (false !== ($file = readdir($dir)))
01437                                                    {
01438                                                            if ($file != "." && $file != "..")
01439                                                            {
01440                                                                    $this->file_item->setFileName($file);
01441                                                            }
01442                                                    }
01443                                                    closedir($dir);
01444                                                 }
01445                                         }
01446                                         
01447                                         // set file item title
01448                                         $this->file_item->setTitle(trim($this->chr_data));
01449                                 }
01450                                 break;
01451 
01452                 }
01453                 $this->endElement($a_name);
01454                 $this->chr_data = "";
01455         }
01456 
01463         function handlerCharacterData($a_xml_parser,$a_data)
01464         {
01465                 // call meta data handler
01466                 if ($this->in_meta_data && $this->processMeta())
01467                 {
01468                         // cache beginning of meta data within media object tags
01469                         // (we need to know the id, after that we send the cached data
01470                         // to the meta xml handler)
01471                         if ($this->in_media_object && $this->media_meta_start)
01472                         {
01473                                 $this->media_meta_cache[] =
01474                                         array("type" => "handlerCharacterData", "par1" => $a_data);
01475                         }
01476                         else
01477                         {
01478                                 parent::handlerCharacterData($a_xml_parser,$a_data);
01479                         }
01480                 }
01481 
01482                 // the parser converts "&gt;" to ">" and "&lt;" to "<"
01483                 // in character data, but we don't want that, because it's the
01484                 // way we mask user html in our content, so we convert back...
01485 
01486                 $a_data = str_replace("<","&lt;",$a_data);
01487                 $a_data = str_replace(">","&gt;",$a_data);
01488 
01489 
01490                 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
01491                 $a_data = preg_replace("/\n/","",$a_data);
01492                 if (!$this->inside_code)
01493                 {
01494                         $a_data = preg_replace("/\t+/","",$a_data);
01495                 }
01496 
01497                 $this->chr_data .= $a_data;
01498 
01499                 if(!empty($a_data) || $a_data === "0")
01500                 {
01501                         // append all data to page, if we are within PageObject,
01502                         // but not within MetaData or MediaObject
01503                         if (($this->in_page_object || $this->in_glossary_definition)
01504                                 && !$this->in_meta_data && !$this->in_media_object)
01505                         {
01506                                 $this->page_object->appendXMLContent($a_data);
01507                         }
01508 
01509                         if ($this->in_meta_data)
01510                         {
01511                                 //$this->meta_data->appendXMLContent($a_data);
01512 //echo "<br>".$a_data;
01513                         }
01514 
01515                         if ($this->in_bib_item  )
01516                         {
01517                                 $this->bib_item->appendXMLContent($a_data);
01518                         }
01519 
01520                         switch($this->getCurrentElement())
01521                         {
01522 
01523                                 case "IntLink":
01524                                 case "ExtLink":
01525                                         if($this->in_map_area)
01526                                         {
01527                                                 $this->map_area->appendTitle($a_data);
01528                                         }
01529                                         break;
01530 
01531                         }
01532                 }
01533 
01534         }
01535         
01536         
01541         function emptyMediaMetaCache(&$a_xml_parser)
01542         {
01543                 foreach ($this->media_meta_cache as $cache_entry)
01544                 {
01545                         switch($cache_entry["type"])
01546                         {
01547                                 case "handlerBeginTag": 
01548                                         parent::handlerBeginTag($a_xml_parser, 
01549                                                 $cache_entry["par1"], $cache_entry["par2"]);
01550                                         break;
01551                                         
01552                                 case "handlerEndTag":
01553                                         parent::handlerEndTag($a_xml_parser, 
01554                                                 $cache_entry["par1"]);
01555                                         break;
01556                                         
01557                                 case "handlerCharacterData":
01558                                         parent::handlerCharacterData($a_xml_parser,
01559                                                 $cache_entry["par1"]);
01560                                         break;
01561                         }
01562                 }
01563 
01564                 $this->media_meta_start = false;
01565                 $this->media_meta_cache[] = array();
01566         }
01567         
01568 
01569 }
01570 ?>

Generated on Fri Dec 13 2013 13:52:09 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1