ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilStyleImporter Class Reference

Importer class for style. More...

+ Inheritance diagram for ilStyleImporter:
+ Collaboration diagram for ilStyleImporter:

Public Member Functions

 init ()
 Init. More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import xml representation. More...
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 Constructor. More...
 
 init ()
 Init. More...
 
 setInstallId ($a_val)
 Set installation id. More...
 
 getInstallId ()
 Get installation id. More...
 
 setInstallUrl ($a_val)
 Set installation url. More...
 
 getInstallUrl ()
 Get installation url. More...
 
 setSchemaVersion ($a_val)
 Set schema version. More...
 
 getSchemaVersion ()
 Get schema version. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setSkipEntities ($a_val)
 Set skip entities. More...
 
 getSkipEntities ()
 Get skip entities. More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import xml representation. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilXmlImporter
 $skip_entities = array()
 

Detailed Description

Importer class for style.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id

Definition at line 13 of file class.ilStyleImporter.php.

Member Function Documentation

◆ importXmlRepresentation()

ilStyleImporter::importXmlRepresentation (   $a_entity,
  $a_id,
  $a_xml,
  $a_mapping 
)

Import xml representation.

Parameters
stringentity
stringtarget release
stringid
Returns
string xml string

Reimplemented from ilXmlImporter.

Definition at line 20 of file class.ilStyleImporter.php.

21 {
22 // see ilStyleExporter::getXmlRepresentation()
23 if(preg_match("/<StyleSheetExport><ImagePath>(.+)<\/ImagePath>/", $a_xml, $hits))
24 {
25 $path = $hits[1];
26 $a_xml = str_replace($hits[0], "", $a_xml);
27 $a_xml = str_replace("</StyleSheetExport>", "", $a_xml);
28 }
29
30 // temp xml-file
31 $tmp_file = $this->getImportDirectory()."/sty_".$a_id.".xml";
32 file_put_contents($tmp_file, $a_xml);
33
34 include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
35 $style = new ilObjStyleSheet();
36 $style->createFromXMLFile($tmp_file);
37 $new_id = $style->getId();
38
39 unlink($tmp_file);
40
41 // images
42 if($path)
43 {
44 $source = $this->getImportDirectory()."/".$path;
45 if(is_dir($source))
46 {
47 $target = $style->getImagesDirectory();
48 if(!is_dir($target))
49 {
50 ilUtil::makeDirParents($target);
51 }
52 ilUtil::rCopy($source, $target);
53 }
54 }
55
56 $a_mapping->addMapping("Services/Style", "sty", $a_id, $new_id);
57 }
Class ilObjStyleSheet.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getImportDirectory()
Get import directory.
$path
Definition: index.php:22

References $path, ilXmlImporter\getImportDirectory(), ilUtil\makeDirParents(), and ilUtil\rCopy().

+ Here is the call graph for this function:

◆ init()

ilStyleImporter::init ( )

Init.

Reimplemented from ilXmlImporter.

Definition at line 15 of file class.ilStyleImporter.php.

16 {
17
18 }

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