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",
"a"));
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",
"iim",
"marker"),
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 "qimg",
"qordul",
"qordli",
"qimgd",
"qetitem",
"qetcorr",
"qover"),
252 "page" => array(
"page_frame",
"page_cont",
"page_title",
"page_fn",
"page",
253 "page_tnav",
"page_bnav",
"page_lnav",
"page_rnav",
"page_lnavlink",
"page_rnavlink",
254 "page_lnavimage",
"page_rnavimage"),
255 "glo" => array(
"glo_overlay",
"glo_ovtitle",
"glo_ovclink",
"glo_ovuglink",
"glo_ovuglistlink"),
256 "sco" => array(
"sco_title",
"sco_keyw",
"sco_desc",
"sco_desct",
"sco_obj",
"sco_objt",
"sco_fmess"),
257 "rte" => array(
"rte_menu",
"rte_mlink",
"rte_tree",
"rte_node",
"rte_tlink",
"rte_status",
258 "rte_tul",
"rte_tli",
"rte_texp",
"rte_tclink",
"rte_drag")
263 "text_block",
"section",
"media_cont",
"table",
"table_cell",
"flist_li",
"table_caption",
265 "va_cntr",
"va_icntr",
"va_ihead",
"va_icont",
266 "ha_cntr",
"ha_icntr",
"ha_ihead",
"ha_icont"
271 "table",
"table_cell"
276 "text_block" =>
"div",
280 "text_inline" =>
"span",
284 "table_cell" =>
"td",
285 "table_caption" =>
"caption",
286 "media_cont" =>
"table",
287 "media_caption" =>
"div",
290 "glo_overlay" =>
"div",
291 "glo_ovtitle" =>
"h1",
292 "glo_ovclink" =>
"a",
293 "glo_ovuglink" =>
"a",
294 "glo_ovuglistlink" =>
"a",
295 "sco_title" =>
"div",
299 "sco_desct" =>
"div",
301 "sco_fmess" =>
"div",
308 "rte_status" =>
"div",
316 "flist_cont" =>
"div",
317 "flist_head" =>
"div",
331 "qlinput" =>
"textarea",
332 "qsubmit" =>
"input",
336 "page_frame" =>
"table",
337 "page_cont" =>
"table",
340 "page_tnav" =>
"div",
341 "page_bnav" =>
"div",
342 "page_lnav" =>
"div",
343 "page_rnav" =>
"div",
344 "page_lnavlink" =>
"a",
345 "page_rnavlink" =>
"a",
346 "page_lnavimage" =>
"img",
347 "page_rnavimage" =>
"img",
348 "page_title" =>
"h1",
361 array (
"a" => array(
"hover"),
"div" => array(
"hover"),
"img" => array(
"hover"));
365 array(
"type" =>
"text_block",
"class" =>
"Standard"),
366 array(
"type" =>
"text_block",
"class" =>
"List"),
367 array(
"type" =>
"text_block",
"class" =>
"TableContent"),
368 array(
"type" =>
"heading1",
"class" =>
"Headline1"),
369 array(
"type" =>
"heading2",
"class" =>
"Headline2"),
370 array(
"type" =>
"heading3",
"class" =>
"Headline3"),
371 array(
"type" =>
"text_inline",
"class" =>
"Comment"),
372 array(
"type" =>
"text_inline",
"class" =>
"Emph"),
373 array(
"type" =>
"text_inline",
"class" =>
"Quotation"),
374 array(
"type" =>
"text_inline",
"class" =>
"Strong"),
375 array(
"type" =>
"text_inline",
"class" =>
"Accent"),
376 array(
"type" =>
"text_inline",
"class" =>
"Important"),
377 array(
"type" =>
"link",
"class" =>
"IntLink"),
378 array(
"type" =>
"link",
"class" =>
"ExtLink"),
379 array(
"type" =>
"link",
"class" =>
"FootnoteLink"),
380 array(
"type" =>
"link",
"class" =>
"FileLink"),
381 array(
"type" =>
"link",
"class" =>
"GlossaryLink"),
382 array(
"type" =>
"media_cont",
"class" =>
"MediaContainer"),
383 array(
"type" =>
"table",
"class" =>
"StandardTable"),
384 array(
"type" =>
"media_caption",
"class" =>
"MediaCaption"),
385 array(
"type" =>
"iim",
"class" =>
"ContentPopup"),
386 array(
"type" =>
"marker",
"class" =>
"Marker"),
387 array(
"type" =>
"page_frame",
"class" =>
"PageFrame"),
388 array(
"type" =>
"page_cont",
"class" =>
"PageContainer"),
389 array(
"type" =>
"page",
"class" =>
"Page"),
390 array(
"type" =>
"page_tnav",
"class" =>
"TopNavigation"),
391 array(
"type" =>
"page_bnav",
"class" =>
"BottomNavigation"),
392 array(
"type" =>
"page_lnav",
"class" =>
"LeftNavigation"),
393 array(
"type" =>
"page_rnav",
"class" =>
"RightNavigation"),
394 array(
"type" =>
"page_lnavlink",
"class" =>
"LeftNavigationLink"),
395 array(
"type" =>
"page_rnavlink",
"class" =>
"RightNavigationLink"),
396 array(
"type" =>
"page_lnavimage",
"class" =>
"LeftNavigationImage"),
397 array(
"type" =>
"page_rnavimage",
"class" =>
"RightNavigationImage"),
398 array(
"type" =>
"page_fn",
"class" =>
"Footnote"),
399 array(
"type" =>
"page_title",
"class" =>
"PageTitle"),
400 array(
"type" =>
"glo_overlay",
"class" =>
"GlossaryOverlay"),
401 array(
"type" =>
"glo_ovtitle",
"class" =>
"GlossaryOvTitle"),
402 array(
"type" =>
"glo_ovclink",
"class" =>
"GlossaryOvCloseLink"),
403 array(
"type" =>
"glo_ovuglink",
"class" =>
"GlossaryOvUnitGloLink"),
404 array(
"type" =>
"glo_ovuglistlink",
"class" =>
"GlossaryOvUGListLink"),
405 array(
"type" =>
"sco_title",
"class" =>
"Title"),
406 array(
"type" =>
"sco_desc",
"class" =>
"Description"),
407 array(
"type" =>
"sco_desct",
"class" =>
"DescriptionTop"),
408 array(
"type" =>
"sco_keyw",
"class" =>
"Keywords"),
409 array(
"type" =>
"sco_obj",
"class" =>
"Objective"),
410 array(
"type" =>
"sco_objt",
"class" =>
"ObjectiveTop"),
411 array(
"type" =>
"sco_fmess",
"class" =>
"FinalMessage"),
412 array(
"type" =>
"rte_menu",
"class" =>
"RTEMenu"),
413 array(
"type" =>
"rte_menu",
"class" =>
"RTELogo"),
414 array(
"type" =>
"rte_menu",
"class" =>
"RTELinkBar"),
415 array(
"type" =>
"rte_mlink",
"class" =>
"RTELink"),
416 array(
"type" =>
"rte_mlink",
"class" =>
"RTELinkDisabled"),
417 array(
"type" =>
"rte_tree",
"class" =>
"RTETree"),
418 array(
"type" =>
"rte_node",
"class" =>
"RTECourse"),
419 array(
"type" =>
"rte_node",
"class" =>
"RTEChapter"),
420 array(
"type" =>
"rte_node",
"class" =>
"RTESco"),
421 array(
"type" =>
"rte_node",
"class" =>
"RTEAsset"),
422 array(
"type" =>
"rte_node",
"class" =>
"RTECourseDisabled"),
423 array(
"type" =>
"rte_node",
"class" =>
"RTEChapterDisabled"),
424 array(
"type" =>
"rte_node",
"class" =>
"RTEScoDisabled"),
425 array(
"type" =>
"rte_node",
"class" =>
"RTEAssetDisabled"),
426 array(
"type" =>
"rte_status",
"class" =>
"RTEAsset"),
427 array(
"type" =>
"rte_status",
"class" =>
"RTECompleted"),
428 array(
"type" =>
"rte_status",
"class" =>
"RTENotAttempted"),
429 array(
"type" =>
"rte_status",
"class" =>
"RTERunning"),
430 array(
"type" =>
"rte_status",
"class" =>
"RTEIncomplete"),
431 array(
"type" =>
"rte_status",
"class" =>
"RTEPassed"),
432 array(
"type" =>
"rte_status",
"class" =>
"RTEFailed"),
433 array(
"type" =>
"rte_status",
"class" =>
"RTEBrowsed"),
434 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeLink"),
435 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeLinkDisabled"),
436 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeCurrent"),
437 array(
"type" =>
"rte_tul",
"class" =>
"RTETreeList"),
438 array(
"type" =>
"rte_tli",
"class" =>
"RTETreeItem"),
439 array(
"type" =>
"rte_texp",
"class" =>
"RTETreeExpanded"),
440 array(
"type" =>
"rte_texp",
"class" =>
"RTETreeCollapsed"),
441 array(
"type" =>
"rte_tree",
"class" =>
"RTETreeControl"),
442 array(
"type" =>
"rte_tclink",
"class" =>
"RTETreeControlLink"),
443 array(
"type" =>
"rte_drag",
"class" =>
"RTEDragBar"),
444 array(
"type" =>
"list_o",
"class" =>
"NumberedList"),
445 array(
"type" =>
"list_u",
"class" =>
"BulletedList"),
446 array(
"type" =>
"list_item",
"class" =>
"StandardListItem"),
447 array(
"type" =>
"question",
"class" =>
"Standard"),
448 array(
"type" =>
"question",
"class" =>
"SingleChoice"),
449 array(
"type" =>
"question",
"class" =>
"MultipleChoice"),
450 array(
"type" =>
"question",
"class" =>
"TextQuestion"),
451 array(
"type" =>
"question",
"class" =>
"OrderingQuestion"),
452 array(
"type" =>
"question",
"class" =>
"MatchingQuestion"),
453 array(
"type" =>
"question",
"class" =>
"ImagemapQuestion"),
454 array(
"type" =>
"question",
"class" =>
"ErrorText"),
455 array(
"type" =>
"question",
"class" =>
"TextSubset"),
456 array(
"type" =>
"question",
"class" =>
"ClozeTest"),
457 array(
"type" =>
"qtitle",
"class" =>
"Title"),
458 array(
"type" =>
"qanswer",
"class" =>
"Answer"),
459 array(
"type" =>
"qimg",
"class" =>
"QuestionImage"),
460 array(
"type" =>
"qimgd",
"class" =>
"ImageDetailsLink"),
461 array(
"type" =>
"qordul",
"class" =>
"OrderList"),
462 array(
"type" =>
"qordli",
"class" =>
"OrderListItem"),
463 array(
"type" =>
"qordul",
"class" =>
"OrderListHorizontal"),
464 array(
"type" =>
"qordli",
"class" =>
"OrderListItemHorizontal"),
465 array(
"type" =>
"qetitem",
"class" =>
"ErrorTextItem"),
466 array(
"type" =>
"qetitem",
"class" =>
"ErrorTextSelected"),
467 array(
"type" =>
"qetcorr",
"class" =>
"ErrorTextCorrected"),
468 array(
"type" =>
"qinput",
"class" =>
"TextInput"),
469 array(
"type" =>
"qlinput",
"class" =>
"LongTextInput"),
470 array(
"type" =>
"qsubmit",
"class" =>
"Submit"),
471 array(
"type" =>
"qfeedr",
"class" =>
"FeedbackRight"),
472 array(
"type" =>
"qfeedw",
"class" =>
"FeedbackWrong"),
473 array(
"type" =>
"qover",
"class" =>
"Correct"),
474 array(
"type" =>
"qover",
"class" =>
"Inorrect"),
475 array(
"type" =>
"qover",
"class" =>
"StatusMessage"),
476 array(
"type" =>
"qover",
"class" =>
"WrongAnswersMessage"),
477 array(
"type" =>
"flist_cont",
"class" =>
"FileListContainer"),
478 array(
"type" =>
"flist_head",
"class" =>
"FileListHeading"),
479 array(
"type" =>
"flist",
"class" =>
"FileList"),
480 array(
"type" =>
"flist_li",
"class" =>
"FileListItem"),
481 array(
"type" =>
"flist_a",
"class" =>
"FileListItemLink")
487 "caption" =>
"table_caption",
488 "row_head" =>
"table_cell",
489 "row_foot" =>
"table_cell",
490 "col_head" =>
"table_cell",
491 "col_foot" =>
"table_cell",
492 "odd_row" =>
"table_cell",
493 "even_row" =>
"table_cell",
494 "odd_col" =>
"table_cell",
495 "even_col" =>
"table_cell"),
496 "vaccordion" => array(
497 "va_cntr" =>
"va_cntr",
498 "va_icntr" =>
"va_icntr",
499 "va_ihead" =>
"va_ihead",
500 "va_icont" =>
"va_icont"
502 "haccordion" => array(
503 "ha_cntr" =>
"ha_cntr",
504 "ha_icntr" =>
"ha_icntr",
505 "ha_ihead" =>
"ha_ihead",
506 "ha_icont" =>
"ha_icont"
524 $this->style = array();
525 if($a_call_by_reference)
527 $this->ilias->raiseError(
"Can't instantiate style object via reference id.",$this->ilias->error_obj->FATAL);
538 $this->ilias->raiseError(
"Operation ilObjStyleSheet::setRefId() not allowed.",$this->ilias->error_obj->FATAL);
555 $this->ilias->raiseError(
"Operation ilObjStyleSheet::putInTree() not allowed.",$this->ilias->error_obj->FATAL);
563 $this->ilias->raiseError(
"Operation ilObjStyleSheet::createReference() not allowed.",$this->ilias->error_obj->FATAL);
571 $this->up_to_date = $a_up_to_date;
579 return $this->up_to_date;
587 $this->scope = $a_scope;
605 $q =
"UPDATE style_data SET uptodate = ".
606 $ilDB->quote((
int) $a_up_to_date,
"integer").
607 " WHERE id = ".$ilDB->quote($a_id,
"integer");
608 $ilDB->manipulate($q);
618 $q =
"SELECT uptodate FROM style_data ".
619 " WHERE id = ".$ilDB->quote($a_id,
"integer");
620 $res = $ilDB->query($q);
621 $sty = $ilDB->fetchAssoc(
$res);
623 return (
boolean) $sty[
"uptodate"];
633 $q =
"UPDATE style_data SET standard = ".
634 $ilDB->quote((
int) $a_std,
"integer").
635 " WHERE id = ".$ilDB->quote($a_id,
"integer");
636 $ilDB->manipulate($q);
646 $q =
"UPDATE style_data SET category = ".
647 $ilDB->quote((
int) $a_scope,
"integer").
648 " WHERE id = ".$ilDB->quote($a_id,
"integer");
649 $ilDB->manipulate($q);
659 $q =
"SELECT * FROM style_data ".
660 " WHERE id = ".$ilDB->quote($a_id,
"integer");
661 $res = $ilDB->query($q);
662 $sty = $ilDB->fetchAssoc(
$res);
664 return (
boolean) $sty[
"standard"];
674 $q =
"UPDATE style_data SET active = ".
675 $ilDB->quote((
int) $a_active,
"integer").
676 " WHERE id = ".$ilDB->quote($a_id,
"integer");
677 $ilDB->manipulate($q);
687 $q =
"SELECT * FROM style_data ".
688 " WHERE id = ".$ilDB->quote($a_id,
"integer");
689 $res = $ilDB->query($q);
690 $sty = $ilDB->fetchAssoc(
$res);
692 return (
boolean) $sty[
"active"];
699 $a_include_deactivated =
false, $a_scope = 0)
703 $default_style = $ilias->getSetting(
"default_content_style_id");
706 if (!$a_include_deactivated)
708 $and_str =
" AND active = 1";
711 $q =
"SELECT * FROM style_data ".
712 " WHERE standard = 1".$and_str;
713 $res = $ilDB->query($q);
715 while($sty = $ilDB->fetchAssoc(
$res))
717 if (!$a_exclude_default_style || $default_style != $sty[
"id"])
720 if ($a_scope > 0 && $sty[
"category"] > 0)
722 if ($tree->isInTree($sty[
"category"]) &&
723 $tree->isInTree($a_scope))
725 $path = $tree->getPathId($a_scope);
726 if (!in_array($sty[
"category"],
$path))
746 global $ilAccess,
$ilDB;
748 $clonable_styles = array();
750 $q =
"SELECT * FROM style_data";
751 $style_set = $ilDB->query($q);
752 while($style_rec = $ilDB->fetchAssoc($style_set))
755 if ($style_rec[
"standard"] == 1)
757 if ($style_rec[
"active"] == 1)
764 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
766 foreach($obj_ids as
$id)
771 if ($ilAccess->checkAccess(
"write",
"", $ref_id))
780 $clonable_styles[$style_rec[
"id"]] =
784 return $clonable_styles;
792 $this->meta_data =& $a_meta_data;
802 if (!is_object(self::$basic_style_dom))
804 self::$basic_style_dom =
new DOMDocument();
805 self::$basic_style_dom->load(self::$basic_style_file);
816 return $this->meta_data;
822 function create($a_from_style = 0, $a_import_mode =
false)
828 if ($a_from_style == 0)
845 $q =
"SELECT * FROM style_parameter WHERE style_id = ".
846 $ilDB->quote($a_from_style,
"integer");
847 $par_set = $ilDB->query($q);
848 while($par_rec = $ilDB->fetchAssoc($par_set))
850 $def[] = array(
"tag" => $par_rec[
"tag"],
"class" => $par_rec[
"class"],
851 "parameter" => $par_rec[
"parameter"],
"value" => $par_rec[
"value"],
852 "type" => $par_rec[
"type"]);
857 $q =
"SELECT * FROM style_char WHERE style_id = ".
858 $ilDB->quote($a_from_style,
"integer");
859 $par_set = $ilDB->query($q);
860 while($par_rec = $ilDB->fetchAssoc($par_set))
862 $chars[] = array(
"type" => $par_rec[
"type"],
"characteristic" => $par_rec[
"characteristic"]);
866 foreach ($def as $sty)
868 $id = $ilDB->nextId(
"style_parameter");
869 $q =
"INSERT INTO style_parameter (id, style_id, tag, class, parameter, value, type) VALUES ".
871 $ilDB->quote(
$id,
"integer").
",".
872 $ilDB->quote($this->
getId(),
"integer").
",".
873 $ilDB->quote($sty[
"tag"],
"text").
",".
874 $ilDB->quote($sty[
"class"],
"text").
",".
875 $ilDB->quote($sty[
"parameter"],
"text").
",".
876 $ilDB->quote($sty[
"value"],
"text").
",".
877 $ilDB->quote($sty[
"type"],
"text").
")";
878 $ilDB->manipulate($q);
882 foreach ($chars as $char)
884 $q =
"INSERT INTO style_char (style_id, type, characteristic) VALUES ".
885 "(".$ilDB->quote($this->
getId(),
"integer").
",".
886 $ilDB->quote($char[
"type"],
"text").
",".
887 $ilDB->quote($char[
"characteristic"],
"text").
")";
888 $ilDB->manipulate($q);
892 $q =
"INSERT INTO style_data (id, uptodate, category) VALUES ".
893 "(".$ilDB->quote($this->
getId(),
"integer").
", 0,".
894 $ilDB->quote((
int) $this->
getScope(),
"integer").
")";
895 $ilDB->manipulate($q);
904 $colors = $from_style->getColors();
905 foreach ($colors as $c)
907 $this->
addColor($c[
"name"], $c[
"code"]);
912 foreach ($tcts as $tct => $v)
917 $this->
addTemplate($tct, $t[
"name"], $t[
"classes"]);
939 if (empty(
$core_styles[$a_type.
".".$a_tag.
".".$a_class]))
942 $st = $ilDB->manipulateF(
943 "DELETE FROM style_char WHERE style_id = %s AND type = %s AND characteristic = %s",
944 array(
"integer",
"text",
"text"),
945 array($this->
getId(), $a_type, $a_class));
948 $st = $ilDB->manipulateF(
"DELETE FROM style_parameter WHERE style_id = %s AND tag = %s AND type = %s AND class = %s",
949 array(
"integer",
"text",
"text",
"text"),
950 array($this->
getId(), $a_tag, $a_type, $a_class));
964 $set = $ilDB->queryF(
965 "SELECT style_id FROM style_char WHERE style_id = %s AND characteristic = %s AND type = %s",
966 array(
"integer",
"text",
"text"),
967 array($this->
getId(), $a_char, $a_style_type));
968 if ($rec = $ilDB->fetchAssoc($set))
983 $ilDB->manipulateF(
"INSERT INTO style_char (style_id, type, characteristic, hide)".
984 " VALUES (%s,%s,%s,%s) ",
985 array(
"integer",
"text",
"text",
"integer"),
986 array($this->
getId(), $a_type, $a_char, $a_hidden));
999 $a_from_type, $a_from_char, $a_to_char)
1011 $pars = $from_style->getParametersOfClass($a_from_type, $a_from_char);
1014 foreach ($pars as $p => $v)
1016 if (substr($v, 0, 1) ==
"!")
1018 $colors[] = substr($v, 1);
1021 $a_to_char, $p, $v, $a_from_type);
1025 foreach ($colors as $c)
1029 $this->
addColor($c, $from_style->getColorCodeForName($c));
1043 $chars = $this->chars;
1045 if (is_array($this->chars_by_type[$a_type]))
1047 $chars = $this->chars_by_type[$a_type];
1052 foreach ($chars as $k => $char)
1054 if ($a_type ==
"" && $this->hidden_chars[$char[
"type"].
":".$char[
"class"]])
1058 else if ($this->hidden_chars[$a_type.
":".$char])
1073 $this->chars = $a_chars;
1084 $ilDB->manipulate(
"UPDATE style_char SET ".
1085 " hide = ".$ilDB->quote((
int) $a_hide,
"integer").
1086 " WHERE style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1087 " type = ".$ilDB->quote($a_type,
"text").
" AND ".
1088 " characteristic = ".$ilDB->quote($a_char,
"text")
1099 $set = $ilDB->query(
"SELECT hide FROM style_char ".
1100 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
1101 " type = ".$ilDB->quote($a_type,
"text").
" AND ".
1102 " characteristic = ".$ilDB->quote($a_char,
"text")
1104 $rec = $ilDB->fetchAssoc($set);
1106 return $rec[
"hide"];
1120 $new_obj->setTitle($this->
getTitle().
" (".$lng->txt(
"sty_acopy").
")");
1121 $new_obj->setType($this->
getType());
1123 $new_obj->create($this->
getId());
1125 $new_obj->writeStyleSetting(
"disable_auto_margins",
1128 return $new_obj->getId();
1151 $tag = explode(
".", $a_tag);
1152 $value = $avail_params[$a_par][0];
1153 $id = $ilDB->nextId(
"style_parameter");
1154 $q =
"INSERT INTO style_parameter (id,style_id, type, tag, class, parameter, value) VALUES ".
1156 $ilDB->quote(
$id,
"integer").
",".
1157 $ilDB->quote($this->
getId(),
"integer").
",".
1158 $ilDB->quote($a_type,
"text").
",".
1159 $ilDB->quote($tag[0],
"text").
",".
1160 $ilDB->quote($tag[1],
"text").
",".
1161 $ilDB->quote($a_par,
"text").
",".
1162 $ilDB->quote($value,
"text").
")";
1163 $ilDB->manipulate($q);
1187 if(!is_writable($sty_data_dir))
1189 $ilErr->raiseError(
"Style data directory (".$sty_data_dir
1190 .
") not writeable.", $ilErr->FATAL);
1193 $style_dir = $sty_data_dir.
"/sty_".$a_style_id;
1195 if(!@is_dir($style_dir))
1197 $ilErr->raiseError(
"Creation of style directory failed (".
1198 $style_dir.
").",$ilErr->FATAL);
1202 $im_dir = $style_dir.
"/images";
1204 if(!@is_dir($im_dir))
1206 $ilErr->raiseError(
"Creation of Import Directory failed (".
1207 $im_dir.
").", $ilErr->FATAL);
1211 $thumb_dir = $style_dir.
"/images/thumbnails";
1213 if(!@is_dir($thumb_dir))
1215 $ilErr->raiseError(
"Creation of Import Directory failed (".
1216 $thumb_dir.
").", $ilErr->FATAL);
1256 foreach($entries as $entry)
1258 if (substr($entry[
"entry"],0,1) ==
".")
1262 if ($entry[
"type"] !=
"dir")
1308 $q =
"DELETE FROM style_parameter WHERE id = ".
1309 $ilDB->quote($a_id,
"integer");
1325 $q =
"DELETE FROM style_parameter WHERE ".
1326 " style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1327 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1328 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1329 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1330 " parameter = ".$ilDB->quote($a_par,
"text");
1332 $ilDB->manipulate($q);
1347 $q =
"DELETE FROM style_parameter WHERE ".
1348 " style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1349 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1350 " ".$ilDB->equals(
"type", $a_type,
"text",
true);
1352 $ilDB->manipulate($q);
1367 $def_style = $this->ilias->getSetting(
"default_content_style_id");
1368 if ($def_style == $this->
getId())
1370 $this->ilias->deleteSetting(
"default_content_style_id");
1374 $fixed_style = $this->ilias->getSetting(
"fixed_content_style_id");
1375 if ($fixed_style == $this->
getId())
1377 $this->ilias->deleteSetting(
"fixed_content_style_id");
1381 $q =
"DELETE FROM style_parameter WHERE style_id = ".
1382 $ilDB->quote($this->
getId(),
"integer");
1383 $ilDB->manipulate($q);
1387 if (is_file($css_file_name))
1389 unlink($css_file_name);
1393 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
1397 $q =
"DELETE FROM style_data WHERE id = ".
1398 $ilDB->quote($this->
getId(),
"integer");
1399 $ilDB->manipulate($q);
1413 $q =
"SELECT * FROM style_parameter WHERE style_id = ".
1414 $ilDB->quote($this->
getId(),
"integer").
" ORDER BY tag, class, type ";
1415 $style_set = $ilDB->query($q);
1419 $this->style = array();
1420 while($style_rec = $ilDB->fetchAssoc($style_set))
1422 if ($style_rec[
"tag"] != $ctag || $style_rec[
"class"] != $cclass
1423 || $style_rec[
"type"] != $ctype)
1428 $this->style[] = $tag;
1432 $ctag = $style_rec[
"tag"];
1433 $cclass = $style_rec[
"class"];
1434 $ctype = $style_rec[
"type"];
1435 $tag[] = $style_rec;
1436 $this->style_class[$ctype][$cclass][$style_rec[
"parameter"]] = $style_rec[
"value"];
1440 $this->style[] = $tag;
1443 $q =
"SELECT * FROM style_data WHERE id = ".
1444 $ilDB->quote($this->
getId(),
"integer");
1445 $res = $ilDB->query($q);
1446 $sty = $ilDB->fetchAssoc(
$res);
1451 $this->chars = array();
1452 $this->chars_by_type = array();
1453 $q =
"SELECT * FROM style_char WHERE style_id = ".
1454 $ilDB->quote($this->
getId(),
"integer").
1455 " ORDER BY type ASC, characteristic ASC";
1456 $par_set = $ilDB->query($q);
1457 while($par_rec = $ilDB->fetchAssoc($par_set))
1459 $this->chars[] = array(
"type" => $par_rec[
"type"],
"class" => $par_rec[
"characteristic"],
"hide" => $par_rec[
"hide"]);
1460 $this->chars_by_type[$par_rec[
"type"]][] = $par_rec[
"characteristic"];
1461 if ($par_rec[
"hide"])
1463 $this->hidden_chars[$par_rec[
"type"].
":".$par_rec[
"characteristic"]] =
true;
1475 if ($a_target_file ==
"")
1481 $css_file_name = $a_target_file;
1483 $css_file = fopen($css_file_name,
"w");
1485 $page_background =
"";
1489 fwrite ($css_file, $tag[0][
"tag"].
".ilc_".$tag[0][
"type"].
"_".$tag[0][
"class"].
"\n");
1490 if ($tag[0][
"tag"] ==
"td")
1492 fwrite ($css_file,
",th".
".ilc_".$tag[0][
"type"].
"_".$tag[0][
"class"].
"\n");
1494 if (in_array($tag[0][
"tag"], array(
"h1",
"h2",
"h3")))
1496 fwrite ($css_file,
",div.ilc_text_block_".$tag[0][
"class"].
"\n");
1497 fwrite ($css_file,
",body.ilc_text_block_".$tag[0][
"class"].
"\n");
1499 if ($tag[0][
"type"] ==
"text_block")
1501 fwrite ($css_file,
",body.ilc_text_block_".$tag[0][
"class"].
"\n");
1503 fwrite ($css_file,
"{\n");
1506 $t_border = array();
1508 foreach($tag as $par)
1510 $cur_par = $par[
"parameter"];
1511 $cur_val = $par[
"value"];
1514 if (is_int(strpos($cur_par,
"color")) && substr(trim($cur_val), 0, 1) ==
"!")
1519 if ($tag[0][
"type"] ==
"table" && is_int(strpos($par[
"parameter"],
"border")))
1521 $t_border[$cur_par] = $cur_val;
1524 if (in_array($cur_par, array(
"background-image",
"list-style-image")))
1526 if (is_int(strpos($cur_val,
"/")))
1528 $cur_val =
"url(".$cur_val.
")";
1532 if ($a_image_dir ==
"")
1534 $cur_val =
"url(../sty/sty_".$this->getId().
"/images/".$cur_val.
")";
1538 $cur_val =
"url(".$a_image_dir.
"/".$cur_val.
")";
1543 if ($cur_par ==
"opacity")
1545 $cur_val = ((int) $cur_val) / 100;
1548 fwrite ($css_file,
"\t".$cur_par.
": ".$cur_val.
";\n");
1551 if ($cur_par ==
"min-height")
1553 fwrite ($css_file,
"\t".
"height".
": ".
"auto !important".
";\n");
1554 fwrite ($css_file,
"\t".
"height".
": ".$cur_val.
";\n");
1558 if ($cur_par ==
"opacity")
1560 fwrite ($css_file,
"\t".
'-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity='.($cur_val * 100).
')"'.
";\n");
1561 fwrite ($css_file,
"\t".
'filter: alpha(opacity='.($cur_val * 100).
')'.
";\n");
1562 fwrite ($css_file,
"\t".
'-moz-opacity: '.$cur_val.
";\n");
1566 if ($tag[0][
"tag"] ==
"div" && $tag[0][
"class"] ==
"Page"
1567 && $cur_par ==
"background-color")
1569 $page_background = $cur_val;
1572 fwrite ($css_file,
"}\n");
1573 fwrite ($css_file,
"\n");
1593 if ($page_background !=
"")
1595 fwrite ($css_file,
"td.ilc_Page\n");
1596 fwrite ($css_file,
"{\n");
1597 fwrite ($css_file,
"\t".
"background-color: ".$page_background.
";\n");
1598 fwrite ($css_file,
"}\n");
1617 $fixed_style = $ilSetting->get(
"fixed_content_style_id");
1618 if ($fixed_style > 0)
1620 $a_style_id = $fixed_style;
1624 if ($a_style_id <= 0)
1626 $a_style_id = $ilSetting->get(
"default_content_style_id");
1645 if (is_array($this->style_class[$a_type][$a_class]))
1647 return $this->style_class[$a_type][$a_class];
1661 $rand = rand(1,999999);
1665 $fixed_style = $ilias->getSetting(
"fixed_content_style_id");
1666 if ($fixed_style > 0)
1668 $a_style_id = $fixed_style;
1672 if ($a_style_id <= 0)
1674 $a_style_id = $ilias->getSetting(
"default_content_style_id");
1687 "/css/style_".$a_style_id.
".css?dummy=$rand";
1691 return "./Services/COPage/css/content.css";
1702 return "./Services/COPage/css/print_content.css";
1712 return "./Services/COPage/css/syntaxhighlight.css";
1722 return "./Services/COPage/css/placeholder.css";
1733 $q =
"UPDATE style_data ".
1734 "SET category = ".$ilDB->quote((
int) $this->
getScope(),
"integer").
1735 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
1736 $ilDB->manipulate($q);
1749 $q =
"UPDATE style_parameter SET VALUE = ".
1750 $ilDB->quote($a_value,
"text").
" WHERE id = ".
1751 $ilDB->quote($a_id,
"integer");
1752 $style_set = $ilDB->manipulate($q);
1768 $q =
"SELECT * FROM style_parameter WHERE ".
1769 " style_id = ".$ilDB->quote($style_id,
"integer").
" AND ".
1770 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1771 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1772 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1773 " parameter = ".$ilDB->quote($a_par,
"text");
1775 $set = $ilDB->query($q);
1777 if ($rec = $set->fetchRow())
1779 $q =
"UPDATE style_parameter SET ".
1780 " value = ".$ilDB->quote($a_val,
"text").
" WHERE ".
1781 " style_id = ".$ilDB->quote($style_id,
"integer").
" AND ".
1782 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1783 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1784 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1785 " parameter = ".$ilDB->quote($a_par,
"text");
1787 $ilDB->manipulate($q);
1791 $id = $ilDB->nextId(
"style_parameter");
1792 $q =
"INSERT INTO style_parameter (id, value, style_id, tag, class, type, parameter) VALUES ".
1794 $ilDB->quote(
$id,
"integer").
",".
1795 $ilDB->quote($a_val,
"text").
",".
1796 " ".$ilDB->quote($this->
getId(),
"integer").
",".
1797 " ".$ilDB->quote($a_tag,
"text").
",".
1798 " ".$ilDB->quote($a_class,
"text").
",".
1799 " ".$ilDB->quote($a_type,
"text").
",".
1800 " ".$ilDB->quote($a_par,
"text").
")";
1802 $ilDB->manipulate($q);
1820 $this->style = $a_style;
1832 return str_replace(
"&",
"&", $a_str);
1840 $xml.=
"<StyleSheet>\n";
1843 $xml.=
"<Title>".$this->handleXmlString($this->
getTitle()).
"</Title>";
1844 $xml.=
"<Description>".$this->handleXmlString($this->
getDescription()).
"</Description>\n";
1847 foreach($this->chars as $char)
1849 $xml.=
"<Style Tag=\"".ilObjStyleSheet::_determineTag($char[
"type"]).
1850 "\" Type=\"".$char[
"type"].
"\" Class=\"".$char[
"class"].
"\">\n";
1851 foreach($this->style as
$style)
1853 if ($style[0][
"type"] == $char[
"type"] && $style[0][
"class"] == $char[
"class"])
1855 foreach($style as $tag)
1857 $xml.=
"<StyleParameter Name=\"".$tag[
"parameter"].
"\" Value=\"".$tag[
"value"].
"\"/>\n";
1861 $xml.=
"</Style>\n";
1867 $xml.=
"<StyleColor Name=\"".$color[
"name"].
"\" Code=\"".$color[
"code"].
"\"/>\n";
1872 foreach ($tcts as $tct => $v)
1878 $xml.=
"<StyleTemplate Type=\"".$tct.
"\" Name=\"".$t[
"name"].
"\">\n";
1879 foreach ($t[
"classes"] as $ct => $c)
1883 $xml.=
"<StyleTemplateClass ClassType=\"".$ct.
"\" Class=\"".$c.
"\"/>\n";
1886 $xml.=
"</StyleTemplate>\n";
1891 $xml.=
"</StyleSheet>";
1904 if(!is_writable($sty_data_dir))
1906 $this->ilias->raiseError(
"Style data directory (".$sty_data_dir
1907 .
") not writeable.",$this->ilias->error_obj->FATAL);
1910 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
1912 if(!@is_dir($style_dir))
1914 $this->ilias->raiseError(
"Creation of style directory failed (".
1915 $style_dir.
").",$this->ilias->error_obj->FATAL);
1919 $ex_dir = $style_dir.
"/export";
1921 if(!@is_dir($ex_dir))
1923 $this->ilias->raiseError(
"Creation of Import Directory failed (".
1924 $ex_dir.
").",$this->ilias->error_obj->FATAL);
1936 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
1938 $ex_dir = $style_dir.
"/export";
1940 if (is_dir($ex_dir))
1955 if(!is_writable($ex_sub_dir))
1957 $this->ilias->raiseError(
"Style data directory (".$ex_sub_dir
1958 .
") not writeable.",$this->ilias->error_obj->FATAL);
1960 $ex_sub_images_dir = $ex_sub_dir.
"/images";
1962 if(!is_writable($ex_sub_images_dir))
1964 $this->ilias->raiseError(
"Style data directory (".$ex_sub_images_dir
1965 .
") not writeable.",$this->ilias->error_obj->FATAL);
1974 $this->export_sub_dir = $a_dir;
1982 if ($this->export_sub_dir ==
"")
1984 return "sty_".$this->getId();
1988 return $this->export_sub_dir;
2002 $this->
exportXML($ex_dir.
"/".$this->getExportSubDir());
2005 $ex_dir.
"/".$this->getExportSubDir().
"/images");
2006 if (is_file($ex_dir.
"/".$this->getExportSubDir().
".zip"))
2008 unlink($ex_dir.
"/".$this->getExportSubDir().
".zip");
2021 $file = $a_dir.
"/style.xml";
2024 if (!($fp = @fopen(
$file,
"w")))
2026 die (
"<b>Error</b>: Could not open \"".
$file.
"\" for writing".
2027 " in <b>".__FILE__.
"</b> on line <b>".__LINE__.
"</b><br />");
2034 fwrite($fp, $this->
getXML());
2048 if(!is_writable($sty_data_dir))
2050 $this->ilias->raiseError(
"Style data directory (".$sty_data_dir
2051 .
") not writeable.",$this->ilias->error_obj->FATAL);
2054 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
2056 if(!@is_dir($style_dir))
2058 $this->ilias->raiseError(
"Creation of style directory failed (".
2059 $style_dir.
").",$this->ilias->error_obj->FATAL);
2063 $im_dir = $style_dir.
"/import";
2065 if(!@is_dir($im_dir))
2067 $this->ilias->raiseError(
"Creation of Import Directory failed (".
2068 $im_dir.
").",$this->ilias->error_obj->FATAL);
2077 function import($a_file)
2084 if (is_array($a_file))
2087 $a_file[
"name"], $im_dir.
"/".$a_file[
"name"]);
2092 $pi = pathinfo($a_file);
2099 if (strtolower(
$file[
"extension"] ==
"zip"))
2102 $subdir = basename(
$file[
"basename"],
".".
$file[
"extension"]);
2103 if (!is_dir($im_dir.
"/".$subdir))
2107 $xml_file = $im_dir.
"/".$subdir.
"/style.xml";
2120 if (is_dir($im_dir.
"/".$subdir.
"/images"))
2123 $this->getImagesDirectory());
2138 $this->is_3_10_skin =
false;
2140 if (!$a_skip_parent_create)
2144 include_once(
"./Services/Style/classes/class.ilStyleImportParser.php");
2146 $importParser->startParsing();
2149 foreach ($this->style as
$style)
2151 foreach($style as $tag)
2153 $id = $ilDB->nextId(
"style_parameter");
2154 $q =
"INSERT INTO style_parameter (id,style_id, tag, class, parameter, type, value) VALUES ".
2156 $ilDB->quote(
$id,
"integer").
",".
2157 $ilDB->quote($this->
getId(),
"integer").
",".
2158 $ilDB->quote($tag[
"tag"],
"text").
",".
2159 $ilDB->quote($tag[
"class"],
"text").
",".
2160 $ilDB->quote($tag[
"parameter"],
"text").
",".
2161 $ilDB->quote($tag[
"type"],
"text").
",".
2162 $ilDB->quote($tag[
"value"],
"text").
")";
2164 $ilDB->manipulate($q);
2169 $this->is_3_10_skin =
true;
2170 if (is_array($this->chars))
2172 foreach ($this->chars as $char)
2174 if ($char[
"type"] !=
"")
2176 $s = substr($char[
"class"], strlen($char[
"class"]) - 6);
2179 $q =
"INSERT INTO style_char (style_id, type, characteristic) VALUES ".
2180 "(".$ilDB->quote($this->
getId(),
"integer").
",".
2181 $ilDB->quote($char[
"type"],
"text").
",".
2182 $ilDB->quote($char[
"class"],
"text").
")";
2183 $ilDB->manipulate($q);
2184 $this->is_3_10_skin =
false;
2191 $q =
"INSERT INTO style_data (id, uptodate) VALUES ".
2192 "(".$ilDB->quote($this->
getId(),
"integer").
", 0)";
2193 $ilDB->manipulate($q);
2198 if ($this->is_3_10_skin)
2212 foreach (self::$parameter as
$parameter => $props)
2221 $input = self::$parameter[$par][
"input"];
2227 $subpar = self::$parameter[$par][
"subpar"];
2238 foreach (self::$parameter as $k => $v)
2240 if (is_array(self::$filtered_groups[$v[
"group"]]) &&
2241 !in_array($a_tag, self::$filtered_groups[$v[
"group"]]))
2257 if ($a_no_percentage)
2266 return self::$parameter[$par][
"values"];
2281 return in_array($a_type, self::$expandable_types);
2286 return in_array($a_type, self::$hideable_types);
2291 foreach (self::$style_super_types as $s =>
$t)
2293 if (in_array($a_type,
$t))
2309 $c_styles = array();
2310 foreach (self::$core_styles as $cstyle)
2313 = array(
"type" => $cstyle[
"type"],
2315 "class" => $cstyle[
"class"]);
2325 if ($a_template_type ==
"")
2330 return self::$templates[$a_template_type];
2336 return self::$pseudo_classes[$tag];
2341 return self::$templates[
$t][$k];
2346 return self::$assigned_tags[$a_type];
2355 foreach(self::$parameter as $p => $v)
2357 $pars[$p] = $v[
"values"];
2369 $styles = array(array(
"id" => $a_id));
2380 if ($a_styles ==
"")
2386 $styles = $a_styles;
2392 $core_images = array();
2394 if (is_dir($core_dir))
2396 $dir = opendir($core_dir);
2399 if (substr(
$file, 0, 1) !=
"." && is_file($core_dir.
"/".
$file))
2401 $core_images[] =
$file;
2406 foreach ($styles as
$style)
2413 $set = $ilDB->queryF(
"SELECT * FROM style_char WHERE style_id = %s ".
2414 "AND type = %s AND characteristic = %s",
2415 array(
"integer",
"text",
"text"),
2416 array(
$id, $cs[
"type"], $cs[
"class"]));
2419 if (!($rec = $ilDB->fetchAssoc($set)))
2422 "INSERT INTO style_char (style_id, type, characteristic) ".
2423 " VALUES (%s,%s,%s) ",
2424 array(
"integer",
"text",
"text"),
2425 array(
$id, $cs[
"type"], $cs[
"class"]));
2427 $xpath =
new DOMXPath($bdom);
2428 $par_nodes = $xpath->query(
"/StyleSheet/Style[@Tag = '".$cs[
"tag"].
"' and @Type='".
2429 $cs[
"type"].
"' and @Class='".$cs[
"class"].
"']/StyleParameter");
2430 foreach ($par_nodes as $par_node)
2433 $set = $ilDB->queryF(
"SELECT * FROM style_parameter WHERE style_id = %s ".
2434 "AND type = %s AND class = %s AND tag = %s AND parameter = %s",
2435 array(
"integer",
"text",
"text",
"text",
"text"),
2436 array(
$id, $cs[
"type"], $cs[
"class"],
2437 $cs[
"tag"], $par_node->getAttribute(
"Name")));
2440 if (!($rec = $ilDB->fetchAssoc($set)))
2442 $spid = $ilDB->nextId(
"style_parameter");
2443 $st = $ilDB->manipulateF(
"INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value) ".
2444 " VALUES (%s,%s,%s,%s,%s,%s,%s)",
2445 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2446 array($spid,
$id, $cs[
"type"], $cs[
"class"], $cs[
"tag"],
2447 $par_node->getAttribute(
"Name"), $par_node->getAttribute(
"Value")));
2456 reset($core_images);
2457 foreach($core_images as $cim)
2459 if (!is_file($imdir.
"/".$cim))
2461 copy($core_dir.
"/".$cim, $imdir.
"/".$cim);
2486 $st = $ilDB->prepareManip(
"UPDATE style_char SET type = ? WHERE characteristic = ?".
2487 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2488 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2489 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2490 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2491 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2492 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2493 $ilDB->execute($st, array(
"page_cont",
"Page", $this->
getId()));
2496 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET type = ? WHERE class = ?".
2497 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2498 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2499 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2500 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2501 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2502 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2503 $ilDB->execute($st, array(
"table",
"Page", $this->
getId()));
2505 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET tag = ? WHERE class = ?".
2506 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2507 $ilDB->execute($st, array(
"div",
"MediaCaption", $this->
getId()));
2510 $st = $ilDB->prepareManip(
"UPDATE style_char SET characteristic = ? WHERE characteristic = ?".
2511 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2512 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2513 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2516 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET class = ? WHERE class = ?".
2517 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2518 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2519 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2522 $st = $ilDB->prepareManip(
"DELETE FROM style_char WHERE type = ?".
2523 " AND style_id = ? ", array(
"text",
"integer"));
2524 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2525 $st = $ilDB->prepareManip(
"DELETE FROM style_parameter WHERE type = ?".
2526 " AND style_id = ? ", array(
"text",
"integer"));
2527 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2544 $add_str =
" AND style_id = ".$ilDB->quote($a_id,
"integer");
2547 $set = $ilDB->query($q =
"SELECT DISTINCT style_id, tag, class FROM style_parameter WHERE ".
2548 $ilDB->equals(
"type",
"",
"text",
true).
" ".$add_str);
2550 while ($rec = $ilDB->fetchAssoc($set))
2554 switch ($rec[
"tag"])
2558 if (in_array($rec[
"class"], array(
"Headline3",
"Headline1",
2559 "Headline2",
"TableContent",
"List",
"Standard",
"Remark",
2560 "Additional",
"Mnemonic",
"Citation",
"Example")))
2562 $types[] =
"text_block";
2564 if (in_array($rec[
"class"], array(
"Block",
"Remark",
2565 "Additional",
"Mnemonic",
"Example",
"Excursus",
"Special")))
2567 $types[] =
"section";
2569 if (in_array($rec[
"class"], array(
"Page",
"Footnote",
"PageTitle",
"LMNavigation")))
2576 $types[] =
"table_cell";
2580 if (in_array($rec[
"class"], array(
"ExtLink",
"IntLink",
"FootnoteLink")))
2587 $types[] =
"text_inline";
2596 foreach ($types as
$t)
2599 $set4 = $ilDB->queryF(
"SELECT * FROM style_char ".
2600 " WHERE style_id = %s AND type = %s AND characteristic = %s",
2601 array(
"integer",
"text",
"text"),
2602 array($rec[
"style_id"], $t, $rec[
"class"]));
2603 if ($rec4 = $ilDB->fetchAssoc($set4))
2610 $ilDB->manipulateF(
"INSERT INTO style_char ".
2611 " (style_id, type, characteristic) VALUES ".
2613 array(
"integer",
"text",
"text"),
2614 array($rec[
"style_id"], $t, $rec[
"class"]));
2619 if ($rec[
"type"] ==
"")
2621 if (count($types) > 0)
2623 $ilDB->manipulateF(
"UPDATE style_parameter SET type = %s ".
2624 " WHERE style_id = %s AND class = %s AND ".$ilDB->equals(
"type",
"",
"text",
true),
2625 array(
"text",
"integer",
"text"),
2626 array($types[0], $rec[
"style_id"], $rec[
"class"]));
2630 if ($types[0] ==
"link")
2632 $ilDB->manipulateF(
"UPDATE style_parameter SET type = %s ".
2633 " WHERE style_id = %s AND (class = %s OR class = %s) AND ".$ilDB->equals(
"type",
"",
"text",
true),
2634 array(
"text",
"integer",
"text",
"text"),
2635 array($types[0], $rec[
"style_id"], $rec[
"class"].
":visited",
2636 $rec[
"class"].
":hover"));
2640 if (count($types) == 2)
2644 $set2 = $ilDB->queryF(
"SELECT * FROM style_parameter ".
2645 " WHERE style_id = %s AND class = %s AND type = %s",
2646 array(
"integer",
"text",
"text"),
2647 array($rec[
"style_id"], $rec[
"class"], $types[0]));
2648 while ($rec2 = $ilDB->fetchAssoc($set2))
2651 $set3 = $ilDB->queryF(
"SELECT * FROM style_parameter ".
2652 " WHERE style_id = %s AND tag = %s AND class = %s AND type = %s AND parameter = %s",
2653 array(
"integer",
"text",
"text",
"text",
"text"),
2654 array($rec[
"style_id"], $rec[
"tag"], $rec[
"class"], $types[1], $rec[
"parameter"]));
2655 if ($rec3 = $ilDB->fetchAssoc($set3))
2661 $nid = $ilDB->nextId(
"style_parameter");
2662 $ilDB->manipulateF(
"INSERT INTO style_parameter ".
2663 " (id, style_id, tag, class, parameter, value, type) VALUES ".
2664 " (%s, %s,%s,%s,%s,%s,%s) ",
2665 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2666 array($nid, $rec2[
"style_id"], $rec2[
"tag"], $rec2[
"class"],
2667 $rec2[
"parameter"], $rec2[
"value"], $types[1]));
2682 $classes = array(
"Example",
"Additional",
"Citation",
"Mnemonic",
"Remark");
2683 $pars = array(
"margin-top",
"margin-bottom");
2685 foreach ($classes as $curr_class)
2687 foreach ($pars as $curr_par)
2689 $res2 = $ilDB->queryF(
"SELECT id FROM style_parameter WHERE style_id = %s".
2690 " AND tag = %s AND class= %s AND parameter = %s",
2691 array(
"integer",
"text",
"text",
"text"),
2692 array($a_id,
"p", $curr_class, $curr_par));
2693 if ($row2 = $ilDB->fetchAssoc($res2))
2695 $ilDB->manipulateF(
"UPDATE style_parameter SET value= %s WHERE id = %s",
2696 array(
"text",
"integer"),
2697 array(
"10px", $row2[
"id"]));
2701 $nid = $ilDB->nextId(
"style_parameter");
2702 $ilDB->manipulateF(
"INSERT INTO style_parameter ".
2703 "(id, style_id, tag, class, parameter,value) VALUES (%s,%s,%s,%s,%s,%s)",
2704 array(
"integer",
"integer",
"text",
"text",
"text",
"text"),
2705 array($nid, $a_id,
"div", $curr_class, $curr_par,
"10px"));
2710 $ilDB->manipulateF(
"UPDATE style_parameter SET tag = %s WHERE tag = %s and style_id = %s",
2711 array(
"text",
"text",
"integer"),
2712 array(
"div",
"p", $a_id));
2724 $set = $ilDB->query(
"SELECT * FROM style_color WHERE ".
2725 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" ".
2726 "ORDER BY color_name");
2729 while ($rec = $ilDB->fetchAssoc($set))
2732 "name" => $rec[
"color_name"],
2733 "code" => $rec[
"color_code"]
2747 $ilDB->manipulate(
"INSERT INTO style_color (style_id, color_name, color_code)".
2749 $ilDB->quote($this->getId(),
"integer").
",".
2750 $ilDB->quote($a_name,
"text").
",".
2751 $ilDB->quote($a_code,
"text").
2764 $ilDB->manipulate(
"UPDATE style_color SET ".
2765 "color_name = ".$ilDB->quote($a_new_name,
"text").
", ".
2766 "color_code = ".$ilDB->quote($a_code,
"text").
2767 " WHERE style_id = ".$ilDB->quote($this->
getId(),
"integer").
2768 " AND color_name = ".$ilDB->quote($a_name,
"text"));
2772 if ($a_name != $a_new_name)
2774 $set = $ilDB->query(
"SELECT * FROM style_parameter ".
2775 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
2777 " parameter = ".$ilDB->quote(
"background-color",
"text").
" OR ".
2778 " parameter = ".$ilDB->quote(
"color",
"text").
" OR ".
2779 " parameter = ".$ilDB->quote(
"border-color",
"text").
" OR ".
2780 " parameter = ".$ilDB->quote(
"border-top-color",
"text").
" OR ".
2781 " parameter = ".$ilDB->quote(
"border-bottom-color",
"text").
" OR ".
2782 " parameter = ".$ilDB->quote(
"border-left-color",
"text").
" OR ".
2783 " parameter = ".$ilDB->quote(
"border-right-color",
"text").
2785 while ($rec = $ilDB->fetchAssoc($set))
2787 if ($rec[
"value"] ==
"!".$a_name ||
2788 is_int(strpos($rec[
"value"],
"!".$a_name.
"(")))
2792 $rec[
"parameter"], str_replace($a_name, $a_new_name, $rec[
"value"]), $rec[
"type"]);
2805 $ilDB->manipulate(
"DELETE FROM style_color WHERE ".
2806 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2807 " color_name = ".$ilDB->quote($a_name,
"text"));
2817 $set = $ilDB->query(
"SELECT * FROM style_color WHERE ".
2818 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2819 "color_name = ".$ilDB->quote($a_color_name,
"text"));
2820 if ($rec = $ilDB->fetchAssoc($set))
2834 $pos = strpos($a_name,
"(");
2837 $a_i = substr($a_name, $pos + 1);
2838 $a_i = str_replace(
")",
"", $a_i);
2839 $a_name = substr($a_name, 0, $pos);
2842 $set = $ilDB->query(
"SELECT color_code FROM style_color WHERE ".
2843 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2844 " color_name = ".$ilDB->quote($a_name,
"text"));
2845 if ($rec = $ilDB->fetchAssoc($set))
2849 return "#".$rec[
"color_code"];
2853 return "#".ilObjStyleSheet::_getColorFlavor($rec[
"color_code"],
2869 $hls[
"l"] = $hls[
"l"] + ((255 - $hls[
"l"]) * ($a_i / 100));
2873 $hls[
"l"] = $hls[
"l"] - (($hls[
"l"]) * (-$a_i / 100));
2878 foreach ($rgb as $k => $v)
2880 $rgb[$k] = str_pad(dechex($v), 2,
"0", STR_PAD_LEFT);
2883 return $rgb[
"r"].$rgb[
"g"].$rgb[
"b"];
2891 $r[
"r"] = substr($a_rgb, 0, 2);
2892 $r[
"g"] = substr($a_rgb, 2, 2);
2893 $r[
"b"] = substr($a_rgb, 4, 2);
2897 $r[
"r"] = (int) hexdec($r[
"r"]);
2898 $r[
"g"] = (int) hexdec($r[
"g"]);
2899 $r[
"b"] = (int) hexdec($r[
"b"]);
2910 $r = $a_rgb[
"r"] / 255;
2911 $g = $a_rgb[
"g"] / 255;
2912 $b = $a_rgb[
"b"] / 255;
2915 $max = max($r,$g,$b);
2916 $min = min($r,$g,$b);
2919 $l = ($max + $min) / 2;
2930 $s = ($max - $min) / ($max + $min);
2934 $s = ($max - $min) / (2.0 - $max - $min);
2939 $h = ($g - $b) / ($max - $min);
2941 else if ($g == $max)
2943 $h = 2.0 + ($b - $r) / ($max - $min);
2945 else if ($b == $max)
2947 $h = 4.0 + ($r - $g) / ($max - $min);
2951 $hls[
"h"] = round(($h / 6) * 255);
2952 $hls[
"l"] = round($l * 255);
2953 $hls[
"s"] = round($s * 255);
2963 $h = $a_hls[
"h"] / 255;
2964 $l = $a_hls[
"l"] / 255;
2965 $s = $a_hls[
"s"] / 255;
2967 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = 0;
2972 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = $l;
2979 $temp2 = $l * (1.0 + $s);
2983 $temp2 = $l + $s - $l * $s;
2986 $temp1 = 2.0 * $l - $temp2;
2989 # For each of R, G, B, compute another temporary value, temp3, as follows:
2990 foreach ($rgb as $k => $v)
2995 $temp3 = $h + 1.0 / 3.0;
3003 $temp3 = $h - 1.0/3.0;
3008 $temp3 = $temp3 + 1.0;
3012 $temp3 = $temp3 - 1.0;
3015 if (6.0 * $temp3 < 1)
3017 $rgb[$k] = $temp1 + ($temp2 - $temp1) * 6.0 * $temp3;
3019 else if (2.0 * $temp3 < 1)
3023 else if (3.0 * $temp3 < 2)
3025 $rgb[$k] = $temp1 + ($temp2 - $temp1) * ((2.0/3.0) - $temp3) * 6.0;
3034 $rgb[
"r"] = round($rgb[
"r"] * 255);
3035 $rgb[
"g"] = round($rgb[
"g"] * 255);
3036 $rgb[
"b"] = round($rgb[
"b"] * 255);
3052 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
3053 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3054 "temp_type = ".$ilDB->quote($a_type,
"text").
" ".
3058 while ($rec = $ilDB->fetchAssoc($set))
3073 $set = $ilDB->query(
"SELECT * FROM style_template_class WHERE ".
3074 "template_id = ".$ilDB->quote($a_tid,
"integer"));
3077 while ($rec = $ilDB->fetchAssoc($set))
3079 $key = $rec[
"class_type"];
3080 $class[$key] = $rec[
"class"];
3094 $tid = $ilDB->nextId(
"style_template");
3095 $ilDB->manipulate($q =
"INSERT INTO style_template ".
3096 "(id, style_id, name, temp_type)".
3098 $ilDB->quote($tid,
"integer").
",".
3099 $ilDB->quote($this->
getId(),
"integer").
",".
3100 $ilDB->quote($a_name,
"text").
",".
3101 $ilDB->quote($a_type,
"text").
3104 foreach ($a_classes as
$t => $c)
3106 $ilDB->manipulate($q =
"INSERT INTO style_template_class ".
3107 "(template_id, class_type, class)".
3109 $ilDB->quote($tid,
"integer").
",".
3110 $ilDB->quote(
$t,
"text").
",".
3111 $ilDB->quote($c,
"text").
3115 include_once(
"./Services/Style/classes/class.ilObjStyleSheetGUI.php");
3129 $ilDB->manipulate(
"UPDATE style_template SET ".
3130 "name = ".$ilDB->quote($a_name,
"text").
3131 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3133 $ilDB->manipulate(
"DELETE FROM style_template_class WHERE ".
3134 "template_id = ".$ilDB->quote($a_t_id,
"integer")
3136 foreach ($a_classes as
$t => $c)
3138 $ilDB->manipulate($q =
"INSERT INTO style_template_class ".
3139 "(template_id, class_type, class)".
3141 $ilDB->quote($a_t_id,
"integer").
",".
3142 $ilDB->quote(
$t,
"text").
",".
3143 $ilDB->quote($c,
"text").
3156 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
3157 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3158 "name = ".$ilDB->quote($a_template_name,
"text"));
3159 if ($rec = $ilDB->fetchAssoc($set))
3173 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
3174 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" ".
3175 " AND id = ".$ilDB->quote($a_t_id,
"integer"));
3177 if ($rec = $ilDB->fetchAssoc($set))
3194 $set = $ilDB->query(
"SELECT name FROM style_template WHERE ".
3195 " id = ".$ilDB->quote($a_t_id,
"integer"));
3197 if ($rec = $ilDB->fetchAssoc($set))
3199 return $rec[
"name"];
3212 $tag =
"<StyleTemplates>";
3214 $ttypes = array(
"table",
"vaccordion",
"haccordion");
3216 foreach ($ttypes as $ttype)
3235 $tag.=
'<StyleTemplate Name="'.$t[
"name"].
'">';
3237 foreach ($atts as
$type => $t)
3239 if ($c[
$type] !=
"")
3241 $tag.=
'<StyleClass Type="'.$type.
'" Value="'.$c[
$type].
'" />';
3245 $tag.=
"</StyleTemplate>";
3249 $tag.=
"</StyleTemplates>";
3261 $a_preview_html = str_replace(
' width=""',
"", $a_preview_html);
3262 $a_preview_html = str_replace(
' valign="top"',
"", $a_preview_html);
3263 $a_preview_html = str_replace(
'<div class="ilc_text_block_TableContent">',
"<div>", $a_preview_html);
3266 if (strlen($a_preview_html) > 4000)
3269 $a_preview_html =
"";
3271 $ilDB->manipulate(
"UPDATE style_template SET ".
3272 "preview = ".$ilDB->quote($a_preview_html,
"text").
3273 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3283 $set = $ilDB->query(
"SELECT preview FROM style_template ".
3284 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3285 if ($rec = $ilDB->fetchAssoc($set))
3287 return $rec[
"preview"];
3300 $set = $ilDB->query(
"SELECT id FROM style_template ".
3301 " WHERE style_id = ".$ilDB->quote($a_style_id,
"integer").
3302 " AND name = ".$ilDB->quote($a_name,
"text"));
3303 if ($rec = $ilDB->fetchAssoc($set))
3318 $ilDB->manipulate(
"DELETE FROM style_template WHERE ".
3319 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3320 " id = ".$ilDB->quote($a_t_id,
"integer"));
3322 $ilDB->manipulate(
"DELETE FROM style_template_class WHERE ".
3323 "template_id = ".$ilDB->quote($a_t_id,
"integer")
3335 $ilDB->manipulate(
"DELETE FROM style_setting WHERE ".
3336 " style_id = ".$ilDB->quote($this->getId(),
"integer").
3337 " AND name = ".$ilDB->quote($a_name,
"text")
3340 $ilDB->manipulate(
"INSERT INTO style_setting ".
3341 "(style_id, name, value) VALUES (".
3342 $ilDB->quote($this->getId(),
"integer").
",".
3343 $ilDB->quote($a_name,
"text").
",".
3344 $ilDB->quote($a_value,
"text").
3355 $set = $ilDB->query(
"SELECT value FROM style_setting ".
3356 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
3357 " AND name = ".$ilDB->quote($a_name,
"text")
3359 $rec = $ilDB->fetchAssoc($set);
3361 return $rec[
"value"];
3371 $ilDB->replace(
"style_usage", array(
3372 "obj_id" => array(
"integer", (
int) $a_obj_id)),
3374 "style_id" => array(
"integer", (
int) $a_style_id))
3385 $set = $ilDB->query(
"SELECT style_id FROM style_usage ".
3386 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")
3388 $rec = $ilDB->fetchAssoc($set);
3390 return (
int) $rec[
"style_id"];