5 require_once
"./Services/Object/classes/class.ilObject.php";
19 public static $num_unit = array(
"px",
"em",
"ex",
"%",
"pt",
"pc",
"in",
"mm",
"cm");
25 "values" => array(
"xx-small",
"x-small",
"small",
"medium",
"large",
"x-large",
"xx-large",
"smaller",
"larger"),
26 "input" =>
"fontsize",
28 "font-family" => array(
32 "font-style" => array(
33 "values" => array(
"italic",
"oblique",
"normal"),
36 "font-weight" => array(
37 "values" => array(
"bold",
"normal",
"bolder",
"lighter"),
40 "font-variant" => array(
41 "values" => array(
"small-caps",
"normal"),
44 "word-spacing" => array(
46 "input" =>
"numeric_no_perc",
48 "letter-spacing" => array(
50 "input" =>
"numeric_no_perc",
52 "text-decoration" => array(
53 "values" => array(
"underline",
"overline",
"line-through",
"blink",
"none"),
56 "text-transform" => array(
57 "values" => array(
"capitalize",
"uppercase",
"lowercase",
"none"),
64 "text-indent" => array(
68 "line-height" => array(
72 "vertical-align" => array(
73 "values" => array(
"top",
"middle",
"bottom",
"baseline",
"sub",
"super",
74 "text-top",
"text-bottom"),
77 "text-align" => array(
78 "values" => array(
"left",
"center",
"right",
"justify"),
81 "white-space" => array(
82 "values" => array(
"normal",
"pre",
"nowrap"),
87 "input" =>
"trbl_numeric",
88 "subpar" => array(
"margin",
"margin-top",
"margin-right",
89 "margin-bottom",
"margin-left"),
90 "group" =>
"margin_and_padding"),
93 "input" =>
"trbl_numeric",
94 "subpar" => array(
"padding",
"padding-top",
"padding-right",
95 "padding-bottom",
"padding-left"),
96 "group" =>
"margin_and_padding"),
97 "border-width" => array(
98 "values" => array(
"thin",
"medium",
"thick"),
99 "input" =>
"border_width",
100 "subpar" => array(
"border-width",
"border-top-width",
"border-right-width",
101 "border-bottom-width",
"border-left-width"),
102 "group" =>
"border"),
103 "border-color" => array(
105 "input" =>
"trbl_color",
106 "subpar" => array(
"border-color",
"border-top-color",
"border-right-color",
107 "border-bottom-color",
"border-left-color"),
108 "group" =>
"border"),
109 "border-style" => array(
110 "values" => array(
"none",
"hidden",
"dotted",
"dashed",
"solid",
"double",
111 "groove",
"ridge",
"inset",
"outset"),
112 "input" =>
"border_style",
113 "subpar" => array(
"border-style",
"border-top-style",
"border-right-style",
114 "border-bottom-style",
"border-left-style"),
115 "group" =>
"border"),
117 "background-color" => array(
120 "group" =>
"background"),
121 "background-image" => array(
123 "input" =>
"background_image",
124 "group" =>
"background"),
125 "background-repeat" => array(
126 "values" => array(
"repeat",
"repeat-x",
"repeat-y",
"no-repeat"),
128 "group" =>
"background"),
129 "background-attachment" => array(
130 "values" => array(
"fixed",
"scroll"),
132 "group" =>
"background"),
133 "background-position" => array(
134 "values" => array(
"horizontal" => array(
"left",
"center",
"right"),
135 "vertical" => array(
"top",
"center",
"bottom")),
136 "input" =>
"background_position",
137 "group" =>
"background"),
140 "values" => array(
"absolute",
"fixed",
"relative",
"static"),
142 "group" =>
"positioning"),
145 "input" =>
"numeric",
146 "group" =>
"positioning"),
149 "input" =>
"numeric",
150 "group" =>
"positioning"),
153 "input" =>
"numeric",
154 "group" =>
"positioning"),
157 "input" =>
"numeric",
158 "group" =>
"positioning"),
161 "input" =>
"numeric",
162 "group" =>
"positioning"),
165 "input" =>
"numeric",
166 "group" =>
"positioning"),
167 "min-height" => array(
169 "input" =>
"numeric",
170 "group" =>
"positioning"),
172 "values" => array(
"left",
"right",
"none"),
174 "group" =>
"positioning"),
176 "values" => array(
"visible",
"hidden",
"scroll",
"auto"),
178 "group" =>
"positioning"),
181 "input" =>
"percentage",
182 "group" =>
"special"),
183 "transform" => array(
184 "values" => array(
"rotate(90deg)",
"rotate(180deg)",
"rotate(270deg)"),
186 "group" =>
"special"),
187 "transform-origin" => array(
188 "values" => array(
"horizontal" => array(
"left",
"center",
"right"),
189 "vertical" => array(
"top",
"center",
"bottom")),
190 "input" =>
"background_position",
191 "group" =>
"special"),
193 "values" => array(
"auto",
"default",
"crosshair",
"pointer",
"move",
194 "n-resize",
"ne-resize",
"e-resize",
"se-resize",
"s-resize",
"sw-resize",
195 "w-resize",
"nw-resize",
"text",
"wait",
"help"),
197 "group" =>
"special"),
199 "values" => array (
"both",
"left",
"right",
"none"),
201 "group" =>
"special"),
203 "list-style-type.ol" => array(
204 "values" => array (
"decimal",
"lower-roman",
"upper-roman",
205 "lower-alpha",
"upper-alpha",
"lower-greek",
"hebrew",
206 "decimal-leading-zero",
"cjk-ideographic",
"hiragana",
207 "katakana",
"hiragana-iroha",
"katakana-iroha",
"none"),
210 "list-style-type.ul" => array(
211 "values" => array (
"disc",
"circle",
"square",
215 "list-style-image.ul" => array(
217 "input" =>
"background_image",
219 "list-style-position.ol" => array(
220 "values" => array (
"inside",
"outside"),
223 "list-style-position.ul" => array(
224 "values" => array (
"inside",
"outside"),
228 "border-collapse" => array(
229 "values" => array (
"collapse",
"separate"),
233 "caption-side" => array(
234 "values" => array (
"top",
"bottom",
"left",
"right"),
243 array(
"ol" => array(
"ol"),
"ul" => array(
"ul"),
244 "table" => array(
"table"),
"positioning" => array(
"h1",
"h2",
"h3",
"div",
"img",
"table",
"a"));
248 "text_block" => array(
"text_block",
"heading1",
"heading2",
"heading3"),
249 "text_inline" => array(
"text_inline"),
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"),
258 "question" => array(
"question",
"qtitle",
"qanswer",
"qinput",
"qlinput",
"qsubmit",
"qfeedr",
"qfeedw",
259 "qimg",
"qordul",
"qordli",
"qimgd",
"qetitem",
"qetcorr",
"qover"),
260 "page" => array(
"page_frame",
"page_cont",
"page_title",
"page_fn",
261 "page_tnav",
"page_bnav",
"page_lnav",
"page_rnav",
"page_lnavlink",
"page_rnavlink",
262 "page_lnavimage",
"page_rnavimage"),
263 "glo" => array(
"glo_overlay",
"glo_ovtitle",
"glo_ovclink",
"glo_ovuglink",
"glo_ovuglistlink"),
264 "sco" => array(
"sco_title",
"sco_keyw",
"sco_desc",
"sco_desct",
"sco_obj",
"sco_objt",
"sco_fmess"),
265 "rte" => array(
"rte_menu",
"rte_mlink",
"rte_tree",
"rte_node",
"rte_tlink",
"rte_status",
266 "rte_tul",
"rte_tli",
"rte_texp",
"rte_tclink",
"rte_drag")
271 "text_block",
"section",
"media_cont",
"table",
"table_cell",
"flist_li",
"table_caption",
273 "va_cntr",
"va_icntr",
"va_ihead",
"va_iheada",
"va_ihcap",
"va_icont",
274 "ha_cntr",
"ha_icntr",
"ha_ihead",
"ha_iheada",
"ha_ihcap",
"ha_icont" 279 "table",
"table_cell" 284 "text_block" =>
"div",
288 "text_inline" =>
"span",
292 "table_cell" =>
"td",
293 "table_caption" =>
"caption",
294 "media_cont" =>
"table",
295 "media_caption" =>
"div",
298 "glo_overlay" =>
"div",
299 "glo_ovtitle" =>
"h1",
300 "glo_ovclink" =>
"a",
301 "glo_ovuglink" =>
"a",
302 "glo_ovuglistlink" =>
"a",
303 "sco_title" =>
"div",
307 "sco_desct" =>
"div",
309 "sco_fmess" =>
"div",
316 "rte_status" =>
"div",
324 "flist_cont" =>
"div",
325 "flist_head" =>
"div",
339 "qlinput" =>
"textarea",
340 "qsubmit" =>
"input",
344 "page_frame" =>
"div",
345 "page_cont" =>
"div",
348 "page_tnav" =>
"div",
349 "page_bnav" =>
"div",
350 "page_lnav" =>
"div",
351 "page_rnav" =>
"div",
352 "page_lnavlink" =>
"a",
353 "page_rnavlink" =>
"a",
354 "page_lnavimage" =>
"img",
355 "page_rnavimage" =>
"img",
356 "page_title" =>
"h1",
361 "va_iheada" =>
"div",
366 "ha_iheada" =>
"div",
373 array (
"a" => array(
"hover"),
"div" => array(
"hover"),
"img" => array(
"hover"));
377 array(
"type" =>
"text_block",
"class" =>
"Standard"),
378 array(
"type" =>
"text_block",
"class" =>
"List"),
379 array(
"type" =>
"text_block",
"class" =>
"TableContent"),
380 array(
"type" =>
"heading1",
"class" =>
"Headline1"),
381 array(
"type" =>
"heading2",
"class" =>
"Headline2"),
382 array(
"type" =>
"heading3",
"class" =>
"Headline3"),
383 array(
"type" =>
"text_inline",
"class" =>
"Comment"),
384 array(
"type" =>
"text_inline",
"class" =>
"Emph"),
385 array(
"type" =>
"text_inline",
"class" =>
"Quotation"),
386 array(
"type" =>
"text_inline",
"class" =>
"Strong"),
387 array(
"type" =>
"text_inline",
"class" =>
"Accent"),
388 array(
"type" =>
"text_inline",
"class" =>
"Important"),
389 array(
"type" =>
"link",
"class" =>
"IntLink"),
390 array(
"type" =>
"link",
"class" =>
"ExtLink"),
391 array(
"type" =>
"link",
"class" =>
"FootnoteLink"),
392 array(
"type" =>
"link",
"class" =>
"FileLink"),
393 array(
"type" =>
"link",
"class" =>
"GlossaryLink"),
394 array(
"type" =>
"media_cont",
"class" =>
"MediaContainer"),
395 array(
"type" =>
"table",
"class" =>
"StandardTable"),
396 array(
"type" =>
"media_caption",
"class" =>
"MediaCaption"),
397 array(
"type" =>
"iim",
"class" =>
"ContentPopup"),
398 array(
"type" =>
"marker",
"class" =>
"Marker"),
399 array(
"type" =>
"page_frame",
"class" =>
"PageFrame"),
400 array(
"type" =>
"page_cont",
"class" =>
"PageContainer"),
401 array(
"type" =>
"page",
"class" =>
"Page"),
402 array(
"type" =>
"page_tnav",
"class" =>
"TopNavigation"),
403 array(
"type" =>
"page_bnav",
"class" =>
"BottomNavigation"),
404 array(
"type" =>
"page_lnav",
"class" =>
"LeftNavigation"),
405 array(
"type" =>
"page_rnav",
"class" =>
"RightNavigation"),
406 array(
"type" =>
"page_lnavlink",
"class" =>
"LeftNavigationLink"),
407 array(
"type" =>
"page_rnavlink",
"class" =>
"RightNavigationLink"),
408 array(
"type" =>
"page_lnavimage",
"class" =>
"LeftNavigationImage"),
409 array(
"type" =>
"page_rnavimage",
"class" =>
"RightNavigationImage"),
410 array(
"type" =>
"page_fn",
"class" =>
"Footnote"),
411 array(
"type" =>
"page_title",
"class" =>
"PageTitle"),
412 array(
"type" =>
"glo_overlay",
"class" =>
"GlossaryOverlay"),
413 array(
"type" =>
"glo_ovtitle",
"class" =>
"GlossaryOvTitle"),
414 array(
"type" =>
"glo_ovclink",
"class" =>
"GlossaryOvCloseLink"),
415 array(
"type" =>
"glo_ovuglink",
"class" =>
"GlossaryOvUnitGloLink"),
416 array(
"type" =>
"glo_ovuglistlink",
"class" =>
"GlossaryOvUGListLink"),
417 array(
"type" =>
"sco_title",
"class" =>
"Title"),
418 array(
"type" =>
"sco_desc",
"class" =>
"Description"),
419 array(
"type" =>
"sco_desct",
"class" =>
"DescriptionTop"),
420 array(
"type" =>
"sco_keyw",
"class" =>
"Keywords"),
421 array(
"type" =>
"sco_obj",
"class" =>
"Objective"),
422 array(
"type" =>
"sco_objt",
"class" =>
"ObjectiveTop"),
423 array(
"type" =>
"sco_fmess",
"class" =>
"FinalMessage"),
424 array(
"type" =>
"rte_menu",
"class" =>
"RTEMenu"),
425 array(
"type" =>
"rte_menu",
"class" =>
"RTELogo"),
426 array(
"type" =>
"rte_menu",
"class" =>
"RTELinkBar"),
427 array(
"type" =>
"rte_mlink",
"class" =>
"RTELink"),
428 array(
"type" =>
"rte_mlink",
"class" =>
"RTELinkDisabled"),
429 array(
"type" =>
"rte_tree",
"class" =>
"RTETree"),
430 array(
"type" =>
"rte_node",
"class" =>
"RTECourse"),
431 array(
"type" =>
"rte_node",
"class" =>
"RTEChapter"),
432 array(
"type" =>
"rte_node",
"class" =>
"RTESco"),
433 array(
"type" =>
"rte_node",
"class" =>
"RTEAsset"),
434 array(
"type" =>
"rte_node",
"class" =>
"RTECourseDisabled"),
435 array(
"type" =>
"rte_node",
"class" =>
"RTEChapterDisabled"),
436 array(
"type" =>
"rte_node",
"class" =>
"RTEScoDisabled"),
437 array(
"type" =>
"rte_node",
"class" =>
"RTEAssetDisabled"),
438 array(
"type" =>
"rte_status",
"class" =>
"RTEAsset"),
439 array(
"type" =>
"rte_status",
"class" =>
"RTECompleted"),
440 array(
"type" =>
"rte_status",
"class" =>
"RTENotAttempted"),
441 array(
"type" =>
"rte_status",
"class" =>
"RTERunning"),
442 array(
"type" =>
"rte_status",
"class" =>
"RTEIncomplete"),
443 array(
"type" =>
"rte_status",
"class" =>
"RTEPassed"),
444 array(
"type" =>
"rte_status",
"class" =>
"RTEFailed"),
445 array(
"type" =>
"rte_status",
"class" =>
"RTEBrowsed"),
446 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeLink"),
447 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeLinkDisabled"),
448 array(
"type" =>
"rte_tlink",
"class" =>
"RTETreeCurrent"),
449 array(
"type" =>
"rte_tul",
"class" =>
"RTETreeList"),
450 array(
"type" =>
"rte_tli",
"class" =>
"RTETreeItem"),
451 array(
"type" =>
"rte_texp",
"class" =>
"RTETreeExpanded"),
452 array(
"type" =>
"rte_texp",
"class" =>
"RTETreeCollapsed"),
453 array(
"type" =>
"rte_tree",
"class" =>
"RTETreeControl"),
454 array(
"type" =>
"rte_tclink",
"class" =>
"RTETreeControlLink"),
455 array(
"type" =>
"rte_drag",
"class" =>
"RTEDragBar"),
456 array(
"type" =>
"list_o",
"class" =>
"NumberedList"),
457 array(
"type" =>
"list_u",
"class" =>
"BulletedList"),
458 array(
"type" =>
"list_item",
"class" =>
"StandardListItem"),
459 array(
"type" =>
"question",
"class" =>
"Standard"),
460 array(
"type" =>
"question",
"class" =>
"SingleChoice"),
461 array(
"type" =>
"question",
"class" =>
"MultipleChoice"),
462 array(
"type" =>
"question",
"class" =>
"TextQuestion"),
463 array(
"type" =>
"question",
"class" =>
"OrderingQuestion"),
464 array(
"type" =>
"question",
"class" =>
"MatchingQuestion"),
465 array(
"type" =>
"question",
"class" =>
"ImagemapQuestion"),
466 array(
"type" =>
"question",
"class" =>
"ErrorText"),
467 array(
"type" =>
"question",
"class" =>
"TextSubset"),
468 array(
"type" =>
"question",
"class" =>
"ClozeTest"),
469 array(
"type" =>
"qtitle",
"class" =>
"Title"),
470 array(
"type" =>
"qanswer",
"class" =>
"Answer"),
471 array(
"type" =>
"qimg",
"class" =>
"QuestionImage"),
472 array(
"type" =>
"qimgd",
"class" =>
"ImageDetailsLink"),
473 array(
"type" =>
"qordul",
"class" =>
"OrderList"),
474 array(
"type" =>
"qordli",
"class" =>
"OrderListItem"),
475 array(
"type" =>
"qordul",
"class" =>
"OrderListHorizontal"),
476 array(
"type" =>
"qordli",
"class" =>
"OrderListItemHorizontal"),
477 array(
"type" =>
"qetitem",
"class" =>
"ErrorTextItem"),
478 array(
"type" =>
"qetitem",
"class" =>
"ErrorTextSelected"),
479 array(
"type" =>
"qetcorr",
"class" =>
"ErrorTextCorrected"),
480 array(
"type" =>
"qinput",
"class" =>
"TextInput"),
481 array(
"type" =>
"qlinput",
"class" =>
"LongTextInput"),
482 array(
"type" =>
"qsubmit",
"class" =>
"Submit"),
483 array(
"type" =>
"qfeedr",
"class" =>
"FeedbackRight"),
484 array(
"type" =>
"qfeedw",
"class" =>
"FeedbackWrong"),
485 array(
"type" =>
"qover",
"class" =>
"Correct"),
486 array(
"type" =>
"qover",
"class" =>
"Inorrect"),
487 array(
"type" =>
"qover",
"class" =>
"StatusMessage"),
488 array(
"type" =>
"qover",
"class" =>
"WrongAnswersMessage"),
489 array(
"type" =>
"flist_cont",
"class" =>
"FileListContainer"),
490 array(
"type" =>
"flist_head",
"class" =>
"FileListHeading"),
491 array(
"type" =>
"flist",
"class" =>
"FileList"),
492 array(
"type" =>
"flist_li",
"class" =>
"FileListItem"),
493 array(
"type" =>
"flist_a",
"class" =>
"FileListItemLink")
499 "caption" =>
"table_caption",
500 "row_head" =>
"table_cell",
501 "row_foot" =>
"table_cell",
502 "col_head" =>
"table_cell",
503 "col_foot" =>
"table_cell",
504 "odd_row" =>
"table_cell",
505 "even_row" =>
"table_cell",
506 "odd_col" =>
"table_cell",
507 "even_col" =>
"table_cell"),
508 "vaccordion" => array(
509 "va_cntr" =>
"va_cntr",
510 "va_icntr" =>
"va_icntr",
511 "va_ihead" =>
"va_ihead",
512 "va_iheada" =>
"va_iheada",
513 "va_ihcap" =>
"va_ihcap",
514 "va_icont" =>
"va_icont" 516 "haccordion" => array(
517 "ha_cntr" =>
"ha_cntr",
518 "ha_icntr" =>
"ha_icntr",
519 "ha_ihead" =>
"ha_ihead",
520 "ha_iheada" =>
"ha_iheada",
521 "ha_ihcap" =>
"ha_ihcap",
522 "ha_icont" =>
"ha_icont" 540 $this->style = array();
541 if($a_call_by_reference)
543 $this->
ilias->raiseError(
"Can't instantiate style object via reference id.",$this->
ilias->error_obj->FATAL);
546 parent::ilObject($a_id,
false);
554 $this->
ilias->raiseError(
"Operation ilObjStyleSheet::setRefId() not allowed.",$this->
ilias->error_obj->FATAL);
571 $this->
ilias->raiseError(
"Operation ilObjStyleSheet::putInTree() not allowed.",$this->
ilias->error_obj->FATAL);
579 $this->
ilias->raiseError(
"Operation ilObjStyleSheet::createReference() not allowed.",$this->
ilias->error_obj->FATAL);
587 $this->up_to_date = $a_up_to_date;
595 return $this->up_to_date;
603 $this->scope = $a_scope;
621 $q =
"UPDATE style_data SET uptodate = ".
622 $ilDB->quote((
int) $a_up_to_date,
"integer").
623 " WHERE id = ".$ilDB->quote($a_id,
"integer");
624 $ilDB->manipulate($q);
634 $q =
"SELECT uptodate FROM style_data ".
635 " WHERE id = ".$ilDB->quote($a_id,
"integer");
636 $res = $ilDB->query($q);
637 $sty = $ilDB->fetchAssoc(
$res);
639 return (
boolean) $sty[
"uptodate"];
649 $q =
"UPDATE style_data SET standard = ".
650 $ilDB->quote((
int) $a_std,
"integer").
651 " WHERE id = ".$ilDB->quote($a_id,
"integer");
652 $ilDB->manipulate($q);
662 $q =
"UPDATE style_data SET category = ".
663 $ilDB->quote((
int) $a_scope,
"integer").
664 " WHERE id = ".$ilDB->quote($a_id,
"integer");
665 $ilDB->manipulate($q);
675 $q =
"SELECT * FROM style_data ".
676 " WHERE id = ".$ilDB->quote($a_id,
"integer");
677 $res = $ilDB->query($q);
678 $sty = $ilDB->fetchAssoc(
$res);
680 return (
boolean) $sty[
"standard"];
690 $q =
"UPDATE style_data SET active = ".
691 $ilDB->quote((
int) $a_active,
"integer").
692 " WHERE id = ".$ilDB->quote($a_id,
"integer");
693 $ilDB->manipulate($q);
703 $q =
"SELECT * FROM style_data ".
704 " WHERE id = ".$ilDB->quote($a_id,
"integer");
705 $res = $ilDB->query($q);
706 $sty = $ilDB->fetchAssoc(
$res);
708 return (
boolean) $sty[
"active"];
715 $a_include_deactivated =
false, $a_scope = 0)
719 $default_style = $ilias->getSetting(
"default_content_style_id");
722 if (!$a_include_deactivated)
724 $and_str =
" AND active = 1";
727 $q =
"SELECT * FROM style_data ".
728 " WHERE standard = 1".$and_str;
729 $res = $ilDB->query($q);
731 while($sty = $ilDB->fetchAssoc(
$res))
733 if (!$a_exclude_default_style || $default_style != $sty[
"id"])
736 if ($a_scope > 0 && $sty[
"category"] > 0)
738 if ($tree->isInTree($sty[
"category"]) &&
739 $tree->isInTree($a_scope))
741 $path = $tree->getPathId($a_scope);
742 if (!in_array($sty[
"category"],
$path))
762 global $ilAccess,
$ilDB;
764 $clonable_styles = array();
766 $q =
"SELECT * FROM style_data";
767 $style_set = $ilDB->query($q);
768 while($style_rec = $ilDB->fetchAssoc($style_set))
771 if ($style_rec[
"standard"] == 1)
773 if ($style_rec[
"active"] == 1)
780 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
782 foreach($obj_ids as
$id)
787 if ($ilAccess->checkAccess(
"write",
"", $ref_id))
796 $clonable_styles[$style_rec[
"id"]] =
800 return $clonable_styles;
808 $this->meta_data =& $a_meta_data;
818 if (!is_object(self::$basic_style_dom))
821 self::$basic_style_dom->load(self::$basic_style_file);
824 return self::$basic_style_dom;
832 return $this->meta_data;
838 function create($a_from_style = 0, $a_import_mode =
false)
844 if ($a_from_style == 0)
861 $q =
"SELECT * FROM style_parameter WHERE style_id = ".
862 $ilDB->quote($a_from_style,
"integer");
863 $par_set = $ilDB->query($q);
864 while($par_rec = $ilDB->fetchAssoc($par_set))
866 $def[] = array(
"tag" => $par_rec[
"tag"],
"class" => $par_rec[
"class"],
867 "parameter" => $par_rec[
"parameter"],
"value" => $par_rec[
"value"],
868 "type" => $par_rec[
"type"],
"mq_id" => $par_rec[
"mq_id"],
"custom" => $par_rec[
"custom"]);
873 $q =
"SELECT * FROM style_char WHERE style_id = ".
874 $ilDB->quote($a_from_style,
"integer");
875 $par_set = $ilDB->query($q);
876 while($par_rec = $ilDB->fetchAssoc($par_set))
878 $chars[] = array(
"type" => $par_rec[
"type"],
"characteristic" => $par_rec[
"characteristic"]);
884 $mqs = $from_style->getMediaQueries();
885 $mq_mapping = array();
886 foreach ($mqs as $mq)
889 $mq_mapping[$mq[
"id"]] = $nid;
893 foreach ($def as $sty)
895 $id = $ilDB->nextId(
"style_parameter");
896 $q =
"INSERT INTO style_parameter (id, style_id, tag, class, parameter, value, type, mq_id, custom) VALUES ".
898 $ilDB->quote(
$id,
"integer").
",".
899 $ilDB->quote($this->
getId(),
"integer").
",".
900 $ilDB->quote($sty[
"tag"],
"text").
",".
901 $ilDB->quote($sty[
"class"],
"text").
",".
902 $ilDB->quote($sty[
"parameter"],
"text").
",".
903 $ilDB->quote($sty[
"value"],
"text").
",".
904 $ilDB->quote($sty[
"type"],
"text").
",".
905 $ilDB->quote((
int) $mq_mapping[$sty[
"mq_id"]],
"integer").
",".
906 $ilDB->quote($sty[
"custom"],
"integer").
908 $ilDB->manipulate($q);
912 foreach ($chars as $char)
914 $q =
"INSERT INTO style_char (style_id, type, characteristic) VALUES ".
915 "(".$ilDB->quote($this->
getId(),
"integer").
",".
916 $ilDB->quote($char[
"type"],
"text").
",".
917 $ilDB->quote($char[
"characteristic"],
"text").
")";
918 $ilDB->manipulate($q);
922 $q =
"INSERT INTO style_data (id, uptodate, category) VALUES ".
923 "(".$ilDB->quote($this->
getId(),
"integer").
", 0,".
924 $ilDB->quote((
int) $this->
getScope(),
"integer").
")";
925 $ilDB->manipulate($q);
933 $colors = $from_style->getColors();
934 foreach ($colors as $c)
936 $this->
addColor($c[
"name"], $c[
"code"]);
941 foreach ($tcts as $tct => $v)
946 $this->
addTemplate($tct, $t[
"name"], $t[
"classes"]);
968 if (empty(
$core_styles[$a_type.
".".$a_tag.
".".$a_class]))
971 $st = $ilDB->manipulateF(
972 "DELETE FROM style_char WHERE style_id = %s AND type = %s AND characteristic = %s",
973 array(
"integer",
"text",
"text"),
974 array($this->
getId(), $a_type, $a_class));
977 $st = $ilDB->manipulateF(
"DELETE FROM style_parameter WHERE style_id = %s AND tag = %s AND type = %s AND class = %s",
978 array(
"integer",
"text",
"text",
"text"),
979 array($this->
getId(), $a_tag, $a_type, $a_class));
993 $set = $ilDB->queryF(
994 "SELECT style_id FROM style_char WHERE style_id = %s AND characteristic = %s AND type = %s",
995 array(
"integer",
"text",
"text"),
996 array($this->
getId(), $a_char, $a_style_type));
997 if ($rec = $ilDB->fetchAssoc($set))
1012 $ilDB->manipulateF(
"INSERT INTO style_char (style_id, type, characteristic, hide)".
1013 " VALUES (%s,%s,%s,%s) ",
1014 array(
"integer",
"text",
"text",
"integer"),
1015 array($this->
getId(), $a_type, $a_char, $a_hidden));
1028 $a_from_type, $a_from_char, $a_to_char)
1041 $pars = $from_style->getParametersOfClass($a_from_type, $a_from_char);
1044 foreach ($pars as $p => $v)
1046 if (substr($v, 0, 1) ==
"!")
1048 $colors[] = substr($v, 1);
1051 $a_to_char, $p, $v, $a_from_type);
1055 foreach ($colors as $c)
1059 $this->
addColor($c, $from_style->getColorCodeForName($c));
1073 $chars = $this->chars;
1075 if (is_array($this->chars_by_type[$a_type]))
1077 $chars = $this->chars_by_type[$a_type];
1082 foreach ($chars as $k => $char)
1084 if ($a_type ==
"" && $this->hidden_chars[$char[
"type"].
":".$char[
"class"]])
1088 else if ($this->hidden_chars[$a_type.
":".$char])
1103 $this->chars = $a_chars;
1114 $ilDB->manipulate(
"UPDATE style_char SET ".
1115 " hide = ".$ilDB->quote((
int) $a_hide,
"integer").
1116 " WHERE style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1117 " type = ".$ilDB->quote($a_type,
"text").
" AND ".
1118 " characteristic = ".$ilDB->quote($a_char,
"text")
1129 $set = $ilDB->query(
"SELECT hide FROM style_char ".
1130 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
1131 " type = ".$ilDB->quote($a_type,
"text").
" AND ".
1132 " characteristic = ".$ilDB->quote($a_char,
"text")
1134 $rec = $ilDB->fetchAssoc($set);
1136 return $rec[
"hide"];
1149 $lng->loadLanguageModule(
"style");
1152 $new_obj->setTitle($this->
getTitle().
" (".$lng->txt(
"sty_acopy").
")");
1153 $new_obj->setType($this->
getType());
1155 $new_obj->create($this->
getId());
1157 $new_obj->writeStyleSetting(
"disable_auto_margins",
1160 return $new_obj->getId();
1180 function addParameter($a_tag, $a_par, $a_type, $a_mq_id = 0, $a_custom =
false)
1185 $tag = explode(
".", $a_tag);
1186 $value = $avail_params[$a_par][0];
1187 $id = $ilDB->nextId(
"style_parameter");
1188 $q =
"INSERT INTO style_parameter (id,style_id, type, tag, class, parameter, value, mq_id, custom) VALUES ".
1190 $ilDB->quote(
$id,
"integer").
",".
1191 $ilDB->quote($this->
getId(),
"integer").
",".
1192 $ilDB->quote($a_type,
"text").
",".
1193 $ilDB->quote($tag[0],
"text").
",".
1194 $ilDB->quote($tag[1],
"text").
",".
1195 $ilDB->quote($a_par,
"text").
",".
1196 $ilDB->quote($value,
"text").
",".
1197 $ilDB->quote($a_mq_id,
"integer").
",".
1198 $ilDB->quote($a_custom,
"integer").
1200 $ilDB->manipulate($q);
1224 if(!is_writable($sty_data_dir))
1226 $ilErr->raiseError(
"Style data directory (".$sty_data_dir
1227 .
") not writeable.", $ilErr->FATAL);
1230 $style_dir = $sty_data_dir.
"/sty_".$a_style_id;
1232 if(!@is_dir($style_dir))
1234 $ilErr->raiseError(
"Creation of style directory failed (".
1235 $style_dir.
").",$ilErr->FATAL);
1239 $im_dir = $style_dir.
"/images";
1241 if(!@is_dir($im_dir))
1243 $ilErr->raiseError(
"Creation of Import Directory failed (".
1244 $im_dir.
").", $ilErr->FATAL);
1248 $thumb_dir = $style_dir.
"/images/thumbnails";
1250 if(!@is_dir($thumb_dir))
1252 $ilErr->raiseError(
"Creation of Import Directory failed (".
1253 $thumb_dir.
").", $ilErr->FATAL);
1293 foreach($entries as $entry)
1295 if (substr($entry[
"entry"],0,1) ==
".")
1299 if ($entry[
"type"] !=
"dir")
1345 $q =
"DELETE FROM style_parameter WHERE id = ".
1346 $ilDB->quote($a_id,
"integer");
1359 function deleteStylePar($a_tag, $a_class, $a_par, $a_type, $a_mq_id = 0, $a_custom =
false)
1363 $q =
"DELETE FROM style_parameter WHERE ".
1364 " style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1365 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1366 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1367 " mq_id = ".$ilDB->quote($a_mq_id,
"integer").
" AND ".
1368 " custom = ".$ilDB->quote($a_custom,
"integer").
" AND ".
1369 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1370 " parameter = ".$ilDB->quote($a_par,
"text");
1372 $ilDB->manipulate($q);
1388 $q =
"DELETE FROM style_parameter WHERE ".
1389 " style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1390 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1391 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1392 " mq_id = ".$ilDB->quote($a_mq_id,
"integer").
" AND ".
1393 " custom = ".$ilDB->quote(1,
"integer").
" AND ".
1394 " ".$ilDB->equals(
"type", $a_type,
"text",
true);
1396 $ilDB->manipulate($q);
1411 $q =
"DELETE FROM style_parameter WHERE ".
1412 " style_id = ".$ilDB->quote($this->
getId(),
"integer").
" AND ".
1413 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1414 " ".$ilDB->equals(
"type", $a_type,
"text",
true);
1416 $ilDB->manipulate($q);
1431 $def_style = $this->
ilias->getSetting(
"default_content_style_id");
1432 if ($def_style == $this->
getId())
1434 $this->
ilias->deleteSetting(
"default_content_style_id");
1438 $fixed_style = $this->
ilias->getSetting(
"fixed_content_style_id");
1439 if ($fixed_style == $this->
getId())
1441 $this->
ilias->deleteSetting(
"fixed_content_style_id");
1445 $q =
"DELETE FROM style_parameter WHERE style_id = ".
1446 $ilDB->quote($this->
getId(),
"integer");
1447 $ilDB->manipulate($q);
1451 if (is_file($css_file_name))
1453 unlink($css_file_name);
1457 $ilDB->manipulate(
"DELETE FROM sty_media_query WHERE ".
1458 " style_id = ".$ilDB->quote($this->getId(),
"integer")
1462 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
1466 $q =
"DELETE FROM style_data WHERE id = ".
1467 $ilDB->quote($this->
getId(),
"integer");
1468 $ilDB->manipulate($q);
1482 $q =
"SELECT * FROM style_parameter WHERE style_id = ".
1483 $ilDB->quote($this->
getId(),
"integer").
" ORDER BY tag, class, type, mq_id ";
1484 $style_set = $ilDB->query($q);
1489 $this->style = array();
1493 $this->end_styles = array();
1494 while($style_rec = $ilDB->fetchAssoc($style_set))
1496 if ($style_rec[
"tag"] != $ctag || $style_rec[
"class"] != $cclass
1497 || $style_rec[
"type"] != $ctype || $style_rec[
"mq_id"] != $cmq_id)
1502 if (in_array($ctype, array(
"ha_iheada",
"va_iheada")))
1504 $this->end_styles[] = $tag;
1508 $this->style[] = $tag;
1513 $ctag = $style_rec[
"tag"];
1514 $cclass = $style_rec[
"class"];
1515 $ctype = $style_rec[
"type"];
1516 $cmq_id = $style_rec[
"mq_id"];
1517 $tag[] = $style_rec;
1519 $this->style_class[$ctype][$cclass][$cmq_id][$style_rec[
"parameter"]] = $style_rec[
"value"];
1523 $this->style[] = $tag;
1525 foreach ($this->end_styles as $s)
1527 $this->style[] = $s;
1530 $q =
"SELECT * FROM style_data WHERE id = ".
1531 $ilDB->quote($this->
getId(),
"integer");
1532 $res = $ilDB->query($q);
1533 $sty = $ilDB->fetchAssoc(
$res);
1538 $this->chars = array();
1539 $this->chars_by_type = array();
1540 $q =
"SELECT * FROM style_char WHERE style_id = ".
1541 $ilDB->quote($this->
getId(),
"integer").
1542 " ORDER BY type ASC, characteristic ASC";
1543 $par_set = $ilDB->query($q);
1544 while($par_rec = $ilDB->fetchAssoc($par_set))
1546 $this->chars[] = array(
"type" => $par_rec[
"type"],
"class" => $par_rec[
"characteristic"],
"hide" => $par_rec[
"hide"]);
1547 $this->chars_by_type[$par_rec[
"type"]][] = $par_rec[
"characteristic"];
1548 if ($par_rec[
"hide"])
1550 $this->hidden_chars[$par_rec[
"type"].
":".$par_rec[
"characteristic"]] =
true;
1563 if ($a_target_file ==
"")
1569 $css_file_name = $a_target_file;
1571 $css_file = fopen($css_file_name,
"w");
1573 $page_background =
"";
1575 $mqs = array(array(
"mquery" =>
"",
"id" => 0));
1582 foreach ($mqs as $mq)
1586 fwrite ($css_file,
"@media ".$mq[
"mquery"].
" {\n");
1589 foreach ($style as $tag)
1591 if ($tag[0][
"mq_id"] != $mq[
"id"])
1595 fwrite ($css_file, $tag[0][
"tag"].
".ilc_".$tag[0][
"type"].
"_".$tag[0][
"class"].
"\n");
1596 if ($tag[0][
"tag"] ==
"td")
1598 fwrite ($css_file,
",th".
".ilc_".$tag[0][
"type"].
"_".$tag[0][
"class"].
"\n");
1600 if (in_array($tag[0][
"tag"], array(
"h1",
"h2",
"h3")))
1602 fwrite ($css_file,
",div.ilc_text_block_".$tag[0][
"class"].
"\n");
1603 fwrite ($css_file,
",body.ilc_text_block_".$tag[0][
"class"].
"\n");
1605 if ($tag[0][
"type"] ==
"text_block")
1607 fwrite ($css_file,
",body.ilc_text_block_".$tag[0][
"class"].
"\n");
1609 fwrite ($css_file,
"{\n");
1612 $t_border = array();
1614 foreach($tag as $par)
1616 $cur_par = $par[
"parameter"];
1617 $cur_val = $par[
"value"];
1620 if (is_int(strpos($cur_par,
"color")) && substr(trim($cur_val), 0, 1) ==
"!")
1625 if ($tag[0][
"type"] ==
"table" && is_int(strpos($par[
"parameter"],
"border")))
1627 $t_border[$cur_par] = $cur_val;
1630 if (in_array($cur_par, array(
"background-image",
"list-style-image")))
1632 if (is_int(strpos($cur_val,
"/")))
1634 $cur_val =
"url(".$cur_val.
")";
1638 if ($a_image_dir ==
"")
1640 $cur_val =
"url(../sty/sty_".$this->getId().
"/images/".$cur_val.
")";
1644 $cur_val =
"url(".$a_image_dir.
"/".$cur_val.
")";
1649 if ($cur_par ==
"opacity")
1651 $cur_val = ((int) $cur_val) / 100;
1654 fwrite ($css_file,
"\t".$cur_par.
": ".$cur_val.
";\n");
1657 if ($cur_par ==
"min-height")
1659 fwrite ($css_file,
"\t".
"height".
": ".
"auto !important".
";\n");
1660 fwrite ($css_file,
"\t".
"height".
": ".$cur_val.
";\n");
1664 if ($cur_par ==
"opacity")
1666 fwrite ($css_file,
"\t".
'-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity='.($cur_val * 100).
')"'.
";\n");
1667 fwrite ($css_file,
"\t".
'filter: alpha(opacity='.($cur_val * 100).
')'.
";\n");
1668 fwrite ($css_file,
"\t".
'-moz-opacity: '.$cur_val.
";\n");
1672 if ($cur_par ==
"transform")
1674 fwrite ($css_file,
"\t".
'-webkit-transform: '.$cur_val.
";\n");
1675 fwrite ($css_file,
"\t".
'-moz-transform: '.$cur_val.
";\n");
1676 fwrite ($css_file,
"\t".
'-ms-transform: '.$cur_val.
";\n");
1680 if ($cur_par ==
"transform-origin")
1682 fwrite ($css_file,
"\t".
'-webkit-transform-origin: '.$cur_val.
";\n");
1683 fwrite ($css_file,
"\t".
'-moz-transform-origin: '.$cur_val.
";\n");
1684 fwrite ($css_file,
"\t".
'-ms-transform-origin: '.$cur_val.
";\n");
1688 if ($tag[0][
"tag"] ==
"div" && $tag[0][
"class"] ==
"Page" 1689 && $cur_par ==
"background-color")
1691 $page_background = $cur_val;
1694 fwrite ($css_file,
"}\n");
1695 fwrite ($css_file,
"\n");
1715 if ($page_background !=
"")
1717 fwrite ($css_file,
"td.ilc_Page\n");
1718 fwrite ($css_file,
"{\n");
1719 fwrite ($css_file,
"\t".
"background-color: ".$page_background.
";\n");
1720 fwrite ($css_file,
"}\n");
1724 fwrite ($css_file,
"}\n");
1744 $fixed_style = $ilSetting->get(
"fixed_content_style_id");
1745 if ($fixed_style > 0)
1747 $a_style_id = $fixed_style;
1751 if ($a_style_id <= 0)
1753 $a_style_id = $ilSetting->get(
"default_content_style_id");
1772 if (is_array($this->style_class[$a_type][$a_class][$a_mq_id]))
1774 return $this->style_class[$a_type][$a_class][$a_mq_id];
1788 $rand = rand(1,999999);
1792 $fixed_style = $ilias->getSetting(
"fixed_content_style_id");
1793 if ($fixed_style > 0)
1795 $a_style_id = $fixed_style;
1799 if ($a_style_id <= 0)
1801 $a_style_id = $ilias->getSetting(
"default_content_style_id");
1810 $style->writeCSSFile();
1814 "/css/style_".$a_style_id.
".css?dummy=$rand";
1818 return "./Services/COPage/css/content.css";
1829 return "./Services/COPage/css/print_content.css";
1839 return "./Services/COPage/css/syntaxhighlight.css";
1849 return "./Services/COPage/css/placeholder.css";
1860 $q =
"UPDATE style_data ".
1861 "SET category = ".$ilDB->quote((
int) $this->
getScope(),
"integer").
1862 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
1863 $ilDB->manipulate($q);
1876 $q =
"UPDATE style_parameter SET VALUE = ".
1877 $ilDB->quote($a_value,
"text").
" WHERE id = ".
1878 $ilDB->quote($a_id,
"integer");
1879 $style_set = $ilDB->manipulate($q);
1887 function replaceStylePar($a_tag, $a_class, $a_par, $a_val, $a_type, $a_mq_id = 0, $a_custom =
false)
1892 function _replaceStylePar($style_id, $a_tag, $a_class, $a_par, $a_val, $a_type, $a_mq_id = 0, $a_custom =
false)
1896 $q =
"SELECT * FROM style_parameter WHERE ".
1897 " style_id = ".$ilDB->quote($style_id,
"integer").
" AND ".
1898 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1899 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1900 " mq_id = ".$ilDB->quote($a_mq_id,
"integer").
" AND ".
1901 " custom = ".$ilDB->quote($a_custom,
"integer").
" AND ".
1902 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1903 " parameter = ".$ilDB->quote($a_par,
"text");
1905 $set = $ilDB->query($q);
1907 if ($rec = $set->fetchRow())
1909 $q =
"UPDATE style_parameter SET ".
1910 " value = ".$ilDB->quote($a_val,
"text").
" WHERE ".
1911 " style_id = ".$ilDB->quote($style_id,
"integer").
" AND ".
1912 " tag = ".$ilDB->quote($a_tag,
"text").
" AND ".
1913 " class = ".$ilDB->quote($a_class,
"text").
" AND ".
1914 " mq_id = ".$ilDB->quote($a_mq_id,
"integer").
" AND ".
1915 " custom = ".$ilDB->quote($a_custom,
"integer").
" AND ".
1916 " ".$ilDB->equals(
"type", $a_type,
"text",
true).
" AND ".
1917 " parameter = ".$ilDB->quote($a_par,
"text");
1919 $ilDB->manipulate($q);
1923 $id = $ilDB->nextId(
"style_parameter");
1924 $q =
"INSERT INTO style_parameter (id, value, style_id, tag, class, type, parameter, mq_id, custom) VALUES ".
1926 $ilDB->quote(
$id,
"integer").
",".
1927 $ilDB->quote($a_val,
"text").
",".
1928 " ".$ilDB->quote($this->
getId(),
"integer").
",".
1929 " ".$ilDB->quote($a_tag,
"text").
",".
1930 " ".$ilDB->quote($a_class,
"text").
",".
1931 " ".$ilDB->quote($a_type,
"text").
",".
1932 " ".$ilDB->quote($a_par,
"text").
",".
1933 " ".$ilDB->quote($a_mq_id,
"integer").
",".
1934 " ".$ilDB->quote($a_custom,
"integer").
1937 $ilDB->manipulate($q);
1955 $this->style = $a_style;
1967 return str_replace(
"&",
"&", $a_str);
1976 $xml.=
"<StyleSheet>\n";
1979 $xml.=
"<Title>".$this->handleXmlString($this->
getTitle()).
"</Title>";
1980 $xml.=
"<Description>".$this->handleXmlString($this->
getDescription()).
"</Description>\n";
1983 foreach($this->chars as $char)
1985 $xml.=
"<Style Tag=\"".ilObjStyleSheet::_determineTag($char[
"type"]).
1986 "\" Type=\"".$char[
"type"].
"\" Class=\"".$char[
"class"].
"\">\n";
1987 foreach($this->style as $style)
1989 if ($style[0][
"type"] == $char[
"type"] && $style[0][
"class"] == $char[
"class"])
1991 foreach($style as $tag)
1993 $xml.=
"<StyleParameter Name=\"".$tag[
"parameter"].
"\" Value=\"".$tag[
"value"].
"\" Custom=\"".$tag[
"custom"].
"\" />\n";
1997 $xml.=
"</Style>\n";
2003 $xml.=
"<StyleColor Name=\"".$color[
"name"].
"\" Code=\"".$color[
"code"].
"\"/>\n";
2008 foreach ($tcts as $tct => $v)
2014 $xml.=
"<StyleTemplate Type=\"".$tct.
"\" Name=\"".$t[
"name"].
"\">\n";
2015 foreach ($t[
"classes"] as $ct => $c)
2019 $xml.=
"<StyleTemplateClass ClassType=\"".$ct.
"\" Class=\"".$c.
"\"/>\n";
2022 $xml.=
"</StyleTemplate>\n";
2027 $xml.=
"</StyleSheet>";
2040 if(!is_writable($sty_data_dir))
2042 $this->
ilias->raiseError(
"Style data directory (".$sty_data_dir
2043 .
") not writeable.",$this->
ilias->error_obj->FATAL);
2046 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
2048 if(!@is_dir($style_dir))
2050 $this->
ilias->raiseError(
"Creation of style directory failed (".
2051 $style_dir.
").",$this->ilias->error_obj->FATAL);
2055 $ex_dir = $style_dir.
"/export";
2057 if(!@is_dir($ex_dir))
2059 $this->
ilias->raiseError(
"Creation of Import Directory failed (".
2060 $ex_dir.
").",$this->ilias->error_obj->FATAL);
2072 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
2074 $ex_dir = $style_dir.
"/export";
2076 if (is_dir($ex_dir))
2091 if(!is_writable($ex_sub_dir))
2093 $this->
ilias->raiseError(
"Style data directory (".$ex_sub_dir
2094 .
") not writeable.",$this->
ilias->error_obj->FATAL);
2096 $ex_sub_images_dir = $ex_sub_dir.
"/images";
2098 if(!is_writable($ex_sub_images_dir))
2100 $this->
ilias->raiseError(
"Style data directory (".$ex_sub_images_dir
2101 .
") not writeable.",$this->
ilias->error_obj->FATAL);
2110 $this->export_sub_dir = $a_dir;
2118 if ($this->export_sub_dir ==
"")
2120 return "sty_".$this->getId();
2124 return $this->export_sub_dir;
2138 $this->
exportXML($ex_dir.
"/".$this->getExportSubDir());
2141 $ex_dir.
"/".$this->getExportSubDir().
"/images");
2142 if (is_file($ex_dir.
"/".$this->getExportSubDir().
".zip"))
2144 unlink($ex_dir.
"/".$this->getExportSubDir().
".zip");
2157 $file = $a_dir.
"/style.xml";
2160 if (!($fp = @fopen(
$file,
"w")))
2162 die (
"<b>Error</b>: Could not open \"".
$file.
"\" for writing".
2163 " in <b>".__FILE__.
"</b> on line <b>".__LINE__.
"</b><br />");
2170 fwrite($fp, $this->
getXML());
2184 if(!is_writable($sty_data_dir))
2186 $this->
ilias->raiseError(
"Style data directory (".$sty_data_dir
2187 .
") not writeable.",$this->
ilias->error_obj->FATAL);
2190 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
2192 if(!@is_dir($style_dir))
2194 $this->
ilias->raiseError(
"Creation of style directory failed (".
2195 $style_dir.
").",$this->ilias->error_obj->FATAL);
2199 $im_dir = $style_dir.
"/import";
2201 if(!@is_dir($im_dir))
2203 $this->
ilias->raiseError(
"Creation of Import Directory failed (".
2204 $im_dir.
").",$this->ilias->error_obj->FATAL);
2213 function import($a_file)
2220 if (is_array($a_file))
2223 $a_file[
"name"], $im_dir.
"/".$a_file[
"name"]);
2224 $file_name = $a_file[
"name"];
2228 $pi = pathinfo($a_file);
2229 $file_name = $pi[
"basename"];
2230 copy($a_file, $im_dir.
"/".$file_name);
2232 $file = pathinfo($file_name);
2235 if (strtolower(
$file[
"extension"] ==
"zip"))
2238 $subdir = basename(
$file[
"basename"],
".".
$file[
"extension"]);
2239 if (!is_dir($im_dir.
"/".$subdir))
2243 $xml_file = $im_dir.
"/".$subdir.
"/style.xml";
2247 $xml_file = $im_dir.
"/".$file_name;
2256 if (is_dir($im_dir.
"/".$subdir.
"/images"))
2259 $this->getImagesDirectory());
2275 $this->is_3_10_skin =
false;
2277 if (!$a_skip_parent_create)
2281 include_once(
"./Services/Style/classes/class.ilStyleImportParser.php");
2283 $importParser->startParsing();
2286 foreach ($this->style as $style)
2288 foreach($style as $tag)
2290 $id = $ilDB->nextId(
"style_parameter");
2293 if (in_array($tag[
"class"], array(
"PageFrame",
"PageContainer")) &&
2294 $tag[
"tag"] ==
"table")
2296 $tag[
"tag"] =
"div";
2297 if ($tag[
"parameter"] ==
"width" && $tag[
"value"] ==
"100%")
2303 $q =
"INSERT INTO style_parameter (id,style_id, tag, class, parameter, type, value, custom) VALUES ".
2305 $ilDB->quote(
$id,
"integer").
",".
2306 $ilDB->quote($this->
getId(),
"integer").
",".
2307 $ilDB->quote($tag[
"tag"],
"text").
",".
2308 $ilDB->quote($tag[
"class"],
"text").
",".
2309 $ilDB->quote($tag[
"parameter"],
"text").
",".
2310 $ilDB->quote($tag[
"type"],
"text").
",".
2311 $ilDB->quote($tag[
"value"],
"text").
",".
2312 $ilDB->quote((
bool) $tag[
"custom"],
"integer").
2314 $ilDB->manipulate($q);
2319 $this->is_3_10_skin =
true;
2320 if (is_array($this->chars))
2322 foreach ($this->chars as $char)
2324 if ($char[
"type"] !=
"")
2326 $s = substr($char[
"class"], strlen($char[
"class"]) - 6);
2329 $q =
"INSERT INTO style_char (style_id, type, characteristic) VALUES ".
2330 "(".$ilDB->quote($this->
getId(),
"integer").
",".
2331 $ilDB->quote($char[
"type"],
"text").
",".
2332 $ilDB->quote($char[
"class"],
"text").
")";
2333 $ilDB->manipulate($q);
2334 $this->is_3_10_skin =
false;
2341 $q =
"INSERT INTO style_data (id, uptodate) VALUES ".
2342 "(".$ilDB->quote($this->
getId(),
"integer").
", 0)";
2343 $ilDB->manipulate($q);
2348 if ($this->is_3_10_skin)
2362 foreach (self::$parameter as
$parameter => $props)
2371 $input = self::$parameter[$par][
"input"];
2377 $subpar = self::$parameter[$par][
"subpar"];
2385 return self::$parameter;
2388 foreach (self::$parameter as $k => $v)
2390 if (is_array(self::$filtered_groups[$v[
"group"]]) &&
2391 !in_array($a_tag, self::$filtered_groups[$v[
"group"]]))
2402 return self::$filtered_groups;
2407 if ($a_no_percentage)
2409 return self::$num_unit_no_perc;
2411 return self::$num_unit;
2416 return self::$parameter[$par][
"values"];
2426 return self::$style_super_types;
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)
2443 if (in_array($a_type,
$t))
2459 $c_styles = array();
2460 foreach (self::$core_styles as $cstyle)
2463 = array(
"type" => $cstyle[
"type"],
2465 "class" => $cstyle[
"class"]);
2475 if ($a_template_type ==
"")
2477 return self::$templates;
2480 return self::$templates[$a_template_type];
2486 return self::$pseudo_classes[$tag];
2491 return self::$templates[
$t][$k];
2496 return self::$assigned_tags[$a_type];
2505 foreach(self::$parameter as $p => $v)
2507 $pars[$p] = $v[
"values"];
2519 $styles = array(array(
"id" => $a_id));
2531 if ($a_styles ==
"")
2537 $styles = $a_styles;
2543 $core_images = array();
2544 $core_dir = self::$basic_style_image_dir;
2545 if (is_dir($core_dir))
2547 $dir = opendir($core_dir);
2548 while(
$file = readdir($dir))
2550 if (substr(
$file, 0, 1) !=
"." && is_file($core_dir.
"/".
$file))
2552 $core_images[] =
$file;
2557 foreach ($styles as $style)
2564 $set = $ilDB->queryF(
"SELECT * FROM style_char WHERE style_id = %s ".
2565 "AND type = %s AND characteristic = %s",
2566 array(
"integer",
"text",
"text"),
2567 array(
$id, $cs[
"type"], $cs[
"class"]));
2570 if (!($rec = $ilDB->fetchAssoc($set)))
2573 "INSERT INTO style_char (style_id, type, characteristic) ".
2574 " VALUES (%s,%s,%s) ",
2575 array(
"integer",
"text",
"text"),
2576 array(
$id, $cs[
"type"], $cs[
"class"]));
2578 $xpath =
new DOMXPath($bdom);
2579 $par_nodes = $xpath->query(
"/StyleSheet/Style[@Tag = '".$cs[
"tag"].
"' and @Type='".
2580 $cs[
"type"].
"' and @Class='".$cs[
"class"].
"']/StyleParameter");
2581 foreach ($par_nodes as $par_node)
2584 $set = $ilDB->queryF(
"SELECT * FROM style_parameter WHERE style_id = %s ".
2585 "AND type = %s AND class = %s AND tag = %s AND parameter = %s",
2586 array(
"integer",
"text",
"text",
"text",
"text"),
2587 array(
$id, $cs[
"type"], $cs[
"class"],
2588 $cs[
"tag"], $par_node->getAttribute(
"Name")));
2591 if (!($rec = $ilDB->fetchAssoc($set)))
2593 $spid = $ilDB->nextId(
"style_parameter");
2594 $st = $ilDB->manipulateF(
"INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value) ".
2595 " VALUES (%s,%s,%s,%s,%s,%s,%s)",
2596 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"text"),
2597 array($spid,
$id, $cs[
"type"], $cs[
"class"], $cs[
"tag"],
2598 $par_node->getAttribute(
"Name"), $par_node->getAttribute(
"Value")));
2607 reset($core_images);
2608 foreach($core_images as $cim)
2610 if (!is_file($imdir.
"/".$cim))
2612 copy($core_dir.
"/".$cim, $imdir.
"/".$cim);
2637 $st = $ilDB->prepareManip(
"UPDATE style_char SET type = ? WHERE characteristic = ?".
2638 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2639 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2640 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2641 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2642 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2643 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2644 $ilDB->execute($st, array(
"page_cont",
"Page", $this->
getId()));
2647 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET type = ? WHERE class = ?".
2648 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2649 $ilDB->execute($st, array(
"media_cont",
"Media", $this->
getId()));
2650 $ilDB->execute($st, array(
"media_caption",
"MediaCaption", $this->
getId()));
2651 $ilDB->execute($st, array(
"page_fn",
"Footnote", $this->
getId()));
2652 $ilDB->execute($st, array(
"page_nav",
"LMNavigation", $this->
getId()));
2653 $ilDB->execute($st, array(
"page_title",
"PageTitle", $this->
getId()));
2654 $ilDB->execute($st, array(
"table",
"Page", $this->
getId()));
2656 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET tag = ? WHERE class = ?".
2657 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2658 $ilDB->execute($st, array(
"div",
"MediaCaption", $this->
getId()));
2661 $st = $ilDB->prepareManip(
"UPDATE style_char SET characteristic = ? WHERE characteristic = ?".
2662 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2663 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2664 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2667 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET class = ? WHERE class = ?".
2668 " AND style_id = ? ", array(
"text",
"text",
"integer"));
2669 $ilDB->execute($st, array(
"MediaContainer",
"Media", $this->
getId()));
2670 $ilDB->execute($st, array(
"PageContainer",
"Page", $this->
getId()));
2673 $st = $ilDB->prepareManip(
"DELETE FROM style_char WHERE type = ?".
2674 " AND style_id = ? ", array(
"text",
"integer"));
2675 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2676 $st = $ilDB->prepareManip(
"DELETE FROM style_parameter WHERE type = ?".
2677 " AND style_id = ? ", array(
"text",
"integer"));
2678 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
2695 $add_str =
" AND style_id = ".$ilDB->quote($a_id,
"integer");
2698 $set = $ilDB->query($q =
"SELECT DISTINCT style_id, tag, class FROM style_parameter WHERE ".
2699 $ilDB->equals(
"type",
"",
"text",
true).
" ".$add_str);
2701 while ($rec = $ilDB->fetchAssoc($set))
2705 switch ($rec[
"tag"])
2709 if (in_array($rec[
"class"], array(
"Headline3",
"Headline1",
2710 "Headline2",
"TableContent",
"List",
"Standard",
"Remark",
2711 "Additional",
"Mnemonic",
"Citation",
"Example")))
2713 $types[] =
"text_block";
2715 if (in_array($rec[
"class"], array(
"Block",
"Remark",
2716 "Additional",
"Mnemonic",
"Example",
"Excursus",
"Special")))
2718 $types[] =
"section";
2720 if (in_array($rec[
"class"], array(
"Page",
"Footnote",
"PageTitle",
"LMNavigation")))
2727 $types[] =
"table_cell";
2731 if (in_array($rec[
"class"], array(
"ExtLink",
"IntLink",
"FootnoteLink")))
2738 $types[] =
"text_inline";
2747 foreach ($types as
$t)
2750 $set4 = $ilDB->queryF(
"SELECT * FROM style_char ".
2751 " WHERE style_id = %s AND type = %s AND characteristic = %s",
2752 array(
"integer",
"text",
"text"),
2753 array($rec[
"style_id"], $t, $rec[
"class"]));
2754 if ($rec4 = $ilDB->fetchAssoc($set4))
2761 $ilDB->manipulateF(
"INSERT INTO style_char ".
2762 " (style_id, type, characteristic) VALUES ".
2764 array(
"integer",
"text",
"text"),
2765 array($rec[
"style_id"], $t, $rec[
"class"]));
2770 if ($rec[
"type"] ==
"")
2772 if (count($types) > 0)
2774 $ilDB->manipulateF(
"UPDATE style_parameter SET type = %s ".
2775 " WHERE style_id = %s AND class = %s AND ".$ilDB->equals(
"type",
"",
"text",
true),
2776 array(
"text",
"integer",
"text"),
2777 array($types[0], $rec[
"style_id"], $rec[
"class"]));
2781 if ($types[0] ==
"link")
2783 $ilDB->manipulateF(
"UPDATE style_parameter SET type = %s ".
2784 " WHERE style_id = %s AND (class = %s OR class = %s) AND ".$ilDB->equals(
"type",
"",
"text",
true),
2785 array(
"text",
"integer",
"text",
"text"),
2786 array($types[0], $rec[
"style_id"], $rec[
"class"].
":visited",
2787 $rec[
"class"].
":hover"));
2791 if (count($types) == 2)
2795 $set2 = $ilDB->queryF(
"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]));
2799 while ($rec2 = $ilDB->fetchAssoc($set2))
2802 $set3 = $ilDB->queryF(
"SELECT * FROM style_parameter ".
2803 " WHERE style_id = %s AND tag = %s AND class = %s AND type = %s AND parameter = %s",
2804 array(
"integer",
"text",
"text",
"text",
"text"),
2805 array($rec[
"style_id"], $rec[
"tag"], $rec[
"class"], $types[1], $rec[
"parameter"]));
2806 if ($rec3 = $ilDB->fetchAssoc($set3))
2812 $nid = $ilDB->nextId(
"style_parameter");
2813 $ilDB->manipulateF(
"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]));
2833 $classes = array(
"Example",
"Additional",
"Citation",
"Mnemonic",
"Remark");
2834 $pars = array(
"margin-top",
"margin-bottom");
2836 foreach ($classes as $curr_class)
2838 foreach ($pars as $curr_par)
2840 $res2 = $ilDB->queryF(
"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));
2844 if ($row2 = $ilDB->fetchAssoc($res2))
2846 $ilDB->manipulateF(
"UPDATE style_parameter SET value= %s WHERE id = %s",
2847 array(
"text",
"integer"),
2848 array(
"10px", $row2[
"id"]));
2852 $nid = $ilDB->nextId(
"style_parameter");
2853 $ilDB->manipulateF(
"INSERT INTO style_parameter ".
2854 "(id, style_id, tag, class, parameter,value) VALUES (%s,%s,%s,%s,%s,%s)",
2855 array(
"integer",
"integer",
"text",
"text",
"text",
"text"),
2856 array($nid, $a_id,
"div", $curr_class, $curr_par,
"10px"));
2861 $ilDB->manipulateF(
"UPDATE style_parameter SET tag = %s WHERE tag = %s and style_id = %s",
2862 array(
"text",
"text",
"integer"),
2863 array(
"div",
"p", $a_id));
2878 $set = $ilDB->query(
"SELECT * FROM style_color WHERE ".
2879 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" ".
2880 "ORDER BY color_name");
2883 while ($rec = $ilDB->fetchAssoc($set))
2886 "name" => $rec[
"color_name"],
2887 "code" => $rec[
"color_code"]
2901 $ilDB->manipulate(
"INSERT INTO style_color (style_id, color_name, color_code)".
2903 $ilDB->quote($this->getId(),
"integer").
",".
2904 $ilDB->quote($a_name,
"text").
",".
2905 $ilDB->quote($a_code,
"text").
2918 $ilDB->manipulate(
"UPDATE style_color SET ".
2919 "color_name = ".$ilDB->quote($a_new_name,
"text").
", ".
2920 "color_code = ".$ilDB->quote($a_code,
"text").
2921 " WHERE style_id = ".$ilDB->quote($this->
getId(),
"integer").
2922 " AND color_name = ".$ilDB->quote($a_name,
"text"));
2926 if ($a_name != $a_new_name)
2928 $set = $ilDB->query(
"SELECT * FROM style_parameter ".
2929 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
2931 " parameter = ".$ilDB->quote(
"background-color",
"text").
" OR ".
2932 " parameter = ".$ilDB->quote(
"color",
"text").
" OR ".
2933 " parameter = ".$ilDB->quote(
"border-color",
"text").
" OR ".
2934 " parameter = ".$ilDB->quote(
"border-top-color",
"text").
" OR ".
2935 " parameter = ".$ilDB->quote(
"border-bottom-color",
"text").
" OR ".
2936 " parameter = ".$ilDB->quote(
"border-left-color",
"text").
" OR ".
2937 " parameter = ".$ilDB->quote(
"border-right-color",
"text").
2939 while ($rec = $ilDB->fetchAssoc($set))
2941 if ($rec[
"value"] ==
"!".$a_name ||
2942 is_int(strpos($rec[
"value"],
"!".$a_name.
"(")))
2946 $rec[
"parameter"], str_replace($a_name, $a_new_name, $rec[
"value"]), $rec[
"type"], $rec[
"mq_id"], $rec[
"custom"]);
2959 $ilDB->manipulate(
"DELETE FROM style_color WHERE ".
2960 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2961 " color_name = ".$ilDB->quote($a_name,
"text"));
2971 $set = $ilDB->query(
"SELECT * FROM style_color WHERE ".
2972 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2973 "color_name = ".$ilDB->quote($a_color_name,
"text"));
2974 if ($rec = $ilDB->fetchAssoc($set))
2988 $pos = strpos($a_name,
"(");
2991 $a_i = substr($a_name, $pos + 1);
2992 $a_i = str_replace(
")",
"", $a_i);
2993 $a_name = substr($a_name, 0, $pos);
2996 $set = $ilDB->query(
"SELECT color_code FROM style_color WHERE ".
2997 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
2998 " color_name = ".$ilDB->quote($a_name,
"text"));
2999 if ($rec = $ilDB->fetchAssoc($set))
3003 return "#".$rec[
"color_code"];
3007 return "#".ilObjStyleSheet::_getColorFlavor($rec[
"color_code"],
3023 $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)
3034 $rgb[$k] = str_pad(dechex($v), 2,
"0", STR_PAD_LEFT);
3037 return $rgb[
"r"].$rgb[
"g"].$rgb[
"b"];
3045 $r[
"r"] = substr($a_rgb, 0, 2);
3046 $r[
"g"] = substr($a_rgb, 2, 2);
3047 $r[
"b"] = substr($a_rgb, 4, 2);
3051 $r[
"r"] = (int) hexdec(
$r[
"r"]);
3052 $r[
"g"] = (int) hexdec(
$r[
"g"]);
3053 $r[
"b"] = (int) hexdec(
$r[
"b"]);
3064 $r = $a_rgb[
"r"] / 255;
3065 $g = $a_rgb[
"g"] / 255;
3066 $b = $a_rgb[
"b"] / 255;
3069 $max = max(
$r,$g,$b);
3070 $min = min(
$r,$g,$b);
3073 $l = ($max + $min) / 2;
3084 $s = ($max - $min) / ($max + $min);
3088 $s = ($max - $min) / (2.0 - $max - $min);
3093 $h = ($g - $b) / ($max - $min);
3095 else if ($g == $max)
3097 $h = 2.0 + ($b -
$r) / ($max - $min);
3099 else if ($b == $max)
3101 $h = 4.0 + (
$r - $g) / ($max - $min);
3105 $hls[
"h"] = round(($h / 6) * 255);
3106 $hls[
"l"] = round($l * 255);
3107 $hls[
"s"] = round($s * 255);
3117 $h = $a_hls[
"h"] / 255;
3118 $l = $a_hls[
"l"] / 255;
3119 $s = $a_hls[
"s"] / 255;
3121 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = 0;
3126 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = $l;
3133 $temp2 = $l * (1.0 + $s);
3137 $temp2 = $l + $s - $l * $s;
3140 $temp1 = 2.0 * $l - $temp2;
3143 # For each of R, G, B, compute another temporary value, temp3, as follows: 3144 foreach ($rgb as $k => $v)
3149 $temp3 = $h + 1.0 / 3.0;
3157 $temp3 = $h - 1.0/3.0;
3162 $temp3 = $temp3 + 1.0;
3166 $temp3 = $temp3 - 1.0;
3169 if (6.0 * $temp3 < 1)
3171 $rgb[$k] = $temp1 + ($temp2 - $temp1) * 6.0 * $temp3;
3173 else if (2.0 * $temp3 < 1)
3177 else if (3.0 * $temp3 < 2)
3179 $rgb[$k] = $temp1 + ($temp2 - $temp1) * ((2.0/3.0) - $temp3) * 6.0;
3188 $rgb[
"r"] = round($rgb[
"r"] * 255);
3189 $rgb[
"g"] = round($rgb[
"g"] * 255);
3190 $rgb[
"b"] = round($rgb[
"b"] * 255);
3210 $set = $ilDB->query(
"SELECT * FROM sty_media_query WHERE ".
3211 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" ".
3212 "ORDER BY order_nr");
3215 while ($rec = $ilDB->fetchAssoc($set))
3231 $id = $ilDB->nextId(
"sty_media_query");
3234 $ilDB->manipulate(
"INSERT INTO sty_media_query (id, style_id, mquery, order_nr)".
3236 $ilDB->quote(
$id,
"integer").
",".
3237 $ilDB->quote($this->
getId(),
"integer").
",".
3238 $ilDB->quote($a_mquery,
"text").
",".
3239 $ilDB->quote($order_nr,
"integer").
3253 $set = $ilDB->query(
"SELECT max(order_nr) mnr FROM sty_media_query ".
3254 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer")
3256 $rec = $ilDB->fetchAssoc($set);
3258 return (
int) $rec[
"mnr"];
3271 $ilDB->manipulate(
"UPDATE sty_media_query SET ".
3272 " mquery = ".$ilDB->quote($a_mquery,
"text").
3273 " WHERE id = ".$ilDB->quote($a_id,
"integer")
3287 $set = $ilDB->query(
"SELECT * FROM sty_media_query ".
3288 " WHERE id = ".$ilDB->quote($a_id,
"integer")
3290 return $ilDB->fetchAssoc($set);
3302 $ilDB->manipulate(
"DELETE FROM sty_media_query WHERE ".
3303 " style_id = ".$ilDB->quote($this->getId(),
"integer").
3304 " AND id = ".$ilDB->quote($a_id,
"integer")
3319 if (is_array ($a_order_nr))
3321 foreach ($mqueries as $k => $mq)
3323 $mqueries[$k][
"order_nr"] = $a_order_nr[$mq[
"id"]];
3328 foreach ($mqueries as $mq)
3330 $ilDB->manipulate(
"UPDATE sty_media_query SET ".
3331 " order_nr = ".$ilDB->quote($cnt,
"integer").
3332 " WHERE id = ".$ilDB->quote($mq[
"id"],
"integer")
3350 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
3351 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3352 "temp_type = ".$ilDB->quote($a_type,
"text").
" ".
3356 while ($rec = $ilDB->fetchAssoc($set))
3371 $set = $ilDB->query(
"SELECT * FROM style_template_class WHERE ".
3372 "template_id = ".$ilDB->quote($a_tid,
"integer"));
3375 while ($rec = $ilDB->fetchAssoc($set))
3377 $key = $rec[
"class_type"];
3378 $class[$key] = $rec[
"class"];
3392 $tid = $ilDB->nextId(
"style_template");
3393 $ilDB->manipulate($q =
"INSERT INTO style_template ".
3394 "(id, style_id, name, temp_type)".
3396 $ilDB->quote($tid,
"integer").
",".
3397 $ilDB->quote($this->
getId(),
"integer").
",".
3398 $ilDB->quote($a_name,
"text").
",".
3399 $ilDB->quote($a_type,
"text").
3402 foreach ($a_classes as
$t => $c)
3404 $ilDB->manipulate($q =
"INSERT INTO style_template_class ".
3405 "(template_id, class_type, class)".
3407 $ilDB->quote($tid,
"integer").
",".
3408 $ilDB->quote(
$t,
"text").
",".
3409 $ilDB->quote($c,
"text").
3413 include_once(
"./Services/Style/classes/class.ilObjStyleSheetGUI.php");
3427 $ilDB->manipulate(
"UPDATE style_template SET ".
3428 "name = ".$ilDB->quote($a_name,
"text").
3429 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3431 $ilDB->manipulate(
"DELETE FROM style_template_class WHERE ".
3432 "template_id = ".$ilDB->quote($a_t_id,
"integer")
3434 foreach ($a_classes as
$t => $c)
3436 $ilDB->manipulate($q =
"INSERT INTO style_template_class ".
3437 "(template_id, class_type, class)".
3439 $ilDB->quote($a_t_id,
"integer").
",".
3440 $ilDB->quote(
$t,
"text").
",".
3441 $ilDB->quote($c,
"text").
3454 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
3455 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3456 "name = ".$ilDB->quote($a_template_name,
"text"));
3457 if ($rec = $ilDB->fetchAssoc($set))
3471 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
3472 "style_id = ".$ilDB->quote($this->getId(),
"integer").
" ".
3473 " AND id = ".$ilDB->quote($a_t_id,
"integer"));
3475 if ($rec = $ilDB->fetchAssoc($set))
3492 $set = $ilDB->query(
"SELECT name FROM style_template WHERE ".
3493 " id = ".$ilDB->quote($a_t_id,
"integer"));
3495 if ($rec = $ilDB->fetchAssoc($set))
3497 return $rec[
"name"];
3510 $tag =
"<StyleTemplates>";
3512 $ttypes = array(
"table",
"vaccordion",
"haccordion");
3514 foreach ($ttypes as $ttype)
3533 $tag.=
'<StyleTemplate Name="'.$t[
"name"].
'">';
3535 foreach ($atts as
$type => $t)
3537 if ($c[
$type] !=
"")
3539 $tag.=
'<StyleClass Type="'.$type.
'" Value="'.$c[
$type].
'" />';
3543 $tag.=
"</StyleTemplate>";
3547 $tag.=
"</StyleTemplates>";
3559 $a_preview_html = str_replace(
' width=""',
"", $a_preview_html);
3560 $a_preview_html = str_replace(
' valign="top"',
"", $a_preview_html);
3561 $a_preview_html = str_replace(
'<div class="ilc_text_block_TableContent">',
"<div>", $a_preview_html);
3564 if (strlen($a_preview_html) > 4000)
3567 $a_preview_html =
"";
3569 $ilDB->manipulate(
"UPDATE style_template SET ".
3570 "preview = ".$ilDB->quote($a_preview_html,
"text").
3571 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3581 $set = $ilDB->query(
"SELECT preview FROM style_template ".
3582 " WHERE id = ".$ilDB->quote($a_t_id,
"integer"));
3583 if ($rec = $ilDB->fetchAssoc($set))
3585 return $rec[
"preview"];
3598 $set = $ilDB->query(
"SELECT id FROM style_template ".
3599 " WHERE style_id = ".$ilDB->quote($a_style_id,
"integer").
3600 " AND name = ".$ilDB->quote($a_name,
"text"));
3601 if ($rec = $ilDB->fetchAssoc($set))
3616 $ilDB->manipulate(
"DELETE FROM style_template WHERE ".
3617 " style_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
3618 " id = ".$ilDB->quote($a_t_id,
"integer"));
3620 $ilDB->manipulate(
"DELETE FROM style_template_class WHERE ".
3621 "template_id = ".$ilDB->quote($a_t_id,
"integer")
3633 $ilDB->manipulate(
"DELETE FROM style_setting WHERE ".
3634 " style_id = ".$ilDB->quote($this->getId(),
"integer").
3635 " AND name = ".$ilDB->quote($a_name,
"text")
3638 $ilDB->manipulate(
"INSERT INTO style_setting ".
3639 "(style_id, name, value) VALUES (".
3640 $ilDB->quote($this->getId(),
"integer").
",".
3641 $ilDB->quote($a_name,
"text").
",".
3642 $ilDB->quote($a_value,
"text").
3653 $set = $ilDB->query(
"SELECT value FROM style_setting ".
3654 " WHERE style_id = ".$ilDB->quote($this->getId(),
"integer").
3655 " AND name = ".$ilDB->quote($a_name,
"text")
3657 $rec = $ilDB->fetchAssoc($set);
3659 return $rec[
"value"];
3669 $ilDB->replace(
"style_usage", array(
3670 "obj_id" => array(
"integer", (
int) $a_obj_id)),
3672 "style_id" => array(
"integer", (
int) $a_style_id))
3683 $set = $ilDB->query(
"SELECT style_id FROM style_usage ".
3684 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")
3686 $rec = $ilDB->fetchAssoc($set);
3690 return (
int) $rec[
"style_id"];
static _lookupTemplateIdByName($a_style_id, $a_name)
Lookup table template preview.
_getTemplatePreview($a_style, $a_type, $a_t_id, $a_small_mode=false)
Get table template preview.
deleteMediaQuery($a_id)
Delete media query.
getXML()
get xml representation of style object todo: add mq_id
static _explodeRGB($a_rgb, $as_dec=false)
Explode an RGB string into an array.
static _getTemplateClassTypes($a_template_type="")
Get template class types.
getHideStatus($a_type, $a_char)
Get characteristic hide status.
removeColor($a_name)
Remove a color.
characteristicExists($a_char, $a_style_type)
Check whether characteristic exists.
exportXML($a_dir)
export style xml file to directory
static _HLSToRGB($a_hls)
HLS to RGB (both arrays, 0..255)
do_3_10_Migration()
Migrates 3.10 style to 3.11 style.
setCharacteristics($a_chars)
Set characteristics.
getColors()
Get colors of style.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
_lookupActive($a_id)
Lookup active flag.
read()
read style properties
static _determineTag($a_type)
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
_writeStandard($a_id, $a_std)
Write standard flag.
deleteParameter($a_id)
delete style parameter
addTemplate($a_type, $a_name, $a_classes)
Add table template.
_writeScope($a_id, $a_scope)
Write scope.
static $style_super_types
putInTree()
Put in tree (show error message, since styles do not use ref ids)
do_3_9_Migration($a_id)
Migrate old 3.9 styles.
getRefId()
Get ref id (show error message, since styles do not use ref ids)
getPlaceHolderStylePath()
get placeholder style path (for Page Layouts)
Class ilObject Basic functions for all objects.
copyImagesToDir($a_target)
Copy images to directory.
setExportSubDir($a_dir)
Set local directory, that will be included within the zip file.
deleteImage($a_file)
Delete an image.
lookupStyleSetting($a_name)
Lookup style setting.
setScope($a_scope)
Set scope.
updateMediaQuery($a_id, $a_mquery)
Update media query.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
_lookupContObjIdByStyleId($a_style_id)
lookup style sheet ID
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static _getStyleSuperTypeForType($a_type)
writeTemplatePreview($a_t_id, $a_preview_html)
Write table template preview.
static _lookupTitle($a_id)
lookup object title
deleteStyleParOfChar($a_type, $a_class)
Delete style parameters of characteristic.
deleteCustomStylePars($a_tag, $a_class, $a_type, $a_mq_id=0)
Delete style parameter by tag/class/parameter.
_lookupUpToDate($a_id)
Looup up to date.
writeCSSFile($a_target_file="", $a_image_dir="")
write css file to webspace directory
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _getStyleSuperTypes()
static lookupObjectStyle($a_obj_id)
Lookup object style.
& getMetaData()
get meta data object
getSyntaxStylePath()
get syntax style path
createExportSubDirectory()
Create export directory.
static _getAllReferences($a_id)
get all reference ids of object
lookupTemplateName($a_t_id)
Lookup table template name for template ID.
do_3_10_CharMigration($a_id="")
This is more or less a copy of Services/Migration/DBUpdate_1385/classes ilStyleMigration->addMissingS...
getThumbnailsDirectory()
Get thumbnails directory.
handleXmlString($a_str)
Handle xml strin.
_replaceStylePar($style_id, $a_tag, $a_class, $a_par, $a_val, $a_type, $a_mq_id=0, $a_custom=false)
static writeStyleUsage($a_obj_id, $a_style_id)
Write style usage.
addColor($a_name, $a_code)
Add color.
getTemplate($a_t_id)
Get template.
_getClonableContentStyles()
Get all clonable styles (active standard styles and individual learning module styles with write perm...
static _getBasicStyleDom()
Get basic style dom.
getImagesDirectory()
Get images directory.
templateExists($a_template_name)
Check whether template exists.
static resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop=false)
resize image
getCharacteristics($a_type="", $a_no_hidden=false)
Get characteristics.
static _addMissingStyleClassesToAllStyles($a_styles="")
Add missing style classes to all styles todo: add mq_id and custom handling.
getId()
get object id public
static _isExpandable($a_type)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
writeStyleSetting($a_name, $a_value)
Write Style Setting.
static _getFilteredGroups()
ilObjStyleSheet($a_id=0, $a_call_by_reference=false)
Constructor public.
getTemplateXML()
Get table template xml.
static _getCoreStyles()
Get core styles.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
_deleteStyleAssignments($a_style_id)
delete all style references to style
getTitle()
get object title public
uploadImage($a_file)
Upload image.
getDescription()
get object description
_getStandardStyles($a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
addParameter($a_tag, $a_par, $a_type, $a_mq_id=0, $a_custom=false)
write style parameter to db
redirection script todo: (a better solution should control the processing via a xml file) ...
setUpToDate($a_up_to_date=true)
Set style up to date (false + update will trigger css generation next time)
copyCharacteristic($a_from_style_id, $a_from_type, $a_from_char, $a_to_char)
Copy characteristic.
saveHideStatus($a_type, $a_char, $a_hide)
Save characteristic hide status.
setStyle($a_style)
set styles
getParametersOfClass($a_type, $a_class, $a_mq_id=0)
Get parameters of class.
static $basic_style_image_dir
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
getType()
get object type public
getStyleParameterGroups()
Get grouped parameter.
static _lookupType($a_id, $a_reference=false)
lookup object type
getContentPrintStyle()
get content print style
export()
Create export file.
getTemplates($a_type)
Get table templates of style.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
deleteStylePar($a_tag, $a_class, $a_par, $a_type, $a_mq_id=0, $a_custom=false)
Delete style parameter by tag/class/parameter.
_writeActive($a_id, $a_active)
Write active flag.
static _getColorFlavor($a_rgb, $a_i)
Get color flavor.
determineTemplateStyleClassType($t, $k)
updateColor($a_name, $a_new_name, $a_code)
Update color.
static _createImagesDirectory($a_style_id)
Create images directory <data_dir>/sty/sty_<id>/images.
createExportDirectory()
Create export directory.
getStyle()
todo: bad style! should return array of objects, not multi-dim-arrays
updateStyleParameter($a_id, $a_value)
update style parameter per id
_writeUpToDate($a_id, $a_up_to_date)
Write up to date.
static _addMissingStyleClassesToStyle($a_id)
Add missing style classes to all styles.
createReference()
Create a reference (show error message, since styles do not use ref ids)
static _getImagesDirectory($a_style_id)
Get images directory.
addCharacteristic($a_type, $a_char, $a_hidden=false)
Add characteristic.
static _RGBToHLS($a_rgb)
RGB to HLS (both arrays, 0..255)
_lookupStandard($a_id)
Lookup standard flag.
getTemplateClasses($a_tid)
Get template classes.
static _getStyleParameterValues($par)
getMaxMQueryOrderNr()
Get maximum media query order nr.
replaceStylePar($a_tag, $a_class, $a_par, $a_val, $a_type, $a_mq_id=0, $a_custom=false)
Set style parameter per tag/class/parameter.
static getDataDir()
get data directory (outside webspace)
colorExists($a_color_name)
Check whether color exists.
deleteCharacteristic($a_type, $a_tag, $a_class)
Delete Characteristic.
static _getStyleParameterNumericUnits($a_no_percentage=false)
getContentStylePath($a_style_id)
get content style path
create($a_from_style=0, $a_import_mode=false)
Create a new style.
getExportSubDir()
The local directory, that will be included within the zip file.
createImportDirectory()
Create import directory.
getColorCodeForName($a_name)
Remove a color.
updateTemplate($a_t_id, $a_name, $a_classes)
Update table template.
static _getStyleParameters($a_tag="")
removeTemplate($a_t_id)
Remove table template.
saveMediaQueryOrder($a_order_nr=null)
Save media query order.
setRefId()
Set ref id (show error message, since styles do not use ref ids)
static _isHideable($a_type)
assignMetaData(&$a_meta_data)
assign meta data object
cleanExportDirectory()
Clear export directory.
getImages()
Get images of style.
createFromXMLFile($a_file, $a_skip_parent_create=false)
create style from xml file todo: add mq_id and custom
static _getStyleParameterInputType($par)
_getObjectsDataForType($a_type, $a_omit_trash=false)
get all objects of a certain type
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
static _getStyleParameterSubPar($par)
createImagesDirectory()
Create images directory <data_dir>/sty/sty_<id>/images.
getMediaQueries()
Get colors of style.
ilClone()
clone style sheet (note: styles have no ref ids and return an object id)
getMediaQueryForId($a_id)
Get media query for id.
static getAvailableParameters()
Get available parameters.
lookupTemplatePreview($a_t_id)
Lookup table template preview.
getUpToDate()
Get up to date.
addMediaQuery($a_mquery)
Add media query.