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

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