00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once "classes/class.ilObject.php";
00026
00035 class ilObjStyleSheet extends ilObject
00036 {
00037 var $style;
00038
00039
00046 function ilObjStyleSheet($a_id = 0, $a_call_by_reference = false)
00047 {
00048 $this->type = "sty";
00049 $this->style = array();
00050 if($a_call_by_reference)
00051 {
00052 $this->ilias->raiseError("Can't instantiate style object via reference id.",$this->ilias->error_obj->FATAL);
00053 }
00054
00055 parent::ilObject($a_id, false);
00056 }
00057
00058 function setRefId()
00059 {
00060 $this->ilias->raiseError("Operation ilObjStyleSheet::setRefId() not allowed.",$this->ilias->error_obj->FATAL);
00061 }
00062
00063 function getRefId()
00064 {
00065 return "";
00066
00067 }
00068
00069 function putInTree()
00070 {
00071 $this->ilias->raiseError("Operation ilObjStyleSheet::putInTree() not allowed.",$this->ilias->error_obj->FATAL);
00072 }
00073
00074 function createReference()
00075 {
00076 $this->ilias->raiseError("Operation ilObjStyleSheet::createReference() not allowed.",$this->ilias->error_obj->FATAL);
00077 }
00078
00079 function setUpToDate($a_up_to_date = true)
00080 {
00081 $this->up_to_date = $a_up_to_date;
00082 }
00083
00084 function getUpToDate()
00085 {
00086 return $this->up_to_date;
00087 }
00088
00089 function setScope($a_scope)
00090 {
00091 $this->scope = $a_scope;
00092 }
00093
00094 function getScope()
00095 {
00096 return $this->scope;
00097 }
00098
00099 function _writeUpToDate($a_id, $a_up_to_date)
00100 {
00101 global $ilDB;
00102
00103 $q = "UPDATE style_data SET uptodate = ".$ilDB->quote((int) $a_up_to_date).
00104 " WHERE id = ".$ilDB->quote($a_id);
00105 $ilDB->query($q);
00106 }
00107
00111 function _lookupUpToDate($a_id)
00112 {
00113 global $ilDB;
00114
00115 $q = "SELECT * FROM style_data ".
00116 " WHERE id = ".$ilDB->quote($a_id);
00117 $res = $ilDB->query($q);
00118 $sty = $res->fetchRow(DB_FETCHMODE_ASSOC);
00119
00120 return (boolean) $sty["uptodate"];
00121 }
00122
00126 function _writeStandard($a_id, $a_std)
00127 {
00128 global $ilDB;
00129
00130 $q = "UPDATE style_data SET standard = ".$ilDB->quote((int) $a_std).
00131 " WHERE id = ".$ilDB->quote($a_id);
00132 $ilDB->query($q);
00133 }
00134
00138 function _writeScope($a_id, $a_scope)
00139 {
00140 global $ilDB;
00141
00142 $q = "UPDATE style_data SET category = ".$ilDB->quote((int) $a_scope).
00143 " WHERE id = ".$ilDB->quote($a_id);
00144 $ilDB->query($q);
00145 }
00146
00150 function _lookupStandard($a_id)
00151 {
00152 global $ilDB;
00153
00154 $q = "SELECT * FROM style_data ".
00155 " WHERE id = ".$ilDB->quote($a_id);
00156 $res = $ilDB->query($q);
00157 $sty = $res->fetchRow(DB_FETCHMODE_ASSOC);
00158
00159 return (boolean) $sty["standard"];
00160 }
00161
00165 function _writeActive($a_id, $a_active)
00166 {
00167 global $ilDB;
00168
00169 $q = "UPDATE style_data SET active = ".$ilDB->quote((int) $a_active).
00170 " WHERE id = ".$ilDB->quote($a_id);
00171 $ilDB->query($q);
00172 }
00173
00177 function _lookupActive($a_id)
00178 {
00179 global $ilDB;
00180
00181 $q = "SELECT * FROM style_data ".
00182 " WHERE id = ".$ilDB->quote($a_id);
00183 $res = $ilDB->query($q);
00184 $sty = $res->fetchRow(DB_FETCHMODE_ASSOC);
00185
00186 return (boolean) $sty["active"];
00187 }
00188
00192 function _getStandardStyles($a_exclude_default_style = false,
00193 $a_include_deactivated = false, $a_scope = 0)
00194 {
00195 global $ilDB, $ilias, $tree;
00196
00197 $default_style = $ilias->getSetting("default_content_style_id");
00198
00199 $and_str = "";
00200 if (!$a_include_deactivated)
00201 {
00202 $and_str = " AND active = 1";
00203 }
00204
00205 $q = "SELECT * FROM style_data ".
00206 " WHERE standard = 1".$and_str;
00207 $res = $ilDB->query($q);
00208 $styles = array();
00209 while($sty = $res->fetchRow(DB_FETCHMODE_ASSOC))
00210 {
00211 if (!$a_exclude_default_style || $default_style != $sty["id"])
00212 {
00213
00214 if ($a_scope > 0 && $sty["category"] > 0)
00215 {
00216 if ($tree->isInTree($sty["category"]) &&
00217 $tree->isInTree($a_scope))
00218 {
00219 $path = $tree->getPathId($a_scope);
00220 if (!in_array($sty["category"], $path))
00221 {
00222 continue;
00223 }
00224 }
00225 }
00226 $styles[$sty["id"]] = ilObject::_lookupTitle($sty["id"]);
00227 }
00228 }
00229
00230 return $styles;
00231 }
00232
00233
00239 function _getClonableContentStyles()
00240 {
00241 global $ilAccess, $ilDB;
00242
00243 $clonable_styles = array();
00244
00245 $q = "SELECT * FROM style_data, object_data ".
00246 " WHERE object_data.obj_id = style_data.id ";
00247 $style_set = $ilDB->query($q);
00248 while($style_rec = $style_set->fetchRow(DB_FETCHMODE_ASSOC))
00249 {
00250 $clonable = false;
00251 if ($style_rec["standard"] == 1)
00252 {
00253 if ($style_rec["active"] == 1)
00254 {
00255 $clonable = true;
00256 }
00257 }
00258 else
00259 {
00260 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
00261 $obj_ids = ilObjContentObject::_lookupContObjIdByStyleId($style_rec["id"]);
00262 foreach($obj_ids as $id)
00263 {
00264 $ref = ilObject::_getAllReferences($id);
00265 foreach($ref as $ref_id)
00266 {
00267 if ($ilAccess->checkAccess("write", "", $ref_id))
00268 {
00269 $clonable = true;
00270 }
00271 }
00272 }
00273 }
00274 if ($clonable)
00275 {
00276 $clonable_styles[$style_rec["id"]] =
00277 $style_rec["title"];
00278 }
00279 }
00280 return $clonable_styles;
00281 }
00282
00286 function assignMetaData(&$a_meta_data)
00287 {
00288 $this->meta_data =& $a_meta_data;
00289 }
00290
00294 function &getMetaData()
00295 {
00296 return $this->meta_data;
00297 }
00298
00299 function create($a_from_style = 0)
00300 {
00301 global $ilDB;
00302
00303 parent::create();
00304
00305 if ($a_from_style == 0)
00306 {
00307 $def = array(
00308 array("tag" => "div", "class" => "PageTitle", "parameter" => "margin-top" ,"value" => "5px"),
00309 array("tag" => "div", "class" => "PageTitle", "parameter" => "margin-bottom" ,"value" => "20px"),
00310 array("tag" => "div", "class" => "PageTitle", "parameter" => "font-size" ,"value" => "140%"),
00311 array("tag" => "div", "class" => "PageTitle", "parameter" => "padding-bottom" ,"value" => "3px"),
00312 array("tag" => "div", "class" => "PageTitle", "parameter" => "border-bottom-width" ,"value" => "1px"),
00313 array("tag" => "div", "class" => "PageTitle", "parameter" => "border-bottom-style" ,"value" => "solid"),
00314 array("tag" => "div", "class" => "PageTitle", "parameter" => "border-color" ,"value" => "#000000"),
00315
00316 array("tag" => "span", "class" => "Strong", "parameter" => "font-weight" ,"value" => "bold"),
00317 array("tag" => "span", "class" => "Emph", "parameter" => "font-style" ,"value" => "italic"),
00318 array("tag" => "span", "class" => "Comment", "parameter" => "color" ,"value" => "green"),
00319 array("tag" => "span", "class" => "Quotation", "parameter" => "color" ,"value" => "brown"),
00320 array("tag" => "span", "class" => "Quotation", "parameter" => "font-style" ,"value" => "italic"),
00321
00322 array("tag" => "a", "class" => "FootnoteLink", "parameter" => "color" ,"value" => "blue"),
00323 array("tag" => "a", "class" => "FootnoteLink", "parameter" => "font-weight" ,"value" => "normal"),
00324 array("tag" => "a", "class" => "FootnoteLink:hover", "parameter" => "color" ,"value" => "#000000"),
00325 array("tag" => "div", "class" => "Footnote", "parameter" => "margin-top" ,"value" => "5px"),
00326 array("tag" => "div", "class" => "Footnote", "parameter" => "margin-bottom" ,"value" => "5px"),
00327 array("tag" => "div", "class" => "Footnote", "parameter" => "font-style" ,"value" => "italic"),
00328
00329 array("tag" => "a", "class" => "IntLink", "parameter" => "color" ,"value" => "blue"),
00330 array("tag" => "a", "class" => "IntLink:visited", "parameter" => "color" ,"value" => "blue"),
00331 array("tag" => "a", "class" => "IntLink", "parameter" => "font-weight" ,"value" => "normal"),
00332 array("tag" => "a", "class" => "IntLink", "parameter" => "text-decoration" ,"value" => "underline"),
00333 array("tag" => "a", "class" => "IntLink:hover", "parameter" => "color" ,"value" => "#000000"),
00334
00335 array("tag" => "a", "class" => "ExtLink", "parameter" => "color" ,"value" => "blue"),
00336 array("tag" => "a", "class" => "ExtLink:visited", "parameter" => "color" ,"value" => "blue"),
00337 array("tag" => "a", "class" => "ExtLink", "parameter" => "font-weight" ,"value" => "normal"),
00338 array("tag" => "a", "class" => "ExtLink", "parameter" => "text-decoration" ,"value" => "underline"),
00339 array("tag" => "a", "class" => "ExtLink:hover", "parameter" => "color" ,"value" => "#000000"),
00340
00341 array("tag" => "div", "class" => "LMNavigation", "parameter" => "background-color" ,"value" => "#EEEEEE"),
00342 array("tag" => "div", "class" => "LMNavigation", "parameter" => "border-style" ,"value" => "outset"),
00343 array("tag" => "div", "class" => "LMNavigation", "parameter" => "border-color" ,"value" => "#EEEEEE"),
00344 array("tag" => "div", "class" => "LMNavigation", "parameter" => "border-width" ,"value" => "1px"),
00345 array("tag" => "div", "class" => "Page", "parameter" => "background-color" ,"value" => "#FFFFFF"),
00346 array("tag" => "div", "class" => "Page", "parameter" => "padding" ,"value" => "0px"),
00347 array("tag" => "div", "class" => "Page", "parameter" => "margin" ,"value" => "0px"),
00348 array("tag" => "td", "class" => "Cell1", "parameter" => "background-color" ,"value" => "#FFCCCC"),
00349 array("tag" => "td", "class" => "Cell2", "parameter" => "background-color" ,"value" => "#CCCCFF"),
00350 array("tag" => "td", "class" => "Cell3", "parameter" => "background-color" ,"value" => "#CCFFCC"),
00351 array("tag" => "td", "class" => "Cell4", "parameter" => "background-color" ,"value" => "#FFFFCC"),
00352
00353 array("tag" => "p", "class" => "Standard", "parameter" => "margin-top" ,"value" => "10px"),
00354 array("tag" => "p", "class" => "Standard", "parameter" => "margin-bottom" ,"value" => "10px"),
00355
00356 array("tag" => "p", "class" => "List", "parameter" => "margin-top" ,"value" => "3px"),
00357 array("tag" => "p", "class" => "List", "parameter" => "margin-bottom" ,"value" => "3px"),
00358
00359 array("tag" => "p", "class" => "Headline1", "parameter" => "margin-top" ,"value" => "20px"),
00360 array("tag" => "p", "class" => "Headline1", "parameter" => "margin-bottom" ,"value" => "10px"),
00361 array("tag" => "p", "class" => "Headline1", "parameter" => "font-size" ,"value" => "140%"),
00362
00363 array("tag" => "p", "class" => "Headline2", "parameter" => "margin-top" ,"value" => "20px"),
00364 array("tag" => "p", "class" => "Headline2", "parameter" => "margin-bottom" ,"value" => "10px"),
00365 array("tag" => "p", "class" => "Headline2", "parameter" => "font-size" ,"value" => "130%"),
00366
00367 array("tag" => "p", "class" => "Headline3", "parameter" => "margin-top" ,"value" => "20px"),
00368 array("tag" => "p", "class" => "Headline3", "parameter" => "margin-bottom" ,"value" => "10px"),
00369 array("tag" => "p", "class" => "Headline3", "parameter" => "font-size" ,"value" => "120%"),
00370
00371 array("tag" => "p", "class" => "Example", "parameter" => "padding-left" ,"value" => "20px"),
00372 array("tag" => "p", "class" => "Example", "parameter" => "border-left-width" ,"value" => "3px"),
00373 array("tag" => "p", "class" => "Example", "parameter" => "border-left-style" ,"value" => "solid"),
00374 array("tag" => "p", "class" => "Example", "parameter" => "border-left-color" ,"value" => "blue"),
00375
00376 array("tag" => "p", "class" => "Citation", "parameter" => "color" ,"value" => "brown"),
00377 array("tag" => "p", "class" => "Citation", "parameter" => "font-style" ,"value" => "italic"),
00378
00379 array("tag" => "p", "class" => "Mnemonic", "parameter" => "margin-left" ,"value" => "20px"),
00380 array("tag" => "p", "class" => "Mnemonic", "parameter" => "margin-right" ,"value" => "20px"),
00381 array("tag" => "p", "class" => "Mnemonic", "parameter" => "color" ,"value" => "red"),
00382 array("tag" => "p", "class" => "Mnemonic", "parameter" => "padding" ,"value" => "10px"),
00383 array("tag" => "p", "class" => "Mnemonic", "parameter" => "border-width" ,"value" => "1px"),
00384 array("tag" => "p", "class" => "Mnemonic", "parameter" => "border-style" ,"value" => "solid"),
00385 array("tag" => "p", "class" => "Mnemonic", "parameter" => "border-color" ,"value" => "red"),
00386
00387 array("tag" => "p", "class" => "Additional", "parameter" => "padding" ,"value" => "10px"),
00388 array("tag" => "p", "class" => "Additional", "parameter" => "border-width" ,"value" => "1px"),
00389 array("tag" => "p", "class" => "Additional", "parameter" => "border-style" ,"value" => "solid"),
00390 array("tag" => "p", "class" => "Additional", "parameter" => "border-color" ,"value" => "blue"),
00391
00392 array("tag" => "p", "class" => "Remark", "parameter" => "padding" ,"value" => "10px"),
00393 array("tag" => "p", "class" => "Remark", "parameter" => "border-width" ,"value" => "1px"),
00394 array("tag" => "p", "class" => "Remark", "parameter" => "border-style" ,"value" => "solid"),
00395 array("tag" => "p", "class" => "Remark", "parameter" => "border-color" ,"value" => "#909090"),
00396 array("tag" => "p", "class" => "Remark", "parameter" => "background-color" ,"value" => "#D0D0D0"),
00397 array("tag" => "p", "class" => "Remark", "parameter" => "text-align" ,"value" => "right"),
00398
00399 array("tag" => "p", "class" => "TableContent", "parameter" => "margin-left" ,"value" => "0px"),
00400 array("tag" => "p", "class" => "TableContent", "parameter" => "margin-right" ,"value" => "0px"),
00401 array("tag" => "p", "class" => "TableContent", "parameter" => "margin-top" ,"value" => "0px"),
00402 array("tag" => "p", "class" => "TableContent", "parameter" => "margin-bottom" ,"value" => "0px"),
00403 array("tag" => "p", "class" => "TableContent", "parameter" => "padding-left" ,"value" => "0px"),
00404 array("tag" => "p", "class" => "TableContent", "parameter" => "padding-right" ,"value" => "0px"),
00405 array("tag" => "p", "class" => "TableContent", "parameter" => "padding-top" ,"value" => "0px"),
00406 array("tag" => "p", "class" => "TableContent", "parameter" => "padding-bottom" ,"value" => "0px"),
00407
00408 array("tag" => "table", "class" => "Media", "parameter" => "background-color" ,"value" => "#F5F5F5"),
00409 array("tag" => "table", "class" => "Media", "parameter" => "padding" ,"value" => "0px"),
00410 array("tag" => "table", "class" => "Media", "parameter" => "margin" ,"value" => "10px"),
00411
00412 array("tag" => "td", "class" => "MediaCaption", "parameter" => "padding" ,"value" => "5px")
00413 );
00414 }
00415 else
00416 {
00417 $def = array();
00418 $q = "SELECT * FROM style_parameter WHERE style_id = ".$ilDB->quote($a_from_style);
00419 $par_set = $ilDB->query($q);
00420 while($par_rec = $par_set->fetchRow(DB_FETCHMODE_ASSOC))
00421 {
00422 $def[] = array("tag" => $par_rec["tag"], "class" => $par_rec["class"],
00423 "parameter" => $par_rec["parameter"] ,"value" => $par_rec["value"]);
00424 }
00425 }
00426
00427
00428 foreach ($def as $sty)
00429 {
00430 $q = "INSERT INTO style_parameter (style_id, tag, class, parameter, value) VALUES ".
00431 "(".$ilDB->quote($this->getId()).",".
00432 $ilDB->quote($sty["tag"]).",".
00433 $ilDB->quote($sty["class"]).",".
00434 $ilDB->quote($sty["parameter"]).",".
00435 $ilDB->quote($sty["value"]).")";
00436 $ilDB->query($q);
00437 }
00438
00439
00440 $q = "INSERT INTO style_data (id, uptodate, category) VALUES ".
00441 "(".$ilDB->quote($this->getId()).", 0,".
00442 $ilDB->quote($this->getScope()).")";
00443 $ilDB->query($q);
00444
00445 $this->read();
00446 $this->writeCSSFile();
00447 }
00448
00455 function ilClone()
00456 {
00457 global $log;
00458
00459 $new_obj = new ilObjStyleSheet();
00460 $new_obj->setTitle($this->getTitle());
00461 $new_obj->setType($this->getType());
00462 $new_obj->setDescription($this->getDescription());
00463 $new_obj->create($this->getId());
00464
00465 return $new_obj->getId();
00466 }
00467
00468
00475 function addParameter($a_tag, $a_par)
00476 {
00477 global $ilDB;
00478
00479 $avail_params = $this->getAvailableParameters();
00480 $tag = explode(".", $a_tag);
00481 $value = $avail_params[$a_par][0];
00482 $q = "INSERT INTO style_parameter (style_id, tag, class, parameter, value) VALUES ".
00483 "(".$ilDB->quote($this->getId()).",".$ilDB->quote($tag[0]).",".
00484 $ilDB->quote($tag[1]).
00485 ",".$ilDB->quote($a_par).",".$ilDB->quote($value).")";
00486 $this->ilias->db->query($q);
00487 $this->read();
00488 $this->writeCSSFile();
00489 }
00490
00496 function deleteParameter($a_id)
00497 {
00498 global $ilDB;
00499
00500 $q = "DELETE FROM style_parameter WHERE id = ".$ilDB->quote($a_id);
00501 $this->ilias->db->query($q);
00502 }
00503
00508 function deleteStylePar($a_tag, $a_class, $a_par)
00509 {
00510 global $ilDB;
00511
00512 $q = "DELETE FROM style_parameter WHERE ".
00513 " style_id = ".$ilDB->quote($this->getId())." AND ".
00514 " tag = ".$ilDB->quote($a_tag)." AND ".
00515 " class = ".$ilDB->quote($a_class)." AND ".
00516 " parameter = ".$ilDB->quote($a_par);
00517
00518 $this->ilias->db->query($q);
00519 }
00520
00524 function delete()
00525 {
00526 global $ilDB;
00527
00528
00529 parent::delete();
00530
00531
00532 $def_style = $this->ilias->getSetting("default_content_style_id");
00533 if ($def_style == $this->getId())
00534 {
00535 $this->ilias->deleteSetting("default_content_style_id");
00536 }
00537
00538
00539 $fixed_style = $this->ilias->getSetting("fixed_content_style_id");
00540 if ($fixed_style == $this->getId())
00541 {
00542 $this->ilias->deleteSetting("fixed_content_style_id");
00543 }
00544
00545
00546 $q = "DELETE FROM style_parameter WHERE style_id = ".$ilDB->quote($this->getId());
00547 $ilDB->query($q);
00548
00549
00550 $css_file_name = ilUtil::getWebspaceDir()."/css/style_".$this->getId().".css";
00551 if (is_file($css_file_name))
00552 {
00553 unlink($css_file_name);
00554 }
00555
00556
00557 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
00558 ilObjContentObject::_deleteStyleAssignments($this->getId());
00559
00560
00561 $q = "DELETE FROM style_data WHERE id = ".$ilDB->quote($this->getId());
00562 $ilDB->query($q);
00563
00564 }
00565
00566
00570 function read()
00571 {
00572 global $ilDB;
00573
00574 parent::read();
00575
00576 $q = "SELECT * FROM style_parameter WHERE style_id = ".
00577 $ilDB->quote($this->getId())." ORDER BY tag, class ";
00578 $style_set = $this->ilias->db->query($q);
00579 $ctag = "";
00580 $cclass = "";
00581 $this->style = array();
00582 while($style_rec = $style_set->fetchRow(DB_FETCHMODE_ASSOC))
00583 {
00584 if ($style_rec["tag"] != $ctag || $style_rec["class"] != $cclass)
00585 {
00586
00587 if(is_array($tag))
00588 {
00589 $this->style[] = $tag;
00590 }
00591 $tag = array();
00592 }
00593 $ctag = $style_rec["tag"];
00594 $cclass = $style_rec["class"];
00595 $tag[] = $style_rec;
00596 }
00597 if(is_array($tag))
00598 {
00599 $this->style[] = $tag;
00600 }
00601
00602 $q = "SELECT * FROM style_data WHERE id = ".$ilDB->quote($this->getId());
00603 $res = $ilDB->query($q);
00604 $sty = $res->fetchRow(DB_FETCHMODE_ASSOC);
00605 $this->setUpToDate((boolean) $sty["uptodate"]);
00606 $this->setScope($sty["category"]);
00607
00608 }
00609
00613 function writeCSSFile($a_target_file = "")
00614 {
00615 $style = $this->getStyle();
00616
00617 if ($a_target_file == "")
00618 {
00619 $css_file_name = ilUtil::getWebspaceDir()."/css/style_".$this->getId().".css";
00620 }
00621 else
00622 {
00623 $css_file_name = $a_target_file;
00624 }
00625 $css_file = fopen($css_file_name, "w");
00626
00627 $page_background = "";
00628
00629 foreach ($style as $tag)
00630 {
00631 fwrite ($css_file, $tag[0]["tag"].".ilc_".$tag[0]["class"]."\n");
00632 fwrite ($css_file, "{\n");
00633
00634 foreach($tag as $par)
00635 {
00636 fwrite ($css_file, "\t".$par["parameter"].": ".$par["value"].";\n");
00637
00638
00639 if ($tag[0]["tag"] == "div" && $tag[0]["class"] == "Page"
00640 && $par["parameter"] == "background-color")
00641 {
00642 $page_background = $par["value"];
00643 }
00644 }
00645 fwrite ($css_file, "}\n");
00646 fwrite ($css_file, "\n");
00647 }
00648
00649 if ($page_background != "")
00650 {
00651 fwrite ($css_file, "td.ilc_Page\n");
00652 fwrite ($css_file, "{\n");
00653 fwrite ($css_file, "\t"."background-color: ".$page_background.";\n");
00654 fwrite ($css_file, "}\n");
00655 }
00656 fclose($css_file);
00657
00658 $this->setUpToDate(true);
00659 $this->_writeUpToDate($this->getId(), true);
00660 }
00661
00662
00668 function getContentStylePath($a_style_id)
00669 {
00670 global $ilias;
00671
00672 $rand = rand(1,999999);
00673
00674
00675
00676 $fixed_style = $ilias->getSetting("fixed_content_style_id");
00677 if ($fixed_style > 0)
00678 {
00679 $a_style_id = $fixed_style;
00680 }
00681
00682
00683 if ($a_style_id <= 0)
00684 {
00685 $a_style_id = $ilias->getSetting("default_content_style_id");
00686 }
00687
00688 if ($a_style_id > 0 && ilObject::_exists($a_style_id))
00689 {
00690
00691 if (!ilObjStyleSheet::_lookupUpToDate($a_style_id))
00692 {
00693 $style = new ilObjStyleSheet($a_style_id);
00694 $style->writeCSSFile();
00695 }
00696
00697 return ilUtil::getWebspaceDir("output").
00698 "/css/style_".$a_style_id.".css?dummy=$rand";
00699 }
00700 else
00701 {
00702 return "./Services/COPage/css/content.css";
00703 }
00704 }
00705
00711 function getContentPrintStyle()
00712 {
00713 return "./Services/COPage/css/print_content.css";
00714 }
00715
00721 function getSyntaxStylePath()
00722 {
00723 return "./Services/COPage/css/syntaxhighlight.css";
00724 }
00725
00726 function update()
00727 {
00728 global $ilDB;
00729
00730 parent::update();
00731 $this->read();
00732 $this->writeCSSFile();
00733
00734 $q = "UPDATE style_data ".
00735 "SET category = ".$ilDB->quote($this->getScope());
00736 $ilDB->query($q);
00737 }
00738
00745 function updateStyleParameter($a_id, $a_value)
00746 {
00747 global $ilDB;
00748
00749 $q = "UPDATE style_parameter SET VALUE=".
00750 $ilDB->quote($a_value)." WHERE id = ".
00751 $ilDB->quote($a_id);
00752 $style_set = $this->ilias->db->query($q);
00753 }
00754
00759 function replaceStylePar($a_tag, $a_class, $a_par, $a_val)
00760 {
00761 global $ilDB;
00762
00763 $q = "SELECT * FROM style_parameter WHERE ".
00764 " style_id = ".$ilDB->quote($this->getId())." AND ".
00765 " tag = ".$ilDB->quote($a_tag)." AND ".
00766 " class = ".$ilDB->quote($a_class)." AND ".
00767 " parameter = ".$ilDB->quote($a_par);
00768
00769 $set = $ilDB->query($q);
00770
00771 if ($rec = $set->fetchRow())
00772 {
00773 $q = "UPDATE style_parameter SET ".
00774 " value = ".$ilDB->quote($a_val)." WHERE ".
00775 " style_id = ".$ilDB->quote($this->getId())." AND ".
00776 " tag = ".$ilDB->quote($a_tag)." AND ".
00777 " class = ".$ilDB->quote($a_class)." AND ".
00778 " parameter = ".$ilDB->quote($a_par);
00779
00780 $ilDB->query($q);
00781 }
00782 else
00783 {
00784 $q = "INSERT INTO style_parameter (value, style_id, tag, class, parameter) VALUES ".
00785 " (".$ilDB->quote($a_val).",".
00786 " ".$ilDB->quote($this->getId()).",".
00787 " ".$ilDB->quote($a_tag).",".
00788 " ".$ilDB->quote($a_class).",".
00789 " ".$ilDB->quote($a_par).")";
00790
00791 $ilDB->query($q);
00792 }
00793 }
00794
00795
00799 function getStyle()
00800 {
00801 return $this->style;
00802 }
00803
00807 function setStyle($a_style)
00808 {
00809 $this->style = $a_style;
00810 }
00811
00812
00816 function getXML()
00817 {
00818 $xml.= "<StyleSheet>";
00819 $xml.= "<Title>".$this->getTitle()."</Title>";
00820 $xml.= "<Description>".$this->getDescription()."</Description>";
00821 foreach($this->style as $style)
00822 {
00823 $xml.= "<Style Tag=\"".$style[0]["tag"]."\" Class=\"".$style[0]["class"]."\">";
00824 foreach($style as $tag)
00825 {
00826 $xml.="<StyleParameter Name=\"".$tag["parameter"]."\" Value=\"".$tag["value"]."\"/>";
00827 }
00828 $xml.= "</Style>";
00829 }
00830 $xml.= "</StyleSheet>";
00831
00832 return $xml;
00833 }
00834
00835
00839 function exportXML($a_dir)
00840 {
00841 $file = $a_dir."/style.xml";
00842
00843
00844 if (!($fp = @fopen($file,"w")))
00845 {
00846 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
00847 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
00848 }
00849
00850
00851 chmod($file, 0770);
00852
00853
00854 fwrite($fp, $this->getXML());
00855
00856
00857 fclose($fp);
00858
00859 }
00860
00864 function createFromXMLFile($a_file)
00865 {
00866 global $ilDB;
00867
00868 parent::create();
00869 include_once("classes/class.ilStyleImportParser.php");
00870 $importParser = new ilStyleImportParser($a_file, $this);
00871 $importParser->startParsing();
00872
00873
00874 foreach ($this->style as $style)
00875 {
00876 foreach($style as $tag)
00877 {
00878 $q = "INSERT INTO style_parameter (style_id, tag, class, parameter, value) VALUES ".
00879 "(".$ilDB->quote($this->getId()).",".
00880 $ilDB->quote($tag["tag"]).",".
00881 $ilDB->quote($tag["class"]).
00882 ",".$ilDB->quote($tag["parameter"]).",".
00883 $ilDB->quote($tag["value"]).")";
00884 $this->ilias->db->query($q);
00885 }
00886 }
00887
00888
00889 $q = "INSERT INTO style_data (id, uptodate) VALUES ".
00890 "(".$ilDB->quote($this->getId()).", 0)";
00891 $ilDB->query($q);
00892
00893 $this->update();
00894 $this->read();
00895 $this->writeCSSFile();
00896 }
00897
00901 function getAvailableTags()
00902 {
00903 $tags = array("a.FootnoteLink", "a.FootnoteLink:hover", "a.IntLink", "a.IntLink:hover",
00904 "a.IntLink:visited", "a.IntLink:active",
00905 "a.ExtLink", "a.ExtLink:hover", "a.ExtLink:visited", "a.ExtLink:active",
00906 "div.Footnote", "div.LMNavigation", "div.Page", "div.PageTitle", "span.Comment",
00907 "span.Emph", "span.Quotation", "span.Strong",
00908 "td.Cell1", "td.Cell2", "td.Cell3", "td.Cell4",
00909 "p.Standard", "p.List", "p.Headline1", "p.Headline2", "p.Headline3",
00910 "p.Example", "p.Citation", "p.Mnemonic", "p.Additional", "p.Remark",
00911 "p.TableContent",
00912 "table.Media", "td.MediaCaption");
00913
00914 return $tags;
00915 }
00916
00917 function getAvailableParameters()
00918 {
00919 $pars = array(
00920 "font-family" => array(),
00921 "font-style" => array("italic", "oblique", "normal"),
00922 "font-variant" => array("small-caps", "normal"),
00923 "font-weight" => array("bold", "normal", "bolder", "lighter"),
00924 "font-stretch" => array("wider", "narrower", "condensed", "semi-condensed",
00925 "extra-condensed", "ultra-condensed", "expanded", "semi-expanded",
00926 "extra-expanded", "ultra-expanded", "normal"),
00927 "font-size" => array(),
00928 "word-spacing" => array(),
00929 "letter-spacing" => array(),
00930 "text-decoration" => array("underline", "overline", "line-through", "blink", "none"),
00931 "text-transform" => array("capitalize", "uppercase", "lowercase", "none"),
00932 "color" => array(),
00933
00934 "text-indent" => array(),
00935 "line-height" => array(),
00936 "vertical-align" => array("top", "middle", "bottom", "baseline", "sub", "super",
00937 "text-top", "text-bottom"),
00938 "text-align" => array("left", "center", "right", "justify"),
00939 "white-space" => array("normal", "pre", "nowrap"),
00940
00941 "margin" => array(),
00942 "margin-top" => array(),
00943 "margin-bottom" => array(),
00944 "margin-left" => array(),
00945 "margin-right" => array(),
00946
00947 "padding" => array(),
00948 "padding-top" => array(),
00949 "padding-bottom" => array(),
00950 "padding-left" => array(),
00951 "padding-right" => array(),
00952
00953 "border-width" => array(),
00954 "border-top-width" => array(),
00955 "border-bottom-width" => array(),
00956 "border-left-width" => array(),
00957 "border-right-width" => array(),
00958
00959 "border-color" => array(),
00960 "border-top-color" => array(),
00961 "border-bottom-color" => array(),
00962 "border-left-color" => array(),
00963 "border-right-color" => array(),
00964
00965 "border-style" => array("none", "hidden", "dotted", "dashed", "solid", "double",
00966 "groove", "ridge", "inset", "outset"),
00967 "border-top-style" => array("none", "hidden", "dotted", "dashed", "solid", "double",
00968 "groove", "ridge", "inset", "outset"),
00969 "border-bottom-style" => array("none", "hidden", "dotted", "dashed", "solid", "double",
00970 "groove", "ridge", "inset", "outset"),
00971 "border-left-style" => array("none", "hidden", "dotted", "dashed", "solid", "double",
00972 "groove", "ridge", "inset", "outset"),
00973 "border-right-style" => array("none", "hidden", "dotted", "dashed", "solid", "double",
00974 "groove", "ridge", "inset", "outset"),
00975
00976 "background-color" => array(),
00977 "background-image" => array(),
00978 "background-repeat" => array("repeat", "repeat-x", "repeat-y", "no-repeat"),
00979 "background-attachment" => array("fixed", "scroll"),
00980 "background-position" => array("top", "center", "middle", "bottom", "left", "right"),
00981
00982 "cursor" => array("auto", "default", "crosshair", "pointer", "move",
00983 "n-resize", "ne-resize", "e-resize", "se-resize", "s-resize", "sw-resize",
00984 "w-resize", "nw-resize", "text", "wait", "help"),
00985 "clear" => array ("non","left","right","both")
00986 );
00987
00988 return $pars;
00989 }
00990
00991 }
00992 ?>