ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilStyleDataSet Class Reference

Style Data set class. More...

+ Inheritance diagram for ilStyleDataSet:
+ Collaboration diagram for ilStyleDataSet:

Public Member Functions

 __construct ()
 constructor More...
 
 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. More...
 
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true, $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ( $a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ... More...
 
 addRecordsXml ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 
 setCurrentInstallationId ($a_val)
 Set current installation id. More...
 
 getCurrentInstallationId ()
 Get current installation id. More...
 

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity. More...
 
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes ($a_entity, $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 createObjectExportId ($a_type, $a_id)
 Build ilias export id. More...
 
 parseObjectExportId ($a_id, $a_fallback_id=null)
 Parse export id. More...
 

Protected Attributes

 $log
 
- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 
 $db
 
 $ds_log
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
 $dircnt
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 

Detailed Description

Style Data set class.

This class implements the following entities:

  • sty: table object_data
  • sty_setting: table style_setting
  • sty_char: table style classes
  • sty_parameter: table style_parameter
  • sty_color: table style colors
  • sty_template: table style_template
  • sty_template_class: table style_template_class
  • sty_media_query: table sty_media_query
  • sty_usage: table style_usage
  • object_style: this is a special entity which allows to export using the ID of the consuming object (e.g. wiki) the "sty" entity will be detemined and exported afterwards (if a non global style has been assigned)
Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 27 of file class.ilStyleDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilStyleDataSet::__construct ( )

constructor

Parameters

Definition at line 40 of file class.ilStyleDataSet.php.

References $DIC, and ilLoggerFactory\getLogger().

41  {
42  global $DIC;
43 
44  $this->db = $DIC->database();
45  parent::__construct();
46  $this->log = ilLoggerFactory::getLogger('styl');
47  $this->log->debug("constructed");
48  }
global $DIC
Definition: saml.php:7
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ getDependencies()

ilStyleDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

Definition at line 334 of file class.ilStyleDataSet.php.

References ilObject\_lookupType(), array, and ilObjStyleSheet\lookupObjectStyle().

335  {
336  $this->ds_log->debug("entity: " . $a_entity . ", rec: " . print_r($a_rec, true));
337  switch ($a_entity) {
338  case "object_style":
339  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
340  $this->ds_log->debug("object id: " . $a_rec["ObjectId"]);
341  $style_id = ilObjStyleSheet::lookupObjectStyle($a_rec["ObjectId"]);
342  $this->ds_log->debug("style id: " . $style_id);
343  //if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id))
344  if ($style_id > 0 && ilObject::_lookupType($style_id) == "sty") { // #0019337 always export style, if valid
345  return array(
346  "sty" => array("ids" => $style_id));
347  }
348  return array();
349  break;
350 
351  case "sty":
352  return array(
353  "sty_setting" => array("ids" => $a_rec["Id"]),
354  "sty_media_query" => array("ids" => $a_rec["Id"]),
355  "sty_char" => array("ids" => $a_rec["Id"]),
356  "sty_color" => array("ids" => $a_rec["Id"]),
357  "sty_parameter" => array("ids" => $a_rec["Id"]),
358  "sty_template" => array("ids" => $a_rec["Id"]),
359  "sty_usage" => array("ids" => $a_rec["Id"])
360  );
361 
362  case "sty_template":
363  return array(
364  "sty_template_class" => array("ids" => $a_rec["Id"])
365  );
366  }
367 
368  return false;
369  }
static lookupObjectStyle($a_obj_id)
Lookup object style.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

◆ getSupportedVersions()

ilStyleDataSet::getSupportedVersions ( )

Get supported versions.

Returns
string version

Definition at line 56 of file class.ilStyleDataSet.php.

References array.

57  {
58  return array("5.1.0");
59  }
Create styles array
The data for the language used.

◆ getTypes()

ilStyleDataSet::getTypes (   $a_entity,
  $a_version 
)
protected

Get field types for entity.

Parameters
string$a_entityentity
string$a_versionversion number
Returns
array types array

Definition at line 79 of file class.ilStyleDataSet.php.

References array.

80  {
81  if ($a_entity == "sty") {
82  switch ($a_version) {
83  case "5.1.0":
84  return array(
85  "Id" => "integer",
86  "Title" => "text",
87  "Description" => "text",
88  "ImagesDir" => "directory"
89  );
90  }
91  }
92 
93  if ($a_entity == "object_style") {
94  switch ($a_version) {
95  case "5.1.0":
96  return array(
97  "ObjectId" => "integer"
98  );
99  }
100  }
101 
102  if ($a_entity == "sty_setting") {
103  switch ($a_version) {
104  case "5.1.0":
105  return array(
106  "StyleId" => "integer",
107  "Name" => "test",
108  "Value" => "text"
109  );
110  }
111  }
112 
113  if ($a_entity == "sty_char") {
114  switch ($a_version) {
115  case "5.1.0":
116  return array(
117  "StyleId" => "integer",
118  "Type" => "text",
119  "Characteristic" => "text",
120  "Hide" => "integer"
121  );
122  }
123  }
124 
125  if ($a_entity == "sty_parameter") {
126  switch ($a_version) {
127  case "5.1.0":
128  return array(
129  "StyleId" => "integer",
130  "Tag" => "text",
131  "Class" => "text",
132  "Parameter" => "text",
133  "Value" => "text",
134  "Type" => "text",
135  "MqId" => "integer",
136  "Custom" => "integer"
137  );
138  }
139  }
140 
141  if ($a_entity == "sty_color") {
142  switch ($a_version) {
143  case "5.1.0":
144  return array(
145  "StyleId" => "integer",
146  "ColorName" => "text",
147  "ColorCode" => "text"
148  );
149  }
150  }
151 
152  if ($a_entity == "sty_media_query") {
153  switch ($a_version) {
154  case "5.1.0":
155  return array(
156  "Id" => "integer",
157  "StyleId" => "integer",
158  "OrderNr" => "integer",
159  "MQuery" => "text"
160  );
161  }
162  }
163 
164  if ($a_entity == "sty_template") {
165  switch ($a_version) {
166  case "5.1.0":
167  return array(
168  "Id" => "integer",
169  "StyleId" => "integer",
170  "Name" => "text",
171  "Preview" => "text",
172  "TempType" => "text"
173  );
174  }
175  }
176 
177  if ($a_entity == "sty_template_class") {
178  switch ($a_version) {
179  case "5.1.0":
180  return array(
181  "TemplateId" => "integer",
182  "ClassType" => "text",
183  "Class" => "text"
184  );
185  }
186  }
187 
188  if ($a_entity == "sty_usage") {
189  switch ($a_version) {
190  case "5.1.0":
191  return array(
192  "ObjId" => "integer",
193  "StyleId" => "integer"
194  );
195  }
196  }
197  }
Create styles array
The data for the language used.

◆ getXmlNamespace()

ilStyleDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

Definition at line 67 of file class.ilStyleDataSet.php.

68  {
69  return "http://www.ilias.de/xml/Services/Style/" . $a_entity;
70  }

◆ getXmlRecord()

ilStyleDataSet::getXmlRecord (   $a_entity,
  $a_version,
  $a_set 
)

Get xml record.

Parameters

Definition at line 205 of file class.ilStyleDataSet.php.

References ilObjStyleSheet\_getImagesDirectory().

206  {
207  if ($a_entity == "sty") {
208  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
209  $dir = ilObjStyleSheet::_getImagesDirectory($a_set["Id"]);
210  $a_set["ImagesDir"] = $dir;
211  }
212 
213  return $a_set;
214  }
static _getImagesDirectory($a_style_id)
Get images directory.
+ Here is the call graph for this function:

◆ importRecord()

ilStyleDataSet::importRecord (   $a_entity,
  $a_types,
  $a_rec,
  $a_mapping,
  $a_schema_version 
)

Import record.

Parameters

Definition at line 378 of file class.ilStyleDataSet.php.

References ilObjStyleSheet\_getImagesDirectory(), array, ilDataSet\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), ilUtil\rCopy(), and ilObjStyleSheet\writeStyleUsage().

379  {
380  switch ($a_entity) {
381  case "sty":
382  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
383  $this->log->debug("Entity: " . $a_entity);
384  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
385  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
386  } else {
387  $newObj = new ilObjStyleSheet();
388  $newObj->create(0, true);
389  }
390 
391  $newObj->setTitle($a_rec["Title"]);
392  $newObj->setDescription($a_rec["Description"]);
393  $newObj->update(true);
394 
395  $this->current_obj = $newObj;
396  $a_mapping->addMapping("Services/Style", "sty", $a_rec["Id"], $newObj->getId());
397  $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
398  $this->log->debug("Added mapping Services/Style sty " . $a_rec["Id"] . " > " . $newObj->getId());
399 
400  $dir = str_replace("..", "", $a_rec["ImagesDir"]);
401  if ($dir != "" && $this->getImportDirectory() != "") {
402  $source_dir = $this->getImportDirectory() . "/" . $dir;
403  $target_dir = $dir = ilObjStyleSheet::_getImagesDirectory($newObj->getId());
404  ilUtil::rCopy($source_dir, $target_dir);
405  }
406  break;
407 
408  case "sty_setting":
409  $this->current_obj->writeStyleSetting($a_rec["Name"], $a_rec["Value"]);
410  break;
411 
412  case "sty_char":
413  $this->current_obj->addCharacteristic($a_rec["Type"], $a_rec["Characteristic"], $a_rec["Hide"]);
414  break;
415 
416  case "sty_parameter":
417  $mq_id = (int) $a_mapping->getMapping("Services/Style", "media_query", $a_rec["MqId"]);
418  $this->current_obj->replaceStylePar($a_rec["Tag"], $a_rec["Class"], $a_rec["Parameter"], $a_rec["Value"], $a_rec["Type"], $mq_id, $a_rec["Custom"]);
419  break;
420 
421  case "sty_color":
422  $this->current_obj->addColor($a_rec["ColorName"], $a_rec["ColorCode"]);
423  break;
424 
425  case "sty_media_query":
426  $mq_id = $this->current_obj->addMediaQuery($a_rec["MQuery"], $a_rec["OrderNr"]);
427  $a_mapping->addMapping("Services/Style", "media_query", $a_rec["Id"], $mq_id);
428  break;
429 
430  case "sty_template":
431  $tid = $this->current_obj->addTemplate($a_rec["TempType"], $a_rec["Name"], array());
432  $a_mapping->addMapping("Services/Style", "template", $a_rec["Id"], $tid);
433  break;
434 
435  case "sty_template_class":
436  $tid = (int) $a_mapping->getMapping("Services/Style", "template", $a_rec["TemplateId"]);
437  $this->current_obj->addTemplateClass($tid, $a_rec["ClassType"], $a_rec["Class"]);
438  break;
439 
440  case "sty_usage":
441  $obj_id = (int) $a_mapping->getMapping("Services/Object", "obj", $a_rec["ObjId"]);
442  $style_id = (int) $a_mapping->getMapping("Services/Style", "sty", $a_rec["StyleId"]);
443  if ($obj_id > 0 && $style_id > 0) {
444  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
445  ilObjStyleSheet::writeStyleUsage($obj_id, $style_id);
446  }
447  break;
448  }
449  }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
getImportDirectory()
Get import directory.
static writeStyleUsage($a_obj_id, $a_style_id)
Write style usage.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
static _getImagesDirectory($a_style_id)
Get images directory.
Class ilObjStyleSheet.
+ Here is the call graph for this function:

