ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 = ""
 

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 ilLoggerFactory\getLogger().

41  {
42  parent::__construct();
43  $this->log = ilLoggerFactory::getLogger('styl');
44  $this->log->debug("constructed");
45  }
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 375 of file class.ilStyleDataSet.php.

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

376  {
377  $this->ds_log->debug("entity: ".$a_entity.", rec: ".print_r($a_rec, true));
378  switch ($a_entity)
379  {
380  case "object_style":
381  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
382  $this->ds_log->debug("object id: ".$a_rec["ObjectId"]);
383  $style_id = ilObjStyleSheet::lookupObjectStyle($a_rec["ObjectId"]);
384  $this->ds_log->debug("style id: ".$style_id);
385  //if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id))
386  if ($style_id > 0 && ilObject::_lookupType($style_id) == "sty") // #0019337 always export style, if valid
387  {
388  return array (
389  "sty" => array("ids" => $style_id));
390  }
391  return array();
392  break;
393 
394  case "sty":
395  return array (
396  "sty_setting" => array("ids" => $a_rec["Id"]),
397  "sty_media_query" => array("ids" => $a_rec["Id"]),
398  "sty_char" => array("ids" => $a_rec["Id"]),
399  "sty_color" => array("ids" => $a_rec["Id"]),
400  "sty_parameter" => array("ids" => $a_rec["Id"]),
401  "sty_template" => array("ids" => $a_rec["Id"]),
402  "sty_usage" => array("ids" => $a_rec["Id"])
403  );
404 
405  case "sty_template":
406  return array (
407  "sty_template_class" => array("ids" => $a_rec["Id"])
408  );
409  }
410 
411  return false;
412  }
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 53 of file class.ilStyleDataSet.php.

References array.

54  {
55  return array("5.1.0");
56  }
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 76 of file class.ilStyleDataSet.php.

References array.

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

◆ getXmlNamespace()

ilStyleDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

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

65  {
66  return "http://www.ilias.de/xml/Services/Style/".$a_entity;
67  }

◆ getXmlRecord()

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

Get xml record.

Parameters

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

References ilObjStyleSheet\_getImagesDirectory().

224  {
225  if ($a_entity == "sty")
226  {
227  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
228  $dir = ilObjStyleSheet::_getImagesDirectory($a_set["Id"]);
229  $a_set["ImagesDir"] = $dir;
230  }
231 
232  return $a_set;
233  }
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 421 of file class.ilStyleDataSet.php.

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

422  {
423  switch ($a_entity)
424  {
425  case "sty":
426  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
427  $this->log->debug("Entity: ".$a_entity);
428  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
429  {
430  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
431  }
432  else
433  {
434  $newObj = new ilObjStyleSheet();
435  $newObj->create(0, true);
436  }
437 
438  $newObj->setTitle($a_rec["Title"]);
439  $newObj->setDescription($a_rec["Description"]);
440  $newObj->update(true);
441 
442  $this->current_obj = $newObj;
443  $a_mapping->addMapping("Services/Style", "sty", $a_rec["Id"], $newObj->getId());
444  $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
445  $this->log->debug("Added mapping Services/Style sty ".$a_rec["Id"]." > ".$newObj->getId());
446 
447  $dir = str_replace("..", "", $a_rec["ImagesDir"]);
448  if ($dir != "" && $this->getImportDirectory() != "")
449  {
450  $source_dir = $this->getImportDirectory()."/".$dir;
451  $target_dir = $dir = ilObjStyleSheet::_getImagesDirectory($newObj->getId());
452  ilUtil::rCopy($source_dir, $target_dir);
453  }
454  break;
455 
456  case "sty_setting":
457  $this->current_obj->writeStyleSetting($a_rec["Name"], $a_rec["Value"]);
458  break;
459 
460  case "sty_char":
461  $this->current_obj->addCharacteristic($a_rec["Type"], $a_rec["Characteristic"], $a_rec["Hide"]);
462  break;
463 
464  case "sty_parameter":
465  $mq_id = (int) $a_mapping->getMapping("Services/Style", "media_query", $a_rec["MqId"]);
466  $this->current_obj->replaceStylePar($a_rec["Tag"], $a_rec["Class"], $a_rec["Parameter"], $a_rec["Value"], $a_rec["Type"], $mq_id, $a_rec["Custom"]);
467  break;
468 
469  case "sty_color":
470  $this->current_obj->addColor($a_rec["ColorName"], $a_rec["ColorCode"]);
471  break;
472 
473  case "sty_media_query":
474  $mq_id = $this->current_obj->addMediaQuery($a_rec["MQuery"], $a_rec["OrderNr"]);
475  $a_mapping->addMapping("Services/Style", "media_query", $a_rec["Id"], $mq_id);
476  break;
477 
478  case "sty_template":
479  $tid = $this->current_obj->addTemplate($a_rec["TempType"], $a_rec["Name"], array());
480  $a_mapping->addMapping("Services/Style", "template", $a_rec["Id"], $tid);
481  break;
482 
483  case "sty_template_class":
484  $tid = (int) $a_mapping->getMapping("Services/Style", "template", $a_rec["TemplateId"]);
485  $this->current_obj->addTemplateClass($tid, $a_rec["ClassType"], $a_rec["Class"]);
486  break;
487 
488  case "sty_usage":
489  $obj_id = (int) $a_mapping->getMapping("Services/Object", "obj", $a_rec["ObjId"]);
490  $style_id = (int) $a_mapping->getMapping("Services/Style", "sty", $a_rec["StyleId"]);
491  if ($obj_id > 0 && $style_id > 0)
492  {
493  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
494  ilObjStyleSheet::writeStyleUsage($obj_id, $style_id);
495  }
496  break;
497  }
498  }
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 241 of file class.ilStyleDataSet.php.

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

