• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/SurveyQuestionPool/classes/class.ilSurveyPhrasesGUI.php

Go to the documentation of this file.
00001 <?php
00002  /*
00003    +----------------------------------------------------------------------------+
00004    | ILIAS open source                                                          |
00005    +----------------------------------------------------------------------------+
00006    | Copyright (c) 1998-2001 ILIAS open source, University of Cologne           |
00007    |                                                                            |
00008    | This program is free software; you can redistribute it and/or              |
00009    | modify it under the terms of the GNU General Public License                |
00010    | as published by the Free Software Foundation; either version 2             |
00011    | of the License, or (at your option) any later version.                     |
00012    |                                                                            |
00013    | This program is distributed in the hope that it will be useful,            |
00014    | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
00015    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              |
00016    | GNU General Public License for more details.                               |
00017    |                                                                            |
00018    | You should have received a copy of the GNU General Public License          |
00019    | along with this program; if not, write to the Free Software                |
00020    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
00021    +----------------------------------------------------------------------------+
00022 */
00023 
00035 class ilSurveyPhrasesGUI
00036 {
00037         var $object;
00038         var $gui_object;
00039         var $lng;
00040         var $tpl;
00041         var $ctrl;
00042         var $ilias;
00043         var $tree;
00044         var $ref_id;
00045         
00053   function ilSurveyPhrasesGUI($a_object)
00054   {
00055                 global $lng, $tpl, $ilCtrl, $ilias, $tree;
00056 
00057                 include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
00058     $this->lng =& $lng;
00059     $this->tpl =& $tpl;
00060                 $this->ctrl =& $ilCtrl;
00061                 $this->ilias =& $ilias;
00062                 $this->gui_object =& $a_object;
00063                 $this->object = new ilSurveyPhrases();
00064                 $this->tree =& $tree;
00065                 $this->ref_id = $a_object->ref_id;
00066         }
00067         
00071         function &executeCommand()
00072         {
00073                 $cmd = $this->ctrl->getCmd();
00074                 $next_class = $this->ctrl->getNextClass($this);
00075 
00076                 $cmd = $this->getCommand($cmd);
00077                 switch($next_class)
00078                 {
00079                         default:
00080                                 $ret =& $this->$cmd();
00081                                 break;
00082                 }
00083                 return $ret;
00084         }
00085 
00093         function getCommand($cmd)
00094         {
00095                 return $cmd;
00096         }
00097         
00105         function deletePhrase()
00106         {
00107                 ilUtil::sendInfo();
00108 
00109                 $checked_phrases = array();
00110                 foreach ($_POST as $key => $value)
00111                 {
00112                         if (preg_match("/phrase_(\d+)/", $key, $matches))
00113                         {
00114                                 array_push($checked_phrases, $matches[1]);
00115                         }
00116                 }
00117                 if (count($checked_phrases))
00118                 {
00119                         ilUtil::sendInfo($this->lng->txt("qpl_confirm_delete_phrases"));
00120                         $this->deletePhrasesForm($checked_phrases);
00121                         return;
00122                 }
00123                 else
00124                 {
00125                         ilUtil::sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
00126                         $this->phrases();
00127                         return;
00128                 }
00129                 
00130                 $this->tpl->setCurrentBlock("obligatory");
00131                 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00132                 $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00133                 $this->tpl->parseCurrentBlock();
00134                 $this->tpl->setCurrentBlock("adm_content");
00135                 $this->tpl->setVariable("DEFINE_QUESTIONBLOCK_HEADING", $this->lng->txt("define_questionblock"));
00136                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00137                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00138                 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00139                 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00140                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00141                 $this->tpl->parseCurrentBlock();
00142         }
00143 
00149   function phrases()
00150         {
00151                 global $rbacsystem;
00152                 
00153                 if ($rbacsystem->checkAccess("write", $this->ref_id))
00154                 {
00155                         $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_phrases.html", "Modules/SurveyQuestionPool");
00156                         $phrases =& $this->object->_getAvailablePhrases(1);
00157                         if (count($phrases))
00158                         {
00159                                 include_once "./Services/Utilities/classes/class.ilUtil.php";
00160                                 $colors = array("tblrow1", "tblrow2");
00161                                 $counter = 0;
00162                                 foreach ($phrases as $phrase_id => $phrase_array)
00163                                 {
00164                                         $this->tpl->setCurrentBlock("phraserow");
00165                                         $this->tpl->setVariable("PHRASE_ID", $phrase_id);
00166                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00167                                         $this->tpl->setVariable("PHRASE_TITLE", $phrase_array["title"]);
00168                                         $categories =& $this->object->_getCategoriesForPhrase($phrase_id);
00169                                         $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
00170                                         $this->tpl->parseCurrentBlock();
00171                                 }
00172                                 $counter++;
00173                                 $this->tpl->setCurrentBlock("selectall");
00174                                 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00175                                 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00176                                 $this->tpl->parseCurrentBlock();
00177                                 $this->tpl->setCurrentBlock("Footer");
00178                                 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00179                                 $this->tpl->setVariable("TEXT_DELETE", $this->lng->txt("delete"));
00180                                 $this->tpl->parseCurrentBlock();
00181                         }
00182                         else
00183                         {
00184                                 $this->tpl->setCurrentBlock("Emptytable");
00185                                 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_user_phrases_defined"));
00186                                 $this->tpl->parseCurrentBlock();
00187                         }
00188                         $this->tpl->setCurrentBlock("adm_content");
00189                         $this->tpl->setVariable("INTRODUCTION_MANAGE_PHRASES", $this->lng->txt("introduction_manage_phrases"));
00190                         $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
00191                         $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
00192                         $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00193                         $this->tpl->parseCurrentBlock();
00194                 }
00195                 else
00196                 {
00197                         ilUtil::sendInfo($this->lng->txt("cannot_manage_phrases"));
00198                 }
00199         }
00200 
00204         function cancelDeletePhrase()
00205         {
00206                 $this->ctrl->redirect($this, "phrases");
00207         }
00208         
00212         function confirmDeletePhrase()
00213         {
00214                 $phrases = array();
00215                 foreach ($_POST as $key => $value)
00216                 {
00217                         if (preg_match("/phrase_(\d+)/", $key, $matches))
00218                         {
00219                                 array_push($phrases, $matches[1]);
00220                         }
00221                 }
00222                 $this->object->deletePhrases($phrases);
00223                 ilUtil::sendInfo($this->lng->txt("qpl_phrases_deleted"), true);
00224                 $this->ctrl->redirect($this, "phrases");
00225         }
00226         
00235         function deletePhrasesForm($checked_phrases)
00236         {
00237                 ilUtil::sendInfo();
00238                 $phrases =& $this->object->_getAvailablePhrases(1);
00239                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_phrases.html", "Modules/SurveyQuestionPool");
00240                 $colors = array("tblrow1", "tblrow2");
00241                 $counter = 0;
00242                 foreach ($checked_phrases as $id)
00243                 {
00244                         $this->tpl->setCurrentBlock("row");
00245                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00246                         $this->tpl->setVariable("PHRASE_TITLE", $phrases[$id]["title"]);
00247                         $categories =& $this->object->_getCategoriesForPhrase($id);
00248                         $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
00249                         $this->tpl->parseCurrentBlock();
00250                         $this->tpl->setCurrentBlock("hidden");
00251                         $this->tpl->setVariable("HIDDEN_NAME", "phrase_$id");
00252                         $this->tpl->setVariable("HIDDEN_VALUE", "1");
00253                         $this->tpl->parseCurrentBlock();
00254                 }
00255 
00256                 $this->tpl->setCurrentBlock("adm_content");
00257                 $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
00258                 $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
00259                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00260                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00261                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00262                 $this->tpl->parseCurrentBlock();
00263         }
00264 }
00265 ?>

Generated on Fri Dec 13 2013 17:56:52 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1