Пример #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;
     }
 }