77 $registry->
register(
'./src/UI/templates/js/Core/ui.js');
106 final public function txt($id)
108 return $this->lng->txt($id);
115 final public function toJS($key)
117 $this->lng->toJS($key);
127 return $this->lng->getLangKey();
154 return $this->tpl_factory->getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks);
166 return "src/UI/templates/default/$component/$name";
200 return $this->js_binding->createId();
212 if ($binder === null) {
216 $id = $this->js_binding->createId();
217 $on_load_code = $binder($id);
218 if (!is_string($on_load_code)) {
219 throw new \LogicException(
220 "Expected JavaScript binder to return string" .
221 " (used component: " . get_class($component) .
")" 224 $this->js_binding->addOnLoadCode($on_load_code);
237 if (count($triggered_signals) == 0) {
242 foreach ($triggered_signals as $triggered_signal) {
243 $signal = $triggered_signal->getSignal();
244 $event = $triggered_signal->getEvent();
245 $options = json_encode($signal->getOptions());
248 if ($event ==
'load' || $event ==
'ready') {
250 "$(document).trigger('{$signal}', 252 'id' : '{$signal}', 'event' : '{$event}', 253 'triggerer' : $('#{$id}'), 254 'options' : JSON.parse('{$options}') 259 "$('#{$id}').on('{$event}', function(event) { 260 $(this).trigger('{$signal}', 262 'id' : '{$signal}', 'event' : '{$event}', 263 'triggerer' : $(this), 264 'options' : JSON.parse('{$options}') 286 if (!is_array($interfaces)) {
287 throw new \LogicException(
288 "Expected array, found '" . (
string) (null) .
"' when rendering." 292 foreach ($interfaces as $interface) {
293 if ($component instanceof $interface) {
297 $ifs = implode(
", ", $interfaces);
298 throw new \LogicException(
299 "Expected $ifs, found '" . get_class($component) .
"' when rendering." 315 $class = get_class($this);
316 if (isset(self::$component_storage[$class])) {
317 return self::$component_storage[$class];
321 $re =
"%ILIAS\\\\UI\\\\Implementation\\\\Component\\\\(\\w+)\\\\(\\w+)%";
322 preg_match($re, $class, $matches);
323 if (preg_match($re, $class, $matches) !== 1) {
324 throw new \LogicException(
"The Renderer needs to be located in ILIAS\\UI\\Implementation\\Component\\*.");
326 self::$component_storage[$class] = $matches[1];
328 return self::$component_storage[$class];
Registry for resources required by rendered output like Javascript or CSS.
getTemplatePath($name)
Get the path to the template of this component.
addTriggererOnLoadCode(Triggerer $triggerer)
Add onload-code for triggerer.
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
Class ChatMainBarProvider .
An entity that renders components to a string output.
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
Some Components need to resolve pathes to image-files.
toJS($key)
Add language var to client side (il.Language)
bindOnloadCode(JavaScriptBindable $component)
Bind the JavaScript onload-code.
createId()
Get a fresh unique id.
txt($id)
Get a text from the language file.
getComponentInterfaceName()
Get the name of the component-interface this renderer is supposed to render.
static $component_storage
__construct(Factory $ui_factory, TemplateFactory $tpl_factory, \ilLanguage $lng, JavaScriptBinding $js_binding, \ILIAS\Refinery\Factory $refinery, ImagePathResolver $image_path_resolver)
This is how the factory for UI elements looks.
getOnLoadCode()
Get the currently bound on load code.
Provides methods to interface with javascript.
register($name)
Add a dependency.
withAdditionalOnLoadCode(\Closure $binder)
Add some onload-code to the component instead of replacing the existing one.
getTriggeredSignals()
Get all triggered signals of this component.
getLangKey()
Get current language key.
getUIFactory()
Get a UI factory.
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.null
Interface for a factory that provides templates.
Base class for all component renderers.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.