• Main Page
  • Related Pages
  • Modules
  • 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 require_once "class.ilObjStyleSheet.php";
00039 
00040 class ilObjStyleSheetGUI extends ilObjectGUI
00041 {
00042         var $cmd_update;
00043         var $cmd_new_par;
00044         var $cmd_refresh;
00045         var $cmd_delete;
00046 
00051         function ilObjStyleSheetGUI($a_data,$a_id,$a_call_by_reference, $a_prep = true)
00052         {
00053                 global $ilCtrl, $lng, $tpl;
00054 
00055                 $this->ctrl =& $ilCtrl;
00056                 $this->lng =& $lng;
00057                 $this->lng->loadLanguageModule("style");
00058 
00059                 $this->type = "sty";
00060                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00061         }
00062 
00066         function &executeCommand()
00067         {
00068                 $next_class = $this->ctrl->getNextClass($this);
00069                 $cmd = $this->ctrl->getCmd("edit");
00070 
00071                 $this->prepareOutput();
00072                 switch($next_class)
00073                 {
00074                         default:
00075                                 $cmd.= "Object";
00076                                 $ret =& $this->$cmd();
00077                                 break;
00078                 }
00079 
00080                 return $ret;
00081         }
00082         
00083         function viewObject()
00084         {
00085                 $this->editObject();
00086         }
00087 
00091         function createObject()
00092         {
00093                 global $rbacsystem, $lng, $tpl;
00094 
00095                 //$this->setTabs();
00096 
00097                 $this->lng =& $lng;
00098                 //$this->ctrl->setParameter($this,'new_type',$this->type);
00099                 $this->getTemplateFile("create", "sty");
00100                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("sty_create_new_stylesheet"));
00101                 $this->tpl->setVariable("TXT_STYLE_BY_IMPORT", $this->lng->txt("sty_import_stylesheet"));
00102                 $this->tpl->setVariable("TXT_STYLE_BY_COPY", $this->lng->txt("sty_copy_other_stylesheet"));
00103                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("import_file"));
00104                 $this->tpl->setVariable("TXT_SOURCE", $this->lng->txt("sty_source"));
00105                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00106                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00107                 $this->tpl->parseCurrentBlock();
00108                 $this->ctrl->setParameter($this, "new_type", "sty");
00109                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00110                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00111                 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
00112                 $this->tpl->setVariable("TXT_COPY", $this->lng->txt("copy"));
00113                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00114                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00115                 
00116                 // get all learning module styles
00117                 $clonable_styles = ilObjStyleSheet::_getClonableContentStyles();
00118                 $select = ilUtil::formSelect("", "source_style", $clonable_styles, false, true);
00119                 $this->tpl->setVariable("SOURCE_SELECT", $select);
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                 // add button button
00141                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00142 
00143                 // export button
00144                 $this->tpl->setCurrentBlock("btn_cell");
00145                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportStyle"));
00146                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("export"));
00147                 $this->tpl->parseCurrentBlock();
00148 
00149                 // output style parameters
00150                 $avail_pars = $this->object->getAvailableParameters();
00151                 $style = $this->object->getStyle();
00152                 foreach($style as $tag)
00153                 {
00154                         foreach($tag as $par)
00155                         {
00156                                 $this->tpl->setCurrentBlock("StyleParameter");
00157                                 $this->tpl->setVariable("PAR_ID", $par["id"]);
00158                                 $var = str_replace("-", "_", $par["parameter"]);
00159                                 
00160                                 // replace _bottom, _top, _left, _right
00161                                 $add = "";
00162                                 $location = array("bottom", "top", "left", "right");
00163                                 foreach ($location as $loc)
00164                                 {
00165                                         if (is_int(strpos($var, "_".$loc)))
00166                                         {
00167                                                 $var = str_replace("_".$loc, "", $var);
00168                                                 $add = ", ".$this->lng->txt("sty_".$loc); 
00169                                         }
00170                                 }
00171                                 $this->tpl->setVariable("TXT_PAR",
00172                                         $this->lng->txt("sty_".$var).$add);
00173 
00174                                 if (count($avail_pars[$par["parameter"]]) == 0)
00175                                 {
00176                                         $input = "<input type=\"text\" size=\"30\" maxlength=\"100\" ".
00177                                                 "name=\"styval[".$par["id"]."]\" value=\"".$par["value"]."\"";
00178                                 }
00179                                 else
00180                                 {
00181                                         $sel_avail_vals = array();
00182                                         foreach($avail_pars[$par["parameter"]] as $key => $val)
00183                                         {
00184                                                 $sel_avail_vals[$val] = $val;
00185                                         }
00186                                         $input = ilUtil::formSelect($par["value"], "styval[".$par["id"]."]", $sel_avail_vals, false, true);
00187                                 }
00188                                 $this->tpl->setVariable("INPUT_VAL", $input);
00189                                 $this->tpl->parseCurrentBlock();
00190                         }
00191                         if ((!is_int(strpos($tag[0]["class"], ":hover"))) &&
00192                                 (!is_int(strpos($tag[0]["class"], ":visited"))) &&
00193                                 (!is_int(strpos($tag[0]["class"], ":active")))
00194                                 )
00195                         {
00196                                 $this->tpl->setCurrentBlock("Example_".$tag[0]["tag"]);
00197                                 $this->tpl->setVariable("EX_CLASS", "ilc_".$tag[0]["class"]);
00198                                 $this->tpl->setVariable("EX_TEXT", "ABC abc 123");
00199                                 $this->tpl->parseCurrentBlock();
00200                         }
00201 
00202                         $this->tpl->setCurrentBlock("StyleTag");
00203                         $tag_str = $tag[0]["tag"].".".$tag[0]["class"];
00204                         $this->tpl->setVariable("TXT_TAG", $tag_str);
00205                         $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00206                         $this->ctrl->setParameter($this, "tag", $tag_str);
00207                         $this->tpl->setVariable("LINK_EDIT_TAG_STYLE",
00208                                 $this->ctrl->getLinkTarget($this, "editTagStyle"));
00209                         $this->tpl->setVariable("STY_ROWSPAN", (count($tag) + 1));
00210                         $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("parameter"));
00211                         $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00212                         $this->tpl->parseCurrentBlock();
00213                 }
00214 
00215                 // title and description
00216                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00217                 $this->tpl->setVariable(strtoupper("TITLE"), $this->object->getTitle());
00218                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00219                 $this->tpl->setVariable(strtoupper("DESCRIPTION"), $this->object->getDescription());
00220                 $this->tpl->parseCurrentBlock();
00221 
00222                 // new parameter
00223                 $temptags = $this->object->getAvailableTags();
00224                 $tags = array();
00225                 foreach($temptags as $key => $val)
00226                 {
00227                         $tags[$val] = $val;
00228                 }
00229                 $tag_select = ilUtil::formSelect("", "tag", $tags, false, true);
00230                 foreach($avail_pars as $key => $val)
00231                 {
00232                         $sel_avail_pars[$key] = $key;
00233                 }
00234                 $this->tpl->setVariable("SELECT_TAG", $tag_select);
00235                 $par_select = ilUtil::formSelect("", "parameter", $sel_avail_pars, false, true);
00236                 $this->tpl->setVariable("SELECT_PAR", $par_select);
00237                 $this->tpl->setVariable("TXT_NEW_PAR", $this->lng->txt("add"));
00238 
00239                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00240                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save_return"));
00241                 $this->tpl->setVariable("BTN_SAVE", "update");
00242                 $this->tpl->setVariable("TXT_REFRESH", $this->lng->txt("save_refresh"));
00243                 $this->tpl->setVariable("BTN_REFRESH", "refresh");
00244                 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete_selected"));
00245                 $this->tpl->setVariable("BTN_DELETE", "deleteStyleParameter");
00246                 $this->tpl->setVariable("BTN_NEW_PAR", "newStyleParameter");
00247                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00248         }
00249 
00253         function editTagStyleObject()
00254         {
00255                 global $rbacsystem, $lng;
00256 
00257                 //$this->setTabs();
00258 
00259                 // set style sheet
00260                 $this->tpl->setCurrentBlock("ContentStyle");
00261                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00262                         $this->object->getContentStylePath($this->object->getId()));
00263                 $this->tpl->parseCurrentBlock();
00264                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content",
00265                         "tpl.sty_tag_edit.html", false, false);
00266                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit_stylesheet"));
00267 
00268                 // output style parameters
00269                 $avail_pars = $this->object->getAvailableParameters();
00270                 $style = $this->object->getStyle();
00271                 $this->tpl->setVariable("TXT_TEXT", $this->lng->txt("sty_text"));
00272                 $this->tpl->setVariable("TXT_MARGIN_AND_PADDING", $this->lng->txt("sty_margin_and_padding"));
00273                 $this->tpl->setVariable("TXT_ALL", $this->lng->txt("sty_all"));
00274                 $this->tpl->setVariable("TXT_TOP", $this->lng->txt("sty_top"));
00275                 $this->tpl->setVariable("TXT_BOTTOM", $this->lng->txt("sty_bottom"));
00276                 $this->tpl->setVariable("TXT_LEFT", $this->lng->txt("sty_left"));
00277                 $this->tpl->setVariable("TXT_RIGHT", $this->lng->txt("sty_right"));
00278                 $this->tpl->setVariable("TXT_BORDER", $this->lng->txt("sty_border"));
00279                 $this->tpl->setVariable("TXT_BACKGROUND", $this->lng->txt("sty_background"));
00280                 $this->tpl->setVariable("TXT_SPECIAL", $this->lng->txt("sty_special"));
00281                 
00282                 $cur = explode(".",$_GET["tag"]);
00283                 $cur_tag = $cur[0];
00284                 $cur_class = $cur[1];
00285                 $parameters = $this->extractParametersOfTag($cur_tag, $cur_class, $style);
00286                 
00287                 $this->tpl->setCurrentBlock("Example_".$cur_tag);
00288                 $this->tpl->setVariable("EX_CLASS", "ilc_".$cur_class);
00289                 $this->tpl->setVariable("EX_TEXT", "ABC abc 123");
00290                 $this->tpl->parseCurrentBlock();
00291 
00292                 // for all tag parameters
00293                 foreach ($avail_pars as $par => $vals)
00294                 {
00295                         $var = str_replace("-", "_", $par);
00296                         $up_par = strtoupper($var);
00297                         $this->tpl->setVariable("TXT_".$up_par, $this->lng->txt("sty_".$var));
00298                         
00299                         // output select lists
00300                         if (count($avail_pars[$par]) > 0)
00301                         {
00302                                 $sel_avail_vals = array("" => "");
00303                                 foreach($avail_pars[$par] as $key => $val)
00304                                 {
00305                                         $sel_avail_vals[$val] = $val;
00306                                 }
00307                                 $sel_str = ilUtil::formSelect($parameters[$par], $var, $sel_avail_vals, false, true);
00308                                 $this->tpl->setVariable("SEL_".$up_par, $sel_str);
00309                         }
00310                         else
00311                         {
00312                                 $this->tpl->setVariable("VAL_".$up_par, $parameters[$par]);
00313                         }
00314                 }
00315                 
00316                 /*
00317                 foreach($style as $tag)
00318                 {
00319                         foreach($tag as $par)
00320                         {
00321                                 $this->tpl->setCurrentBlock("StyleParameter");
00322                                 $this->tpl->setVariable("PAR_ID", $par["id"]);
00323                                 $this->tpl->setVariable("TXT_PAR", $par["parameter"]);
00324                                 if (count($avail_pars[$par["parameter"]]) == 0)
00325                                 {
00326                                         $input = "<input type=\"text\" size=\"30\" maxlength=\"100\" ".
00327                                                 "name=\"styval[".$par["id"]."]\" value=\"".$par["value"]."\"";
00328                                 }
00329                                 else
00330                                 {
00331                                         $sel_avail_vals = array();
00332                                         foreach($avail_pars[$par["parameter"]] as $key => $val)
00333                                         {
00334                                                 $sel_avail_vals[$val] = $val;
00335                                         }
00336                                         $input = ilUtil::formSelect($par["value"], "styval[".$par["id"]."]", $sel_avail_vals, false, true);
00337                                 }
00338                                 $this->tpl->setVariable("INPUT_VAL", $input);
00339                                 $this->tpl->parseCurrentBlock();
00340                         }
00341                         if ((!is_int(strpos($tag[0]["class"], ":hover"))) &&
00342                                 (!is_int(strpos($tag[0]["class"], ":visited"))) &&
00343                                 (!is_int(strpos($tag[0]["class"], ":active")))
00344                                 )
00345                         {
00346                                 $this->tpl->setCurrentBlock("Example_".$tag[0]["tag"]);
00347                                 $this->tpl->setVariable("EX_CLASS", "ilc_".$tag[0]["class"]);
00348                                 $this->tpl->setVariable("EX_TEXT", "ABC abc 123");
00349                                 $this->tpl->parseCurrentBlock();
00350                         }
00351 
00352                         $this->tpl->setCurrentBlock("StyleTag");
00353                         $tag_str = $tag[0]["tag"].".".$tag[0]["class"];
00354                         $this->tpl->setVariable("TXT_TAG", $tag_str);
00355                         $this->ctrl->setParameter($this, "tag", $tag_str);
00356                         $this->tpl->setVariable("LINK_EDIT_TAG_STYLE",
00357                                 $this->ctrl->getLinkTarget($this, "editTagStyle"));
00358                         $this->tpl->setVariable("STY_ROWSPAN", (count($tag) + 1));
00359                         $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("parameter"));
00360                         $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00361                         $this->tpl->parseCurrentBlock();
00362                 }
00363 
00364                 // title and description
00365                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00366                 $this->tpl->setVariable(strtoupper("TITLE"), $this->object->getTitle());
00367                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00368                 $this->tpl->setVariable(strtoupper("DESCRIPTION"), $this->object->getDescription());
00369                 $this->tpl->parseCurrentBlock();
00370 
00371                 // new parameter
00372                 $temptags = $this->object->getAvailableTags();
00373                 $tags = array();
00374                 foreach($temptags as $key => $val)
00375                 {
00376                         $tags[$val] = $val;
00377                 }
00378                 $tag_select = ilUtil::formSelect("", "tag", $tags, false, true);
00379                 foreach($avail_pars as $key => $val)
00380                 {
00381                         $sel_avail_pars[$key] = $key;
00382                 }
00383                 $this->tpl->setVariable("SELECT_TAG", $tag_select);
00384                 $par_select = ilUtil::formSelect("", "parameter", $sel_avail_pars, false, true);
00385                 $this->tpl->setVariable("SELECT_PAR", $par_select);
00386                 $this->tpl->setVariable("TXT_NEW_PAR", $this->lng->txt("add"));
00387                 */
00388 
00389                 $this->ctrl->setParameter($this, "tag", $_GET["tag"]);
00390                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00391                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save_return"));
00392                 $this->tpl->setVariable("BTN_SAVE", "updateTagStyle");
00393                 $this->tpl->setVariable("TXT_REFRESH", $this->lng->txt("save_refresh"));
00394                 $this->tpl->setVariable("BTN_REFRESH", "refreshTagStyle");
00395         }
00396         
00400         function refreshTagStyleObject()
00401         {
00402                 $avail_pars = $this->object->getAvailableParameters();
00403                 $cur = explode(".",$_GET["tag"]);
00404                 $cur_tag = $cur[0];
00405                 $cur_class = $cur[1];
00406                 foreach ($avail_pars as $par => $vals)
00407                 {
00408                         $var = str_replace("-", "_", $par);
00409                         if ($_POST[$var] != "")
00410                         {
00411                                 $this->object->replaceStylePar($cur_tag, $cur_class, $par, $_POST[$var]);
00412                         }
00413                         else
00414                         {
00415                                 $this->object->deleteStylePar($cur_tag, $cur_class, $par);
00416                         }
00417 
00418                         //$this->object->updateStyleParameter($id, $value);
00419                 }
00420                 $this->object->update();
00421                 $this->editTagStyleObject();
00422         }
00423 
00427         function updateTagStyleObject()
00428         {
00429                 $avail_pars = $this->object->getAvailableParameters();
00430                 $cur = explode(".", $_GET["tag"]);
00431                 $cur_tag = $cur[0];
00432                 $cur_class = $cur[1];
00433                 foreach ($avail_pars as $par => $vals)
00434                 {
00435                         $var = str_replace("-", "_", $par);
00436                         if ($_POST[$var] != "")
00437                         {
00438                                 $this->object->replaceStylePar($cur_tag, $cur_class, $par, $_POST[$var]);
00439                         }
00440                         else
00441                         {
00442                                 $this->object->deleteStylePar($cur_tag, $cur_class, $par);
00443                         }
00444 
00445                         //$this->object->updateStyleParameter($id, $value);
00446                 }
00447                 $this->object->update();
00448                 $this->editObject();
00449         }
00450 
00454         function exportStyleObject()
00455         {
00456                 ilUtil::deliverData($this->object->getXML(), "style_".$this->object->getId().".xml");
00457         }
00458 
00459         function extractParametersOfTag($a_tag, $a_class, $a_style)
00460         {
00461                 $parameters = array();
00462                 foreach($a_style as $tag)
00463                 {
00464                         foreach($tag as $par)
00465                         {
00466                                 if ($par["tag"] == $a_tag && $par["class"] == $a_class)
00467                                 {
00468                                         $parameters[$par["parameter"]] = $par["value"]; 
00469                                 }
00470                         }
00471                 }
00472                 return $parameters;
00473         }
00474         
00478         function newStyleParameterObject()
00479         {
00480                 $this->object->addParameter($_POST["tag"], $_POST["parameter"]);
00481                 $this->editObject();
00482         }
00483 
00487         function refreshObject()
00488         {
00489                 //$class_name = "ilObjStyleSheet";
00490                 //require_once("classes/class.ilObjStyleSheet.php");
00491                 $this->object->setTitle($_POST["style_title"]);
00492                 $this->object->setDescription($_POST["style_description"]);
00493 
00494                 foreach($_POST["styval"] as $id => $value)
00495                 {
00496                         $this->object->updateStyleParameter($id, $value);
00497                 }
00498                 $this->object->update();
00499                 $this->editObject();
00500         }
00501         
00507         function deleteObject($a_error = false)
00508         {
00509                 //$this->setTabs();
00510 
00511                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
00512 
00513                 if(!$a_error)
00514                 {
00515                         sendInfo($this->lng->txt("info_delete_sure"));
00516                 }
00517 
00518                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00519 
00520                 // BEGIN TABLE HEADER
00521                 $this->tpl->setCurrentBlock("table_header");
00522                 $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
00523                 $this->tpl->parseCurrentBlock();
00524                 
00525                 // END TABLE HEADER
00526 
00527                 // BEGIN TABLE DATA
00528                 $counter = 0;
00529 
00530                 $this->tpl->setCurrentBlock("table_row");
00531                 $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_styf.gif"));
00532                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00533                 $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($this->object->getId()));
00534                 $this->tpl->parseCurrentBlock();
00535                 
00536                 // END TABLE DATA
00537 
00538                 // BEGIN OPERATION_BTN
00539                 $buttons = array("confirmedDelete"  => $this->lng->txt("confirm"),
00540                         "cancelDelete"  => $this->lng->txt("cancel"));
00541                 foreach ($buttons as $name => $value)
00542                 {
00543                         $this->tpl->setCurrentBlock("operation_btn");
00544                         $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00545                         $this->tpl->setVariable("BTN_NAME",$name);
00546                         $this->tpl->setVariable("BTN_VALUE",$value);
00547                         $this->tpl->parseCurrentBlock();
00548                 }
00549         }
00550         
00551         
00555         function cancelDeleteObject()
00556         {
00557                 $this->ctrl->returnToParent($this);
00558         }
00559 
00563         function confirmedDeleteObject()
00564         {
00565                 global $ilias;
00566                 
00567                 $this->object->delete();
00568                 
00569                 $this->ctrl->returnToParent($this);
00570         }
00571 
00575         function deleteStyleParameterObject()
00576         {
00577                 if (is_array($_POST["sty_select"]))
00578                 {
00579                         foreach($_POST["sty_select"] as $id => $dummy)
00580                         {
00581                                 $this->object->deleteParameter($id);
00582                         }
00583                 }
00584                 $this->object->read();
00585                 $this->object->writeCSSFile();
00586                 $this->editObject();
00587         }
00588 
00592         function saveObject()
00593         {
00594 //echo "HH"; exit;
00595                 $class_name = "ilObjStyleSheet";
00596                 require_once("classes/class.ilObjStyleSheet.php");
00597                 $newObj = new ilObjStyleSheet();
00598                 $newObj->setTitle($_POST["style_title"]);
00599                 $newObj->setDescription($_POST["style_description"]);
00600                 $newObj->create();
00601 
00602                 // assign style to style sheet folder,
00603                 // if parent is style sheet folder
00604                 if ($_GET["ref_id"] > 0)
00605                 {
00606 
00607                         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00608                         if ($fold->getType() == "stys")
00609                         {
00610                                 $fold->addStyle($newObj->getId());
00611                                 $fold->update();
00612                                 ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
00613                                 $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
00614                         }
00615                 }
00616 
00617                 return $newObj->getId();
00618         }
00619 
00623         function updateObject()
00624         {
00625                 //$class_name = "ilObjStyleSheet";
00626                 //require_once("classes/class.ilObjStyleSheet.php");
00627                 $this->object->setTitle($_POST["style_title"]);
00628                 $this->object->setDescription($_POST["style_description"]);
00629 
00630                 foreach($_POST["styval"] as $id => $value)
00631                 {
00632                         $this->object->updateStyleParameter($id, $value);
00633                 }
00634                 $this->object->update();
00635                 
00636                 if ($_GET["ref_id"] > 0)
00637                 {
00638 
00639                         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00640                         if ($fold->getType() == "stys")
00641                         {
00642                                 $this->ctrl->redirectByClass("ilobjstylesettingsgui",
00643                                         "editContentStyles");
00644                         }
00645                 }
00646 
00647                 $this->ctrl->returnToParent($this);
00648         }
00649 
00653         function copyStyleObject()
00654         {
00655                 global $ilias;
00656                 
00657                 if ($_POST["source_style"] > 0)
00658                 $style_obj =& $ilias->obj_factory->getInstanceByObjId($_POST["source_style"]);
00659                 $new_id = $style_obj->ilClone();
00660 
00661                 // assign style to style sheet folder,
00662                 // if parent is style sheet folder
00663                 if ($_GET["ref_id"] > 0)
00664                 {
00665 
00666                         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00667                         if ($fold->getType() == "stys")
00668                         {
00669                                 $fold->addStyle($new_id);
00670                                 $fold->update();
00671                                 ilObjStyleSheet::_writeStandard($new_id, "1");
00672                                 $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
00673                         }
00674                 }
00675 
00676                 return $new_id;
00677         }
00678 
00682         function importStyleObject()
00683         {
00684                 // check file
00685                 $source = $_FILES["stylefile"]["tmp_name"];
00686                 if (($source == 'none') || (!$source))
00687                 {
00688                         $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00689                 }
00690                 
00691                 // check correct file type
00692                 $info = pathinfo($_FILES["stylefile"]["name"]);
00693                 if (strtolower($info["extension"]) != "xml")
00694                 {
00695                         $this->ilias->raiseError("File must be a xml file!",$this->ilias->error_obj->MESSAGE);
00696                 }
00697 
00698                 $class_name = "ilObjStyleSheet";
00699                 require_once("classes/class.ilObjStyleSheet.php");
00700                 $newObj = new ilObjStyleSheet();
00701                 //$newObj->setTitle();
00702                 //$newObj->setDescription($_POST["style_description"]);
00703                 $newObj->createFromXMLFile($_FILES["stylefile"]["tmp_name"]);
00704 
00705                 // assign style to style sheet folder,
00706                 // if parent is style sheet folder
00707                 if ($_GET["ref_id"] > 0)
00708                 {
00709 
00710                         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00711                         if ($fold->getType() == "stys")
00712                         {
00713                                 $fold->addStyle($newObj->getId());
00714                                 $fold->update();
00715                                 ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
00716                                 $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
00717                         }
00718                 }
00719 
00720                 return $newObj->getId();
00721         }
00722 
00726         function cancelObject()
00727         {
00728                 global $lng;
00729 
00730                 sendInfo($lng->txt("msg_cancel"), true);
00731                 $this->ctrl->returnToParent($this);
00732         }
00733         
00737         function getAdminTabs(&$tabs_gui)
00738         {
00739                 $this->getTabs($tabs_gui);
00740         }
00741 
00745         function setTabs()
00746         {
00747                 global $lng;
00748 
00749                 // catch feedback message
00750                 #include_once("classes/class.ilTabsGUI.php");
00751                 #$tabs_gui =& new ilTabsGUI();
00752                 $this->getTabs($this->tabs_gui);
00753                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00754 
00755                 if (strtolower(get_class($this->object)) == "ilobjstylesheet")
00756                 {
00757                         $this->tpl->setVariable("HEADER", $this->object->getTitle());
00758                 }
00759                 else
00760                 {
00761                         $this->tpl->setVariable("HEADER", $lng->txt("create_stylesheet"));
00762                 }
00763         }
00764 
00770         function getTabs(&$tabs_gui)
00771         {               
00772                 // back to upper context
00773                 $tabs_gui->addTarget("cont_back",
00774                         $this->ctrl->getParentReturn($this), "",
00775                         "");
00776         }
00777 
00782         function addAdminLocatorItems()
00783         {
00784                 global $ilLocator;
00785 
00786                 if ($_GET["admin_mode"] == "settings")  // system settings
00787                 {               
00788                         $ilLocator->addItem($this->lng->txt("administration"),
00789                                 $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
00790                                 ilFrameTargetInfo::_getFrame("MainContent"));
00791                                 
00792                         $ilLocator->addItem(ilObject::_lookupTitle(
00793                                 ilObject::_lookupObjId($_GET["ref_id"])),
00794                                 $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui", "view"));
00795 
00796                         if ($_GET["obj_id"] > 0)
00797                         {
00798                                 $ilLocator->addItem($this->object->getTitle(),
00799                                         $this->ctrl->getLinkTarget($this, "edit"));
00800                         }
00801                 }
00802                 else                                                    // repository administration
00803                 {
00804                         //?
00805                 }
00806 
00807         }
00808         
00809         function showUpperIcon()
00810         {
00811                 global $tree, $tpl, $objDefinition;
00812                 
00813                 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00814                 {
00815                                 $tpl->setUpperIcon(
00816                                         $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui",
00817                                                 "editContentStyles"));
00818                 }
00819                 else
00820                 {
00821                         // ?
00822                 }
00823         }
00824 
00825 } // END class.ObjStyleSheetGUI
00826 ?>

Generated on Fri Dec 13 2013 13:52:08 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1