5require_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);
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;
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);
673 $q =
"SELECT uptodate FROM style_data " .
674 " WHERE id = " .
$ilDB->quote($a_id,
"integer");
678 return (
boolean) $sty[
"uptodate"];
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);
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);
720 $q =
"SELECT * FROM style_data " .
721 " WHERE id = " .
$ilDB->quote($a_id,
"integer");
725 return (
boolean) $sty[
"standard"];
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);
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,
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)) {
791 $path =
$tree->getPathId($a_scope);
792 if (!in_array($sty[
"category"], $path)) {
813 $ilAccess =
$DIC->access();
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) {
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)) {
866 self::$basic_style_dom =
new DOMDocument();
867 self::$basic_style_dom->load(self::$basic_style_file);
878 return $this->meta_data;
894 public function create($a_from_style = 0, $a_import_mode =
false)
900 if ($a_from_style == 0) {
901 if (!$a_import_mode) {
908 self::$basic_style_image_dir,
913 $q =
"INSERT INTO style_data (id, uptodate, category) VALUES " .
914 "(" .
$ilDB->quote($this->
getId(),
"integer") .
", 0," .
916 $ilDB->manipulate($q);
922 $q =
"SELECT * FROM style_parameter WHERE style_id = " .
923 $ilDB->quote($a_from_style,
"integer");
924 $par_set =
$ilDB->query($q);
925 while ($par_rec =
$ilDB->fetchAssoc($par_set)) {
926 $def[] = array(
"tag" => $par_rec[
"tag"],
"class" => $par_rec[
"class"],
927 "parameter" => $par_rec[
"parameter"],
"value" => $par_rec[
"value"],
928 "type" => $par_rec[
"type"],
"mq_id" => $par_rec[
"mq_id"],
"custom" => $par_rec[
"custom"]);
933 $q =
"SELECT * FROM style_char WHERE style_id = " .
934 $ilDB->quote($a_from_style,
"integer");
935 $par_set =
$ilDB->query($q);
936 while ($par_rec =
$ilDB->fetchAssoc($par_set)) {
937 $chars[] = array(
"type" => $par_rec[
"type"],
"characteristic" => $par_rec[
"characteristic"]);
943 $mqs = $from_style->getMediaQueries();
944 $mq_mapping = array();
945 foreach ($mqs as $mq) {
947 $mq_mapping[$mq[
"id"]] = $nid;
951 foreach ($def as $sty) {
952 $id =
$ilDB->nextId(
"style_parameter");
953 $q =
"INSERT INTO style_parameter (id, style_id, tag, class, parameter, value, type, mq_id, custom) VALUES " .
955 $ilDB->quote(
$id,
"integer") .
"," .
956 $ilDB->quote($this->
getId(),
"integer") .
"," .
957 $ilDB->quote($sty[
"tag"],
"text") .
"," .
958 $ilDB->quote($sty[
"class"],
"text") .
"," .
959 $ilDB->quote($sty[
"parameter"],
"text") .
"," .
960 $ilDB->quote($sty[
"value"],
"text") .
"," .
961 $ilDB->quote($sty[
"type"],
"text") .
"," .
962 $ilDB->quote((
int) $mq_mapping[$sty[
"mq_id"]],
"integer") .
"," .
963 $ilDB->quote($sty[
"custom"],
"integer") .
965 $ilDB->manipulate($q);
969 foreach ($chars as $char) {
970 $q =
"INSERT INTO style_char (style_id, type, characteristic) VALUES " .
971 "(" .
$ilDB->quote($this->
getId(),
"integer") .
"," .
972 $ilDB->quote($char[
"type"],
"text") .
"," .
973 $ilDB->quote($char[
"characteristic"],
"text") .
")";
974 $ilDB->manipulate($q);
978 $q =
"INSERT INTO style_data (id, uptodate, category) VALUES " .
979 "(" .
$ilDB->quote($this->
getId(),
"integer") .
", 0," .
981 $ilDB->manipulate($q);
986 $from_style->getImagesDirectory(),
987 $this->getImagesDirectory()
991 $colors = $from_style->getColors();
992 foreach ($colors as
$c) {
998 foreach ($tcts as $tct => $v) {
1001 $this->
addTemplate($tct, $t[
"name"], $t[
"classes"]);
1007 if (!$a_import_mode) {
1023 $st =
$ilDB->manipulateF(
1024 "DELETE FROM style_char WHERE style_id = %s AND type = %s AND characteristic = %s",
1025 array(
"integer",
"text",
"text"),
1030 $st =
$ilDB->manipulateF(
1031 "DELETE FROM style_parameter WHERE style_id = %s AND tag = %s AND type = %s AND class = %s",
1032 array(
"integer",
"text",
"text",
"text"),
1048 $set =
$ilDB->queryF(
1049 "SELECT style_id FROM style_char WHERE style_id = %s AND characteristic = %s AND type = %s",
1050 array(
"integer",
"text",
"text"),
1051 array($this->
getId(), $a_char, $a_style_type)
1053 if ($rec =
$ilDB->fetchAssoc($set)) {
1068 "INSERT INTO style_char (style_id, type, characteristic, hide)" .
1069 " VALUES (%s,%s,%s,%s) ",
1070 array(
"integer",
"text",
"text",
"integer"),
1100 $pars = $from_style->getParametersOfClass($a_from_type, $a_from_char);
1103 foreach ($pars as $p => $v) {
1104 if (substr($v, 0, 1) ==
"!") {
1105 $colors[] = substr($v, 1);
1117 foreach ($colors as
$c) {
1119 $this->
addColor($c, $from_style->getColorCodeForName(
$c));
1132 $chars = $this->chars;
1134 if (is_array($this->chars_by_type[
$a_type])) {
1135 foreach ($this->chars_by_type[
$a_type] as
$c) {
1136 if ($a_include_core || !self::isCoreStyle(
$a_type,
$c)) {
1143 foreach ($chars as $k => $char) {
1144 if (
$a_type ==
"" && $this->hidden_chars[$char[
"type"] .
":" . $char[
"class"]]) {
1146 } elseif ($this->hidden_chars[
$a_type .
":" . $char]) {
1160 $this->chars = $a_chars;
1172 "UPDATE style_char SET " .
1173 " hide = " .
$ilDB->quote((
int) $a_hide,
"integer") .
1174 " WHERE style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
1176 " characteristic = " .
$ilDB->quote($a_char,
"text")
1187 $set =
$ilDB->query(
1188 "SELECT hide FROM style_char " .
1189 " WHERE style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
1191 " characteristic = " .
$ilDB->quote($a_char,
"text")
1193 $rec =
$ilDB->fetchAssoc($set);
1195 return $rec[
"hide"];
1208 $lng->loadLanguageModule(
"style");
1211 $new_obj->setTitle($this->
getTitle() .
" (" .
$lng->txt(
"sty_acopy") .
")");
1212 $new_obj->setType($this->
getType());
1214 $new_obj->create($this->
getId());
1216 $new_obj->writeStyleSetting(
1217 "disable_auto_margins",
1221 return $new_obj->getId();
1246 $tag = explode(
".", $a_tag);
1247 $value = $avail_params[$a_par][0];
1248 $id =
$ilDB->nextId(
"style_parameter");
1249 $q =
"INSERT INTO style_parameter (id,style_id, type, tag, class, parameter, value, mq_id, custom) VALUES " .
1251 $ilDB->quote(
$id,
"integer") .
"," .
1252 $ilDB->quote($this->
getId(),
"integer") .
"," .
1254 $ilDB->quote($tag[0],
"text") .
"," .
1255 $ilDB->quote($tag[1],
"text") .
"," .
1256 $ilDB->quote($a_par,
"text") .
"," .
1257 $ilDB->quote($value,
"text") .
"," .
1258 $ilDB->quote($a_mq_id,
"integer") .
"," .
1259 $ilDB->quote($a_custom,
"integer") .
1261 $ilDB->manipulate($q);
1287 if (!is_writable($sty_data_dir)) {
1288 $ilErr->raiseError(
"Style data directory (" . $sty_data_dir
1289 .
") not writeable.",
$ilErr->FATAL);
1292 $style_dir = $sty_data_dir .
"/sty_" . $a_style_id;
1294 if (!@is_dir($style_dir)) {
1295 $ilErr->raiseError(
"Creation of style directory failed (" .
1296 $style_dir .
").",
$ilErr->FATAL);
1300 $im_dir = $style_dir .
"/images";
1302 if (!@is_dir($im_dir)) {
1303 $ilErr->raiseError(
"Creation of Import Directory failed (" .
1304 $im_dir .
").",
$ilErr->FATAL);
1308 $thumb_dir = $style_dir .
"/images/thumbnails";
1310 if (!@is_dir($thumb_dir)) {
1311 $ilErr->raiseError(
"Creation of Import Directory failed (" .
1312 $thumb_dir .
").",
$ilErr->FATAL);
1351 foreach ($entries as $entry) {
1352 if (substr($entry[
"entry"], 0, 1) ==
".") {
1355 if ($entry[
"type"] !=
"dir") {
1371 $a_file[
"tmp_name"],
1405 $q =
"DELETE FROM style_parameter WHERE id = " .
1406 $ilDB->quote($a_id,
"integer");
1423 $q =
"DELETE FROM style_parameter WHERE " .
1424 " style_id = " .
$ilDB->quote($this->
getId(),
"integer") .
" AND " .
1425 " tag = " .
$ilDB->quote($a_tag,
"text") .
" AND " .
1426 " class = " .
$ilDB->quote($a_class,
"text") .
" AND " .
1427 " mq_id = " .
$ilDB->quote($a_mq_id,
"integer") .
" AND " .
1428 " custom = " .
$ilDB->quote($a_custom,
"integer") .
" AND " .
1429 " " .
$ilDB->equals(
"type",
$a_type,
"text",
true) .
" AND " .
1430 " parameter = " .
$ilDB->quote($a_par,
"text");
1432 $ilDB->manipulate($q);
1448 $q =
"DELETE FROM style_parameter WHERE " .
1449 " style_id = " .
$ilDB->quote($this->
getId(),
"integer") .
" AND " .
1450 " tag = " .
$ilDB->quote($a_tag,
"text") .
" AND " .
1451 " class = " .
$ilDB->quote($a_class,
"text") .
" AND " .
1452 " mq_id = " .
$ilDB->quote($a_mq_id,
"integer") .
" AND " .
1453 " custom = " .
$ilDB->quote(1,
"integer") .
" AND " .
1456 $ilDB->manipulate($q);
1471 $q =
"DELETE FROM style_parameter WHERE " .
1472 " style_id = " .
$ilDB->quote($this->
getId(),
"integer") .
" AND " .
1473 " class = " .
$ilDB->quote($a_class,
"text") .
" AND " .
1476 $ilDB->manipulate($q);
1483 public function delete()
1491 $def_style = $this->
ilias->getSetting(
"default_content_style_id");
1492 if ($def_style == $this->
getId()) {
1493 $this->
ilias->deleteSetting(
"default_content_style_id");
1497 $fixed_style = $this->
ilias->getSetting(
"fixed_content_style_id");
1498 if ($fixed_style == $this->
getId()) {
1499 $this->
ilias->deleteSetting(
"fixed_content_style_id");
1503 $q =
"DELETE FROM style_parameter WHERE style_id = " .
1505 $ilDB->manipulate($q);
1509 if (is_file($css_file_name)) {
1510 unlink($css_file_name);
1515 "DELETE FROM sty_media_query WHERE " .
1516 " style_id = " .
$ilDB->quote($this->getId(),
"integer")
1520 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
1524 $q =
"DELETE FROM style_data WHERE id = " .
1526 $ilDB->manipulate($q);
1539 $q =
"SELECT * FROM style_parameter WHERE style_id = " .
1540 $ilDB->quote($this->
getId(),
"integer") .
" ORDER BY tag, class, type, mq_id ";
1541 $style_set =
$ilDB->query($q);
1546 $this->style = array();
1550 $this->end_styles = array();
1551 while ($style_rec =
$ilDB->fetchAssoc($style_set)) {
1552 if ($style_rec[
"tag"] != $ctag || $style_rec[
"class"] != $cclass
1553 || $style_rec[
"type"] != $ctype || $style_rec[
"mq_id"] != $cmq_id) {
1555 if (is_array($tag)) {
1556 if (in_array($ctype, array(
"ha_iheada",
"va_iheada"))) {
1557 $this->end_styles[] = $tag;
1559 $this->style[] = $tag;
1564 $ctag = $style_rec[
"tag"];
1565 $cclass = $style_rec[
"class"];
1566 $ctype = $style_rec[
"type"];
1567 $cmq_id = $style_rec[
"mq_id"];
1568 $tag[] = $style_rec;
1570 $this->style_class[$ctype][$cclass][$cmq_id][$style_rec[
"parameter"]] = $style_rec[
"value"];
1572 if (is_array($tag)) {
1573 $this->style[] = $tag;
1575 foreach ($this->end_styles as $s) {
1576 $this->style[] = $s;
1579 $q =
"SELECT * FROM style_data WHERE id = " .
1587 $this->chars = array();
1588 $this->chars_by_type = array();
1589 $q =
"SELECT * FROM style_char WHERE style_id = " .
1591 " ORDER BY type ASC, characteristic ASC";
1592 $par_set =
$ilDB->query($q);
1593 while ($par_rec =
$ilDB->fetchAssoc($par_set)) {
1594 $this->chars[] = array(
"type" => $par_rec[
"type"],
"class" => $par_rec[
"characteristic"],
"hide" => $par_rec[
"hide"]);
1595 $this->chars_by_type[$par_rec[
"type"]][] = $par_rec[
"characteristic"];
1596 if ($par_rec[
"hide"]) {
1597 $this->hidden_chars[$par_rec[
"type"] .
":" . $par_rec[
"characteristic"]] =
true;
1614 if ($a_target_file ==
"") {
1617 $css_file_name = $a_target_file;
1619 $css_file = fopen($css_file_name,
"w");
1621 $page_background =
"";
1623 $mqs = array(array(
"mquery" =>
"",
"id" => 0));
1629 foreach ($mqs as $mq) {
1630 if ($mq[
"id"] > 0) {
1631 fwrite($css_file,
"@media " . $mq[
"mquery"] .
" {\n");
1634 foreach (
$style as $tag) {
1635 if ($tag[0][
"mq_id"] != $mq[
"id"]) {
1638 fwrite($css_file, $tag[0][
"tag"] .
".ilc_" . $tag[0][
"type"] .
"_" . $tag[0][
"class"] .
"\n");
1641 if ($tag[0][
"tag"] ==
"td") {
1642 fwrite($css_file,
",th" .
".ilc_" . $tag[0][
"type"] .
"_" . $tag[0][
"class"] .
"\n");
1644 if (in_array($tag[0][
"tag"], array(
"h1",
"h2",
"h3"))) {
1645 fwrite($css_file,
",div.ilc_text_block_" . $tag[0][
"class"] .
"\n");
1646 fwrite($css_file,
",body.ilc_text_block_" . $tag[0][
"class"] .
"\n");
1648 if ($tag[0][
"type"] ==
"section") {
1649 fwrite($css_file,
",a.ilc_" . $tag[0][
"type"] .
"_" . $tag[0][
"class"] .
"\n");
1651 if ($tag[0][
"type"] ==
"text_block") {
1652 fwrite($css_file,
",body.ilc_text_block_" . $tag[0][
"class"] .
"\n");
1654 fwrite($css_file,
"{\n");
1657 $t_border = array();
1659 foreach ($tag as $par) {
1660 $cur_par = $par[
"parameter"];
1661 $cur_val = $par[
"value"];
1664 if (is_int(strpos($cur_par,
"color")) && substr(trim($cur_val), 0, 1) ==
"!") {
1668 if ($tag[0][
"type"] ==
"table" && is_int(strpos($par[
"parameter"],
"border"))) {
1669 $t_border[$cur_par] = $cur_val;
1672 if (in_array($cur_par, array(
"background-image",
"list-style-image"))) {
1673 if (is_int(strpos($cur_val,
"/"))) {
1674 $cur_val =
"url(" . $cur_val .
")";
1676 if ($a_image_dir ==
"") {
1677 $cur_val =
"url(../sty/sty_" . $this->
getId() .
"/images/" . $cur_val .
")";
1679 $cur_val =
"url(" . $a_image_dir .
"/" . $cur_val .
")";
1684 if ($cur_par ==
"opacity") {
1685 $cur_val = ((int) $cur_val) / 100;
1688 fwrite($css_file,
"\t" . $cur_par .
": " . $cur_val .
";\n");
1691 if ($cur_par ==
"min-height") {
1692 fwrite($css_file,
"\t" .
"height" .
": " .
"auto !important" .
";\n");
1693 fwrite($css_file,
"\t" .
"height" .
": " . $cur_val .
";\n");
1697 if ($cur_par ==
"opacity") {
1698 fwrite($css_file,
"\t" .
'-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=' . ($cur_val * 100) .
')"' .
";\n");
1699 fwrite($css_file,
"\t" .
'filter: alpha(opacity=' . ($cur_val * 100) .
')' .
";\n");
1700 fwrite($css_file,
"\t" .
'-moz-opacity: ' . $cur_val .
";\n");
1704 if ($cur_par ==
"transform") {
1705 fwrite($css_file,
"\t" .
'-webkit-transform: ' . $cur_val .
";\n");
1706 fwrite($css_file,
"\t" .
'-moz-transform: ' . $cur_val .
";\n");
1707 fwrite($css_file,
"\t" .
'-ms-transform: ' . $cur_val .
";\n");
1711 if ($cur_par ==
"transform-origin") {
1712 fwrite($css_file,
"\t" .
'-webkit-transform-origin: ' . $cur_val .
";\n");
1713 fwrite($css_file,
"\t" .
'-moz-transform-origin: ' . $cur_val .
";\n");
1714 fwrite($css_file,
"\t" .
'-ms-transform-origin: ' . $cur_val .
";\n");
1718 if ($tag[0][
"tag"] ==
"div" && $tag[0][
"class"] ==
"Page"
1719 && $cur_par ==
"background-color") {
1720 $page_background = $cur_val;
1723 fwrite($css_file,
"}\n");
1724 fwrite($css_file,
"\n");
1744 if ($page_background !=
"") {
1745 fwrite($css_file,
"td.ilc_Page\n");
1746 fwrite($css_file,
"{\n");
1747 fwrite($css_file,
"\t" .
"background-color: " . $page_background .
";\n");
1748 fwrite($css_file,
"}\n");
1750 if ($mq[
"id"] > 0) {
1751 fwrite($css_file,
"}\n");
1773 $fixed_style =
$ilSetting->get(
"fixed_content_style_id");
1774 if ($fixed_style > 0) {
1775 $a_style_id = $fixed_style;
1779 if ($a_style_id <= 0) {
1780 $a_style_id =
$ilSetting->get(
"default_content_style_id");
1798 if (is_array($this->style_class[
$a_type][$a_class][$a_mq_id])) {
1799 return $this->style_class[
$a_type][$a_class][$a_mq_id];
1815 $random = new \ilRandom();
1816 $rand = $random->int(1, 999999);
1820 $fixed_style =
$ilSetting->get(
"fixed_content_style_id");
1821 if ($fixed_style > 0) {
1822 $a_style_id = $fixed_style;
1826 if ($a_style_id <= 0) {
1827 $a_style_id =
$ilSetting->get(
"default_content_style_id");
1839 $path .=
"?dummy=$rand";
1842 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);
1928 $q =
"SELECT * FROM style_parameter WHERE " .
1929 " style_id = " .
$ilDB->quote($style_id,
"integer") .
" AND " .
1930 " tag = " .
$ilDB->quote($a_tag,
"text") .
" AND " .
1931 " class = " .
$ilDB->quote($a_class,
"text") .
" AND " .
1932 " mq_id = " .
$ilDB->quote($a_mq_id,
"integer") .
" AND " .
1933 " custom = " .
$ilDB->quote($a_custom,
"integer") .
" AND " .
1934 " " .
$ilDB->equals(
"type",
$a_type,
"text",
true) .
" AND " .
1935 " parameter = " .
$ilDB->quote($a_par,
"text");
1937 $set =
$ilDB->query($q);
1939 if ($rec = $set->fetchRow()) {
1940 $q =
"UPDATE style_parameter SET " .
1941 " value = " .
$ilDB->quote($a_val,
"text") .
" WHERE " .
1942 " style_id = " .
$ilDB->quote($style_id,
"integer") .
" AND " .
1943 " tag = " .
$ilDB->quote($a_tag,
"text") .
" AND " .
1944 " class = " .
$ilDB->quote($a_class,
"text") .
" AND " .
1945 " mq_id = " .
$ilDB->quote($a_mq_id,
"integer") .
" AND " .
1946 " custom = " .
$ilDB->quote($a_custom,
"integer") .
" AND " .
1947 " " .
$ilDB->equals(
"type",
$a_type,
"text",
true) .
" AND " .
1948 " parameter = " .
$ilDB->quote($a_par,
"text");
1950 $ilDB->manipulate($q);
1952 $id =
$ilDB->nextId(
"style_parameter");
1953 $q =
"INSERT INTO style_parameter (id, value, style_id, tag, class, type, parameter, mq_id, custom) VALUES " .
1955 $ilDB->quote(
$id,
"integer") .
"," .
1956 $ilDB->quote($a_val,
"text") .
"," .
1957 " " .
$ilDB->quote($style_id,
"integer") .
"," .
1958 " " .
$ilDB->quote($a_tag,
"text") .
"," .
1959 " " .
$ilDB->quote($a_class,
"text") .
"," .
1961 " " .
$ilDB->quote($a_par,
"text") .
"," .
1962 " " .
$ilDB->quote($a_mq_id,
"integer") .
"," .
1963 " " .
$ilDB->quote($a_custom,
"integer") .
1966 $ilDB->manipulate($q);
1984 $this->style = $a_style;
1996 return str_replace(
"&",
"&", $a_str);
2005 $xml .=
"<StyleSheet>\n";
2012 foreach ($this->chars as $char) {
2014 "\" Type=\"" . $char[
"type"] .
"\" Class=\"" . $char[
"class"] .
"\">\n";
2015 foreach ($this->style as
$style) {
2016 if (
$style[0][
"type"] == $char[
"type"] &&
$style[0][
"class"] == $char[
"class"]) {
2017 foreach (
$style as $tag) {
2018 $xml .=
"<StyleParameter Name=\"" . $tag[
"parameter"] .
"\" Value=\"" . $tag[
"value"] .
"\" Custom=\"" . $tag[
"custom"] .
"\" />\n";
2022 $xml .=
"</Style>\n";
2026 foreach ($this->
getColors() as $color) {
2027 $xml .=
"<StyleColor Name=\"" . $color[
"name"] .
"\" Code=\"" . $color[
"code"] .
"\"/>\n";
2032 foreach ($tcts as $tct => $v) {
2035 foreach ($ts as $t) {
2036 $xml .=
"<StyleTemplate Type=\"" . $tct .
"\" Name=\"" . $t[
"name"] .
"\">\n";
2037 foreach ($t[
"classes"] as $ct =>
$c) {
2039 $xml .=
"<StyleTemplateClass ClassType=\"" . $ct .
"\" Class=\"" .
$c .
"\"/>\n";
2042 $xml .=
"</StyleTemplate>\n";
2047 $xml .=
"</StyleSheet>";
2060 if (!is_writable($sty_data_dir)) {
2061 $this->
ilias->raiseError(
"Style data directory (" . $sty_data_dir
2062 .
") not writeable.", $this->
ilias->error_obj->FATAL);
2065 $style_dir = $sty_data_dir .
"/sty_" . $this->
getId();
2067 if (!@is_dir($style_dir)) {
2068 $this->
ilias->raiseError(
"Creation of style directory failed (" .
2069 $style_dir .
").", $this->
ilias->error_obj->FATAL);
2073 $ex_dir = $style_dir .
"/export";
2075 if (!@is_dir($ex_dir)) {
2076 $this->
ilias->raiseError(
"Creation of Import Directory failed (" .
2077 $ex_dir .
").", $this->
ilias->error_obj->FATAL);
2089 $style_dir = $sty_data_dir .
"/sty_" . $this->
getId();
2091 $ex_dir = $style_dir .
"/export";
2093 if (is_dir($ex_dir)) {
2107 if (!is_writable($ex_sub_dir)) {
2108 $this->
ilias->raiseError(
"Style data directory (" . $ex_sub_dir
2109 .
") not writeable.", $this->
ilias->error_obj->FATAL);
2111 $ex_sub_images_dir = $ex_sub_dir .
"/images";
2113 if (!is_writable($ex_sub_images_dir)) {
2114 $this->
ilias->raiseError(
"Style data directory (" . $ex_sub_images_dir
2115 .
") not writeable.", $this->
ilias->error_obj->FATAL);
2124 $this->export_sub_dir = $a_dir;
2132 if ($this->export_sub_dir ==
"") {
2133 return "sty_" . $this->
getId();
2135 return $this->export_sub_dir;
2171 $file = $a_dir .
"/style.xml";
2174 if (!($fp = @fopen($file,
"w"))) {
2175 die(
"<b>Error</b>: Could not open \"" . $file .
"\" for writing" .
2176 " in <b>" . __FILE__ .
"</b> on line <b>" . __LINE__ .
"</b><br />");
2183 fwrite($fp, $this->
getXML());
2196 if (!is_writable($sty_data_dir)) {
2197 $this->
ilias->raiseError(
"Style data directory (" . $sty_data_dir
2198 .
") not writeable.", $this->
ilias->error_obj->FATAL);
2201 $style_dir = $sty_data_dir .
"/sty_" . $this->
getId();
2203 if (!@is_dir($style_dir)) {
2204 $this->
ilias->raiseError(
"Creation of style directory failed (" .
2205 $style_dir .
").", $this->
ilias->error_obj->FATAL);
2209 $im_dir = $style_dir .
"/import";
2211 if (!@is_dir($im_dir)) {
2212 $this->
ilias->raiseError(
"Creation of Import Directory failed (" .
2213 $im_dir .
").", $this->
ilias->error_obj->FATAL);
2222 public function import($a_file)
2229 if (is_array($a_file)) {
2231 $a_file[
"tmp_name"],
2233 $im_dir .
"/" . $a_file[
"name"]
2235 $file_name = $a_file[
"name"];
2237 $pi = pathinfo($a_file);
2238 $file_name = $pi[
"basename"];
2239 copy($a_file, $im_dir .
"/" . $file_name);
2241 $file = pathinfo($file_name);
2244 if (strtolower($file[
"extension"] ==
"zip")) {
2246 $subdir = basename($file[
"basename"],
"." . $file[
"extension"]);
2247 if (!is_dir($im_dir .
"/" . $subdir)) {
2250 $xml_file = $im_dir .
"/" . $subdir .
"/style.xml";
2252 $xml_file = $im_dir .
"/" . $file_name;
2261 if (is_dir($im_dir .
"/" . $subdir .
"/images")) {
2263 $im_dir .
"/" . $subdir .
"/images",
2281 $this->is_3_10_skin =
false;
2283 if (!$a_skip_parent_create) {
2286 include_once(
"./Services/Style/Content/classes/class.ilStyleImportParser.php");
2288 $importParser->startParsing();
2291 foreach ($this->style as
$style) {
2292 foreach (
$style as $tag) {
2293 $id =
$ilDB->nextId(
"style_parameter");
2296 if (in_array($tag[
"class"], array(
"PageFrame",
"PageContainer")) &&
2297 $tag[
"tag"] ==
"table") {
2298 $tag[
"tag"] =
"div";
2299 if ($tag[
"parameter"] ==
"width" && $tag[
"value"] ==
"100%") {
2304 $q =
"INSERT INTO style_parameter (id,style_id, tag, class, parameter, type, value, custom) VALUES " .
2306 $ilDB->quote(
$id,
"integer") .
"," .
2307 $ilDB->quote($this->
getId(),
"integer") .
"," .
2308 $ilDB->quote($tag[
"tag"],
"text") .
"," .
2309 $ilDB->quote($tag[
"class"],
"text") .
"," .
2310 $ilDB->quote($tag[
"parameter"],
"text") .
"," .
2311 $ilDB->quote($tag[
"type"],
"text") .
"," .
2312 $ilDB->quote($tag[
"value"],
"text") .
"," .
2313 $ilDB->quote((
bool) $tag[
"custom"],
"integer") .
2315 $ilDB->manipulate($q);
2320 $this->is_3_10_skin =
true;
2321 if (is_array($this->chars)) {
2322 foreach ($this->chars as $char) {
2323 if ($char[
"type"] !=
"") {
2324 $s = substr($char[
"class"], strlen($char[
"class"]) - 6);
2325 if ($s !=
":hover") {
2329 "style_id" => array(
"integer", $this->
getId()),
2330 "type" => array(
"text", $char[
"type"]),
2331 "characteristic" => array(
"text", $char[
"class"])),
2332 array(
"hide" => array(
"integer", 0))
2340 $this->is_3_10_skin =
false;
2347 $q =
"INSERT INTO style_data (id, uptodate) VALUES " .
2348 "(" .
$ilDB->quote($this->
getId(),
"integer") .
", 0)";
2349 $ilDB->manipulate($q);
2354 if ($this->is_3_10_skin) {
2367 foreach (self::$parameter as
$parameter => $props) {
2375 $input = self::$parameter[$par][
"input"];
2381 $subpar = self::$parameter[$par][
"subpar"];
2391 foreach (self::$parameter as $k => $v) {
2392 if (is_array(self::$filtered_groups[$v[
"group"]]) &&
2393 !in_array($a_tag, self::$filtered_groups[$v[
"group"]])) {
2408 if ($a_no_percentage) {
2416 return self::$parameter[$par][
"values"];
2431 return in_array(
$a_type, self::$expandable_types);
2436 return in_array(
$a_type, self::$hideable_types);
2441 foreach (self::$style_super_types as $s => $t) {
2456 $c_styles = array();
2457 foreach (self::$core_styles as $cstyle) {
2459 = array(
"type" => $cstyle[
"type"],
2461 "class" => $cstyle[
"class"]);
2474 foreach (self::$core_styles as $s) {
2475 if ($s[
"type"] ==
$a_type && $s[
"class"] == $a_class) {
2488 if ($a_template_type ==
"") {
2492 return self::$templates[$a_template_type];
2498 return self::$pseudo_classes[$tag];
2503 return self::$templates[$t][$k];
2508 return self::$assigned_tags[
$a_type];
2517 foreach (self::$parameter as $p => $v) {
2518 $pars[$p] = $v[
"values"];
2530 $styles = array(array(
"id" => $a_id));
2544 if ($a_styles ==
"") {
2547 $styles = $a_styles;
2553 $core_images = array();
2555 if (is_dir($core_dir)) {
2556 $dir = opendir($core_dir);
2557 while ($file = readdir($dir)) {
2558 if (substr($file, 0, 1) !=
"." && is_file($core_dir .
"/" . $file)) {
2559 $core_images[] = $file;
2564 foreach ($styles as
$style) {
2569 $set =
$ilDB->queryF(
2570 "SELECT * FROM style_char WHERE style_id = %s " .
2571 "AND type = %s AND characteristic = %s",
2572 array(
"integer",
"text",
"text"),
2573 array(
$id, $cs[
"type"], $cs[
"class"])
2577 if (!($rec =
$ilDB->fetchAssoc($set))) {
2579 "INSERT INTO style_char (style_id, type, characteristic) " .
2580 " VALUES (%s,%s,%s) ",
2581 array(
"integer",
"text",
"text"),
2582 array(
$id, $cs[
"type"], $cs[
"class"])
2585 $xpath =
new DOMXPath($bdom);
2586 $par_nodes = $xpath->query(
"/StyleSheet/Style[@Tag = '" . $cs[
"tag"] .
"' and @Type='" .
2587 $cs[
"type"] .
"' and @Class='" . $cs[
"class"] .
"']/StyleParameter");
2588 foreach ($par_nodes as $par_node) {
2590 $set =
$ilDB->queryF(
2591 "SELECT * FROM style_parameter WHERE style_id = %s " .
2592 "AND type = %s AND class = %s AND tag = %s AND parameter = %s",
2593 array(
"integer",
"text",
"text",
"text",
"text"),
2594 array(
$id, $cs[
"type"], $cs[
"class"],
2595 $cs[
"tag"], $par_node->getAttribute(
"Name"))
2599 if (!($rec =
$ilDB->fetchAssoc($set))) {
2600 $spid =
$ilDB->nextId(
"style_parameter");
2601 $st =
$ilDB->manipulateF(
2602 "INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value) " .
2603 " VALUES (%s,%s,%s,%s,%s,%s,%s)",
2604 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2605 array($spid,
$id, $cs[
"type"], $cs[
"class"], $cs[
"tag"],
2606 $par_node->getAttribute(
"Name"), $par_node->getAttribute(
"Value"))
2616 reset($core_images);
2617 foreach ($core_images as $cim) {
2618 if (!is_file($imdir .
"/" . $cim)) {
2619 copy($core_dir .
"/" . $cim, $imdir .
"/" . $cim);
2644 $st =
$ilDB->prepareManip(
"UPDATE style_char SET type = ? WHERE characteristic = ?" .
2645 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2646 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2647 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2648 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2649 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2650 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2651 $ilDB->execute($st, array(
"page_cont",
"Page", $this->
getId()));
2654 $st =
$ilDB->prepareManip(
"UPDATE style_parameter SET type = ? WHERE class = ?" .
2655 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2656 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2657 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2658 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2659 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2660 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2661 $ilDB->execute($st, array(
"table",
"Page", $this->
getId()));
2663 $st =
$ilDB->prepareManip(
"UPDATE style_parameter SET tag = ? WHERE class = ?" .
2664 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2665 $ilDB->execute($st, array(
"div",
"MediaCaption", $this->
getId()));
2668 $st =
$ilDB->prepareManip(
"UPDATE style_char SET characteristic = ? WHERE characteristic = ?" .
2669 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2670 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2671 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2674 $st =
$ilDB->prepareManip(
"UPDATE style_parameter SET class = ? WHERE class = ?" .
2675 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2676 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2677 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2680 $st =
$ilDB->prepareManip(
"DELETE FROM style_char WHERE type = ?" .
2681 " AND style_id = ? ", array(
"text",
"integer"));
2682 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2683 $st =
$ilDB->prepareManip(
"DELETE FROM style_parameter WHERE type = ?" .
2684 " AND style_id = ? ", array(
"text",
"integer"));
2685 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2700 $add_str =
" AND style_id = " .
$ilDB->quote($a_id,
"integer");
2703 $set =
$ilDB->query($q =
"SELECT DISTINCT style_id, tag, class FROM style_parameter WHERE " .
2704 $ilDB->equals(
"type",
"",
"text",
true) .
" " . $add_str);
2706 while ($rec =
$ilDB->fetchAssoc($set)) {
2709 switch ($rec[
"tag"]) {
2712 if (in_array($rec[
"class"], array(
"Headline3",
"Headline1",
2713 "Headline2",
"TableContent",
"List",
"Standard",
"Remark",
2714 "Additional",
"Mnemonic",
"Citation",
"Example"))) {
2715 $types[] =
"text_block";
2717 if (in_array($rec[
"class"], array(
"Block",
"Remark",
2718 "Additional",
"Mnemonic",
"Example",
"Excursus",
"Special"))) {
2719 $types[] =
"section";
2721 if (in_array($rec[
"class"], array(
"Page",
"Footnote",
"PageTitle",
"LMNavigation"))) {
2727 $types[] =
"table_cell";
2731 if (in_array($rec[
"class"], array(
"ExtLink",
"IntLink",
"FootnoteLink"))) {
2737 $types[] =
"text_inline";
2746 foreach ($types as $t) {
2748 $set4 =
$ilDB->queryF(
2749 "SELECT * FROM style_char " .
2750 " WHERE style_id = %s AND type = %s AND characteristic = %s",
2751 array(
"integer",
"text",
"text"),
2752 array($rec[
"style_id"], $t, $rec[
"class"])
2754 if ($rec4 =
$ilDB->fetchAssoc($set4)) {
2759 "INSERT INTO style_char " .
2760 " (style_id, type, characteristic) VALUES " .
2762 array(
"integer",
"text",
"text"),
2763 array($rec[
"style_id"], $t, $rec[
"class"])
2769 if ($rec[
"type"] ==
"") {
2770 if (count($types) > 0) {
2772 "UPDATE style_parameter SET type = %s " .
2773 " WHERE style_id = %s AND class = %s AND " .
$ilDB->equals(
"type",
"",
"text",
true),
2774 array(
"text",
"integer",
"text"),
2775 array($types[0], $rec[
"style_id"], $rec[
"class"])
2780 if ($types[0] ==
"link") {
2782 "UPDATE style_parameter SET type = %s " .
2783 " WHERE style_id = %s AND (class = %s OR class = %s) AND " .
$ilDB->equals(
"type",
"",
"text",
true),
2784 array(
"text",
"integer",
"text",
"text"),
2785 array($types[0], $rec[
"style_id"], $rec[
"class"] .
":visited",
2786 $rec[
"class"] .
":hover")
2791 if (count($types) == 2) {
2794 $set2 =
$ilDB->queryF(
2795 "SELECT * FROM style_parameter " .
2796 " WHERE style_id = %s AND class = %s AND type = %s",
2797 array(
"integer",
"text",
"text"),
2798 array($rec[
"style_id"], $rec[
"class"], $types[0])
2800 while ($rec2 =
$ilDB->fetchAssoc($set2)) {
2802 $set3 =
$ilDB->queryF(
2803 "SELECT * FROM style_parameter " .
2804 " WHERE style_id = %s AND tag = %s AND class = %s AND type = %s AND parameter = %s",
2805 array(
"integer",
"text",
"text",
"text",
"text"),
2806 array($rec[
"style_id"], $rec[
"tag"], $rec[
"class"], $types[1], $rec[
"parameter"])
2808 if ($rec3 =
$ilDB->fetchAssoc($set3)) {
2811 $nid =
$ilDB->nextId(
"style_parameter");
2813 "INSERT INTO style_parameter " .
2814 " (id, style_id, tag, class, parameter, value, type) VALUES " .
2815 " (%s, %s,%s,%s,%s,%s,%s) ",
2816 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2817 array($nid, $rec2[
"style_id"], $rec2[
"tag"], $rec2[
"class"],
2818 $rec2[
"parameter"], $rec2[
"value"], $types[1])
2834 $classes = array(
"Example",
"Additional",
"Citation",
"Mnemonic",
"Remark");
2835 $pars = array(
"margin-top",
"margin-bottom");
2837 foreach ($classes as $curr_class) {
2838 foreach ($pars as $curr_par) {
2839 $res2 =
$ilDB->queryF(
2840 "SELECT id FROM style_parameter WHERE style_id = %s" .
2841 " AND tag = %s AND class= %s AND parameter = %s",
2842 array(
"integer",
"text",
"text",
"text"),
2843 array($a_id,
"p", $curr_class, $curr_par)
2845 if ($row2 =
$ilDB->fetchAssoc($res2)) {
2847 "UPDATE style_parameter SET value= %s WHERE id = %s",
2848 array(
"text",
"integer"),
2849 array(
"10px", $row2[
"id"])
2852 $nid =
$ilDB->nextId(
"style_parameter");
2854 "INSERT INTO style_parameter " .
2855 "(id, style_id, tag, class, parameter,value) VALUES (%s,%s,%s,%s,%s,%s)",
2856 array(
"integer",
"integer",
"text",
"text",
"text",
"text"),
2857 array($nid, $a_id,
"div", $curr_class, $curr_par,
"10px")
2864 "UPDATE style_parameter SET tag = %s WHERE tag = %s and style_id = %s",
2865 array(
"text",
"text",
"integer"),
2866 array(
"div",
"p", $a_id)
2881 $set =
$ilDB->query(
"SELECT * FROM style_color WHERE " .
2882 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" " .
2883 "ORDER BY color_name");
2886 while ($rec =
$ilDB->fetchAssoc($set)) {
2888 "name" => $rec[
"color_name"],
2889 "code" => $rec[
"color_code"]
2903 $ilDB->manipulate(
"INSERT INTO style_color (style_id, color_name, color_code)" .
2905 $ilDB->quote($this->getId(),
"integer") .
"," .
2906 $ilDB->quote($a_name,
"text") .
"," .
2907 $ilDB->quote($a_code,
"text") .
2920 $ilDB->manipulate(
"UPDATE style_color SET " .
2921 "color_name = " .
$ilDB->quote($a_new_name,
"text") .
", " .
2922 "color_code = " .
$ilDB->quote($a_code,
"text") .
2923 " WHERE style_id = " .
$ilDB->quote($this->getId(),
"integer") .
2924 " AND color_name = " .
$ilDB->quote($a_name,
"text"));
2928 if ($a_name != $a_new_name) {
2929 $set =
$ilDB->query(
"SELECT * FROM style_parameter " .
2930 " WHERE style_id = " .
$ilDB->quote($this->getId(),
"integer") .
2932 " parameter = " .
$ilDB->quote(
"background-color",
"text") .
" OR " .
2933 " parameter = " .
$ilDB->quote(
"color",
"text") .
" OR " .
2934 " parameter = " .
$ilDB->quote(
"border-color",
"text") .
" OR " .
2935 " parameter = " .
$ilDB->quote(
"border-top-color",
"text") .
" OR " .
2936 " parameter = " .
$ilDB->quote(
"border-bottom-color",
"text") .
" OR " .
2937 " parameter = " .
$ilDB->quote(
"border-left-color",
"text") .
" OR " .
2938 " parameter = " .
$ilDB->quote(
"border-right-color",
"text") .
2940 while ($rec =
$ilDB->fetchAssoc($set)) {
2941 if ($rec[
"value"] ==
"!" . $a_name ||
2942 is_int(strpos($rec[
"value"],
"!" . $a_name .
"("))) {
2948 str_replace($a_name, $a_new_name, $rec[
"value"]),
2965 $ilDB->manipulate(
"DELETE FROM style_color WHERE " .
2966 " style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
2967 " color_name = " .
$ilDB->quote($a_name,
"text"));
2977 $set =
$ilDB->query(
"SELECT * FROM style_color WHERE " .
2978 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
2979 "color_name = " .
$ilDB->quote($a_color_name,
"text"));
2980 if ($rec =
$ilDB->fetchAssoc($set)) {
2993 $pos = strpos($a_name,
"(");
2995 $a_i = substr($a_name, $pos + 1);
2996 $a_i = str_replace(
")",
"", $a_i);
2997 $a_name = substr($a_name, 0, $pos);
3000 $set =
$ilDB->query(
"SELECT color_code FROM style_color WHERE " .
3001 " style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
3002 " color_name = " .
$ilDB->quote($a_name,
"text"));
3003 if ($rec =
$ilDB->fetchAssoc($set)) {
3005 return "#" . $rec[
"color_code"];
3024 $hls[
"l"] = $hls[
"l"] + ((255 - $hls[
"l"]) * ($a_i / 100));
3027 $hls[
"l"] = $hls[
"l"] - (($hls[
"l"]) * (-$a_i / 100));
3032 foreach ($rgb as $k => $v) {
3033 $rgb[$k] = str_pad(dechex($v), 2,
"0", STR_PAD_LEFT);
3036 return $rgb[
"r"] . $rgb[
"g"] . $rgb[
"b"];
3044 $r[
"r"] = substr($a_rgb, 0, 2);
3045 $r[
"g"] = substr($a_rgb, 2, 2);
3046 $r[
"b"] = substr($a_rgb, 4, 2);
3049 $r[
"r"] = (int) hexdec($r[
"r"]);
3050 $r[
"g"] = (int) hexdec($r[
"g"]);
3051 $r[
"b"] = (int) hexdec($r[
"b"]);
3062 $r = $a_rgb[
"r"] / 255;
3063 $g = $a_rgb[
"g"] / 255;
3064 $b = $a_rgb[
"b"] / 255;
3067 $max = max($r, $g,
$b);
3068 $min = min($r, $g,
$b);
3071 $l = ($max + $min) / 2;
3078 $s = ($max - $min) / ($max + $min);
3080 $s = ($max - $min) / (2.0 - $max - $min);
3084 $h = ($g -
$b) / ($max - $min);
3085 } elseif ($g == $max) {
3086 $h = 2.0 + (
$b - $r) / ($max - $min);
3087 } elseif (
$b == $max) {
3088 $h = 4.0 + ($r - $g) / ($max - $min);
3092 $hls[
"h"] = round(($h / 6) * 255);
3093 $hls[
"l"] = round($l * 255);
3094 $hls[
"s"] = round($s * 255);
3104 $h = $a_hls[
"h"] / 255;
3105 $l = $a_hls[
"l"] / 255;
3106 $s = $a_hls[
"s"] / 255;
3108 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = 0;
3112 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = $l;
3115 $temp2 = $l * (1.0 + $s);
3117 $temp2 = $l + $s - $l * $s;
3120 $temp1 = 2.0 * $l - $temp2;
3123 # For each of R, G, B, compute another temporary value, temp3, as follows:
3124 foreach ($rgb as $k => $v) {
3127 $temp3 = $h + 1.0 / 3.0;
3135 $temp3 = $h - 1.0 / 3.0;
3139 $temp3 = $temp3 + 1.0;
3142 $temp3 = $temp3 - 1.0;
3145 if (6.0 * $temp3 < 1) {
3146 $rgb[$k] = $temp1 + ($temp2 - $temp1) * 6.0 * $temp3;
3147 } elseif (2.0 * $temp3 < 1) {
3149 } elseif (3.0 * $temp3 < 2) {
3150 $rgb[$k] = $temp1 + ($temp2 - $temp1) * ((2.0 / 3.0) - $temp3) * 6.0;
3157 $rgb[
"r"] = round($rgb[
"r"] * 255);
3158 $rgb[
"g"] = round($rgb[
"g"] * 255);
3159 $rgb[
"b"] = round($rgb[
"b"] * 255);
3179 $set =
$ilDB->query(
"SELECT * FROM sty_media_query WHERE " .
3180 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" " .
3181 "ORDER BY order_nr");
3184 while ($rec =
$ilDB->fetchAssoc($set)) {
3199 $id =
$ilDB->nextId(
"sty_media_query");
3200 if ($order_nr == 0) {
3204 $ilDB->manipulate(
"INSERT INTO sty_media_query (id, style_id, mquery, order_nr)" .
3206 $ilDB->quote(
$id,
"integer") .
"," .
3207 $ilDB->quote($this->getId(),
"integer") .
"," .
3208 $ilDB->quote($a_mquery,
"text") .
"," .
3209 $ilDB->quote($order_nr,
"integer") .
3223 $set =
$ilDB->query(
3224 "SELECT max(order_nr) mnr FROM sty_media_query " .
3225 " WHERE style_id = " .
$ilDB->quote($this->getId(),
"integer")
3227 $rec =
$ilDB->fetchAssoc($set);
3229 return (
int) $rec[
"mnr"];
3243 "UPDATE sty_media_query SET " .
3244 " mquery = " .
$ilDB->quote($a_mquery,
"text") .
3245 " WHERE id = " .
$ilDB->quote($a_id,
"integer")
3259 $set =
$ilDB->query(
3260 "SELECT * FROM sty_media_query " .
3261 " WHERE id = " .
$ilDB->quote($a_id,
"integer")
3263 return $ilDB->fetchAssoc($set);
3276 "DELETE FROM sty_media_query WHERE " .
3277 " style_id = " .
$ilDB->quote($this->getId(),
"integer") .
3278 " AND id = " .
$ilDB->quote($a_id,
"integer")
3293 if (is_array($a_order_nr)) {
3294 foreach ($mqueries as $k => $mq) {
3295 $mqueries[$k][
"order_nr"] = $a_order_nr[$mq[
"id"]];
3300 foreach ($mqueries as $mq) {
3302 "UPDATE sty_media_query SET " .
3303 " order_nr = " .
$ilDB->quote($cnt,
"integer") .
3304 " WHERE id = " .
$ilDB->quote($mq[
"id"],
"integer")
3322 $set =
$ilDB->query(
"SELECT * FROM style_template WHERE " .
3323 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
3328 while ($rec =
$ilDB->fetchAssoc($set)) {
3342 $set =
$ilDB->query(
"SELECT * FROM style_template_class WHERE " .
3343 "template_id = " .
$ilDB->quote($a_tid,
"integer"));
3346 while ($rec =
$ilDB->fetchAssoc($set)) {
3347 $key = $rec[
"class_type"];
3348 $class[$key] = $rec[
"class"];
3362 $tid =
$ilDB->nextId(
"style_template");
3363 $ilDB->manipulate($q =
"INSERT INTO style_template " .
3364 "(id, style_id, name, temp_type)" .
3366 $ilDB->quote($tid,
"integer") .
"," .
3367 $ilDB->quote($this->getId(),
"integer") .
"," .
3368 $ilDB->quote($a_name,
"text") .
"," .
3372 foreach ($a_classes as $t =>
$c) {
3373 $ilDB->manipulate($q =
"INSERT INTO style_template_class " .
3374 "(template_id, class_type, class)" .
3376 $ilDB->quote($tid,
"integer") .
"," .
3377 $ilDB->quote($t,
"text") .
"," .
3382 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheetGUI.php");
3398 $ilDB->manipulate(
"UPDATE style_template SET " .
3399 "name = " .
$ilDB->quote($a_name,
"text") .
3400 " WHERE id = " .
$ilDB->quote($a_t_id,
"integer"));
3403 "DELETE FROM style_template_class WHERE " .
3404 "template_id = " .
$ilDB->quote($a_t_id,
"integer")
3406 foreach ($a_classes as $t =>
$c) {
3407 $ilDB->manipulate($q =
"INSERT INTO style_template_class " .
3408 "(template_id, class_type, class)" .
3410 $ilDB->quote($a_t_id,
"integer") .
"," .
3411 $ilDB->quote($t,
"text") .
"," .
3424 $ilDB->manipulate($q =
"INSERT INTO style_template_class " .
3425 "(template_id, class_type, class)" .
3427 $ilDB->quote($a_t_id,
"integer") .
"," .
3429 $ilDB->quote($a_class,
"text") .
3441 $set =
$ilDB->query(
"SELECT * FROM style_template WHERE " .
3442 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
3443 "name = " .
$ilDB->quote($a_template_name,
"text"));
3444 if ($rec =
$ilDB->fetchAssoc($set)) {
3457 $set =
$ilDB->query(
"SELECT * FROM style_template WHERE " .
3458 "style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" " .
3459 " AND id = " .
$ilDB->quote($a_t_id,
"integer"));
3461 if ($rec =
$ilDB->fetchAssoc($set)) {
3487 $set =
$ilDB->query(
"SELECT name FROM style_template WHERE " .
3488 " id = " .
$ilDB->quote($a_t_id,
"integer"));
3490 if ($rec =
$ilDB->fetchAssoc($set)) {
3491 return $rec[
"name"];
3504 $tag =
"<StyleTemplates>";
3506 $ttypes = array(
"table",
"vaccordion",
"haccordion",
"carousel");
3508 foreach ($ttypes as $ttype) {
3511 foreach ($ts as $t) {
3525 $tag .=
'<StyleTemplate Name="' . $t[
"name"] .
'">';
3527 foreach ($atts as
$type => $t) {
3529 $tag .=
'<StyleClass Type="' .
$type .
'" Value="' .
$c[
$type] .
'" />';
3533 $tag .=
"</StyleTemplate>";
3537 $tag .=
"</StyleTemplates>";
3549 $a_preview_html = str_replace(
' width=""',
"", $a_preview_html);
3550 $a_preview_html = str_replace(
' valign="top"',
"", $a_preview_html);
3551 $a_preview_html = str_replace(
'<div class="ilc_text_block_TableContent">',
"<div>", $a_preview_html);
3554 if (strlen($a_preview_html) > 4000) {
3556 $a_preview_html =
"";
3558 $ilDB->manipulate(
"UPDATE style_template SET " .
3559 "preview = " .
$ilDB->quote($a_preview_html,
"text") .
3560 " WHERE id = " .
$ilDB->quote($a_t_id,
"integer"));
3570 $set =
$ilDB->query(
"SELECT preview FROM style_template " .
3571 " WHERE id = " .
$ilDB->quote($a_t_id,
"integer"));
3572 if ($rec =
$ilDB->fetchAssoc($set)) {
3573 return $rec[
"preview"];
3588 $set =
$ilDB->query(
"SELECT id FROM style_template " .
3589 " WHERE style_id = " .
$ilDB->quote($a_style_id,
"integer") .
3590 " AND name = " .
$ilDB->quote($a_name,
"text"));
3591 if ($rec =
$ilDB->fetchAssoc($set)) {
3605 $ilDB->manipulate(
"DELETE FROM style_template WHERE " .
3606 " style_id = " .
$ilDB->quote($this->getId(),
"integer") .
" AND " .
3607 " id = " .
$ilDB->quote($a_t_id,
"integer"));
3610 "DELETE FROM style_template_class WHERE " .
3611 "template_id = " .
$ilDB->quote($a_t_id,
"integer")
3623 "DELETE FROM style_setting WHERE " .
3624 " style_id = " .
$ilDB->quote($this->getId(),
"integer") .
3625 " AND name = " .
$ilDB->quote($a_name,
"text")
3628 $ilDB->manipulate(
"INSERT INTO style_setting " .
3629 "(style_id, name, value) VALUES (" .
3630 $ilDB->quote($this->getId(),
"integer") .
"," .
3631 $ilDB->quote($a_name,
"text") .
"," .
3632 $ilDB->quote($a_value,
"text") .
3643 $set =
$ilDB->query(
3644 "SELECT value FROM style_setting " .
3645 " WHERE style_id = " .
$ilDB->quote($this->getId(),
"integer") .
3646 " AND name = " .
$ilDB->quote($a_name,
"text")
3648 $rec =
$ilDB->fetchAssoc($set);
3650 return $rec[
"value"];
3665 "obj_id" => array(
"integer", (
int) $a_obj_id)),
3667 "style_id" => array(
"integer", (
int) $a_style_id))
3680 $set =
$ilDB->query(
3681 "SELECT style_id FROM style_usage " .
3682 " WHERE obj_id = " .
$ilDB->quote($a_obj_id,
"integer")
3684 $rec =
$ilDB->fetchAssoc($set);
3687 return (
int) $rec[
"style_id"];
3704 $set =
$ilDB->query(
3705 "SELECT DISTINCT obj_id FROM style_usage " .
3706 " WHERE style_id = " .
$ilDB->quote($a_style_id,
"integer")
3709 while ($rec =
$ilDB->fetchAssoc($set)) {
3710 $obj_ids[] = $rec[
"obj_id"];
An exception for terminatinating execution or to throw for unit testing.
static _lookupContObjIdByStyleId($a_style_id)
lookup style sheet ID
static _deleteStyleAssignments($a_style_id)
delete all style references to style
static _getTemplatePreview($a_style, $a_type, $a_t_id, $a_small_mode=false)
Get table template preview.
determineTemplateStyleClassType($t, $k)
static getBasicZipPath()
Get basic zip path.
setExportSubDir($a_dir)
Set local directory, that will be included within the zip file.
static _lookupActive($a_id)
Lookup active flag.
static _lookupStandard($a_id)
Lookup standard flag.
getMediaQueries()
Get colors of style.
getMaxMQueryOrderNr()
Get maximum media query order nr.
export()
Create export file.
getRefId()
Get ref id (show error message, since styles do not use ref ids)
static _getStyleParameterInputType($par)
static getBasicImageDir()
Get basic image dir.
updateTemplate($a_t_id, $a_name, $a_classes)
Update table template.
static getContentPrintStyle()
get content print style
addMediaQuery($a_mquery, $order_nr=0)
Add media query.
getColorCodeForName($a_name)
Remove a color.
deleteMediaQuery($a_id)
Delete media query.
do_3_9_Migration($a_id)
Migrate old 3.9 styles.
getCharacteristics($a_type="", $a_no_hidden=false, $a_include_core=true)
Get characteristics.
writeTemplatePreview($a_t_id, $a_preview_html)
Write table template preview.
read()
read style properties
static _getTemplateClassTypes($a_template_type="")
Get template class types.
deleteStylePar($a_tag, $a_class, $a_par, $a_type, $a_mq_id=0, $a_custom=false)
Delete style parameter by tag/class/parameter.
static _getClonableContentStyles()
Get all clonable styles (active standard styles and individual learning module styles with write perm...
addColor($a_name, $a_code)
Add color.
static _getFilteredGroups()
createReference()
Create a reference (show error message, since styles do not use ref ids)
static _lookupUpToDate($a_id)
Looup up to date.
static _replaceStylePar($style_id, $a_tag, $a_class, $a_par, $a_val, $a_type, $a_mq_id=0, $a_custom=false)
createExportDirectory()
Create export directory.
update()
update object in db
static _getStyleParameters($a_tag="")
putInTree($a_parent_ref)
Put in tree (show error message, since styles do not use ref ids)
static _HLSToRGB($a_hls)
HLS to RGB (both arrays, 0..255)
getParametersOfClass($a_type, $a_class, $a_mq_id=0)
Get parameters of class.
updateStyleParameter($a_id, $a_value)
update style parameter per id
uploadImage($a_file)
Upload image.
copyImagesToDir($a_target)
Copy images to directory.
createFromXMLFile($a_file, $a_skip_parent_create=false)
create style from xml file todo: add mq_id and custom
static lookupObjectForStyle($a_style_id)
Lookup object style.
characteristicExists($a_char, $a_style_type)
Check whether characteristic exists.
saveMediaQueryOrder($a_order_nr=null)
Save media query order.
addCharacteristic($a_type, $a_char, $a_hidden=false)
Add characteristic.
lookupTemplateName($a_t_id)
Lookup table template name for template ID.
getImagesDirectory()
Get images directory.
addTemplateClass($a_t_id, $a_type, $a_class)
Update table template.
getTemplates($a_type)
Get table templates of style.
removeColor($a_name)
Remove a color.
do_3_10_CharMigration($a_id="")
This is more or less a copy of Services/Migration/DBUpdate_1385/classes ilStyleMigration->addMissingS...
static getAvailableParameters()
Get available parameters.
updateMediaQuery($a_id, $a_mquery)
Update media query.
ilClone()
clone style sheet (note: styles have no ref ids and return an object id)
static _writeStandard($a_id, $a_std)
Write standard flag.
exportXML($a_dir)
export style xml file to directory
static _isExpandable($a_type)
setStyle($a_style)
set styles
cleanExportDirectory()
Clear export directory.
static lookupObjectStyle($a_obj_id)
Lookup object style.
handleXmlString($a_str)
Handle xml strin.
__construct($a_id=0, $a_call_by_reference=false)
Constructor @access public.
deleteCustomStylePars($a_tag, $a_class, $a_type, $a_mq_id=0)
Delete style parameter by tag/class/parameter.
& getMetaData()
get meta data object
addParameter($a_tag, $a_par, $a_type, $a_mq_id=0, $a_custom=false)
write style parameter to db
static _getColorFlavor($a_rgb, $a_i)
Get color flavor.
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 _getStyleParameterNumericUnits($a_no_percentage=false)
static _createImagesDirectory($a_style_id)
Create images directory <data_dir>/sty/sty_<id>/images.
deleteParameter($a_id)
delete style parameter
getTemplateXML()
Get table template xml.
setRefId($a_ref_id)
Set ref id (show error message, since styles do not use ref ids)
setCharacteristics($a_chars)
Set characteristics.
static _getPseudoClasses($tag)
saveHideStatus($a_type, $a_char, $a_hide)
Save characteristic hide status.
writeStyleSetting($a_name, $a_value)
Write Style Setting.
static _addMissingStyleClassesToStyle($a_id)
Add missing style classes to all styles.
static _RGBToHLS($a_rgb)
RGB to HLS (both arrays, 0..255)
static _isHideable($a_type)
getStyleParameterGroups()
Get grouped parameter.
lookupStyleSetting($a_name)
Lookup style setting.
getThumbnailsDirectory()
Get thumbnails directory.
getTemplateClasses($a_tid)
Get template classes.
getHideStatus($a_type, $a_char)
Get characteristic hide status.
lookupTemplatePreview($a_t_id)
Lookup table template preview.
create($a_from_style=0, $a_import_mode=false)
Create a new style.
static _getStyleParameterSubPar($par)
writeCSSFile($a_target_file="", $a_image_dir="")
write css file to webspace directory
static getSyntaxStylePath()
get syntax style path
colorExists($a_color_name)
Check whether color exists.
static _determineTag($a_type)
getUpToDate()
Get up to date.
removeTemplate($a_t_id)
Remove table template.
getExportSubDir()
The local directory, that will be included within the zip file.
getStyle()
todo: bad style! should return array of objects, not multi-dim-arrays
static _lookupTemplateIdByName($a_style_id, $a_name)
Lookup table template preview.
static _writeActive($a_id, $a_active)
Write active flag.
static _getStandardStyles( $a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
addTemplate($a_type, $a_name, $a_classes)
Add table template.
setScope($a_scope)
Set scope.
static _getStyleSuperTypeForType($a_type)
updateColor($a_name, $a_new_name, $a_code)
Update color.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
getImages()
Get images of style.
getMediaQueryForId($a_id)
Get media query for id.
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static _lookupTemplateName($a_t_id)
Lookup table template name for template ID.
static _writeUpToDate($a_id, $a_up_to_date)
Write up to date.
do_3_10_Migration()
Migrates 3.10 style to 3.11 style.
copyCharacteristic( $a_from_style_id, $a_from_type, $a_from_char, $a_to_char)
Copy characteristic.
static isCoreStyle($a_type, $a_class)
Is core style.
static getPlaceHolderStylePath()
get placeholder style path (for Page Layouts)
createImportDirectory()
Create import directory.
deleteCharacteristic($a_type, $a_tag, $a_class)
Delete Characteristic.
getColors()
Get colors of style.
static $style_super_types
createImagesDirectory()
Create images directory <data_dir>/sty/sty_<id>/images.
getTemplate($a_t_id)
Get template.
assignMetaData(&$a_meta_data)
assign meta data object
setUpToDate($a_up_to_date=true)
Set style up to date (false + update will trigger css generation next time)
static _explodeRGB($a_rgb, $as_dec=false)
Explode an RGB string into an array.
static _getImagesDirectory($a_style_id)
Get images directory.
static _getStyleParameterValues($par)
static _getStyleSuperTypes()
static _writeScope($a_id, $a_scope)
Write scope.
deleteImage($a_file)
Delete an image.
static _getCoreStyles()
Get core styles.
static _addMissingStyleClassesToAllStyles($a_styles="")
Add missing style classes to all styles todo: add mq_id and custom handling.
static writeStyleUsage($a_obj_id, $a_style_id)
Write style usage.
createExportSubDirectory()
Create export directory.
static $basic_style_image_dir
getXML()
get xml representation of style object todo: add mq_id
static _getBasicStyleDom()
Get basic style dom.
templateExists($a_template_name)
Check whether template exists.
deleteStyleParOfChar($a_type, $a_class)
Delete style parameters of characteristic.
Class ilObject Basic functions for all objects.
getType()
get object type @access public
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
getDescription()
get object description
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
getId()
get object id @access public
static _getObjectsDataForType($a_type, $a_omit_trash=false)
get all objects of a certain type
static _lookupType($a_id, $a_reference=false)
lookup object type
getTitle()
get object title @access public
static getDataDir()
get data directory (outside webspace)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getWebspaceDir($mode="filesystem")
get webspace directory
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop=false)
resize image
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static signFile($path_to_file)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
redirection script todo: (a better solution should control the processing via a xml file)
foreach($_POST as $key=> $value) $res