5 require_once
"./Services/Object/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"),
181 "input" =>
"percentage",
182 "group" =>
"special"),
183 "transform" => array(
184 "values" => array(
"rotate(90deg)",
"rotate(180deg)",
"rotate(270deg)"),
186 "group" =>
"special"),
187 "transform-origin" => array(
188 "values" => array(
"horizontal" => array(
"left",
"center",
"right"),
189 "vertical" => array(
"top",
"center",
"bottom")),
190 "input" =>
"background_position",
191 "group" =>
"special"),
193 "values" => array(
"auto",
"default",
"crosshair",
"pointer",
"move",
194 "n-resize",
"ne-resize",
"e-resize",
"se-resize",
"s-resize",
"sw-resize",
195 "w-resize",
"nw-resize",
"text",
"wait",
"help"),
197 "group" =>
"special"),
199 "values" => array (
"both",
"left",
"right",
"none"),
201 "group" =>
"special"),
203 "list-style-type.ol" => array(
204 "values" => array (
"decimal",
"lower-roman",
"upper-roman",
205 "lower-alpha",
"upper-alpha",
"lower-greek",
"hebrew",
206 "decimal-leading-zero",
"cjk-ideographic",
"hiragana",
207 "katakana",
"hiragana-iroha",
"katakana-iroha",
"none"),
210 "list-style-type.ul" => array(
211 "values" => array (
"disc",
"circle",
"square",
215 "list-style-image.ul" => array(
217 "input" =>
"background_image",
219 "list-style-position.ol" => array(
220 "values" => array (
"inside",
"outside"),
223 "list-style-position.ul" => array(
224 "values" => array (
"inside",
"outside"),
228 "border-collapse" => array(
229 "values" => array (
"collapse",
"separate"),
233 "caption-side" => array(
234 "values" => array (
"top",
"bottom",
"left",
"right"),
243 array(
"ol" => array(
"ol"),
"ul" => array(
"ul"),
244 "table" => array(
"table"),
"positioning" => array(
"h1",
"h2",
"h3",
"div",
"img",
"table",
"a"));
248 "text_block" => array(
"text_block",
"heading1",
"heading2",
"heading3"),
249 "text_inline" => array(
"text_inline",
"sub",
"sup"),
250 "section" => array(
"section"),
251 "link" => array(
"link"),
252 "table" => array(
"table",
"table_cell",
"table_caption"),
253 "list" => array(
"list_o",
"list_u",
"list_item"),
254 "flist" => array(
"flist_cont",
"flist_head",
"flist",
"flist_li",
"flist_a"),
255 "media" => array(
"media_cont",
"media_caption",
"iim",
"marker"),
256 "tabs" => array(
"va_cntr",
"va_icntr",
"va_ihead",
"va_iheada",
"va_ihcap",
"va_icont",
257 "ha_cntr",
"ha_icntr",
"ha_ihead",
"ha_iheada",
"ha_ihcap",
"ha_icont",
"ca_cntr",
"ca_icntr",
"ca_ihead",
"ca_icont"),
258 "question" => array(
"question",
"qtitle",
"qanswer",
"qinput",
"qlinput",
"qsubmit",
"qfeedr",
"qfeedw",
259 "qimg",
"qordul",
"qordli",
"qimgd",
"qetitem",
"qetcorr",
"qover"),
260 "page" => array(
"page_frame",
"page_cont",
"page_title",
"page_fn",
261 "page_tnav",
"page_bnav",
"page_lnav",
"page_rnav",
"page_lnavlink",
"page_rnavlink",
262 "page_lnavimage",
"page_rnavimage"),
263 "glo" => array(
"glo_overlay",
"glo_ovtitle",
"glo_ovclink",
"glo_ovuglink",
"glo_ovuglistlink"),
264 "sco" => array(
"sco_title",
"sco_keyw",
"sco_desc",
"sco_desct",
"sco_obj",
"sco_objt",
"sco_fmess"),
265 "rte" => array(
"rte_menu",
"rte_mlink",
"rte_tree",
"rte_node",
"rte_tlink",
"rte_status",
266 "rte_tul",
"rte_tli",
"rte_texp",
"rte_tclink",
"rte_drag")
271 "text_block",
"section",
"media_cont",
"table",
"table_cell",
"flist_li",
"table_caption",
273 "va_cntr",
"va_icntr",
"va_ihead",
"va_iheada",
"va_ihcap",
"va_icont",
274 "ha_cntr",
"ha_icntr",
"ha_ihead",
"ha_iheada",
"ha_ihcap",
"ha_icont",
275 "ca_cntr",
"ca_icntr",
"ca_ihead",
"ca_icont" 280 "table",
"table_cell" 285 "text_block" =>
"div",
289 "text_inline" =>
"span",
295 "table_cell" =>
"td",
296 "table_caption" =>
"caption",
297 "media_cont" =>
"table",
298 "media_caption" =>
"div",
301 "glo_overlay" =>
"div",
302 "glo_ovtitle" =>
"h1",
303 "glo_ovclink" =>
"a",
304 "glo_ovuglink" =>
"a",
305 "glo_ovuglistlink" =>
"a",
306 "sco_title" =>
"div",
310 "sco_desct" =>
"div",
312 "sco_fmess" =>
"div",
319 "rte_status" =>
"div",
327 "flist_cont" =>
"div",
328 "flist_head" =>
"div",
342 "qlinput" =>
"textarea",
343 "qsubmit" =>
"input",
347 "page_frame" =>
"div",
348 "page_cont" =>
"div",
351 "page_tnav" =>
"div",
352 "page_bnav" =>
"div",
353 "page_lnav" =>
"div",
354 "page_rnav" =>
"div",
355 "page_lnavlink" =>
"a",
356 "page_rnavlink" =>
"a",
357 "page_lnavimage" =>
"img",
358 "page_rnavimage" =>
"img",
359 "page_title" =>
"h1",
364 "va_iheada" =>
"div",
369 "ha_iheada" =>
"div",
380 array (
"a" => array(
"hover"),
"div" => array(
"hover"),
"img" => array(
"hover"));
384 array(
"type" =>
"text_block",
"class" =>
"Standard"),
385 array(
"type" =>
"text_block",
"class" =>
"List"),
386 array(
"type" =>
"text_block",
"class" =>
"TableContent"),
387 array(
"type" =>
"heading1",
"class" =>
"Headline1"),
388 array(
"type" =>
"heading2",
"class" =>
"Headline2"),
389 array(
"type" =>
"heading3",
"class" =>
"Headline3"),
390 array(
"type" =>
"text_inline",
"class" =>
"Comment"),
391 array(
"type" =>
"text_inline",
"class" =>
"Emph"),
392 array(
"type" =>
"text_inline",
"class" =>
"Quotation"),
393 array(
"type" =>
"text_inline",
"class" =>
"Strong"),
394 array(
"type" =>
"text_inline",
"class" =>
"Accent"),
395 array(
"type" =>
"text_inline",
"class" =>
"Important"),
396 array(
"type" =>
"sup",
"class" =>
"Sup"),
397 array(
"type" =>
"sub",
"class" =>
"Sub"),
398 array(
"type" =>
"link",
"class" =>
"IntLink"),
399 array(
"type" =>
"link",
"class" =>
"ExtLink"),
400 array(
"type" =>
"link",
"class" =>
"FootnoteLink"),
401 array(
"type" =>
"link",
"class" =>
"FileLink"),
402 array(
"type" =>
"link",
"class" =>
"GlossaryLink"),
403 array(
"type" =>
"media_cont",
"class" =>
"MediaContainer"),
404 array(
"type" =>
"table",
"class" =>
"StandardTable"),
405 array(
"type" =>
"media_caption",
"class" =>
"MediaCaption"),
406 array(
"type" =>
"iim",
"class" =>
"ContentPopup"),
407 array(
"type" =>
"marker",
"class" =>
"Marker"),
408 array(
"type" =>
"page_frame",
"class" =>
"PageFrame"),
409 array(
"type" =>
"page_cont",
"class" =>
"PageContainer"),
410 array(
"type" =>
"page",
"class" =>
"Page"),
411 array(
"type" =>
"page_tnav",
"class" =>
"TopNavigation"),
412 array(
"type" =>
"page_bnav",
"class" =>
"BottomNavigation"),
413 array(
"type" =>
"page_lnav",
"class" =>
"LeftNavigation"),
414 array(
"type" =>
"page_rnav",
"class" =>
"RightNavigation"),
415 array(
"type" =>
"page_lnavlink",
"class" =>
"LeftNavigationLink"),
416 array(
"type" =>
"page_rnavlink",
"class" =>
"RightNavigationLink"),
417 array(
"type" =>
"page_lnavimage",
"class" =>
"LeftNavigationImage"),
418 array(
"type" =>
"page_rnavimage",
"class" =>
"RightNavigationImage"),
419 array(
"type" =>
"page_fn",
"class" =>
"Footnote"),
420 array(
"type" =>
"page_title",
"class" =>
"PageTitle"),
421 array(
"type" =>
"glo_overlay",
"class" =>
"GlossaryOverlay"),
422 array(
"type" =>
"glo_ovtitle",
"class" =>
"GlossaryOvTitle"),
423 array(
"type" =>
"glo_ovclink",
"class" =>
"GlossaryOvCloseLink"),
424 array(
"type" =>
"glo_ovuglink",
"class" =>
"GlossaryOvUnitGloLink"),
425 array(
"type" =>
"glo_ovuglistlink",
"class" =>
"GlossaryOvUGListLink"),
426 array(
"type" =>
"sco_title",
"class" =>
"Title"),
427 array(
"type" =>
"sco_desc",
"class" =>
"Description"),
428 array(
"type" =>
"sco_desct",
"class" =>
"DescriptionTop"),
429 array(
"type" =>
"sco_keyw",
"class" =>
"Keywords"),
430 array(
"type" =>
"sco_obj",
"class" =>
"Objective"),
431 array(
"type" =>
"sco_objt",
"class" =>
"ObjectiveTop"),
432 array(
"type" =>
"sco_fmess",
"class" =>
"FinalMessage"),
433 array(
"type" =>
"rte_menu",
"class" =>
"RTEMenu"),
434 array(
"type" =>
"rte_menu",
"class" =>
"RTELogo"),
435 array(
"type" =>
"rte_menu",
"class" =>
"RTELinkBar"),
436 array(
"type" =>
"rte_mlink",
"class" =>
"RTELink"),
437 array(
"type" =>
"rte_mlink",
"class" =>
"RTELinkDisabled"),
438 array(
"type" =>
"rte_tree",
"class" =>
"RTETree"),
439 array(
"type" =>
"rte_node",
"class" =>
"RTECourse"),
440 array(
"type" =>
"rte_node",
"class" =>
"RTEChapter"),
441 array(
"type" =>
"rte_node",
"class" =>
"RTESco"),
442 array(
"type" =>
"rte_node",
"class" =>
"RTEAsset"),
443 array(
"type" =>
"rte_node",
"class" =>
"RTECourseDisabled"),
444 array(
"type" =>
"rte_node",
"class" =>
"RTEChapterDisabled"),
445 array(
"type" =>
"rte_node",
"class" =>
"RTEScoDisabled"),
446 array(
"type" =>
"rte_node",
"class" =>
"RTEAssetDisabled"),
447 array(
"type" =>
"rte_status",
"class" =>
"RTEAsset"),
448 array(
"type" =>
"rte_status",
"class" =>
"RTECompleted"),
449 array(
"type" =>
"rte_status",
"class" =>
"RTENotAttempted"),
450 array(
"type" =>
"rte_status",
"class" =>
"RTERunning"),
451 array(
"type" =>
"rte_status",
"class" =>
"RTEIncomplete"),
452 array(
"type" =>
"rte_status",
"class" =>
"RTEPassed"),
453 array(
"type" =>
"rte_status",
"class" =>
"RTEFailed"),
454 array(
"type" =>
"rte_status",
"class" =>
"RTEBrowsed"),
455 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeLink"),
456 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeLinkDisabled"),
457 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeCurrent"),
458 array(
"type" =>
"rte_tul",
"class" =>
"RTETreeList"),
459 array(
"type" =>
"rte_tli",
"class" =>
"RTETreeItem"),
460 array(
"type" =>
"rte_texp",
"class" =>
"RTETreeExpanded"),
461 array(
"type" =>
"rte_texp",
"class" =>
"RTETreeCollapsed"),
462 array(
"type" =>
"rte_tree",
"class" =>
"RTETreeControl"),
463 array(
"type" =>
"rte_tclink",
"class" =>
"RTETreeControlLink"),
464 array(
"type" =>
"rte_drag",
"class" =>
"RTEDragBar"),
465 array(
"type" =>
"list_o",
"class" =>
"NumberedList"),
466 array(
"type" =>
"list_u",
"class" =>
"BulletedList"),
467 array(
"type" =>
"list_item",
"class" =>
"StandardListItem"),
468 array(
"type" =>
"question",
"class" =>
"Standard"),
469 array(
"type" =>
"question",
"class" =>
"SingleChoice"),
470 array(
"type" =>
"question",
"class" =>
"MultipleChoice"),
471 array(
"type" =>
"question",
"class" =>
"TextQuestion"),
472 array(
"type" =>
"question",
"class" =>
"OrderingQuestion"),
473 array(
"type" =>
"question",
"class" =>
"MatchingQuestion"),
474 array(
"type" =>
"question",
"class" =>
"ImagemapQuestion"),
475 array(
"type" =>
"question",
"class" =>
"ErrorText"),
476 array(
"type" =>
"question",
"class" =>
"TextSubset"),
477 array(
"type" =>
"question",
"class" =>
"ClozeTest"),
478 array(
"type" =>
"qtitle",
"class" =>
"Title"),
479 array(
"type" =>
"qanswer",
"class" =>
"Answer"),
480 array(
"type" =>
"qimg",
"class" =>
"QuestionImage"),
481 array(
"type" =>
"qimgd",
"class" =>
"ImageDetailsLink"),
482 array(
"type" =>
"qordul",
"class" =>
"OrderList"),
483 array(
"type" =>
"qordli",
"class" =>
"OrderListItem"),
484 array(
"type" =>
"qordul",
"class" =>
"OrderListHorizontal"),
485 array(
"type" =>
"qordli",
"class" =>
"OrderListItemHorizontal"),
486 array(
"type" =>
"qetitem",
"class" =>
"ErrorTextItem"),
487 array(
"type" =>
"qetitem",
"class" =>
"ErrorTextSelected"),
488 array(
"type" =>
"qetcorr",
"class" =>
"ErrorTextCorrected"),
489 array(
"type" =>
"qinput",
"class" =>
"TextInput"),
490 array(
"type" =>
"qlinput",
"class" =>
"LongTextInput"),
491 array(
"type" =>
"qsubmit",
"class" =>
"Submit"),
492 array(
"type" =>
"qfeedr",
"class" =>
"FeedbackRight"),
493 array(
"type" =>
"qfeedw",
"class" =>
"FeedbackWrong"),
494 array(
"type" =>
"qover",
"class" =>
"Correct"),
495 array(
"type" =>
"qover",
"class" =>
"Inorrect"),
496 array(
"type" =>
"qover",
"class" =>
"StatusMessage"),
497 array(
"type" =>
"qover",
"class" =>
"WrongAnswersMessage"),
498 array(
"type" =>
"flist_cont",
"class" =>
"FileListContainer"),
499 array(
"type" =>
"flist_head",
"class" =>
"FileListHeading"),
500 array(
"type" =>
"flist",
"class" =>
"FileList"),
501 array(
"type" =>
"flist_li",
"class" =>
"FileListItem"),
502 array(
"type" =>
"flist_a",
"class" =>
"FileListItemLink")
508 "caption" =>
"table_caption",
509 "row_head" =>
"table_cell",
510 "row_foot" =>
"table_cell",
511 "col_head" =>
"table_cell",
512 "col_foot" =>
"table_cell",
513 "odd_row" =>
"table_cell",
514 "even_row" =>
"table_cell",
515 "odd_col" =>
"table_cell",
516 "even_col" =>
"table_cell"),
517 "vaccordion" => array(
518 "va_cntr" =>
"va_cntr",
519 "va_icntr" =>
"va_icntr",
520 "va_ihead" =>
"va_ihead",
521 "va_iheada" =>
"va_iheada",
522 "va_ihcap" =>
"va_ihcap",
523 "va_icont" =>
"va_icont" 525 "haccordion" => array(
526 "ha_cntr" =>
"ha_cntr",
527 "ha_icntr" =>
"ha_icntr",
528 "ha_ihead" =>
"ha_ihead",
529 "ha_iheada" =>
"ha_iheada",
530 "ha_ihcap" =>
"ha_ihcap",
531 "ha_icont" =>
"ha_icont" 534 "ca_cntr" =>
"ca_cntr",
535 "ca_icntr" =>
"ca_icntr",
536 "ca_ihead" =>
"ca_ihead",
537 "ca_icont" =>
"ca_icont" 555 $this->
style = array();
556 if($a_call_by_reference)
558 $this->
ilias->raiseError(
"Can't instantiate style object via reference id.",$this->
ilias->error_obj->FATAL);
561 parent::ilObject($a_id,
false);
569 $this->
ilias->raiseError(
"Operation ilObjStyleSheet::setRefId() not allowed.",$this->
ilias->error_obj->FATAL);
586 $this->
ilias->raiseError(
"Operation ilObjStyleSheet::putInTree() not allowed.",$this->
ilias->error_obj->FATAL);
594 $this->
ilias->raiseError(
"Operation ilObjStyleSheet::createReference() not allowed.",$this->
ilias->error_obj->FATAL);
602 $this->up_to_date = $a_up_to_date;
610 return $this->up_to_date;
618 $this->scope = $a_scope;
636 $q =
"UPDATE style_data SET uptodate = ".
637 $ilDB->quote((
int) $a_up_to_date,
"integer").
638 " WHERE id = ".$ilDB->quote($a_id,
"integer");
639 $ilDB->manipulate($q);
649 $q =
"SELECT uptodate FROM style_data ".
650 " WHERE id = ".$ilDB->quote($a_id,
"integer");
651 $res = $ilDB->query($q);
652 $sty = $ilDB->fetchAssoc(
$res);
654 return (
boolean) $sty[
"uptodate"];
664 $q =
"UPDATE style_data SET standard = ".
665 $ilDB->quote((
int) $a_std,
"integer").
666 " WHERE id = ".$ilDB->quote($a_id,
"integer");
667 $ilDB->manipulate($q);
677 $q =
"UPDATE style_data SET category = ".
678 $ilDB->quote((
int) $a_scope,
"integer").
679 " WHERE id = ".$ilDB->quote($a_id,
"integer");
680 $ilDB->manipulate($q);
690 $q =
"SELECT * FROM style_data ".
691 " WHERE id = ".$ilDB->quote($a_id,
"integer");
692 $res = $ilDB->query($q);
693 $sty = $ilDB->fetchAssoc(
$res);
695 return (
boolean) $sty[
"standard"];
705 $q =
"UPDATE style_data SET active = ".
706 $ilDB->quote((
int) $a_active,
"integer").
707 " WHERE id = ".$ilDB->quote($a_id,
"integer");
708 $ilDB->manipulate($q);
718 $q =
"SELECT * FROM style_data ".
719 " WHERE id = ".$ilDB->quote($a_id,
"integer");
720 $res = $ilDB->query($q);
721 $sty = $ilDB->fetchAssoc(
$res);
723 return (
boolean) $sty[
"active"];
730 $a_include_deactivated =
false, $a_scope = 0)
734 $default_style = $ilias->getSetting(
"default_content_style_id");
737 if (!$a_include_deactivated)
739 $and_str =
" AND active = 1";
742 $q =
"SELECT * FROM style_data ".
743 " WHERE standard = 1".$and_str;
744 $res = $ilDB->query($q);
746 while($sty = $ilDB->fetchAssoc(
$res))
748 if (!$a_exclude_default_style || $default_style != $sty[
"id"])
751 if ($a_scope > 0 && $sty[
"category"] > 0)
753 if ($tree->isInTree($sty[
"category"]) &&
754 $tree->isInTree($a_scope))
756 $path = $tree->getPathId($a_scope);
757 if (!in_array($sty[
"category"],
$path))
777 global $ilAccess,
$ilDB;
779 $clonable_styles = array();
781 $q =
"SELECT * FROM style_data";
782 $style_set = $ilDB->query($q);
783 while($style_rec = $ilDB->fetchAssoc($style_set))
786 if ($style_rec[
"standard"] == 1)
788 if ($style_rec[
"active"] == 1)
795 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
797 foreach($obj_ids as
$id)
802 if ($ilAccess->checkAccess(
"write",
"", $ref_id))
811 $clonable_styles[$style_rec[
"id"]] =
816 asort($clonable_styles);
818 return $clonable_styles;
826 $this->meta_data =& $a_meta_data;
836 if (!is_object(self::$basic_style_dom))
839 self::$basic_style_dom->load(self::$basic_style_file);
842 return self::$basic_style_dom;
850 return $this->meta_data;
856 function create($a_from_style = 0, $a_import_mode =
false)
862 if ($a_from_style == 0)
877 $q =
"INSERT INTO style_data (id, uptodate, category) VALUES ".
878 "(".$ilDB->quote($this->
getId(),
"integer").
", 0,".
879 $ilDB->quote((
int) $this->
getScope(),
"integer").
")";
880 $ilDB->manipulate($q);
888 $q =
"SELECT * FROM style_parameter WHERE style_id = ".
889 $ilDB->quote($a_from_style,
"integer");
890 $par_set = $ilDB->query($q);
891 while($par_rec = $ilDB->fetchAssoc($par_set))
893 $def[] = array(
"tag" => $par_rec[
"tag"],
"class" => $par_rec[
"class"],
894 "parameter" => $par_rec[
"parameter"],
"value" => $par_rec[
"value"],
895 "type" => $par_rec[
"type"],
"mq_id" => $par_rec[
"mq_id"],
"custom" => $par_rec[
"custom"]);
900 $q =
"SELECT * FROM style_char WHERE style_id = ".
901 $ilDB->quote($a_from_style,
"integer");
902 $par_set = $ilDB->query($q);
903 while($par_rec = $ilDB->fetchAssoc($par_set))
905 $chars[] = array(
"type" => $par_rec[
"type"],
"characteristic" => $par_rec[
"characteristic"]);
911 $mqs = $from_style->getMediaQueries();
912 $mq_mapping = array();
913 foreach ($mqs as $mq)
916 $mq_mapping[$mq[
"id"]] = $nid;
920 foreach ($def as $sty)
922 $id = $ilDB->nextId(
"style_parameter");
923 $q =
"INSERT INTO style_parameter (id, style_id, tag, class, parameter, value, type, mq_id, custom) VALUES ".
925 $ilDB->quote(
$id,
"integer").
",".
926 $ilDB->quote($this->
getId(),
"integer").
",".
927 $ilDB->quote($sty[
"tag"],
"text").
",".
928 $ilDB->quote($sty[
"class"],
"text").
",".
929 $ilDB->quote($sty[
"parameter"],
"text").
",".
930 $ilDB->quote($sty[
"value"],
"text").
",".
931 $ilDB->quote($sty[
"type"],
"text").
",".
932 $ilDB->quote((
int) $mq_mapping[$sty[
"mq_id"]],
"integer").
",".
933 $ilDB->quote($sty[
"custom"],
"integer").
935 $ilDB->manipulate($q);
939 foreach ($chars as $char)
941 $q =
"INSERT INTO style_char (style_id, type, characteristic) VALUES ".
942 "(".$ilDB->quote($this->
getId(),
"integer").
",".
943 $ilDB->quote($char[
"type"],
"text").
",".
944 $ilDB->quote($char[
"characteristic"],
"text").
")";
945 $ilDB->manipulate($q);
949 $q =
"INSERT INTO style_data (id, uptodate, category) VALUES ".
950 "(".$ilDB->quote($this->
getId(),
"integer").
", 0,".
951 $ilDB->quote((
int) $this->
getScope(),
"integer").
")";
952 $ilDB->manipulate($q);
960 $colors = $from_style->getColors();
961 foreach ($colors as $c)
963 $this->
addColor($c[
"name"], $c[
"code"]);
968 foreach ($tcts as $tct => $v)
973 $this->
addTemplate($tct, $t[
"name"], $t[
"classes"]);
995 if (empty(
$core_styles[$a_type.
".".$a_tag.
".".$a_class]))
998 $st = $ilDB->manipulateF(
999 "DELETE FROM style_char WHERE style_id = %s AND type = %s AND characteristic = %s",
1000 array(
"integer",
"text",
"text"),
1001 array($this->
getId(), $a_type, $a_class));
1004 $st = $ilDB->manipulateF(
"DELETE FROM style_parameter WHERE style_id = %s AND tag = %s AND type = %s AND class = %s",
1005 array(
"integer",
"text",
"text",
"text"),
1006 array($this->
getId(), $a_tag, $a_type, $a_class));
1020 $set = $ilDB->queryF(
1021 "SELECT style_id FROM style_char WHERE style_id = %s AND characteristic = %s AND type = %s",
1022 array(
"integer",
"text",
"text"),
1023 array($this->
getId(), $a_char, $a_style_type));
1024 if ($rec = $ilDB->fetchAssoc($set))
1039 $ilDB->manipulateF(
"INSERT INTO style_char (style_id, type, characteristic, hide)".
1040 " VALUES (%s,%s,%s,%s) ",
1041 array(
"integer",
"text",
"text",
"integer"),
1042 array($this->
getId(), $a_type, $a_char, $a_hidden));
1055 $a_from_type, $a_from_char, $a_to_char)
1068 $pars = $from_style->getParametersOfClass($a_from_type, $a_from_char);
1071 foreach ($pars as $p => $v)
1073 if (substr($v, 0, 1) ==
"!")
1075 $colors[] = substr($v, 1);
1078 $a_to_char, $p, $v, $a_from_type);
1082 foreach ($colors as $c)
1086 $this->
addColor($c, $from_style->getColorCodeForName($c));
1100 $chars = $this->chars;
1102 if (is_array($this->chars_by_type[$a_type]))
1104 $chars = $this->chars_by_type[$a_type];
1109 foreach ($chars as $k => $char)
1111 if ($a_type ==
"" && $this->hidden_chars[$char[
"type"].
":".$char[
"class"]])
1115 else if ($this->hidden_chars[$a_type.
":".$char])
1130 $this->chars = $a_chars;
1141 $ilDB->manipulate(
"UPDATE style_char SET ".
1142 " hide = ".$ilDB->quote((
int) $a_hide,
"integer").
1143 " WHERE style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1144 " type = ".$ilDB->quote($a_type,
"text").
" AND ".
1145 " characteristic = ".$ilDB->quote($a_char,
"text")
1156 $set = $ilDB->query(
"SELECT hide FROM style_char ".
1157 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
1158 " type = ".$ilDB->quote($a_type,
"text").
" AND ".
1159 " characteristic = ".$ilDB->quote($a_char,
"text")
1161 $rec = $ilDB->fetchAssoc($set);
1163 return $rec[
"hide"];
1176 $lng->loadLanguageModule(
"style");
1179 $new_obj->setTitle($this->
getTitle().
" (".$lng->txt(
"sty_acopy").
")");
1180 $new_obj->setType($this->
getType());
1182 $new_obj->create($this->
getId());
1184 $new_obj->writeStyleSetting(
"disable_auto_margins",
1187 return $new_obj->getId();
1207 function addParameter($a_tag, $a_par, $a_type, $a_mq_id = 0, $a_custom =
false)
1212 $tag = explode(
".", $a_tag);
1213 $value = $avail_params[$a_par][0];
1214 $id = $ilDB->nextId(
"style_parameter");
1215 $q =
"INSERT INTO style_parameter (id,style_id, type, tag, class, parameter, value, mq_id, custom) VALUES ".
1217 $ilDB->quote(
$id,
"integer").
",".
1218 $ilDB->quote($this->
getId(),
"integer").
",".
1219 $ilDB->quote($a_type,
"text").
",".
1220 $ilDB->quote($tag[0],
"text").
",".
1221 $ilDB->quote($tag[1],
"text").
",".
1222 $ilDB->quote($a_par,
"text").
",".
1223 $ilDB->quote($value,
"text").
",".
1224 $ilDB->quote($a_mq_id,
"integer").
",".
1225 $ilDB->quote($a_custom,
"integer").
1227 $ilDB->manipulate($q);
1251 if(!is_writable($sty_data_dir))
1253 $ilErr->raiseError(
"Style data directory (".$sty_data_dir
1254 .
") not writeable.", $ilErr->FATAL);
1257 $style_dir = $sty_data_dir.
"/sty_".$a_style_id;
1259 if(!@is_dir($style_dir))
1261 $ilErr->raiseError(
"Creation of style directory failed (".
1262 $style_dir.
").",$ilErr->FATAL);
1266 $im_dir = $style_dir.
"/images";
1268 if(!@is_dir($im_dir))
1270 $ilErr->raiseError(
"Creation of Import Directory failed (".
1271 $im_dir.
").", $ilErr->FATAL);
1275 $thumb_dir = $style_dir.
"/images/thumbnails";
1277 if(!@is_dir($thumb_dir))
1279 $ilErr->raiseError(
"Creation of Import Directory failed (".
1280 $thumb_dir.
").", $ilErr->FATAL);
1320 foreach($entries as $entry)
1322 if (substr($entry[
"entry"],0,1) ==
".")
1326 if ($entry[
"type"] !=
"dir")
1372 $q =
"DELETE FROM style_parameter WHERE id = ".
1373 $ilDB->quote($a_id,
"integer");
1386 function deleteStylePar($a_tag, $a_class, $a_par, $a_type, $a_mq_id = 0, $a_custom =
false)
1390 $q =
"DELETE FROM style_parameter WHERE ".
1391 " style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1392 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1393 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1394 " mq_id = ".$ilDB->quote($a_mq_id,
"integer").
" AND ".
1395 " custom = ".$ilDB->quote($a_custom,
"integer").
" AND ".
1396 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1397 " parameter = ".$ilDB->quote($a_par,
"text");
1399 $ilDB->manipulate($q);
1415 $q =
"DELETE FROM style_parameter WHERE ".
1416 " style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1417 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1418 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1419 " mq_id = ".$ilDB->quote($a_mq_id,
"integer").
" AND ".
1420 " custom = ".$ilDB->quote(1,
"integer").
" AND ".
1421 " ".$ilDB->equals(
"type", $a_type,
"text",
true);
1423 $ilDB->manipulate($q);
1438 $q =
"DELETE FROM style_parameter WHERE ".
1439 " style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1440 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1441 " ".$ilDB->equals(
"type", $a_type,
"text",
true);
1443 $ilDB->manipulate($q);
1458 $def_style = $this->
ilias->getSetting(
"default_content_style_id");
1459 if ($def_style == $this->
getId())
1461 $this->
ilias->deleteSetting(
"default_content_style_id");
1465 $fixed_style = $this->
ilias->getSetting(
"fixed_content_style_id");
1466 if ($fixed_style == $this->
getId())
1468 $this->
ilias->deleteSetting(
"fixed_content_style_id");
1472 $q =
"DELETE FROM style_parameter WHERE style_id = ".
1473 $ilDB->quote($this->
getId(),
"integer");
1474 $ilDB->manipulate($q);
1478 if (is_file($css_file_name))
1480 unlink($css_file_name);
1484 $ilDB->manipulate(
"DELETE FROM sty_media_query WHERE ".
1485 " style_id = ".$ilDB->quote($this->getId(),
"integer")
1489 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
1493 $q =
"DELETE FROM style_data WHERE id = ".
1494 $ilDB->quote($this->
getId(),
"integer");
1495 $ilDB->manipulate($q);
1509 $q =
"SELECT * FROM style_parameter WHERE style_id = ".
1510 $ilDB->quote($this->
getId(),
"integer").
" ORDER BY tag, class, type, mq_id ";
1511 $style_set = $ilDB->query($q);
1516 $this->
style = array();
1520 $this->end_styles = array();
1521 while($style_rec = $ilDB->fetchAssoc($style_set))
1523 if ($style_rec[
"tag"] != $ctag || $style_rec[
"class"] != $cclass
1524 || $style_rec[
"type"] != $ctype || $style_rec[
"mq_id"] != $cmq_id)
1529 if (in_array($ctype, array(
"ha_iheada",
"va_iheada")))
1531 $this->end_styles[] = $tag;
1535 $this->
style[] = $tag;
1540 $ctag = $style_rec[
"tag"];
1541 $cclass = $style_rec[
"class"];
1542 $ctype = $style_rec[
"type"];
1543 $cmq_id = $style_rec[
"mq_id"];
1544 $tag[] = $style_rec;
1546 $this->style_class[$ctype][$cclass][$cmq_id][$style_rec[
"parameter"]] = $style_rec[
"value"];
1550 $this->
style[] = $tag;
1552 foreach ($this->end_styles as $s)
1554 $this->
style[] = $s;
1557 $q =
"SELECT * FROM style_data WHERE id = ".
1558 $ilDB->quote($this->
getId(),
"integer");
1559 $res = $ilDB->query($q);
1560 $sty = $ilDB->fetchAssoc(
$res);
1565 $this->chars = array();
1566 $this->chars_by_type = array();
1567 $q =
"SELECT * FROM style_char WHERE style_id = ".
1568 $ilDB->quote($this->
getId(),
"integer").
1569 " ORDER BY type ASC, characteristic ASC";
1570 $par_set = $ilDB->query($q);
1571 while($par_rec = $ilDB->fetchAssoc($par_set))
1573 $this->chars[] = array(
"type" => $par_rec[
"type"],
"class" => $par_rec[
"characteristic"],
"hide" => $par_rec[
"hide"]);
1574 $this->chars_by_type[$par_rec[
"type"]][] = $par_rec[
"characteristic"];
1575 if ($par_rec[
"hide"])
1577 $this->hidden_chars[$par_rec[
"type"].
":".$par_rec[
"characteristic"]] =
true;
1590 if ($a_target_file ==
"")
1596 $css_file_name = $a_target_file;
1598 $css_file = fopen($css_file_name,
"w");
1600 $page_background =
"";
1602 $mqs = array(array(
"mquery" =>
"",
"id" => 0));
1609 foreach ($mqs as $mq)
1613 fwrite ($css_file,
"@media ".$mq[
"mquery"].
" {\n");
1616 foreach ($style as $tag)
1618 if ($tag[0][
"mq_id"] != $mq[
"id"])
1622 fwrite ($css_file, $tag[0][
"tag"].
".ilc_".$tag[0][
"type"].
"_".$tag[0][
"class"].
"\n");
1623 if ($tag[0][
"tag"] ==
"td")
1625 fwrite ($css_file,
",th".
".ilc_".$tag[0][
"type"].
"_".$tag[0][
"class"].
"\n");
1627 if (in_array($tag[0][
"tag"], array(
"h1",
"h2",
"h3")))
1629 fwrite ($css_file,
",div.ilc_text_block_".$tag[0][
"class"].
"\n");
1630 fwrite ($css_file,
",body.ilc_text_block_".$tag[0][
"class"].
"\n");
1632 if ($tag[0][
"type"] ==
"text_block")
1634 fwrite ($css_file,
",body.ilc_text_block_".$tag[0][
"class"].
"\n");
1636 fwrite ($css_file,
"{\n");
1639 $t_border = array();
1641 foreach($tag as $par)
1643 $cur_par = $par[
"parameter"];
1644 $cur_val = $par[
"value"];
1647 if (is_int(strpos($cur_par,
"color")) && substr(trim($cur_val), 0, 1) ==
"!")
1652 if ($tag[0][
"type"] ==
"table" && is_int(strpos($par[
"parameter"],
"border")))
1654 $t_border[$cur_par] = $cur_val;
1657 if (in_array($cur_par, array(
"background-image",
"list-style-image")))
1659 if (is_int(strpos($cur_val,
"/")))
1661 $cur_val =
"url(".$cur_val.
")";
1665 if ($a_image_dir ==
"")
1667 $cur_val =
"url(../sty/sty_".$this->getId().
"/images/".$cur_val.
")";
1671 $cur_val =
"url(".$a_image_dir.
"/".$cur_val.
")";
1676 if ($cur_par ==
"opacity")
1678 $cur_val = ((int) $cur_val) / 100;
1681 fwrite ($css_file,
"\t".$cur_par.
": ".$cur_val.
";\n");
1684 if ($cur_par ==
"min-height")
1686 fwrite ($css_file,
"\t".
"height".
": ".
"auto !important".
";\n");
1687 fwrite ($css_file,
"\t".
"height".
": ".$cur_val.
";\n");
1691 if ($cur_par ==
"opacity")
1693 fwrite ($css_file,
"\t".
'-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity='.($cur_val * 100).
')"'.
";\n");
1694 fwrite ($css_file,
"\t".
'filter: alpha(opacity='.($cur_val * 100).
')'.
";\n");
1695 fwrite ($css_file,
"\t".
'-moz-opacity: '.$cur_val.
";\n");
1699 if ($cur_par ==
"transform")
1701 fwrite ($css_file,
"\t".
'-webkit-transform: '.$cur_val.
";\n");
1702 fwrite ($css_file,
"\t".
'-moz-transform: '.$cur_val.
";\n");
1703 fwrite ($css_file,
"\t".
'-ms-transform: '.$cur_val.
";\n");
1707 if ($cur_par ==
"transform-origin")
1709 fwrite ($css_file,
"\t".
'-webkit-transform-origin: '.$cur_val.
";\n");
1710 fwrite ($css_file,
"\t".
'-moz-transform-origin: '.$cur_val.
";\n");
1711 fwrite ($css_file,
"\t".
'-ms-transform-origin: '.$cur_val.
";\n");
1715 if ($tag[0][
"tag"] ==
"div" && $tag[0][
"class"] ==
"Page" 1716 && $cur_par ==
"background-color")
1718 $page_background = $cur_val;
1721 fwrite ($css_file,
"}\n");
1722 fwrite ($css_file,
"\n");
1742 if ($page_background !=
"")
1744 fwrite ($css_file,
"td.ilc_Page\n");
1745 fwrite ($css_file,
"{\n");
1746 fwrite ($css_file,
"\t".
"background-color: ".$page_background.
";\n");
1747 fwrite ($css_file,
"}\n");
1751 fwrite ($css_file,
"}\n");
1771 $fixed_style = $ilSetting->get(
"fixed_content_style_id");
1772 if ($fixed_style > 0)
1774 $a_style_id = $fixed_style;
1778 if ($a_style_id <= 0)
1780 $a_style_id = $ilSetting->get(
"default_content_style_id");
1799 if (is_array($this->style_class[$a_type][$a_class][$a_mq_id]))
1801 return $this->style_class[$a_type][$a_class][$a_mq_id];
1815 $rand = rand(1,999999);
1819 $fixed_style = $ilias->getSetting(
"fixed_content_style_id");
1820 if ($fixed_style > 0)
1822 $a_style_id = $fixed_style;
1826 if ($a_style_id <= 0)
1828 $a_style_id = $ilias->getSetting(
"default_content_style_id");
1837 $style->writeCSSFile();
1841 require_once(
'./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
1848 return "./Services/COPage/css/content.css";
1859 return "./Services/COPage/css/print_content.css";
1869 return "./Services/COPage/css/syntaxhighlight.css";
1879 return "./Services/COPage/css/placeholder.css";
1890 $q =
"UPDATE style_data ".
1891 "SET category = ".$ilDB->quote((
int) $this->
getScope(),
"integer").
1892 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
1893 $ilDB->manipulate($q);
1906 $q =
"UPDATE style_parameter SET VALUE = ".
1907 $ilDB->quote($a_value,
"text").
" WHERE id = ".
1908 $ilDB->quote($a_id,
"integer");
1909 $style_set = $ilDB->manipulate($q);
1917 function replaceStylePar($a_tag, $a_class, $a_par, $a_val, $a_type, $a_mq_id = 0, $a_custom =
false)
1922 function _replaceStylePar($style_id, $a_tag, $a_class, $a_par, $a_val, $a_type, $a_mq_id = 0, $a_custom =
false)
1926 $q =
"SELECT * FROM style_parameter WHERE ".
1927 " style_id = ".$ilDB->quote($style_id,
"integer").
" AND ".
1928 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1929 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1930 " mq_id = ".$ilDB->quote($a_mq_id,
"integer").
" AND ".
1931 " custom = ".$ilDB->quote($a_custom,
"integer").
" AND ".
1932 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1933 " parameter = ".$ilDB->quote($a_par,
"text");
1935 $set = $ilDB->query($q);
1937 if ($rec = $set->fetchRow())
1939 $q =
"UPDATE style_parameter SET ".
1940 " value = ".$ilDB->quote($a_val,
"text").
" WHERE ".
1941 " style_id = ".$ilDB->quote($style_id,
"integer").
" AND ".
1942 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1943 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1944 " mq_id = ".$ilDB->quote($a_mq_id,
"integer").
" AND ".
1945 " custom = ".$ilDB->quote($a_custom,
"integer").
" AND ".
1946 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1947 " parameter = ".$ilDB->quote($a_par,
"text");
1949 $ilDB->manipulate($q);
1953 $id = $ilDB->nextId(
"style_parameter");
1954 $q =
"INSERT INTO style_parameter (id, value, style_id, tag, class, type, parameter, mq_id, custom) VALUES ".
1956 $ilDB->quote(
$id,
"integer").
",".
1957 $ilDB->quote($a_val,
"text").
",".
1958 " ".$ilDB->quote($this->
getId(),
"integer").
",".
1959 " ".$ilDB->quote($a_tag,
"text").
",".
1960 " ".$ilDB->quote($a_class,
"text").
",".
1961 " ".$ilDB->quote($a_type,
"text").
",".
1962 " ".$ilDB->quote($a_par,
"text").
",".
1963 " ".$ilDB->quote($a_mq_id,
"integer").
",".
1964 " ".$ilDB->quote($a_custom,
"integer").
1967 $ilDB->manipulate($q);
1985 $this->
style = $a_style;
1997 return str_replace(
"&",
"&", $a_str);
2006 $xml.=
"<StyleSheet>\n";
2009 $xml.=
"<Title>".$this->handleXmlString($this->
getTitle()).
"</Title>";
2010 $xml.=
"<Description>".$this->handleXmlString($this->
getDescription()).
"</Description>\n";
2013 foreach($this->chars as $char)
2015 $xml.=
"<Style Tag=\"".ilObjStyleSheet::_determineTag($char[
"type"]).
2016 "\" Type=\"".$char[
"type"].
"\" Class=\"".$char[
"class"].
"\">\n";
2017 foreach($this->
style as $style)
2019 if ($style[0][
"type"] == $char[
"type"] && $style[0][
"class"] == $char[
"class"])
2021 foreach($style as $tag)
2023 $xml.=
"<StyleParameter Name=\"".$tag[
"parameter"].
"\" Value=\"".$tag[
"value"].
"\" Custom=\"".$tag[
"custom"].
"\" />\n";
2027 $xml.=
"</Style>\n";
2033 $xml.=
"<StyleColor Name=\"".$color[
"name"].
"\" Code=\"".$color[
"code"].
"\"/>\n";
2038 foreach ($tcts as $tct => $v)
2044 $xml.=
"<StyleTemplate Type=\"".$tct.
"\" Name=\"".$t[
"name"].
"\">\n";
2045 foreach ($t[
"classes"] as $ct => $c)
2049 $xml.=
"<StyleTemplateClass ClassType=\"".$ct.
"\" Class=\"".$c.
"\"/>\n";
2052 $xml.=
"</StyleTemplate>\n";
2057 $xml.=
"</StyleSheet>";
2070 if(!is_writable($sty_data_dir))
2072 $this->
ilias->raiseError(
"Style data directory (".$sty_data_dir
2073 .
") not writeable.",$this->
ilias->error_obj->FATAL);
2076 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
2078 if(!@is_dir($style_dir))
2080 $this->
ilias->raiseError(
"Creation of style directory failed (".
2081 $style_dir.
").",$this->ilias->error_obj->FATAL);
2085 $ex_dir = $style_dir.
"/export";
2087 if(!@is_dir($ex_dir))
2089 $this->
ilias->raiseError(
"Creation of Import Directory failed (".
2090 $ex_dir.
").",$this->ilias->error_obj->FATAL);
2102 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
2104 $ex_dir = $style_dir.
"/export";
2106 if (is_dir($ex_dir))
2121 if(!is_writable($ex_sub_dir))
2123 $this->
ilias->raiseError(
"Style data directory (".$ex_sub_dir
2124 .
") not writeable.",$this->
ilias->error_obj->FATAL);
2126 $ex_sub_images_dir = $ex_sub_dir.
"/images";
2128 if(!is_writable($ex_sub_images_dir))
2130 $this->
ilias->raiseError(
"Style data directory (".$ex_sub_images_dir
2131 .
") not writeable.",$this->
ilias->error_obj->FATAL);
2140 $this->export_sub_dir = $a_dir;
2148 if ($this->export_sub_dir ==
"")
2150 return "sty_".$this->getId();
2154 return $this->export_sub_dir;
2168 $this->
exportXML($ex_dir.
"/".$this->getExportSubDir());
2171 $ex_dir.
"/".$this->getExportSubDir().
"/images");
2172 if (is_file($ex_dir.
"/".$this->getExportSubDir().
".zip"))
2174 unlink($ex_dir.
"/".$this->getExportSubDir().
".zip");
2187 $file = $a_dir.
"/style.xml";
2190 if (!($fp = @fopen(
$file,
"w")))
2192 die (
"<b>Error</b>: Could not open \"".
$file.
"\" for writing".
2193 " in <b>".__FILE__.
"</b> on line <b>".__LINE__.
"</b><br />");
2200 fwrite($fp, $this->
getXML());
2214 if(!is_writable($sty_data_dir))
2216 $this->
ilias->raiseError(
"Style data directory (".$sty_data_dir
2217 .
") not writeable.",$this->
ilias->error_obj->FATAL);
2220 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
2222 if(!@is_dir($style_dir))
2224 $this->
ilias->raiseError(
"Creation of style directory failed (".
2225 $style_dir.
").",$this->ilias->error_obj->FATAL);
2229 $im_dir = $style_dir.
"/import";
2231 if(!@is_dir($im_dir))
2233 $this->
ilias->raiseError(
"Creation of Import Directory failed (".
2234 $im_dir.
").",$this->ilias->error_obj->FATAL);
2243 function import($a_file)
2250 if (is_array($a_file))
2253 $a_file[
"name"], $im_dir.
"/".$a_file[
"name"]);
2254 $file_name = $a_file[
"name"];
2258 $pi = pathinfo($a_file);
2259 $file_name = $pi[
"basename"];
2260 copy($a_file, $im_dir.
"/".$file_name);
2262 $file = pathinfo($file_name);
2265 if (strtolower(
$file[
"extension"] ==
"zip"))
2268 $subdir = basename(
$file[
"basename"],
".".
$file[
"extension"]);
2269 if (!is_dir($im_dir.
"/".$subdir))
2273 $xml_file = $im_dir.
"/".$subdir.
"/style.xml";
2277 $xml_file = $im_dir.
"/".$file_name;
2286 if (is_dir($im_dir.
"/".$subdir.
"/images"))
2289 $this->getImagesDirectory());
2305 $this->is_3_10_skin =
false;
2307 if (!$a_skip_parent_create)
2311 include_once(
"./Services/Style/classes/class.ilStyleImportParser.php");
2313 $importParser->startParsing();
2316 foreach ($this->
style as $style)
2318 foreach($style as $tag)
2320 $id = $ilDB->nextId(
"style_parameter");
2323 if (in_array($tag[
"class"], array(
"PageFrame",
"PageContainer")) &&
2324 $tag[
"tag"] ==
"table")
2326 $tag[
"tag"] =
"div";
2327 if ($tag[
"parameter"] ==
"width" && $tag[
"value"] ==
"100%")
2333 $q =
"INSERT INTO style_parameter (id,style_id, tag, class, parameter, type, value, custom) VALUES ".
2335 $ilDB->quote(
$id,
"integer").
",".
2336 $ilDB->quote($this->
getId(),
"integer").
",".
2337 $ilDB->quote($tag[
"tag"],
"text").
",".
2338 $ilDB->quote($tag[
"class"],
"text").
",".
2339 $ilDB->quote($tag[
"parameter"],
"text").
",".
2340 $ilDB->quote($tag[
"type"],
"text").
",".
2341 $ilDB->quote($tag[
"value"],
"text").
",".
2342 $ilDB->quote((
bool) $tag[
"custom"],
"integer").
2344 $ilDB->manipulate($q);
2349 $this->is_3_10_skin =
true;
2350 if (is_array($this->chars))
2352 foreach ($this->chars as $char)
2354 if ($char[
"type"] !=
"")
2356 $s = substr($char[
"class"], strlen($char[
"class"]) - 6);
2359 $q =
"INSERT INTO style_char (style_id, type, characteristic) VALUES ".
2360 "(".$ilDB->quote($this->
getId(),
"integer").
",".
2361 $ilDB->quote($char[
"type"],
"text").
",".
2362 $ilDB->quote($char[
"class"],
"text").
")";
2363 $ilDB->manipulate($q);
2364 $this->is_3_10_skin =
false;
2371 $q =
"INSERT INTO style_data (id, uptodate) VALUES ".
2372 "(".$ilDB->quote($this->
getId(),
"integer").
", 0)";
2373 $ilDB->manipulate($q);
2378 if ($this->is_3_10_skin)
2392 foreach (self::$parameter as
$parameter => $props)
2401 $input = self::$parameter[$par][
"input"];
2407 $subpar = self::$parameter[$par][
"subpar"];
2415 return self::$parameter;
2418 foreach (self::$parameter as $k => $v)
2420 if (is_array(self::$filtered_groups[$v[
"group"]]) &&
2421 !in_array($a_tag, self::$filtered_groups[$v[
"group"]]))
2432 return self::$filtered_groups;
2437 if ($a_no_percentage)
2439 return self::$num_unit_no_perc;
2441 return self::$num_unit;
2446 return self::$parameter[$par][
"values"];
2456 return self::$style_super_types;
2461 return in_array($a_type, self::$expandable_types);
2466 return in_array($a_type, self::$hideable_types);
2471 foreach (self::$style_super_types as $s =>
$t)
2473 if (in_array($a_type,
$t))
2489 $c_styles = array();
2490 foreach (self::$core_styles as $cstyle)
2493 = array(
"type" => $cstyle[
"type"],
2495 "class" => $cstyle[
"class"]);
2505 if ($a_template_type ==
"")
2507 return self::$templates;
2510 return self::$templates[$a_template_type];
2516 return self::$pseudo_classes[$tag];
2521 return self::$templates[
$t][$k];
2526 return self::$assigned_tags[$a_type];
2535 foreach(self::$parameter as $p => $v)
2537 $pars[$p] = $v[
"values"];
2549 $styles = array(array(
"id" => $a_id));
2561 if ($a_styles ==
"")
2567 $styles = $a_styles;
2573 $core_images = array();
2574 $core_dir = self::$basic_style_image_dir;
2575 if (is_dir($core_dir))
2577 $dir = opendir($core_dir);
2578 while(
$file = readdir($dir))
2580 if (substr(
$file, 0, 1) !=
"." && is_file($core_dir.
"/".
$file))
2582 $core_images[] =
$file;
2587 foreach ($styles as $style)
2594 $set = $ilDB->queryF(
"SELECT * FROM style_char WHERE style_id = %s ".
2595 "AND type = %s AND characteristic = %s",
2596 array(
"integer",
"text",
"text"),
2597 array(
$id, $cs[
"type"], $cs[
"class"]));
2600 if (!($rec = $ilDB->fetchAssoc($set)))
2603 "INSERT INTO style_char (style_id, type, characteristic) ".
2604 " VALUES (%s,%s,%s) ",
2605 array(
"integer",
"text",
"text"),
2606 array(
$id, $cs[
"type"], $cs[
"class"]));
2608 $xpath =
new DOMXPath($bdom);
2609 $par_nodes = $xpath->query(
"/StyleSheet/Style[@Tag = '".$cs[
"tag"].
"' and @Type='".
2610 $cs[
"type"].
"' and @Class='".$cs[
"class"].
"']/StyleParameter");
2611 foreach ($par_nodes as $par_node)
2614 $set = $ilDB->queryF(
"SELECT * FROM style_parameter WHERE style_id = %s ".
2615 "AND type = %s AND class = %s AND tag = %s AND parameter = %s",
2616 array(
"integer",
"text",
"text",
"text",
"text"),
2617 array(
$id, $cs[
"type"], $cs[
"class"],
2618 $cs[
"tag"], $par_node->getAttribute(
"Name")));
2621 if (!($rec = $ilDB->fetchAssoc($set)))
2623 $spid = $ilDB->nextId(
"style_parameter");
2624 $st = $ilDB->manipulateF(
"INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value) ".
2625 " VALUES (%s,%s,%s,%s,%s,%s,%s)",
2626 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2627 array($spid,
$id, $cs[
"type"], $cs[
"class"], $cs[
"tag"],
2628 $par_node->getAttribute(
"Name"), $par_node->getAttribute(
"Value")));
2637 reset($core_images);
2638 foreach($core_images as $cim)
2640 if (!is_file($imdir.
"/".$cim))
2642 copy($core_dir.
"/".$cim, $imdir.
"/".$cim);
2667 $st = $ilDB->prepareManip(
"UPDATE style_char SET type = ? WHERE characteristic = ?".
2668 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2669 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2670 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2671 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2672 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2673 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2674 $ilDB->execute($st, array(
"page_cont",
"Page", $this->
getId()));
2677 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET type = ? WHERE class = ?".
2678 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2679 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2680 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2681 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2682 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2683 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2684 $ilDB->execute($st, array(
"table",
"Page", $this->
getId()));
2686 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET tag = ? WHERE class = ?".
2687 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2688 $ilDB->execute($st, array(
"div",
"MediaCaption", $this->
getId()));
2691 $st = $ilDB->prepareManip(
"UPDATE style_char SET characteristic = ? WHERE characteristic = ?".
2692 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2693 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2694 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2697 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET class = ? WHERE class = ?".
2698 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2699 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2700 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2703 $st = $ilDB->prepareManip(
"DELETE FROM style_char WHERE type = ?".
2704 " AND style_id = ? ", array(
"text",
"integer"));
2705 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2706 $st = $ilDB->prepareManip(
"DELETE FROM style_parameter WHERE type = ?".
2707 " AND style_id = ? ", array(
"text",
"integer"));
2708 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2725 $add_str =
" AND style_id = ".$ilDB->quote($a_id,
"integer");
2728 $set = $ilDB->query($q =
"SELECT DISTINCT style_id, tag, class FROM style_parameter WHERE ".
2729 $ilDB->equals(
"type",
"",
"text",
true).
" ".$add_str);
2731 while ($rec = $ilDB->fetchAssoc($set))
2735 switch ($rec[
"tag"])
2739 if (in_array($rec[
"class"], array(
"Headline3",
"Headline1",
2740 "Headline2",
"TableContent",
"List",
"Standard",
"Remark",
2741 "Additional",
"Mnemonic",
"Citation",
"Example")))
2743 $types[] =
"text_block";
2745 if (in_array($rec[
"class"], array(
"Block",
"Remark",
2746 "Additional",
"Mnemonic",
"Example",
"Excursus",
"Special")))
2748 $types[] =
"section";
2750 if (in_array($rec[
"class"], array(
"Page",
"Footnote",
"PageTitle",
"LMNavigation")))
2757 $types[] =
"table_cell";
2761 if (in_array($rec[
"class"], array(
"ExtLink",
"IntLink",
"FootnoteLink")))
2768 $types[] =
"text_inline";
2777 foreach ($types as
$t)
2780 $set4 = $ilDB->queryF(
"SELECT * FROM style_char ".
2781 " WHERE style_id = %s AND type = %s AND characteristic = %s",
2782 array(
"integer",
"text",
"text"),
2783 array($rec[
"style_id"], $t, $rec[
"class"]));
2784 if ($rec4 = $ilDB->fetchAssoc($set4))
2791 $ilDB->manipulateF(
"INSERT INTO style_char ".
2792 " (style_id, type, characteristic) VALUES ".
2794 array(
"integer",
"text",
"text"),
2795 array($rec[
"style_id"], $t, $rec[
"class"]));
2800 if ($rec[
"type"] ==
"")
2802 if (count($types) > 0)
2804 $ilDB->manipulateF(
"UPDATE style_parameter SET type = %s ".
2805 " WHERE style_id = %s AND class = %s AND ".$ilDB->equals(
"type",
"",
"text",
true),
2806 array(
"text",
"integer",
"text"),
2807 array($types[0], $rec[
"style_id"], $rec[
"class"]));
2811 if ($types[0] ==
"link")
2813 $ilDB->manipulateF(
"UPDATE style_parameter SET type = %s ".
2814 " WHERE style_id = %s AND (class = %s OR class = %s) AND ".$ilDB->equals(
"type",
"",
"text",
true),
2815 array(
"text",
"integer",
"text",
"text"),
2816 array($types[0], $rec[
"style_id"], $rec[
"class"].
":visited",
2817 $rec[
"class"].
":hover"));
2821 if (count($types) == 2)
2825 $set2 = $ilDB->queryF(
"SELECT * FROM style_parameter ".
2826 " WHERE style_id = %s AND class = %s AND type = %s",
2827 array(
"integer",
"text",
"text"),
2828 array($rec[
"style_id"], $rec[
"class"], $types[0]));
2829 while ($rec2 = $ilDB->fetchAssoc($set2))
2832 $set3 = $ilDB->queryF(
"SELECT * FROM style_parameter ".
2833 " WHERE style_id = %s AND tag = %s AND class = %s AND type = %s AND parameter = %s",
2834 array(
"integer",
"text",
"text",
"text",
"text"),
2835 array($rec[
"style_id"], $rec[
"tag"], $rec[
"class"], $types[1], $rec[
"parameter"]));
2836 if ($rec3 = $ilDB->fetchAssoc($set3))
2842 $nid = $ilDB->nextId(
"style_parameter");
2843 $ilDB->manipulateF(
"INSERT INTO style_parameter ".
2844 " (id, style_id, tag, class, parameter, value, type) VALUES ".
2845 " (%s, %s,%s,%s,%s,%s,%s) ",
2846 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2847 array($nid, $rec2[
"style_id"], $rec2[
"tag"], $rec2[
"class"],
2848 $rec2[
"parameter"], $rec2[
"value"], $types[1]));
2863 $classes = array(
"Example",
"Additional",
"Citation",
"Mnemonic",
"Remark");
2864 $pars = array(
"margin-top",
"margin-bottom");
2866 foreach ($classes as $curr_class)
2868 foreach ($pars as $curr_par)
2870 $res2 = $ilDB->queryF(
"SELECT id FROM style_parameter WHERE style_id = %s".
2871 " AND tag = %s AND class= %s AND parameter = %s",
2872 array(
"integer",
"text",
"text",
"text"),
2873 array($a_id,
"p", $curr_class, $curr_par));
2874 if ($row2 = $ilDB->fetchAssoc($res2))
2876 $ilDB->manipulateF(
"UPDATE style_parameter SET value= %s WHERE id = %s",
2877 array(
"text",
"integer"),
2878 array(
"10px", $row2[
"id"]));
2882 $nid = $ilDB->nextId(
"style_parameter");
2883 $ilDB->manipulateF(
"INSERT INTO style_parameter ".
2884 "(id, style_id, tag, class, parameter,value) VALUES (%s,%s,%s,%s,%s,%s)",
2885 array(
"integer",
"integer",
"text",
"text",
"text",
"text"),
2886 array($nid, $a_id,
"div", $curr_class, $curr_par,
"10px"));
2891 $ilDB->manipulateF(
"UPDATE style_parameter SET tag = %s WHERE tag = %s and style_id = %s",
2892 array(
"text",
"text",
"integer"),
2893 array(
"div",
"p", $a_id));
2908 $set = $ilDB->query(
"SELECT * FROM style_color WHERE ".
2909 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" ".
2910 "ORDER BY color_name");
2913 while ($rec = $ilDB->fetchAssoc($set))
2916 "name" => $rec[
"color_name"],
2917 "code" => $rec[
"color_code"]
2931 $ilDB->manipulate(
"INSERT INTO style_color (style_id, color_name, color_code)".
2933 $ilDB->quote($this->getId(),
"integer").
",".
2934 $ilDB->quote($a_name,
"text").
",".
2935 $ilDB->quote($a_code,
"text").
2948 $ilDB->manipulate(
"UPDATE style_color SET ".
2949 "color_name = ".$ilDB->quote($a_new_name,
"text").
", ".
2950 "color_code = ".$ilDB->quote($a_code,
"text").
2951 " WHERE style_id = ".$ilDB->quote($this->
getId(),
"integer").
2952 " AND color_name = ".$ilDB->quote($a_name,
"text"));
2956 if ($a_name != $a_new_name)
2958 $set = $ilDB->query(
"SELECT * FROM style_parameter ".
2959 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
2961 " parameter = ".$ilDB->quote(
"background-color",
"text").
" OR ".
2962 " parameter = ".$ilDB->quote(
"color",
"text").
" OR ".
2963 " parameter = ".$ilDB->quote(
"border-color",
"text").
" OR ".
2964 " parameter = ".$ilDB->quote(
"border-top-color",
"text").
" OR ".
2965 " parameter = ".$ilDB->quote(
"border-bottom-color",
"text").
" OR ".
2966 " parameter = ".$ilDB->quote(
"border-left-color",
"text").
" OR ".
2967 " parameter = ".$ilDB->quote(
"border-right-color",
"text").
2969 while ($rec = $ilDB->fetchAssoc($set))
2971 if ($rec[
"value"] ==
"!".$a_name ||
2972 is_int(strpos($rec[
"value"],
"!".$a_name.
"(")))
2976 $rec[
"parameter"], str_replace($a_name, $a_new_name, $rec[
"value"]), $rec[
"type"], $rec[
"mq_id"], $rec[
"custom"]);
2989 $ilDB->manipulate(
"DELETE FROM style_color WHERE ".
2990 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2991 " color_name = ".$ilDB->quote($a_name,
"text"));
3001 $set = $ilDB->query(
"SELECT * FROM style_color WHERE ".
3002 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3003 "color_name = ".$ilDB->quote($a_color_name,
"text"));
3004 if ($rec = $ilDB->fetchAssoc($set))
3018 $pos = strpos($a_name,
"(");
3021 $a_i = substr($a_name, $pos + 1);
3022 $a_i = str_replace(
")",
"", $a_i);
3023 $a_name = substr($a_name, 0, $pos);
3026 $set = $ilDB->query(
"SELECT color_code FROM style_color WHERE ".
3027 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3028 " color_name = ".$ilDB->quote($a_name,
"text"));
3029 if ($rec = $ilDB->fetchAssoc($set))
3033 return "#".$rec[
"color_code"];
3037 return "#".ilObjStyleSheet::_getColorFlavor($rec[
"color_code"],
3053 $hls[
"l"] = $hls[
"l"] + ((255 - $hls[
"l"]) * ($a_i / 100));
3057 $hls[
"l"] = $hls[
"l"] - (($hls[
"l"]) * (-$a_i / 100));
3062 foreach ($rgb as $k => $v)
3064 $rgb[$k] = str_pad(dechex($v), 2,
"0", STR_PAD_LEFT);
3067 return $rgb[
"r"].$rgb[
"g"].$rgb[
"b"];
3075 $r[
"r"] = substr($a_rgb, 0, 2);
3076 $r[
"g"] = substr($a_rgb, 2, 2);
3077 $r[
"b"] = substr($a_rgb, 4, 2);
3081 $r[
"r"] = (int) hexdec(
$r[
"r"]);
3082 $r[
"g"] = (int) hexdec(
$r[
"g"]);
3083 $r[
"b"] = (int) hexdec(
$r[
"b"]);
3094 $r = $a_rgb[
"r"] / 255;
3095 $g = $a_rgb[
"g"] / 255;
3096 $b = $a_rgb[
"b"] / 255;
3099 $max = max(
$r,$g,$b);
3100 $min = min(
$r,$g,$b);
3103 $l = ($max + $min) / 2;
3114 $s = ($max - $min) / ($max + $min);
3118 $s = ($max - $min) / (2.0 - $max - $min);
3123 $h = ($g - $b) / ($max - $min);
3125 else if ($g == $max)
3127 $h = 2.0 + ($b -
$r) / ($max - $min);
3129 else if ($b == $max)
3131 $h = 4.0 + (
$r - $g) / ($max - $min);
3135 $hls[
"h"] = round((
$h / 6) * 255);
3136 $hls[
"l"] = round(
$l * 255);
3137 $hls[
"s"] = round($s * 255);
3147 $h = $a_hls[
"h"] / 255;
3148 $l = $a_hls[
"l"] / 255;
3149 $s = $a_hls[
"s"] / 255;
3151 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = 0;
3156 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] =
$l;
3163 $temp2 =
$l * (1.0 + $s);
3167 $temp2 =
$l + $s -
$l * $s;
3170 $temp1 = 2.0 *
$l - $temp2;
3173 # For each of R, G, B, compute another temporary value, temp3, as follows: 3174 foreach ($rgb as $k => $v)
3179 $temp3 =
$h + 1.0 / 3.0;
3187 $temp3 =
$h - 1.0/3.0;
3192 $temp3 = $temp3 + 1.0;
3196 $temp3 = $temp3 - 1.0;
3199 if (6.0 * $temp3 < 1)
3201 $rgb[$k] = $temp1 + ($temp2 - $temp1) * 6.0 * $temp3;
3203 else if (2.0 * $temp3 < 1)
3207 else if (3.0 * $temp3 < 2)
3209 $rgb[$k] = $temp1 + ($temp2 - $temp1) * ((2.0/3.0) - $temp3) * 6.0;
3218 $rgb[
"r"] = round($rgb[
"r"] * 255);
3219 $rgb[
"g"] = round($rgb[
"g"] * 255);
3220 $rgb[
"b"] = round($rgb[
"b"] * 255);
3240 $set = $ilDB->query(
"SELECT * FROM sty_media_query WHERE ".
3241 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" ".
3242 "ORDER BY order_nr");
3245 while ($rec = $ilDB->fetchAssoc($set))
3261 $id = $ilDB->nextId(
"sty_media_query");
3267 $ilDB->manipulate(
"INSERT INTO sty_media_query (id, style_id, mquery, order_nr)".
3269 $ilDB->quote(
$id,
"integer").
",".
3270 $ilDB->quote($this->
getId(),
"integer").
",".
3271 $ilDB->quote($a_mquery,
"text").
",".
3272 $ilDB->quote($order_nr,
"integer").
3286 $set = $ilDB->query(
"SELECT max(order_nr) mnr FROM sty_media_query ".
3287 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer")
3289 $rec = $ilDB->fetchAssoc($set);
3291 return (
int) $rec[
"mnr"];
3304 $ilDB->manipulate(
"UPDATE sty_media_query SET ".
3305 " mquery = ".$ilDB->quote($a_mquery,
"text").
3306 " WHERE id = ".$ilDB->quote($a_id,
"integer")
3320 $set = $ilDB->query(
"SELECT * FROM sty_media_query ".
3321 " WHERE id = ".$ilDB->quote($a_id,
"integer")
3323 return $ilDB->fetchAssoc($set);
3335 $ilDB->manipulate(
"DELETE FROM sty_media_query WHERE ".
3336 " style_id = ".$ilDB->quote($this->getId(),
"integer").
3337 " AND id = ".$ilDB->quote($a_id,
"integer")
3352 if (is_array ($a_order_nr))
3354 foreach ($mqueries as $k => $mq)
3356 $mqueries[$k][
"order_nr"] = $a_order_nr[$mq[
"id"]];
3361 foreach ($mqueries as $mq)
3363 $ilDB->manipulate(
"UPDATE sty_media_query SET ".
3364 " order_nr = ".$ilDB->quote($cnt,
"integer").
3365 " WHERE id = ".$ilDB->quote($mq[
"id"],
"integer")
3383 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
3384 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3385 "temp_type = ".$ilDB->quote($a_type,
"text").
" ".
3389 while ($rec = $ilDB->fetchAssoc($set))
3404 $set = $ilDB->query(
"SELECT * FROM style_template_class WHERE ".
3405 "template_id = ".$ilDB->quote($a_tid,
"integer"));
3408 while ($rec = $ilDB->fetchAssoc($set))
3410 $key = $rec[
"class_type"];
3411 $class[$key] = $rec[
"class"];
3425 $tid = $ilDB->nextId(
"style_template");
3426 $ilDB->manipulate($q =
"INSERT INTO style_template ".
3427 "(id, style_id, name, temp_type)".
3429 $ilDB->quote($tid,
"integer").
",".
3430 $ilDB->quote($this->
getId(),
"integer").
",".
3431 $ilDB->quote($a_name,
"text").
",".
3432 $ilDB->quote($a_type,
"text").
3435 foreach ($a_classes as
$t => $c)
3437 $ilDB->manipulate($q =
"INSERT INTO style_template_class ".
3438 "(template_id, class_type, class)".
3440 $ilDB->quote($tid,
"integer").
",".
3441 $ilDB->quote(
$t,
"text").
",".
3442 $ilDB->quote($c,
"text").
3446 include_once(
"./Services/Style/classes/class.ilObjStyleSheetGUI.php");
3460 $ilDB->manipulate(
"UPDATE style_template SET ".
3461 "name = ".$ilDB->quote($a_name,
"text").
3462 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3464 $ilDB->manipulate(
"DELETE FROM style_template_class WHERE ".
3465 "template_id = ".$ilDB->quote($a_t_id,
"integer")
3467 foreach ($a_classes as
$t => $c)
3469 $ilDB->manipulate($q =
"INSERT INTO style_template_class ".
3470 "(template_id, class_type, class)".
3472 $ilDB->quote($a_t_id,
"integer").
",".
3473 $ilDB->quote(
$t,
"text").
",".
3474 $ilDB->quote($c,
"text").
3487 $ilDB->manipulate($q =
"INSERT INTO style_template_class ".
3488 "(template_id, class_type, class)".
3490 $ilDB->quote($a_t_id,
"integer").
",".
3491 $ilDB->quote($a_type,
"text").
",".
3492 $ilDB->quote($a_class,
"text").
3504 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
3505 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3506 "name = ".$ilDB->quote($a_template_name,
"text"));
3507 if ($rec = $ilDB->fetchAssoc($set))
3521 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
3522 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" ".
3523 " AND id = ".$ilDB->quote($a_t_id,
"integer"));
3525 if ($rec = $ilDB->fetchAssoc($set))
3542 $set = $ilDB->query(
"SELECT name FROM style_template WHERE ".
3543 " id = ".$ilDB->quote($a_t_id,
"integer"));
3545 if ($rec = $ilDB->fetchAssoc($set))
3547 return $rec[
"name"];
3560 $tag =
"<StyleTemplates>";
3562 $ttypes = array(
"table",
"vaccordion",
"haccordion",
"carousel");
3564 foreach ($ttypes as $ttype)
3583 $tag.=
'<StyleTemplate Name="'.$t[
"name"].
'">';
3585 foreach ($atts as
$type => $t)
3587 if ($c[
$type] !=
"")
3589 $tag.=
'<StyleClass Type="'.$type.
'" Value="'.$c[
$type].
'" />';
3593 $tag.=
"</StyleTemplate>";
3597 $tag.=
"</StyleTemplates>";
3609 $a_preview_html = str_replace(
' width=""',
"", $a_preview_html);
3610 $a_preview_html = str_replace(
' valign="top"',
"", $a_preview_html);
3611 $a_preview_html = str_replace(
'<div class="ilc_text_block_TableContent">',
"<div>", $a_preview_html);
3614 if (strlen($a_preview_html) > 4000)
3617 $a_preview_html =
"";
3619 $ilDB->manipulate(
"UPDATE style_template SET ".
3620 "preview = ".$ilDB->quote($a_preview_html,
"text").
3621 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3631 $set = $ilDB->query(
"SELECT preview FROM style_template ".
3632 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3633 if ($rec = $ilDB->fetchAssoc($set))
3635 return $rec[
"preview"];
3648 $set = $ilDB->query(
"SELECT id FROM style_template ".
3649 " WHERE style_id = ".$ilDB->quote($a_style_id,
"integer").
3650 " AND name = ".$ilDB->quote($a_name,
"text"));
3651 if ($rec = $ilDB->fetchAssoc($set))
3666 $ilDB->manipulate(
"DELETE FROM style_template WHERE ".
3667 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3668 " id = ".$ilDB->quote($a_t_id,
"integer"));
3670 $ilDB->manipulate(
"DELETE FROM style_template_class WHERE ".
3671 "template_id = ".$ilDB->quote($a_t_id,
"integer")
3683 $ilDB->manipulate(
"DELETE FROM style_setting WHERE ".
3684 " style_id = ".$ilDB->quote($this->getId(),
"integer").
3685 " AND name = ".$ilDB->quote($a_name,
"text")
3688 $ilDB->manipulate(
"INSERT INTO style_setting ".
3689 "(style_id, name, value) VALUES (".
3690 $ilDB->quote($this->getId(),
"integer").
",".
3691 $ilDB->quote($a_name,
"text").
",".
3692 $ilDB->quote($a_value,
"text").
3703 $set = $ilDB->query(
"SELECT value FROM style_setting ".
3704 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
3705 " AND name = ".$ilDB->quote($a_name,
"text")
3707 $rec = $ilDB->fetchAssoc($set);
3709 return $rec[
"value"];
3719 $ilDB->replace(
"style_usage", array(
3720 "obj_id" => array(
"integer", (
int) $a_obj_id)),
3722 "style_id" => array(
"integer", (
int) $a_style_id))
3733 $set = $ilDB->query(
"SELECT style_id FROM style_usage ".
3734 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")
3736 $rec = $ilDB->fetchAssoc($set);
3740 return (
int) $rec[
"style_id"];
static _lookupTemplateIdByName($a_style_id, $a_name)
Lookup table template preview.
_getTemplatePreview($a_style, $a_type, $a_t_id, $a_small_mode=false)
Get table template preview.
deleteMediaQuery($a_id)
Delete media query.
getXML()
get xml representation of style object todo: add mq_id
static _explodeRGB($a_rgb, $as_dec=false)
Explode an RGB string into an array.
static _getTemplateClassTypes($a_template_type="")
Get template class types.
getHideStatus($a_type, $a_char)
Get characteristic hide status.
removeColor($a_name)
Remove a color.
characteristicExists($a_char, $a_style_type)
Check whether characteristic exists.
exportXML($a_dir)
export style xml file to directory
static _HLSToRGB($a_hls)
HLS to RGB (both arrays, 0..255)
do_3_10_Migration()
Migrates 3.10 style to 3.11 style.
setCharacteristics($a_chars)
Set characteristics.
getColors()
Get colors of style.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
_lookupActive($a_id)
Lookup active flag.
read()
read style properties
static _determineTag($a_type)
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
_writeStandard($a_id, $a_std)
Write standard flag.
deleteParameter($a_id)
delete style parameter
addTemplate($a_type, $a_name, $a_classes)
Add table template.
_writeScope($a_id, $a_scope)
Write scope.
static $style_super_types
putInTree()
Put in tree (show error message, since styles do not use ref ids)
do_3_9_Migration($a_id)
Migrate old 3.9 styles.
getRefId()
Get ref id (show error message, since styles do not use ref ids)
getPlaceHolderStylePath()
get placeholder style path (for Page Layouts)
Class ilObject Basic functions for all objects.
copyImagesToDir($a_target)
Copy images to directory.
setExportSubDir($a_dir)
Set local directory, that will be included within the zip file.
deleteImage($a_file)
Delete an image.
lookupStyleSetting($a_name)
Lookup style setting.
setScope($a_scope)
Set scope.
updateMediaQuery($a_id, $a_mquery)
Update media query.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
_lookupContObjIdByStyleId($a_style_id)
lookup style sheet ID
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static _getStyleSuperTypeForType($a_type)
writeTemplatePreview($a_t_id, $a_preview_html)
Write table template preview.
static _lookupTitle($a_id)
lookup object title
deleteStyleParOfChar($a_type, $a_class)
Delete style parameters of characteristic.
deleteCustomStylePars($a_tag, $a_class, $a_type, $a_mq_id=0)
Delete style parameter by tag/class/parameter.
_lookupUpToDate($a_id)
Looup up to date.
writeCSSFile($a_target_file="", $a_image_dir="")
write css file to webspace directory
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _getStyleSuperTypes()
static lookupObjectStyle($a_obj_id)
Lookup object style.
& getMetaData()
get meta data object
getSyntaxStylePath()
get syntax style path
createExportSubDirectory()
Create export directory.
static _getAllReferences($a_id)
get all reference ids of object
lookupTemplateName($a_t_id)
Lookup table template name for template ID.
do_3_10_CharMigration($a_id="")
This is more or less a copy of Services/Migration/DBUpdate_1385/classes ilStyleMigration->addMissingS...
getThumbnailsDirectory()
Get thumbnails directory.
handleXmlString($a_str)
Handle xml strin.
_replaceStylePar($style_id, $a_tag, $a_class, $a_par, $a_val, $a_type, $a_mq_id=0, $a_custom=false)
static writeStyleUsage($a_obj_id, $a_style_id)
Write style usage.
addColor($a_name, $a_code)
Add color.
getTemplate($a_t_id)
Get template.
addTemplateClass($a_t_id, $a_type, $a_class)
Update table template.
_getClonableContentStyles()
Get all clonable styles (active standard styles and individual learning module styles with write perm...
static _getBasicStyleDom()
Get basic style dom.
getImagesDirectory()
Get images directory.
templateExists($a_template_name)
Check whether template exists.
static resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop=false)
resize image
getCharacteristics($a_type="", $a_no_hidden=false)
Get characteristics.
static _addMissingStyleClassesToAllStyles($a_styles="")
Add missing style classes to all styles todo: add mq_id and custom handling.
getId()
get object id public
static _isExpandable($a_type)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
writeStyleSetting($a_name, $a_value)
Write Style Setting.
static _getFilteredGroups()
ilObjStyleSheet($a_id=0, $a_call_by_reference=false)
Constructor public.
getTemplateXML()
Get table template xml.
static _getCoreStyles()
Get core styles.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
_deleteStyleAssignments($a_style_id)
delete all style references to style
getTitle()
get object title public
uploadImage($a_file)
Upload image.
getDescription()
get object description
_getStandardStyles($a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
addParameter($a_tag, $a_par, $a_type, $a_mq_id=0, $a_custom=false)
write style parameter to db
redirection script todo: (a better solution should control the processing via a xml file) ...
setUpToDate($a_up_to_date=true)
Set style up to date (false + update will trigger css generation next time)
copyCharacteristic($a_from_style_id, $a_from_type, $a_from_char, $a_to_char)
Copy characteristic.
saveHideStatus($a_type, $a_char, $a_hide)
Save characteristic hide status.
setStyle($a_style)
set styles
static signFile($path_to_file)
getParametersOfClass($a_type, $a_class, $a_mq_id=0)
Get parameters of class.
static $basic_style_image_dir
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
getType()
get object type public
getStyleParameterGroups()
Get grouped parameter.
static _lookupType($a_id, $a_reference=false)
lookup object type
getContentPrintStyle()
get content print style
export()
Create export file.
getTemplates($a_type)
Get table templates of style.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
deleteStylePar($a_tag, $a_class, $a_par, $a_type, $a_mq_id=0, $a_custom=false)
Delete style parameter by tag/class/parameter.
_writeActive($a_id, $a_active)
Write active flag.
static _getColorFlavor($a_rgb, $a_i)
Get color flavor.
determineTemplateStyleClassType($t, $k)
updateColor($a_name, $a_new_name, $a_code)
Update color.
static _createImagesDirectory($a_style_id)
Create images directory <data_dir>/sty/sty_<id>/images.
createExportDirectory()
Create export directory.
getStyle()
todo: bad style! should return array of objects, not multi-dim-arrays
updateStyleParameter($a_id, $a_value)
update style parameter per id
_writeUpToDate($a_id, $a_up_to_date)
Write up to date.
static _addMissingStyleClassesToStyle($a_id)
Add missing style classes to all styles.
createReference()
Create a reference (show error message, since styles do not use ref ids)
static _getImagesDirectory($a_style_id)
Get images directory.
addCharacteristic($a_type, $a_char, $a_hidden=false)
Add characteristic.
static _RGBToHLS($a_rgb)
RGB to HLS (both arrays, 0..255)
_lookupStandard($a_id)
Lookup standard flag.
getTemplateClasses($a_tid)
Get template classes.
static _getStyleParameterValues($par)
getMaxMQueryOrderNr()
Get maximum media query order nr.
replaceStylePar($a_tag, $a_class, $a_par, $a_val, $a_type, $a_mq_id=0, $a_custom=false)
Set style parameter per tag/class/parameter.
static getDataDir()
get data directory (outside webspace)
colorExists($a_color_name)
Check whether color exists.
deleteCharacteristic($a_type, $a_tag, $a_class)
Delete Characteristic.
static _getStyleParameterNumericUnits($a_no_percentage=false)
getContentStylePath($a_style_id)
get content style path
create($a_from_style=0, $a_import_mode=false)
Create a new style.
getExportSubDir()
The local directory, that will be included within the zip file.
createImportDirectory()
Create import directory.
getColorCodeForName($a_name)
Remove a color.
updateTemplate($a_t_id, $a_name, $a_classes)
Update table template.
static _getStyleParameters($a_tag="")
removeTemplate($a_t_id)
Remove table template.
saveMediaQueryOrder($a_order_nr=null)
Save media query order.
setRefId()
Set ref id (show error message, since styles do not use ref ids)
static _isHideable($a_type)
assignMetaData(&$a_meta_data)
assign meta data object
cleanExportDirectory()
Clear export directory.
getImages()
Get images of style.
createFromXMLFile($a_file, $a_skip_parent_create=false)
create style from xml file todo: add mq_id and custom
static _getStyleParameterInputType($par)
addMediaQuery($a_mquery, $order_nr=0)
Add media query.
_getObjectsDataForType($a_type, $a_omit_trash=false)
get all objects of a certain type
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
static _getStyleParameterSubPar($par)
createImagesDirectory()
Create images directory <data_dir>/sty/sty_<id>/images.
getMediaQueries()
Get colors of style.
ilClone()
clone style sheet (note: styles have no ref ids and return an object id)
getMediaQueryForId($a_id)
Get media query for id.
static getAvailableParameters()
Get available parameters.
lookupTemplatePreview($a_t_id)
Lookup table template preview.
getUpToDate()
Get up to date.