242  {
243  global $ilDB;
244 
245  if (!is_array($a_ids))
246  {
247  $a_ids = array($a_ids);
248  }
249 
250  if ($a_entity == "object_style")
251  {
252  switch ($a_version)
253  {
254  case "5.1.0":
255  foreach ($a_ids as $id)
256  {
257  $this->data[] = array("ObjectId" => $id);
258  }
259  break;
260  }
261  }
262 
263  if ($a_entity == "sty")
264  {
265  switch ($a_version)
266  {
267  case "5.1.0":
268  $this->getDirectDataFromQuery("SELECT o.title, o.description, o.obj_id id".
269  " FROM object_data o ".
270  " WHERE ".$ilDB->in("o.obj_id", $a_ids, false, "integer"));
271  break;
272  }
273  }
274 
275  if ($a_entity == "sty_setting")
276  {
277  switch ($a_version)
278  {
279  case "5.1.0":
280  $this->getDirectDataFromQuery("SELECT style_id, name, value".
281  " FROM style_setting ".
282  " WHERE ".$ilDB->in("style_id", $a_ids, false, "integer"));
283  break;
284  }
285  }
286 
287  if ($a_entity == "sty_char")
288  {
289  switch ($a_version)
290  {
291  case "5.1.0":
292  $this->getDirectDataFromQuery("SELECT style_id, type, characteristic, hide".
293  " FROM style_char ".
294  " WHERE ".$ilDB->in("style_id", $a_ids, false, "integer"));
295  break;
296  }
297  }
298 
299  if ($a_entity == "sty_parameter")
300  {
301  switch ($a_version)
302  {
303  case "5.1.0":
304  $this->getDirectDataFromQuery("SELECT style_id, tag, class, parameter, value, type, mq_id, custom".
305  " FROM style_parameter ".
306  " WHERE ".$ilDB->in("style_id", $a_ids, false, "integer"));
307  break;
308  }
309  }
310 
311  if ($a_entity == "sty_color")
312  {
313  switch ($a_version)
314  {
315  case "5.1.0":
316  $this->getDirectDataFromQuery("SELECT style_id, color_name, color_code".
317  " FROM style_color ".
318  " WHERE ".$ilDB->in("style_id", $a_ids, false, "integer"));
319  break;
320  }
321  }
322 
323  if ($a_entity == "sty_media_query")
324  {
325  switch ($a_version)
326  {
327  case "5.1.0":
328  $this->getDirectDataFromQuery("SELECT id, style_id, order_nr, mquery m_query".
329  " FROM sty_media_query ".
330  " WHERE ".$ilDB->in("style_id", $a_ids, false, "integer"));
331  break;
332  }
333  }
334 
335  if ($a_entity == "sty_template")
336  {
337  switch ($a_version)
338  {
339  case "5.1.0":
340  $this->getDirectDataFromQuery("SELECT id, style_id, name, preview, temp_type".
341  " FROM style_template ".
342  " WHERE ".$ilDB->in("style_id", $a_ids, false, "integer"));
343  break;
344  }
345  }
346 
347  if ($a_entity == "sty_template_class")
348  {
349  switch ($a_version)
350  {
351  case "5.1.0":
352  $this->getDirectDataFromQuery("SELECT template_id, class_type, class".
353  " FROM style_template_class ".
354  " WHERE ".$ilDB->in("template_id", $a_ids, false, "integer"));
355  break;
356  }
357  }
358 
359  if ($a_entity == "sty_usage")
360  {
361  switch ($a_version)
362  {
363  case "5.1.0":
364  $this->getDirectDataFromQuery("SELECT obj_id, style_id".
365  " FROM style_usage ".
366  " WHERE ".$ilDB->in("style_id", $a_ids, false, "integer"));
367  break;
368  }
369  }
370  }
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 ...
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: