5 require_once
"./classes/class.ilObject.php";
19 public static $num_unit = array(
"px",
"em",
"ex",
"%",
"pt",
"pc",
"in",
"mm",
"cm");
25 "values" => array(
"xx-small",
"x-small",
"small",
"medium",
"large",
"x-large",
"xx-large",
"smaller",
"larger"),
26 "input" =>
"fontsize",
28 "font-family" => array(
32 "font-style" => array(
33 "values" => array(
"italic",
"oblique",
"normal"),
36 "font-weight" => array(
37 "values" => array(
"bold",
"normal",
"bolder",
"lighter"),
40 "font-variant" => array(
41 "values" => array(
"small-caps",
"normal"),
44 "word-spacing" => array(
46 "input" =>
"numeric_no_perc",
48 "letter-spacing" => array(
50 "input" =>
"numeric_no_perc",
52 "text-decoration" => array(
53 "values" => array(
"underline",
"overline",
"line-through",
"blink",
"none"),
56 "text-transform" => array(
57 "values" => array(
"capitalize",
"uppercase",
"lowercase",
"none"),
64 "text-indent" => array(
68 "line-height" => array(
72 "vertical-align" => array(
73 "values" => array(
"top",
"middle",
"bottom",
"baseline",
"sub",
"super",
74 "text-top",
"text-bottom"),
77 "text-align" => array(
78 "values" => array(
"left",
"center",
"right",
"justify"),
81 "white-space" => array(
82 "values" => array(
"normal",
"pre",
"nowrap"),
87 "input" =>
"trbl_numeric",
88 "subpar" => array(
"margin",
"margin-top",
"margin-right",
89 "margin-bottom",
"margin-left"),
90 "group" =>
"margin_and_padding"),
93 "input" =>
"trbl_numeric",
94 "subpar" => array(
"padding",
"padding-top",
"padding-right",
95 "padding-bottom",
"padding-left"),
96 "group" =>
"margin_and_padding"),
97 "border-width" => array(
98 "values" => array(
"thin",
"medium",
"thick"),
99 "input" =>
"border_width",
100 "subpar" => array(
"border-width",
"border-top-width",
"border-right-width",
101 "border-bottom-width",
"border-left-width"),
102 "group" =>
"border"),
103 "border-color" => array(
105 "input" =>
"trbl_color",
106 "subpar" => array(
"border-color",
"border-top-color",
"border-right-color",
107 "border-bottom-color",
"border-left-color"),
108 "group" =>
"border"),
109 "border-style" => array(
110 "values" => array(
"none",
"hidden",
"dotted",
"dashed",
"solid",
"double",
111 "groove",
"ridge",
"inset",
"outset"),
112 "input" =>
"border_style",
113 "subpar" => array(
"border-style",
"border-top-style",
"border-right-style",
114 "border-bottom-style",
"border-left-style"),
115 "group" =>
"border"),
117 "background-color" => array(
120 "group" =>
"background"),
121 "background-image" => array(
123 "input" =>
"background_image",
124 "group" =>
"background"),
125 "background-repeat" => array(
126 "values" => array(
"repeat",
"repeat-x",
"repeat-y",
"no-repeat"),
128 "group" =>
"background"),
129 "background-attachment" => array(
130 "values" => array(
"fixed",
"scroll"),
132 "group" =>
"background"),
133 "background-position" => array(
134 "values" => array(
"horizontal" => array(
"left",
"center",
"right"),
135 "vertical" => array(
"top",
"center",
"bottom")),
136 "input" =>
"background_position",
137 "group" =>
"background"),
140 "values" => array(
"absolute",
"fixed",
"relative",
"static"),
142 "group" =>
"positioning"),
145 "input" =>
"numeric",
146 "group" =>
"positioning"),
149 "input" =>
"numeric",
150 "group" =>
"positioning"),
153 "input" =>
"numeric",
154 "group" =>
"positioning"),
157 "input" =>
"numeric",
158 "group" =>
"positioning"),
161 "input" =>
"numeric",
162 "group" =>
"positioning"),
165 "input" =>
"numeric",
166 "group" =>
"positioning"),
167 "min-height" => array(
169 "input" =>
"numeric",
170 "group" =>
"positioning"),
172 "values" => array(
"left",
"right",
"none"),
174 "group" =>
"positioning"),
176 "values" => array(
"visible",
"hidden",
"scroll",
"auto"),
178 "group" =>
"positioning"),
182 "input" =>
"percentage",
183 "group" =>
"special"),
185 "values" => array(
"auto",
"default",
"crosshair",
"pointer",
"move",
186 "n-resize",
"ne-resize",
"e-resize",
"se-resize",
"s-resize",
"sw-resize",
187 "w-resize",
"nw-resize",
"text",
"wait",
"help"),
189 "group" =>
"special"),
191 "values" => array (
"both",
"left",
"right",
"none"),
193 "group" =>
"special"),
195 "list-style-type.ol" => array(
196 "values" => array (
"decimal",
"lower-roman",
"upper-roman",
197 "lower-alpha",
"upper-alpha",
"lower-greek",
"hebrew",
198 "decimal-leading-zero",
"cjk-ideographic",
"hiragana",
199 "katakana",
"hiragana-iroha",
"katakana-iroha",
"none"),
202 "list-style-type.ul" => array(
203 "values" => array (
"disc",
"circle",
"square",
207 "list-style-image.ul" => array(
209 "input" =>
"background_image",
211 "list-style-position.ol" => array(
212 "values" => array (
"inside",
"outside"),
215 "list-style-position.ul" => array(
216 "values" => array (
"inside",
"outside"),
220 "border-collapse" => array(
221 "values" => array (
"collapse",
"separate"),
225 "caption-side" => array(
226 "values" => array (
"top",
"bottom",
"left",
"right"),
235 array(
"ol" => array(
"ol"),
"ul" => array(
"ul"),
236 "table" => array(
"table"),
"positioning" => array(
"h1",
"h2",
"h3",
"div",
"img",
"table"));
240 "text_block" => array(
"text_block",
"heading1",
"heading2",
"heading3"),
241 "text_inline" => array(
"text_inline"),
242 "section" => array(
"section"),
243 "link" => array(
"link"),
244 "table" => array(
"table",
"table_cell",
"table_caption"),
245 "list" => array(
"list_o",
"list_u",
"list_item"),
246 "flist" => array(
"flist_cont",
"flist_head",
"flist",
"flist_li",
"flist_a"),
247 "media" => array(
"media_cont",
"media_caption"),
248 "tabs" => array(
"va_cntr",
"va_icntr",
"va_ihead",
"va_icont",
249 "ha_cntr",
"ha_icntr",
"ha_ihead",
"ha_icont"),
250 "question" => array(
"question",
"qtitle",
"qanswer",
"qinput",
"qlinput",
"qsubmit",
"qfeedr",
"qfeedw"),
251 "page" => array(
"page_frame",
"page_cont",
"page_title",
"page_fn",
252 "page_tnav",
"page_bnav",
"page_lnav",
"page_rnav",
"page_lnavlink",
"page_rnavlink",
253 "page_lnavimage",
"page_rnavimage"),
254 "sco" => array(
"sco_title",
"sco_keyw",
"sco_desc",
"sco_desct",
"sco_obj",
"sco_objt")
259 "text_block",
"section",
"media_cont",
"table",
"table_cell",
"flist_li",
"table_caption",
261 "va_cntr",
"va_icntr",
"va_ihead",
"va_icont",
262 "ha_cntr",
"ha_icntr",
"ha_ihead",
"ha_icont"
267 "table",
"table_cell"
272 "text_block" =>
"div",
276 "text_inline" =>
"span",
280 "table_cell" =>
"td",
281 "table_caption" =>
"caption",
282 "media_cont" =>
"table",
283 "media_caption" =>
"div",
284 "sco_title" =>
"div",
288 "sco_desct" =>
"div",
293 "flist_cont" =>
"div",
294 "flist_head" =>
"div",
302 "qlinput" =>
"textarea",
303 "qsubmit" =>
"input",
306 "page_frame" =>
"table",
307 "page_cont" =>
"table",
309 "page_tnav" =>
"div",
310 "page_bnav" =>
"div",
311 "page_lnav" =>
"div",
312 "page_rnav" =>
"div",
313 "page_lnavlink" =>
"a",
314 "page_rnavlink" =>
"a",
315 "page_lnavimage" =>
"img",
316 "page_rnavimage" =>
"img",
317 "page_title" =>
"h1",
330 array (
"a" => array(
"hover"),
"div" => array(
"hover"),
"img" => array(
"hover"));
334 array(
"type" =>
"text_block",
"class" =>
"Standard"),
335 array(
"type" =>
"text_block",
"class" =>
"List"),
336 array(
"type" =>
"text_block",
"class" =>
"TableContent"),
337 array(
"type" =>
"heading1",
"class" =>
"Headline1"),
338 array(
"type" =>
"heading2",
"class" =>
"Headline2"),
339 array(
"type" =>
"heading3",
"class" =>
"Headline3"),
340 array(
"type" =>
"text_inline",
"class" =>
"Comment"),
341 array(
"type" =>
"text_inline",
"class" =>
"Emph"),
342 array(
"type" =>
"text_inline",
"class" =>
"Quotation"),
343 array(
"type" =>
"text_inline",
"class" =>
"Strong"),
344 array(
"type" =>
"text_inline",
"class" =>
"Accent"),
345 array(
"type" =>
"text_inline",
"class" =>
"Important"),
346 array(
"type" =>
"link",
"class" =>
"IntLink"),
347 array(
"type" =>
"link",
"class" =>
"ExtLink"),
348 array(
"type" =>
"link",
"class" =>
"FootnoteLink"),
349 array(
"type" =>
"media_cont",
"class" =>
"MediaContainer"),
350 array(
"type" =>
"table",
"class" =>
"StandardTable"),
351 array(
"type" =>
"media_caption",
"class" =>
"MediaCaption"),
352 array(
"type" =>
"page_frame",
"class" =>
"PageFrame"),
353 array(
"type" =>
"page_cont",
"class" =>
"PageContainer"),
354 array(
"type" =>
"page_tnav",
"class" =>
"TopNavigation"),
355 array(
"type" =>
"page_bnav",
"class" =>
"BottomNavigation"),
356 array(
"type" =>
"page_lnav",
"class" =>
"LeftNavigation"),
357 array(
"type" =>
"page_rnav",
"class" =>
"RightNavigation"),
358 array(
"type" =>
"page_lnavlink",
"class" =>
"LeftNavigationLink"),
359 array(
"type" =>
"page_rnavlink",
"class" =>
"RightNavigationLink"),
360 array(
"type" =>
"page_lnavimage",
"class" =>
"LeftNavigationImage"),
361 array(
"type" =>
"page_rnavimage",
"class" =>
"RightNavigationImage"),
362 array(
"type" =>
"page_fn",
"class" =>
"Footnote"),
363 array(
"type" =>
"page_title",
"class" =>
"PageTitle"),
364 array(
"type" =>
"sco_title",
"class" =>
"Title"),
365 array(
"type" =>
"sco_desc",
"class" =>
"Description"),
366 array(
"type" =>
"sco_desct",
"class" =>
"DescriptionTop"),
367 array(
"type" =>
"sco_keyw",
"class" =>
"Keywords"),
368 array(
"type" =>
"sco_obj",
"class" =>
"Objective"),
369 array(
"type" =>
"sco_objt",
"class" =>
"ObjectiveTop"),
370 array(
"type" =>
"list_o",
"class" =>
"NumberedList"),
371 array(
"type" =>
"list_u",
"class" =>
"BulletedList"),
372 array(
"type" =>
"list_item",
"class" =>
"StandardListItem"),
373 array(
"type" =>
"question",
"class" =>
"Standard"),
374 array(
"type" =>
"question",
"class" =>
"SingleChoice"),
375 array(
"type" =>
"question",
"class" =>
"MultipleChoice"),
376 array(
"type" =>
"question",
"class" =>
"TextQuestion"),
377 array(
"type" =>
"question",
"class" =>
"OrderingQuestion"),
378 array(
"type" =>
"question",
"class" =>
"MatchingQuestion"),
379 array(
"type" =>
"question",
"class" =>
"ImagemapQuestion"),
380 array(
"type" =>
"question",
"class" =>
"ClozeTest"),
381 array(
"type" =>
"qtitle",
"class" =>
"Title"),
382 array(
"type" =>
"qanswer",
"class" =>
"Answer"),
383 array(
"type" =>
"qinput",
"class" =>
"TextInput"),
384 array(
"type" =>
"qlinput",
"class" =>
"LongTextInput"),
385 array(
"type" =>
"qsubmit",
"class" =>
"Submit"),
386 array(
"type" =>
"qfeedr",
"class" =>
"FeedbackRight"),
387 array(
"type" =>
"qfeedw",
"class" =>
"FeedbackWrong"),
388 array(
"type" =>
"flist_cont",
"class" =>
"FileListContainer"),
389 array(
"type" =>
"flist_head",
"class" =>
"FileListHeading"),
390 array(
"type" =>
"flist",
"class" =>
"FileList"),
391 array(
"type" =>
"flist_li",
"class" =>
"FileListItem"),
392 array(
"type" =>
"flist_a",
"class" =>
"FileListItemLink")
398 "caption" =>
"table_caption",
399 "row_head" =>
"table_cell",
400 "row_foot" =>
"table_cell",
401 "col_head" =>
"table_cell",
402 "col_foot" =>
"table_cell",
403 "odd_row" =>
"table_cell",
404 "even_row" =>
"table_cell",
405 "odd_col" =>
"table_cell",
406 "even_col" =>
"table_cell"),
407 "vaccordion" => array(
408 "va_cntr" =>
"va_cntr",
409 "va_icntr" =>
"va_icntr",
410 "va_ihead" =>
"va_ihead",
411 "va_icont" =>
"va_icont"
413 "haccordion" => array(
414 "ha_cntr" =>
"ha_cntr",
415 "ha_icntr" =>
"ha_icntr",
416 "ha_ihead" =>
"ha_ihead",
417 "ha_icont" =>
"ha_icont"
435 $this->style = array();
436 if($a_call_by_reference)
438 $this->ilias->raiseError(
"Can't instantiate style object via reference id.",$this->ilias->error_obj->FATAL);
449 $this->ilias->raiseError(
"Operation ilObjStyleSheet::setRefId() not allowed.",$this->ilias->error_obj->FATAL);
466 $this->ilias->raiseError(
"Operation ilObjStyleSheet::putInTree() not allowed.",$this->ilias->error_obj->FATAL);
474 $this->ilias->raiseError(
"Operation ilObjStyleSheet::createReference() not allowed.",$this->ilias->error_obj->FATAL);
482 $this->up_to_date = $a_up_to_date;
490 return $this->up_to_date;
498 $this->scope = $a_scope;
516 $q =
"UPDATE style_data SET uptodate = ".
517 $ilDB->quote((
int) $a_up_to_date,
"integer").
518 " WHERE id = ".$ilDB->quote($a_id,
"integer");
519 $ilDB->manipulate(
$q);
529 $q =
"SELECT uptodate FROM style_data ".
530 " WHERE id = ".$ilDB->quote($a_id,
"integer");
532 $sty = $ilDB->fetchAssoc(
$res);
534 return (
boolean) $sty[
"uptodate"];
544 $q =
"UPDATE style_data SET standard = ".
545 $ilDB->quote((
int) $a_std,
"integer").
546 " WHERE id = ".$ilDB->quote($a_id,
"integer");
547 $ilDB->manipulate(
$q);
557 $q =
"UPDATE style_data SET category = ".
558 $ilDB->quote((
int) $a_scope,
"integer").
559 " WHERE id = ".$ilDB->quote($a_id,
"integer");
560 $ilDB->manipulate(
$q);
570 $q =
"SELECT * FROM style_data ".
571 " WHERE id = ".$ilDB->quote($a_id,
"integer");
573 $sty = $ilDB->fetchAssoc(
$res);
575 return (
boolean) $sty[
"standard"];
585 $q =
"UPDATE style_data SET active = ".
586 $ilDB->quote((
int) $a_active,
"integer").
587 " WHERE id = ".$ilDB->quote($a_id,
"integer");
588 $ilDB->manipulate(
$q);
598 $q =
"SELECT * FROM style_data ".
599 " WHERE id = ".$ilDB->quote($a_id,
"integer");
601 $sty = $ilDB->fetchAssoc(
$res);
603 return (
boolean) $sty[
"active"];
610 $a_include_deactivated =
false, $a_scope = 0)
614 $default_style = $ilias->getSetting(
"default_content_style_id");
617 if (!$a_include_deactivated)
619 $and_str =
" AND active = 1";
622 $q =
"SELECT * FROM style_data ".
623 " WHERE standard = 1".$and_str;
626 while($sty = $ilDB->fetchAssoc(
$res))
628 if (!$a_exclude_default_style || $default_style != $sty[
"id"])
631 if ($a_scope > 0 && $sty[
"category"] > 0)
633 if ($tree->isInTree($sty[
"category"]) &&
634 $tree->isInTree($a_scope))
636 $path = $tree->getPathId($a_scope);
637 if (!in_array($sty[
"category"], $path))
657 global $ilAccess,
$ilDB;
659 $clonable_styles = array();
661 $q =
"SELECT * FROM style_data";
662 $style_set = $ilDB->query(
$q);
663 while($style_rec = $ilDB->fetchAssoc($style_set))
666 if ($style_rec[
"standard"] == 1)
668 if ($style_rec[
"active"] == 1)
675 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
677 foreach($obj_ids as
$id)
682 if ($ilAccess->checkAccess(
"write",
"", $ref_id))
691 $clonable_styles[$style_rec[
"id"]] =
695 return $clonable_styles;
703 $this->meta_data =& $a_meta_data;
713 if (!is_object(self::$basic_style_dom))
715 self::$basic_style_dom =
new DOMDocument();
716 self::$basic_style_dom->load(self::$basic_style_file);
727 return $this->meta_data;
733 function create($a_from_style = 0, $a_import_mode =
false)
739 if ($a_from_style == 0)
756 $q =
"SELECT * FROM style_parameter WHERE style_id = ".
757 $ilDB->quote($a_from_style,
"integer");
758 $par_set = $ilDB->query(
$q);
759 while($par_rec = $ilDB->fetchAssoc($par_set))
761 $def[] = array(
"tag" => $par_rec[
"tag"],
"class" => $par_rec[
"class"],
762 "parameter" => $par_rec[
"parameter"],
"value" => $par_rec[
"value"],
763 "type" => $par_rec[
"type"]);
768 $q =
"SELECT * FROM style_char WHERE style_id = ".
769 $ilDB->quote($a_from_style,
"integer");
770 $par_set = $ilDB->query(
$q);
771 while($par_rec = $ilDB->fetchAssoc($par_set))
773 $chars[] = array(
"type" => $par_rec[
"type"],
"characteristic" => $par_rec[
"characteristic"]);
777 foreach ($def as $sty)
779 $id = $ilDB->nextId(
"style_parameter");
780 $q =
"INSERT INTO style_parameter (id, style_id, tag, class, parameter, value, type) VALUES ".
782 $ilDB->quote(
$id,
"integer").
",".
783 $ilDB->quote($this->
getId(),
"integer").
",".
784 $ilDB->quote($sty[
"tag"],
"text").
",".
785 $ilDB->quote($sty[
"class"],
"text").
",".
786 $ilDB->quote($sty[
"parameter"],
"text").
",".
787 $ilDB->quote($sty[
"value"],
"text").
",".
788 $ilDB->quote($sty[
"type"],
"text").
")";
789 $ilDB->manipulate(
$q);
793 foreach ($chars as $char)
795 $q =
"INSERT INTO style_char (style_id, type, characteristic) VALUES ".
796 "(".$ilDB->quote($this->
getId(),
"integer").
",".
797 $ilDB->quote($char[
"type"],
"text").
",".
798 $ilDB->quote($char[
"characteristic"],
"text").
")";
799 $ilDB->manipulate(
$q);
803 $q =
"INSERT INTO style_data (id, uptodate, category) VALUES ".
804 "(".$ilDB->quote($this->
getId(),
"integer").
", 0,".
805 $ilDB->quote((
int) $this->
getScope(),
"integer").
")";
806 $ilDB->manipulate(
$q);
815 $colors = $from_style->getColors();
816 foreach ($colors as $c)
818 $this->
addColor($c[
"name"], $c[
"code"]);
823 foreach ($tcts as $tct => $v)
828 $this->
addTemplate($tct, $t[
"name"], $t[
"classes"]);
850 if (empty(
$core_styles[$a_type.
".".$a_tag.
".".$a_class]))
853 $st = $ilDB->manipulateF(
854 "DELETE FROM style_char WHERE style_id = %s AND type = %s AND characteristic = %s",
855 array(
"integer",
"text",
"text"),
856 array($this->
getId(), $a_type, $a_class));
859 $st = $ilDB->manipulateF(
"DELETE FROM style_parameter WHERE style_id = %s AND tag = %s AND type = %s AND class = %s",
860 array(
"integer",
"text",
"text",
"text"),
861 array($this->
getId(), $a_tag, $a_type, $a_class));
875 $set = $ilDB->queryF(
876 "SELECT style_id FROM style_char WHERE style_id = %s AND characteristic = %s AND type = %s",
877 array(
"integer",
"text",
"text"),
878 array($this->
getId(), $a_char, $a_style_type));
879 if ($rec = $ilDB->fetchAssoc($set))
894 $ilDB->manipulateF(
"INSERT INTO style_char (style_id, type, characteristic, hide)".
895 " VALUES (%s,%s,%s,%s) ",
896 array(
"integer",
"text",
"text",
"integer"),
897 array($this->
getId(), $a_type, $a_char, $a_hidden));
912 $chars = $this->chars;
914 if (is_array($this->chars_by_type[$a_type]))
916 $chars = $this->chars_by_type[$a_type];
921 foreach ($chars as $k => $char)
923 if ($a_type ==
"" && $this->hidden_chars[$char[
"type"].
":".$char[
"class"]])
927 else if ($this->hidden_chars[$a_type.
":".$char])
942 $this->chars = $a_chars;
953 $ilDB->manipulate(
"UPDATE style_char SET ".
954 " hide = ".$ilDB->quote((
int) $a_hide,
"integer").
955 " WHERE style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
956 " type = ".$ilDB->quote($a_type,
"text").
" AND ".
957 " characteristic = ".$ilDB->quote($a_char,
"text")
968 $set = $ilDB->query(
"SELECT hide FROM style_char ".
969 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
970 " type = ".$ilDB->quote($a_type,
"text").
" AND ".
971 " characteristic = ".$ilDB->quote($a_char,
"text")
973 $rec = $ilDB->fetchAssoc($set);
989 $new_obj->setTitle($this->
getTitle().
" (".$lng->txt(
"sty_acopy").
")");
990 $new_obj->setType($this->
getType());
992 $new_obj->create($this->
getId());
994 return $new_obj->getId();
1017 $tag = explode(
".", $a_tag);
1018 $value = $avail_params[$a_par][0];
1019 $id = $ilDB->nextId(
"style_parameter");
1020 $q =
"INSERT INTO style_parameter (id,style_id, type, tag, class, parameter, value) VALUES ".
1022 $ilDB->quote(
$id,
"integer").
",".
1023 $ilDB->quote($this->
getId(),
"integer").
",".
1024 $ilDB->quote($a_type,
"text").
",".
1025 $ilDB->quote($tag[0],
"text").
",".
1026 $ilDB->quote($tag[1],
"text").
",".
1027 $ilDB->quote($a_par,
"text").
",".
1028 $ilDB->quote($value,
"text").
")";
1029 $ilDB->manipulate(
$q);
1053 if(!is_writable($sty_data_dir))
1055 $ilErr->raiseError(
"Style data directory (".$sty_data_dir
1056 .
") not writeable.", $ilErr->FATAL);
1059 $style_dir = $sty_data_dir.
"/sty_".$a_style_id;
1061 if(!@is_dir($style_dir))
1063 $ilErr->raiseError(
"Creation of style directory failed (".
1064 $style_dir.
").",$ilErr->FATAL);
1068 $im_dir = $style_dir.
"/images";
1070 if(!@is_dir($im_dir))
1072 $ilErr->raiseError(
"Creation of Import Directory failed (".
1073 $im_dir.
").", $ilErr->FATAL);
1077 $thumb_dir = $style_dir.
"/images/thumbnails";
1079 if(!@is_dir($thumb_dir))
1081 $ilErr->raiseError(
"Creation of Import Directory failed (".
1082 $thumb_dir.
").", $ilErr->FATAL);
1122 foreach($entries as $entry)
1124 if (substr($entry[
"entry"],0,1) ==
".")
1128 if ($entry[
"type"] !=
"dir")
1174 $q =
"DELETE FROM style_parameter WHERE id = ".
1175 $ilDB->quote($a_id,
"integer");
1187 $q =
"DELETE FROM style_parameter WHERE ".
1188 " style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1189 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1190 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1191 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1192 " parameter = ".$ilDB->quote($a_par,
"text");
1194 $ilDB->manipulate(
$q);
1208 $def_style = $this->ilias->getSetting(
"default_content_style_id");
1209 if ($def_style == $this->
getId())
1211 $this->ilias->deleteSetting(
"default_content_style_id");
1215 $fixed_style = $this->ilias->getSetting(
"fixed_content_style_id");
1216 if ($fixed_style == $this->
getId())
1218 $this->ilias->deleteSetting(
"fixed_content_style_id");
1222 $q =
"DELETE FROM style_parameter WHERE style_id = ".
1223 $ilDB->quote($this->
getId(),
"integer");
1224 $ilDB->manipulate(
$q);
1228 if (is_file($css_file_name))
1230 unlink($css_file_name);
1234 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
1238 $q =
"DELETE FROM style_data WHERE id = ".
1239 $ilDB->quote($this->
getId(),
"integer");
1240 $ilDB->manipulate(
$q);
1254 $q =
"SELECT * FROM style_parameter WHERE style_id = ".
1255 $ilDB->quote($this->
getId(),
"integer").
" ORDER BY tag, class, type ";
1256 $style_set = $ilDB->query(
$q);
1260 $this->style = array();
1261 while($style_rec = $ilDB->fetchAssoc($style_set))
1263 if ($style_rec[
"tag"] != $ctag || $style_rec[
"class"] != $cclass
1264 || $style_rec[
"type"] != $ctype)
1269 $this->style[] = $tag;
1273 $ctag = $style_rec[
"tag"];
1274 $cclass = $style_rec[
"class"];
1275 $ctype = $style_rec[
"type"];
1276 $tag[] = $style_rec;
1280 $this->style[] = $tag;
1283 $q =
"SELECT * FROM style_data WHERE id = ".
1284 $ilDB->quote($this->
getId(),
"integer");
1286 $sty = $ilDB->fetchAssoc(
$res);
1291 $this->chars = array();
1292 $this->chars_by_type = array();
1293 $q =
"SELECT * FROM style_char WHERE style_id = ".
1294 $ilDB->quote($this->
getId(),
"integer").
1295 " ORDER BY type ASC, characteristic ASC";
1296 $par_set = $ilDB->query(
$q);
1297 while($par_rec = $ilDB->fetchAssoc($par_set))
1299 $this->chars[] = array(
"type" => $par_rec[
"type"],
"class" => $par_rec[
"characteristic"],
"hide" => $par_rec[
"hide"]);
1300 $this->chars_by_type[$par_rec[
"type"]][] = $par_rec[
"characteristic"];
1301 if ($par_rec[
"hide"])
1303 $this->hidden_chars[$par_rec[
"type"].
":".$par_rec[
"characteristic"]] =
true;
1315 if ($a_target_file ==
"")
1321 $css_file_name = $a_target_file;
1323 $css_file = fopen($css_file_name,
"w");
1325 $page_background =
"";
1329 fwrite ($css_file, $tag[0][
"tag"].
".ilc_".$tag[0][
"type"].
"_".$tag[0][
"class"].
"\n");
1330 if ($tag[0][
"tag"] =
"td")
1332 fwrite ($css_file,
",th".
".ilc_".$tag[0][
"type"].
"_".$tag[0][
"class"].
"\n");
1334 fwrite ($css_file,
"{\n");
1337 $t_border = array();
1339 foreach($tag as $par)
1341 $cur_par = $par[
"parameter"];
1342 $cur_val = $par[
"value"];
1345 if (is_int(strpos($cur_par,
"color")) && substr(trim($cur_val), 0, 1) ==
"!")
1350 if ($tag[0][
"type"] ==
"table" && is_int(strpos($par[
"parameter"],
"border")))
1352 $t_border[$cur_par] = $cur_val;
1355 if (in_array($cur_par, array(
"background-image",
"list-style-image")))
1357 if (is_int(strpos($cur_val,
"/")))
1359 $cur_val =
"url(".$cur_val.
")";
1363 if ($a_image_dir ==
"")
1365 $cur_val =
"url(../sty/sty_".$this->getId().
"/images/".$cur_val.
")";
1369 $cur_val =
"url(".$a_image_dir.
"/".$cur_val.
")";
1374 if ($cur_par ==
"opacity")
1376 $cur_val = ((int) $cur_val) / 100;
1379 fwrite ($css_file,
"\t".$cur_par.
": ".$cur_val.
";\n");
1382 if ($cur_par ==
"min-height")
1384 fwrite ($css_file,
"\t".
"height".
": ".
"auto !important".
";\n");
1385 fwrite ($css_file,
"\t".
"height".
": ".$cur_val.
";\n");
1389 if ($cur_par ==
"opacity")
1391 fwrite ($css_file,
"\t".
'-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity='.($cur_val * 100).
')"'.
";\n");
1392 fwrite ($css_file,
"\t".
'filter: alpha(opacity='.($cur_val * 100).
')'.
";\n");
1393 fwrite ($css_file,
"\t".
'-moz-opacity: '.$cur_val.
";\n");
1397 if ($tag[0][
"tag"] ==
"div" && $tag[0][
"class"] ==
"Page"
1398 && $cur_par ==
"background-color")
1400 $page_background = $cur_val;
1403 fwrite ($css_file,
"}\n");
1404 fwrite ($css_file,
"\n");
1424 if ($page_background !=
"")
1426 fwrite ($css_file,
"td.ilc_Page\n");
1427 fwrite ($css_file,
"{\n");
1428 fwrite ($css_file,
"\t".
"background-color: ".$page_background.
";\n");
1429 fwrite ($css_file,
"}\n");
1448 $fixed_style = $ilSetting->get(
"fixed_content_style_id");
1449 if ($fixed_style > 0)
1451 $a_style_id = $fixed_style;
1455 if ($a_style_id <= 0)
1457 $a_style_id = $ilSetting->get(
"default_content_style_id");
1477 $rand = rand(1,999999);
1481 $fixed_style = $ilias->getSetting(
"fixed_content_style_id");
1482 if ($fixed_style > 0)
1484 $a_style_id = $fixed_style;
1488 if ($a_style_id <= 0)
1490 $a_style_id = $ilias->getSetting(
"default_content_style_id");
1503 "/css/style_".$a_style_id.
".css?dummy=$rand";
1507 return "./Services/COPage/css/content.css";
1518 return "./Services/COPage/css/print_content.css";
1528 return "./Services/COPage/css/syntaxhighlight.css";
1538 return "./Services/COPage/css/placeholder.css";
1549 $q =
"UPDATE style_data ".
1550 "SET category = ".$ilDB->quote((
int) $this->
getScope(),
"integer").
1551 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
1552 $ilDB->manipulate(
$q);
1565 $q =
"UPDATE style_parameter SET VALUE = ".
1566 $ilDB->quote($a_value,
"text").
" WHERE id = ".
1567 $ilDB->quote($a_id,
"integer");
1568 $style_set = $ilDB->manipulate(
$q);
1584 $q =
"SELECT * FROM style_parameter WHERE ".
1585 " style_id = ".$ilDB->quote($style_id,
"integer").
" AND ".
1586 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1587 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1588 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1589 " parameter = ".$ilDB->quote($a_par,
"text");
1591 $set = $ilDB->query(
$q);
1593 if ($rec = $set->fetchRow())
1595 $q =
"UPDATE style_parameter SET ".
1596 " value = ".$ilDB->quote($a_val,
"text").
" WHERE ".
1597 " style_id = ".$ilDB->quote($style_id,
"integer").
" AND ".
1598 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1599 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1600 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1601 " parameter = ".$ilDB->quote($a_par,
"text");
1603 $ilDB->manipulate(
$q);
1607 $id = $ilDB->nextId(
"style_parameter");
1608 $q =
"INSERT INTO style_parameter (id, value, style_id, tag, class, type, parameter) VALUES ".
1610 $ilDB->quote(
$id,
"integer").
",".
1611 $ilDB->quote($a_val,
"text").
",".
1612 " ".$ilDB->quote($this->
getId(),
"integer").
",".
1613 " ".$ilDB->quote($a_tag,
"text").
",".
1614 " ".$ilDB->quote($a_class,
"text").
",".
1615 " ".$ilDB->quote($a_type,
"text").
",".
1616 " ".$ilDB->quote($a_par,
"text").
")";
1618 $ilDB->manipulate(
$q);
1636 $this->style = $a_style;
1648 return str_replace(
"&",
"&", $a_str);
1656 $xml.=
"<StyleSheet>\n";
1659 $xml.=
"<Title>".$this->handleXmlString($this->
getTitle()).
"</Title>";
1660 $xml.=
"<Description>".$this->handleXmlString($this->
getDescription()).
"</Description>\n";
1663 foreach($this->chars as $char)
1665 $xml.=
"<Style Tag=\"".ilObjStyleSheet::_determineTag($char[
"type"]).
1666 "\" Type=\"".$char[
"type"].
"\" Class=\"".$char[
"class"].
"\">\n";
1667 foreach($this->style as
$style)
1669 if ($style[0][
"type"] == $char[
"type"] && $style[0][
"class"] == $char[
"class"])
1671 foreach($style as $tag)
1673 $xml.=
"<StyleParameter Name=\"".$tag[
"parameter"].
"\" Value=\"".$tag[
"value"].
"\"/>\n";
1677 $xml.=
"</Style>\n";
1683 $xml.=
"<StyleColor Name=\"".$color[
"name"].
"\" Code=\"".$color[
"code"].
"\"/>\n";
1688 foreach ($tcts as $tct => $v)
1694 $xml.=
"<StyleTemplate Type=\"".$tct.
"\" Name=\"".$t[
"name"].
"\">\n";
1695 foreach ($t[
"classes"] as $ct => $c)
1699 $xml.=
"<StyleTemplateClass ClassType=\"".$ct.
"\" Class=\"".$c.
"\"/>\n";
1702 $xml.=
"</StyleTemplate>\n";
1707 $xml.=
"</StyleSheet>";
1720 if(!is_writable($sty_data_dir))
1722 $this->ilias->raiseError(
"Style data directory (".$sty_data_dir
1723 .
") not writeable.",$this->ilias->error_obj->FATAL);
1726 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
1728 if(!@is_dir($style_dir))
1730 $this->ilias->raiseError(
"Creation of style directory failed (".
1731 $style_dir.
").",$this->ilias->error_obj->FATAL);
1735 $ex_dir = $style_dir.
"/export";
1737 if(!@is_dir($ex_dir))
1739 $this->ilias->raiseError(
"Creation of Import Directory failed (".
1740 $ex_dir.
").",$this->ilias->error_obj->FATAL);
1752 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
1754 $ex_dir = $style_dir.
"/export";
1756 if (is_dir($ex_dir))
1771 if(!is_writable($ex_sub_dir))
1773 $this->ilias->raiseError(
"Style data directory (".$ex_sub_dir
1774 .
") not writeable.",$this->ilias->error_obj->FATAL);
1776 $ex_sub_images_dir = $ex_sub_dir.
"/images";
1778 if(!is_writable($ex_sub_images_dir))
1780 $this->ilias->raiseError(
"Style data directory (".$ex_sub_images_dir
1781 .
") not writeable.",$this->ilias->error_obj->FATAL);
1790 $this->export_sub_dir = $a_dir;
1798 if ($this->export_sub_dir ==
"")
1800 return "sty_".$this->getId();
1804 return $this->export_sub_dir;
1818 $this->
exportXML($ex_dir.
"/".$this->getExportSubDir());
1821 $ex_dir.
"/".$this->getExportSubDir().
"/images");
1822 if (is_file($ex_dir.
"/".$this->getExportSubDir().
".zip"))
1824 unlink($ex_dir.
"/".$this->getExportSubDir().
".zip");
1837 $file = $a_dir.
"/style.xml";
1840 if (!($fp = @fopen(
$file,
"w")))
1842 die (
"<b>Error</b>: Could not open \"".
$file.
"\" for writing".
1843 " in <b>".__FILE__.
"</b> on line <b>".__LINE__.
"</b><br />");
1850 fwrite($fp, $this->
getXML());
1864 if(!is_writable($sty_data_dir))
1866 $this->ilias->raiseError(
"Style data directory (".$sty_data_dir
1867 .
") not writeable.",$this->ilias->error_obj->FATAL);
1870 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
1872 if(!@is_dir($style_dir))
1874 $this->ilias->raiseError(
"Creation of style directory failed (".
1875 $style_dir.
").",$this->ilias->error_obj->FATAL);
1879 $im_dir = $style_dir.
"/import";
1881 if(!@is_dir($im_dir))
1883 $this->ilias->raiseError(
"Creation of Import Directory failed (".
1884 $im_dir.
").",$this->ilias->error_obj->FATAL);
1893 function import($a_file)
1900 if (is_array($a_file))
1903 $a_file[
"name"], $im_dir.
"/".$a_file[
"name"]);
1908 $pi = pathinfo($a_file);
1915 if (strtolower(
$file[
"extension"] ==
"zip"))
1918 $subdir = basename(
$file[
"basename"],
".".
$file[
"extension"]);
1919 if (!is_dir($im_dir.
"/".$subdir))
1923 $xml_file = $im_dir.
"/".$subdir.
"/style.xml";
1936 if (is_dir($im_dir.
"/".$subdir.
"/images"))
1939 $this->getImagesDirectory());
1954 $this->is_3_10_skin =
false;
1956 if (!$a_skip_parent_create)
1960 include_once(
"./Services/Style/classes/class.ilStyleImportParser.php");
1962 $importParser->startParsing();
1965 foreach ($this->style as
$style)
1967 foreach($style as $tag)
1969 $id = $ilDB->nextId(
"style_parameter");
1970 $q =
"INSERT INTO style_parameter (id,style_id, tag, class, parameter, type, value) VALUES ".
1972 $ilDB->quote(
$id,
"integer").
",".
1973 $ilDB->quote($this->
getId(),
"integer").
",".
1974 $ilDB->quote($tag[
"tag"],
"text").
",".
1975 $ilDB->quote($tag[
"class"],
"text").
",".
1976 $ilDB->quote($tag[
"parameter"],
"text").
",".
1977 $ilDB->quote($tag[
"type"],
"text").
",".
1978 $ilDB->quote($tag[
"value"],
"text").
")";
1980 $ilDB->manipulate(
$q);
1985 $this->is_3_10_skin =
true;
1986 if (is_array($this->chars))
1988 foreach ($this->chars as $char)
1990 if ($char[
"type"] !=
"")
1992 $q =
"INSERT INTO style_char (style_id, type, characteristic) VALUES ".
1993 "(".$ilDB->quote($this->
getId(),
"integer").
",".
1994 $ilDB->quote($char[
"type"],
"text").
",".
1995 $ilDB->quote($char[
"class"],
"text").
")";
1996 $ilDB->manipulate(
$q);
1997 $this->is_3_10_skin =
false;
2003 $q =
"INSERT INTO style_data (id, uptodate) VALUES ".
2004 "(".$ilDB->quote($this->
getId(),
"integer").
", 0)";
2005 $ilDB->manipulate(
$q);
2010 if ($this->is_3_10_skin)
2024 foreach (self::$parameter as
$parameter => $props)
2033 $input = self::$parameter[$par][
"input"];
2039 $subpar = self::$parameter[$par][
"subpar"];
2050 foreach (self::$parameter as $k => $v)
2052 if (is_array(self::$filtered_groups[$v[
"group"]]) &&
2053 !in_array($a_tag, self::$filtered_groups[$v[
"group"]]))
2069 if ($a_no_percentage)
2078 return self::$parameter[$par][
"values"];
2093 return in_array($a_type, self::$expandable_types);
2098 return in_array($a_type, self::$hideable_types);
2103 foreach (self::$style_super_types as $s =>
$t)
2105 if (in_array($a_type,
$t))
2121 $c_styles = array();
2122 foreach (self::$core_styles as $cstyle)
2125 = array(
"type" => $cstyle[
"type"],
2127 "class" => $cstyle[
"class"]);
2137 if ($a_template_type ==
"")
2142 return self::$templates[$a_template_type];
2148 return self::$pseudo_classes[$tag];
2153 return self::$templates[
$t][$k];
2158 return self::$assigned_tags[$a_type];
2167 foreach(self::$parameter as $p => $v)
2169 $pars[$p] = $v[
"values"];
2181 $styles = array(array(
"id" => $a_id));
2192 if ($a_styles ==
"")
2198 $styles = $a_styles;
2204 $core_images = array();
2206 if (is_dir($core_dir))
2208 $dir = opendir($core_dir);
2211 if (substr(
$file, 0, 1) !=
"." && is_file($core_dir.
"/".
$file))
2213 $core_images[] =
$file;
2218 foreach ($styles as
$style)
2225 $set = $ilDB->queryF(
"SELECT * FROM style_char WHERE style_id = %s ".
2226 "AND type = %s AND characteristic = %s",
2227 array(
"integer",
"text",
"text"),
2228 array(
$id, $cs[
"type"], $cs[
"class"]));
2231 if (!($rec = $ilDB->fetchAssoc($set)))
2234 "INSERT INTO style_char (style_id, type, characteristic) ".
2235 " VALUES (%s,%s,%s) ",
2236 array(
"integer",
"text",
"text"),
2237 array(
$id, $cs[
"type"], $cs[
"class"]));
2239 $xpath =
new DOMXPath($bdom);
2240 $par_nodes = $xpath->query(
"/StyleSheet/Style[@Tag = '".$cs[
"tag"].
"' and @Type='".
2241 $cs[
"type"].
"' and @Class='".$cs[
"class"].
"']/StyleParameter");
2242 foreach ($par_nodes as $par_node)
2245 $set = $ilDB->queryF(
"SELECT * FROM style_parameter WHERE style_id = %s ".
2246 "AND type = %s AND class = %s AND tag = %s AND parameter = %s",
2247 array(
"integer",
"text",
"text",
"text",
"text"),
2248 array(
$id, $cs[
"type"], $cs[
"class"],
2249 $cs[
"tag"], $par_node->getAttribute(
"Name")));
2252 if (!($rec = $ilDB->fetchAssoc($set)))
2254 $spid = $ilDB->nextId(
"style_parameter");
2255 $st = $ilDB->manipulateF(
"INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value) ".
2256 " VALUES (%s,%s,%s,%s,%s,%s,%s)",
2257 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2258 array($spid,
$id, $cs[
"type"], $cs[
"class"], $cs[
"tag"],
2259 $par_node->getAttribute(
"Name"), $par_node->getAttribute(
"Value")));
2268 reset($core_images);
2269 foreach($core_images as $cim)
2271 if (!is_file($imdir.
"/".$cim))
2273 copy($core_dir.
"/".$cim, $imdir.
"/".$cim);
2298 $st = $ilDB->prepareManip(
"UPDATE style_char SET type = ? WHERE characteristic = ?".
2299 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2300 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2301 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2302 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2303 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2304 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2305 $ilDB->execute($st, array(
"page_cont",
"Page", $this->
getId()));
2308 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET type = ? WHERE class = ?".
2309 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2310 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2311 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2312 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2313 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2314 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2315 $ilDB->execute($st, array(
"table",
"Page", $this->
getId()));
2317 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET tag = ? WHERE class = ?".
2318 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2319 $ilDB->execute($st, array(
"div",
"MediaCaption", $this->
getId()));
2322 $st = $ilDB->prepareManip(
"UPDATE style_char SET characteristic = ? WHERE characteristic = ?".
2323 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2324 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2325 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2328 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET class = ? WHERE class = ?".
2329 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2330 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2331 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2334 $st = $ilDB->prepareManip(
"DELETE FROM style_char WHERE type = ?".
2335 " AND style_id = ? ", array(
"text",
"integer"));
2336 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2337 $st = $ilDB->prepareManip(
"DELETE FROM style_parameter WHERE type = ?".
2338 " AND style_id = ? ", array(
"text",
"integer"));
2339 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2356 $add_str =
" AND style_id = ".$ilDB->quote($a_id,
"integer");
2359 $set = $ilDB->query(
$q =
"SELECT DISTINCT style_id, tag, class FROM style_parameter WHERE ".
2360 $ilDB->equals(
"type",
"",
"text",
true).
" ".$add_str);
2362 while ($rec = $ilDB->fetchAssoc($set))
2366 switch ($rec[
"tag"])
2370 if (in_array($rec[
"class"], array(
"Headline3",
"Headline1",
2371 "Headline2",
"TableContent",
"List",
"Standard",
"Remark",
2372 "Additional",
"Mnemonic",
"Citation",
"Example")))
2374 $types[] =
"text_block";
2376 if (in_array($rec[
"class"], array(
"Block",
"Remark",
2377 "Additional",
"Mnemonic",
"Example",
"Excursus",
"Special")))
2379 $types[] =
"section";
2381 if (in_array($rec[
"class"], array(
"Page",
"Footnote",
"PageTitle",
"LMNavigation")))
2388 $types[] =
"table_cell";
2392 if (in_array($rec[
"class"], array(
"ExtLink",
"IntLink",
"FootnoteLink")))
2399 $types[] =
"text_inline";
2408 foreach ($types as
$t)
2411 $set4 = $ilDB->queryF(
"SELECT * FROM style_char ".
2412 " WHERE style_id = %s AND type = %s AND characteristic = %s",
2413 array(
"integer",
"text",
"text"),
2414 array($rec[
"style_id"], $t, $rec[
"class"]));
2415 if ($rec4 = $ilDB->fetchAssoc($set4))
2422 $ilDB->manipulateF(
"INSERT INTO style_char ".
2423 " (style_id, type, characteristic) VALUES ".
2425 array(
"integer",
"text",
"text"),
2426 array($rec[
"style_id"], $t, $rec[
"class"]));
2431 if ($rec[
"type"] ==
"")
2433 if (count($types) > 0)
2435 $ilDB->manipulateF(
"UPDATE style_parameter SET type = %s ".
2436 " WHERE style_id = %s AND class = %s AND ".$ilDB->equals(
"type",
"",
"text",
true),
2437 array(
"text",
"integer",
"text"),
2438 array($types[0], $rec[
"style_id"], $rec[
"class"]));
2442 if ($types[0] ==
"link")
2444 $ilDB->manipulateF(
"UPDATE style_parameter SET type = %s ".
2445 " WHERE style_id = %s AND (class = %s OR class = %s) AND ".$ilDB->equals(
"type",
"",
"text",
true),
2446 array(
"text",
"integer",
"text",
"text"),
2447 array($types[0], $rec[
"style_id"], $rec[
"class"].
":visited",
2448 $rec[
"class"].
":hover"));
2452 if (count($types) == 2)
2456 $set2 = $ilDB->queryF(
"SELECT * FROM style_parameter ".
2457 " WHERE style_id = %s AND class = %s AND type = %s",
2458 array(
"integer",
"text",
"text"),
2459 array($rec[
"style_id"], $rec[
"class"], $types[0]));
2460 while ($rec2 = $ilDB->fetchAssoc($set2))
2463 $set3 = $ilDB->queryF(
"SELECT * FROM style_parameter ".
2464 " WHERE style_id = %s AND tag = %s AND class = %s AND type = %s AND parameter = %s",
2465 array(
"integer",
"text",
"text",
"text",
"text"),
2466 array($rec[
"style_id"], $rec[
"tag"], $rec[
"class"], $types[1], $rec[
"parameter"]));
2467 if ($rec3 = $ilDB->fetchAssoc($set3))
2473 $nid = $ilDB->nextId(
"style_parameter");
2474 $ilDB->manipulateF(
"INSERT INTO style_parameter ".
2475 " (id, style_id, tag, class, parameter, value, type) VALUES ".
2476 " (%s, %s,%s,%s,%s,%s,%s) ",
2477 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2478 array($nid, $rec2[
"style_id"], $rec2[
"tag"], $rec2[
"class"],
2479 $rec2[
"parameter"], $rec2[
"value"], $types[1]));
2494 $classes = array(
"Example",
"Additional",
"Citation",
"Mnemonic",
"Remark");
2495 $pars = array(
"margin-top",
"margin-bottom");
2497 foreach ($classes as $curr_class)
2499 foreach ($pars as $curr_par)
2501 $res2 = $ilDB->queryF(
"SELECT id FROM style_parameter WHERE style_id = %s".
2502 " AND tag = %s AND class= %s AND parameter = %s",
2503 array(
"integer",
"text",
"text",
"text"),
2504 array($a_id,
"p", $curr_class, $curr_par));
2505 if ($row2 = $ilDB->fetchAssoc($res2))
2507 $ilDB->manipulateF(
"UPDATE style_parameter SET value= %s WHERE id = %s",
2508 array(
"text",
"integer"),
2509 array(
"10px", $row2[
"id"]));
2513 $nid = $ilDB->nextId(
"style_parameter");
2514 $ilDB->manipulateF(
"INSERT INTO style_parameter ".
2515 "(id, style_id, tag, class, parameter,value) VALUES (%s,%s,%s,%s,%s,%s)",
2516 array(
"integer",
"integer",
"text",
"text",
"text",
"text"),
2517 array($nid, $a_id,
"div", $curr_class, $curr_par,
"10px"));
2522 $ilDB->manipulateF(
"UPDATE style_parameter SET tag = %s WHERE tag = %s and style_id = %s",
2523 array(
"text",
"text",
"integer"),
2524 array(
"div",
"p", $a_id));
2536 $set = $ilDB->query(
"SELECT * FROM style_color WHERE ".
2537 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" ".
2538 "ORDER BY color_name");
2541 while ($rec = $ilDB->fetchAssoc($set))
2544 "name" => $rec[
"color_name"],
2545 "code" => $rec[
"color_code"]
2559 $ilDB->manipulate(
"INSERT INTO style_color (style_id, color_name, color_code)".
2561 $ilDB->quote($this->getId(),
"integer").
",".
2562 $ilDB->quote($a_name,
"text").
",".
2563 $ilDB->quote($a_code,
"text").
2576 $ilDB->manipulate(
"UPDATE style_color SET ".
2577 "color_name = ".$ilDB->quote($a_new_name,
"text").
", ".
2578 "color_code = ".$ilDB->quote($a_code,
"text").
2579 " WHERE style_id = ".$ilDB->quote($this->
getId(),
"integer").
2580 " AND color_name = ".$ilDB->quote($a_name,
"text"));
2584 if ($a_name != $a_new_name)
2586 $set = $ilDB->query(
"SELECT * FROM style_parameter ".
2587 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
2589 " parameter = ".$ilDB->quote(
"background-color",
"text").
" OR ".
2590 " parameter = ".$ilDB->quote(
"color",
"text").
" OR ".
2591 " parameter = ".$ilDB->quote(
"border-color",
"text").
" OR ".
2592 " parameter = ".$ilDB->quote(
"border-top-color",
"text").
" OR ".
2593 " parameter = ".$ilDB->quote(
"border-bottom-color",
"text").
" OR ".
2594 " parameter = ".$ilDB->quote(
"border-left-color",
"text").
" OR ".
2595 " parameter = ".$ilDB->quote(
"border-right-color",
"text").
2597 while ($rec = $ilDB->fetchAssoc($set))
2599 if ($rec[
"value"] ==
"!".$a_name ||
2600 is_int(strpos($rec[
"value"],
"!".$a_name.
"(")))
2604 $rec[
"parameter"], str_replace($a_name, $a_new_name, $rec[
"value"]), $rec[
"type"]);
2617 $ilDB->manipulate(
"DELETE FROM style_color WHERE ".
2618 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2619 " color_name = ".$ilDB->quote($a_name,
"text"));
2629 $set = $ilDB->query(
"SELECT * FROM style_color WHERE ".
2630 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2631 "color_name = ".$ilDB->quote($a_color_name,
"text"));
2632 if ($rec = $ilDB->fetchAssoc($set))
2646 $pos = strpos($a_name,
"(");
2649 $a_i = substr($a_name, $pos + 1);
2650 $a_i = str_replace(
")",
"", $a_i);
2651 $a_name = substr($a_name, 0, $pos);
2654 $set = $ilDB->query(
"SELECT color_code FROM style_color WHERE ".
2655 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2656 " color_name = ".$ilDB->quote($a_name,
"text"));
2657 if ($rec = $ilDB->fetchAssoc($set))
2661 return "#".$rec[
"color_code"];
2665 return "#".ilObjStyleSheet::_getColorFlavor($rec[
"color_code"],
2681 $hls[
"l"] = $hls[
"l"] + ((255 - $hls[
"l"]) * ($a_i / 100));
2685 $hls[
"l"] = $hls[
"l"] - (($hls[
"l"]) * (-$a_i / 100));
2690 foreach ($rgb as $k => $v)
2692 $rgb[$k] = str_pad(dechex($v), 2,
"0", STR_PAD_LEFT);
2695 return $rgb[
"r"].$rgb[
"g"].$rgb[
"b"];
2703 $r[
"r"] = substr($a_rgb, 0, 2);
2704 $r[
"g"] = substr($a_rgb, 2, 2);
2705 $r[
"b"] = substr($a_rgb, 4, 2);
2709 $r[
"r"] = (int) hexdec($r[
"r"]);
2710 $r[
"g"] = (int) hexdec($r[
"g"]);
2711 $r[
"b"] = (int) hexdec($r[
"b"]);
2722 $r = $a_rgb[
"r"] / 255;
2723 $g = $a_rgb[
"g"] / 255;
2724 $b = $a_rgb[
"b"] / 255;
2727 $max = max($r,$g,$b);
2728 $min = min($r,$g,$b);
2731 $l = ($max + $min) / 2;
2742 $s = ($max - $min) / ($max + $min);
2746 $s = ($max - $min) / (2.0 - $max - $min);
2751 $h = ($g - $b) / ($max - $min);
2753 else if ($g == $max)
2755 $h = 2.0 + ($b - $r) / ($max - $min);
2757 else if ($b == $max)
2759 $h = 4.0 + ($r - $g) / ($max - $min);
2763 $hls[
"h"] = round(($h / 6) * 255);
2764 $hls[
"l"] = round(
$l * 255);
2765 $hls[
"s"] = round($s * 255);
2775 $h = $a_hls[
"h"] / 255;
2776 $l = $a_hls[
"l"] / 255;
2777 $s = $a_hls[
"s"] / 255;
2779 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = 0;
2784 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] =
$l;
2791 $temp2 =
$l * (1.0 + $s);
2795 $temp2 =
$l + $s -
$l * $s;
2798 $temp1 = 2.0 *
$l - $temp2;
2801 # For each of R, G, B, compute another temporary value, temp3, as follows:
2802 foreach ($rgb as $k => $v)
2807 $temp3 = $h + 1.0 / 3.0;
2815 $temp3 = $h - 1.0/3.0;
2820 $temp3 = $temp3 + 1.0;
2824 $temp3 = $temp3 - 1.0;
2827 if (6.0 * $temp3 < 1)
2829 $rgb[$k] = $temp1 + ($temp2 - $temp1) * 6.0 * $temp3;
2831 else if (2.0 * $temp3 < 1)
2835 else if (3.0 * $temp3 < 2)
2837 $rgb[$k] = $temp1 + ($temp2 - $temp1) * ((2.0/3.0) - $temp3) * 6.0;
2846 $rgb[
"r"] = round($rgb[
"r"] * 255);
2847 $rgb[
"g"] = round($rgb[
"g"] * 255);
2848 $rgb[
"b"] = round($rgb[
"b"] * 255);
2864 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
2865 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2866 "temp_type = ".$ilDB->quote($a_type,
"text").
" ".
2870 while ($rec = $ilDB->fetchAssoc($set))
2885 $set = $ilDB->query(
"SELECT * FROM style_template_class WHERE ".
2886 "template_id = ".$ilDB->quote($a_tid,
"integer"));
2889 while ($rec = $ilDB->fetchAssoc($set))
2891 $key = $rec[
"class_type"];
2892 $class[
$key] = $rec[
"class"];
2906 $tid = $ilDB->nextId(
"style_template");
2907 $ilDB->manipulate(
$q =
"INSERT INTO style_template ".
2908 "(id, style_id, name, temp_type)".
2910 $ilDB->quote($tid,
"integer").
",".
2911 $ilDB->quote($this->
getId(),
"integer").
",".
2912 $ilDB->quote($a_name,
"text").
",".
2913 $ilDB->quote($a_type,
"text").
2916 foreach ($a_classes as
$t => $c)
2918 $ilDB->manipulate(
$q =
"INSERT INTO style_template_class ".
2919 "(template_id, class_type, class)".
2921 $ilDB->quote($tid,
"integer").
",".
2922 $ilDB->quote(
$t,
"text").
",".
2923 $ilDB->quote($c,
"text").
2927 include_once(
"./Services/Style/classes/class.ilObjStyleSheetGUI.php");
2941 $ilDB->manipulate(
"UPDATE style_template SET ".
2942 "name = ".$ilDB->quote($a_name,
"text").
2943 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
2945 $ilDB->manipulate(
"DELETE FROM style_template_class WHERE ".
2946 "template_id = ".$ilDB->quote($a_t_id,
"integer")
2948 foreach ($a_classes as
$t => $c)
2950 $ilDB->manipulate(
$q =
"INSERT INTO style_template_class ".
2951 "(template_id, class_type, class)".
2953 $ilDB->quote($a_t_id,
"integer").
",".
2954 $ilDB->quote(
$t,
"text").
",".
2955 $ilDB->quote($c,
"text").
2968 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
2969 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2970 "name = ".$ilDB->quote($a_template_name,
"text"));
2971 if ($rec = $ilDB->fetchAssoc($set))
2985 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
2986 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" ".
2987 " AND id = ".$ilDB->quote($a_t_id,
"integer"));
2989 if ($rec = $ilDB->fetchAssoc($set))
3006 $set = $ilDB->query(
"SELECT name FROM style_template WHERE ".
3007 " id = ".$ilDB->quote($a_t_id,
"integer"));
3009 if ($rec = $ilDB->fetchAssoc($set))
3011 return $rec[
"name"];
3024 $tag =
"<StyleTemplates>";
3026 $ttypes = array(
"table",
"vaccordion",
"haccordion");
3028 foreach ($ttypes as $ttype)
3047 $tag.=
'<StyleTemplate Name="'.$t[
"name"].
'">';
3049 foreach ($atts as
$type => $t)
3051 if ($c[
$type] !=
"")
3053 $tag.=
'<StyleClass Type="'.$type.
'" Value="'.$c[
$type].
'" />';
3057 $tag.=
"</StyleTemplate>";
3061 $tag.=
"</StyleTemplates>";
3073 $a_preview_html = str_replace(
' width=""',
"", $a_preview_html);
3074 $a_preview_html = str_replace(
' valign="top"',
"", $a_preview_html);
3075 $a_preview_html = str_replace(
'<div class="ilc_text_block_TableContent">',
"<div>", $a_preview_html);
3078 if (strlen($a_preview_html) > 4000)
3081 $a_preview_html =
"";
3083 $ilDB->manipulate(
"UPDATE style_template SET ".
3084 "preview = ".$ilDB->quote($a_preview_html,
"text").
3085 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3095 $set = $ilDB->query(
"SELECT preview FROM style_template ".
3096 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3097 if ($rec = $ilDB->fetchAssoc($set))
3099 return $rec[
"preview"];
3112 $set = $ilDB->query(
"SELECT id FROM style_template ".
3113 " WHERE style_id = ".$ilDB->quote($a_style_id,
"integer").
3114 " AND name = ".$ilDB->quote($a_name,
"text"));
3115 if ($rec = $ilDB->fetchAssoc($set))
3130 $ilDB->manipulate(
"DELETE FROM style_template WHERE ".
3131 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3132 " id = ".$ilDB->quote($a_t_id,
"integer"));
3134 $ilDB->manipulate(
"DELETE FROM style_template_class WHERE ".
3135 "template_id = ".$ilDB->quote($a_t_id,
"integer")
3147 $ilDB->manipulate(
"DELETE FROM style_setting WHERE ".
3148 " style_id = ".$ilDB->quote($this->getId(),
"integer").
3149 " AND name = ".$ilDB->quote($a_name,
"text")
3152 $ilDB->manipulate(
"INSERT INTO style_setting ".
3153 "(style_id, name, value) VALUES (".
3154 $ilDB->quote($this->getId(),
"integer").
",".
3155 $ilDB->quote($a_name,
"text").
",".
3156 $ilDB->quote($a_value,
"text").
3167 $set = $ilDB->query(
"SELECT value FROM style_setting ".
3168 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
3169 " AND name = ".$ilDB->quote($a_name,
"text")
3171 $rec = $ilDB->fetchAssoc($set);
3173 return $rec[
"value"];
3183 $ilDB->replace(
"style_usage", array(
3184 "obj_id" => array(
"integer", (
int) $a_obj_id)),
3186 "style_id" => array(
"integer", (
int) $a_style_id))
3197 $set = $ilDB->query(
"SELECT style_id FROM style_usage ".
3198 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")
3200 $rec = $ilDB->fetchAssoc($set);
3202 return (
int) $rec[
"style_id"];