ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilContentStyleSettings.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 var $styles = array();
15
19 function __construct()
20 {
21 $this->read();
22 }
23
29 public function addStyle($a_style_id)
30 {
31 $this->styles[$a_style_id] =
32 array("id" => $a_style_id,
33 "title" => ilObject::_lookupTitle($a_style_id));
34 }
35
36
40 public function removeStyle($a_id)
41 {
42 unset($this->styles[$a_id]);
43 }
44
45
51 public function update()
52 {
53 global $ilDB;
54
55 // save styles of style folder
56 // note: there are no different style folders in ILIAS, only the one in the settings
57 $q = "DELETE FROM style_folder_styles";
58 $ilDB->manipulate($q);
59 foreach($this->styles as $style)
60 {
61 $q = "INSERT INTO style_folder_styles (folder_id, style_id) VALUES".
62 "(".$ilDB->quote((int) 0, "integer").", ".
63 $ilDB->quote((int) $style["id"], "integer").")";
64 $ilDB->manipulate($q);
65 }
66
67 return true;
68 }
69
73 function read()
74 {
75 global $ilDB;
76
77 // get styles of style folder
78 $q = "SELECT * FROM style_folder_styles JOIN style_data ON (style_id = style_data.id)";
79
80 $style_set = $ilDB->query($q);
81 $this->styles = array();
82 while ($style_rec = $ilDB->fetchAssoc($style_set))
83 {
84 $this->styles[$style_rec["style_id"]] =
85 array("id" => $style_rec["style_id"],
86 "title" => ilObject::_lookupTitle($style_rec["style_id"]),
87 "category" => $style_rec["category"]);
88 }
89
90 $this->styles =
91 ilUtil::sortArray($this->styles, "title", "asc", false, true);
92 }
93
94
100 function getStyles()
101 {
102 return $this->styles;
103 }
104
105}
106?>
An exception for terminatinating execution or to throw for unit testing.
addStyle($a_style_id)
Add style to style folder.
removeStyle($a_id)
remove Style from style list
static _lookupTitle($a_id)
lookup object title
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$style
Definition: example_012.php:70
global $ilDB