◆ readData()

ilStyleDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters

Definition at line 222 of file class.ilStyleDataSet.php.

References ilDataSet\$db, $id, $ilDB, array, data, and ilDataSet\getDirectDataFromQuery().

223  {
224  $ilDB = $this->db;
225 
226  if (!is_array($a_ids)) {
227  $a_ids = array($a_ids);
228  }
229 
230  if ($a_entity == "object_style") {
231  switch ($a_version) {
232  case "5.1.0":
233  foreach ($a_ids as $id) {
234  $this->data[] = array("ObjectId" => $id);
235  }
236  break;
237  }
238  }
239 
240  if ($a_entity == "sty") {
241  switch ($a_version) {
242  case "5.1.0":
243  $this->getDirectDataFromQuery("SELECT o.title, o.description, o.obj_id id" .
244  " FROM object_data o " .
245  " WHERE " . $ilDB->in("o.obj_id", $a_ids, false, "integer"));
246  break;
247  }
248  }
249 
250  if ($a_entity == "sty_setting") {
251  switch ($a_version) {
252  case "5.1.0":
253  $this->getDirectDataFromQuery("SELECT style_id, name, value" .
254  " FROM style_setting " .
255  " WHERE " . $ilDB->in("style_id", $a_ids, false, "integer"));
256  break;
257  }
258  }
259 
260  if ($a_entity == "sty_char") {
261  switch ($a_version) {
262  case "5.1.0":
263  $this->getDirectDataFromQuery("SELECT style_id, type, characteristic, hide" .
264  " FROM style_char " .
265  " WHERE " . $ilDB->in("style_id", $a_ids, false, "integer"));
266  break;
267  }
268  }
269 
270  if ($a_entity == "sty_parameter") {
271  switch ($a_version) {
272  case "5.1.0":
273  $this->getDirectDataFromQuery("SELECT style_id, tag, class, parameter, value, type, mq_id, custom" .
274  " FROM style_parameter " .
275  " WHERE " . $ilDB->in("style_id", $a_ids, false, "integer"));
276  break;
277  }
278  }
279 
280  if ($a_entity == "sty_color") {
281  switch ($a_version) {
282  case "5.1.0":
283  $this->getDirectDataFromQuery("SELECT style_id, color_name, color_code" .
284  " FROM style_color " .
285  " WHERE " . $ilDB->in("style_id", $a_ids, false, "integer"));
286  break;
287  }
288  }
289 
290  if ($a_entity == "sty_media_query") {
291  switch ($a_version) {
292  case "5.1.0":
293  $this->getDirectDataFromQuery("SELECT id, style_id, order_nr, mquery m_query" .
294  " FROM sty_media_query " .
295  " WHERE " . $ilDB->in("style_id", $a_ids, false, "integer"));
296  break;
297  }
298  }
299 
300  if ($a_entity == "sty_template") {
301  switch ($a_version) {
302  case "5.1.0":
303  $this->getDirectDataFromQuery("SELECT id, style_id, name, preview, temp_type" .
304  " FROM style_template " .
305  " WHERE " . $ilDB->in("style_id", $a_ids, false, "integer"));
306  break;
307  }
308  }
309 
310  if ($a_entity == "sty_template_class") {
311  switch ($a_version) {
312  case "5.1.0":
313  $this->getDirectDataFromQuery("SELECT template_id, class_type, class" .
314  " FROM style_template_class " .
315  " WHERE " . $ilDB->in("template_id", $a_ids, false, "integer"));
316  break;
317  }
318  }
319 
320  if ($a_entity == "sty_usage") {
321  switch ($a_version) {
322  case "5.1.0":
323  $this->getDirectDataFromQuery("SELECT obj_id, style_id" .
324  " FROM style_usage " .
325  " WHERE " . $ilDB->in("style_id", $a_ids, false, "integer"));
326  break;
327  }
328  }
329  }
Add some data
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true, $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $log

ilStyleDataSet::$log
protected

Definition at line 32 of file class.ilStyleDataSet.php.


The documentation for this class was generated from the following file: