ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjStyleSheetGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
36 require_once "./classes/class.ilObjectGUI.php";
37 require_once "./Services/Style/classes/class.ilObjStyleSheet.php";
38 
40 {
45 
50  function ilObjStyleSheetGUI($a_data,$a_id,$a_call_by_reference, $a_prep = true)
51  {
52  global $ilCtrl, $lng, $tpl;
53 
54  $this->ctrl =& $ilCtrl;
55  $this->lng =& $lng;
56  $this->lng->loadLanguageModule("style");
57 
58  $this->type = "sty";
59  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
60  }
61 
65  function &executeCommand()
66  {
67  $next_class = $this->ctrl->getNextClass($this);
68  $cmd = $this->ctrl->getCmd("edit");
69 
70  $this->prepareOutput();
71  switch($next_class)
72  {
73  default:
74  $cmd.= "Object";
75  $ret =& $this->$cmd();
76  break;
77  }
78 
79  return $ret;
80  }
81 
82  function viewObject()
83  {
84  $this->editObject();
85  }
86 
90  function createObject()
91  {
92  global $rbacsystem, $lng, $tpl;
93 
94  //$this->setTabs();
95 
96 
97  $this->lng =& $lng;
98  //$this->ctrl->setParameter($this,'new_type',$this->type);
99  $this->getTemplateFile("create", "sty");
100 
101  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("sty_create_new_stylesheet"));
102 
103  $this->tpl->setVariable("TXT_STYLE_BY_IMPORT", $this->lng->txt("sty_import_stylesheet"));
104  $this->tpl->setVariable("TXT_STYLE_BY_COPY", $this->lng->txt("sty_copy_other_stylesheet"));
105  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("import_file"));
106  $this->tpl->setVariable("TXT_SOURCE", $this->lng->txt("sty_source"));
107  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
108  $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
109 
110  $this->ctrl->setParameter($this, "new_type", "sty");
111  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
112  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
113  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
114  $this->tpl->setVariable("TXT_COPY", $this->lng->txt("copy"));
115  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
116  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
117 
118  // get all learning module styles
119  $clonable_styles = ilObjStyleSheet::_getClonableContentStyles();
120  $select = ilUtil::formSelect("", "source_style", $clonable_styles, false, true);
121  $this->tpl->setVariable("SOURCE_SELECT", $select);
122 
123  }
124 
128  function editObject()
129  {
130  global $rbacsystem, $lng;
131 
132  //$this->setTabs();
133 
134  // set style sheet
135  $this->tpl->setCurrentBlock("ContentStyle");
136  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
137  $this->object->getContentStylePath($this->object->getId()));
138  $this->tpl->parseCurrentBlock();
139 
140  $this->getTemplateFile("edit", "sty");
141  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit_stylesheet"));
142 
143  // add button button
144  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
145 
146  // export button
147  $this->tpl->setCurrentBlock("btn_cell");
148  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportStyle"));
149  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("export"));
150  $this->tpl->parseCurrentBlock();
151 
152  // output style parameters
153  $avail_pars = $this->object->getAvailableParameters();
154  $style = $this->object->getStyle();
155  foreach($style as $tag)
156  {
157  foreach($tag as $par)
158  {
159  $this->tpl->setCurrentBlock("StyleParameter");
160  $this->tpl->setVariable("PAR_ID", $par["id"]);
161  $var = str_replace("-", "_", $par["parameter"]);
162 
163  // replace _bottom, _top, _left, _right
164  $add = "";
165  $location = array("bottom", "top", "left", "right");
166  foreach ($location as $loc)
167  {
168  if (is_int(strpos($var, "_".$loc)))
169  {
170  $var = str_replace("_".$loc, "", $var);
171  $add = ", ".$this->lng->txt("sty_".$loc);
172  }
173  }
174  $this->tpl->setVariable("TXT_PAR",
175  $this->lng->txt("sty_".$var).$add);
176 
177  if (count($avail_pars[$par["parameter"]]) == 0)
178  {
179  $input = "<input type=\"text\" size=\"30\" maxlength=\"100\" ".
180  "name=\"styval[".$par["id"]."]\" value=\"".$par["value"]."\"";
181  }
182  else
183  {
184  $sel_avail_vals = array();
185  foreach($avail_pars[$par["parameter"]] as $key => $val)
186  {
187  $sel_avail_vals[$val] = $val;
188  }
189  $input = ilUtil::formSelect($par["value"], "styval[".$par["id"]."]", $sel_avail_vals, false, true);
190  }
191  $this->tpl->setVariable("INPUT_VAL", $input);
192  $this->tpl->parseCurrentBlock();
193  }
194  if ((!is_int(strpos($tag[0]["class"], ":hover"))) &&
195  (!is_int(strpos($tag[0]["class"], ":visited"))) &&
196  (!is_int(strpos($tag[0]["class"], ":active")))
197  )
198  {
199  $this->tpl->setCurrentBlock("Example_".$tag[0]["tag"]);
200  $this->tpl->setVariable("EX_CLASS", "ilc_".$tag[0]["class"]);
201  $this->tpl->setVariable("EX_TEXT", "ABC abc 123");
202  $this->tpl->parseCurrentBlock();
203  }
204 
205  $this->tpl->setCurrentBlock("StyleTag");
206  $tag_str = $tag[0]["tag"].".".$tag[0]["class"];
207  $this->tpl->setVariable("TXT_TAG", $tag_str);
208  $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
209  $this->ctrl->setParameter($this, "tag", $tag_str);
210  $this->tpl->setVariable("LINK_EDIT_TAG_STYLE",
211  $this->ctrl->getLinkTarget($this, "editTagStyle"));
212  $this->tpl->setVariable("STY_ROWSPAN", (count($tag) + 1));
213  $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("parameter"));
214  $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
215  $this->tpl->parseCurrentBlock();
216  }
217 
218  // title and description
219  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
220  $this->tpl->setVariable(strtoupper("TITLE"), $this->object->getTitle());
221  $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
222  $this->tpl->setVariable(strtoupper("DESCRIPTION"), $this->object->getDescription());
223  $this->tpl->parseCurrentBlock();
224 
225  // new parameter
226  $temptags = $this->object->getAvailableTags();
227  $tags = array();
228  foreach($temptags as $key => $val)
229  {
230  $tags[$val] = $val;
231  }
232  $tag_select = ilUtil::formSelect("", "tag", $tags, false, true);
233  foreach($avail_pars as $key => $val)
234  {
235  $sel_avail_pars[$key] = $key;
236  }
237  $this->tpl->setVariable("SELECT_TAG", $tag_select);
238  $par_select = ilUtil::formSelect("", "parameter", $sel_avail_pars, false, true);
239  $this->tpl->setVariable("SELECT_PAR", $par_select);
240  $this->tpl->setVariable("TXT_NEW_PAR", $this->lng->txt("add"));
241 
242  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
243  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save_return"));
244  $this->tpl->setVariable("BTN_SAVE", "update");
245  $this->tpl->setVariable("TXT_REFRESH", $this->lng->txt("save_refresh"));
246  $this->tpl->setVariable("BTN_REFRESH", "refresh");
247  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete_selected"));
248  $this->tpl->setVariable("BTN_DELETE", "deleteStyleParameter");
249  $this->tpl->setVariable("BTN_NEW_PAR", "newStyleParameter");
250  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
251  }
252 
257  {
258  global $rbacsystem, $lng;
259 
260  //$this->setTabs();
261 
262  // set style sheet
263  $this->tpl->setCurrentBlock("ContentStyle");
264  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
265  $this->object->getContentStylePath($this->object->getId()));
266  $this->tpl->parseCurrentBlock();
267  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content",
268  "tpl.sty_tag_edit.html", false, false);
269  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit_stylesheet"));
270 
271  // output style parameters
272  $avail_pars = $this->object->getAvailableParameters();
273  $style = $this->object->getStyle();
274  $this->tpl->setVariable("TXT_TEXT", $this->lng->txt("sty_text"));
275  $this->tpl->setVariable("TXT_MARGIN_AND_PADDING", $this->lng->txt("sty_margin_and_padding"));
276  $this->tpl->setVariable("TXT_ALL", $this->lng->txt("sty_all"));
277  $this->tpl->setVariable("TXT_TOP", $this->lng->txt("sty_top"));
278  $this->tpl->setVariable("TXT_BOTTOM", $this->lng->txt("sty_bottom"));
279  $this->tpl->setVariable("TXT_LEFT", $this->lng->txt("sty_left"));
280  $this->tpl->setVariable("TXT_RIGHT", $this->lng->txt("sty_right"));
281  $this->tpl->setVariable("TXT_BORDER", $this->lng->txt("sty_border"));
282  $this->tpl->setVariable("TXT_BACKGROUND", $this->lng->txt("sty_background"));
283  $this->tpl->setVariable("TXT_SPECIAL", $this->lng->txt("sty_special"));
284 
285  $cur = explode(".",$_GET["tag"]);
286  $cur_tag = $cur[0];
287  $cur_class = $cur[1];
288  $parameters = $this->extractParametersOfTag($cur_tag, $cur_class, $style);
289 
290  $this->tpl->setCurrentBlock("Example_".$cur_tag);
291  $this->tpl->setVariable("EX_CLASS", "ilc_".$cur_class);
292  $this->tpl->setVariable("EX_TEXT", "ABC abc 123");
293  $this->tpl->parseCurrentBlock();
294 
295  // for all tag parameters
296  foreach ($avail_pars as $par => $vals)
297  {
298  $var = str_replace("-", "_", $par);
299  $up_par = strtoupper($var);
300  $this->tpl->setVariable("TXT_".$up_par, $this->lng->txt("sty_".$var));
301 
302  // output select lists
303  if (count($avail_pars[$par]) > 0)
304  {
305  $sel_avail_vals = array("" => "");
306  foreach($avail_pars[$par] as $key => $val)
307  {
308  $sel_avail_vals[$val] = $val;
309  }
310  $sel_str = ilUtil::formSelect($parameters[$par], $var, $sel_avail_vals, false, true);
311  $this->tpl->setVariable("SEL_".$up_par, $sel_str);
312  }
313  else
314  {
315  $this->tpl->setVariable("VAL_".$up_par, $parameters[$par]);
316  }
317  }
318 
319  /*
320  foreach($style as $tag)
321  {
322  foreach($tag as $par)
323  {
324  $this->tpl->setCurrentBlock("StyleParameter");
325  $this->tpl->setVariable("PAR_ID", $par["id"]);
326  $this->tpl->setVariable("TXT_PAR", $par["parameter"]);
327  if (count($avail_pars[$par["parameter"]]) == 0)
328  {
329  $input = "<input type=\"text\" size=\"30\" maxlength=\"100\" ".
330  "name=\"styval[".$par["id"]."]\" value=\"".$par["value"]."\"";
331  }
332  else
333  {
334  $sel_avail_vals = array();
335  foreach($avail_pars[$par["parameter"]] as $key => $val)
336  {
337  $sel_avail_vals[$val] = $val;
338  }
339  $input = ilUtil::formSelect($par["value"], "styval[".$par["id"]."]", $sel_avail_vals, false, true);
340  }
341  $this->tpl->setVariable("INPUT_VAL", $input);
342  $this->tpl->parseCurrentBlock();
343  }
344  if ((!is_int(strpos($tag[0]["class"], ":hover"))) &&
345  (!is_int(strpos($tag[0]["class"], ":visited"))) &&
346  (!is_int(strpos($tag[0]["class"], ":active")))
347  )
348  {
349  $this->tpl->setCurrentBlock("Example_".$tag[0]["tag"]);
350  $this->tpl->setVariable("EX_CLASS", "ilc_".$tag[0]["class"]);
351  $this->tpl->setVariable("EX_TEXT", "ABC abc 123");
352  $this->tpl->parseCurrentBlock();
353  }
354 
355  $this->tpl->setCurrentBlock("StyleTag");
356  $tag_str = $tag[0]["tag"].".".$tag[0]["class"];
357  $this->tpl->setVariable("TXT_TAG", $tag_str);
358  $this->ctrl->setParameter($this, "tag", $tag_str);
359  $this->tpl->setVariable("LINK_EDIT_TAG_STYLE",
360  $this->ctrl->getLinkTarget($this, "editTagStyle"));
361  $this->tpl->setVariable("STY_ROWSPAN", (count($tag) + 1));
362  $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("parameter"));
363  $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
364  $this->tpl->parseCurrentBlock();
365  }
366 
367  // title and description
368  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
369  $this->tpl->setVariable(strtoupper("TITLE"), $this->object->getTitle());
370  $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
371  $this->tpl->setVariable(strtoupper("DESCRIPTION"), $this->object->getDescription());
372  $this->tpl->parseCurrentBlock();
373 
374  // new parameter
375  $temptags = $this->object->getAvailableTags();
376  $tags = array();
377  foreach($temptags as $key => $val)
378  {
379  $tags[$val] = $val;
380  }
381  $tag_select = ilUtil::formSelect("", "tag", $tags, false, true);
382  foreach($avail_pars as $key => $val)
383  {
384  $sel_avail_pars[$key] = $key;
385  }
386  $this->tpl->setVariable("SELECT_TAG", $tag_select);
387  $par_select = ilUtil::formSelect("", "parameter", $sel_avail_pars, false, true);
388  $this->tpl->setVariable("SELECT_PAR", $par_select);
389  $this->tpl->setVariable("TXT_NEW_PAR", $this->lng->txt("add"));
390  */
391 
392  $this->ctrl->setParameter($this, "tag", $_GET["tag"]);
393  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
394  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save_return"));
395  $this->tpl->setVariable("BTN_SAVE", "updateTagStyle");
396  $this->tpl->setVariable("TXT_REFRESH", $this->lng->txt("save_refresh"));
397  $this->tpl->setVariable("BTN_REFRESH", "refreshTagStyle");
398  }
399 
404  {
405  $avail_pars = $this->object->getAvailableParameters();
406  $cur = explode(".",$_GET["tag"]);
407  $cur_tag = $cur[0];
408  $cur_class = $cur[1];
409  foreach ($avail_pars as $par => $vals)
410  {
411  $var = str_replace("-", "_", $par);
412  if ($_POST[$var] != "")
413  {
414  $this->object->replaceStylePar($cur_tag, $cur_class, $par, $_POST[$var]);
415  }
416  else
417  {
418  $this->object->deleteStylePar($cur_tag, $cur_class, $par);
419  }
420 
421  //$this->object->updateStyleParameter($id, $value);
422  }
423  $this->object->update();
424  $this->editTagStyleObject();
425  }
426 
431  {
432  $avail_pars = $this->object->getAvailableParameters();
433  $cur = explode(".", $_GET["tag"]);
434  $cur_tag = $cur[0];
435  $cur_class = $cur[1];
436  foreach ($avail_pars as $par => $vals)
437  {
438  $var = str_replace("-", "_", $par);
439  if ($_POST[$var] != "")
440  {
441  $this->object->replaceStylePar($cur_tag, $cur_class, $par, $_POST[$var]);
442  }
443  else
444  {
445  $this->object->deleteStylePar($cur_tag, $cur_class, $par);
446  }
447 
448  //$this->object->updateStyleParameter($id, $value);
449  }
450  $this->object->update();
451  $this->editObject();
452  }
453 
457  function exportStyleObject()
458  {
459  ilUtil::deliverData($this->object->getXML(), "style_".$this->object->getId().".xml");
460  }
461 
462  function extractParametersOfTag($a_tag, $a_class, $a_style)
463  {
464  $parameters = array();
465  foreach($a_style as $tag)
466  {
467  foreach($tag as $par)
468  {
469  if ($par["tag"] == $a_tag && $par["class"] == $a_class)
470  {
471  $parameters[$par["parameter"]] = $par["value"];
472  }
473  }
474  }
475  return $parameters;
476  }
477 
482  {
483  $this->object->addParameter($_POST["tag"], $_POST["parameter"]);
484  $this->editObject();
485  }
486 
490  function refreshObject()
491  {
492  //$class_name = "ilObjStyleSheet";
493  //require_once("classes/class.ilObjStyleSheet.php");
494  $this->object->setTitle($_POST["style_title"]);
495  $this->object->setDescription($_POST["style_description"]);
496 
497  foreach($_POST["styval"] as $id => $value)
498  {
499  $this->object->updateStyleParameter($id, $value);
500  }
501  $this->object->update();
502  $this->editObject();
503  }
504 
510  function deleteObject($a_error = false)
511  {
512  //$this->setTabs();
513 
514  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
515 
516  if(!$a_error)
517  {
518  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
519  }
520 
521  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
522 
523  // BEGIN TABLE HEADER
524  $this->tpl->setCurrentBlock("table_header");
525  $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
526  $this->tpl->parseCurrentBlock();
527 
528  // END TABLE HEADER
529 
530  // BEGIN TABLE DATA
531  $counter = 0;
532 
533  $this->tpl->setCurrentBlock("table_row");
534  $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_styf.gif"));
535  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
536  $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($this->object->getId()));
537  $this->tpl->parseCurrentBlock();
538 
539  // END TABLE DATA
540 
541  // BEGIN OPERATION_BTN
542  $buttons = array("confirmedDelete" => $this->lng->txt("confirm"),
543  "cancelDelete" => $this->lng->txt("cancel"));
544  foreach ($buttons as $name => $value)
545  {
546  $this->tpl->setCurrentBlock("operation_btn");
547  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
548  $this->tpl->setVariable("BTN_NAME",$name);
549  $this->tpl->setVariable("BTN_VALUE",$value);
550  $this->tpl->parseCurrentBlock();
551  }
552  }
553 
554 
559  {
560  $this->ctrl->returnToParent($this);
561  }
562 
567  {
568  global $ilias;
569 
570  $this->object->delete();
571 
572  $this->ctrl->returnToParent($this);
573  }
574 
579  {
580  if (is_array($_POST["sty_select"]))
581  {
582  foreach($_POST["sty_select"] as $id => $dummy)
583  {
584  $this->object->deleteParameter($id);
585  }
586  }
587  $this->object->read();
588  $this->object->writeCSSFile();
589  $this->editObject();
590  }
591 
595  function saveObject()
596  {
597 //echo "HH"; exit;
598  $class_name = "ilObjStyleSheet";
599  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
600  $newObj = new ilObjStyleSheet();
601  $newObj->setTitle($_POST["style_title"]);
602  $newObj->setDescription($_POST["style_description"]);
603  $newObj->create();
604 
605  // assign style to style sheet folder,
606  // if parent is style sheet folder
607  if ($_GET["ref_id"] > 0)
608  {
609 
610  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
611  if ($fold->getType() == "stys")
612  {
613  $fold->addStyle($newObj->getId());
614  $fold->update();
615  ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
616  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
617  }
618  }
619 
620  return $newObj->getId();
621  }
622 
626  function updateObject()
627  {
628  //$class_name = "ilObjStyleSheet";
629  //require_once("classes/class.ilObjStyleSheet.php");
630  $this->object->setTitle($_POST["style_title"]);
631  $this->object->setDescription($_POST["style_description"]);
632 
633  foreach($_POST["styval"] as $id => $value)
634  {
635  $this->object->updateStyleParameter($id, $value);
636  }
637  $this->object->update();
638 
639  if ($_GET["ref_id"] > 0)
640  {
641 
642  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
643  if ($fold->getType() == "stys")
644  {
645  $this->ctrl->redirectByClass("ilobjstylesettingsgui",
646  "editContentStyles");
647  }
648  }
649 
650  $this->ctrl->returnToParent($this);
651  }
652 
656  function copyStyleObject()
657  {
658  global $ilias;
659 
660  if ($_POST["source_style"] > 0)
661  $style_obj =& $ilias->obj_factory->getInstanceByObjId($_POST["source_style"]);
662  $new_id = $style_obj->ilClone();
663 
664  // assign style to style sheet folder,
665  // if parent is style sheet folder
666  if ($_GET["ref_id"] > 0)
667  {
668 
669  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
670  if ($fold->getType() == "stys")
671  {
672  $fold->addStyle($new_id);
673  $fold->update();
674  ilObjStyleSheet::_writeStandard($new_id, "1");
675  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
676  }
677  }
678 
679  return $new_id;
680  }
681 
685  function importStyleObject()
686  {
687  // check file
688  $source = $_FILES["stylefile"]["tmp_name"];
689  if (($source == 'none') || (!$source))
690  {
691  $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
692  }
693 
694  // check correct file type
695  $info = pathinfo($_FILES["stylefile"]["name"]);
696  if (strtolower($info["extension"]) != "xml")
697  {
698  $this->ilias->raiseError("File must be a xml file!",$this->ilias->error_obj->MESSAGE);
699  }
700 
701  $class_name = "ilObjStyleSheet";
702  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
703  $newObj = new ilObjStyleSheet();
704  //$newObj->setTitle();
705  //$newObj->setDescription($_POST["style_description"]);
706  $newObj->createFromXMLFile($_FILES["stylefile"]["tmp_name"]);
707 
708  // assign style to style sheet folder,
709  // if parent is style sheet folder
710  if ($_GET["ref_id"] > 0)
711  {
712 
713  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
714  if ($fold->getType() == "stys")
715  {
716  $fold->addStyle($newObj->getId());
717  $fold->update();
718  ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
719  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
720  }
721  }
722 
723  return $newObj->getId();
724  }
725 
729  function cancelObject()
730  {
731  global $lng;
732 
733  ilUtil::sendInfo($lng->txt("msg_cancel"), true);
734  $this->ctrl->returnToParent($this);
735  }
736 
740  function getAdminTabs(&$tabs_gui)
741  {
742  $this->getTabs($tabs_gui);
743  }
744 
748  function setTabs()
749  {
750  global $lng;
751 
752  // catch feedback message
753  #include_once("classes/class.ilTabsGUI.php");
754  #$tabs_gui =& new ilTabsGUI();
755  $this->getTabs($this->tabs_gui);
756  #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
757 
758  if (strtolower(get_class($this->object)) == "ilobjstylesheet")
759  {
760  $this->tpl->setVariable("HEADER", $this->object->getTitle());
761  }
762  else
763  {
764  $this->tpl->setVariable("HEADER", $lng->txt("create_stylesheet"));
765  }
766  }
767 
773  function getTabs(&$tabs_gui)
774  {
775  // back to upper context
776  $tabs_gui->addTarget("cont_back",
777  $this->ctrl->getParentReturn($this), "",
778  "");
779  }
780 
786  {
787  global $ilLocator;
788 
789  if ($_GET["admin_mode"] == "settings") // system settings
790  {
791  $ilLocator->addItem($this->lng->txt("administration"),
792  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
793  ilFrameTargetInfo::_getFrame("MainContent"));
794 
795  $ilLocator->addItem(ilObject::_lookupTitle(
796  ilObject::_lookupObjId($_GET["ref_id"])),
797  $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui", "view"));
798 
799  if ($_GET["obj_id"] > 0)
800  {
801  $ilLocator->addItem($this->object->getTitle(),
802  $this->ctrl->getLinkTarget($this, "edit"));
803  }
804  }
805  else // repository administration
806  {
807  //?
808  }
809 
810  }
811 
812  function showUpperIcon()
813  {
814  global $tree, $tpl, $objDefinition;
815 
816  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
817  {
818  $tpl->setUpperIcon(
819  $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui",
820  "editContentStyles"));
821  }
822  else
823  {
824  // ?
825  }
826  }
827 
828 } // END class.ObjStyleSheetGUI
829 ?>