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",
"figure"));
248 "text_block" => array(
"text_block",
"heading1",
"heading2",
"heading3",
"code_block"),
249 "text_inline" => array(
"text_inline",
"sub",
"sup",
"code_inline"),
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",
"text_inline",
"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 "code_block" =>
"pre",
290 "text_inline" =>
"span",
291 "code_inline" =>
"code",
297 "table_cell" =>
"td",
298 "table_caption" =>
"caption",
299 "media_cont" =>
"figure",
300 "media_caption" =>
"div",
303 "glo_overlay" =>
"div",
304 "glo_ovtitle" =>
"h1",
305 "glo_ovclink" =>
"a",
306 "glo_ovuglink" =>
"a",
307 "glo_ovuglistlink" =>
"a",
308 "sco_title" =>
"div",
312 "sco_desct" =>
"div",
314 "sco_fmess" =>
"div",
321 "rte_status" =>
"div",
329 "flist_cont" =>
"div",
330 "flist_head" =>
"div",
344 "qlinput" =>
"textarea",
345 "qsubmit" =>
"input",
349 "page_frame" =>
"div",
350 "page_cont" =>
"div",
353 "page_tnav" =>
"div",
354 "page_bnav" =>
"div",
355 "page_lnav" =>
"div",
356 "page_rnav" =>
"div",
357 "page_lnavlink" =>
"a",
358 "page_rnavlink" =>
"a",
359 "page_lnavimage" =>
"img",
360 "page_rnavimage" =>
"img",
361 "page_title" =>
"h1",
366 "va_iheada" =>
"div",
371 "ha_iheada" =>
"div",
382 array(
"a" => array(
"hover"),
"div" => array(
"hover"),
"img" => array(
"hover"));
386 array(
"type" =>
"text_block",
"class" =>
"Standard"),
387 array(
"type" =>
"text_block",
"class" =>
"List"),
388 array(
"type" =>
"text_block",
"class" =>
"TableContent"),
389 array(
"type" =>
"code_block",
"class" =>
"Code"),
390 array(
"type" =>
"heading1",
"class" =>
"Headline1"),
391 array(
"type" =>
"heading2",
"class" =>
"Headline2"),
392 array(
"type" =>
"heading3",
"class" =>
"Headline3"),
393 array(
"type" =>
"text_inline",
"class" =>
"Comment"),
394 array(
"type" =>
"text_inline",
"class" =>
"Emph"),
395 array(
"type" =>
"text_inline",
"class" =>
"Quotation"),
396 array(
"type" =>
"text_inline",
"class" =>
"Strong"),
397 array(
"type" =>
"text_inline",
"class" =>
"Accent"),
398 array(
"type" =>
"text_inline",
"class" =>
"Important"),
399 array(
"type" =>
"code_inline",
"class" =>
"CodeInline"),
400 array(
"type" =>
"sup",
"class" =>
"Sup"),
401 array(
"type" =>
"sub",
"class" =>
"Sub"),
402 array(
"type" =>
"link",
"class" =>
"IntLink"),
403 array(
"type" =>
"link",
"class" =>
"ExtLink"),
404 array(
"type" =>
"link",
"class" =>
"FootnoteLink"),
405 array(
"type" =>
"link",
"class" =>
"FileLink"),
406 array(
"type" =>
"link",
"class" =>
"GlossaryLink"),
407 array(
"type" =>
"media_cont",
"class" =>
"MediaContainer"),
408 array(
"type" =>
"media_cont",
"class" =>
"MediaContainerMax50"),
409 array(
"type" =>
"media_cont",
"class" =>
"MediaContainerFull100"),
410 array(
"type" =>
"table",
"class" =>
"StandardTable"),
411 array(
"type" =>
"media_caption",
"class" =>
"MediaCaption"),
412 array(
"type" =>
"iim",
"class" =>
"ContentPopup"),
413 array(
"type" =>
"marker",
"class" =>
"Marker"),
414 array(
"type" =>
"page_frame",
"class" =>
"PageFrame"),
415 array(
"type" =>
"page_cont",
"class" =>
"PageContainer"),
416 array(
"type" =>
"page",
"class" =>
"Page"),
417 array(
"type" =>
"page_tnav",
"class" =>
"TopNavigation"),
418 array(
"type" =>
"page_bnav",
"class" =>
"BottomNavigation"),
419 array(
"type" =>
"page_lnav",
"class" =>
"LeftNavigation"),
420 array(
"type" =>
"page_rnav",
"class" =>
"RightNavigation"),
421 array(
"type" =>
"page_lnavlink",
"class" =>
"LeftNavigationLink"),
422 array(
"type" =>
"page_rnavlink",
"class" =>
"RightNavigationLink"),
423 array(
"type" =>
"page_lnavimage",
"class" =>
"LeftNavigationImage"),
424 array(
"type" =>
"page_rnavimage",
"class" =>
"RightNavigationImage"),
425 array(
"type" =>
"page_fn",
"class" =>
"Footnote"),
426 array(
"type" =>
"page_title",
"class" =>
"PageTitle"),
427 array(
"type" =>
"glo_overlay",
"class" =>
"GlossaryOverlay"),
428 array(
"type" =>
"glo_ovtitle",
"class" =>
"GlossaryOvTitle"),
429 array(
"type" =>
"glo_ovclink",
"class" =>
"GlossaryOvCloseLink"),
430 array(
"type" =>
"glo_ovuglink",
"class" =>
"GlossaryOvUnitGloLink"),
431 array(
"type" =>
"glo_ovuglistlink",
"class" =>
"GlossaryOvUGListLink"),
432 array(
"type" =>
"sco_title",
"class" =>
"Title"),
433 array(
"type" =>
"sco_desc",
"class" =>
"Description"),
434 array(
"type" =>
"sco_desct",
"class" =>
"DescriptionTop"),
435 array(
"type" =>
"sco_keyw",
"class" =>
"Keywords"),
436 array(
"type" =>
"sco_obj",
"class" =>
"Objective"),
437 array(
"type" =>
"sco_objt",
"class" =>
"ObjectiveTop"),
438 array(
"type" =>
"sco_fmess",
"class" =>
"FinalMessage"),
439 array(
"type" =>
"rte_menu",
"class" =>
"RTEMenu"),
440 array(
"type" =>
"rte_menu",
"class" =>
"RTELogo"),
441 array(
"type" =>
"rte_menu",
"class" =>
"RTELinkBar"),
442 array(
"type" =>
"rte_mlink",
"class" =>
"RTELink"),
443 array(
"type" =>
"rte_mlink",
"class" =>
"RTELinkDisabled"),
444 array(
"type" =>
"rte_tree",
"class" =>
"RTETree"),
445 array(
"type" =>
"rte_node",
"class" =>
"RTECourse"),
446 array(
"type" =>
"rte_node",
"class" =>
"RTEChapter"),
447 array(
"type" =>
"rte_node",
"class" =>
"RTESco"),
448 array(
"type" =>
"rte_node",
"class" =>
"RTEAsset"),
449 array(
"type" =>
"rte_node",
"class" =>
"RTECourseDisabled"),
450 array(
"type" =>
"rte_node",
"class" =>
"RTEChapterDisabled"),
451 array(
"type" =>
"rte_node",
"class" =>
"RTEScoDisabled"),
452 array(
"type" =>
"rte_node",
"class" =>
"RTEAssetDisabled"),
453 array(
"type" =>
"rte_status",
"class" =>
"RTEAsset"),
454 array(
"type" =>
"rte_status",
"class" =>
"RTECompleted"),
455 array(
"type" =>
"rte_status",
"class" =>
"RTENotAttempted"),
456 array(
"type" =>
"rte_status",
"class" =>
"RTERunning"),
457 array(
"type" =>
"rte_status",
"class" =>
"RTEIncomplete"),
458 array(
"type" =>
"rte_status",
"class" =>
"RTEPassed"),
459 array(
"type" =>
"rte_status",
"class" =>
"RTEFailed"),
460 array(
"type" =>
"rte_status",
"class" =>
"RTEBrowsed"),
461 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeLink"),
462 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeLinkDisabled"),
463 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeCurrent"),
464 array(
"type" =>
"rte_tul",
"class" =>
"RTETreeList"),
465 array(
"type" =>
"rte_tli",
"class" =>
"RTETreeItem"),
466 array(
"type" =>
"rte_texp",
"class" =>
"RTETreeExpanded"),
467 array(
"type" =>
"rte_texp",
"class" =>
"RTETreeCollapsed"),
468 array(
"type" =>
"rte_tree",
"class" =>
"RTETreeControl"),
469 array(
"type" =>
"rte_tclink",
"class" =>
"RTETreeControlLink"),
470 array(
"type" =>
"rte_drag",
"class" =>
"RTEDragBar"),
471 array(
"type" =>
"list_o",
"class" =>
"NumberedList"),
472 array(
"type" =>
"list_u",
"class" =>
"BulletedList"),
473 array(
"type" =>
"list_item",
"class" =>
"StandardListItem"),
474 array(
"type" =>
"question",
"class" =>
"Standard"),
475 array(
"type" =>
"question",
"class" =>
"SingleChoice"),
476 array(
"type" =>
"question",
"class" =>
"MultipleChoice"),
477 array(
"type" =>
"question",
"class" =>
"TextQuestion"),
478 array(
"type" =>
"question",
"class" =>
"OrderingQuestion"),
479 array(
"type" =>
"question",
"class" =>
"MatchingQuestion"),
480 array(
"type" =>
"question",
"class" =>
"ImagemapQuestion"),
481 array(
"type" =>
"question",
"class" =>
"ErrorText"),
482 array(
"type" =>
"question",
"class" =>
"TextSubset"),
483 array(
"type" =>
"question",
"class" =>
"ClozeTest"),
484 array(
"type" =>
"qtitle",
"class" =>
"Title"),
485 array(
"type" =>
"qanswer",
"class" =>
"Answer"),
486 array(
"type" =>
"qimg",
"class" =>
"QuestionImage"),
487 array(
"type" =>
"qimgd",
"class" =>
"ImageDetailsLink"),
488 array(
"type" =>
"qordul",
"class" =>
"OrderList"),
489 array(
"type" =>
"qordli",
"class" =>
"OrderListItem"),
490 array(
"type" =>
"qordul",
"class" =>
"OrderListHorizontal"),
491 array(
"type" =>
"qordli",
"class" =>
"OrderListItemHorizontal"),
492 array(
"type" =>
"qetitem",
"class" =>
"ErrorTextItem"),
493 array(
"type" =>
"qetitem",
"class" =>
"ErrorTextSelected"),
494 array(
"type" =>
"qetcorr",
"class" =>
"ErrorTextCorrected"),
495 array(
"type" =>
"qinput",
"class" =>
"TextInput"),
496 array(
"type" =>
"qlinput",
"class" =>
"LongTextInput"),
497 array(
"type" =>
"qsubmit",
"class" =>
"Submit"),
498 array(
"type" =>
"qfeedr",
"class" =>
"FeedbackRight"),
499 array(
"type" =>
"qfeedw",
"class" =>
"FeedbackWrong"),
500 array(
"type" =>
"qover",
"class" =>
"Correct"),
501 array(
"type" =>
"qover",
"class" =>
"Inorrect"),
502 array(
"type" =>
"qover",
"class" =>
"StatusMessage"),
503 array(
"type" =>
"qover",
"class" =>
"WrongAnswersMessage"),
504 array(
"type" =>
"flist_cont",
"class" =>
"FileListContainer"),
505 array(
"type" =>
"flist_head",
"class" =>
"FileListHeading"),
506 array(
"type" =>
"flist",
"class" =>
"FileList"),
507 array(
"type" =>
"flist_li",
"class" =>
"FileListItem"),
508 array(
"type" =>
"flist_a",
"class" =>
"FileListItemLink")
514 "caption" =>
"table_caption",
515 "row_head" =>
"table_cell",
516 "row_foot" =>
"table_cell",
517 "col_head" =>
"table_cell",
518 "col_foot" =>
"table_cell",
519 "odd_row" =>
"table_cell",
520 "even_row" =>
"table_cell",
521 "odd_col" =>
"table_cell",
522 "even_col" =>
"table_cell"),
523 "vaccordion" => array(
524 "va_cntr" =>
"va_cntr",
525 "va_icntr" =>
"va_icntr",
526 "va_ihead" =>
"va_ihead",
527 "va_iheada" =>
"va_iheada",
528 "va_ihcap" =>
"va_ihcap",
529 "va_icont" =>
"va_icont" 531 "haccordion" => array(
532 "ha_cntr" =>
"ha_cntr",
533 "ha_icntr" =>
"ha_icntr",
534 "ha_ihead" =>
"ha_ihead",
535 "ha_iheada" =>
"ha_iheada",
536 "ha_ihcap" =>
"ha_ihcap",
537 "ha_icont" =>
"ha_icont" 540 "ca_cntr" =>
"ca_cntr",
541 "ca_icntr" =>
"ca_icntr",
542 "ca_ihead" =>
"ca_ihead",
543 "ca_icont" =>
"ca_icont" 559 public function __construct($a_id = 0, $a_call_by_reference =
false)
563 $this->db = $DIC->database();
564 $this->lng = $DIC->language();
566 $this->
style = array();
567 if ($a_call_by_reference) {
568 $this->
ilias->raiseError(
"Can't instantiate style object via reference id.", $this->
ilias->error_obj->FATAL);
571 parent::__construct($a_id,
false);
581 return self::$basic_style_zip;
589 $this->
ilias->raiseError(
"Operation ilObjStyleSheet::setRefId() not allowed.", $this->
ilias->error_obj->FATAL);
606 $this->
ilias->raiseError(
"Operation ilObjStyleSheet::putInTree() not allowed.", $this->
ilias->error_obj->FATAL);
614 $this->
ilias->raiseError(
"Operation ilObjStyleSheet::createReference() not allowed.", $this->
ilias->error_obj->FATAL);
622 $this->up_to_date = $a_up_to_date;
630 return $this->up_to_date;
638 $this->scope = $a_scope;
656 $ilDB = $DIC->database();
658 $q =
"UPDATE style_data SET uptodate = " .
659 $ilDB->quote((
int) $a_up_to_date,
"integer") .
660 " WHERE id = " .
$ilDB->quote($a_id,
"integer");
661 $ilDB->manipulate($q);
671 $ilDB = $DIC->database();
673 $q =
"SELECT uptodate FROM style_data " .
674 " WHERE id = " .
$ilDB->quote($a_id,
"integer");
678 return (
boolean) $sty[
"uptodate"];
688 $ilDB = $DIC->database();
690 $q =
"UPDATE style_data SET standard = " .
691 $ilDB->quote((
int) $a_std,
"integer") .
692 " WHERE id = " .
$ilDB->quote($a_id,
"integer");
693 $ilDB->manipulate($q);
703 $ilDB = $DIC->database();
705 $q =
"UPDATE style_data SET category = " .
706 $ilDB->quote((
int) $a_scope,
"integer") .
707 " WHERE id = " .
$ilDB->quote($a_id,
"integer");
708 $ilDB->manipulate($q);
718 $ilDB = $DIC->database();
720 $q =
"SELECT * FROM style_data " .
721 " WHERE id = " .
$ilDB->quote($a_id,
"integer");
725 return (
boolean) $sty[
"standard"];
735 $ilDB = $DIC->database();
737 $q =
"UPDATE style_data SET active = " .
738 $ilDB->quote((
int) $a_active,
"integer") .
739 " WHERE id = " .
$ilDB->quote($a_id,
"integer");
740 $ilDB->manipulate($q);
750 $ilDB = $DIC->database();
752 $q =
"SELECT * FROM style_data " .
753 " WHERE id = " .
$ilDB->quote($a_id,
"integer");
757 return (
boolean) $sty[
"active"];
764 $a_exclude_default_style =
false,
765 $a_include_deactivated =
false,
770 $ilDB = $DIC->database();
772 $tree = $DIC->repositoryTree();
774 $default_style =
$ilSetting->get(
"default_content_style_id");
777 if (!$a_include_deactivated) {
778 $and_str =
" AND active = 1";
781 $q =
"SELECT * FROM style_data " .
782 " WHERE standard = 1" . $and_str;
786 if (!$a_exclude_default_style || $default_style != $sty[
"id"]) {
788 if ($a_scope > 0 && $sty[
"category"] > 0) {
789 if (
$tree->isInTree($sty[
"category"]) &&
790 $tree->isInTree($a_scope)) {
792 if (!in_array($sty[
"category"],
$path)) {
813 $ilAccess = $DIC->access();
814 $ilDB = $DIC->database();
816 $clonable_styles = array();
818 $q =
"SELECT * FROM style_data";
819 $style_set =
$ilDB->query($q);
820 while ($style_rec =
$ilDB->fetchAssoc($style_set)) {
822 if ($style_rec[
"standard"] == 1) {
823 if ($style_rec[
"active"] == 1) {
827 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
829 if (count($obj_ids) == 0) {
830 $obj_ids = self::lookupObjectForStyle($style_rec[
"id"]);
832 foreach ($obj_ids as
$id) {
835 if ($ilAccess->checkAccess(
"write",
"", $ref_id)) {
842 $clonable_styles[$style_rec[
"id"]] =
847 asort($clonable_styles);
849 return $clonable_styles;
857 $this->meta_data = $a_meta_data;
865 if (!is_object(self::$basic_style_dom)) {
867 self::$basic_style_dom->load(self::$basic_style_file);
870 return self::$basic_style_dom;
878 return $this->meta_data;
884 public function create($a_from_style = 0, $a_import_mode =
false)
890 if ($a_from_style == 0) {
891 if (!$a_import_mode) {
898 self::$basic_style_image_dir,
903 $q =
"INSERT INTO style_data (id, uptodate, category) VALUES " .
904 "(" .
$ilDB->quote($this->
getId(),
"integer") .
", 0," .
906 $ilDB->manipulate($q);
912 $q =
"SELECT * FROM style_parameter WHERE style_id = " .
913 $ilDB->quote($a_from_style,
"integer");
914 $par_set =
$ilDB->query($q);
915 while ($par_rec =
$ilDB->fetchAssoc($par_set)) {
916 $def[] = array(
"tag" => $par_rec[
"tag"],
"class" => $par_rec[
"class"],
917 "parameter" => $par_rec[
"parameter"],
"value" => $par_rec[
"value"],
918 "type" => $par_rec[
"type"],
"mq_id" => $par_rec[
"mq_id"],
"custom" => $par_rec[
"custom"]);
923 $q =
"SELECT * FROM style_char WHERE style_id = " .
924 $ilDB->quote($a_from_style,
"integer");
925 $par_set =
$ilDB->query($q);
926 while ($par_rec =
$ilDB->fetchAssoc($par_set)) {
927 $chars[] = array(
"type" => $par_rec[
"type"],
"characteristic" => $par_rec[
"characteristic"]);
933 $mqs = $from_style->getMediaQueries();
934 $mq_mapping = array();
935 foreach ($mqs as $mq) {
937 $mq_mapping[$mq[
"id"]] = $nid;
941 foreach (
$def as $sty) {
942 $id =
$ilDB->nextId(
"style_parameter");
943 $q =
"INSERT INTO style_parameter (id, style_id, tag, class, parameter, value, type, mq_id, custom) VALUES " .
945 $ilDB->quote(
$id,
"integer") .
"," .
946 $ilDB->quote($this->
getId(),
"integer") .
"," .
947 $ilDB->quote($sty[
"tag"],
"text") .
"," .
948 $ilDB->quote($sty[
"class"],
"text") .
"," .
949 $ilDB->quote($sty[
"parameter"],
"text") .
"," .
950 $ilDB->quote($sty[
"value"],
"text") .
"," .
951 $ilDB->quote($sty[
"type"],
"text") .
"," .
952 $ilDB->quote((
int) $mq_mapping[$sty[
"mq_id"]],
"integer") .
"," .
953 $ilDB->quote($sty[
"custom"],
"integer") .
955 $ilDB->manipulate($q);
959 foreach ($chars as $char) {
960 $q =
"INSERT INTO style_char (style_id, type, characteristic) VALUES " .
961 "(" .
$ilDB->quote($this->
getId(),
"integer") .
"," .
962 $ilDB->quote($char[
"type"],
"text") .
"," .
963 $ilDB->quote($char[
"characteristic"],
"text") .
")";
964 $ilDB->manipulate($q);
968 $q =
"INSERT INTO style_data (id, uptodate, category) VALUES " .
969 "(" .
$ilDB->quote($this->
getId(),
"integer") .
", 0," .
971 $ilDB->manipulate($q);
976 $from_style->getImagesDirectory(),
981 $colors = $from_style->getColors();
982 foreach ($colors as
$c) {
983 $this->
addColor($c[
"name"], $c[
"code"]);
988 foreach ($tcts as $tct => $v) {
991 $this->
addTemplate($tct, $t[
"name"], $t[
"classes"]);
997 if (!$a_import_mode) {
1013 $st =
$ilDB->manipulateF(
1014 "DELETE FROM style_char WHERE style_id = %s AND type = %s AND characteristic = %s",
1015 array(
"integer",
"text",
"text"),
1020 $st =
$ilDB->manipulateF(
1021 "DELETE FROM style_parameter WHERE style_id = %s AND tag = %s AND type = %s AND class = %s",
1022 array(
"integer",
"text",
"text",
"text"),
1038 $set =
$ilDB->queryF(
1039 "SELECT style_id FROM style_char WHERE style_id = %s AND characteristic = %s AND type = %s",
1040 array(
"integer",
"text",
"text"),
1041 array($this->
getId(), $a_char, $a_style_type)
1043 if ($rec =
$ilDB->fetchAssoc($set)) {
1058 "INSERT INTO style_char (style_id, type, characteristic, hide)" .
1059 " VALUES (%s,%s,%s,%s) ",
1060 array(
"integer",
"text",
"text",
"integer"),
1090 $pars = $from_style->getParametersOfClass($a_from_type, $a_from_char);
1093 foreach ($pars as $p => $v) {
1094 if (substr($v, 0, 1) ==
"!") {
1095 $colors[] = substr($v, 1);
1107 foreach ($colors as
$c) {
1109 $this->
addColor($c, $from_style->getColorCodeForName($c));
1122 $chars = $this->chars;
1124 if (is_array($this->chars_by_type[
$a_type])) {
1125 foreach ($this->chars_by_type[$a_type] as
$c) {
1126 if ($a_include_core || !self::isCoreStyle($a_type, $c)) {
1133 foreach ($chars as $k => $char) {
1134 if ($a_type ==
"" && $this->hidden_chars[$char[
"type"] .
":" . $char[
"class"]]) {
1136 } elseif ($this->hidden_chars[$a_type .
":" . $char]) {
1150 $this->chars = $a_chars;
1162 "UPDATE style_char SET " .
1163 " hide = " .
$ilDB->quote((
int) $a_hide,
"integer") .
1164 " WHERE style_id = " .
$ilDB->quote($this->
getId(),
"integer") .
" AND " .
1166 " characteristic = " .
$ilDB->quote($a_char,
"text")
1177 $set =
$ilDB->query(
1178 "SELECT hide FROM style_char " .
1179 " WHERE style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
1181 " characteristic = " .
$ilDB->quote($a_char,
"text")
1183 $rec =
$ilDB->fetchAssoc($set);
1185 return $rec[
"hide"];
1198 $lng->loadLanguageModule(
"style");
1201 $new_obj->setTitle($this->
getTitle() .
" (" .
$lng->txt(
"sty_acopy") .
")");
1202 $new_obj->setType($this->
getType());
1204 $new_obj->create($this->
getId());
1206 $new_obj->writeStyleSetting(
1207 "disable_auto_margins",
1211 return $new_obj->getId();
1236 $tag = explode(
".", $a_tag);
1237 $value = $avail_params[$a_par][0];
1238 $id =
$ilDB->nextId(
"style_parameter");
1239 $q =
"INSERT INTO style_parameter (id,style_id, type, tag, class, parameter, value, mq_id, custom) VALUES " .
1241 $ilDB->quote(
$id,
"integer") .
"," .
1242 $ilDB->quote($this->
getId(),
"integer") .
"," .
1246 $ilDB->quote($a_par,
"text") .
"," .
1247 $ilDB->quote($value,
"text") .
"," .
1248 $ilDB->quote($a_mq_id,
"integer") .
"," .
1249 $ilDB->quote($a_custom,
"integer") .
1251 $ilDB->manipulate($q);
1277 if (!is_writable($sty_data_dir)) {
1278 $ilErr->raiseError(
"Style data directory (" . $sty_data_dir
1279 .
") not writeable.",
$ilErr->FATAL);
1282 $style_dir = $sty_data_dir .
"/sty_" . $a_style_id;
1284 if (!@is_dir($style_dir)) {
1285 $ilErr->raiseError(
"Creation of style directory failed (" .
1286 $style_dir .
").",
$ilErr->FATAL);
1290 $im_dir = $style_dir .
"/images";
1292 if (!@is_dir($im_dir)) {
1293 $ilErr->raiseError(
"Creation of Import Directory failed (" .
1294 $im_dir .
").",
$ilErr->FATAL);
1298 $thumb_dir = $style_dir .
"/images/thumbnails";
1300 if (!@is_dir($thumb_dir)) {
1301 $ilErr->raiseError(
"Creation of Import Directory failed (" .
1302 $thumb_dir .
").",
$ilErr->FATAL);
1341 foreach ($entries as $entry) {
1342 if (substr($entry[
"entry"], 0, 1) ==
".") {
1345 if ($entry[
"type"] !=
"dir") {
1360 @ilUtil::moveUploadedFile(
1361 $a_file[
"tmp_name"],
1395 $q =
"DELETE FROM style_parameter WHERE id = " .
1396 $ilDB->quote($a_id,
"integer");
1413 $q =
"DELETE FROM style_parameter WHERE " .
1414 " style_id = " .
$ilDB->quote($this->
getId(),
"integer") .
" AND " .
1415 " tag = " .
$ilDB->quote($a_tag,
"text") .
" AND " .
1416 " class = " .
$ilDB->quote($a_class,
"text") .
" AND " .
1417 " mq_id = " .
$ilDB->quote($a_mq_id,
"integer") .
" AND " .
1418 " custom = " .
$ilDB->quote($a_custom,
"integer") .
" AND " .
1419 " " .
$ilDB->equals(
"type",
$a_type,
"text",
true) .
" AND " .
1420 " parameter = " .
$ilDB->quote($a_par,
"text");
1422 $ilDB->manipulate($q);
1438 $q =
"DELETE FROM style_parameter WHERE " .
1439 " style_id = " .
$ilDB->quote($this->
getId(),
"integer") .
" AND " .
1440 " tag = " .
$ilDB->quote($a_tag,
"text") .
" AND " .
1441 " class = " .
$ilDB->quote($a_class,
"text") .
" AND " .
1442 " mq_id = " .
$ilDB->quote($a_mq_id,
"integer") .
" AND " .
1443 " custom = " .
$ilDB->quote(1,
"integer") .
" AND " .
1446 $ilDB->manipulate($q);
1461 $q =
"DELETE FROM style_parameter WHERE " .
1462 " style_id = " .
$ilDB->quote($this->
getId(),
"integer") .
" AND " .
1463 " class = " .
$ilDB->quote($a_class,
"text") .
" AND " .
1466 $ilDB->manipulate($q);
1473 public function delete()
1481 $def_style = $this->
ilias->getSetting(
"default_content_style_id");
1482 if ($def_style == $this->
getId()) {
1483 $this->
ilias->deleteSetting(
"default_content_style_id");
1487 $fixed_style = $this->
ilias->getSetting(
"fixed_content_style_id");
1488 if ($fixed_style == $this->
getId()) {
1489 $this->
ilias->deleteSetting(
"fixed_content_style_id");
1493 $q =
"DELETE FROM style_parameter WHERE style_id = " .
1495 $ilDB->manipulate($q);
1499 if (is_file($css_file_name)) {
1500 unlink($css_file_name);
1505 "DELETE FROM sty_media_query WHERE " .
1506 " style_id = " .
$ilDB->quote($this->getId(),
"integer")
1510 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
1514 $q =
"DELETE FROM style_data WHERE id = " .
1516 $ilDB->manipulate($q);
1529 $q =
"SELECT * FROM style_parameter WHERE style_id = " .
1530 $ilDB->quote($this->
getId(),
"integer") .
" ORDER BY tag, class, type, mq_id ";
1531 $style_set =
$ilDB->query($q);
1536 $this->
style = array();
1540 $this->end_styles = array();
1541 while ($style_rec =
$ilDB->fetchAssoc($style_set)) {
1542 if ($style_rec[
"tag"] != $ctag || $style_rec[
"class"] != $cclass
1543 || $style_rec[
"type"] != $ctype || $style_rec[
"mq_id"] != $cmq_id) {
1545 if (is_array(
$tag)) {
1546 if (in_array($ctype, array(
"ha_iheada",
"va_iheada"))) {
1547 $this->end_styles[] =
$tag;
1554 $ctag = $style_rec[
"tag"];
1555 $cclass = $style_rec[
"class"];
1556 $ctype = $style_rec[
"type"];
1557 $cmq_id = $style_rec[
"mq_id"];
1558 $tag[] = $style_rec;
1560 $this->style_class[$ctype][$cclass][$cmq_id][$style_rec[
"parameter"]] = $style_rec[
"value"];
1562 if (is_array(
$tag)) {
1565 foreach ($this->end_styles as
$s) {
1569 $q =
"SELECT * FROM style_data WHERE id = " .
1577 $this->chars = array();
1578 $this->chars_by_type = array();
1579 $q =
"SELECT * FROM style_char WHERE style_id = " .
1581 " ORDER BY type ASC, characteristic ASC";
1582 $par_set =
$ilDB->query($q);
1583 while ($par_rec =
$ilDB->fetchAssoc($par_set)) {
1584 $this->chars[] = array(
"type" => $par_rec[
"type"],
"class" => $par_rec[
"characteristic"],
"hide" => $par_rec[
"hide"]);
1585 $this->chars_by_type[$par_rec[
"type"]][] = $par_rec[
"characteristic"];
1586 if ($par_rec[
"hide"]) {
1587 $this->hidden_chars[$par_rec[
"type"] .
":" . $par_rec[
"characteristic"]] =
true;
1600 if ($a_target_file ==
"") {
1603 $css_file_name = $a_target_file;
1605 $css_file =
fopen($css_file_name,
"w");
1607 $page_background =
"";
1609 $mqs = array(array(
"mquery" =>
"",
"id" => 0));
1615 foreach ($mqs as $mq) {
1616 if ($mq[
"id"] > 0) {
1617 fwrite($css_file,
"@media " . $mq[
"mquery"] .
" {\n");
1621 if ($tag[0][
"mq_id"] != $mq[
"id"]) {
1624 fwrite($css_file, $tag[0][
"tag"] .
".ilc_" . $tag[0][
"type"] .
"_" . $tag[0][
"class"] .
"\n");
1627 if ($tag[0][
"tag"] ==
"td") {
1628 fwrite($css_file,
",th" .
".ilc_" . $tag[0][
"type"] .
"_" . $tag[0][
"class"] .
"\n");
1630 if (in_array($tag[0][
"tag"], array(
"h1",
"h2",
"h3"))) {
1631 fwrite($css_file,
",div.ilc_text_block_" . $tag[0][
"class"] .
"\n");
1632 fwrite($css_file,
",body.ilc_text_block_" . $tag[0][
"class"] .
"\n");
1634 if ($tag[0][
"type"] ==
"section") {
1635 fwrite($css_file,
",a.ilc_" . $tag[0][
"type"] .
"_" . $tag[0][
"class"] .
"\n");
1637 if ($tag[0][
"type"] ==
"text_block") {
1638 fwrite($css_file,
",body.ilc_text_block_" . $tag[0][
"class"] .
"\n");
1640 fwrite($css_file,
"{\n");
1643 $t_border = array();
1645 foreach ($tag as $par) {
1646 $cur_par = $par[
"parameter"];
1647 $cur_val = $par[
"value"];
1650 if (is_int(strpos($cur_par,
"color")) && substr(trim($cur_val), 0, 1) ==
"!") {
1654 if ($tag[0][
"type"] ==
"table" && is_int(strpos($par[
"parameter"],
"border"))) {
1655 $t_border[$cur_par] = $cur_val;
1658 if (in_array($cur_par, array(
"background-image",
"list-style-image"))) {
1659 if (is_int(strpos($cur_val,
"/"))) {
1660 $cur_val =
"url(" . $cur_val .
")";
1662 if ($a_image_dir ==
"") {
1663 $cur_val =
"url(../sty/sty_" . $this->
getId() .
"/images/" . $cur_val .
")";
1665 $cur_val =
"url(" . $a_image_dir .
"/" . $cur_val .
")";
1670 if ($cur_par ==
"opacity") {
1671 $cur_val = ((int) $cur_val) / 100;
1674 fwrite($css_file,
"\t" . $cur_par .
": " . $cur_val .
";\n");
1677 if ($cur_par ==
"min-height") {
1678 fwrite($css_file,
"\t" .
"height" .
": " .
"auto !important" .
";\n");
1679 fwrite($css_file,
"\t" .
"height" .
": " . $cur_val .
";\n");
1683 if ($cur_par ==
"opacity") {
1684 fwrite($css_file,
"\t" .
'-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=' . ($cur_val * 100) .
')"' .
";\n");
1685 fwrite($css_file,
"\t" .
'filter: alpha(opacity=' . ($cur_val * 100) .
')' .
";\n");
1686 fwrite($css_file,
"\t" .
'-moz-opacity: ' . $cur_val .
";\n");
1690 if ($cur_par ==
"transform") {
1691 fwrite($css_file,
"\t" .
'-webkit-transform: ' . $cur_val .
";\n");
1692 fwrite($css_file,
"\t" .
'-moz-transform: ' . $cur_val .
";\n");
1693 fwrite($css_file,
"\t" .
'-ms-transform: ' . $cur_val .
";\n");
1697 if ($cur_par ==
"transform-origin") {
1698 fwrite($css_file,
"\t" .
'-webkit-transform-origin: ' . $cur_val .
";\n");
1699 fwrite($css_file,
"\t" .
'-moz-transform-origin: ' . $cur_val .
";\n");
1700 fwrite($css_file,
"\t" .
'-ms-transform-origin: ' . $cur_val .
";\n");
1704 if ($tag[0][
"tag"] ==
"div" && $tag[0][
"class"] ==
"Page" 1705 && $cur_par ==
"background-color") {
1706 $page_background = $cur_val;
1709 fwrite($css_file,
"}\n");
1710 fwrite($css_file,
"\n");
1730 if ($page_background !=
"") {
1731 fwrite($css_file,
"td.ilc_Page\n");
1732 fwrite($css_file,
"{\n");
1733 fwrite($css_file,
"\t" .
"background-color: " . $page_background .
";\n");
1734 fwrite($css_file,
"}\n");
1736 if ($mq[
"id"] > 0) {
1737 fwrite($css_file,
"}\n");
1759 $fixed_style =
$ilSetting->get(
"fixed_content_style_id");
1760 if ($fixed_style > 0) {
1761 $a_style_id = $fixed_style;
1765 if ($a_style_id <= 0) {
1766 $a_style_id =
$ilSetting->get(
"default_content_style_id");
1784 if (is_array($this->style_class[
$a_type][$a_class][$a_mq_id])) {
1785 return $this->style_class[
$a_type][$a_class][$a_mq_id];
1801 $random = new \ilRandom();
1802 $rand = $random->int(1, 999999);
1806 $fixed_style =
$ilSetting->get(
"fixed_content_style_id");
1807 if ($fixed_style > 0) {
1808 $a_style_id = $fixed_style;
1812 if ($a_style_id <= 0) {
1813 $a_style_id =
$ilSetting->get(
"default_content_style_id");
1825 $path .=
"?dummy=$rand";
1827 require_once(
'./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
1832 return "./Services/COPage/css/content.css";
1843 return "./Services/COPage/css/print_content.css";
1853 return "./Services/COPage/css/syntaxhighlight.css";
1863 return "./Services/COPage/css/placeholder.css";
1874 $q =
"UPDATE style_data " .
1875 "SET category = " .
$ilDB->quote((
int) $this->
getScope(),
"integer") .
1876 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
1877 $ilDB->manipulate($q);
1890 $q =
"UPDATE style_parameter SET VALUE = " .
1891 $ilDB->quote($a_value,
"text") .
" WHERE id = " .
1892 $ilDB->quote($a_id,
"integer");
1893 $style_set =
$ilDB->manipulate($q);
1910 $ilDB = $DIC->database();
1912 $q =
"SELECT * FROM style_parameter WHERE " .
1913 " style_id = " .
$ilDB->quote($style_id,
"integer") .
" AND " .
1914 " tag = " .
$ilDB->quote($a_tag,
"text") .
" AND " .
1915 " class = " .
$ilDB->quote($a_class,
"text") .
" AND " .
1916 " mq_id = " .
$ilDB->quote($a_mq_id,
"integer") .
" AND " .
1917 " custom = " .
$ilDB->quote($a_custom,
"integer") .
" AND " .
1918 " " .
$ilDB->equals(
"type",
$a_type,
"text",
true) .
" AND " .
1919 " parameter = " .
$ilDB->quote($a_par,
"text");
1921 $set =
$ilDB->query($q);
1923 if ($rec = $set->fetchRow()) {
1924 $q =
"UPDATE style_parameter SET " .
1925 " value = " .
$ilDB->quote($a_val,
"text") .
" WHERE " .
1926 " style_id = " .
$ilDB->quote($style_id,
"integer") .
" AND " .
1927 " tag = " .
$ilDB->quote($a_tag,
"text") .
" AND " .
1928 " class = " .
$ilDB->quote($a_class,
"text") .
" AND " .
1929 " mq_id = " .
$ilDB->quote($a_mq_id,
"integer") .
" AND " .
1930 " custom = " .
$ilDB->quote($a_custom,
"integer") .
" AND " .
1931 " " .
$ilDB->equals(
"type",
$a_type,
"text",
true) .
" AND " .
1932 " parameter = " .
$ilDB->quote($a_par,
"text");
1934 $ilDB->manipulate($q);
1936 $id =
$ilDB->nextId(
"style_parameter");
1937 $q =
"INSERT INTO style_parameter (id, value, style_id, tag, class, type, parameter, mq_id, custom) VALUES " .
1939 $ilDB->quote(
$id,
"integer") .
"," .
1940 $ilDB->quote($a_val,
"text") .
"," .
1941 " " .
$ilDB->quote($style_id,
"integer") .
"," .
1942 " " .
$ilDB->quote($a_tag,
"text") .
"," .
1943 " " .
$ilDB->quote($a_class,
"text") .
"," .
1945 " " .
$ilDB->quote($a_par,
"text") .
"," .
1946 " " .
$ilDB->quote($a_mq_id,
"integer") .
"," .
1947 " " .
$ilDB->quote($a_custom,
"integer") .
1950 $ilDB->manipulate($q);
1968 $this->
style = $a_style;
1980 return str_replace(
"&",
"&", $a_str);
1989 $xml .=
"<StyleSheet>\n";
1996 foreach ($this->chars as $char) {
1998 "\" Type=\"" . $char[
"type"] .
"\" Class=\"" . $char[
"class"] .
"\">\n";
2000 if ($style[0][
"type"] == $char[
"type"] && $style[0][
"class"] == $char[
"class"]) {
2001 foreach ($style as
$tag) {
2002 $xml .=
"<StyleParameter Name=\"" . $tag[
"parameter"] .
"\" Value=\"" . $tag[
"value"] .
"\" Custom=\"" . $tag[
"custom"] .
"\" />\n";
2006 $xml .=
"</Style>\n";
2010 foreach ($this->
getColors() as $color) {
2011 $xml .=
"<StyleColor Name=\"" . $color[
"name"] .
"\" Code=\"" . $color[
"code"] .
"\"/>\n";
2016 foreach ($tcts as $tct => $v) {
2019 foreach ($ts as
$t) {
2020 $xml .=
"<StyleTemplate Type=\"" . $tct .
"\" Name=\"" . $t[
"name"] .
"\">\n";
2021 foreach ($t[
"classes"] as $ct =>
$c) {
2023 $xml .=
"<StyleTemplateClass ClassType=\"" . $ct .
"\" Class=\"" .
$c .
"\"/>\n";
2026 $xml .=
"</StyleTemplate>\n";
2031 $xml .=
"</StyleSheet>";
2044 if (!is_writable($sty_data_dir)) {
2045 $this->
ilias->raiseError(
"Style data directory (" . $sty_data_dir
2046 .
") not writeable.", $this->
ilias->error_obj->FATAL);
2049 $style_dir = $sty_data_dir .
"/sty_" . $this->
getId();
2051 if (!@is_dir($style_dir)) {
2052 $this->
ilias->raiseError(
"Creation of style directory failed (" .
2053 $style_dir .
").", $this->
ilias->error_obj->FATAL);
2057 $ex_dir = $style_dir .
"/export";
2059 if (!@is_dir($ex_dir)) {
2060 $this->
ilias->raiseError(
"Creation of Import Directory failed (" .
2061 $ex_dir .
").", $this->
ilias->error_obj->FATAL);
2073 $style_dir = $sty_data_dir .
"/sty_" . $this->
getId();
2075 $ex_dir = $style_dir .
"/export";
2077 if (is_dir($ex_dir)) {
2091 if (!is_writable($ex_sub_dir)) {
2092 $this->
ilias->raiseError(
"Style data directory (" . $ex_sub_dir
2093 .
") not writeable.", $this->
ilias->error_obj->FATAL);
2095 $ex_sub_images_dir = $ex_sub_dir .
"/images";
2097 if (!is_writable($ex_sub_images_dir)) {
2098 $this->
ilias->raiseError(
"Style data directory (" . $ex_sub_images_dir
2099 .
") not writeable.", $this->
ilias->error_obj->FATAL);
2108 $this->export_sub_dir = $a_dir;
2116 if ($this->export_sub_dir ==
"") {
2117 return "sty_" . $this->
getId();
2119 return $this->export_sub_dir;
2155 $file = $a_dir .
"/style.xml";
2158 if (!($fp = @
fopen($file,
"w"))) {
2159 die(
"<b>Error</b>: Could not open \"" . $file .
"\" for writing" .
2160 " in <b>" . __FILE__ .
"</b> on line <b>" . __LINE__ .
"</b><br />");
2167 fwrite($fp, $this->
getXML());
2180 if (!is_writable($sty_data_dir)) {
2181 $this->
ilias->raiseError(
"Style data directory (" . $sty_data_dir
2182 .
") not writeable.", $this->
ilias->error_obj->FATAL);
2185 $style_dir = $sty_data_dir .
"/sty_" . $this->
getId();
2187 if (!@is_dir($style_dir)) {
2188 $this->
ilias->raiseError(
"Creation of style directory failed (" .
2189 $style_dir .
").", $this->
ilias->error_obj->FATAL);
2193 $im_dir = $style_dir .
"/import";
2195 if (!@is_dir($im_dir)) {
2196 $this->
ilias->raiseError(
"Creation of Import Directory failed (" .
2197 $im_dir .
").", $this->
ilias->error_obj->FATAL);
2206 public function import($a_file)
2213 if (is_array($a_file)) {
2214 ilUtil::moveUploadedFile(
2215 $a_file[
"tmp_name"],
2217 $im_dir .
"/" . $a_file[
"name"]
2219 $file_name = $a_file[
"name"];
2221 $pi = pathinfo($a_file);
2222 $file_name = $pi[
"basename"];
2223 copy($a_file, $im_dir .
"/" . $file_name);
2225 $file = pathinfo($file_name);
2228 if (strtolower($file[
"extension"] ==
"zip")) {
2230 $subdir = basename($file[
"basename"],
"." . $file[
"extension"]);
2231 if (!is_dir($im_dir .
"/" . $subdir)) {
2234 $xml_file = $im_dir .
"/" . $subdir .
"/style.xml";
2236 $xml_file = $im_dir .
"/" . $file_name;
2245 if (is_dir($im_dir .
"/" . $subdir .
"/images")) {
2247 $im_dir .
"/" . $subdir .
"/images",
2265 $this->is_3_10_skin =
false;
2267 if (!$a_skip_parent_create) {
2270 include_once(
"./Services/Style/Content/classes/class.ilStyleImportParser.php");
2272 $importParser->startParsing();
2276 foreach ($style as
$tag) {
2277 $id =
$ilDB->nextId(
"style_parameter");
2280 if (in_array($tag[
"class"], array(
"PageFrame",
"PageContainer")) &&
2281 $tag[
"tag"] ==
"table") {
2282 $tag[
"tag"] =
"div";
2283 if ($tag[
"parameter"] ==
"width" && $tag[
"value"] ==
"100%") {
2288 $q =
"INSERT INTO style_parameter (id,style_id, tag, class, parameter, type, value, custom) VALUES " .
2290 $ilDB->quote(
$id,
"integer") .
"," .
2291 $ilDB->quote($this->
getId(),
"integer") .
"," .
2292 $ilDB->quote($tag[
"tag"],
"text") .
"," .
2293 $ilDB->quote($tag[
"class"],
"text") .
"," .
2294 $ilDB->quote($tag[
"parameter"],
"text") .
"," .
2295 $ilDB->quote($tag[
"type"],
"text") .
"," .
2296 $ilDB->quote($tag[
"value"],
"text") .
"," .
2297 $ilDB->quote((
bool) $tag[
"custom"],
"integer") .
2299 $ilDB->manipulate($q);
2304 $this->is_3_10_skin =
true;
2305 if (is_array($this->chars)) {
2306 foreach ($this->chars as $char) {
2307 if ($char[
"type"] !=
"") {
2308 $s = substr($char[
"class"], strlen($char[
"class"]) - 6);
2309 if (
$s !=
":hover") {
2313 "style_id" => array(
"integer", $this->
getId()),
2314 "type" => array(
"text", $char[
"type"]),
2315 "characteristic" => array(
"text", $char[
"class"])),
2316 array(
"hide" => array(
"integer", 0))
2324 $this->is_3_10_skin =
false;
2331 $q =
"INSERT INTO style_data (id, uptodate) VALUES " .
2332 "(" .
$ilDB->quote($this->
getId(),
"integer") .
", 0)";
2333 $ilDB->manipulate($q);
2338 if ($this->is_3_10_skin) {
2351 foreach (self::$parameter as
$parameter => $props) {
2359 $input = self::$parameter[$par][
"input"];
2365 $subpar = self::$parameter[$par][
"subpar"];
2372 return self::$parameter;
2375 foreach (self::$parameter as $k => $v) {
2376 if (is_array(self::$filtered_groups[$v[
"group"]]) &&
2377 !in_array($a_tag, self::$filtered_groups[$v[
"group"]])) {
2387 return self::$filtered_groups;
2392 if ($a_no_percentage) {
2393 return self::$num_unit_no_perc;
2395 return self::$num_unit;
2400 return self::$parameter[$par][
"values"];
2410 return self::$style_super_types;
2415 return in_array(
$a_type, self::$expandable_types);
2420 return in_array(
$a_type, self::$hideable_types);
2425 foreach (self::$style_super_types as
$s =>
$t) {
2440 $c_styles = array();
2441 foreach (self::$core_styles as $cstyle) {
2443 = array(
"type" => $cstyle[
"type"],
2445 "class" => $cstyle[
"class"]);
2458 foreach (self::$core_styles as
$s) {
2459 if ($s[
"type"] ==
$a_type && $s[
"class"] == $a_class) {
2472 if ($a_template_type ==
"") {
2473 return self::$templates;
2476 return self::$templates[$a_template_type];
2482 return self::$pseudo_classes[
$tag];
2487 return self::$templates[
$t][$k];
2492 return self::$assigned_tags[
$a_type];
2501 foreach (self::$parameter as $p => $v) {
2502 $pars[$p] = $v[
"values"];
2514 $styles = array(array(
"id" => $a_id));
2526 $ilDB = $DIC->database();
2528 if ($a_styles ==
"") {
2531 $styles = $a_styles;
2537 $core_images = array();
2538 $core_dir = self::$basic_style_image_dir;
2539 if (is_dir($core_dir)) {
2540 $dir = opendir($core_dir);
2541 while ($file = readdir($dir)) {
2542 if (substr($file, 0, 1) !=
"." && is_file($core_dir .
"/" . $file)) {
2543 $core_images[] = $file;
2548 foreach ($styles as
$style) {
2553 $set =
$ilDB->queryF(
2554 "SELECT * FROM style_char WHERE style_id = %s " .
2555 "AND type = %s AND characteristic = %s",
2556 array(
"integer",
"text",
"text"),
2557 array(
$id, $cs[
"type"], $cs[
"class"])
2561 if (!($rec =
$ilDB->fetchAssoc($set))) {
2563 "INSERT INTO style_char (style_id, type, characteristic) " .
2564 " VALUES (%s,%s,%s) ",
2565 array(
"integer",
"text",
"text"),
2566 array(
$id, $cs[
"type"], $cs[
"class"])
2570 $par_nodes = $xpath->query(
"/StyleSheet/Style[@Tag = '" . $cs[
"tag"] .
"' and @Type='" .
2571 $cs[
"type"] .
"' and @Class='" . $cs[
"class"] .
"']/StyleParameter");
2572 foreach ($par_nodes as $par_node) {
2574 $set =
$ilDB->queryF(
2575 "SELECT * FROM style_parameter WHERE style_id = %s " .
2576 "AND type = %s AND class = %s AND tag = %s AND parameter = %s",
2577 array(
"integer",
"text",
"text",
"text",
"text"),
2578 array(
$id, $cs[
"type"], $cs[
"class"],
2579 $cs[
"tag"], $par_node->getAttribute(
"Name"))
2583 if (!($rec =
$ilDB->fetchAssoc($set))) {
2584 $spid =
$ilDB->nextId(
"style_parameter");
2585 $st =
$ilDB->manipulateF(
2586 "INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value) " .
2587 " VALUES (%s,%s,%s,%s,%s,%s,%s)",
2588 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2589 array($spid,
$id, $cs[
"type"], $cs[
"class"], $cs[
"tag"],
2590 $par_node->getAttribute(
"Name"), $par_node->getAttribute(
"Value"))
2600 reset($core_images);
2601 foreach ($core_images as $cim) {
2602 if (!is_file($imdir .
"/" . $cim)) {
2603 copy($core_dir .
"/" . $cim, $imdir .
"/" . $cim);
2628 $st =
$ilDB->prepareManip(
"UPDATE style_char SET type = ? WHERE characteristic = ?" .
2629 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2630 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2631 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2632 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2633 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2634 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2635 $ilDB->execute($st, array(
"page_cont",
"Page", $this->
getId()));
2638 $st =
$ilDB->prepareManip(
"UPDATE style_parameter SET type = ? WHERE class = ?" .
2639 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2640 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2641 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2642 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2643 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2644 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2645 $ilDB->execute($st, array(
"table",
"Page", $this->
getId()));
2647 $st =
$ilDB->prepareManip(
"UPDATE style_parameter SET tag = ? WHERE class = ?" .
2648 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2649 $ilDB->execute($st, array(
"div",
"MediaCaption", $this->
getId()));
2652 $st =
$ilDB->prepareManip(
"UPDATE style_char SET characteristic = ? WHERE characteristic = ?" .
2653 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2654 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2655 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2658 $st =
$ilDB->prepareManip(
"UPDATE style_parameter SET class = ? WHERE class = ?" .
2659 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2660 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2661 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2664 $st =
$ilDB->prepareManip(
"DELETE FROM style_char WHERE type = ?" .
2665 " AND style_id = ? ", array(
"text",
"integer"));
2666 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2667 $st =
$ilDB->prepareManip(
"DELETE FROM style_parameter WHERE type = ?" .
2668 " AND style_id = ? ", array(
"text",
"integer"));
2669 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2684 $add_str =
" AND style_id = " .
$ilDB->quote($a_id,
"integer");
2687 $set =
$ilDB->query($q =
"SELECT DISTINCT style_id, tag, class FROM style_parameter WHERE " .
2688 $ilDB->equals(
"type",
"",
"text",
true) .
" " . $add_str);
2690 while ($rec =
$ilDB->fetchAssoc($set)) {
2693 switch ($rec[
"tag"]) {
2696 if (in_array($rec[
"class"], array(
"Headline3",
"Headline1",
2697 "Headline2",
"TableContent",
"List",
"Standard",
"Remark",
2698 "Additional",
"Mnemonic",
"Citation",
"Example"))) {
2699 $types[] =
"text_block";
2701 if (in_array($rec[
"class"], array(
"Block",
"Remark",
2702 "Additional",
"Mnemonic",
"Example",
"Excursus",
"Special"))) {
2703 $types[] =
"section";
2705 if (in_array($rec[
"class"], array(
"Page",
"Footnote",
"PageTitle",
"LMNavigation"))) {
2711 $types[] =
"table_cell";
2715 if (in_array($rec[
"class"], array(
"ExtLink",
"IntLink",
"FootnoteLink"))) {
2721 $types[] =
"text_inline";
2730 foreach ($types as
$t) {
2732 $set4 =
$ilDB->queryF(
2733 "SELECT * FROM style_char " .
2734 " WHERE style_id = %s AND type = %s AND characteristic = %s",
2735 array(
"integer",
"text",
"text"),
2736 array($rec[
"style_id"], $t, $rec[
"class"])
2738 if ($rec4 =
$ilDB->fetchAssoc($set4)) {
2743 "INSERT INTO style_char " .
2744 " (style_id, type, characteristic) VALUES " .
2746 array(
"integer",
"text",
"text"),
2747 array($rec[
"style_id"], $t, $rec[
"class"])
2753 if ($rec[
"type"] ==
"") {
2754 if (count($types) > 0) {
2756 "UPDATE style_parameter SET type = %s " .
2757 " WHERE style_id = %s AND class = %s AND " .
$ilDB->equals(
"type",
"",
"text",
true),
2758 array(
"text",
"integer",
"text"),
2759 array($types[0], $rec[
"style_id"], $rec[
"class"])
2764 if ($types[0] ==
"link") {
2766 "UPDATE style_parameter SET type = %s " .
2767 " WHERE style_id = %s AND (class = %s OR class = %s) AND " .
$ilDB->equals(
"type",
"",
"text",
true),
2768 array(
"text",
"integer",
"text",
"text"),
2769 array($types[0], $rec[
"style_id"], $rec[
"class"] .
":visited",
2770 $rec[
"class"] .
":hover")
2775 if (count($types) == 2) {
2778 $set2 =
$ilDB->queryF(
2779 "SELECT * FROM style_parameter " .
2780 " WHERE style_id = %s AND class = %s AND type = %s",
2781 array(
"integer",
"text",
"text"),
2782 array($rec[
"style_id"], $rec[
"class"], $types[0])
2784 while ($rec2 =
$ilDB->fetchAssoc($set2)) {
2786 $set3 =
$ilDB->queryF(
2787 "SELECT * FROM style_parameter " .
2788 " WHERE style_id = %s AND tag = %s AND class = %s AND type = %s AND parameter = %s",
2789 array(
"integer",
"text",
"text",
"text",
"text"),
2790 array($rec[
"style_id"], $rec[
"tag"], $rec[
"class"], $types[1], $rec[
"parameter"])
2792 if ($rec3 =
$ilDB->fetchAssoc($set3)) {
2795 $nid =
$ilDB->nextId(
"style_parameter");
2797 "INSERT INTO style_parameter " .
2798 " (id, style_id, tag, class, parameter, value, type) VALUES " .
2799 " (%s, %s,%s,%s,%s,%s,%s) ",
2800 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2801 array($nid, $rec2[
"style_id"], $rec2[
"tag"], $rec2[
"class"],
2802 $rec2[
"parameter"], $rec2[
"value"], $types[1])
2818 $classes = array(
"Example",
"Additional",
"Citation",
"Mnemonic",
"Remark");
2819 $pars = array(
"margin-top",
"margin-bottom");
2821 foreach ($classes as $curr_class) {
2822 foreach ($pars as $curr_par) {
2823 $res2 =
$ilDB->queryF(
2824 "SELECT id FROM style_parameter WHERE style_id = %s" .
2825 " AND tag = %s AND class= %s AND parameter = %s",
2826 array(
"integer",
"text",
"text",
"text"),
2827 array($a_id,
"p", $curr_class, $curr_par)
2829 if ($row2 =
$ilDB->fetchAssoc($res2)) {
2831 "UPDATE style_parameter SET value= %s WHERE id = %s",
2832 array(
"text",
"integer"),
2833 array(
"10px", $row2[
"id"])
2836 $nid =
$ilDB->nextId(
"style_parameter");
2838 "INSERT INTO style_parameter " .
2839 "(id, style_id, tag, class, parameter,value) VALUES (%s,%s,%s,%s,%s,%s)",
2840 array(
"integer",
"integer",
"text",
"text",
"text",
"text"),
2841 array($nid, $a_id,
"div", $curr_class, $curr_par,
"10px")
2848 "UPDATE style_parameter SET tag = %s WHERE tag = %s and style_id = %s",
2849 array(
"text",
"text",
"integer"),
2850 array(
"div",
"p", $a_id)
2865 $set =
$ilDB->query(
"SELECT * FROM style_color WHERE " .
2866 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" " .
2867 "ORDER BY color_name");
2870 while ($rec =
$ilDB->fetchAssoc($set)) {
2872 "name" => $rec[
"color_name"],
2873 "code" => $rec[
"color_code"]
2887 $ilDB->manipulate(
"INSERT INTO style_color (style_id, color_name, color_code)" .
2889 $ilDB->quote($this->getId(),
"integer") .
"," .
2890 $ilDB->quote($a_name,
"text") .
"," .
2891 $ilDB->quote($a_code,
"text") .
2904 $ilDB->manipulate(
"UPDATE style_color SET " .
2905 "color_name = " .
$ilDB->quote($a_new_name,
"text") .
", " .
2906 "color_code = " .
$ilDB->quote($a_code,
"text") .
2907 " WHERE style_id = " .
$ilDB->quote($this->
getId(),
"integer") .
2908 " AND color_name = " .
$ilDB->quote($a_name,
"text"));
2912 if ($a_name != $a_new_name) {
2913 $set =
$ilDB->query(
"SELECT * FROM style_parameter " .
2914 " WHERE style_id = " .
$ilDB->quote($this->getId(),
"integer") .
2916 " parameter = " .
$ilDB->quote(
"background-color",
"text") .
" OR " .
2917 " parameter = " .
$ilDB->quote(
"color",
"text") .
" OR " .
2918 " parameter = " .
$ilDB->quote(
"border-color",
"text") .
" OR " .
2919 " parameter = " .
$ilDB->quote(
"border-top-color",
"text") .
" OR " .
2920 " parameter = " .
$ilDB->quote(
"border-bottom-color",
"text") .
" OR " .
2921 " parameter = " .
$ilDB->quote(
"border-left-color",
"text") .
" OR " .
2922 " parameter = " .
$ilDB->quote(
"border-right-color",
"text") .
2924 while ($rec =
$ilDB->fetchAssoc($set)) {
2925 if ($rec[
"value"] ==
"!" . $a_name ||
2926 is_int(strpos($rec[
"value"],
"!" . $a_name .
"("))) {
2932 str_replace($a_name, $a_new_name, $rec[
"value"]),
2949 $ilDB->manipulate(
"DELETE FROM style_color WHERE " .
2950 " style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
2951 " color_name = " .
$ilDB->quote($a_name,
"text"));
2961 $set =
$ilDB->query(
"SELECT * FROM style_color WHERE " .
2962 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
2963 "color_name = " .
$ilDB->quote($a_color_name,
"text"));
2964 if ($rec =
$ilDB->fetchAssoc($set)) {
2977 $pos = strpos($a_name,
"(");
2979 $a_i = substr($a_name, $pos + 1);
2980 $a_i = str_replace(
")",
"", $a_i);
2981 $a_name = substr($a_name, 0, $pos);
2984 $set =
$ilDB->query(
"SELECT color_code FROM style_color WHERE " .
2985 " style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
2986 " color_name = " .
$ilDB->quote($a_name,
"text"));
2987 if ($rec =
$ilDB->fetchAssoc($set)) {
2989 return "#" . $rec[
"color_code"];
3008 $hls[
"l"] = $hls[
"l"] + ((255 - $hls[
"l"]) * ($a_i / 100));
3011 $hls[
"l"] = $hls[
"l"] - (($hls[
"l"]) * (-$a_i / 100));
3016 foreach ($rgb as $k => $v) {
3017 $rgb[$k] = str_pad(dechex($v), 2,
"0", STR_PAD_LEFT);
3020 return $rgb[
"r"] . $rgb[
"g"] . $rgb[
"b"];
3028 $r[
"r"] = substr($a_rgb, 0, 2);
3029 $r[
"g"] = substr($a_rgb, 2, 2);
3030 $r[
"b"] = substr($a_rgb, 4, 2);
3033 $r[
"r"] = (int) hexdec(
$r[
"r"]);
3034 $r[
"g"] = (int) hexdec(
$r[
"g"]);
3035 $r[
"b"] = (int) hexdec(
$r[
"b"]);
3046 $r = $a_rgb[
"r"] / 255;
3047 $g = $a_rgb[
"g"] / 255;
3048 $b = $a_rgb[
"b"] / 255;
3051 $max = max(
$r, $g, $b);
3052 $min = min(
$r, $g, $b);
3055 $l = ($max + $min) / 2;
3062 $s = ($max - $min) / ($max + $min);
3064 $s = ($max - $min) / (2.0 - $max - $min);
3068 $h = ($g - $b) / ($max - $min);
3069 } elseif ($g == $max) {
3070 $h = 2.0 + ($b -
$r) / ($max - $min);
3071 } elseif ($b == $max) {
3072 $h = 4.0 + (
$r - $g) / ($max - $min);
3076 $hls[
"h"] = round((
$h / 6) * 255);
3077 $hls[
"l"] = round(
$l * 255);
3078 $hls[
"s"] = round(
$s * 255);
3088 $h = $a_hls[
"h"] / 255;
3089 $l = $a_hls[
"l"] / 255;
3090 $s = $a_hls[
"s"] / 255;
3092 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = 0;
3096 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] =
$l;
3099 $temp2 =
$l * (1.0 +
$s);
3104 $temp1 = 2.0 *
$l - $temp2;
3107 # For each of R, G, B, compute another temporary value, temp3, as follows: 3108 foreach ($rgb as $k => $v) {
3111 $temp3 =
$h + 1.0 / 3.0;
3119 $temp3 =
$h - 1.0 / 3.0;
3123 $temp3 = $temp3 + 1.0;
3126 $temp3 = $temp3 - 1.0;
3129 if (6.0 * $temp3 < 1) {
3130 $rgb[$k] = $temp1 + ($temp2 - $temp1) * 6.0 * $temp3;
3131 } elseif (2.0 * $temp3 < 1) {
3133 } elseif (3.0 * $temp3 < 2) {
3134 $rgb[$k] = $temp1 + ($temp2 - $temp1) * ((2.0 / 3.0) - $temp3) * 6.0;
3141 $rgb[
"r"] = round($rgb[
"r"] * 255);
3142 $rgb[
"g"] = round($rgb[
"g"] * 255);
3143 $rgb[
"b"] = round($rgb[
"b"] * 255);
3163 $set =
$ilDB->query(
"SELECT * FROM sty_media_query WHERE " .
3164 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" " .
3165 "ORDER BY order_nr");
3168 while ($rec =
$ilDB->fetchAssoc($set)) {
3183 $id =
$ilDB->nextId(
"sty_media_query");
3184 if ($order_nr == 0) {
3188 $ilDB->manipulate(
"INSERT INTO sty_media_query (id, style_id, mquery, order_nr)" .
3190 $ilDB->quote(
$id,
"integer") .
"," .
3191 $ilDB->quote($this->
getId(),
"integer") .
"," .
3192 $ilDB->quote($a_mquery,
"text") .
"," .
3193 $ilDB->quote($order_nr,
"integer") .
3207 $set =
$ilDB->query(
3208 "SELECT max(order_nr) mnr FROM sty_media_query " .
3209 " WHERE style_id = " .
$ilDB->quote($this->getId(),
"integer")
3211 $rec =
$ilDB->fetchAssoc($set);
3213 return (
int) $rec[
"mnr"];
3227 "UPDATE sty_media_query SET " .
3228 " mquery = " .
$ilDB->quote($a_mquery,
"text") .
3229 " WHERE id = " .
$ilDB->quote($a_id,
"integer")
3243 $set =
$ilDB->query(
3244 "SELECT * FROM sty_media_query " .
3245 " WHERE id = " .
$ilDB->quote($a_id,
"integer")
3247 return $ilDB->fetchAssoc($set);
3260 "DELETE FROM sty_media_query WHERE " .
3261 " style_id = " .
$ilDB->quote($this->getId(),
"integer") .
3262 " AND id = " .
$ilDB->quote($a_id,
"integer")
3277 if (is_array($a_order_nr)) {
3278 foreach ($mqueries as $k => $mq) {
3279 $mqueries[$k][
"order_nr"] = $a_order_nr[$mq[
"id"]];
3284 foreach ($mqueries as $mq) {
3286 "UPDATE sty_media_query SET " .
3287 " order_nr = " .
$ilDB->quote($cnt,
"integer") .
3288 " WHERE id = " .
$ilDB->quote($mq[
"id"],
"integer")
3306 $set =
$ilDB->query(
"SELECT * FROM style_template WHERE " .
3307 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
3312 while ($rec =
$ilDB->fetchAssoc($set)) {
3326 $set =
$ilDB->query(
"SELECT * FROM style_template_class WHERE " .
3327 "template_id = " .
$ilDB->quote($a_tid,
"integer"));
3330 while ($rec =
$ilDB->fetchAssoc($set)) {
3331 $key = $rec[
"class_type"];
3332 $class[
$key] = $rec[
"class"];
3346 $tid =
$ilDB->nextId(
"style_template");
3347 $ilDB->manipulate($q =
"INSERT INTO style_template " .
3348 "(id, style_id, name, temp_type)" .
3350 $ilDB->quote($tid,
"integer") .
"," .
3351 $ilDB->quote($this->
getId(),
"integer") .
"," .
3352 $ilDB->quote($a_name,
"text") .
"," .
3356 foreach ($a_classes as
$t =>
$c) {
3357 $ilDB->manipulate($q =
"INSERT INTO style_template_class " .
3358 "(template_id, class_type, class)" .
3360 $ilDB->quote($tid,
"integer") .
"," .
3361 $ilDB->quote(
$t,
"text") .
"," .
3366 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheetGUI.php");
3382 $ilDB->manipulate(
"UPDATE style_template SET " .
3383 "name = " .
$ilDB->quote($a_name,
"text") .
3384 " WHERE id = " .
$ilDB->quote($a_t_id,
"integer"));
3387 "DELETE FROM style_template_class WHERE " .
3388 "template_id = " .
$ilDB->quote($a_t_id,
"integer")
3390 foreach ($a_classes as
$t =>
$c) {
3391 $ilDB->manipulate($q =
"INSERT INTO style_template_class " .
3392 "(template_id, class_type, class)" .
3394 $ilDB->quote($a_t_id,
"integer") .
"," .
3395 $ilDB->quote(
$t,
"text") .
"," .
3408 $ilDB->manipulate($q =
"INSERT INTO style_template_class " .
3409 "(template_id, class_type, class)" .
3411 $ilDB->quote($a_t_id,
"integer") .
"," .
3413 $ilDB->quote($a_class,
"text") .
3425 $set =
$ilDB->query(
"SELECT * FROM style_template WHERE " .
3426 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
3427 "name = " .
$ilDB->quote($a_template_name,
"text"));
3428 if ($rec =
$ilDB->fetchAssoc($set)) {
3441 $set =
$ilDB->query(
"SELECT * FROM style_template WHERE " .
3442 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" " .
3443 " AND id = " .
$ilDB->quote($a_t_id,
"integer"));
3445 if ($rec =
$ilDB->fetchAssoc($set)) {
3459 return self::_lookupTemplateName($a_t_id);
3469 $ilDB = $DIC->database();
3471 $set =
$ilDB->query(
"SELECT name FROM style_template WHERE " .
3472 " id = " .
$ilDB->quote($a_t_id,
"integer"));
3474 if ($rec =
$ilDB->fetchAssoc($set)) {
3475 return $rec[
"name"];
3488 $tag =
"<StyleTemplates>";
3490 $ttypes = array(
"table",
"vaccordion",
"haccordion",
"carousel");
3492 foreach ($ttypes as $ttype) {
3495 foreach ($ts as
$t) {
3509 $tag .=
'<StyleTemplate Name="' . $t[
"name"] .
'">';
3511 foreach ($atts as
$type => $t) {
3517 $tag .=
"</StyleTemplate>";
3521 $tag .=
"</StyleTemplates>";
3533 $a_preview_html = str_replace(
' width=""',
"", $a_preview_html);
3534 $a_preview_html = str_replace(
' valign="top"',
"", $a_preview_html);
3535 $a_preview_html = str_replace(
'<div class="ilc_text_block_TableContent">',
"<div>", $a_preview_html);
3538 if (strlen($a_preview_html) > 4000) {
3540 $a_preview_html =
"";
3542 $ilDB->manipulate(
"UPDATE style_template SET " .
3543 "preview = " .
$ilDB->quote($a_preview_html,
"text") .
3544 " WHERE id = " .
$ilDB->quote($a_t_id,
"integer"));
3554 $set =
$ilDB->query(
"SELECT preview FROM style_template " .
3555 " WHERE id = " .
$ilDB->quote($a_t_id,
"integer"));
3556 if ($rec =
$ilDB->fetchAssoc($set)) {
3557 return $rec[
"preview"];
3570 $ilDB = $DIC->database();
3572 $set =
$ilDB->query(
"SELECT id FROM style_template " .
3573 " WHERE style_id = " .
$ilDB->quote($a_style_id,
"integer") .
3574 " AND name = " .
$ilDB->quote($a_name,
"text"));
3575 if ($rec =
$ilDB->fetchAssoc($set)) {
3589 $ilDB->manipulate(
"DELETE FROM style_template WHERE " .
3590 " style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
3591 " id = " .
$ilDB->quote($a_t_id,
"integer"));
3594 "DELETE FROM style_template_class WHERE " .
3595 "template_id = " .
$ilDB->quote($a_t_id,
"integer")
3607 "DELETE FROM style_setting WHERE " .
3608 " style_id = " .
$ilDB->quote($this->getId(),
"integer") .
3609 " AND name = " .
$ilDB->quote($a_name,
"text")
3612 $ilDB->manipulate(
"INSERT INTO style_setting " .
3613 "(style_id, name, value) VALUES (" .
3614 $ilDB->quote($this->getId(),
"integer") .
"," .
3615 $ilDB->quote($a_name,
"text") .
"," .
3616 $ilDB->quote($a_value,
"text") .
3627 $set =
$ilDB->query(
3628 "SELECT value FROM style_setting " .
3629 " WHERE style_id = " .
$ilDB->quote($this->getId(),
"integer") .
3630 " AND name = " .
$ilDB->quote($a_name,
"text")
3632 $rec =
$ilDB->fetchAssoc($set);
3634 return $rec[
"value"];
3644 $ilDB = $DIC->database();
3649 "obj_id" => array(
"integer", (
int) $a_obj_id)),
3651 "style_id" => array(
"integer", (
int) $a_style_id))
3662 $ilDB = $DIC->database();
3664 $set =
$ilDB->query(
3665 "SELECT style_id FROM style_usage " .
3666 " WHERE obj_id = " .
$ilDB->quote($a_obj_id,
"integer")
3668 $rec =
$ilDB->fetchAssoc($set);
3671 return (
int) $rec[
"style_id"];
3684 $ilDB = $DIC->database();
3688 $set =
$ilDB->query(
3689 "SELECT DISTINCT obj_id FROM style_usage " .
3690 " WHERE style_id = " .
$ilDB->quote($a_style_id,
"integer")
3693 while ($rec =
$ilDB->fetchAssoc($set)) {
3694 $obj_ids[] = $rec[
"obj_id"];
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _lookupTemplateIdByName($a_style_id, $a_name)
Lookup table template preview.
static _lookupContObjIdByStyleId($a_style_id)
lookup style sheet ID
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 _writeScope($a_id, $a_scope)
Write scope.
static _getTemplateClassTypes($a_template_type="")
Get template class types.
static getContentPrintStyle()
get content print style
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.
static getPlaceHolderStylePath()
get placeholder style path (for Page Layouts)
exportXML($a_dir)
export style xml file to directory
static _HLSToRGB($a_hls)
HLS to RGB (both arrays, 0..255)
static lookupObjectForStyle($a_style_id)
Lookup object style.
static _lookupTemplateName($a_t_id)
Lookup table template name for template ID.
do_3_10_Migration()
Migrates 3.10 style to 3.11 style.
static _getTemplatePreview($a_style, $a_type, $a_t_id, $a_small_mode=false)
Get table template preview.
setCharacteristics($a_chars)
Set characteristics.
getColors()
Get colors of style.
setRefId($a_ref_id)
Set ref id (show error message, since styles do not use ref ids)
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
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
deleteParameter($a_id)
delete style parameter
addTemplate($a_type, $a_name, $a_classes)
Add table template.
static $style_super_types
do_3_9_Migration($a_id)
Migrate old 3.9 styles.
static getBasicZipPath()
Get basic zip path.
getRefId()
Get ref id (show error message, since styles do not use ref ids)
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
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
static _getStandardStyles( $a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
static _deleteStyleAssignments($a_style_id)
delete all style references to style
deleteStyleParOfChar($a_type, $a_class)
Delete style parameters of characteristic.
copyCharacteristic( $a_from_style_id, $a_from_type, $a_from_char, $a_to_char)
Copy characteristic.
deleteCustomStylePars($a_tag, $a_class, $a_type, $a_mq_id=0)
Delete style parameter by tag/class/parameter.
static _lookupUpToDate($a_id)
Looup up to date.
static _getPseudoClasses($tag)
static _getClonableContentStyles()
Get all clonable styles (active standard styles and individual learning module styles with write perm...
writeCSSFile($a_target_file="", $a_image_dir="")
write css file to webspace directory
static _getStyleSuperTypes()
static lookupObjectStyle($a_obj_id)
Lookup object style.
& getMetaData()
get meta data object
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.
static _lookupStandard($a_id)
Lookup standard flag.
handleXmlString($a_str)
Handle xml strin.
static writeStyleUsage($a_obj_id, $a_style_id)
Write style usage.
static _writeActive($a_id, $a_active)
Write active flag.
addColor($a_name, $a_code)
Add color.
getTemplate($a_t_id)
Get template.
addTemplateClass($a_t_id, $a_type, $a_class)
Update table template.
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
foreach($_POST as $key=> $value) $res
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)
writeStyleSetting($a_name, $a_value)
Write Style Setting.
static _getFilteredGroups()
getTemplateXML()
Get table template xml.
static _getCoreStyles()
Get core styles.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
getTitle()
get object title public
uploadImage($a_file)
Upload image.
getDescription()
get object description
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)
saveHideStatus($a_type, $a_char, $a_hide)
Save characteristic hide status.
setStyle($a_style)
set styles
static getSyntaxStylePath()
get syntax style path
static signFile($path_to_file)
static getContentStylePath($a_style_id, $add_random=true)
get content style path
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
getCharacteristics($a_type="", $a_no_hidden=false, $a_include_core=true)
Get characteristics.
getStyleParameterGroups()
Get grouped parameter.
static _lookupType($a_id, $a_reference=false)
lookup object type
__construct($a_id=0, $a_call_by_reference=false)
Constructor public.
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.
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.
update($pash, $contents, Config $config)
getStyle()
todo: bad style! should return array of objects, not multi-dim-arrays
updateStyleParameter($a_id, $a_value)
update style parameter per id
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)
getTemplateClasses($a_tid)
Get template classes.
static _getStyleParameterValues($par)
getMaxMQueryOrderNr()
Get maximum media query order nr.
static _writeStandard($a_id, $a_std)
Write standard flag.
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)
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.
static isCoreStyle($a_type, $a_class)
Is core style.
saveMediaQueryOrder($a_order_nr=null)
Save media query order.
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 _lookupActive($a_id)
Lookup active flag.
static _getStyleParameterInputType($par)
addMediaQuery($a_mquery, $order_nr=0)
Add media query.
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 _getObjectsDataForType($a_type, $a_omit_trash=false)
get all objects of a certain type
static _replaceStylePar($style_id, $a_tag, $a_class, $a_par, $a_val, $a_type, $a_mq_id=0, $a_custom=false)
static _getStyleParameterSubPar($par)
createImagesDirectory()
Create images directory <data_dir>/sty/sty_<id>/images.
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
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.
static _writeUpToDate($a_id, $a_up_to_date)
Write up to date.
lookupTemplatePreview($a_t_id)
Lookup table template preview.
putInTree($a_parent_ref)
Put in tree (show error message, since styles do not use ref ids)
getUpToDate()
Get up to date.