5 require_once 
"./classes/class.ilObject.php";
 
   19         public static $num_unit = array(
"px", 
"em", 
"ex", 
"%", 
"pt", 
"pc", 
"in", 
"mm", 
"cm");
 
   25                                                 "values" => array(
"xx-small", 
"x-small", 
"small", 
"medium", 
"large", 
"x-large", 
"xx-large", 
"smaller", 
"larger"),
 
   26                                                 "input" => 
"fontsize",
 
   28                 "font-family" => array(
 
   32                 "font-style" => array(
 
   33                                                 "values" => array(
"italic", 
"oblique", 
"normal"),
 
   36                 "font-weight" => array(
 
   37                                                 "values" => array(
"bold", 
"normal", 
"bolder", 
"lighter"),
 
   40                 "font-variant" => array(
 
   41                                                 "values" => array(
"small-caps", 
"normal"),
 
   44                 "word-spacing" => array(
 
   46                                                 "input" => 
"numeric_no_perc",
 
   48                 "letter-spacing" => array(
 
   50                                                 "input" => 
"numeric_no_perc",
 
   52                 "text-decoration" => array(
 
   53                                                 "values" => array(
"underline", 
"overline", 
"line-through", 
"blink", 
"none"),
 
   56                 "text-transform" => array(
 
   57                                                 "values" => array(
"capitalize", 
"uppercase", 
"lowercase", 
"none"),
 
   64                 "text-indent" => array(
 
   68                 "line-height" => array(
 
   72                 "vertical-align" => array(
 
   73                                                 "values" => array(
"top", 
"middle", 
"bottom", 
"baseline", 
"sub", 
"super",
 
   74                                                         "text-top", 
"text-bottom"),
 
   77                 "text-align" => array(
 
   78                                                 "values" => array(
"left", 
"center", 
"right", 
"justify"),
 
   81                 "white-space" => array(
 
   82                                                 "values" => array(
"normal", 
"pre", 
"nowrap"),
 
   87                                                 "input" => 
"trbl_numeric",
 
   88                                                 "subpar" => array(
"margin", 
"margin-top", 
"margin-right",
 
   89                                                         "margin-bottom", 
"margin-left"),
 
   90                                                 "group" => 
"margin_and_padding"),
 
   93                                                 "input" => 
"trbl_numeric",
 
   94                                                 "subpar" => array(
"padding", 
"padding-top", 
"padding-right",
 
   95                                                         "padding-bottom", 
"padding-left"),
 
   96                                                 "group" => 
"margin_and_padding"),
 
   97                 "border-width" => array(
 
   98                                                 "values" => array(
"thin", 
"medium", 
"thick"),
 
   99                                                 "input" => 
"border_width",
 
  100                                                 "subpar" => array(
"border-width", 
"border-top-width", 
"border-right-width",
 
  101                                                         "border-bottom-width", 
"border-left-width"),
 
  102                                                 "group" => 
"border"),
 
  103                 "border-color" => array(
 
  105                                                 "input" => 
"trbl_color",
 
  106                                                 "subpar" => array(
"border-color", 
"border-top-color", 
"border-right-color",
 
  107                                                         "border-bottom-color", 
"border-left-color"),
 
  108                                                 "group" => 
"border"),
 
  109                 "border-style" => array(
 
  110                                                 "values" => array(
"none", 
"hidden", 
"dotted", 
"dashed", 
"solid", 
"double",
 
  111                                                         "groove", 
"ridge", 
"inset", 
"outset"),
 
  112                                                 "input" => 
"border_style",
 
  113                                                 "subpar" => array(
"border-style", 
"border-top-style", 
"border-right-style",
 
  114                                                         "border-bottom-style", 
"border-left-style"),
 
  115                                                 "group" => 
"border"),
 
  117                 "background-color" => array(
 
  120                                                 "group" => 
"background"),
 
  121                 "background-image" => array(
 
  123                                                 "input" => 
"background_image",
 
  124                                                 "group" => 
"background"),
 
  125                 "background-repeat" => array(
 
  126                                                 "values" => array(
"repeat", 
"repeat-x", 
"repeat-y", 
"no-repeat"),
 
  128                                                 "group" => 
"background"),
 
  129                 "background-attachment" => array(
 
  130                                                 "values" => array(
"fixed", 
"scroll"),
 
  132                                                 "group" => 
"background"),
 
  133                 "background-position" => array(
 
  134                                                 "values" => array(
"horizontal" => array(
"left", 
"center", 
"right"),
 
  135                                                         "vertical" => array(
"top", 
"center", 
"bottom")),
 
  136                                                 "input" => 
"background_position",
 
  137                                                 "group" => 
"background"),
 
  140                                                 "values" => array(
"absolute", 
"fixed", 
"relative", 
"static"),
 
  142                                                 "group" => 
"positioning"),
 
  145                                                 "input" => 
"numeric",
 
  146                                                 "group" => 
"positioning"),
 
  149                                                 "input" => 
"numeric",
 
  150                                                 "group" => 
"positioning"),
 
  153                                                 "input" => 
"numeric",
 
  154                                                 "group" => 
"positioning"),
 
  157                                                 "input" => 
"numeric",
 
  158                                                 "group" => 
"positioning"),
 
  161                                                 "input" => 
"numeric",
 
  162                                                 "group" => 
"positioning"),
 
  165                                                 "input" => 
"numeric",
 
  166                                                 "group" => 
"positioning"),
 
  167                 "min-height" => array(
 
  169                                                 "input" => 
"numeric",
 
  170                                                 "group" => 
"positioning"),
 
  172                                                 "values" => array(
"left", 
"right", 
"none"),
 
  174                                                 "group" => 
"positioning"),
 
  176                                                 "values" => array(
"visible", 
"hidden", 
"scroll", 
"auto"),
 
  178                                                 "group" => 
"positioning"),
 
  182                                                 "input" => 
"percentage",
 
  183                                                 "group" => 
"special"),
 
  185                                                 "values" => array(
"auto", 
"default", 
"crosshair", 
"pointer", 
"move",
 
  186                                                         "n-resize", 
"ne-resize", 
"e-resize", 
"se-resize", 
"s-resize", 
"sw-resize",
 
  187                                                         "w-resize", 
"nw-resize", 
"text", 
"wait", 
"help"),
 
  189                                                 "group" => 
"special"),
 
  191                                                 "values" => array (
"both",
"left",
"right",
"none"),
 
  193                                                 "group" => 
