19declare(strict_types=1);
29use InvalidArgumentException;
74 $registry->
register(
'./src/UI/templates/js/Core/dist/core.js');
100 final public function txt(
string $id): string
102 return $this->
lng->txt($id);
119 return $this->
lng->getLangKey();
138 return $this->tpl_factory->getTemplate(
$path, $purge_unfilled_vars, $purge_unused_blocks);
147 return "src/UI/templates/default/$component/$name";
178 return $this->js_binding->createId();
187 if ($binder ===
null) {
191 $id = $this->js_binding->createId();
192 $on_load_code = $binder(
$id);
193 if (!is_string($on_load_code)) {
194 throw new LogicException(
195 "Expected JavaScript binder to return string" .
196 " (used component: " . get_class($component) .
")"
199 $this->js_binding->addOnLoadCode($on_load_code);
209 if (count($triggered_signals) == 0) {
214 foreach ($triggered_signals as $triggered_signal) {
215 $signal = $triggered_signal->getSignal();
216 $event = $triggered_signal->getEvent();
217 $options = json_encode($signal->getOptions());
220 if ($event ==
'load' || $event ==
'ready') {
222 "$(document).trigger('$signal',
224 'id' : '$signal', 'event' : '$event',
225 'triggerer' : $('#$id'),
226 'options' : JSON.parse('$options')
231 "$('#$id').on('$event', function(event) {
232 $(this).trigger('$signal',
234 'id' : '$signal', 'event' : '$event',
235 'triggerer' : $(this),
236 'options' : JSON.parse('$options')
256 if (!is_array($interfaces)) {
257 throw new LogicException(
258 "Expected array, found '" . (
string) (
null) .
"' when rendering."
262 foreach ($interfaces as $interface) {
263 if ($component instanceof $interface) {
267 $ifs = implode(
", ", $interfaces);
268 throw new LogicException(
269 "Expected $ifs, found '" . get_class($component) .
"' when rendering."
287 $class = get_class($this);
288 if (isset(self::$component_storage[$class])) {
289 return self::$component_storage[$class];
293 $re =
"%ILIAS\\\\UI\\\\Implementation\\\\Component\\\\(\\w+)\\\\(\\w+)%";
294 preg_match($re, $class, $matches);
295 if (preg_match($re, $class, $matches) !== 1) {
296 throw new LogicException(
"The Renderer needs to be located in ILIAS\\UI\\Implementation\\Component\\*.");
298 self::$component_storage[$class] = $matches[1];
300 return self::$component_storage[$class];
310 return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE,
'utf-8');
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Base class for all component renderers.
txt(string $id)
Get a text from the language file.
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
static array $component_storage
createId()
Get a fresh unique id.
ImagePathResolver $image_path_resolver
__construct(Factory $ui_factory, TemplateFactory $tpl_factory, ilLanguage $lng, JavaScriptBinding $js_binding, \ILIAS\Refinery\Factory $refinery, ImagePathResolver $image_path_resolver, DataFactory $data_factory)
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.
checkComponent(Component $component)
Check if a given component fits this renderer and throw \LogicError if that is not the case.
convertSpecialCharacters(string $value)
DataFactory $data_factory
getLangKey()
Get current language key.
getTemplatePath(string $name)
Get the path to the template of this component.
addTriggererOnLoadCode(Triggerer $triggerer)
Add onload-code for triggerer.
JavaScriptBinding $js_binding
toJS($key)
Add language var to client side (il.Language)
TemplateFactory $tpl_factory
getUIFactory()
Get a UI factory.
ILIAS Refinery Factory $refinery
getComponentInterfaceName()
Get the name of the component-interface this renderer is supposed to render.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
bindOnloadCode(JavaScriptBindable $component)
Bind the JavaScript onload-code.
A component is the most general form of an entity in the UI.
Interface to be extended by components that have the possibility to bind to Javascript.
withAdditionalOnLoadCode(Closure $binder)
Add some onload-code to the component instead of replacing the existing one.
getOnLoadCode()
Get the currently bound on load code.
getTriggeredSignals()
Get all triggered signals of this component.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
Some Components need to resolve pathes to image-files.
Provides methods to interface with javascript.
Registry for resources required by rendered output like Javascript or CSS.
register(string $name)
Add a dependency.
Interface for a factory that provides templates.
Interface to templating as it is used in the UI framework.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.