19 declare(strict_types=1);
33 private const XPATH =
'/wopi-discovery/net-zone/app';
44 $this->crawl_actions = [
45 ActionTarget::VIEW->value,
46 ActionTarget::EMBED_VIEW->value,
47 ActionTarget::EDIT->value,
48 ActionTarget::EMBED_EDIT->value,
49 ActionTarget::CONVERT->value,
56 $this->content = file_get_contents((
string) $discovery_url) ?:
null;
57 if ($this->content ===
null) {
61 $this->discovery = simplexml_load_string($this->content) ?:
null;
62 if ($this->discovery ===
null) {
65 $this->xml_app_elements = $this->discovery->xpath(self::XPATH);
67 return is_array($this->xml_app_elements);
75 if (!$this->
validate($discovery_url)) {
81 foreach ($this->xml_app_elements as $app) {
83 foreach ($app->action as $action) {
84 $action_name = $action[
'name'] ??
null;
85 $action_ext = $action[
'ext'] ??
null;
86 $action_urlsrc = $action[
'urlsrc'] ??
null;
87 $target_text = isset($action[
'targetext']) ? (string) $action[
'targetext'] : null;
91 if (!$action_ext instanceof \SimpleXMLElement) {
94 if (!$action_urlsrc instanceof \SimpleXMLElement) {
98 if (!in_array((
string) $action_name, $this->crawl_actions,
true)) {
102 $uri_string = rtrim((
string) $action_urlsrc,
'?');
104 $uri = explode(
'?', $uri_string);
105 $uri_string = $uri[0];
108 (
string) $action_name,
109 (
string) $action_ext,
110 new URI($uri_string),
115 if ($actions === []) {
119 $app_name = $app[
'name'] ??
null;
120 if ($app_name === null) {
123 $app_fav_icon_url = $app[
'favIconUrl'] ??
null;
128 $app_fav_icon_url === null ? null :
new URI((
string) $app_fav_icon_url)
131 return new Apps($apps);
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
crawl(URI $discovery_url)
validate(URI $discovery_url)
SimpleXMLElement $discovery