Esempio n. 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;
     }
 }
 /**
  * Print view selection
  *
  * @param
  * @return
  */
 function printViewSelection()
 {
     global $ilUser, $lng, $ilToolbar, $ilCtrl, $tpl, $ilTabs;
     $ilCtrl->saveParameter($this, "term_id");
     if ((int) $this->term_id == 0) {
         $this->setTabs();
         $ilTabs->activateTab("print_view");
     } else {
         $tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.png"));
         $term = new ilGlossaryTerm((int) $this->term_id);
         $tpl->setTitle($this->lng->txt("cont_term") . ": " . $term->getTerm());
         $this->showDefinitionTabs("print_view");
     }
     $this->initPrintViewSelectionForm();
     $tpl->setContent($this->form->getHTML());
 }
 /**
  * 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();
 }
Esempio n. 4
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");
 }
 /**
  * confirm term deletion
  */
 function confirmTermDeletion()
 {
     global $ilCtrl, $lng;
     //$this->prepareOutput();
     if (!isset($_POST["id"])) {
         ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
         $ilCtrl->redirect($this, "listTerms");
     }
     // check ids
     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
     foreach ($_POST["id"] as $term_id) {
         $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");
         }
     }
     // display confirmation message
     include_once "./Services/Utilities/classes/class.ilConfirmationGUI.php";
     $cgui = new ilConfirmationGUI();
     $cgui->setFormAction($this->ctrl->getFormAction($this));
     $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
     $cgui->setCancel($this->lng->txt("cancel"), "cancelTermDeletion");
     $cgui->setConfirm($this->lng->txt("confirm"), "deleteTerms");
     foreach ($_POST["id"] as $id) {
         $term = new ilGlossaryTerm($id);
         $add = "";
         $nr = ilGlossaryTerm::getNumberOfUsages($id);
         if ($nr > 0) {
             $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $id);
             $link = "[<a href='" . $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages") . "'>" . $lng->txt("glo_list_usages") . "</a>]";
             $add = "<div class='small'>" . sprintf($lng->txt("glo_term_is_used_n_times"), $nr) . " " . $link . "</div>";
         }
         $cgui->addItem("id[]", $id, $term->getTerm() . $add);
     }
     $this->tpl->setContent($cgui->getHTML());
 }