19declare(strict_types=1);
31use InvalidArgumentException;
53 private DataFactory $data_factory,
64 $registry->
register(
'assets/js/core.js');
74 return $this->ui_factory;
79 return $this->data_factory;
84 return $this->upload_limit_resolver;
90 final public function txt(
string $id): string
92 return $this->
lng->txt($id);
99 final public function toJS($key): void
101 $this->
lng->toJS($key);
109 return $this->
lng->getLangKey();
114 return $this->js_binding;
125 final protected function getTemplate(
string $name,
bool $purge_unfilled_vars,
bool $purge_unused_blocks):
Template
137 return "components/ILIAS/UI/src/templates/default/$component/$name";
145 return $this->tpl_factory->getTemplate(
$path, $purge_unfilled_vars, $purge_unused_blocks);
173 return $this->js_binding->createId();
182 if ($binder ===
null) {
186 $id = $this->js_binding->createId();
187 $on_load_code = $binder(
$id);
188 if (!is_string($on_load_code)) {
189 throw new LogicException(
190 "Expected JavaScript binder to return string" .
191 " (used component: " . get_class($component) .
")"
194 $this->js_binding->addOnLoadCode($on_load_code);
204 if (count($triggered_signals) == 0) {
209 foreach ($triggered_signals as $triggered_signal) {
210 $signal = $triggered_signal->getSignal();
211 $event = $triggered_signal->getEvent();
212 $options = json_encode($signal->getOptions());
215 if ($event ==
'load' || $event ==
'ready') {
217 "$(document).trigger('$signal',
219 'id' : '$signal', 'event' : '$event',
220 'triggerer' : $('#$id'),
221 'options' : JSON.parse('$options')
226 "$('#$id').on('$event', function(event) {
227 $(this).trigger('$signal',
229 'id' : '$signal', 'event' : '$event',
230 'triggerer' : $(this),
231 'options' : JSON.parse('$options')
248 throw new LogicException(
250 "%s could not render component %s",
252 get_class($component)
262 $class = get_class($this);
263 if (isset(self::$component_storage[$class])) {
264 return self::$component_storage[$class];
268 $re =
"%ILIAS\\\\UI\\\\Implementation\\\\Component\\\\(\\w+)\\\\(\\w+)%";
269 preg_match($re, $class, $matches);
270 if (preg_match($re, $class, $matches) !== 1) {
271 throw new LogicException(
"The Renderer needs to be located in ILIAS\\UI\\Implementation\\Component\\*.");
273 self::$component_storage[$class] = $matches[1];
275 return self::$component_storage[$class];
280 return $this->image_path_resolver;
285 return $this->help_text_retriever->getHelpText($purpose, ...
$topics);
295 if ($this->tooltip_renderer ===
null) {
306 return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE,
'utf-8');
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
A purpose describes the intended use for a certain help text.
This is just a class that marks a string as a help topic.
Base class for all component renderers.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
txt(string $id)
Get a text from the language file.
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
static array $component_storage
__construct(private FactoryInternal $ui_factory, private TemplateFactory $tpl_factory, private Language $lng, private JavaScriptBinding $js_binding, private ImagePathResolver $image_path_resolver, private DataFactory $data_factory, private HelpTextRetriever $help_text_retriever, private UploadLimitResolver $upload_limit_resolver,)
getHelpText(Help\Purpose $purpose, Help\Topic ... $topics)
createId()
Get a fresh unique id.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.
convertSpecialCharacters(string $value)
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.
toJS($key)
Add language var to client side (il.Language)
getComponentCanonicalNameAttribute(Component $component)
getTemplateRaw(string $path, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get a template from any path.
TooltipRenderer $tooltip_renderer
getUIFactory()
Get a UI factory.
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.
getCanonicalName()
Get the canonical name of the component.
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 describes a facility that the UI framework can use to retrieve some help text.
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.
An entity that renders components to a string output.
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.