19 declare(strict_types=1);
30 private const XPATH =
'/wopi-discovery/net-zone/app';
41 $this->crawl_actions = [
42 ActionTarget::VIEW->value,
43 ActionTarget::EMBED_VIEW->value,
44 ActionTarget::EDIT->value,
45 ActionTarget::EMBED_EDIT->value,
46 ActionTarget::CONVERT->value,
53 $this->content = file_get_contents((
string) $discovery_url) ?: null;
54 if ($this->content === null) {
58 $this->discovery = simplexml_load_string($this->content) ?: null;
59 if ($this->discovery === null) {
62 $this->xml_app_elements = $this->discovery->xpath(self::XPATH);
64 return is_array($this->xml_app_elements);
72 if (!$this->
validate($discovery_url)) {
78 foreach ($this->xml_app_elements as
$app) {
80 foreach ($app->action as $action) {
81 $action_name = $action[
'name'] ?? null;
82 $action_ext = $action[
'ext'] ?? null;
83 $action_urlsrc = $action[
'urlsrc'] ?? null;
84 $target_text = isset($action[
'targetext']) ? (string) $action[
'targetext'] : null;
85 if (!$action_name instanceof \SimpleXMLElement) {
88 if (!$action_ext instanceof \SimpleXMLElement) {
91 if (!$action_urlsrc instanceof \SimpleXMLElement) {
95 if (!in_array((
string) $action_name, $this->crawl_actions,
true)) {
99 $uri_string = rtrim((
string) $action_urlsrc,
'?');
101 $uri = explode(
'?', $uri_string);
102 $uri_string = $uri[0];
105 (
string) $action_name,
106 (
string) $action_ext,
107 new URI($uri_string),
112 if ($actions === []) {
116 $app_name = $app[
'name'] ?? null;
117 if ($app_name === null) {
120 $app_fav_icon_url = $app[
'favIconUrl'] ?? null;
125 $app_fav_icon_url === null ? null :
new URI((
string) $app_fav_icon_url)
128 return new Apps($apps);
crawl(URI $discovery_url)
The scope of this class is split ilias-conform URI's into components.
SimpleXMLElement $discovery
validate(URI $discovery_url)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...