• 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, $a_prep = true)
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, $a_prep);
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         function viewObject()
00079         {
00080                 $this->editObject();
00081         }
00082 
00083         /*
00084         function setCmdUpdate($a_cmd = "update")
00085         {
00086                 $this->cmd_update = $a_cmd;
00087         }
00088 
00089         function setCmdNewStyleParameter($a_cmd = "newStyleParameter")
00090         {
00091                 $this->cmd_new_par = $a_cmd;
00092         }
00093 
00094         function setCmdRefresh($a_cmd = "refresh")
00095         {
00096                 $this->cmd_refresh = $a_cmd;
00097         }
00098 
00099         function setCmdDeleteStyleParameter($a_cmd = "deleteStyleParameter")
00100         {
00101                 $this->cmd_delete = $a_cmd;
00102         }*/
00103 
00107         function createObject()
00108         {
00109                 global $rbacsystem, $lng, $tpl;
00110 
00111                 $this->setTabs();
00112 
00113                 $this->lng =& $lng;
00114                 //$this->ctrl->setParameter($this,'new_type',$this->type);
00115                 $this->getTemplateFile("create", "sty");
00116                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("create_stylesheet"));
00117                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00118                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00119                 $this->tpl->parseCurrentBlock();
00120                 $this->ctrl->setParameter($this, "new_type", "sty");
00121                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00122                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00123                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00124                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00125                 //$this->tpl->parseCurrentBlock();
00126         }
00127 
00131         function editObject()
00132         {
00133                 global $rbacsystem, $lng;
00134 
00135                 $this->setTabs();
00136 
00137                 // set style sheet
00138                 $this->tpl->setCurrentBlock("ContentStyle");
00139                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00140                         $this->object->getContentStylePath($this->object->getId()));
00141                 $this->tpl->parseCurrentBlock();
00142 
00143                 $this->getTemplateFile("edit", "sty");
00144                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit_stylesheet"));
00145 
00146                 // output style parameters
00147                 $avail_pars = $this->object->getAvailableParameters();
00148                 $style = $this->object->getStyle();
00149                 foreach($style as $tag)
00150                 {
00151                         foreach($tag as $par)
00152                         {
00153                                 $this->tpl->setCurrentBlock("StyleParameter");
00154                                 $this->tpl->setVariable("PAR_ID", $par["id"]);
00155                                 $this->tpl->setVariable("TXT_PAR", $par["parameter"]);
00156                                 if (count($avail_pars[$par["parameter"]]) == 0)
00157                                 {
00158                                         $input = "<input type=\"text\" size=\"30\" maxlength=\"100\" ".
00159                                                 "name=\"styval[".$par["id"]."]\" value=\"".$par["value"]."\"";
00160                                 }
00161                                 else
00162                                 {
00163                                         $sel_avail_vals = array();
00164                                         foreach($avail_pars[$par["parameter"]] as $key => $val)
00165                                         {
00166                                                 $sel_avail_vals[$val] = $val;
00167                                         }
00168                                         $input = ilUtil::formSelect($par["value"], "styval[".$par["id"]."]", $sel_avail_vals, false, true);
00169                                 }
00170                                 $this->tpl->setVariable("INPUT_VAL", $input);
00171                                 $this->tpl->parseCurrentBlock();
00172                         }
00173                         if ((!is_int(strpos($tag[0]["class"], ":hover"))) &&
00174                                 (!is_int(strpos($tag[0]["class"], ":visited"))) &&
00175                                 (!is_int(strpos($tag[0]["class"], ":active")))
00176                                 )
00177                         {
00178                                 $this->tpl->setCurrentBlock("Example_".$tag[0]["tag"]);
00179                                 $this->tpl->setVariable("EX_CLASS", "ilc_".$tag[0]["class"]);
00180                                 $this->tpl->setVariable("EX_TEXT", "ABC abc 123");
00181                                 $this->tpl->parseCurrentBlock();
00182                         }
00183 
00184                         $this->tpl->setCurrentBlock("StyleTag");
00185                         $this->tpl->setVariable("TXT_TAG", $tag[0]["tag"].".".$tag[0]["class"]);
00186                         $this->tpl->setVariable("STY_ROWSPAN", (count($tag) + 1));
00187                         $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("parameter"));
00188                         $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00189                         $this->tpl->parseCurrentBlock();
00190                 }
00191 
00192                 // title and description
00193                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00194                 $this->tpl->setVariable(strtoupper("TITLE"), $this->object->getTitle());
00195                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00196                 $this->tpl->setVariable(strtoupper("DESCRIPTION"), $this->object->getDescription());
00197                 $this->tpl->parseCurrentBlock();
00198 
00199                 // new parameter
00200                 $temptags = $this->object->getAvailableTags();
00201                 $tags = array();
00202                 foreach($temptags as $key => $val)
00203                 {
00204                         $tags[$val] = $val;
00205                 }
00206                 $tag_select = ilUtil::formSelect("", "tag", $tags, false, true);
00207                 foreach($avail_pars as $key => $val)
00208                 {
00209                         $sel_avail_pars[$key] = $key;
00210                 }
00211                 $this->tpl->setVariable("SELECT_TAG", $tag_select);
00212                 $par_select = ilUtil::formSelect("", "parameter", $sel_avail_pars, false, true);
00213                 $this->tpl->setVariable("SELECT_PAR", $par_select);
00214                 $this->tpl->setVariable("TXT_NEW_PAR", $this->lng->txt("add"));
00215 
00216                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00217                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save_return"));
00218                 $this->tpl->setVariable("BTN_SAVE", "update");
00219                 $this->tpl->setVariable("TXT_REFRESH", $this->lng->txt("save_refresh"));
00220                 $this->tpl->setVariable("BTN_REFRESH", "refresh");
00221                 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete_selected"));
00222                 $this->tpl->setVariable("BTN_DELETE", "deleteStyleParameter");
00223                 $this->tpl->setVariable("BTN_NEW_PAR", "newStyleParameter");
00224                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00225         }
00226 
00230         function newStyleParameterObject()
00231         {
00232                 $this->object->addParameter($_POST["tag"], $_POST["parameter"]);
00233                 $this->editObject();
00234         }
00235 
00239         function refreshObject()
00240         {
00241                 //$class_name = "ilObjStyleSheet";
00242                 //require_once("classes/class.ilObjStyleSheet.php");
00243                 $this->object->setTitle($_POST["style_title"]);
00244                 $this->object->setDescription($_POST["style_description"]);
00245 
00246                 foreach($_POST["styval"] as $id => $value)
00247                 {
00248                         $this->object->updateStyleParameter($id, $value);
00249                 }
00250                 $this->object->update();
00251                 $this->editObject();
00252         }
00253         
00259         function deleteObject($a_error = false)
00260         {
00261                 $this->setTabs();
00262 
00263                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
00264 
00265                 if(!$a_error)
00266                 {
00267                         sendInfo($this->lng->txt("info_delete_sure"));
00268                 }
00269 
00270                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00271 
00272                 // BEGIN TABLE HEADER
00273                 $this->tpl->setCurrentBlock("table_header");
00274                 $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
00275                 $this->tpl->parseCurrentBlock();
00276                 
00277                 // END TABLE HEADER
00278 
00279                 // BEGIN TABLE DATA
00280                 $counter = 0;
00281 
00282                 $this->tpl->setCurrentBlock("table_row");
00283                 $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_styf.gif"));
00284                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00285                 $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($this->object->getId()));
00286                 $this->tpl->parseCurrentBlock();
00287                 
00288                 // END TABLE DATA
00289 
00290                 // BEGIN OPERATION_BTN
00291                 $buttons = array("confirmedDelete"  => $this->lng->txt("confirm"),
00292                         "cancelDelete"  => $this->lng->txt("cancel"));
00293                 foreach ($buttons as $name => $value)
00294                 {
00295                         $this->tpl->setCurrentBlock("operation_btn");
00296                         $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00297                         $this->tpl->setVariable("BTN_NAME",$name);
00298                         $this->tpl->setVariable("BTN_VALUE",$value);
00299                         $this->tpl->parseCurrentBlock();
00300                 }
00301         }
00302         
00303         
00307         function cancelDeleteObject()
00308         {
00309                 $this->ctrl->returnToParent($this);
00310         }
00311 
00315         function confirmedDeleteObject()
00316         {
00317                 global $ilias;
00318                 
00319                 $this->object->delete();
00320                 
00321                 $this->ctrl->returnToParent($this);
00322         }
00323 
00327         function deleteStyleParameterObject()
00328         {
00329                 if (is_array($_POST["sty_select"]))
00330                 {
00331                         foreach($_POST["sty_select"] as $id => $dummy)
00332                         {
00333                                 $this->object->deleteParameter($id);
00334                         }
00335                 }
00336                 $this->object->read();
00337                 $this->object->writeCSSFile();
00338                 $this->editObject();
00339         }
00340 
00344         function saveObject()
00345         {
00346 //echo "HH"; exit;
00347                 $class_name = "ilObjStyleSheet";
00348                 require_once("classes/class.ilObjStyleSheet.php");
00349                 $newObj = new ilObjStyleSheet();
00350                 $newObj->setTitle($_POST["style_title"]);
00351                 $newObj->setDescription($_POST["style_description"]);
00352                 $newObj->create();
00353 
00354                 // assign style to style sheet folder,
00355                 // if parent is style sheet folder
00356                 if ($_GET["ref_id"] > 0)
00357                 {
00358 
00359                         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00360                         if ($fold->getType() == "stys")
00361                         {
00362                                 $fold->addStyle($newObj->getId());
00363                                 $fold->update();
00364                                 
00365                                 // to do: introduce ilCtrl in administration properly
00366                                 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]);
00367                         }
00368                 }
00369 
00370                 return $newObj->getId();
00371         }
00372 
00376         function updateObject()
00377         {
00378                 //$class_name = "ilObjStyleSheet";
00379                 //require_once("classes/class.ilObjStyleSheet.php");
00380                 $this->object->setTitle($_POST["style_title"]);
00381                 $this->object->setDescription($_POST["style_description"]);
00382 
00383                 foreach($_POST["styval"] as $id => $value)
00384                 {
00385                         $this->object->updateStyleParameter($id, $value);
00386                 }
00387                 $this->object->update();
00388                 
00389                 // to do: introduce ilCtrl in administration properly
00390                 if ($_GET["ref_id"] > 0)
00391                 {
00392 
00393                         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00394                         if ($fold->getType() == "stys")
00395                         {                               
00396                                 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]);
00397                         }
00398                 }
00399 
00400                 $this->ctrl->returnToParent($this);
00401         }
00402 
00406         function cancelObject()
00407         {
00408                 global $lng;
00409                 
00410                 // to do: introduce ilCtrl in administration properly
00411                 if ($_GET["ref_id"] > 0)
00412                 {
00413 
00414                         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00415                         if ($fold->getType() == "stys")
00416                         {                               
00417                                 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]);
00418                         }
00419                 }
00420 
00421                 sendInfo($lng->txt("msg_cancel"), true);
00422                 $this->ctrl->returnToParent($this);
00423         }
00424 
00428         function setTabs()
00429         {
00430                 global $lng;
00431 
00432                 // catch feedback message
00433                 include_once("classes/class.ilTabsGUI.php");
00434                 $tabs_gui =& new ilTabsGUI();
00435                 $this->getTabs($tabs_gui);
00436                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00437 
00438                 if (strtolower(get_class($this->object)) == "ilobjstylesheet")
00439                 {
00440                         $this->tpl->setVariable("HEADER", $this->object->getTitle());
00441                 }
00442                 else
00443                 {
00444                         $this->tpl->setVariable("HEADER", $lng->txt("create_stylesheet"));
00445                 }
00446         }
00447 
00453         function getTabs(&$tabs_gui)
00454         {
00455                 // to do: introduce ilCtrl in administration properly
00456                 if ($_GET["ref_id"] > 0)
00457                 {
00458 
00459                         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00460                         if ($fold->getType() == "stys")
00461                         {                               
00462                                 // back to upper context
00463                                 $tabs_gui->addTarget("back",
00464                                         "adm_object.php?ref_id=".$_GET["ref_id"], "",
00465                                         "");
00466                                 return;
00467                         }
00468                 }
00469                 
00470                 // back to upper context
00471                 $tabs_gui->addTarget("cont_back",
00472                         $this->ctrl->getParentReturn($this), "",
00473                         "");
00474         }
00475 
00476 
00477 } // END class.ObjStyleSheetGUI
00478 ?>

Generated on Fri Dec 13 2013 09:06:34 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1