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

classes/class.ilObjStyleSheetGUI.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 
00024 
00035 require_once "class.ilObjectGUI.php";
00036 
00037 class ilObjStyleSheetGUI extends ilObjectGUI
00038 {
00039         var $cmd_update;
00040         var $cmd_new_par;
00041         var $cmd_refresh;
00042         var $cmd_delete;
00043 
00048         function ilObjStyleSheetGUI($a_data,$a_id,$a_call_by_reference)
00049         {
00050                 global $ilCtrl, $lng, $tpl;
00051 
00052                 $this->ctrl =& $ilCtrl;
00053                 $this->lng =& $lng;
00054 
00055                 $this->type = "sty";
00056                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00057         }
00058 
00062         function &executeCommand()
00063         {
00064                 $next_class = $this->ctrl->getNextClass($this);
00065                 $cmd = $this->ctrl->getCmd();
00066 
00067                 switch($next_class)
00068                 {
00069                         default:
00070                                 $cmd.= "Object";
00071                                 $ret =& $this->$cmd();
00072                                 break;
00073                 }
00074 
00075                 return $ret;
00076         }
00077 
00078         /*
00079         function setCmdUpdate($a_cmd = "update")
00080         {
00081                 $this->cmd_update = $a_cmd;
00082         }
00083 
00084         function setCmdNewStyleParameter($a_cmd = "newStyleParameter")
00085         {
00086                 $this->cmd_new_par = $a_cmd;
00087         }
00088 
00089         function setCmdRefresh($a_cmd = "refresh")
00090         {
00091                 $this->cmd_refresh = $a_cmd;
00092         }
00093 
00094         function setCmdDeleteStyleParameter($a_cmd = "deleteStyleParameter")
00095         {
00096                 $this->cmd_delete = $a_cmd;
00097         }*/
00098 
00102         function createObject()
00103         {
00104                 global $rbacsystem, $lng, $tpl;
00105 
00106                 $this->setTabs();
00107 
00108                 $this->lng =& $lng;
00109 
00110                 $this->getTemplateFile("create", "sty");
00111                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("create_stylesheet"));
00112                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00113                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00114                 $this->tpl->parseCurrentBlock();
00115                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00116                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00117                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00118                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00119 
00120         }
00121 
00125         function editObject()
00126         {
00127                 global $rbacsystem, $lng;
00128 
00129                 $this->setTabs();
00130 
00131                 // set style sheet
00132                 $this->tpl->setCurrentBlock("ContentStyle");
00133                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00134                         $this->object->getContentStylePath($this->object->getId()));
00135                 $this->tpl->parseCurrentBlock();
00136 
00137                 $this->getTemplateFile("edit", "sty");
00138                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit_stylesheet"));
00139 
00140                 // output style parameters
00141                 $avail_pars = $this->object->getAvailableParameters();
00142                 $style = $this->object->getStyle();
00143                 foreach($style as $tag)
00144                 {
00145                         foreach($tag as $par)
00146                         {
00147                                 $this->tpl->setCurrentBlock("StyleParameter");
00148                                 $this->tpl->setVariable("PAR_ID", $par["id"]);
00149                                 $this->tpl->setVariable("TXT_PAR", $par["parameter"]);
00150                                 if (count($avail_pars[$par["parameter"]]) == 0)
00151                                 {
00152                                         $input = "<input type=\"text\" size=\"30\" maxlength=\"100\" ".
00153                                                 "name=\"styval[".$par["id"]."]\" value=\"".$par["value"]."\"";
00154                                 }
00155                                 else
00156                                 {
00157                                         $sel_avail_vals = array();
00158                                         foreach($avail_pars[$par["parameter"]] as $key => $val)
00159                                         {
00160                                                 $sel_avail_vals[$val] = $val;
00161                                         }
00162                                         $input = ilUtil::formSelect($par["value"], "styval[".$par["id"]."]", $sel_avail_vals, false, true);
00163                                 }
00164                                 $this->tpl->setVariable("INPUT_VAL", $input);
00165                                 $this->tpl->parseCurrentBlock();
00166                         }
00167                         if ((!is_int(strpos($tag[0]["class"], ":hover"))) &&
00168                                 (!is_int(strpos($tag[0]["class"], ":visited"))) &&
00169                                 (!is_int(strpos($tag[0]["class"], ":active")))
00170                                 )
00171                         {
00172                                 $this->tpl->setCurrentBlock("Example_".$tag[0]["tag"]);
00173                                 $this->tpl->setVariable("EX_CLASS", "ilc_".$tag[0]["class"]);
00174                                 $this->tpl->setVariable("EX_TEXT", "ABC abc 123");
00175                                 $this->tpl->parseCurrentBlock();
00176                         }
00177 
00178                         $this->tpl->setCurrentBlock("StyleTag");
00179                         $this->tpl->setVariable("TXT_TAG", $tag[0]["tag"].".".$tag[0]["class"]);
00180                         $this->tpl->setVariable("STY_ROWSPAN", (count($tag) + 1));
00181                         $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("parameter"));
00182                         $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00183                         $this->tpl->parseCurrentBlock();
00184                 }
00185 
00186                 // title and description
00187                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00188                 $this->tpl->setVariable(strtoupper("TITLE"), $this->object->getTitle());
00189                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00190                 $this->tpl->setVariable(strtoupper("DESCRIPTION"), $this->object->getDescription());
00191                 $this->tpl->parseCurrentBlock();
00192 
00193                 // new parameter
00194                 $temptags = $this->object->getAvailableTags();
00195                 $tags = array();
00196                 foreach($temptags as $key => $val)
00197                 {
00198                         $tags[$val] = $val;
00199                 }
00200                 $tag_select = ilUtil::formSelect("", "tag", $tags, false, true);
00201                 foreach($avail_pars as $key => $val)
00202                 {
00203                         $sel_avail_pars[$key] = $key;
00204                 }
00205                 $this->tpl->setVariable("SELECT_TAG", $tag_select);
00206                 $par_select = ilUtil::formSelect("", "parameter", $sel_avail_pars, false, true);
00207                 $this->tpl->setVariable("SELECT_PAR", $par_select);
00208                 $this->tpl->setVariable("TXT_NEW_PAR", $this->lng->txt("add"));
00209 
00210                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00211                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save_return"));
00212                 $this->tpl->setVariable("BTN_SAVE", "update");
00213                 $this->tpl->setVariable("TXT_REFRESH", $this->lng->txt("save_refresh"));
00214                 $this->tpl->setVariable("BTN_REFRESH", "refresh");
00215                 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete_selected"));
00216                 $this->tpl->setVariable("BTN_DELETE", "deleteStyleParameter");
00217                 $this->tpl->setVariable("BTN_NEW_PAR", "newStyleParameter");
00218                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00219         }
00220 
00224         function newStyleParameterObject()
00225         {
00226                 $this->object->addParameter($_POST["tag"], $_POST["parameter"]);
00227                 $this->editObject();
00228         }
00229 
00233         function refreshObject()
00234         {
00235                 //$class_name = "ilObjStyleSheet";
00236                 //require_once("classes/class.ilObjStyleSheet.php");
00237                 $this->object->setTitle($_POST["style_title"]);
00238                 $this->object->setDescription($_POST["style_description"]);
00239 
00240                 foreach($_POST["styval"] as $id => $value)
00241                 {
00242                         $this->object->updateStyleParameter($id, $value);
00243                 }
00244                 $this->object->update();
00245                 $this->editObject();
00246         }
00247 
00251         function deleteStyleParameterObject()
00252         {
00253                 if (is_array($_POST["sty_select"]))
00254                 {
00255                         foreach($_POST["sty_select"] as $id => $dummy)
00256                         {
00257                                 $this->object->deleteParameter($id);
00258                         }
00259                 }
00260                 $this->object->read();
00261                 $this->object->writeCSSFile();
00262                 $this->editObject();
00263         }
00264 
00268         function saveObject()
00269         {
00270 //echo "HH"; exit;
00271                 $class_name = "ilObjStyleSheet";
00272                 require_once("classes/class.ilObjStyleSheet.php");
00273                 $newObj = new ilObjStyleSheet();
00274                 $newObj->setTitle($_POST["style_title"]);
00275                 $newObj->setDescription($_POST["style_description"]);
00276                 $newObj->create();
00277 
00278                 return $newObj->getId();
00279         }
00280 
00284         function updateObject()
00285         {
00286                 //$class_name = "ilObjStyleSheet";
00287                 //require_once("classes/class.ilObjStyleSheet.php");
00288                 $this->object->setTitle($_POST["style_title"]);
00289                 $this->object->setDescription($_POST["style_description"]);
00290 
00291                 foreach($_POST["styval"] as $id => $value)
00292                 {
00293                         $this->object->updateStyleParameter($id, $value);
00294                 }
00295                 $this->object->update();
00296 
00297                 $this->ctrl->returnToParent($this);
00298         }
00299 
00303         function cancelObject()
00304         {
00305                 global $lng;
00306 
00307                 sendInfo($lng->txt("msg_cancel"), true);
00308                 $this->ctrl->returnToParent($this);
00309         }
00310 
00314         function setTabs()
00315         {
00316                 global $lng;
00317 
00318                 // catch feedback message
00319                 include_once("classes/class.ilTabsGUI.php");
00320                 $tabs_gui =& new ilTabsGUI();
00321                 $this->getTabs($tabs_gui);
00322                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00323                 if (get_class($this->object) == "ilobjstylesheet")
00324                 {
00325                         $this->tpl->setVariable("HEADER", $this->object->getTitle());
00326                 }
00327                 else
00328                 {
00329                         $this->tpl->setVariable("HEADER", $lng->txt("create_stylesheet"));
00330                 }
00331         }
00332 
00338         function getTabs(&$tabs_gui)
00339         {
00340                 // back to upper context
00341                 $tabs_gui->addTarget("cont_back",
00342                         $this->ctrl->getParentReturn($this), "",
00343                         "");
00344         }
00345 
00346 
00347 } // END class.ObjStyleSheetGUI
00348 ?>

Generated on Fri Dec 13 2013 08:00:15 for ILIAS Release_3_3_x_branch .rev 46803 by  doxygen 1.7.1