ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSurveyPhrasesGUI.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 
36 {
37  var $object;
39  var $lng;
40  var $tpl;
41  var $ctrl;
42  var $ilias;
43  var $tree;
44  var $ref_id;
45 
53  function ilSurveyPhrasesGUI($a_object)
54  {
55  global $lng, $tpl, $ilCtrl, $ilias, $tree;
56 
57  include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
58  $this->lng =& $lng;
59  $this->tpl =& $tpl;
60  $this->ctrl =& $ilCtrl;
61  $this->ilias =& $ilias;
62  $this->gui_object =& $a_object;
63  $this->object = new ilSurveyPhrases();
64  $this->tree =& $tree;
65  $this->ref_id = $a_object->ref_id;
66  }
67 
71  function &executeCommand()
72  {
73  $cmd = $this->ctrl->getCmd();
74  $next_class = $this->ctrl->getNextClass($this);
75 
76  $cmd = $this->getCommand($cmd);
77  switch($next_class)
78  {
79  default:
80  $ret =& $this->$cmd();
81  break;
82  }
83  return $ret;
84  }
85 
93  function getCommand($cmd)
94  {
95  return $cmd;
96  }
97 
105  function deletePhrase()
106  {
108 
109  $checked_phrases = array();
110  foreach ($_POST as $key => $value)
111  {
112  if (preg_match("/phrase_(\d+)/", $key, $matches))
113  {
114  array_push($checked_phrases, $matches[1]);
115  }
116  }
117  if (count($checked_phrases))
118  {
119  ilUtil::sendInfo($this->lng->txt("qpl_confirm_delete_phrases"));
120  $this->deletePhrasesForm($checked_phrases);
121  return;
122  }
123  else
124  {
125  ilUtil::sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
126  $this->phrases();
127  return;
128  }
129 
130  $this->tpl->setCurrentBlock("obligatory");
131  $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
132  $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
133  $this->tpl->parseCurrentBlock();
134  $this->tpl->setCurrentBlock("adm_content");
135  $this->tpl->setVariable("DEFINE_QUESTIONBLOCK_HEADING", $this->lng->txt("define_questionblock"));
136  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
137  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
138  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
139  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
140  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
141  $this->tpl->parseCurrentBlock();
142  }
143 
149  function phrases()
150  {
151  global $rbacsystem;
152 
153  if ($rbacsystem->checkAccess("write", $this->ref_id))
154  {
155  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_phrases.html", "Modules/SurveyQuestionPool");
156  $phrases =& $this->object->_getAvailablePhrases(1);
157  if (count($phrases))
158  {
159  include_once "./Services/Utilities/classes/class.ilUtil.php";
160  $colors = array("tblrow1", "tblrow2");
161  $counter = 0;
162  foreach ($phrases as $phrase_id => $phrase_array)
163  {
164  $this->tpl->setCurrentBlock("phraserow");
165  $this->tpl->setVariable("PHRASE_ID", $phrase_id);
166  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
167  $this->tpl->setVariable("PHRASE_TITLE", $phrase_array["title"]);
168  $categories =& $this->object->_getCategoriesForPhrase($phrase_id);
169  $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
170  $this->tpl->parseCurrentBlock();
171  }
172  $counter++;
173  $this->tpl->setCurrentBlock("selectall");
174  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
175  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
176  $this->tpl->parseCurrentBlock();
177  $this->tpl->setCurrentBlock("Footer");
178  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
179  $this->tpl->setVariable("TEXT_DELETE", $this->lng->txt("delete"));
180  $this->tpl->parseCurrentBlock();
181  }
182  else
183  {
184  $this->tpl->setCurrentBlock("Emptytable");
185  $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_user_phrases_defined"));
186  $this->tpl->parseCurrentBlock();
187  }
188  $this->tpl->setCurrentBlock("adm_content");
189  $this->tpl->setVariable("INTRODUCTION_MANAGE_PHRASES", $this->lng->txt("introduction_manage_phrases"));
190  $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
191  $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
192  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
193  $this->tpl->parseCurrentBlock();
194  }
195  else
196  {
197  ilUtil::sendInfo($this->lng->txt("cannot_manage_phrases"));
198  }
199  }
200 
205  {
206  $this->ctrl->redirect($this, "phrases");
207  }
208 
213  {
214  $phrases = array();
215  foreach ($_POST as $key => $value)
216  {
217  if (preg_match("/phrase_(\d+)/", $key, $matches))
218  {
219  array_push($phrases, $matches[1]);
220  }
221  }
222  $this->object->deletePhrases($phrases);
223  ilUtil::sendInfo($this->lng->txt("qpl_phrases_deleted"), true);
224  $this->ctrl->redirect($this, "phrases");
225  }
226 
235  function deletePhrasesForm($checked_phrases)
236  {
238  $phrases =& $this->object->_getAvailablePhrases(1);
239  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_phrases.html", "Modules/SurveyQuestionPool");
240  $colors = array("tblrow1", "tblrow2");
241  $counter = 0;
242  foreach ($checked_phrases as $id)
243  {
244  $this->tpl->setCurrentBlock("row");
245  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
246  $this->tpl->setVariable("PHRASE_TITLE", $phrases[$id]["title"]);
247  $categories =& $this->object->_getCategoriesForPhrase($id);
248  $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
249  $this->tpl->parseCurrentBlock();
250  $this->tpl->setCurrentBlock("hidden");
251  $this->tpl->setVariable("HIDDEN_NAME", "phrase_$id");
252  $this->tpl->setVariable("HIDDEN_VALUE", "1");
253  $this->tpl->parseCurrentBlock();
254  }
255 
256  $this->tpl->setCurrentBlock("adm_content");
257  $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
258  $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
259  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
260  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
261  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
262  $this->tpl->parseCurrentBlock();
263  }
264 }
265 ?>