ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
20 
22 {
23  public function getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks)
24  {
25  return new ilIndependentTemplate($path, $purge_unfilled_vars, $purge_unused_blocks);
26  }
27 }
28 
29 class NoUIFactory implements Factory
30 {
31  public function counter()
32  {
33  }
34  public function glyph()
35  {
36  }
37  public function button()
38  {
39  }
40  public function card($title, \ILIAS\UI\Component\Image\Image $image = null)
41  {
42  }
43  public function deck(array $cards)
44  {
45  }
46  public function listing()
47  {
48  }
49  public function image()
50  {
51  }
52  public function legacy($content)
53  {
54  }
55  public function panel()
56  {
57  }
58  public function modal()
59  {
60  }
61  public function dropzone()
62  {
63  }
64  public function popover()
65  {
66  }
67  public function divider()
68  {
69  }
70  public function link()
71  {
72  }
73  public function dropdown()
74  {
75  }
76  public function item()
77  {
78  }
79  public function icon()
80  {
81  }
82  public function viewControl()
83  {
84  }
85  public function breadcrumbs(array $crumbs)
86  {
87  }
88  public function chart()
89  {
90  }
91 }
92 
94 {
95  public $resources = array();
96 
97  public function register($name)
98  {
99  $this->resources[] = $name;
100  }
101 }
102 
104 {
105  public $requested = array();
106  public function __construct()
107  {
108  }
109  public function txt($a_topic, $a_default_lang_fallback_mod = "")
110  {
111  $this->requested[] = $a_topic;
112  return $a_topic;
113  }
114  public function toJS($a_key, ilTemplate $a_tpl = null)
115  {
116  }
117 }
118 
120 {
121  private $count = 0;
122  public $ids = array();
123  public function createId()
124  {
125  $this->count++;
126  $id = "id_" . $this->count;
127  $this->ids[] = $id;
128  return $id;
129  }
130  public $on_load_code = array();
131  public function addOnLoadCode($code)
132  {
133  $this->on_load_code[] = $code;
134  }
135  public function getOnLoadCodeAsync()
136  {
137  }
138 }
139 
141 {
142  public function _getRendererFor(IComponent $component)
143  {
144  return $this->getRendererFor($component);
145  }
146  public function _getContexts()
147  {
148  return $this->getContexts();
149  }
150 }
151 
153 {
154  protected $id = 0;
155 
156  protected function createId()
157  {
158  return 'signal_' . ++$this->id;
159  }
160 }
161 
163 {
164 }
165 
166 class DummyComponent implements IComponent
167 {
168  public function getCanonicalName()
169  {
170  return "DummyComponent";
171  }
172 }
173 
178 {
179  public function setUp()
180  {
181  assert_options(ASSERT_WARNING, 0);
182  assert_options(ASSERT_CALLBACK, null);
183  }
184 
185  public function tearDown()
186  {
187  assert_options(ASSERT_WARNING, 1);
188  assert_options(ASSERT_CALLBACK, null);
189  }
190 
191  public function getUIFactory()
192  {
193  return new NoUIFactory();
194  }
195 
196  public function getTemplateFactory()
197  {
198  return new ilIndependentTemplateFactory();
199  }
200 
201  public function getResourceRegistry()
202  {
203  return new LoggingRegistry();
204  }
205 
206  public function getLanguage()
207  {
208  return new ilLanguageMock();
209  }
210 
211  public function getJavaScriptBinding()
212  {
213  return new LoggingJavaScriptBinding();
214  }
215 
216  public function getDefaultRenderer(JavaScriptBinding $js_binding = null)
217  {
218  $ui_factory = $this->getUIFactory();
219  $tpl_factory = $this->getTemplateFactory();
220  $resource_registry = $this->getResourceRegistry();
221  $lng = $this->getLanguage();
222  if (!$js_binding) {
223  $js_binding = $this->getJavaScriptBinding();
224  }
225 
226  $component_renderer_loader
227  = new Render\LoaderCachingWrapper(
229  $resource_registry,
230  new Render\FSLoader(
232  $ui_factory,
233  $tpl_factory,
234  $lng,
235  $js_binding
236  )
237  )
238  )
239  );
240  return new TestDefaultRenderer($component_renderer_loader);
241  }
242 
243  public function normalizeHTML($html)
244  {
245  return trim(str_replace("\n", "", $html));
246  }
247 
252  public function assertHTMLEquals($expected_html_as_string, $html_as_string)
253  {
254  $html = new DOMDocument();
255  $html->formatOutput = true;
256  $html->preserveWhiteSpace = false;
257  $expected = new DOMDocument();
258  $expected->formatOutput = true;
259  $expected->preserveWhiteSpace = false;
260  $html->loadXML($this->normalizeHTML($html_as_string));
261  $expected->loadXML($this->normalizeHTML($expected_html_as_string));
262  $this->assertEquals($expected->saveHTML(), $html->saveHTML());
263  }
264 }
card($title, \ILIAS\UI\Component\Image\Image $image=null)
description: purpose: > A card is a flexible content container for small chunks of structured data...
Definition: Base.php:40
Registry for resources required by rendered output like Javascript or CSS.
item()
description: purpose: > An item displays a unique entity within the system.
Definition: Base.php:76
breadcrumbs(array $crumbs)
description: purpose: > Breadcrumbs is a supplemental navigation scheme.
Definition: Base.php:85
dropzone()
description: purpose: > Dropzones are containers used to drop either files or other HTML elements...
Definition: Base.php:61
Class Factory.
icon()
description: purpose: > Icons are quickly comprehensible and recognizable graphics.
Definition: Base.php:79
getCanonicalName()
Get the canonical name of the component.
Definition: Base.php:168
viewControl()
description: purpose: > View Controls switch between different visualisation of data.
Definition: Base.php:82
Loads renderers for components from the file system.
Definition: FSLoader.php:20
Class BaseForm.
$code
Definition: example_050.php:99
link()
description: purpose: > Links are used navigate to other resources or views of the system...
Definition: Base.php:70
if(!array_key_exists('StateId', $_REQUEST)) $id
Registers resources for retreived renderers at a ResourceRegistry.
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
deck(array $cards)
description: purpose: > Decks are used to display multiple Cards in a grid.
Definition: Base.php:43
getOnLoadCodeAsync()
Get all the registered on-load javascript code for the async context, e.g.
Definition: Base.php:135
getJavaScriptBinding()
Definition: Base.php:211
if($format !==null) $name
Definition: metadata.php:146
glyph()
description: purpose: > Glyphs map a generally known concept or symbol to a specific concept in ILIA...
Definition: Base.php:34
toJS($a_key, ilTemplate $a_tpl=null)
Definition: Base.php:114
Provides common functionality for UI tests.
Definition: Base.php:177
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:88
panel()
description: purpose: > Panels are used to group titled content.
Definition: Base.php:55
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:52
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:252
modal()
description: purpose: The Modal forces users to focus on the task at hand.
Definition: Base.php:58
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:73
Create styles array
The data for the language used.
getTemplateFactory()
Definition: Base.php:196
image()
description: purpose: The Image component is used to display images of various sources.
Definition: Base.php:49
addOnLoadCode($code)
Add some JavaScript-statements to the on-load handler of the page.
Definition: Base.php:131
getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks)
Get template instance.
Definition: Base.php:23
getResourceRegistry()
Definition: Base.php:201
global $lng
Definition: privfeed.php:17
listing()
description: purpose: > Listings are used to structure itemised textual information.
Definition: Base.php:46
_getRendererFor(IComponent $component)
Definition: Base.php:142
language handling
createId()
Create a fresh unique id.
Definition: Base.php:123
button()
description: purpose: > Buttons trigger interactions that change the system’s status.
Definition: Base.php:37
txt($a_topic, $a_default_lang_fallback_mod="")
Definition: Base.php:109
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:67
counter()
description: purpose: > Counter inform users about the quantity of items indicated by a glyph...
Definition: Base.php:31
popover()
description: purpose: > Popovers can be used when space is scarce i.e.
Definition: Base.php:64