ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
17  protected $db;
18 
19  public $styles = array();
20 
24  public function __construct()
25  {
26  global $DIC;
27 
28  $this->db = $DIC->database();
29  $this->read();
30  }
31 
37  public function addStyle($a_style_id)
38  {
39  $this->styles[$a_style_id] =
40  array("id" => $a_style_id,
41  "title" => ilObject::_lookupTitle($a_style_id));
42  }
43 
44 
48  public function removeStyle($a_id)
49  {
50  unset($this->styles[$a_id]);
51  }
52 
53 
59  public function update()
60  {
61  $ilDB = $this->db;
62 
63  // save styles of style folder
64  // note: there are no different style folders in ILIAS, only the one in the settings
65  $q = "DELETE FROM style_folder_styles";
66  $ilDB->manipulate($q);
67  foreach ($this->styles as $style) {
68  $q = "INSERT INTO style_folder_styles (folder_id, style_id) VALUES" .
69  "(" . $ilDB->quote((int) 0, "integer") . ", " .
70  $ilDB->quote((int) $style["id"], "integer") . ")";
71  $ilDB->manipulate($q);
72  }
73 
74  return true;
75  }
76 
80  public function read()
81  {
82  $ilDB = $this->db;
83 
84  // get styles of style folder
85  $q = "SELECT * FROM style_folder_styles JOIN style_data ON (style_id = style_data.id)";
86 
87  $style_set = $ilDB->query($q);
88  $this->styles = array();
89  while ($style_rec = $ilDB->fetchAssoc($style_set)) {
90  $this->styles[$style_rec["style_id"]] =
91  array("id" => $style_rec["style_id"],
92  "title" => ilObject::_lookupTitle($style_rec["style_id"]),
93  "category" => $style_rec["category"]);
94  }
95 
96  $this->styles =
97  ilUtil::sortArray($this->styles, "title", "asc", false, true);
98  }
99 
100 
106  public function getStyles()
107  {
108  return $this->styles;
109  }
110 }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
addStyle($a_style_id)
Add style to style folder.
$style
Definition: example_012.php:70
global $DIC
Definition: saml.php:7
static _lookupTitle($a_id)
lookup object title
removeStyle($a_id)
remove Style from style list
Create styles array
The data for the language used.
global $ilDB