"special"),
 
  195                 "list-style-type.ol" => array(
 
  196                                                 "values" => array (
"decimal",
"lower-roman",
"upper-roman",
 
  197                                                         "lower-alpha", 
"upper-alpha", 
"lower-greek", 
"hebrew",
 
  198                                                         "decimal-leading-zero", 
"cjk-ideographic", 
"hiragana",
 
  199                                                         "katakana", 
"hiragana-iroha", 
"katakana-iroha", 
"none"),
 
  202                 "list-style-type.ul" => array(
 
  203                                                 "values" => array (
"disc",
"circle",
"square",
 
  207                 "list-style-image.ul" => array(
 
  209                                                 "input" => 
"background_image",
 
  211                 "list-style-position.ol" => array(
 
  212                                                 "values" => array (
"inside",
"outside"),
 
  215                 "list-style-position.ul" => array(
 
  216                                                 "values" => array (
"inside",
"outside"),
 
  220                 "border-collapse" => array(
 
  221                                                 "values" => array (
"collapse",
"separate"),
 
  225                 "caption-side" => array(
 
  226                                                 "values" => array (
"top",
"bottom",
"left",
"right"),
 
  235                         array(
"ol" => array(
"ol"), 
"ul" => array(
"ul"),
 
  236                                 "table" => array(
"table"), 
"positioning" => array(
"h1", 
"h2", 
"h3", 
"div", 
"img", 
"table"));
 
  240                 "text_block" => array(
"text_block", 
"heading1", 
"heading2", 
"heading3"),
 
  241                 "text_inline" => array(
"text_inline"),
 
  242                 "section" => array(
"section"),
 
  243                 "link" => array(
"link"),
 
  244                 "table" => array(
"table", 
"table_cell", 
"table_caption"),
 
  245                 "list" => array(
"list_o", 
"list_u", 
"list_item"),
 
  246                 "flist" => array(
"flist_cont", 
"flist_head", 
"flist", 
"flist_li", 
"flist_a"),
 
  247                 "media" => array(
"media_cont", 
"media_caption"),
 
  248                 "tabs" => array(
"va_cntr", 
"va_icntr", 
"va_ihead", 
"va_icont",
 
  249                         "ha_cntr", 
"ha_icntr", 
"ha_ihead", 
"ha_icont"),
 
  250                 "question" => array(
"question", 
"qtitle", 
"qanswer", 
"qinput", 
"qlinput", 
"qsubmit", 
"qfeedr", 
"qfeedw"),
 
  251                 "page" => array(
"page_frame", 
"page_cont", 
"page_title", 
"page_fn",
 
  252                         "page_tnav", 
"page_bnav", 
"page_lnav", 
"page_rnav", 
"page_lnavlink", 
"page_rnavlink",
 
  253                         "page_lnavimage", 
"page_rnavimage"),
 
  254                 "glo" => array(
"glo_overlay", 
"glo_ovtitle", 
"glo_ovclink", 
"glo_ovuglink", 
"glo_ovuglistlink"),
 
  255                 "sco" => array(
"sco_title", 
"sco_keyw", 
"sco_desc", 
"sco_desct", 
"sco_obj", 
"sco_objt")
 
  260                         "text_block", 
"section", 
"media_cont", 
"table", 
"table_cell", 
"flist_li", 
"table_caption",
 
  262                                 "va_cntr", 
"va_icntr", 
"va_ihead", 
"va_icont",
 
  263                                 "ha_cntr", 
"ha_icntr", 
"ha_ihead", 
"ha_icont" 
  268                         "table", 
"table_cell" 
  273                 "text_block" => 
"div",
 
  277                 "text_inline" => 
"span",
 
  281                 "table_cell" => 
"td",
 
  282                 "table_caption" => 
"caption",
 
  283                 "media_cont" => 
"table",
 
  284                 "media_caption" => 
"div",
 
  285                 "glo_overlay" => 
"div",
 
  286                 "glo_ovtitle" => 
"h1",
 
  287                 "glo_ovclink" => 
"a",
 
  288                 "glo_ovuglink" => 
"a",
 
  289                 "glo_ovuglistlink" => 
"a",
 
  290                 "sco_title" => 
"div",
 
  294                 "sco_desct" => 
"div",
 
  299                 "flist_cont" => 
"div",
 
  300                 "flist_head" => 
"div",
 
  308                 "qlinput" => 
"textarea",
 
  309                 "qsubmit" => 
"input",
 
  312                 "page_frame" => 
"table",
 
  313                 "page_cont" => 
"table",
 
  315                 "page_tnav" => 
"div",
 
  316                 "page_bnav" => 
"div",
 
  317                 "page_lnav" => 
"div",
 
  318                 "page_rnav" => 
"div",
 
  319                 "page_lnavlink" => 
"a",
 
  320                 "page_rnavlink" => 
"a",
 
  321                 "page_lnavimage" => 
"img",
 
  322                 "page_rnavimage" => 
"img",
 
  323                 "page_title" => 
"h1",
 
  336                 array (
"a" => array(
"hover"), 
"div" => array(
"hover"), 
"img" => array(
"hover"));
 
  340                         array(
"type" => 
"text_block", 
"class" => 
"Standard"),
 
  341                         array(
"type" => 
"text_block", 
"class" => 
"List"),
 
  342                         array(
"type" => 
"text_block", 
"class" => 
"TableContent"),
 
  343                         array(
"type" => 
"heading1", 
"class" => 
"Headline1"),
 
  344                         array(
"type" => 
"heading2", 
"class" => 
"Headline2"),
 
  345                         array(
"type" => 
"heading3", 
"class" => 
"Headline3"),
 
  346                         array(
"type" => 
"text_inline", 
"class" => 
"Comment"),
 
  347                         array(
"type" => 
"text_inline", 
"class" => 
"Emph"),
 
  348                         array(
"type" => 
"text_inline", 
"class" => 
"Quotation"),
 
  349                         array(
"type" => 
"text_inline", 
"class" => 
"Strong"),
 
  350                         array(
"type" => 
"text_inline", 
"class" => 
"Accent"),
 
  351                         array(
"type" => 
"text_inline", 
"class" => 
"Important"),
 
  352                         array(
"type" => 
"link", 
"class" => 
"IntLink"),
 
  353                         array(
"type" => 
"link", 
"class" => 
"ExtLink"),
 
  354                         array(
"type" => 
"link", 
"class" => 
"FootnoteLink"),
 
  355                         array(
"type" => 
"link", 
"class" => 
"FileLink"),
 
  356                         array(
"type" => 
"link", 
"class" => 
"GlossaryLink"),
 
  357                         array(
"type" => 
"media_cont", 
"class" => 
"MediaContainer"),
 
  358                         array(
"type" => 
"table", 
"class" => 
"StandardTable"),
 
  359                         array(
"type" => 
"media_caption", 
"class" => 
"MediaCaption"),
 
  360                         array(
"type" => 
"page_frame", 
"class" => 
"PageFrame"),
 
  361                         array(
"type" => 
"page_cont", 
"class" => 
"PageContainer"),
 
  362                         array(
"type" => 
"page_tnav", 
"class" => 
"TopNavigation"),
 
  363                         array(
"type" => 
"page_bnav", 
"class" => 
"BottomNavigation"),
 
  364                         array(
"type" => 
"page_lnav", 
"class" => 
"LeftNavigation"),
 
  365                         array(
"type" => 
"page_rnav", 
"class" => 
"RightNavigation"),
 
  366                         array(
"type" => 
"page_lnavlink", 
"class" => 
"LeftNavigationLink"),
 
  367                         array(
"type" => 
"page_rnavlink", 
"class" => 
"RightNavigationLink"),
 
  368                         array(
"type" => 
"page_lnavimage", 
"class" => 
"LeftNavigationImage"),
 
  369                         array(
"type" => 
"page_rnavimage", 
"class" => 
"RightNavigationImage"),
 
  370                         array(
"type" => 
"page_fn", 
"class" => 
"Footnote"),
 
  371                         array(
"type" => 
"page_title", 
"class" => 
"PageTitle"),
 
  372                         array(
"type" => 
"glo_overlay", 
"class" => 
"GlossaryOverlay"),
 
  373                         array(
"type" => 
"glo_ovtitle", 
"class" => 
"GlossaryOvTitle"),
 
  374                         array(
"type" => 
"glo_ovclink", 
"class" => 
"GlossaryOvCloseLink"),
 
  375                         array(
"type" => 
"glo_ovuglink", 
"class" => 
"GlossaryOvUnitGloLink"),
 
  376                         array(
"type" => 
"glo_ovuglistlink", 
"class" => 
"GlossaryOvUGListLink"),
 
  377                         array(
"type" => 
"sco_title", 
"class" => 
"Title"),
 
  378                         array(
"type" => 
"sco_desc", 
"class" => 
"Description"),
 
  379                         array(
"type" => 
"sco_desct", 
"class" => 
"DescriptionTop"),
 
  380                         array(
"type" => 
"sco_keyw", 
"class" => 
"Keywords"),
 
  381                         array(
"type" => 
"sco_obj", 
"class" => 
"Objective"),
 
  382                         array(
"type" => 
"sco_objt", 
"class" => 
"ObjectiveTop"),
 
  383                         array(
"type" => 
"list_o", 
"class" => 
"NumberedList"),
 
  384                         array(
"type" => 
"list_u", 
"class" => 
"BulletedList"),
 
  385                         array(
"type" => 
"list_item", 
"class" => 
"StandardListItem"),
 
  386                         array(
"type" => 
"question", 
"class" => 
"Standard"),
 
  387                         array(
"type" => 
"question", 
"class" => 
"SingleChoice"),
 
  388                         array(
"type" => 
"question", 
"class" => 
"MultipleChoice"),
 
  389                         array(
"type" => 
"question", 
"class" => 
"TextQuestion"),
 
  390                         array(
"type" => 
"question", 
"class" => 
"OrderingQuestion"),
 
  391                         array(
"type" => 
"question", 
"class" => 
"MatchingQuestion"),
 
  392                         array(
"type" => 
"question", 
"class" => 
"ImagemapQuestion"),
 
  393                         array(
"type" => 
"question", 
"class" => 
"ClozeTest"),
 
  394                         array(
"type" => 
"qtitle", 
"class" => 
"Title"),
 
  395                         array(
"type" => 
"qanswer", 
"class" => 
"Answer"),
 
  396                         array(
"type" => 
"qinput", 
"class" => 
"TextInput"),
 
  397                         array(
"type" => 
"qlinput", 
"class" => 
"LongTextInput"),
 
  398                         array(
"type" => 
"qsubmit", 
"class" => 
"Submit"),
 
  399                         array(
"type" => 
"qfeedr", 
"class" => 
"FeedbackRight"),
 
  400                         array(
"type" => 
"qfeedw", 
"class" => 
"FeedbackWrong"),
 
  401                         array(
"type" => 
"flist_cont", 
"class" => 
"FileListContainer"),
 
  402                         array(
"type" => 
"flist_head", 
"class" => 
"FileListHeading"),
 
  403                         array(
"type" => 
"flist", 
"class" => 
"FileList"),
 
  404                         array(
"type" => 
"flist_li", 
"class" => 
"FileListItem"),
 
  405                         array(
"type" => 
"flist_a", 
"class" => 
"FileListItemLink")
 
  411                         "caption" => 
"table_caption",
 
  412                         "row_head" => 
"table_cell",
 
  413                         "row_foot" => 
"table_cell",
 
  414                         "col_head" => 
"table_cell",
 
  415                         "col_foot" => 
"table_cell",
 
  416                         "odd_row" => 
"table_cell",
 
  417                         "even_row" => 
"table_cell",
 
  418                         "odd_col" => 
"table_cell",
 
  419                         "even_col" => 
"table_cell"),
 
  420                 "vaccordion" => array(
 
  421                         "va_cntr" => 
"va_cntr",
 
  422                         "va_icntr" => 
"va_icntr",
 
  423                         "va_ihead" => 
"va_ihead",
 
  424                         "va_icont" => 
"va_icont" 
  426                 "haccordion" => array(
 
  427                         "ha_cntr" => 
"ha_cntr",
 
  428                         "ha_icntr" => 
"ha_icntr",
 
  429                         "ha_ihead" => 
"ha_ihead",
 
  430                         "ha_icont" => 
"ha_icont" 
  448                 $this->style = array();
 
  449                 if($a_call_by_reference)
 
  451                         $this->ilias->raiseError(
"Can't instantiate style object via reference id.",$this->ilias->error_obj->FATAL);
 
  462                 $this->ilias->raiseError(
"Operation ilObjStyleSheet::setRefId() not allowed.",$this->ilias->error_obj->FATAL);
 
  479                 $this->ilias->raiseError(
"Operation ilObjStyleSheet::putInTree() not allowed.",$this->ilias->error_obj->FATAL);
 
  487                 $this->ilias->raiseError(
"Operation ilObjStyleSheet::createReference() not allowed.",$this->ilias->error_obj->FATAL);
 
  495                 $this->up_to_date = $a_up_to_date;
 
  503                 return $this->up_to_date;
 
  511                 $this->scope = $a_scope;
 
  529                 $q = 
"UPDATE style_data SET uptodate = ".
 
  530                         $ilDB->quote((
int) $a_up_to_date, 
"integer").
 
  531                         " WHERE id = ".$ilDB->quote($a_id, 
"integer");
 
  532                 $ilDB->manipulate($q);
 
  542                 $q = 
"SELECT uptodate FROM style_data ".
 
  543                         " WHERE id = ".$ilDB->quote($a_id, 
"integer");
 
  544                 $res = $ilDB->query($q);
 
  545                 $sty = $ilDB->fetchAssoc(
$res);
 
  547                 return (
boolean) $sty[
"uptodate"];
 
  557                 $q = 
"UPDATE style_data SET standard = ".
 
  558                         $ilDB->quote((
int) $a_std, 
"integer").
 
  559                         " WHERE id = ".$ilDB->quote($a_id, 
"integer");
 
  560                 $ilDB->manipulate($q);
 
  570                 $q = 
"UPDATE style_data SET category = ".
 
  571                         $ilDB->quote((
int) $a_scope, 
"integer").
 
  572                         " WHERE id = ".$ilDB->quote($a_id, 
"integer");
 
  573                 $ilDB->manipulate($q);
 
  583                 $q = 
"SELECT * FROM style_data ".
 
  584                         " WHERE id = ".$ilDB->quote($a_id, 
"integer");
 
  585                 $res = $ilDB->query($q);
 
  586                 $sty = $ilDB->fetchAssoc(
$res);
 
  588                 return (
boolean) $sty[
"standard"];
 
  598                 $q = 
"UPDATE style_data SET active = ".
 
  599                         $ilDB->quote((
int) $a_active, 
"integer").
 
  600                         " WHERE id = ".$ilDB->quote($a_id, 
"integer");
 
  601                 $ilDB->manipulate($q);
 
  611                 $q = 
"SELECT * FROM style_data ".
 
  612                         " WHERE id = ".$ilDB->quote($a_id, 
"integer");
 
  613                 $res = $ilDB->query($q);
 
  614                 $sty = $ilDB->fetchAssoc(
$res);
 
  616                 return (
boolean) $sty[
"active"];
 
  623                 $a_include_deactivated = 
false, $a_scope = 0)
 
  627                 $default_style = $ilias->getSetting(
"default_content_style_id");
 
  630                 if (!$a_include_deactivated)
 
  632                         $and_str = 
" AND active = 1";
 
  635                 $q = 
"SELECT * FROM style_data ".
 
  636                         " WHERE standard = 1".$and_str;
 
  637                 $res = $ilDB->query($q);
 
  639                 while($sty = $ilDB->fetchAssoc(
$res))
 
  641                         if (!$a_exclude_default_style || $default_style != $sty[
"id"])
 
  644                                 if ($a_scope > 0 && $sty[
"category"] > 0)
 
  646                                         if ($tree->isInTree($sty[
"category"]) &&
 
  647                                                 $tree->isInTree($a_scope))
 
  649                                                 $path = $tree->getPathId($a_scope);
 
  650                                                 if (!in_array($sty[
"category"], 
$path))
 
  670                 global $ilAccess, 
$ilDB;
 
  672                 $clonable_styles = array();
 
  674                 $q = 
"SELECT * FROM style_data";
 
  675                 $style_set = $ilDB->query($q);
 
  676                 while($style_rec = $ilDB->fetchAssoc($style_set))
 
  679                         if ($style_rec[
"standard"] == 1)
 
  681                                 if ($style_rec[
"active"] == 1)
 
  688                                 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
 
  690                                 foreach($obj_ids as 
$id)
 
  695                                                 if ($ilAccess->checkAccess(
"write", 
"", $ref_id))
 
  704                                 $clonable_styles[$style_rec[
"id"]] =
 
  708                 return $clonable_styles;
 
  716                 $this->meta_data =& $a_meta_data;
 
  726                 if (!is_object(self::$basic_style_dom))
 
  728                         self::$basic_style_dom = 
new DOMDocument();
 
  729                         self::$basic_style_dom->load(self::$basic_style_file);
 
  740                 return $this->meta_data;
 
  746         function create($a_from_style = 0, $a_import_mode = 
false)
 
  752                 if ($a_from_style == 0)
 
  769                         $q = 
"SELECT * FROM style_parameter WHERE style_id = ".
 
  770                                 $ilDB->quote($a_from_style, 
"integer");
 
  771                         $par_set = $ilDB->query($q);
 
  772                         while($par_rec = $ilDB->fetchAssoc($par_set))
 
  774                                 $def[] = array(
"tag" => $par_rec[
"tag"], 
"class" => $par_rec[
"class"],
 
  775                                         "parameter" => $par_rec[
"parameter"], 
"value" => $par_rec[
"value"],
 
  776                                         "type" => $par_rec[
"type"]);
 
  781                         $q = 
"SELECT * FROM style_char WHERE style_id = ".
 
  782                                 $ilDB->quote($a_from_style, 
"integer");
 
  783                         $par_set = $ilDB->query($q);
 
  784                         while($par_rec = $ilDB->fetchAssoc($par_set))
 
  786                                 $chars[] = array(
"type" => $par_rec[
"type"], 
"characteristic" => $par_rec[
"characteristic"]);
 
  790                         foreach ($def as $sty)
 
  792                                 $id = $ilDB->nextId(
"style_parameter");
 
  793                                 $q = 
"INSERT INTO style_parameter (id, style_id, tag, class, parameter, value, type) VALUES ".
 
  795                                         $ilDB->quote(
$id, 
"integer").
",".
 
  796                                         $ilDB->quote($this->
getId(), 
"integer").
",".
 
  797                                         $ilDB->quote($sty[
"tag"], 
"text").
",".
 
  798                                         $ilDB->quote($sty[
"class"], 
"text").
",".
 
  799                                         $ilDB->quote($sty[
"parameter"], 
"text").
",".
 
  800                                         $ilDB->quote($sty[
"value"], 
"text").
",".
 
  801                                         $ilDB->quote($sty[
"type"], 
"text").
")";
 
  802                                 $ilDB->manipulate($q);
 
  806                         foreach ($chars as $char)
 
  808                                 $q = 
"INSERT INTO style_char (style_id, type, characteristic) VALUES ".
 
  809                                         "(".$ilDB->quote($this->
getId(), 
"integer").
",".
 
  810                                         $ilDB->quote($char[
"type"], 
"text").
",".
 
  811                                         $ilDB->quote($char[
"characteristic"], 
"text").
")";
 
  812                                 $ilDB->manipulate($q);
 
  816                         $q = 
"INSERT INTO style_data (id, uptodate, category) VALUES ".
 
  817                                 "(".$ilDB->quote($this->
getId(), 
"integer").
", 0,".
 
  818                                 $ilDB->quote((
int) $this->
getScope(), 
"integer").
")";
 
  819                         $ilDB->manipulate($q);
 
  828                         $colors = $from_style->getColors();
 
  829                         foreach ($colors as $c)
 
  831                                 $this->
addColor($c[
"name"], $c[
"code"]);
 
  836                         foreach ($tcts as $tct => $v)
 
  841                                         $this->
addTemplate($tct, $t[
"name"], $t[
"classes"]);
 
  863                 if (empty(
$core_styles[$a_type.
".".$a_tag.
".".$a_class]))
 
  866                         $st = $ilDB->manipulateF(
 
  867                                 "DELETE FROM style_char WHERE style_id = %s AND type = %s AND characteristic = %s",
 
  868                                 array(
"integer", 
"text", 
"text"),
 
  869                                 array($this->
getId(), $a_type, $a_class));
 
  872                         $st = $ilDB->manipulateF(
"DELETE FROM style_parameter WHERE style_id = %s AND tag = %s AND type = %s AND class = %s",
 
  873                                 array(
"integer", 
"text", 
"text", 
"text"),
 
  874                                 array($this->
getId(), $a_tag, $a_type, $a_class));
 
  888                 $set = $ilDB->queryF(
 
  889                         "SELECT style_id FROM style_char WHERE style_id = %s AND characteristic = %s AND type = %s",
 
  890                         array(
"integer", 
"text", 
"text"),
 
  891                         array($this->
getId(), $a_char, $a_style_type));
 
  892                 if ($rec = $ilDB->fetchAssoc($set))
 
  907                 $ilDB->manipulateF(
"INSERT INTO style_char (style_id, type, characteristic, hide)".
 
  908                         " VALUES (%s,%s,%s,%s) ",
 
  909                         array(
"integer", 
"text", 
"text", 
"integer"),
 
  910                         array($this->
getId(), $a_type, $a_char, $a_hidden));
 
  923                 $a_from_type, $a_from_char, $a_to_char)
 
  935                 $pars = $from_style->getParametersOfClass($a_from_type, $a_from_char);
 
  938                 foreach ($pars as $p => $v)
 
  940                         if (substr($v, 0, 1) == 
"!")
 
  942                                 $colors[] = substr($v, 1);
 
  945                                 $a_to_char, $p, $v, $a_from_type);
 
  949                 foreach ($colors as $c)
 
  953                                 $this->
addColor($c, $from_style->getColorCodeForName($c));
 
  967                         $chars = $this->chars;
 
  969                 if (is_array($this->chars_by_type[$a_type]))
 
  971                         $chars = $this->chars_by_type[$a_type];
 
  976                         foreach ($chars as $k => $char)
 
  978                                 if ($a_type == 
"" && $this->hidden_chars[$char[
"type"].
":".$char[
"class"]])
 
  982                                 else if ($this->hidden_chars[$a_type.
":".$char])
 
  997                 $this->chars = $a_chars;
 
 1008                 $ilDB->manipulate(
"UPDATE style_char SET ".
 
 1009                         " hide = ".$ilDB->quote((
int) $a_hide, 
"integer").
 
 1010                         " WHERE style_id = ".$ilDB->quote($this->
getId(), 
"integer").
" AND ".
 
 1011                         " type = ".$ilDB->quote($a_type, 
"text").
" AND ".
 
 1012                         " characteristic = ".$ilDB->quote($a_char, 
"text")
 
 1023                 $set = $ilDB->query(
"SELECT hide FROM  style_char ".
 
 1024                         " WHERE style_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 1025                         " type = ".$ilDB->quote($a_type, 
"text").
" AND ".
 
 1026                         " characteristic = ".$ilDB->quote($a_char, 
"text")
 
 1028                 $rec = $ilDB->fetchAssoc($set);
 
 1030                 return $rec[
"hide"];
 
 1044                 $new_obj->setTitle($this->
getTitle().
" (".$lng->txt(
"sty_acopy").
")");
 
 1045                 $new_obj->setType($this->
getType());
 
 1047                 $new_obj->create($this->
getId());
 
 1049                 return $new_obj->getId();
 
 1072                 $tag = explode(
".", $a_tag);
 
 1073                 $value = $avail_params[$a_par][0];
 
 1074                 $id = $ilDB->nextId(
"style_parameter");
 
 1075                 $q = 
"INSERT INTO style_parameter (id,style_id, type, tag, class, parameter, value) VALUES ".
 
 1077                         $ilDB->quote(
$id, 
"integer").
",".
 
 1078                         $ilDB->quote($this->
getId(), 
"integer").
",".
 
 1079                         $ilDB->quote($a_type, 
"text").
",".
 
 1080                         $ilDB->quote($tag[0], 
"text").
",".
 
 1081                         $ilDB->quote($tag[1], 
"text").
",".
 
 1082                         $ilDB->quote($a_par, 
"text").
",".
 
 1083                         $ilDB->quote($value, 
"text").
")";
 
 1084                 $ilDB->manipulate($q);
 
 1108                 if(!is_writable($sty_data_dir))
 
 1110                         $ilErr->raiseError(
"Style data directory (".$sty_data_dir
 
 1111                                 .
") not writeable.", $ilErr->FATAL);
 
 1114                 $style_dir = $sty_data_dir.
"/sty_".$a_style_id;
 
 1116                 if(!@is_dir($style_dir))
 
 1118                         $ilErr->raiseError(
"Creation of style directory failed (".
 
 1119                                 $style_dir.
").",$ilErr->FATAL);
 
 1123                 $im_dir = $style_dir.
"/images";
 
 1125                 if(!@is_dir($im_dir))
 
 1127                         $ilErr->raiseError(
"Creation of Import Directory failed (".
 
 1128                                 $im_dir.
").", $ilErr->FATAL);
 
 1132                 $thumb_dir = $style_dir.
"/images/thumbnails";
 
 1134                 if(!@is_dir($thumb_dir))
 
 1136                         $ilErr->raiseError(
"Creation of Import Directory failed (".
 
 1137                                 $thumb_dir.
").", $ilErr->FATAL);
 
 1177                         foreach($entries as $entry)
 
 1179                                 if (substr($entry[
"entry"],0,1) == 
".")
 
 1183                                 if ($entry[
"type"] != 
"dir")
 
 1229                 $q = 
"DELETE FROM style_parameter WHERE id = ".
 
 1230                         $ilDB->quote($a_id, 
"integer");
 
 1246                 $q = 
"DELETE FROM style_parameter WHERE ".
 
 1247                         " style_id = ".$ilDB->quote($this->
getId(), 
"integer").
" AND ".
 
 1248                         " tag = ".$ilDB->quote($a_tag, 
"text").
" AND ".
 
 1249                         " class = ".$ilDB->quote($a_class, 
"text").
" AND ".
 
 1250                         " ".$ilDB->equals(
"type", $a_type, 
"text", 
true).
" AND ".
 
 1251                         " parameter = ".$ilDB->quote($a_par, 
"text");
 
 1253                 $ilDB->manipulate($q);
 
 1268                 $q = 
"DELETE FROM style_parameter WHERE ".
 
 1269                         " style_id = ".$ilDB->quote($this->
getId(), 
"integer").
" AND ".
 
 1270                         " class = ".$ilDB->quote($a_class, 
"text").
" AND ".
 
 1271                         " ".$ilDB->equals(
"type", $a_type, 
"text", 
true);
 
 1273                 $ilDB->manipulate($q);
 
 1288                 $def_style = $this->ilias->getSetting(
"default_content_style_id");              
 
 1289                 if ($def_style == $this->
getId())
 
 1291                         $this->ilias->deleteSetting(
"default_content_style_id");
 
 1295                 $fixed_style = $this->ilias->getSetting(
"fixed_content_style_id");              
 
 1296                 if ($fixed_style == $this->
getId())
 
 1298                         $this->ilias->deleteSetting(
"fixed_content_style_id");
 
 1302                 $q = 
"DELETE FROM style_parameter WHERE style_id = ".
 
 1303                         $ilDB->quote($this->
getId(), 
"integer");
 
 1304                 $ilDB->manipulate($q);
 
 1308                 if (is_file($css_file_name))
 
 1310                         unlink($css_file_name);
 
 1314                 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
 
 1318                 $q = 
"DELETE FROM style_data WHERE id = ".
 
 1319                         $ilDB->quote($this->
getId(), 
"integer");
 
 1320                 $ilDB->manipulate($q);
 
 1334                 $q = 
"SELECT * FROM style_parameter WHERE style_id = ".
 
 1335                         $ilDB->quote($this->
getId(), 
"integer").
" ORDER BY tag, class, type ";
 
 1336                 $style_set = $ilDB->query($q);
 
 1340                 $this->style = array();
 
 1341                 while($style_rec = $ilDB->fetchAssoc($style_set))
 
 1343                         if ($style_rec[
"tag"] != $ctag || $style_rec[
"class"] != $cclass
 
 1344                                 || $style_rec[
"type"] != $ctype)
 
 1349                                         $this->style[] = $tag;
 
 1353                         $ctag = $style_rec[
"tag"];
 
 1354                         $cclass = $style_rec[
"class"];
 
 1355                         $ctype = $style_rec[
"type"];
 
 1356                         $tag[] = $style_rec;
 
 1357                         $this->style_class[$ctype][$cclass][$style_rec[
"parameter"]] = $style_rec[
"value"];
 
 1361                         $this->style[] = $tag;
 
 1364                 $q = 
"SELECT * FROM style_data WHERE id = ".
 
 1365                         $ilDB->quote($this->
getId(), 
"integer");
 
 1366                 $res = $ilDB->query($q);
 
 1367                 $sty = $ilDB->fetchAssoc(
$res);
 
 1372                 $this->chars = array();
 
 1373                 $this->chars_by_type = array();
 
 1374                 $q = 
"SELECT * FROM style_char WHERE style_id = ".
 
 1375                         $ilDB->quote($this->
getId(), 
"integer").
 
 1376                         " ORDER BY type ASC, characteristic ASC";
 
 1377                 $par_set = $ilDB->query($q);
 
 1378                 while($par_rec = $ilDB->fetchAssoc($par_set))
 
 1380                         $this->chars[] = array(
"type" => $par_rec[
"type"], 
"class" => $par_rec[
"characteristic"], 
"hide" => $par_rec[
"hide"]);
 
 1381                         $this->chars_by_type[$par_rec[
"type"]][] = $par_rec[
"characteristic"];
 
 1382                         if ($par_rec[
"hide"])
 
 1384                                 $this->hidden_chars[$par_rec[
"type"].
":".$par_rec[
"characteristic"]] = 
true;
 
 1396                 if ($a_target_file == 
"")
 
 1402                         $css_file_name = $a_target_file;
 
 1404                 $css_file = fopen($css_file_name, 
"w");
 
 1406                 $page_background = 
"";
 
 1410                         fwrite ($css_file, $tag[0][
"tag"].
".ilc_".$tag[0][
"type"].
"_".$tag[0][
"class"].
"\n");
 
 1411                         if ($tag[0][
"tag"] = 
"td")
 
 1413                                 fwrite ($css_file, 
",th".
".ilc_".$tag[0][
"type"].
"_".$tag[0][
"class"].
"\n");
 
 1415                         fwrite ($css_file, 
"{\n");
 
 1418                         $t_border = array();
 
 1420                         foreach($tag as $par)
 
 1422                                 $cur_par = $par[
"parameter"];
 
 1423                                 $cur_val = $par[
"value"];
 
 1426                                 if (is_int(strpos($cur_par, 
"color")) && substr(trim($cur_val), 0, 1) == 
"!")
 
 1431                                 if ($tag[0][
"type"] == 
"table" && is_int(strpos($par[
"parameter"], 
"border")))
 
 1433                                         $t_border[$cur_par] = $cur_val;
 
 1436                                 if (in_array($cur_par, array(
"background-image", 
"list-style-image")))
 
 1438                                         if (is_int(strpos($cur_val, 
"/")))      
 
 1440                                                 $cur_val = 
"url(".$cur_val.
")";
 
 1444                                                 if ($a_image_dir == 
"")
 
 1446                                                         $cur_val = 
"url(../sty/sty_".$this->getId().
"/images/".$cur_val.
")";
 
 1450                                                         $cur_val = 
"url(".$a_image_dir.
"/".$cur_val.
")";
 
 1455                                 if ($cur_par == 
"opacity")
 
 1457                                         $cur_val = ((int) $cur_val) / 100;
 
 1460                                 fwrite ($css_file, 
"\t".$cur_par.
": ".$cur_val.
";\n");
 
 1463                                 if ($cur_par == 
"min-height")
 
 1465                                         fwrite ($css_file, 
"\t".
"height".
": ".
"auto !important".
";\n");
 
 1466                                         fwrite ($css_file, 
"\t".
"height".
": ".$cur_val.
";\n");
 
 1470                                 if ($cur_par == 
"opacity")
 
 1472                                         fwrite ($css_file, 
"\t".
'-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity='.($cur_val * 100).
')"'.
";\n");
 
 1473                                         fwrite ($css_file, 
"\t".
'filter: alpha(opacity='.($cur_val * 100).
')'.
";\n");
 
 1474                                         fwrite ($css_file, 
"\t".
'-moz-opacity: '.$cur_val.
";\n");
 
 1478                                 if ($tag[0][
"tag"] == 
"div" && $tag[0][
"class"] == 
"Page" 
 1479                                         && $cur_par == 
"background-color")
 
 1481                                         $page_background = $cur_val;
 
 1484                         fwrite ($css_file, 
"}\n");
 
 1485                         fwrite ($css_file, 
"\n");
 
 1505                 if ($page_background != 
"")
 
 1507                         fwrite ($css_file, 
"td.ilc_Page\n");
 
 1508                         fwrite ($css_file, 
"{\n");
 
 1509                         fwrite ($css_file, 
"\t".
"background-color: ".$page_background.
";\n");
 
 1510                         fwrite ($css_file, 
"}\n");
 
 1529                 $fixed_style = $ilSetting->get(
"fixed_content_style_id");
 
 1530                 if ($fixed_style > 0)
 
 1532                         $a_style_id = $fixed_style;
 
 1536                 if ($a_style_id <= 0)
 
 1538                         $a_style_id = $ilSetting->get(
"default_content_style_id");
 
 1557                 if (is_array($this->style_class[$a_type][$a_class]))
 
 1559                         return $this->style_class[$a_type][$a_class];
 
 1573                 $rand = rand(1,999999);
 
 1577                 $fixed_style = $ilias->getSetting(
"fixed_content_style_id");
 
 1578                 if ($fixed_style > 0)
 
 1580                         $a_style_id = $fixed_style;
 
 1584                 if ($a_style_id <= 0)
 
 1586                         $a_style_id = $ilias->getSetting(
"default_content_style_id");
 
 1599                                 "/css/style_".$a_style_id.
".css?dummy=$rand";
 
 1603                         return "./Services/COPage/css/content.css";
 
 1614                 return "./Services/COPage/css/print_content.css";
 
 1624                 return "./Services/COPage/css/syntaxhighlight.css";
 
 1634                 return "./Services/COPage/css/placeholder.css";
 
 1645                 $q = 
"UPDATE style_data ".
 
 1646                         "SET category = ".$ilDB->quote((
int) $this->
getScope(), 
"integer").
 
 1647                         " WHERE id = ".$ilDB->quote($this->
getId(), 
"integer");
 
 1648                 $ilDB->manipulate($q);
 
 1661                 $q = 
"UPDATE style_parameter SET VALUE = ".
 
 1662                         $ilDB->quote($a_value, 
"text").
" WHERE id = ".
 
 1663                         $ilDB->quote($a_id, 
"integer");
 
 1664                 $style_set = $ilDB->manipulate($q);
 
 1680                 $q = 
"SELECT * FROM style_parameter WHERE ".
 
 1681                         " style_id = ".$ilDB->quote($style_id, 
"integer").
" AND ".
 
 1682                         " tag = ".$ilDB->quote($a_tag, 
"text").
" AND ".
 
 1683                         " class = ".$ilDB->quote($a_class, 
"text").
" AND ".
 
 1684                         " ".$ilDB->equals(
"type", $a_type, 
"text", 
true).
" AND ".
 
 1685                         " parameter = ".$ilDB->quote($a_par, 
"text");
 
 1687                 $set = $ilDB->query($q);
 
 1689                 if ($rec = $set->fetchRow())
 
 1691                         $q = 
"UPDATE style_parameter SET ".
 
 1692                                 " value = ".$ilDB->quote($a_val, 
"text").
" WHERE ".
 
 1693                                 " style_id = ".$ilDB->quote($style_id, 
"integer").
" AND ".
 
 1694                                 " tag = ".$ilDB->quote($a_tag, 
"text").
" AND ".
 
 1695                                 " class = ".$ilDB->quote($a_class, 
"text").
" AND ".
 
 1696                                 " ".$ilDB->equals(
"type", $a_type, 
"text", 
true).
" AND ".
 
 1697                                 " parameter = ".$ilDB->quote($a_par, 
"text");
 
 1699                         $ilDB->manipulate($q);
 
 1703                         $id = $ilDB->nextId(
"style_parameter");
 
 1704                         $q = 
"INSERT INTO style_parameter (id, value, style_id, tag,  class, type, parameter) VALUES ".
 
 1706                                 $ilDB->quote(
$id, 
"integer").
",".
 
 1707                                 $ilDB->quote($a_val, 
"text").
",".
 
 1708                                 " ".$ilDB->quote($this->
getId(), 
"integer").
",".
 
 1709                                 " ".$ilDB->quote($a_tag, 
"text").
",".
 
 1710                                 " ".$ilDB->quote($a_class, 
"text").
",".
 
 1711                                 " ".$ilDB->quote($a_type, 
"text").
",".
 
 1712                                 " ".$ilDB->quote($a_par, 
"text").
")";
 
 1714                         $ilDB->manipulate($q);
 
 1732                 $this->style = $a_style;
 
 1744                 return str_replace(
"&", 
"&", $a_str);
 
 1752                 $xml.= 
"<StyleSheet>\n";
 
 1755                 $xml.= 
"<Title>".$this->handleXmlString($this->
getTitle()).
"</Title>";
 
 1756                 $xml.= 
"<Description>".$this->handleXmlString($this->
getDescription()).
"</Description>\n";
 
 1759                 foreach($this->chars as $char)
 
 1761                         $xml.= 
"<Style Tag=\"".ilObjStyleSheet::_determineTag($char[
"type"]).
 
 1762                                 "\" Type=\"".$char[
"type"].
"\" Class=\"".$char[
"class"].
"\">\n";
 
 1763                         foreach($this->style as 
$style)
 
 1765                                 if ($style[0][
"type"] == $char[
"type"] && $style[0][
"class"] == $char[
"class"])
 
 1767                                         foreach($style as $tag)
 
 1769                                                 $xml.=
"<StyleParameter Name=\"".$tag[
"parameter"].
"\" Value=\"".$tag[
"value"].
"\"/>\n";
 
 1773                         $xml.= 
"</Style>\n";
 
 1779                         $xml.=
"<StyleColor Name=\"".$color[
"name"].
"\" Code=\"".$color[
"code"].
"\"/>\n";
 
 1784                 foreach ($tcts as $tct => $v)
 
 1790                                 $xml.=
"<StyleTemplate Type=\"".$tct.
"\" Name=\"".$t[
"name"].
"\">\n";
 
 1791                                 foreach ($t[
"classes"] as $ct => $c)
 
 1795                                                 $xml.=
"<StyleTemplateClass ClassType=\"".$ct.
"\" Class=\"".$c.
"\"/>\n";
 
 1798                                 $xml.=
"</StyleTemplate>\n";
 
 1803                 $xml.= 
"</StyleSheet>";
 
 1816                 if(!is_writable($sty_data_dir))
 
 1818                         $this->ilias->raiseError(
"Style data directory (".$sty_data_dir
 
 1819                                 .
") not writeable.",$this->ilias->error_obj->FATAL);
 
 1822                 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
 
 1824                 if(!@is_dir($style_dir))
 
 1826                         $this->ilias->raiseError(
"Creation of style directory failed (".
 
 1827                                 $style_dir.
").",$this->ilias->error_obj->FATAL);
 
 1831                 $ex_dir = $style_dir.
"/export";
 
 1833                 if(!@is_dir($ex_dir))
 
 1835                         $this->ilias->raiseError(
"Creation of Import Directory failed (".
 
 1836                                 $ex_dir.
").",$this->ilias->error_obj->FATAL);
 
 1848                 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
 
 1850                 $ex_dir = $style_dir.
"/export";
 
 1852                 if (is_dir($ex_dir))
 
 1867                 if(!is_writable($ex_sub_dir))
 
 1869                         $this->ilias->raiseError(
"Style data directory (".$ex_sub_dir
 
 1870                                 .
") not writeable.",$this->ilias->error_obj->FATAL);
 
 1872                 $ex_sub_images_dir = $ex_sub_dir.
"/images";
 
 1874                 if(!is_writable($ex_sub_images_dir))
 
 1876                         $this->ilias->raiseError(
"Style data directory (".$ex_sub_images_dir
 
 1877                                 .
") not writeable.",$this->ilias->error_obj->FATAL);
 
 1886                 $this->export_sub_dir = $a_dir;
 
 1894                 if ($this->export_sub_dir == 
"")
 
 1896                         return "sty_".$this->getId();
 
 1900                         return $this->export_sub_dir;
 
 1914                 $this->
exportXML($ex_dir.
"/".$this->getExportSubDir());
 
 1917                         $ex_dir.
"/".$this->getExportSubDir().
"/images");
 
 1918                 if (is_file($ex_dir.
"/".$this->getExportSubDir().
".zip"))
 
 1920                         unlink($ex_dir.
"/".$this->getExportSubDir().
".zip");
 
 1933                 $file = $a_dir.
"/style.xml";
 
 1936                 if (!($fp = @fopen(
$file,
"w")))
 
 1938                         die (
"<b>Error</b>: Could not open \"".
$file.
"\" for writing".
 
 1939                                         " in <b>".__FILE__.
"</b> on line <b>".__LINE__.
"</b><br />");
 
 1946                 fwrite($fp, $this->
getXML());
 
 1960                 if(!is_writable($sty_data_dir))
 
 1962                         $this->ilias->raiseError(
"Style data directory (".$sty_data_dir
 
 1963                                 .
") not writeable.",$this->ilias->error_obj->FATAL);
 
 1966                 $style_dir = $sty_data_dir.
"/sty_".$this->
getId();
 
 1968                 if(!@is_dir($style_dir))
 
 1970                         $this->ilias->raiseError(
"Creation of style directory failed (".
 
 1971                                 $style_dir.
").",$this->ilias->error_obj->FATAL);
 
 1975                 $im_dir = $style_dir.
"/import";
 
 1977                 if(!@is_dir($im_dir))
 
 1979                         $this->ilias->raiseError(
"Creation of Import Directory failed (".
 
 1980                                 $im_dir.
").",$this->ilias->error_obj->FATAL);
 
 1989         function import($a_file)
 
 1996                 if (is_array($a_file))
 
 1999                                 $a_file[
"name"], $im_dir.
"/".$a_file[
"name"]);
 
 2004                         $pi = pathinfo($a_file);
 
 2011                 if (strtolower(
$file[
"extension"] == 
"zip"))
 
 2014                         $subdir = basename(
$file[
"basename"],
".".
$file[
"extension"]);
 
 2015                         if (!is_dir($im_dir.
"/".$subdir))
 
 2019                         $xml_file = $im_dir.
"/".$subdir.
"/style.xml";
 
 2032                 if (is_dir($im_dir.
"/".$subdir.
"/images"))
 
 2035                                 $this->getImagesDirectory());
 
 2050                 $this->is_3_10_skin = 
false;
 
 2052                 if (!$a_skip_parent_create)
 
 2056                 include_once(
"./Services/Style/classes/class.ilStyleImportParser.php");
 
 2058                 $importParser->startParsing();
 
 2061                 foreach ($this->style as 
$style)
 
 2063                         foreach($style as $tag)
 
 2065                                 $id = $ilDB->nextId(
"style_parameter");
 
 2066                                 $q = 
"INSERT INTO style_parameter (id,style_id, tag, class, parameter, type, value) VALUES ".
 
 2068                                         $ilDB->quote(
$id, 
"integer").
",".
 
 2069                                         $ilDB->quote($this->
getId(), 
"integer").
",".
 
 2070                                         $ilDB->quote($tag[
"tag"], 
"text").
",".
 
 2071                                         $ilDB->quote($tag[
"class"], 
"text").
",".
 
 2072                                         $ilDB->quote($tag[
"parameter"], 
"text").
",".
 
 2073                                         $ilDB->quote($tag[
"type"], 
"text").
",".
 
 2074                                         $ilDB->quote($tag[
"value"], 
"text").
")";
 
 2076                                 $ilDB->manipulate($q);
 
 2081                 $this->is_3_10_skin = 
true;
 
 2082                 if (is_array($this->chars))
 
 2084                         foreach ($this->chars as $char)
 
 2086                                 if ($char[
"type"] != 
"")
 
 2088                                         $q = 
"INSERT INTO style_char (style_id, type, characteristic) VALUES ".
 
 2089                                                 "(".$ilDB->quote($this->
getId(), 
"integer").
",".
 
 2090                                                 $ilDB->quote($char[
"type"], 
"text").
",".
 
 2091                                                 $ilDB->quote($char[
"class"], 
"text").
")";
 
 2092                                         $ilDB->manipulate($q);
 
 2093                                         $this->is_3_10_skin = 
false;
 
 2099                 $q = 
"INSERT INTO style_data (id, uptodate) VALUES ".
 
 2100                         "(".$ilDB->quote($this->
getId(), 
"integer").
", 0)";
 
 2101                 $ilDB->manipulate($q);
 
 2106                 if ($this->is_3_10_skin)
 
 2120                 foreach (self::$parameter as 
$parameter => $props)
 
 2129                 $input = self::$parameter[$par][
"input"];
 
 2135                 $subpar = self::$parameter[$par][
"subpar"];
 
 2146                 foreach (self::$parameter as $k => $v)
 
 2148                         if (is_array(self::$filtered_groups[$v[
"group"]]) &&
 
 2149                                 !in_array($a_tag, self::$filtered_groups[$v[
"group"]]))
 
 2165                 if ($a_no_percentage)
 
 2174                 return self::$parameter[$par][
"values"];
 
 2189                 return in_array($a_type, self::$expandable_types);
 
 2194                 return in_array($a_type, self::$hideable_types);
 
 2199                 foreach (self::$style_super_types as $s => 
$t)
 
 2201                         if (in_array($a_type, 
$t))
 
 2217                 $c_styles = array();
 
 2218                 foreach (self::$core_styles as $cstyle)
 
 2221                                 = array(
"type" => $cstyle[
"type"],
 
 2223                                         "class" => $cstyle[
"class"]);
 
 2233                 if ($a_template_type == 
"")
 
 2238                 return self::$templates[$a_template_type];
 
 2244                 return self::$pseudo_classes[$tag];
 
 2249                 return self::$templates[
$t][$k];
 
 2254                 return self::$assigned_tags[$a_type];
 
 2263                 foreach(self::$parameter as $p => $v)
 
 2265                         $pars[$p] = $v[
"values"];
 
 2277                 $styles = array(array(
"id" => $a_id));
 
 2288                 if ($a_styles == 
"")
 
 2294                         $styles = $a_styles;
 
 2300                 $core_images = array();
 
 2302                 if (is_dir($core_dir))
 
 2304                         $dir = opendir($core_dir);
 
 2307                                 if (substr(
$file, 0, 1) != 
"." && is_file($core_dir.
"/".
$file))
 
 2309                                         $core_images[] = 
$file;
 
 2314                 foreach ($styles as 
$style)
 
 2321                                 $set = $ilDB->queryF(
"SELECT * FROM style_char WHERE style_id = %s ".
 
 2322                                         "AND type = %s AND characteristic = %s",
 
 2323                                         array(
"integer", 
"text", 
"text"),
 
 2324                                         array(
$id, $cs[
"type"], $cs[
"class"]));
 
 2327                                 if (!($rec = $ilDB->fetchAssoc($set)))
 
 2330                                                 "INSERT INTO style_char (style_id, type, characteristic) ".
 
 2331                                                 " VALUES (%s,%s,%s) ",
 
 2332                                                 array(
"integer", 
"text", 
"text"),
 
 2333                                                 array(
$id, $cs[
"type"], $cs[
"class"]));
 
 2335                                         $xpath = 
new DOMXPath($bdom);
 
 2336                                         $par_nodes = $xpath->query(
"/StyleSheet/Style[@Tag = '".$cs[
"tag"].
"' and @Type='".
 
 2337                                                 $cs[
"type"].
"' and @Class='".$cs[
"class"].
"']/StyleParameter");
 
 2338                                         foreach ($par_nodes as $par_node)
 
 2341                                                 $set = $ilDB->queryF(
"SELECT * FROM style_parameter WHERE style_id = %s ".
 
 2342                                                         "AND type = %s AND class = %s AND tag = %s AND parameter = %s",
 
 2343                                                         array(
"integer", 
"text", 
"text", 
"text", 
"text"),
 
 2344                                                         array(
$id, $cs[
"type"], $cs[
"class"],
 
 2345                                                         $cs[
"tag"], $par_node->getAttribute(
"Name")));
 
 2348                                                 if (!($rec = $ilDB->fetchAssoc($set)))
 
 2350                                                         $spid = $ilDB->nextId(
"style_parameter");
 
 2351                                                         $st = $ilDB->manipulateF(
"INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value) ".
 
 2352                                                                 " VALUES (%s,%s,%s,%s,%s,%s,%s)",
 
 2353                                                                 array(
"integer", 
"integer", 
"text", 
"text", 
"text", 
"text", 
"text"),
 
 2354                                                                 array($spid, 
$id, $cs[
"type"], $cs[
"class"], $cs[
"tag"],
 
 2355                                                                 $par_node->getAttribute(
"Name"), $par_node->getAttribute(
"Value")));
 
 2364                         reset($core_images);
 
 2365                         foreach($core_images as $cim)
 
 2367                                 if (!is_file($imdir.
"/".$cim))
 
 2369                                         copy($core_dir.
"/".$cim, $imdir.
"/".$cim);
 
 2394                 $st = $ilDB->prepareManip(
"UPDATE style_char SET type = ? WHERE characteristic = ?".
 
 2395                         " AND style_id = ? ", array(
"text", 
"text", 
"integer"));
 
 2396                 $ilDB->execute($st, array(
"media_cont", 
"Media", $this->
getId()));
 
 2397                 $ilDB->execute($st, array(
"media_caption", 
"MediaCaption", $this->
getId()));
 
 2398                 $ilDB->execute($st, array(
"page_fn", 
"Footnote", $this->
getId()));
 
 2399                 $ilDB->execute($st, array(
"page_nav", 
"LMNavigation", $this->
getId()));
 
 2400                 $ilDB->execute($st, array(
"page_title", 
"PageTitle", $this->
getId()));
 
 2401                 $ilDB->execute($st, array(
"page_cont", 
"Page", $this->
getId()));
 
 2404                 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET type = ? WHERE class = ?".
 
 2405                         " AND style_id = ? ", array(
"text", 
"text", 
"integer"));
 
 2406                 $ilDB->execute($st, array(
"media_cont", 
"Media", $this->
getId()));
 
 2407                 $ilDB->execute($st, array(
"media_caption", 
"MediaCaption", $this->
getId()));
 
 2408                 $ilDB->execute($st, array(
"page_fn", 
"Footnote", $this->
getId()));
 
 2409                 $ilDB->execute($st, array(
"page_nav", 
"LMNavigation", $this->
getId()));
 
 2410                 $ilDB->execute($st, array(
"page_title", 
"PageTitle", $this->
getId()));
 
 2411                 $ilDB->execute($st, array(
"table", 
"Page", $this->
getId()));
 
 2413                 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET tag = ? WHERE class = ?".
 
 2414                         " AND style_id = ? ", array(
"text", 
"text", 
"integer"));
 
 2415                 $ilDB->execute($st, array(
"div", 
"MediaCaption", $this->
getId()));
 
 2418                 $st = $ilDB->prepareManip(
"UPDATE style_char SET characteristic = ? WHERE characteristic = ?".
 
 2419                         " AND style_id = ? ", array(
"text", 
"text", 
"integer"));
 
 2420                 $ilDB->execute($st, array(
"MediaContainer", 
"Media", $this->
getId()));
 
 2421                 $ilDB->execute($st, array(
"PageContainer", 
"Page", $this->
getId()));
 
 2424                 $st = $ilDB->prepareManip(
"UPDATE style_parameter SET class = ? WHERE class = ?".
 
 2425                         " AND style_id = ? ", array(
"text", 
"text", 
"integer"));
 
 2426                 $ilDB->execute($st, array(
"MediaContainer", 
"Media", $this->
getId()));
 
 2427                 $ilDB->execute($st, array(
"PageContainer", 
"Page", $this->
getId()));
 
 2430                 $st = $ilDB->prepareManip(
"DELETE FROM style_char WHERE type = ?".
 
 2431                         " AND style_id = ? ", array(
"text", 
"integer"));
 
 2432                 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
 
 2433                 $st = $ilDB->prepareManip(
"DELETE FROM style_parameter WHERE type = ?".
 
 2434                         " AND style_id = ? ", array(
"text", 
"integer"));
 
 2435                 $ilDB->execute($st, array(
"page_cont", $this->
getId()));
 
 2452                         $add_str = 
" AND style_id = ".$ilDB->quote($a_id, 
"integer");
 
 2455                 $set = $ilDB->query($q = 
"SELECT DISTINCT style_id, tag, class FROM style_parameter WHERE ".
 
 2456                         $ilDB->equals(
"type", 
"", 
"text", 
true).
" ".$add_str);
 
 2458                 while ($rec = $ilDB->fetchAssoc($set))
 
 2462                         switch ($rec[
"tag"])
 
 2466                                         if (in_array($rec[
"class"], array(
"Headline3", 
"Headline1",
 
 2467                                                 "Headline2", 
"TableContent", 
"List", 
"Standard", 
"Remark",
 
 2468                                                 "Additional", 
"Mnemonic", 
"Citation", 
"Example")))
 
 2470                                                 $types[] = 
"text_block";
 
 2472                                         if (in_array($rec[
"class"], array(
"Block", 
"Remark",
 
 2473                                                 "Additional", 
"Mnemonic", 
"Example", 
"Excursus", 
"Special")))
 
 2475                                                 $types[] = 
"section";
 
 2477                                         if (in_array($rec[
"class"], array(
"Page", 
"Footnote", 
"PageTitle", 
"LMNavigation")))
 
 2484                                         $types[] = 
"table_cell";
 
 2488                                         if (in_array($rec[
"class"], array(
"ExtLink", 
"IntLink", 
"FootnoteLink")))
 
 2495                                         $types[] = 
"text_inline";
 
 2504                         foreach ($types as 
$t)
 
 2507                                 $set4 = $ilDB->queryF(
"SELECT * FROM style_char ".
 
 2508                                         " WHERE style_id = %s AND type = %s AND characteristic = %s",
 
 2509                                         array(
"integer", 
"text", 
"text"),
 
 2510                                         array($rec[
"style_id"], $t, $rec[
"class"]));
 
 2511                                 if ($rec4 = $ilDB->fetchAssoc($set4))
 
 2518                                         $ilDB->manipulateF(
"INSERT INTO style_char ".
 
 2519                                                 " (style_id, type, characteristic) VALUES ".
 
 2521                                                 array(
"integer", 
"text", 
"text"),
 
 2522                                                 array($rec[
"style_id"], $t, $rec[
"class"]));
 
 2527                         if ($rec[
"type"] == 
"")
 
 2529                                 if (count($types) > 0)
 
 2531                                         $ilDB->manipulateF(
"UPDATE style_parameter SET type = %s ".
 
 2532                                                 " WHERE style_id = %s AND class = %s AND ".$ilDB->equals(
"type", 
"", 
"text", 
true),
 
 2533                                                 array(
"text", 
"integer", 
"text"),
 
 2534                                                 array($types[0], $rec[
"style_id"], $rec[
"class"]));
 
 2538                                         if ($types[0] == 
"link")
 
 2540                                                 $ilDB->manipulateF(
"UPDATE style_parameter SET type = %s ".
 
 2541                                                         " WHERE style_id = %s AND (class = %s OR class = %s) AND ".$ilDB->equals(
"type", 
"", 
"text", 
true),
 
 2542                                                         array(
"text", 
"integer", 
"text", 
"text"),
 
 2543                                                         array($types[0], $rec[
"style_id"], $rec[
"class"].
":visited",
 
 2544                                                         $rec[
"class"].
":hover"));
 
 2548                                 if (count($types) == 2)
 
 2552                                         $set2 = $ilDB->queryF(
"SELECT * FROM style_parameter ".
 
 2553                                                 " WHERE style_id = %s AND class = %s AND type = %s",
 
 2554                                                 array(
"integer", 
"text", 
"text"),
 
 2555                                                 array($rec[
"style_id"], $rec[
"class"], $types[0]));
 
 2556                                         while ($rec2 = $ilDB->fetchAssoc($set2))
 
 2559                                                 $set3 = $ilDB->queryF(
"SELECT * FROM style_parameter ".
 
 2560                                                         " WHERE style_id = %s AND tag = %s AND class = %s AND type = %s AND parameter = %s",
 
 2561                                                         array(
"integer", 
"text", 
"text", 
"text", 
"text"),
 
 2562                                                         array($rec[
"style_id"], $rec[
"tag"], $rec[
"class"], $types[1], $rec[
"parameter"]));
 
 2563                                                 if ($rec3 = $ilDB->fetchAssoc($set3))
 
 2569                                                         $nid = $ilDB->nextId(
"style_parameter");
 
 2570                                                         $ilDB->manipulateF(
"INSERT INTO style_parameter ".
 
 2571                                                                 " (id, style_id, tag, class, parameter, value, type) VALUES ".
 
 2572                                                                 " (%s, %s,%s,%s,%s,%s,%s) ",
 
 2573                                                                 array(
"integer", 
"integer", 
"text", 
"text", 
"text", 
"text", 
"text"),
 
 2574                                                                 array($nid, $rec2[
"style_id"], $rec2[
"tag"], $rec2[
"class"],
 
 2575                                                                         $rec2[
"parameter"], $rec2[
"value"], $types[1]));
 
 2590                 $classes = array(
"Example", 
"Additional", 
"Citation", 
"Mnemonic", 
"Remark");
 
 2591                 $pars = array(
"margin-top", 
"margin-bottom");
 
 2593                 foreach ($classes as $curr_class)
 
 2595                         foreach ($pars as $curr_par)
 
 2597                                 $res2 = $ilDB->queryF(
"SELECT id FROM style_parameter WHERE style_id = %s".
 
 2598                                         " AND tag = %s AND class= %s AND parameter = %s",
 
 2599                                         array(
"integer", 
"text", 
"text", 
"text"),
 
 2600                                         array($a_id, 
"p", $curr_class, $curr_par));
 
 2601                                 if ($row2 = $ilDB->fetchAssoc($res2))
 
 2603                                         $ilDB->manipulateF(
"UPDATE style_parameter SET value= %s WHERE id = %s",
 
 2604                                                 array(
"text", 
"integer"),
 
 2605                                                 array(
"10px", $row2[
"id"]));
 
 2609                                         $nid = $ilDB->nextId(
"style_parameter");
 
 2610                                         $ilDB->manipulateF(
"INSERT INTO style_parameter ".
 
 2611                                                 "(id, style_id, tag, class, parameter,value) VALUES (%s,%s,%s,%s,%s,%s)",
 
 2612                                                 array(
"integer", 
"integer", 
"text", 
"text", 
"text", 
"text"),
 
 2613                                                 array($nid, $a_id, 
"div", $curr_class, $curr_par, 
"10px"));
 
 2618                 $ilDB->manipulateF(
"UPDATE style_parameter SET tag = %s WHERE tag = %s and style_id = %s",
 
 2619                         array(
"text", 
"text", 
"integer"),
 
 2620                         array(
"div", 
"p", $a_id));
 
 2632                 $set = $ilDB->query(
"SELECT * FROM style_color WHERE ".
 
 2633                         "style_id = ".$ilDB->quote($this->getId(), 
"integer").
" ".
 
 2634                         "ORDER BY color_name");
 
 2637                 while ($rec = $ilDB->fetchAssoc($set))
 
 2640                                 "name" => $rec[
"color_name"],
 
 2641                                 "code" => $rec[
"color_code"]
 
 2655                 $ilDB->manipulate(
"INSERT INTO style_color (style_id, color_name, color_code)".
 
 2657                         $ilDB->quote($this->getId(), 
"integer").
",".
 
 2658                         $ilDB->quote($a_name, 
"text").
",".
 
 2659                         $ilDB->quote($a_code, 
"text").
 
 2672                 $ilDB->manipulate(
"UPDATE style_color SET ".
 
 2673                         "color_name = ".$ilDB->quote($a_new_name, 
"text").
", ".
 
 2674                         "color_code = ".$ilDB->quote($a_code, 
"text").
 
 2675                         " WHERE style_id = ".$ilDB->quote($this->
getId(), 
"integer").
 
 2676                         " AND color_name = ".$ilDB->quote($a_name, 
"text"));
 
 2680                 if ($a_name != $a_new_name)
 
 2682                         $set = $ilDB->query(
"SELECT * FROM style_parameter ".
 
 2683                                 " WHERE style_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 2685                                 " parameter = ".$ilDB->quote(
"background-color", 
"text"). 
" OR ".
 
 2686                                 " parameter = ".$ilDB->quote(
"color", 
"text"). 
" OR ".
 
 2687                                 " parameter = ".$ilDB->quote(
"border-color", 
"text"). 
" OR ".
 
 2688                                 " parameter = ".$ilDB->quote(
"border-top-color", 
"text"). 
" OR ".
 
 2689                                 " parameter = ".$ilDB->quote(
"border-bottom-color", 
"text"). 
" OR ".
 
 2690                                 " parameter = ".$ilDB->quote(
"border-left-color", 
"text"). 
" OR ".
 
 2691                                 " parameter = ".$ilDB->quote(
"border-right-color", 
"text").
 
 2693                         while ($rec = $ilDB->fetchAssoc($set))
 
 2695                                 if ($rec[
"value"] == 
"!".$a_name ||
 
 2696                                         is_int(strpos($rec[
"value"], 
"!".$a_name.
"(")))
 
 2700                                                 $rec[
"parameter"], str_replace($a_name, $a_new_name, $rec[
"value"]), $rec[
"type"]);
 
 2713                 $ilDB->manipulate(
"DELETE FROM style_color WHERE ".
 
 2714                         " style_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 2715                         " color_name = ".$ilDB->quote($a_name, 
"text"));
 
 2725                 $set = $ilDB->query(
"SELECT * FROM style_color WHERE ".
 
 2726                         "style_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 2727                         "color_name = ".$ilDB->quote($a_color_name, 
"text"));
 
 2728                 if ($rec = $ilDB->fetchAssoc($set))
 
 2742                 $pos = strpos($a_name, 
"(");
 
 2745                         $a_i = substr($a_name, $pos + 1);
 
 2746                         $a_i = str_replace(
")", 
"", $a_i);
 
 2747                         $a_name = substr($a_name, 0, $pos); 
 
 2750                 $set = $ilDB->query(
"SELECT color_code FROM style_color WHERE ".
 
 2751                         " style_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 2752                         " color_name = ".$ilDB->quote($a_name, 
"text"));
 
 2753                 if ($rec = $ilDB->fetchAssoc($set))
 
 2757                                 return "#".$rec[
"color_code"];
 
 2761                                 return "#".ilObjStyleSheet::_getColorFlavor($rec[
"color_code"],
 
 2777                         $hls[
"l"] = $hls[
"l"] + ((255 - $hls[
"l"]) * ($a_i / 100));
 
 2781                         $hls[
"l"] = $hls[
"l"] - (($hls[
"l"]) * (-$a_i / 100));
 
 2786                 foreach ($rgb as $k => $v)
 
 2788                         $rgb[$k] = str_pad(dechex($v), 2, 
"0", STR_PAD_LEFT);
 
 2791                 return $rgb[
"r"].$rgb[
"g"].$rgb[
"b"];
 
 2799                 $r[
"r"] = substr($a_rgb, 0, 2);
 
 2800                 $r[
"g"] = substr($a_rgb, 2, 2);
 
 2801                 $r[
"b"] = substr($a_rgb, 4, 2);
 
 2805                         $r[
"r"] = (int) hexdec($r[
"r"]);
 
 2806                         $r[
"g"] = (int) hexdec($r[
"g"]);
 
 2807                         $r[
"b"] = (int) hexdec($r[
"b"]);
 
 2818                 $r = $a_rgb[
"r"] / 255;
 
 2819                 $g = $a_rgb[
"g"] / 255;
 
 2820                 $b = $a_rgb[
"b"] / 255;
 
 2823                 $max = max($r,$g,$b);
 
 2824                 $min = min($r,$g,$b);
 
 2827                 $l = ($max + $min) / 2;
 
 2838                                 $s = ($max - $min) / ($max + $min);
 
 2842                                 $s = ($max - $min) / (2.0 - $max - $min);
 
 2847                                 $h  = ($g - $b) / ($max - $min);
 
 2849                         else if ($g == $max)
 
 2851                                 $h = 2.0 + ($b - $r) / ($max - $min);
 
 2853                         else if ($b == $max)
 
 2855                                 $h = 4.0 + ($r - $g) / ($max - $min);
 
 2859                 $hls[
"h"] = round(($h / 6) * 255);
 
 2860                 $hls[
"l"] = round($l * 255);
 
 2861                 $hls[
"s"] = round($s * 255);
 
 2871                 $h = $a_hls[
"h"] / 255;
 
 2872                 $l = $a_hls[
"l"] / 255;
 
 2873                 $s = $a_hls[
"s"] / 255;
 
 2875                 $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = 0;
 
 2880                         $rgb[
"r"] = $rgb[
"g"] = $rgb[
"b"] = $l;
 
 2887                                 $temp2 = $l * (1.0 + $s);
 
 2891                                 $temp2 = $l + $s - $l * $s;
 
 2894                         $temp1 = 2.0 * $l - $temp2;
 
 2897                         # For each of R, G, B, compute another temporary value, temp3, as follows: 
 2898                         foreach ($rgb as $k => $v)
 
 2903                                                 $temp3 = $h + 1.0 / 3.0;
 
 2911                                                 $temp3 = $h - 1.0/3.0;
 
 2916                                         $temp3 = $temp3 + 1.0;
 
 2920                                         $temp3 = $temp3 - 1.0;
 
 2923                                 if (6.0 * $temp3 < 1)
 
 2925                                         $rgb[$k] = $temp1 + ($temp2 - $temp1) * 6.0 * $temp3;
 
 2927                                 else if (2.0 * $temp3 < 1)
 
 2931                                 else if (3.0 * $temp3 < 2)
 
 2933                                         $rgb[$k] = $temp1 + ($temp2 - $temp1) * ((2.0/3.0) - $temp3) * 6.0;
 
 2942                 $rgb[
"r"] = round($rgb[
"r"] * 255);
 
 2943                 $rgb[
"g"] = round($rgb[
"g"] * 255);
 
 2944                 $rgb[
"b"] = round($rgb[
"b"] * 255);
 
 2960                 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
 
 2961                         "style_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 2962                         "temp_type = ".$ilDB->quote($a_type, 
"text").
" ".
 
 2966                 while ($rec = $ilDB->fetchAssoc($set))
 
 2981                 $set = $ilDB->query(
"SELECT * FROM style_template_class WHERE ".
 
 2982                         "template_id = ".$ilDB->quote($a_tid, 
"integer"));
 
 2985                 while ($rec = $ilDB->fetchAssoc($set))
 
 2987                         $key = $rec[
"class_type"];
 
 2988                         $class[$key] = $rec[
"class"];
 
 3002                 $tid = $ilDB->nextId(
"style_template");
 
 3003                 $ilDB->manipulate($q = 
"INSERT INTO style_template ".
 
 3004                         "(id, style_id, name, temp_type)".
 
 3006                         $ilDB->quote($tid, 
"integer").
",".
 
 3007                         $ilDB->quote($this->
getId(), 
"integer").
",".
 
 3008                         $ilDB->quote($a_name, 
"text").
",".
 
 3009                         $ilDB->quote($a_type, 
"text").
 
 3012                 foreach ($a_classes as 
$t => $c)
 
 3014                         $ilDB->manipulate($q = 
"INSERT INTO style_template_class ".
 
 3015                                 "(template_id, class_type, class)".
 
 3017                                 $ilDB->quote($tid, 
"integer").
",".
 
 3018                                 $ilDB->quote(
$t, 
"text").
",".
 
 3019                                 $ilDB->quote($c, 
"text").
 
 3023                 include_once(
"./Services/Style/classes/class.ilObjStyleSheetGUI.php");
 
 3037                 $ilDB->manipulate(
"UPDATE style_template SET ".
 
 3038                         "name = ".$ilDB->quote($a_name, 
"text").
 
 3039                         " WHERE id = ".$ilDB->quote($a_t_id, 
"integer"));
 
 3041                 $ilDB->manipulate(
"DELETE FROM style_template_class WHERE ".
 
 3042                         "template_id = ".$ilDB->quote($a_t_id, 
"integer")
 
 3044                 foreach ($a_classes as 
$t => $c)
 
 3046                         $ilDB->manipulate($q = 
"INSERT INTO style_template_class ".
 
 3047                                 "(template_id, class_type, class)".
 
 3049                                 $ilDB->quote($a_t_id, 
"integer").
",".
 
 3050                                 $ilDB->quote(
$t, 
"text").
",".
 
 3051                                 $ilDB->quote($c, 
"text").
 
 3064                 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
 
 3065                         "style_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 3066                         "name = ".$ilDB->quote($a_template_name, 
"text"));
 
 3067                 if ($rec = $ilDB->fetchAssoc($set))
 
 3081                 $set = $ilDB->query(
"SELECT * FROM style_template WHERE ".
 
 3082                         "style_id = ".$ilDB->quote($this->getId(), 
"integer").
" ".
 
 3083                         " AND id = ".$ilDB->quote($a_t_id, 
"integer"));
 
 3085                 if ($rec = $ilDB->fetchAssoc($set))
 
 3102                 $set = $ilDB->query(
"SELECT name FROM style_template WHERE ".
 
 3103                         " id = ".$ilDB->quote($a_t_id, 
"integer"));
 
 3105                 if ($rec = $ilDB->fetchAssoc($set))
 
 3107                         return $rec[
"name"];
 
 3120                 $tag = 
"<StyleTemplates>";
 
 3122                 $ttypes = array(
"table", 
"vaccordion", 
"haccordion");
 
 3124                 foreach ($ttypes as $ttype)
 
 3143                                 $tag.= 
'<StyleTemplate Name="'.$t[
"name"].
'">';
 
 3145                                 foreach ($atts as 
$type => $t)
 
 3147                                         if ($c[
$type] != 
"")
 
 3149                                                 $tag.= 
'<StyleClass Type="'.$type.
'" Value="'.$c[
$type].
'" />';
 
 3153                                 $tag.= 
"</StyleTemplate>";
 
 3157                 $tag.= 
"</StyleTemplates>";
 
 3169                 $a_preview_html = str_replace(
' width=""', 
"", $a_preview_html);
 
 3170                 $a_preview_html = str_replace(
' valign="top"', 
"", $a_preview_html);
 
 3171                 $a_preview_html = str_replace(
'<div class="ilc_text_block_TableContent">', 
"<div>", $a_preview_html);
 
 3174                 if (strlen($a_preview_html) > 4000)
 
 3177                         $a_preview_html = 
"";
 
 3179                 $ilDB->manipulate(
"UPDATE style_template SET ".
 
 3180                         "preview = ".$ilDB->quote($a_preview_html, 
"text").
 
 3181                         " WHERE id = ".$ilDB->quote($a_t_id, 
"integer"));
 
 3191                 $set = $ilDB->query(
"SELECT preview FROM style_template ".
 
 3192                         " WHERE id = ".$ilDB->quote($a_t_id, 
"integer"));
 
 3193                 if ($rec = $ilDB->fetchAssoc($set))
 
 3195                         return $rec[
"preview"];
 
 3208                 $set = $ilDB->query(
"SELECT id FROM style_template ".
 
 3209                         " WHERE style_id = ".$ilDB->quote($a_style_id, 
"integer").
 
 3210                         " AND name = ".$ilDB->quote($a_name, 
"text"));
 
 3211                 if ($rec = $ilDB->fetchAssoc($set))
 
 3226                 $ilDB->manipulate(
"DELETE FROM style_template WHERE ".
 
 3227                         " style_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 3228                         " id = ".$ilDB->quote($a_t_id, 
"integer"));
 
 3230                 $ilDB->manipulate(
"DELETE FROM style_template_class WHERE ".
 
 3231                         "template_id = ".$ilDB->quote($a_t_id, 
"integer")
 
 3243                 $ilDB->manipulate(
"DELETE FROM style_setting WHERE ".
 
 3244                         " style_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 3245                         " AND name = ".$ilDB->quote($a_name, 
"text")
 
 3248                 $ilDB->manipulate(
"INSERT INTO style_setting ".
 
 3249                         "(style_id, name, value) VALUES (".
 
 3250                         $ilDB->quote($this->getId(), 
"integer").
",".
 
 3251                         $ilDB->quote($a_name, 
"text").
",".
 
 3252                         $ilDB->quote($a_value, 
"text").
 
 3263                 $set = $ilDB->query(
"SELECT value FROM style_setting ".
 
 3264                         " WHERE style_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 3265                         " AND name = ".$ilDB->quote($a_name, 
"text")
 
 3267                 $rec  = $ilDB->fetchAssoc($set);
 
 3269                 return $rec[
"value"];
 
 3279                 $ilDB->replace(
"style_usage", array(
 
 3280                         "obj_id" => array(
"integer", (
int) $a_obj_id)),
 
 3282                                 "style_id" => array(
"integer", (
int) $a_style_id))
 
 3293                 $set = $ilDB->query(
"SELECT style_id FROM style_usage ".
 
 3294                         " WHERE obj_id = ".$ilDB->quote($a_obj_id, 
"integer")
 
 3296                 $rec  = $ilDB->fetchAssoc($set);
 
 3298                 return (
int) $rec[
"style_id"];