ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
15 
17  public function getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks) {
18  return new ilIndependentTemplate($path, $purge_unfilled_vars, $purge_unused_blocks);
19  }
20 }
21 
22 class NoUIFactory implements Factory {
23  public function counter() {}
24  public function glyph() {}
25  public function button() {}
26  public function card($title, \ILIAS\UI\Component\Image\Image $image = null) {}
27  public function deck(array $cards) {}
28  public function listing() {}
29  public function image() {}
30  public function legacy($content) {}
31  public function panel() {}
32 }
33 
35  public $resources = array();
36 
37  public function register($name) {
38  $this->resources[] = $name;
39  }
40 }
41 
42 class ilLanguageMock extends \ilLanguage {
43  public $requested = array();
44  public function __construct() {}
45  public function txt($a_topic, $a_default_lang_fallback_mod = "") {
46  $this->requested[] = $a_topic;
47  return $a_topic;
48  }
49 }
50 
52  private $count = 0;
53  public $ids = array();
54  public function createId() {
55  $this->count++;
56  $id = "id_".$this->count;
57  $this->ids[] = $id;
58  return $id;
59  }
60  public $on_load_code = array();
61  public function addOnLoadCode($code) {
62  $this->on_load_code[] = $code;
63  }
64 }
65 
70  public function setUp() {
71  assert_options(ASSERT_WARNING, 0);
72  assert_options(ASSERT_CALLBACK, null);
73  }
74 
75  public function tearDown() {
76  assert_options(ASSERT_WARNING, 1);
77  assert_options(ASSERT_CALLBACK, null);
78  }
79 
80  public function getUIFactory() {
81  return new NoUIFactory();
82  }
83 
84  public function getTemplateFactory() {
85  return new ilIndependentTemplateFactory();
86  }
87 
88  public function getResourceRegistry() {
89  return new LoggingRegistry();
90  }
91 
92  public function getLanguage() {
93  return new ilLanguageMock();
94  }
95 
96  public function getJavaScriptBinding() {
97  return new LoggingJavaScriptBinding();
98  }
99 
100  public function getDefaultRenderer() {
101  $ui_factory = $this->getUIFactory();
102  $tpl_factory = $this->getTemplateFactory();
103  $resource_registry = $this->getResourceRegistry();
104  $lng = $this->getLanguage();
105  $js_binding = $this->getJavaScriptBinding();
106  return new DefaultRenderer(
107  $ui_factory, $tpl_factory, $resource_registry, $lng, $js_binding);
108  }
109 
110  public function normalizeHTML($html) {
111  return trim(str_replace("\n", "", $html));
112  }
113 
118  public function assertHTMLEquals($expected_html_as_string,$html_as_string){
119  $html = new DOMDocument();
120  $html->formatOutput = true;
121  $html->preserveWhiteSpace = false;
122  $expected = new DOMDocument();
123  $expected->formatOutput = true;
124  $expected->preserveWhiteSpace = false;
125  $html->loadXML($this->normalizeHTML($html_as_string));
126  $expected->loadXML($this->normalizeHTML($expected_html_as_string));
127  $this->assertEquals($expected->saveHTML(), $html->saveHTML());
128  }
129 }
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:26
Registry for resources required by rendered output like Javascript or CSS.
$path
Definition: aliased.php:25
Interface Card .
$code
Definition: example_050.php:99
normalizeHTML($html)
Definition: Base.php:110
deck(array $cards)
description: purpose: > Decks are used to display multiple Cards in a grid.
Definition: Base.php:27
getJavaScriptBinding()
Definition: Base.php:96
glyph()
description: purpose: > Glyphs map a generally known concept or symbol to a specific concept in ILIA...
Definition: Base.php:24
Provides common functionality for UI tests.
Definition: Base.php:69
This is how the factory for UI elements looks.
Definition: Factory.php:15
panel()
description: purpose: > Panels are used to group titled content.
Definition: Base.php:31
legacy($content)
description: purpose: > This component is used to wrap an existing ILIAS UI element into a UI compon...
Definition: Base.php:30
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:118
Provides methods to interface with javascript.
Create styles array
The data for the language used.
getDefaultRenderer()
Definition: Base.php:100
getTemplateFactory()
Definition: Base.php:84
image()
description: purpose: The Image component is used to display images of various sources.
Definition: Base.php:29
__construct()
Definition: Base.php:44
addOnLoadCode($code)
Add some JavaScript-statements to the on-load handler of the page.
Definition: Base.php:61
getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks)
Get template instance.
Definition: Base.php:17
getResourceRegistry()
Definition: Base.php:88
global $lng
Definition: privfeed.php:17
listing()
description: purpose: > Listings are used to structure itemised textual information.
Definition: Base.php:28
language handling
createId()
Create a fresh unique id.
Definition: Base.php:54
button()
description: purpose: > Buttons trigger interactions that change the system’s status.
Definition: Base.php:25
txt($a_topic, $a_default_lang_fallback_mod="")
Definition: Base.php:45
Interface for a factory that provides templates.
$html
Definition: example_001.php:87
counter()
description: purpose: > Counter inform users about the quantity of items indicated by a glyph...
Definition: Base.php:23