예제 #1
0
 /**
  * get the HTML pages of a card from the glossary
  * Each page is an assoc array with title and html code
  * The first page is assumed to be the question
  * 
  * @return array ( array ("title" => string, "html" => string), ...)
  */
 function getGlossaryTermPages()
 {
     require_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
     require_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
     require_once "./Services/COPage/classes/class.ilPageObjectGUI.php";
     $term = new ilGlossaryTerm($this->card->getTermId());
     $defs = ilGlossaryDefinition::getDefinitionList($term->getId());
     // get the term page
     $term_page = array("title" => $this->plugin->txt("glossary_term"), "html" => $term->getTerm());
     // get the definition pages
     $i = 1;
     $def_pages = array();
     $def_title = count($defs) > 1 ? $this->plugin->txt("glossary_definition_x") : $this->plugin->txt("glossary_definition");
     foreach ($defs as $definition) {
         $page_gui = new ilPageObjectGUI("gdf", $definition["id"]);
         $page_gui->setTemplateOutput(false);
         $page_gui->setOutputMode(IL_PAGE_PRESENTATION);
         $page_gui->setEnabledTabs(false);
         $def_pages[] = array("title" => sprintf($def_title, $i++), "html" => $page_gui->getHTML());
     }
     // return the pages according to the glossary mode
     switch ($this->object->getGlossaryMode()) {
         case ilObjFlashcards::GLOSSARY_MODE_TERM_DEFINITIONS:
             return array_merge(array($term_page), $def_pages);
         case ilObjFlashcards::GLOSSARY_MODE_DEFINITION_TERM:
             return array_merge($def_pages, array($term_page));
         case ilObjFlashcards::GLOSSARY_MODE_DEFINITIONS:
             $def_pages[0]["title"] = $this->plugin->txt("question");
             $answer_title = count($def_pages) > 2 ? $this->plugin->txt("answer_x") : $this->plugin->txt("answer");
             for ($i = 1; $i < count($def_pages); $i++) {
                 $def_pages[$i]["title"] = sprintf($answer_title, $i);
             }
             return $def_pages;
     }
 }
 /**
  * Output post processing
  *
  * @param
  * @return
  */
 function outputPostProcessing($a_output)
 {
     // for question html get the page gui object
     include_once "./Services/COPage/classes/class.ilPageObjectGUI.php";
     $pg_gui = new ilPageObjectGUI($this->page->getParentType(), $this->page->getId());
     $pg_gui->setOutputMode(IL_PAGE_PREVIEW);
     $pg_gui->setEnabledSelfAssessment(true);
     $pg_gui->initSelfAssessmentRendering(true);
     $qhtml = $pg_gui->getQuestionHTML();
     if (is_array($qhtml)) {
         foreach ($qhtml as $k => $h) {
             $a_output = str_replace($pg_gui->pl_start . "Question;il__qst_{$k}" . $pg_gui->pl_end, " " . $h, $a_output);
         }
     }
     $a_output = $pg_gui->selfAssessmentRendering($a_output);
     return $a_output;
 }
 /**
  * output glossary term definitions
  *
  * used in ilLMPresentationGUI->ilGlossary()
  */
 function output($a_offline = false, $a_tpl = "", $a_outputmode = "presentation")
 {
     if ($a_tpl != "") {
         $tpl = $a_tpl;
     } else {
         $tpl = $this->tpl;
     }
     require_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
     require_once "./Services/COPage/classes/class.ilPageObjectGUI.php";
     $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
     $tpl->setVariable("TXT_TERM", $this->term->getTerm());
     for ($j = 0; $j < count($defs); $j++) {
         $def = $defs[$j];
         $page_gui = new ilPageObjectGUI("gdf", $def["id"]);
         $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $_GET["ref_id"]);
         if (!$a_offline) {
             //$page_gui->setFullscreenLink(
             //	"ilias.php?baseClass=ilGlossaryPresentationGUI&cmd=fullscreen&ref_id=".$_GET["ref_id"]);
         } else {
             $page_gui->setFullscreenLink("fullscreen.html");
             // id is set by xslt
         }
         $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=downloadFile&amp;ref_id=" . $_GET["ref_id"]);
         if (!$a_offline) {
             $page_gui->setOutputMode($a_outputmode);
         } else {
             $page_gui->setOutputMode("offline");
             $page_gui->setOfflineDirectory($this->getOfflineDirectory());
         }
         //$page_gui->setOutputMode("edit");
         //$page_gui->setPresentationTitle($this->term->getTerm());
         $page_gui->setLinkXML($this->getLinkXML());
         $page_gui->setTemplateOutput(false);
         $output = $page_gui->presentation($page_gui->getOutputMode());
         if (count($defs) > 1) {
             $tpl->setCurrentBlock("definition_header");
             $tpl->setVariable("TXT_DEFINITION", $this->lng->txt("cont_definition") . " " . ($j + 1));
             $tpl->parseCurrentBlock();
         }
         $tpl->setCurrentBlock("definition");
         $tpl->setVariable("PAGE_CONTENT", $output);
         $tpl->parseCurrentBlock();
     }
 }
 /**
  * Compares two revisions of the page
  */
 function compareVersion()
 {
     global $lng;
     if (!$this->getEnableEditing()) {
         return;
     }
     $tpl = new ilTemplate("tpl.page_compare.html", true, true, "Services/COPage");
     $compare = $this->obj->compareVersion($_POST["left"], $_POST["right"]);
     // left page
     $lpage = $compare["l_page"];
     $lpage_gui = new ilPageObjectGUI($lpage->getParentType(), 0);
     $cfg = $lpage_gui->getPageConfig();
     $cfg->setPreventHTMLUnmasking(true);
     $lpage_gui->setOutputMode(IL_PAGE_PREVIEW);
     $lpage_gui->setPageObject($lpage);
     $lpage_gui->setPresentationTitle($this->getPresentationTitle());
     $lpage_gui->setCompareMode(true);
     $lhtml = $lpage_gui->showPage();
     $lhtml = $this->replaceDiffTags($lhtml);
     $lhtml = str_replace("&lt;br /&gt;", "<br />", $lhtml);
     $tpl->setVariable("LEFT", $lhtml);
     // right page
     $rpage = $compare["r_page"];
     $rpage_gui = new ilPageObjectGUI($rpage->getParentType(), 0);
     $cfg = $rpage_gui->getPageConfig();
     $cfg->setPreventHTMLUnmasking(true);
     $rpage_gui->setOutputMode(IL_PAGE_PREVIEW);
     $rpage_gui->setPageObject($rpage);
     $rpage_gui->setPresentationTitle($this->getPresentationTitle());
     $rpage_gui->setCompareMode(true);
     $rhtml = $rpage_gui->showPage();
     $rhtml = $this->replaceDiffTags($rhtml);
     $rhtml = str_replace("&lt;br /&gt;", "<br />", $rhtml);
     $tpl->setVariable("RIGHT", $rhtml);
     $tpl->setVariable("TXT_NEW", $lng->txt("cont_pc_new"));
     $tpl->setVariable("TXT_MODIFIED", $lng->txt("cont_pc_modified"));
     $tpl->setVariable("TXT_DELETED", $lng->txt("cont_pc_deleted"));
     //var_dump($left);
     //var_dump($right);
     return $tpl->get();
 }