• 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-2005 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 
00037 require_once "class.ilObjectGUI.php";
00038 
00039 class ilObjStyleSheetGUI extends ilObjectGUI
00040 {
00041         var $cmd_update;
00042         var $cmd_new_par;
00043         var $cmd_refresh;
00044         var $cmd_delete;
00045 
00050         function ilObjStyleSheetGUI($a_data,$a_id,$a_call_by_reference, $a_prep = true)
00051         {
00052                 global $ilCtrl, $lng, $tpl;
00053 
00054                 $this->ctrl =& $ilCtrl;
00055                 $this->lng =& $lng;
00056 
00057                 $this->type = "sty";
00058                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00059         }
00060 
00064         function &executeCommand()
00065         {
00066                 $next_class = $this->ctrl->getNextClass($this);
00067                 $cmd = $this->ctrl->getCmd("edit");
00068 
00069                 $this->prepareOutput();
00070                 switch($next_class)
00071                 {
00072                         default:
00073                                 $cmd.= "Object";
00074                                 $ret =& $this->$cmd();
00075                                 break;
00076                 }
00077 
00078                 return $ret;
00079         }
00080         
00081         function viewObject()
00082         {
00083                 $this->editObject();
00084         }
00085 
00089         function createObject()
00090         {
00091                 global $rbacsystem, $lng, $tpl;
00092 
00093                 //$this->setTabs();
00094 
00095                 $this->lng =& $lng;
00096                 //$this->ctrl->setParameter($this,'new_type',$this->type);
00097                 $this->getTemplateFile("create", "sty");
00098                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("create_stylesheet"));
00099                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00100                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00101                 $this->tpl->parseCurrentBlock();
00102                 $this->ctrl->setParameter($this, "new_type", "sty");
00103                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00104                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00105                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00106                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00107                 //$this->tpl->parseCurrentBlock();
00108         }
00109 
00113         function editObject()
00114         {
00115                 global $rbacsystem, $lng;
00116 
00117                 //$this->setTabs();
00118 
00119                 // set style sheet
00120                 $this->tpl->setCurrentBlock("ContentStyle");
00121                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00122                         $this->object->getContentStylePath($this->object->getId()));
00123                 $this->tpl->parseCurrentBlock();
00124 
00125                 $this->getTemplateFile("edit", "sty");
00126                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit_stylesheet"));
00127 
00128                 // output style parameters
00129                 $avail_pars = $this->object->getAvailableParameters();
00130                 $style = $this->object->getStyle();
00131                 foreach($style as $tag)
00132                 {
00133                         foreach($tag as $par)
00134                         {
00135                                 $this->tpl->setCurrentBlock("StyleParameter");
00136                                 $this->tpl->setVariable("PAR_ID", $par["id"]);
00137                                 $this->tpl->setVariable("TXT_PAR", $par["parameter"]);
00138                                 if (count($avail_pars[$par["parameter"]]) == 0)
00139                                 {
00140                                         $input = "<input type=\"text\" size=\"30\" maxlength=\"100\" ".
00141                                                 "name=\"styval[".$par["id"]."]\" value=\"".$par["value"]."\"";
00142                                 }
00143                                 else
00144                                 {
00145                                         $sel_avail_vals = array();
00146                                         foreach($avail_pars[$par["parameter"]] as $key => $val)
00147                                         {
00148                                                 $sel_avail_vals[$val] = $val;
00149                                         }
00150                                         $input = ilUtil::formSelect($par["value"], "styval[".$par["id"]."]", $sel_avail_vals, false, true);
00151                                 }
00152                                 $this->tpl->setVariable("INPUT_VAL", $input);
00153                                 $this->tpl->parseCurrentBlock();
00154                         }
00155                         if ((!is_int(strpos($tag[0]["class"], ":hover"))) &&
00156                                 (!is_int(strpos($tag[0]["class"], ":visited"))) &&
00157                                 (!is_int(strpos($tag[0]["class"], ":active")))
00158                                 )
00159                         {
00160                                 $this->tpl->setCurrentBlock("Example_".$tag[0]["tag"]);
00161                                 $this->tpl->setVariable("EX_CLASS", "ilc_".$tag[0]["class"]);
00162                                 $this->tpl->setVariable("EX_TEXT", "ABC abc 123");
00163                                 $this->tpl->parseCurrentBlock();
00164                         }
00165 
00166                         $this->tpl->setCurrentBlock("StyleTag");
00167                         $this->tpl->setVariable("TXT_TAG", $tag[0]["tag"].".".$tag[0]["class"]);
00168                         $this->tpl->setVariable("STY_ROWSPAN", (count($tag) + 1));
00169                         $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("parameter"));
00170                         $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00171                         $this->tpl->parseCurrentBlock();
00172                 }
00173 
00174                 // title and description
00175                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00176                 $this->tpl->setVariable(strtoupper("TITLE"), $this->object->getTitle());
00177                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00178                 $this->tpl->setVariable(strtoupper("DESCRIPTION"), $this->object->getDescription());
00179                 $this->tpl->parseCurrentBlock();
00180 
00181                 // new parameter
00182                 $temptags = $this->object->getAvailableTags();
00183                 $tags = array();
00184                 foreach($temptags as $key => $val)
00185                 {
00186                         $tags[$val] = $val;
00187                 }
00188                 $tag_select = ilUtil::formSelect("", "tag", $tags, false, true);
00189                 foreach($avail_pars as $key => $val)
00190                 {
00191                         $sel_avail_pars[$key] = $key;
00192                 }
00193                 $this->tpl->setVariable("SELECT_TAG", $tag_select);
00194                 $par_select = ilUtil::formSelect("", "parameter", $sel_avail_pars, false, true);
00195                 $this->tpl->setVariable("SELECT_PAR", $par_select);
00196                 $this->tpl->setVariable("TXT_NEW_PAR", $this->lng->txt("add"));
00197 
00198                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00199                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save_return"));
00200                 $this->tpl->setVariable("BTN_SAVE", "update");
00201                 $this->tpl->setVariable("TXT_REFRESH", $this->lng->txt("save_refresh"));
00202                 $this->tpl->setVariable("BTN_REFRESH", "refresh");
00203                 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete_selected"));
00204                 $this->tpl->setVariable("BTN_DELETE", "deleteStyleParameter");
00205                 $this->tpl->setVariable("BTN_NEW_PAR", "newStyleParameter");
00206                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00207         }
00208 
00212         function newStyleParameterObject()
00213         {
00214                 $this->object->addParameter($_POST["tag"], $_POST["parameter"]);
00215                 $this->editObject();
00216         }
00217 
00221         function refreshObject()
00222         {
00223                 //$class_name = "ilObjStyleSheet";
00224                 //require_once("classes/class.ilObjStyleSheet.php");
00225                 $this->object->setTitle($_POST["style_title"]);
00226                 $this->object->setDescription($_POST["style_description"]);
00227 
00228                 foreach($_POST["styval"] as $id => $value)
00229                 {
00230                         $this->object->updateStyleParameter($id, $value);
00231                 }
00232                 $this->object->update();
00233                 $this->editObject();
00234         }
00235         
00241         function deleteObject($a_error = false)
00242         {
00243                 //$this->setTabs();
00244 
00245                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
00246 
00247                 if(!$a_error)
00248                 {
00249                         sendInfo($this->lng->txt("info_delete_sure"));
00250                 }
00251 
00252                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00253 
00254                 // BEGIN TABLE HEADER
00255                 $this->tpl->setCurrentBlock("table_header");
00256                 $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
00257                 $this->tpl->parseCurrentBlock();
00258                 
00259                 // END TABLE HEADER
00260 
00261                 // BEGIN TABLE DATA
00262                 $counter = 0;
00263 
00264                 $this->tpl->setCurrentBlock("table_row");
00265                 $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_styf.gif"));
00266                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00267                 $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($this->object->getId()));
00268                 $this->tpl->parseCurrentBlock();
00269                 
00270                 // END TABLE DATA
00271 
00272                 // BEGIN OPERATION_BTN
00273                 $buttons = array("confirmedDelete"  => $this->lng->txt("confirm"),
00274                         "cancelDelete"  => $this->lng->txt("cancel"));
00275                 foreach ($buttons as $name => $value)
00276                 {
00277                         $this->tpl->setCurrentBlock("operation_btn");
00278                         $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00279                         $this->tpl->setVariable("BTN_NAME",$name);
00280                         $this->tpl->setVariable("BTN_VALUE",$value);
00281                         $this->tpl->parseCurrentBlock();
00282                 }
00283         }
00284         
00285         
00289         function cancelDeleteObject()
00290         {
00291                 $this->ctrl->returnToParent($this);
00292         }
00293 
00297         function confirmedDeleteObject()
00298         {
00299                 global $ilias;
00300                 
00301                 $this->object->delete();
00302                 
00303                 $this->ctrl->returnToParent($this);
00304         }
00305 
00309         function deleteStyleParameterObject()
00310         {
00311                 if (is_array($_POST["sty_select"]))
00312                 {
00313                         foreach($_POST["sty_select"] as $id => $dummy)
00314                         {
00315                                 $this->object->deleteParameter($id);
00316                         }
00317                 }
00318                 $this->object->read();
00319                 $this->object->writeCSSFile();
00320                 $this->editObject();
00321         }
00322 
00326         function saveObject()
00327         {
00328 //echo "HH"; exit;
00329                 $class_name = "ilObjStyleSheet";
00330                 require_once("classes/class.ilObjStyleSheet.php");
00331                 $newObj = new ilObjStyleSheet();
00332                 $newObj->setTitle($_POST["style_title"]);
00333                 $newObj->setDescription($_POST["style_description"]);
00334                 $newObj->create();
00335 
00336                 // assign style to style sheet folder,
00337                 // if parent is style sheet folder
00338                 if ($_GET["ref_id"] > 0)
00339                 {
00340 
00341                         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00342                         if ($fold->getType() == "stys")
00343                         {
00344                                 $fold->addStyle($newObj->getId());
00345                                 $fold->update();
00346                                 
00347                                 $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
00348                         }
00349                 }
00350 
00351                 return $newObj->getId();
00352         }
00353 
00357         function updateObject()
00358         {
00359                 //$class_name = "ilObjStyleSheet";
00360                 //require_once("classes/class.ilObjStyleSheet.php");
00361                 $this->object->setTitle($_POST["style_title"]);
00362                 $this->object->setDescription($_POST["style_description"]);
00363 
00364                 foreach($_POST["styval"] as $id => $value)
00365                 {
00366                         $this->object->updateStyleParameter($id, $value);
00367                 }
00368                 $this->object->update();
00369                 
00370                 if ($_GET["ref_id"] > 0)
00371                 {
00372 
00373                         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00374                         if ($fold->getType() == "stys")
00375                         {
00376                                 $this->ctrl->redirectByClass("ilobjstylesettingsgui",
00377                                         "editContentStyles");
00378                         }
00379                 }
00380 
00381                 $this->ctrl->returnToParent($this);
00382         }
00383 
00387         function cancelObject()
00388         {
00389                 global $lng;
00390 
00391                 sendInfo($lng->txt("msg_cancel"), true);
00392                 $this->ctrl->returnToParent($this);
00393         }
00394         
00398         function getAdminTabs(&$tabs_gui)
00399         {
00400                 $this->getTabs($tabs_gui);
00401         }
00402 
00406         function setTabs()
00407         {
00408                 global $lng;
00409 
00410                 // catch feedback message
00411                 #include_once("classes/class.ilTabsGUI.php");
00412                 #$tabs_gui =& new ilTabsGUI();
00413                 $this->getTabs($this->tabs_gui);
00414                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00415 
00416                 if (strtolower(get_class($this->object)) == "ilobjstylesheet")
00417                 {
00418                         $this->tpl->setVariable("HEADER", $this->object->getTitle());
00419                 }
00420                 else
00421                 {
00422                         $this->tpl->setVariable("HEADER", $lng->txt("create_stylesheet"));
00423                 }
00424         }
00425 
00431         function getTabs(&$tabs_gui)
00432         {               
00433                 // back to upper context
00434                 $tabs_gui->addTarget("cont_back",
00435                         $this->ctrl->getParentReturn($this), "",
00436                         "");
00437         }
00438 
00443         function addAdminLocatorItems()
00444         {
00445                 global $ilLocator;
00446 
00447                 if ($_GET["admin_mode"] == "settings")  // system settings
00448                 {               
00449                         $ilLocator->addItem($this->lng->txt("administration"),
00450                                 $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
00451                                 ilFrameTargetInfo::_getFrame("MainContent"));
00452                                 
00453                         $ilLocator->addItem(ilObject::_lookupTitle(
00454                                 ilObject::_lookupObjId($_GET["ref_id"])),
00455                                 $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui", "view"));
00456 
00457                         if ($_GET["obj_id"] > 0)
00458                         {
00459                                 $ilLocator->addItem($this->object->getTitle(),
00460                                         $this->ctrl->getLinkTarget($this, "edit"));
00461                         }
00462                 }
00463                 else                                                    // repository administration
00464                 {
00465                         //?
00466                 }
00467 
00468         }
00469         
00470         function showUpperIcon()
00471         {
00472                 global $tree, $tpl, $objDefinition;
00473                 
00474                 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00475                 {
00476                                 $tpl->setUpperIcon(
00477                                         $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui",
00478                                                 "editContentStyles"));
00479                 }
00480                 else
00481                 {
00482                         // ?
00483                 }
00484         }
00485 
00486 } // END class.ObjStyleSheetGUI
00487 ?>

Generated on Fri Dec 13 2013 11:57:55 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1