ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilImportExportFactory.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
12 const PLUGINS_DIR = "Plugins";
13
14 public static function getExporterClass($a_type)
15 {
19 global $objDefinition;
20
21 if($objDefinition->isPlugin($a_type))
22 {
23 $classname = 'il'.$objDefinition->getClassName($a_type).'Exporter';
24 $location = $objDefinition->getLocation($a_type);
25 if(include_once $location.'/class.'.$classname.'.php')
26 {
27 return $classname;
28 }
29 }
30 else
31 {
32
33 $comp = $objDefinition->getComponentForType($a_type);
34 $class = array_pop(explode("/", $comp));
35 $class = "il".$class."Exporter";
36
37 // the next line had a "@" in front of the include_once
38 // I removed this because it tages ages to track down errors
39 // if the include class contains parse errors.
40 // Alex, 20 Jul 2012
41 if(include_once "./".$comp."/classes/class.".$class.".php")
42 {
43 return $class;
44 }
45 }
46
47 throw new InvalidArgumentException('Invalid exporter type given');
48 }
49
50 public static function getComponentForExport($a_type)
51 {
55 global $objDefinition;
56
57 if($objDefinition->isPlugin($a_type))
58 {
59 return self::PLUGINS_DIR."/".$a_type;
60 }
61 else
62 {
63 return $objDefinition->getComponentForType($a_type);
64 }
65 }
66
67 public static function getImporterClass($a_component)
68 {
72 global $objDefinition;
73
74 $parts = explode('/', $a_component);
75 $component_type = $parts[0];
76 $component = $parts[1];
77
78 if($component_type == self::PLUGINS_DIR &&
79 $objDefinition->isPlugin($component))
80 {
81 $classname = 'il'.$objDefinition->getClassName($component).'Importer';
82 $location = $objDefinition->getLocation($component);
83 if(include_once $location.'/class.'.$classname.'.php')
84 {
85 return $classname;
86 }
87 }
88 else
89 {
90 $class = "il".$component."Importer";
91 if(include_once "./".$a_component."/classes/class.".$class.".php")
92 {
93 return $class;
94 }
95 }
96
97 throw new InvalidArgumentException('Invalid importer type given');
98 }
99}
100?>
$location
Definition: buildRTE.php:44
An exception for terminatinating execution or to throw for unit testing.
Factory for importer/exporter implementers.
$a_type
Definition: workflow.php:93