ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\components\WOPI\Discovery\Crawler Class Reference
+ Collaboration diagram for ILIAS\components\WOPI\Discovery\Crawler:

Public Member Functions

 __construct ()
 
 validate (URI $discovery_url)
 
 crawl (URI $discovery_url)
 

Private Attributes

const XPATH = '/wopi-discovery/net-zone/app'
 
array $crawl_actions = []
 
string $content = null
 
SimpleXMLElement $discovery = null
 
array $xml_app_elements = null
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 28 of file Crawler.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\components\WOPI\Discovery\Crawler::__construct ( )

Definition at line 42 of file Crawler.php.

43  {
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,
50  ];
51  }

Member Function Documentation

◆ crawl()

ILIAS\components\WOPI\Discovery\Crawler::crawl ( URI  $discovery_url)

Definition at line 73 of file Crawler.php.

References null, and ILIAS\components\WOPI\Discovery\Crawler\validate().

73  : ?Apps
74  {
75  if (!$this->validate($discovery_url)) {
76  return null;
77  }
78 
79  // read wopi-discovery XML from $discovery_url and parse Apps with it's Actions
80  $apps = [];
81  foreach ($this->xml_app_elements as $app) {
82  $actions = [];
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;
88  if (!$action_name instanceof \SimpleXMLElement) {
89  continue;
90  }
91  if (!$action_ext instanceof \SimpleXMLElement) {
92  continue;
93  }
94  if (!$action_urlsrc instanceof \SimpleXMLElement) {
95  continue;
96  }
97 
98  if (!in_array((string) $action_name, $this->crawl_actions, true)) {
99  continue;
100  }
101 
102  $uri_string = rtrim((string) $action_urlsrc, '?');
103  // remove all after ?
104  $uri = explode('?', $uri_string);
105  $uri_string = $uri[0];
106  $actions[] = new Action(
107  0,
108  (string) $action_name,
109  (string) $action_ext,
110  new URI($uri_string),
111  $uri[1] ?? null,
112  $target_text
113  );
114  }
115  if ($actions === []) {
116  continue;
117  }
118 
119  $app_name = $app['name'] ?? null;
120  if ($app_name === null) {
121  continue;
122  }
123  $app_fav_icon_url = $app['favIconUrl'] ?? null;
124  $apps[] = new App(
125  0,
126  (string) $app_name,
127  $actions,
128  $app_fav_icon_url === null ? null : new URI((string) $app_fav_icon_url)
129  );
130  }
131  return new Apps($apps);
132  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ validate()

ILIAS\components\WOPI\Discovery\Crawler::validate ( URI  $discovery_url)

Definition at line 53 of file Crawler.php.

References null.

Referenced by ILIAS\components\WOPI\Discovery\Crawler\crawl().

53  : bool
54  {
55  try {
56  $this->content = file_get_contents((string) $discovery_url) ?: null;
57  if ($this->content === null) {
58  return false;
59  }
60 
61  $this->discovery = simplexml_load_string($this->content) ?: null;
62  if ($this->discovery === null) {
63  return false;
64  }
65  $this->xml_app_elements = $this->discovery->xpath(self::XPATH);
66 
67  return is_array($this->xml_app_elements);
68  } catch (\Throwable) {
69  return false;
70  }
71  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

Field Documentation

◆ $content

string ILIAS\components\WOPI\Discovery\Crawler::$content = null
private

Definition at line 35 of file Crawler.php.

◆ $crawl_actions

array ILIAS\components\WOPI\Discovery\Crawler::$crawl_actions = []
private

Definition at line 34 of file Crawler.php.

◆ $discovery

SimpleXMLElement ILIAS\components\WOPI\Discovery\Crawler::$discovery = null
private

Definition at line 36 of file Crawler.php.

◆ $xml_app_elements

array ILIAS\components\WOPI\Discovery\Crawler::$xml_app_elements = null
private

Definition at line 40 of file Crawler.php.

◆ XPATH

const ILIAS\components\WOPI\Discovery\Crawler::XPATH = '/wopi-discovery/net-zone/app'
private

Definition at line 33 of file Crawler.php.


The documentation for this class was generated from the following file: