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);
176 return $this->js_binding->createId();
185 if ($binder ===
null) {
189 $id = $this->js_binding->createId();
190 $on_load_code = $binder(
$id);
191 if (!is_string($on_load_code)) {
192 throw new LogicException(
193 "Expected JavaScript binder to return string" .
194 " (used component: " . get_class($component) .
")"
197 $this->js_binding->addOnLoadCode($on_load_code);
207 if (count($triggered_signals) == 0) {
212 foreach ($triggered_signals as $triggered_signal) {
213 $signal = $triggered_signal->getSignal();
214 $event = $triggered_signal->getEvent();
215 $options = json_encode($signal->getOptions());
218 if ($event ==
'load' || $event ==
'ready') {
220 "$(document).trigger('$signal',
222 'id' : '$signal', 'event' : '$event',
223 'triggerer' : $('#$id'),
224 'options' : JSON.parse('$options')
229 "$('#$id').on('$event', function(event) {
230 $(this).trigger('$signal',
232 'id' : '$signal', 'event' : '$event',
233 'triggerer' : $(this),
234 'options' : JSON.parse('$options')
251 throw new LogicException(
253 "%s could not render component %s",
255 get_class($component)
265 $class = get_class($this);
266 if (isset(self::$component_storage[$class])) {
267 return self::$component_storage[$class];
271 $re =
"%ILIAS\\\\UI\\\\Implementation\\\\Component\\\\(\\w+)\\\\(\\w+)%";
272 preg_match($re, $class, $matches);
273 if (preg_match($re, $class, $matches) !== 1) {
274 throw new LogicException(
"The Renderer needs to be located in ILIAS\\UI\\Implementation\\Component\\*.");
276 self::$component_storage[$class] = $matches[1];
278 return self::$component_storage[$class];
283 return $this->image_path_resolver;
288 return $this->help_text_retriever->getHelpText($purpose, ...
$topics);
298 if ($this->tooltip_renderer ===
null) {
309 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.