コード例 #1
0
 /**
  * Final processing
  *
  * @param	array		mapping array
  */
 function finalProcessing($a_mapping)
 {
     $pages = $a_mapping->getMappingsOfEntity("Services/COPage", "pg");
     $media_objects = $a_mapping->getMappingsOfEntity("Services/MediaObjects", "mob");
     $file_objects = $a_mapping->getMappingsOfEntity("Modules/File", "file");
     if (count($media_objects) > 0 || count($file_objects) > 0) {
         foreach ($pages as $p) {
             $id = explode(":", $p);
             if (count($id) == 2) {
                 include_once "./Services/COPage/classes/class.ilPageObject.php";
                 if (ilPageObject::_exists($id[0], $id[1])) {
                     $new_page = new ilPageObject($id[0], $id[1]);
                     $new_page->buildDom();
                     $med = $new_page->resolveMediaAliases($media_objects);
                     $fil = $new_page->resolveFileItems($file_objects);
                     if ($med || $fil) {
                         $new_page->update(false, true);
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
 /**
  * get internal links
  */
 function getInternalLinks()
 {
     require_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
     require_once "./Services/COPage/classes/class.ilPageObjectGUI.php";
     $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
     $term_links = array();
     for ($j = 0; $j < count($defs); $j++) {
         $def = $defs[$j];
         $page = new ilPageObject("gdf", $def["id"]);
         $page->buildDom();
         $page_links = $page->getInternalLinks();
         foreach ($page_links as $key => $page_link) {
             $term_links[$key] = $page_link;
         }
     }
     return $term_links;
 }
コード例 #3
0
 /**
  * parse pages that contain files, mobs and/or internal links
  */
 function processPagesToParse()
 {
     /*
     		$pg_mapping = array();
     		foreach($this->pg_mapping as $key => $value)
     		{
     			$pg_mapping[$key] = "il__pg_".$value;
     		}*/
     //echo "<br><b>processIntLinks</b>"; flush();
     // outgoin internal links
     foreach ($this->pages_to_parse as $page_id) {
         $page_arr = explode(":", $page_id);
         //echo "<br>resolve:".$this->content_object->getType().":".$page_id; flush();
         switch ($page_arr[0]) {
             case "lm":
                 $page_obj =& new ilPageObject($this->content_object->getType(), $page_arr[1]);
                 break;
             case "gdf":
                 $page_obj =& new ilPageObject("gdf", $page_arr[1]);
                 break;
         }
         $page_obj->buildDom();
         $page_obj->resolveIntLinks();
         $page_obj->resolveIIMMediaAliases($this->mob_mapping);
         if (in_array($this->coType, array("lm", "dbk"))) {
             $page_obj->resolveQuestionReferences($this->qst_mapping);
         }
         $page_obj->update(false);
         if ($page_arr[0] == "gdf") {
             $def =& new ilGlossaryDefinition($page_arr[1]);
             $def->updateShortText();
         }
         unset($page_obj);
     }
     //echo "<br><b>map area internal links</b>"; flush();
     // outgoins map area (mob) internal links
     foreach ($this->mobs_with_int_links as $mob_id) {
         ilMediaItem::_resolveMapAreaLinks($mob_id);
     }
     //echo "<br><b>incoming interna links</b>"; flush();
     // incoming internal links
     $done = array();
     foreach ($this->link_targets as $link_target) {
         //echo "doin link target:".$link_target.":<br>";
         $link_arr = explode("_", $link_target);
         $target_inst = $link_arr[1];
         $target_type = $link_arr[2];
         $target_id = $link_arr[3];
         $sources = ilInternalLink::_getSourcesOfTarget($target_type, $target_id, $target_inst);
         foreach ($sources as $key => $source) {
             //echo "got source:".$key.":<br>";
             if (in_array($key, $done)) {
                 continue;
             }
             $type_arr = explode(":", $source["type"]);
             // content object pages
             if ($type_arr[1] == "pg") {
                 $page_object = new ilPageObject($type_arr[0], $source["id"]);
                 $page_object->buildDom();
                 $page_object->resolveIntLinks();
                 $page_object->update();
                 unset($page_object);
             }
             // eventually correct links in questions to learning modules
             if ($type_arr[0] == "qst") {
                 require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                 assQuestion::_resolveIntLinks($source["id"]);
             }
             // eventually correct links in survey questions to learning modules
             if ($type_arr[0] == "sqst") {
                 require_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                 SurveyQuestion::_resolveIntLinks($source["id"]);
             }
             $done[$key] = $key;
         }
     }
 }
コード例 #4
0
 /**
  * Validate all pages
  */
 function validatePages()
 {
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     include_once "./Services/COPage/classes/class.ilPageObject.php";
     $mess = "";
     $pages = ilLMPageObject::getPageList($this->getId());
     foreach ($pages as $page) {
         if (ilPageObject::_exists($this->getType(), $page["obj_id"])) {
             $cpage = new ilPageObject($this->getType(), $page["obj_id"]);
             $cpage->buildDom();
             $error = @$cpage->validateDom();
             if ($error != "") {
                 $this->lng->loadLanguageModule("content");
                 ilUtil::sendInfo($this->lng->txt("cont_import_validation_errors"));
                 $title = ilLMObject::_lookupTitle($page["obj_id"]);
                 $page_obj = new ilLMPageObject($this, $page["obj_id"]);
                 $mess .= $this->lng->txt("obj_pg") . ": " . $title;
                 $mess .= '<div class="small">';
                 foreach ($error as $e) {
                     $err_mess = implode($e, " - ");
                     if (!is_int(strpos($err_mess, ":0:"))) {
                         $mess .= htmlentities($err_mess) . "<br />";
                     }
                 }
                 $mess .= '</div>';
                 $mess .= "<br />";
             }
         }
     }
     return $mess;
 }
コード例 #5
0
 /**
  * Clone container settings
  *
  * @access public
  * @param int target ref_id
  * @param int copy id
  * @return object new object 
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
     $sorting = new ilContainerSortingSettings($new_obj->getId());
     $sorting->setSortMode($this->getOrderType());
     $sorting->update();
     // copy content page
     include_once "./Services/COPage/classes/class.ilPageObject.php";
     if (ilPageObject::_exists($this->getType(), $this->getId())) {
         $orig_page = new ilPageObject($this->getType(), $this->getId());
         $new_page_object = new ilPageObject($this->getType());
         $new_page_object->setParentId($new_obj->getId());
         $new_page_object->setId($new_obj->getId());
         $new_page_object->createFromXML();
         $new_page_object->setXMLContent($orig_page->getXMLContent());
         $new_page_object->buildDom();
         $new_page_object->update();
     }
     return $new_obj;
 }
コード例 #6
0
 /**
  * export page objects to xml (see ilias_co.dtd)
  *
  * @param	object		$a_xml_writer	ilXmlWriter object that receives the
  *										xml data
  */
 function exportXMLPageObjects(&$a_xml_writer, $a_inst, &$expLog)
 {
     global $ilBench;
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     foreach ($this->questions as $question_id) {
         $ilBench->start("ContentObjectExport", "exportPageObject");
         $expLog->write(date("[y-m-d H:i:s] ") . "Page Object " . $question_id);
         $attrs = array();
         $a_xml_writer->xmlStartTag("PageObject", $attrs);
         // export xml to writer object
         $ilBench->start("ContentObjectExport", "exportPageObject_XML");
         $page_object = new ilPageObject("qpl", $question_id);
         $page_object->buildDom();
         $page_object->insertInstIntoIDs($a_inst);
         $mob_ids = $page_object->collectMediaObjects(false);
         $file_ids = $page_object->collectFileItems();
         $xml = $page_object->getXMLFromDom(false, false, false, "", true);
         $xml = str_replace("&", "&amp;", $xml);
         $a_xml_writer->appendXML($xml);
         $page_object->freeDom();
         unset($page_object);
         $ilBench->stop("ContentObjectExport", "exportPageObject_XML");
         // collect media objects
         $ilBench->start("ContentObjectExport", "exportPageObject_CollectMedia");
         //$mob_ids = $page_obj->getMediaObjectIDs();
         foreach ($mob_ids as $mob_id) {
             $this->mob_ids[$mob_id] = $mob_id;
         }
         $ilBench->stop("ContentObjectExport", "exportPageObject_CollectMedia");
         // collect all file items
         $ilBench->start("ContentObjectExport", "exportPageObject_CollectFileItems");
         //$file_ids = $page_obj->getFileItemIds();
         foreach ($file_ids as $file_id) {
             $this->file_ids[$file_id] = $file_id;
         }
         $ilBench->stop("ContentObjectExport", "exportPageObject_CollectFileItems");
         $a_xml_writer->xmlEndTag("PageObject");
         //unset($page_obj);
         $ilBench->stop("ContentObjectExport", "exportPageObject");
     }
 }
コード例 #7
0
 /**
  * Export HTML pages of SCO
  */
 function exportHTMLPageObjects($a_inst, $a_target_dir, &$expLog, $mode, $a_asset_type = "sco", $a_one_file = "", $a_sco_tpl = null)
 {
     global $tpl, $ilCtrl, $ilBench, $ilLog, $lng;
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php";
     include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModuleGUI.php";
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $output = "";
     $tree = new ilTree($this->slm_id);
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     // @todo
     // Why is that much HTML code in an application class?
     // Please extract all this HTML to a tpl.<t_name>.html file and use
     // placeholders and the template engine to insert data.
     //
     // There copy/paste code residenting in ilSCORM2004ScoGUI. This
     // should be merged.
     //
     // alex, 4 Apr 09
     //
     //		if ($a_one_file == "")
     //		{
     $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004");
     //		}
     //		else
     //		{
     //			$sco_tpl = $a_sco_tpl;
     //		}
     if ($mode != 'pdf' && $a_one_file == "") {
         include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php";
         $pg_exp = new ilCOPageHTMLExport($a_target_dir);
         $pg_exp->getPreparedMainTemplate($sco_tpl);
         // init and question lang vars
         $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->slm_id);
         $sco_tpl->setCurrentBlock("init");
         $sco_tpl->setVariable("TXT_INIT_CODE", ilPageObjectGUI::getJSTextInitCode($lk));
         $sco_tpl->parseCurrentBlock();
         // (additional) style sheets needed
         $styles = array("./css/yahoo/container.css", "./css/question_handling.css");
         foreach ($styles as $style) {
             $sco_tpl->setCurrentBlock("css_file");
             $sco_tpl->setVariable("CSS_FILE", $style);
             $sco_tpl->parseCurrentBlock();
         }
         // (additional) scripts needed
         $scripts = array("./js/scorm.js", "./js/pager.js", "./js/pure.js", "./js/questions_" . $this->getId() . ".js");
         foreach ($scripts as $script) {
             $sco_tpl->setCurrentBlock("js_file");
             $sco_tpl->setVariable("JS_FILE", $script);
             $sco_tpl->parseCurrentBlock();
         }
         if ($a_asset_type != "entry_asset" && $a_asset_type != "final_asset") {
             self::renderNavigation($sco_tpl, "./images/spacer.png", $lk);
         }
         $sco_tpl->touchBlock("finish");
     }
     // render head
     $sco_tpl->setCurrentBlock("head");
     $sco_tpl->setVariable("SCO_TITLE", $this->getTitle());
     $sco_tpl->parseCurrentBlock();
     $sco_tpl->touchBlock("tail");
     // meta page (meta info at SCO beginning)
     self::renderMetaPage($sco_tpl, $this, $a_asset_type, $mode);
     if ($a_one_file != "") {
         fputs($a_one_file, "<a name='sco" . $this->getId() . "'></a>");
         fputs($a_one_file, $sco_tpl->get("meta_page"));
     }
     //notify Question Exporter of new SCO
     require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
     ilQuestionExporter::indicateNewSco();
     // init export (this initialises glossary template)
     ilSCORM2004PageGUI::initExport();
     $terms = array();
     $terms = $this->getGlossaryTermIds();
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ScoGUI.php";
     $pages = $tree->getSubTree($tree->getNodeData($this->getId()), true, 'page');
     $sco_q_ids = array();
     foreach ($pages as $page) {
         //echo(print_r($page));
         $page_obj = new ilSCORM2004PageGUI($this->getType(), $page["obj_id"], 0, $this->slm_object->getId());
         $page_obj->setPresentationTitle($page["title"]);
         $page_obj->setOutputMode(IL_PAGE_OFFLINE);
         $page_obj->setStyleId($this->slm_object->getStyleSheetId());
         if (count($terms) > 1) {
             $page_obj->setGlossaryOverviewInfo(ilSCORM2004ScoGUI::getGlossaryOverviewId(), $this);
         }
         $page_output = $page_obj->showPage("export");
         // collect media objects
         $mob_ids = $page_obj->getSCORM2004Page()->collectMediaObjects(false);
         foreach ($mob_ids as $mob_id) {
             $this->mob_ids[$mob_id] = $mob_id;
             $media_obj = new ilObjMediaObject($mob_id);
             if ($media_obj->hasFullscreenItem()) {
                 $media_obj->exportMediaFullscreen($a_target_dir, $page_obj->getPageObject());
             }
         }
         // collect glossary items
         $int_links = $page_obj->getPageObject()->getInternalLinks(true);
         include_once "./Services/COPage/classes/class.ilInternalLink.php";
         include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
         include_once "./Services/COPage/classes/class.ilPageObject.php";
         if (is_array($int_links)) {
             foreach ($int_links as $k => $e) {
                 // glossary link
                 if ($e["Type"] == "GlossaryItem") {
                     $karr = explode(":", $k);
                     $tid = ilInternalLink::_extractObjIdOfTarget($karr[0]);
                     $dids = ilGlossaryDefinition::getDefinitionList($tid);
                     foreach ($dids as $did) {
                         $def_pg = new ilPageObject("gdf", $did["id"]);
                         $def_pg->buildDom();
                         $mob_ids = $def_pg->collectMediaObjects(false);
                         foreach ($mob_ids as $mob_id) {
                             $this->mob_ids[$mob_id] = $mob_id;
                             //echo "<br>-$mob_id-";
                             $media_obj = new ilObjMediaObject($mob_id);
                             if ($media_obj->hasFullscreenItem()) {
                                 $media_obj->exportMediaFullscreen($a_target_dir, $def_pg);
                             }
                         }
                         $file_ids = $def_pg->collectFileItems();
                         foreach ($file_ids as $file_id) {
                             $this->file_ids[$file_id] = $file_id;
                         }
                     }
                 }
             }
         }
         //exit;
         // collect all file items
         $file_ids = $page_obj->getSCORM2004Page()->collectFileItems();
         foreach ($file_ids as $file_id) {
             $this->file_ids[$file_id] = $file_id;
         }
         if ($mode == 'pdf') {
             $q_ids = ilSCORM2004Page::_getQuestionIdsForPage("sahs", $page["obj_id"]);
             foreach ($q_ids as $q_id) {
                 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
                 $q_gui =& assQuestionGUI::_getQuestionGUI("", $q_id);
                 $q_gui->outAdditionalOutput();
                 $html = $q_gui->getPreview(TRUE);
                 $page_output = preg_replace("/{{{{{Question;il__qst_" . $q_id . "}}}}}/i", $html, $page_output);
             }
             $sco_tpl->touchBlock("pdf_pg_break");
         }
         $sco_tpl->setCurrentBlock("page");
         $sco_tpl->setVariable("PAGE", $page_output);
         $sco_tpl->parseCurrentBlock();
         // get all question ids of the sco
         if ($a_one_file != "") {
             $q_ids = ilSCORM2004Page::_getQuestionIdsForPage("sahs", $page["obj_id"]);
             foreach ($q_ids as $i) {
                 if (!in_array($i, $sco_q_ids)) {
                     $sco_q_ids[] = $i;
                 }
             }
         }
     }
     // glossary
     if ($mode != 'pdf') {
         $sco_tpl->setVariable("GLOSSARY_HTML", ilSCORM2004PageGUI::getGlossaryHTML($this));
     }
     if ($a_one_file == "") {
         $output = $sco_tpl->get();
     } else {
         $output = $sco_tpl->get("page");
     }
     if ($mode == 'pdf') {
         $output = preg_replace("/<div class=\"ilc_page_title_PageTitle\">(.*?)<\\/div>/i", "<h2>\$1</h2>", $output);
     }
     //$output = preg_replace("/\.\/mobs\/mm_(\d+)\/([^\"]+)/i","./objects/il_".IL_INST_ID."_mob_$1/$2",$output);
     $output = preg_replace("/mobs\\/mm_(\\d+)\\/([^\"]+)/i", "./objects/il_" . IL_INST_ID . "_mob_\$1/\$2", $output);
     $output = preg_replace("/\\.\\/files\\/file_(\\d+)\\/([^\"]+)/i", "./objects/il_" . IL_INST_ID . "_file_\$1/\$2", $output);
     $output = preg_replace("/\\.\\/Services\\/MediaObjects\\/flash_mp3_player/i", "./players", $output);
     //		$output = preg_replace("/\.\/".str_replace("/", "\/", ilPlayerUtil::getFlashVideoPlayerDirectory())."/i","./players",$output);
     $output = preg_replace("/file=..\\/..\\/..\\/.\\//i", "file=../", $output);
     if ($mode != 'pdf') {
         $output = preg_replace_callback("/href=\"&mob_id=(\\d+)&pg_id=(\\d+)\"/", array(get_class($this), 'fixFullscreeenLink'), $output);
         // this one is for fullscreen in glossary entries
         $output = preg_replace_callback("/href=\"fullscreen_(\\d+)\\.html\"/", array(get_class($this), 'fixFullscreeenLink'), $output);
         $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/", array(get_class($this), 'insertQuestion'), $output);
         //			$output = preg_replace("/&#123;/","",$output);
         //			$output = preg_replace("/&#125;/","",$output);
         $q_handling = file_get_contents('./Modules/Scorm2004/scripts/questions/question_handling.js');
         fputs(fopen($a_target_dir . '/js/questions_' . $this->getId() . '.js', 'w+'), ilQuestionExporter::questionsJS() . $q_handling);
         copy("./Modules/Scorm2004/templates/default/question_handling.css", $a_target_dir . '/css/question_handling.css');
         // hack to get the question js into the file and to display the correct answers
         if ($a_one_file != "") {
             $output = '<script type="text/javascript">' . ilQuestionExporter::questionsJS() . '</script>' . $output;
             if (count($sco_q_ids) > 0) {
                 $output .= '<script type="text/javascript">';
                 foreach ($sco_q_ids as $i) {
                     if ($i > 0) {
                         $output .= "ilias.questions.showCorrectAnswers(" . $i . "); \n";
                     }
                 }
                 $output .= '</script>';
             }
         }
         foreach (ilQuestionExporter::getMobs() as $mob_id) {
             $this->mob_ids[$mob_id] = $mob_id;
         }
     }
     $this->q_media = ilQuestionExporter::getFiles();
     //questions export end
     if ($a_one_file != "") {
         fputs($a_one_file, $output);
     } else {
         fputs(fopen($a_target_dir . '/index.html', 'w+'), $output);
     }
     $this->exportFileItems($a_target_dir, $expLog);
 }
コード例 #8
0
 /**
  * Standard Version of Fill Row. Most likely to
  * be overwritten by derived class.
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl;
     $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
     $ilCtrl->setParameterByClass("illmpageobjectgui", "obj_id", $a_set["obj_id"]);
     $this->tpl->setVariable("HREF_PAGE", $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "edit"));
     $page_object = new ilPageObject($this->lm_type, $a_set["obj_id"]);
     $page_object->buildDom();
     $int_links = $page_object->getInternalLinks();
     foreach ($int_links as $link) {
         $target = $link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $link["Type"];
             switch ($type) {
                 case "PageObject":
                     $this->tpl->setCurrentBlock("link");
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
                     if (ilLMObject::_exists($target_id)) {
                         $lm_id = ilLMObject::_lookupContObjID($target_id);
                         $add_str = $lm_id != $this->lm_id ? " (" . ilObject::_lookupTitle($lm_id) . ")" : "";
                         $this->tpl->setVariable("TXT_LINK_TITLE", ilLMObject::_lookupTitle($target_id) . $add_str);
                     } else {
                         $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>");
                     }
                     $this->tpl->parseCurrentBlock();
                     break;
                 case "StructureObject":
                     $this->tpl->setCurrentBlock("link");
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
                     if (ilLMObject::_exists($target_id)) {
                         $lm_id = ilLMObject::_lookupContObjID($target_id);
                         $add_str = $lm_id != $this->lm_id ? " (" . ilObject::_lookupTitle($lm_id) . ")" : "";
                         $this->tpl->setVariable("TXT_LINK_TITLE", ilLMObject::_lookupTitle($target_id) . $add_str);
                     } else {
                         $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>");
                     }
                     $this->tpl->parseCurrentBlock();
                     break;
                 case "GlossaryItem":
                     $this->tpl->setCurrentBlock("link");
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
                     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                     if (ilGlossaryTerm::_exists($target_id)) {
                         $this->tpl->setVariable("TXT_LINK_TITLE", ilGlossaryTerm::_lookGlossaryTerm($target_id));
                     } else {
                         $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>");
                     }
                     $this->tpl->parseCurrentBlock();
                     break;
                 case "MediaObject":
                     $this->tpl->setCurrentBlock("link");
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
                     if (ilObject::_exists($target_id)) {
                         $this->tpl->setVariable("TXT_LINK_TITLE", ilObject::_lookupTitle($target_id));
                     } else {
                         $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>");
                     }
                     $this->tpl->parseCurrentBlock();
                     break;
                 case "RepositoryItem":
                     $this->tpl->setCurrentBlock("link");
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     if (ilObject::_exists($obj_id)) {
                         $this->tpl->setVariable("TXT_LINK_TITLE", ilObject::_lookupTitle($obj_id) . " (" . $lng->txt("obj_" . $obj_type) . ")");
                     } else {
                         $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>");
                     }
                     $this->tpl->parseCurrentBlock();
                     break;
             }
         } else {
             $type = $link["Type"];
             switch ($type) {
                 case "PageObject":
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
                     break;
                 case "StructureObject":
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
                     break;
                 case "GlossaryItem":
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
                     break;
                 case "MediaObject":
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
                     break;
                 case "RepositoryItem":
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
                     break;
             }
             $this->tpl->setCurrentBlock("link");
             $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target . "]" . "</b>");
             $this->tpl->parseCurrentBlock();
         }
     }
 }
コード例 #9
0
 /**
  * Update internal links, after multiple pages have been copied
  */
 static function updateInternalLinks($a_copied_nodes, $a_parent_type = "lm")
 {
     $all_fixes = array();
     foreach ($a_copied_nodes as $original_id => $copied_id) {
         $copied_type = ilLMObject::_lookupType($copied_id);
         $copy_lm = ilLMObject::_lookupContObjID($copied_id);
         if ($copied_type == "pg") {
             //
             // 1. Outgoing links from the copied page.
             //
             //$targets = ilInternalLink::_getTargetsOfSource($a_parent_type.":pg", $copied_id);
             $tpg = new ilPageObject($a_parent_type, $copied_id);
             $tpg->buildDom();
             $il = $tpg->getInternalLinks();
             $targets = array();
             foreach ($il as $l) {
                 $targets[] = array("type" => ilInternalLink::_extractTypeOfTarget($l["Target"]), "id" => (int) ilInternalLink::_extractObjIdOfTarget($l["Target"]), "inst" => (int) ilInternalLink::_extractInstOfTarget($l["Target"]));
             }
             $fix = array();
             foreach ($targets as $target) {
                 if (($target["inst"] == 0 || ($target["inst"] = IL_INST_ID)) && ($target["type"] == "pg" || $target["type"] == "st")) {
                     // first check, whether target is also within the copied set
                     if ($a_copied_nodes[$target["id"]] > 0) {
                         $fix[$target["id"]] = $a_copied_nodes[$target["id"]];
                     } else {
                         // now check, if a copy if the target is already in the same lm
                         // only if target is not already in the same lm!
                         $trg_lm = ilLMObject::_lookupContObjID($target["id"]);
                         if ($trg_lm != $copy_lm) {
                             $lm_data = ilLMObject::_getAllObjectsForImportId("il__" . $target["type"] . "_" . $target["id"]);
                             $found = false;
                             foreach ($lm_data as $item) {
                                 if (!$found && $item["lm_id"] == $copy_lm) {
                                     $fix[$target["id"]] = $item["obj_id"];
                                     $found = true;
                                 }
                             }
                         }
                     }
                 }
             }
             // outgoing links to be fixed
             if (count($fix) > 0) {
                 //echo "<br>--".$copied_id;
                 //var_dump($fix);
                 $t = ilObject::_lookupType($copy_lm);
                 if (is_array($all_fixes[$t . ":" . $copied_id])) {
                     $all_fixes[$t . ":" . $copied_id] += $fix;
                 } else {
                     $all_fixes[$t . ":" . $copied_id] = $fix;
                 }
                 //					$page = new ilPageObject(ilObject::_lookupType($copy_lm), $copied_id);
                 //					$page->moveIntLinks($fix);
                 //					$page->update();
             }
         }
         if ($copied_type == "pg" || $copied_type == "st") {
             //
             // 2. Incoming links to the original pages
             //
             // A->B			A2			(A+B currently copied)
             // A->C			B2
             // B->A
             // C->A			C2->A		(C already copied)
             $original_lm = ilLMObject::_lookupContObjID($original_id);
             $original_type = ilObject::_lookupType($original_lm);
             if ($original_lm != $copy_lm) {
                 // This gets sources that link to A+B (so we have C here)
                 // (this also does already the trick when instance map areas are given in C)
                 // int_link, where target_type, target_id, target_inst -> ok
                 $sources = ilInternalLink::_getSourcesOfTarget($copied_type, $original_id, 0);
                 // mobs linking to $original_id
                 // map_area, where link_type, target -> ok
                 $mobs = ilMapArea::_getMobsForTarget("int", "il__" . $copied_type . "_" . $original_id);
                 // pages using these mobs
                 include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
                 foreach ($mobs as $mob) {
                     // mob_usage, where id -> ok
                     // mep_item, where foreign_id, type -> ok
                     // mep_tree, where child -> already existed
                     // il_news_item, where mob_id -> ok
                     // map_area, where link_type, target -> aready existed
                     // media_item, where id -> already existed
                     // personal_clipboard, where item_id, type -> ok
                     $usages = ilObjMediaObject::lookupUsages($mob);
                     foreach ($usages as $usage) {
                         if ($usage["type"] == "lm:pg" | $usage["type"] == "lm:st") {
                             $sources[] = $usage;
                         }
                     }
                 }
                 $fix = array();
                 foreach ($sources as $source) {
                     $stype = explode(":", $source["type"]);
                     $source_type = $stype[1];
                     if ($source_type == "pg" || $source_type == "st") {
                         // first of all: source must be in original lm
                         $src_lm = ilLMObject::_lookupContObjID($source["id"]);
                         if ($src_lm == $original_lm) {
                             // check, if a copy if the source is already in the same lm
                             // now we look for the latest copy of C in LM2
                             $lm_data = ilLMObject::_getAllObjectsForImportId("il__" . $source_type . "_" . $source["id"], $copy_lm);
                             $found = false;
                             foreach ($lm_data as $item) {
                                 if (!$found) {
                                     $fix[$item["obj_id"]][$original_id] = $copied_id;
                                     $found = true;
                                 }
                             }
                         }
                     }
                 }
                 // outgoing links to be fixed
                 if (count($fix) > 0) {
                     foreach ($fix as $page_id => $fix_array) {
                         //echo "<br>++".$page_id;
                         //var_dump($fix_array);
                         $t = ilObject::_lookupType($copy_lm);
                         if (is_array($all_fixes[$t . ":" . $page_id])) {
                             $all_fixes[$t . ":" . $page_id] += $fix_array;
                         } else {
                             $all_fixes[$t . ":" . $page_id] = $fix_array;
                         }
                         //							$page = new ilPageObject(ilObject::_lookupType($copy_lm), $page_id);
                         //							$page->moveIntLinks($fix_array);
                         //							$page->update();
                     }
                 }
             }
         }
     }
     foreach ($all_fixes as $pg => $fixes) {
         //echo "<br>**".$pg;
         //echo var_dump($fixes);
         $pg = explode(":", $pg);
         $page = new ilPageObject($pg[0], $pg[1]);
         if ($page->moveIntLinks($fixes)) {
             $page->update(true, true, true);
         }
     }
 }
コード例 #10
0
 /**
  * Get xml representation
  *
  * @param string	entity
  * @param string	schema version
  * @param array		ids
  * @return string	xml
  */
 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
 {
     if ($a_entity == "pg") {
         include_once "./Services/COPage/classes/class.ilPageObject.php";
         $id = explode(":", $a_id);
         $page_object = new ilPageObject($id[0], $id[1]);
         $page_object->buildDom();
         $page_object->insertInstIntoIDs(IL_INST_ID);
         $pxml = $page_object->getXMLFromDom(false, false, false, "", true);
         $pxml = str_replace("&", "&amp;", $pxml);
         $xml = "<PageObject>";
         $xml .= $pxml;
         $xml .= "</PageObject>";
         $page_object->freeDom();
         return $xml;
     }
     if ($a_entity == "pgtp") {
         return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
     }
 }
コード例 #11
0
 /**
  * Fix container item group references after a container has been cloned
  *
  * @param
  * @return
  */
 static function fixContainerItemGroupRefsAfterCloning($a_source_container, $a_copy_id)
 {
     global $ilLog;
     $ilLog->write(__METHOD__ . ': Fix item group references in ' . $a_source_container->getType());
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     $new_container_ref_id = $mappings[$a_source_container->getRefId()];
     $ilLog->write(__METHOD__ . ': 2-' . $new_container_ref_id . '-');
     $new_container_obj_id = ilObject::_lookupObjId($new_container_ref_id);
     include_once "./Services/COPage/classes/class.ilPageObject.php";
     $new_page = new ilPageObject($a_source_container->getType(), $new_container_obj_id);
     $new_page->buildDom();
     include_once "./Services/COPage/classes/class.ilPCResources.php";
     ilPCResources::modifyItemGroupRefIdsByMapping($new_page, $mappings);
     $new_page->update();
 }