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

Generated on Fri Dec 13 2013 11:57:56 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1