/**
  * 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;
     }
 }
 /**
  * Copy a term to a glossary
  *
  * @param
  * @return
  */
 function _copyTerm($a_term_id, $a_glossary_id)
 {
     $old_term = new ilGlossaryTerm($a_term_id);
     // copy the term
     $new_term = new ilGlossaryTerm();
     $new_term->setTerm($old_term->getTerm());
     $new_term->setLanguage($old_term->getLanguage());
     $new_term->setGlossaryId($a_glossary_id);
     $new_term->create();
     // copy the definitions
     include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
     $def_list = ilGlossaryDefinition::getDefinitionList($a_term_id);
     foreach ($def_list as $def) {
         $old_def = new ilGlossaryDefinition($def["id"]);
         $new_def = new ilGlossaryDefinition();
         $new_def->setShortText($old_def->getShortText());
         $new_def->setNr($old_def->getNr());
         $new_def->setTermId($new_term->getId());
         $new_def->create();
         // copy meta data
         include_once "Services/MetaData/classes/class.ilMD.php";
         $md = new ilMD($old_term->getGlossaryId(), $old_def->getPageObject()->getId(), $old_def->getPageObject()->getParentType());
         $new_md = $md->cloneMD($a_glossary_id, $new_def->getPageObject()->getId(), $old_def->getPageObject()->getParentType());
         // page content
         $new_def->getPageObject()->setXMLContent($old_def->getPageObject()->copyXmlContent(true));
         $new_def->getPageObject()->buildDom();
         $new_def->getPageObject()->update();
     }
     return $new_term->getId();
 }
示例#3
0
 /**
  * add definition
  */
 function addDefinition()
 {
     global $ilCtrl;
     $term_id = (int) $_GET["term_id"];
     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
     $term_glo_id = ilGlossaryTerm::_lookGlossaryID((int) $term_id);
     if ($term_glo_id != $this->object->getId()) {
         ilUtil::sendFailure($this->lng->txt("glo_term_must_belong_to_glo"), true);
         $ilCtrl->redirect($this, "listTerms");
     }
     // add term
     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
     $term = new ilGlossaryTerm($term_id);
     // add first definition
     $def = new ilGlossaryDefinition();
     $def->setTermId($term->getId());
     $def->setTitle(ilUtil::stripSlashes($term->getTerm()));
     $def->create();
     $this->ctrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term->getId());
     $this->ctrl->setParameterByClass("ilglossarydefpagegui", "def", $def->getId());
     $this->ctrl->redirectByClass(array("ilglossarytermgui", "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit");
 }