ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Base.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2016 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 require_once("libs/composer/vendor/autoload.php");
6 
7 require_once(__DIR__ . "/Renderer/ilIndependentTemplate.php");
8 require_once(__DIR__ . "/../../Services/Language/classes/class.ilLanguage.php");
9 
21 
23 {
24  public function getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks)
25  {
26  return new ilIndependentTemplate($path, $purge_unfilled_vars, $purge_unused_blocks);
27  }
28 }
29 
30 class NoUIFactory implements Factory
31 {
32  public function counter()
33  {
34  }
35  public function glyph()
36  {
37  }
38  public function button()
39  {
40  }
41  public function card()
42  {
43  }
44  public function deck(array $cards)
45  {
46  }
47  public function listing()
48  {
49  }
50  public function image()
51  {
52  }
53  public function legacy($content)
54  {
55  }
56  public function panel()
57  {
58  }
59  public function modal()
60  {
61  }
62  public function dropzone()
63  {
64  }
65  public function popover()
66  {
67  }
68  public function divider()
69  {
70  }
71  public function link()
72  {
73  }
74  public function dropdown()
75  {
76  }
77  public function item()
78  {
79  }
80  public function icon()
81  {
82  }
83  public function viewControl()
84  {
85  }
86  public function breadcrumbs(array $crumbs)
87  {
88  }
89  public function chart()
90  {
91  }
92  public function input()
93  {
94  }
95  public function table()
96  {
97  }
98  public function messageBox()
99  {
100  }
101 }
102 
104 {
105  public $resources = array();
106 
107  public function register($name)
108  {
109  $this->resources[] = $name;
110  }
111 }
112 
114 {
115  public $requested = array();
116  public function __construct()
117  {
118  }
119  public function txt($a_topic, $a_default_lang_fallback_mod = "")
120  {
121  $this->requested[] = $a_topic;
122  return $a_topic;
123  }
124  public function toJS($a_key, ilTemplate $a_tpl = null)
125  {
126  }
127  public $lang_module = 'common';
128  public function loadLanguageModule($lang_module)
129  {
130  }
131 }
132 
134 {
135  private $count = 0;
136  public $ids = array();
137  public function createId()
138  {
139  $this->count++;
140  $id = "id_" . $this->count;
141  $this->ids[] = $id;
142  return $id;
143  }
144  public $on_load_code = array();
145  public function addOnLoadCode($code)
146  {
147  $this->on_load_code[] = $code;
148  }
149  public function getOnLoadCodeAsync()
150  {
151  }
152 }
153 
155 {
156  public function _getRendererFor(IComponent $component)
157  {
158  return $this->getRendererFor($component);
159  }
160  public function _getContexts()
161  {
162  return $this->getContexts();
163  }
164 }
165 
167 {
168  protected $id = 0;
169 
170  protected function createId()
171  {
172  return 'signal_' . ++$this->id;
173  }
174 }
175 
177 {
178 }
179 
180 class DummyComponent implements IComponent
181 {
182  public function getCanonicalName()
183  {
184  return "DummyComponent";
185  }
186 }
187 
192 {
193  public function setUp()
194  {
195  assert_options(ASSERT_WARNING, 0);
196  }
197 
198  public function tearDown()
199  {
200  assert_options(ASSERT_WARNING, 1);
201  }
202 
203  public function getUIFactory()
204  {
205  return new NoUIFactory();
206  }
207 
208  public function getTemplateFactory()
209  {
210  return new ilIndependentTemplateFactory();
211  }
212 
213  public function getResourceRegistry()
214  {
215  return new LoggingRegistry();
216  }
217 
218  public function getLanguage()
219  {
220  return new ilLanguageMock();
221  }
222 
223  public function getJavaScriptBinding()
224  {
225  return new LoggingJavaScriptBinding();
226  }
227 
228  public function getDefaultRenderer(JavaScriptBinding $js_binding = null)
229  {
230  $ui_factory = $this->getUIFactory();
231  $tpl_factory = $this->getTemplateFactory();
232  $resource_registry = $this->getResourceRegistry();
233  $lng = $this->getLanguage();
234  if (!$js_binding) {
235  $js_binding = $this->getJavaScriptBinding();
236  }
237 
238  $component_renderer_loader
239  = new Render\LoaderCachingWrapper(
241  $resource_registry,
242  new Render\FSLoader(
244  $ui_factory,
245  $tpl_factory,
246  $lng,
247  $js_binding
248  ),
250  $ui_factory,
251  $tpl_factory,
252  $lng,
253  $js_binding
254  )
255  )
256  )
257  );
258  return new TestDefaultRenderer($component_renderer_loader);
259  }
260 
261  public function normalizeHTML($html)
262  {
263  return trim(str_replace("\n", "", $html));
264  }
265 
270  public function assertHTMLEquals($expected_html_as_string, $html_as_string)
271  {
272  $html = new DOMDocument();
273  $html->formatOutput = true;
274  $html->preserveWhiteSpace = false;
275  $expected = new DOMDocument();
276  $expected->formatOutput = true;
277  $expected->preserveWhiteSpace = false;
278  $html->loadXML($this->normalizeHTML($html_as_string));
279  $expected->loadXML($this->normalizeHTML($expected_html_as_string));
280  $this->assertEquals($expected->saveHTML(), $html->saveHTML());
281  }
282 }
Registry for resources required by rendered output like Javascript or CSS.
card()
description: purpose: > A card is a flexible content container for small chunks of structured data...
Definition: Base.php:41
$path
Definition: aliased.php:25
item()
description: purpose: > An item displays a unique entity within the system.
Definition: Base.php:77
breadcrumbs(array $crumbs)
description: purpose: > Breadcrumbs is a supplemental navigation scheme.
Definition: Base.php:86
dropzone()
description: purpose: > Dropzones are containers used to drop either files or other HTML elements...
Definition: Base.php:62
icon()
description: purpose: > Icons are quickly comprehensible and recognizable graphics.
Definition: Base.php:80
getCanonicalName()
Get the canonical name of the component.
Definition: Base.php:182
viewControl()
description: purpose: > View Controls switch between different visualisation of data.
Definition: Base.php:83
Loads renderers for components from the file system.
Definition: FSLoader.php:20
$code
Definition: example_050.php:99
link()
description: purpose: > Links are used navigate to other resources or views of the system...
Definition: Base.php:71
if(!array_key_exists('StateId', $_REQUEST)) $id
Registers resources for retreived renderers at a ResourceRegistry.
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
messageBox()
description: purpose: > Message Boxes inform the user about the state of the system or an ongoing us...
Definition: Base.php:98
normalizeHTML($html)
Definition: Base.php:261
deck(array $cards)
description: purpose: > Decks are used to display multiple Cards in a grid.
Definition: Base.php:44
getOnLoadCodeAsync()
Get all the registered on-load javascript code for the async context, e.g.
Definition: Base.php:149
getJavaScriptBinding()
Definition: Base.php:223
glyph()
description: purpose: > Glyphs map a generally known concept or symbol to a specific concept in ILIA...
Definition: Base.php:35
toJS($a_key, ilTemplate $a_tpl=null)
Definition: Base.php:124
Provides common functionality for UI tests.
Definition: Base.php:191
$lng
This is how the factory for UI elements looks.
Definition: Factory.php:15
chart()
description: purpose: > Charts are used to graphically represent data in various forms such as maps...
Definition: Base.php:89
panel()
description: purpose: > Panels are used to group titled content.
Definition: Base.php:56
special template class to simplify handling of ITX/PEAR
legacy($content)
description: purpose: > This component is used to wrap an existing ILIAS UI element into a UI compon...
Definition: Base.php:53
input()
description: purpose: > In opposite to components with a purely receptive or at most navigational ch...
Definition: Base.php:92
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
modal()
description: purpose: The Modal forces users to focus on the task at hand.
Definition: Base.php:59
Provides methods to interface with javascript.
dropdown()
description: purpose: > Dropdowns reveal a list of interactions that change the system’s status or ...
Definition: Base.php:74
getTemplateFactory()
Definition: Base.php:208
image()
description: purpose: The Image component is used to display images of various sources.
Definition: Base.php:50
addOnLoadCode($code)
Add some JavaScript-statements to the on-load handler of the page.
Definition: Base.php:145
getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks)
Get template instance.
Definition: Base.php:24
getResourceRegistry()
Definition: Base.php:213
listing()
description: purpose: > Listings are used to structure itemised textual information.
Definition: Base.php:47
_getRendererFor(IComponent $component)
Definition: Base.php:156
language handling
table()
description: purpose: > Tables present a set of uniformly structured data.
Definition: Base.php:95
createId()
Create a fresh unique id.
Definition: Base.php:137
button()
description: purpose: > Buttons trigger interactions that change the system’s or view&#39;s status...
Definition: Base.php:38
txt($a_topic, $a_default_lang_fallback_mod="")
Definition: Base.php:119
loadLanguageModule($lang_module)
Definition: Base.php:128
Interface for a factory that provides templates.
$html
Definition: example_001.php:87
divider()
description: purpose: > A divider marks a thematic change in a sequence of other components...
Definition: Base.php:68
counter()
description: purpose: > Counter inform users about the quantity of items indicated by a glyph...
Definition: Base.php:32
popover()
description: purpose: > Popovers can be used when space is scarce i.e.
Definition: Base.php:65