ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTermDefinitionEditorGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
25 require_once ("./Services/COPage/classes/class.ilPageObjectGUI.php");
26 
38 {
39  var $ilias;
40  var $tpl;
41  var $lng;
42  var $glossary;
44  var $term;
45 
51  {
52  global $ilias, $tpl, $lng, $objDefinition, $ilCtrl;
53 
54  // initiate variables
55  $this->ilias =& $ilias;
56  $this->tpl =& $tpl;
57  $this->lng =& $lng;
58  $this->ctrl =& $ilCtrl;
59  $this->glossary =& new ilObjGlossary($_GET["ref_id"], true);
60  $this->definition =& new ilGlossaryDefinition($_GET["def"]);
61  $this->term =& new ilGlossaryTerm($this->definition->getTermId());
62 
63  $this->ctrl->saveParameter($this, array("def"));
64  }
65 
66 
67  function &executeCommand()
68  {
69  global $tpl, $ilCtrl, $lng;
70 
71  $next_class = $this->ctrl->getNextClass($this);
72  $cmd = $this->ctrl->getCmd();
73 
74  // content style
75  $this->tpl->setCurrentBlock("ContentStyle");
76  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
78  $this->tpl->parseCurrentBlock();
79 
80  // syntax style
81  $this->tpl->setCurrentBlock("SyntaxStyle");
82  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
84  $this->tpl->parseCurrentBlock();
85 
86  require_once ("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
87  $gloss_loc =& new ilGlossaryLocatorGUI();
88  $gloss_loc->setTerm($this->term);
89  $gloss_loc->setGlossary($this->glossary);
90  $gloss_loc->setDefinition($this->definition);
91 
92  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
93  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
94  $this->tpl->setTitle($this->term->getTerm()." - ".
95  $this->lng->txt("cont_definition")." ".
96  $this->definition->getNr());
97  if ($this->ctrl->getNextClass() == "ilpageobjectgui")
98  {
99  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_def_b.gif"));
100  }
101 
102  switch ($next_class)
103  {
104 
105  case "ilpageobjectgui":
106 
107  // output number of usages
108  if ($ilCtrl->getCmd() == "edit" &&
109  $ilCtrl->getCmdClass() == "ilpageobjectgui")
110  {
111  $nr = ilGlossaryTerm::getNumberOfUsages($_GET["term_id"]);
112  if ($nr > 0)
113  {
114  $link = "[<a href='".
115  $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages").
116  "'>".$lng->txt("glo_list_usages")."</a>]";
117  ilUtil::sendInfo(sprintf($lng->txt("glo_term_is_used_n_times"),
118  $nr)." ".$link);
119  }
120  }
121 
122  // not so nice, to do: revise locator handling
123  if ($this->ctrl->getNextClass() == "ilpageobjectgui"
124  || $this->ctrl->getCmdClass() == "ileditclipboardgui")
125  {
126  $gloss_loc->display();
127  }
128  $this->setTabs();
129  $this->ctrl->setReturnByClass("ilPageObjectGUI", "edit");
130  $this->ctrl->setReturn($this, "listDefinitions");
131  $page_gui =& new ilPageObjectGUI("gdf", $this->definition->getId());
132  $page = $page_gui->getPageObject();
133  $this->definition->assignPageObject($page);
134  $page->addUpdateListener($this, "saveShortText");
135  $page_gui->setEditPreview(true);
136  $page_gui->activateMetaDataEditor($this->glossary->getId(),
137  $this->definition->getId(), "gdf");
138  // $this->obj, "MDUpdateListener");
139 
140  $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
141  $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=fullscreen&amp;ref_id=".$_GET["ref_id"]);
142  $page_gui->setTemplateTargetVar("ADM_CONTENT");
143  $page_gui->setOutputMode("edit");
144  $page_gui->setLocator($gloss_loc);
145  $page_gui->setEnabledInternalLinks(true);
146  $page_gui->setIntLinkHelpDefault("GlossaryItem", $_GET["ref_id"]);
147  $page_gui->setIntLinkReturn($this->ctrl->getLinkTargetByClass("ilobjglossarygui", "quickList",
148  "", false, false));
149  $page_gui->setPageBackTitle($this->lng->txt("cont_definition"));
150  $page_gui->setLinkParams("ref_id=".$_GET["ref_id"]);
151  $page_gui->setHeader($this->term->getTerm());
152  $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=downloadFile&amp;ref_id=".$_GET["ref_id"]);
153  $page_gui->setPresentationTitle($this->term->getTerm());
154  $ret =& $this->ctrl->forwardCommand($page_gui);
155  $tpl->setContent($ret);
156  break;
157 
158  default:
159  $this->setTabs();
160  $gloss_loc->display();
161  $ret =& $this->$cmd();
162  break;
163 
164  }
165  }
166 
167 
171  function main_header($a_header_title)
172  {
173  global $lng;
174 
175  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
176  $this->tpl->setVariable("HEADER", $a_header_title);
177  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
178  $this->displayLocator();
179  //$this->setAdminTabs($a_type);
180  }
181 
185  function setTabs()
186  {
187  global $ilTabs;
188 
189  // catch feedback message
190  $this->getTabs($ilTabs);
191  }
192 
196  function getTabs(&$tabs_gui)
197  {
198  // back to glossary
199  $tabs_gui->setBack2Target($this->lng->txt("glossary"),
200  $this->ctrl->getParentReturn($this));
201 
202  // back to upper context
203  $tabs_gui->setBackTarget($this->lng->txt("term"),
204  $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
205 
206  }
207 
208 
209  function saveShortText()
210  {
211  $this->definition->updateShortText();
212  }
213 }
214 ?>