ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExternalMediaAnalyzer Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilExternalMediaAnalyzer:

Static Public Member Functions

static isYouTube (string $a_location)
 Identify YouTube links. More...
 
static extractYouTubeParameters (string $a_location)
 Extract YouTube Parameter. More...
 
static isFlickr (string $a_location)
 Identify Flickr links. More...
 
static extractFlickrParameters (string $a_location)
 Extract Flickr Parameter. More...
 
static isGoogleVideo (string $a_location)
 Identify GoogleVideo links. More...
 
static extractGoogleVideoParameters (string $a_location)
 Extract GoogleVideo Parameter. More...
 
static isVimeo (string $a_location)
 Identify Vimeo links. More...
 
static extractVimeoParameters (string $a_location)
 Extract Vimeo Parameter. More...
 
static getVimeoMetadata (string $vid)
 
static getYoutubeMetadata (string $vid)
 
static isGoogleDocument (string $a_location)
 Identify Google Document links. More...
 
static extractGoogleDocumentParameters (string $a_location)
 Extract GoogleDocument Parameter. More...
 
static extractUrlParameters (string $a_location, array $a_parameter)
 Extract URL information to parameter array. More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Analyzes external media locations and extracts important information into parameter field.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 25 of file class.ilExternalMediaAnalyzer.php.

Member Function Documentation

◆ extractFlickrParameters()

static ilExternalMediaAnalyzer::extractFlickrParameters ( string  $a_location)
static

Extract Flickr Parameter.

Returns
array<string,string>

Definition at line 81 of file class.ilExternalMediaAnalyzer.php.

Referenced by extractUrlParameters().

83  : array {
84  $par = array();
85  $pos1 = strpos($a_location, "flickr.com/photos/");
86  $pos2 = strpos($a_location, "/", $pos1 + 18);
87  if ($pos1 > 0) {
88  $len = ($pos2 > 0)
89  ? $pos2
90  : $a_location;
91  $par["user_id"] = substr($a_location, $pos1 + 18, $len - ($pos1 + 18));
92  }
93 
94  // tags
95  $pos1 = strpos($a_location, "/tags/");
96  $pos2 = strpos($a_location, "/", $pos1 + 6);
97  if ($pos1 > 0) {
98  $len = ($pos2 > 0)
99  ? $pos2
100  : strlen($a_location);
101  $par["tags"] = substr($a_location, $pos1 + 6, $len - ($pos1 + 6));
102  }
103 
104  // sets
105  $pos1 = strpos($a_location, "/sets/");
106  $pos2 = strpos($a_location, "/", $pos1 + 6);
107  if ($pos1 > 0) {
108  $len = ($pos2 > 0)
109  ? $pos2
110  : $a_location;
111  $par["sets"] = substr($a_location, $pos1 + 6, $len - ($pos1 + 6));
112  }
113 
114  return $par;
115  }
+ Here is the caller graph for this function:

◆ extractGoogleDocumentParameters()

static ilExternalMediaAnalyzer::extractGoogleDocumentParameters ( string  $a_location)
static

Extract GoogleDocument Parameter.

Returns
array<string,string>

Definition at line 238 of file class.ilExternalMediaAnalyzer.php.

Referenced by extractUrlParameters().

240  : array {
241  $par = array();
242  $pos1 = strpos($a_location, "id=");
243  $pos2 = strpos($a_location, "&", $pos1 + 3);
244  if ($pos1 > 0) {
245  $len = ($pos2 > 0)
246  ? $pos2
247  : strlen($a_location);
248  $par["docid"] = substr($a_location, $pos1 + 3, $len - ($pos1 + 3));
249  }
250  $pos1 = strpos($a_location, "docID=");
251  $pos2 = strpos($a_location, "&", $pos1 + 6);
252  if ($pos1 > 0) {
253  $len = ($pos2 > 0)
254  ? $pos2
255  : strlen($a_location);
256  $par["docid"] = substr($a_location, $pos1 + 6, $len - ($pos1 + 6));
257  }
258  if (strpos($a_location, "Presentation?") > 0) {
259  $par["type"] = "Presentation";
260  }
261  if (strpos($a_location, "View?") > 0) {
262  $par["type"] = "Document";
263  }
264 
265  return $par;
266  }
+ Here is the caller graph for this function:

◆ extractGoogleVideoParameters()

static ilExternalMediaAnalyzer::extractGoogleVideoParameters ( string  $a_location)
static

Extract GoogleVideo Parameter.

Returns
array<string,string>

Definition at line 133 of file class.ilExternalMediaAnalyzer.php.

Referenced by extractUrlParameters().

135  : array {
136  $par = array();
137  $pos1 = strpos($a_location, "docid=");
138  $pos2 = strpos($a_location, "&", $pos1 + 6);
139  if ($pos1 > 0) {
140  $len = ($pos2 > 0)
141  ? $pos2
142  : strlen($a_location);
143  $par["docid"] = substr($a_location, $pos1 + 6, $len - ($pos1 + 6));
144  }
145 
146  return $par;
147  }
+ Here is the caller graph for this function:

◆ extractUrlParameters()

static ilExternalMediaAnalyzer::extractUrlParameters ( string  $a_location,
array  $a_parameter 
)
static

Extract URL information to parameter array.

Returns
array<string,string>

Definition at line 272 of file class.ilExternalMediaAnalyzer.php.

References $name, extractFlickrParameters(), extractGoogleDocumentParameters(), extractGoogleVideoParameters(), extractYouTubeParameters(), isFlickr(), isGoogleDocument(), isGoogleVideo(), and isYouTube().

Referenced by ilMediaItem\extractUrlParameters().

275  : array {
276  $ext_par = array();
277 
278  // YouTube
279  if (ilExternalMediaAnalyzer::isYouTube($a_location)) {
281  $a_parameter = array();
282  }
283 
284  // Flickr
285  if (ilExternalMediaAnalyzer::isFlickr($a_location)) {
286  $ext_par = ilExternalMediaAnalyzer::extractFlickrParameters($a_location);
287  $a_parameter = array();
288  }
289 
290  // GoogleVideo
291  if (ilExternalMediaAnalyzer::isGoogleVideo($a_location)) {
293  $a_parameter = array();
294  }
295 
296  // GoogleDocs
299  $a_parameter = array();
300  }
301 
302  foreach ($ext_par as $name => $value) {
303  $a_parameter[$name] = $value;
304  }
305 
306  return $a_parameter;
307  }
static extractGoogleVideoParameters(string $a_location)
Extract GoogleVideo Parameter.
static isYouTube(string $a_location)
Identify YouTube links.
static isGoogleDocument(string $a_location)
Identify Google Document links.
if($format !==null) $name
Definition: metadata.php:247
static extractYouTubeParameters(string $a_location)
Extract YouTube Parameter.
static extractGoogleDocumentParameters(string $a_location)
Extract GoogleDocument Parameter.
static isGoogleVideo(string $a_location)
Identify GoogleVideo links.
static isFlickr(string $a_location)
Identify Flickr links.
static extractFlickrParameters(string $a_location)
Extract Flickr Parameter.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extractVimeoParameters()

static ilExternalMediaAnalyzer::extractVimeoParameters ( string  $a_location)
static

Extract Vimeo Parameter.

Returns
array<string,string>

Definition at line 165 of file class.ilExternalMediaAnalyzer.php.

Referenced by ilMediaItem\determineDuration(), and ilObjMediaObject\getExternalMetadata().

167  : array {
168  $par = array();
169  $pos1 = strpos($a_location, "vimeo.com/");
170  $pos2 = strpos($a_location, "&", $pos1 + 10);
171  if ($pos1 > 0) {
172  $len = ($pos2 > 0)
173  ? $pos2
174  : strlen($a_location);
175  $par["id"] = substr($a_location, $pos1 + 10, $len - ($pos1 + 10));
176  }
177 
178  return $par;
179  }
+ Here is the caller graph for this function:

◆ extractYouTubeParameters()

static ilExternalMediaAnalyzer::extractYouTubeParameters ( string  $a_location)
static

Extract YouTube Parameter.

Returns
array<string,string>

Definition at line 44 of file class.ilExternalMediaAnalyzer.php.

Referenced by extractUrlParameters(), and ilMediaPlayerGUI\getMp3PlayerHtml().

46  : array {
47  $par = array();
48  $pos1 = strpos($a_location, "v=");
49  $pos2 = strpos($a_location, "&", $pos1);
50  if ($pos1 > 0) {
51  $len = ($pos2 > 0)
52  ? $pos2
53  : strlen($a_location);
54  $par["v"] = substr($a_location, $pos1 + 2, $len - ($pos1 + 2));
55  } elseif (strpos($a_location, "youtu.be") > 0) {
56  $par["v"] = substr($a_location, strrpos($a_location, "/") + 1);
57  }
58  $qpos = strpos($par["v"], "?");
59  if (is_int($qpos)) {
60  $par["v"] = substr($par["v"], 0, $qpos);
61  }
62  return $par;
63  }
+ Here is the caller graph for this function:

◆ getVimeoMetadata()

static ilExternalMediaAnalyzer::getVimeoMetadata ( string  $vid)
static

Definition at line 181 of file class.ilExternalMediaAnalyzer.php.

Referenced by ilMediaItem\determineDuration(), and ilObjMediaObject\getExternalMetadata().

181  : array
182  {
183  $json_url = 'https://vimeo.com/api/oembed.json?url=https%3A//vimeo.com/' . $vid;
184 
185  $curl = curl_init($json_url);
186  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
187  curl_setopt($curl, CURLOPT_TIMEOUT, 10);
188  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
189  curl_setopt($curl, CURLOPT_REFERER, ILIAS_HTTP_PATH);
190 
191  $return = curl_exec($curl);
192  curl_close($curl);
193 
194  $r = json_decode($return, true);
195 
196  if ($return === false || is_null($r)) {
197  throw new ilExternalMediaApiException("Could not connect to vimeo API at $json_url.");
198  }
199  return $r;
200  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getYoutubeMetadata()

static ilExternalMediaAnalyzer::getYoutubeMetadata ( string  $vid)
static

Definition at line 202 of file class.ilExternalMediaAnalyzer.php.

Referenced by ilObjMediaObject\getExternalMetadata().

202  : array
203  {
204  $json_url = 'https://www.youtube.com/oembed?url=http%3A//youtube.com/watch%3Fv%3D' . $vid . '&format=json';
205  $curl = curl_init($json_url);
206  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
207  curl_setopt($curl, CURLOPT_TIMEOUT, 10);
208  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
209  curl_setopt($curl, CURLOPT_REFERER, ILIAS_HTTP_PATH);
210 
211  $return = curl_exec($curl);
212  curl_close($curl);
213 
214  $r = json_decode($return, true);
215 
216  if ($return === false || is_null($r)) {
217  throw new ilExternalMediaApiException("Could not connect to youtube API at $json_url.");
218  }
219  return $r;
220  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ isFlickr()

static ilExternalMediaAnalyzer::isFlickr ( string  $a_location)
static

Identify Flickr links.

Definition at line 68 of file class.ilExternalMediaAnalyzer.php.

Referenced by extractUrlParameters().

70  : bool {
71  if (strpos($a_location, "flickr.com") > 0) {
72  return true;
73  }
74  return false;
75  }
+ Here is the caller graph for this function:

◆ isGoogleDocument()

static ilExternalMediaAnalyzer::isGoogleDocument ( string  $a_location)
static

Identify Google Document links.

Definition at line 225 of file class.ilExternalMediaAnalyzer.php.

Referenced by extractUrlParameters().

227  : bool {
228  if (strpos($a_location, "docs.google") > 0) {
229  return true;
230  }
231  return false;
232  }
+ Here is the caller graph for this function:

◆ isGoogleVideo()

static ilExternalMediaAnalyzer::isGoogleVideo ( string  $a_location)
static

Identify GoogleVideo links.

Definition at line 120 of file class.ilExternalMediaAnalyzer.php.

Referenced by extractUrlParameters().

122  : bool {
123  if (strpos($a_location, "video.google") > 0) {
124  return true;
125  }
126  return false;
127  }
+ Here is the caller graph for this function:

◆ isVimeo()

static ilExternalMediaAnalyzer::isVimeo ( string  $a_location)
static

Identify Vimeo links.

Definition at line 152 of file class.ilExternalMediaAnalyzer.php.

Referenced by ilMediaItem\determineDuration(), ilObjMediaObject\getExternalMetadata(), and ilMediaPlayerGUI\getMp3PlayerHtml().

154  : bool {
155  if (strpos($a_location, "vimeo.com") > 0) {
156  return true;
157  }
158  return false;
159  }
+ Here is the caller graph for this function:

◆ isYouTube()

static ilExternalMediaAnalyzer::isYouTube ( string  $a_location)
static

Identify YouTube links.

Definition at line 30 of file class.ilExternalMediaAnalyzer.php.

Referenced by extractUrlParameters(), and ilMediaPlayerGUI\getMp3PlayerHtml().

32  : bool {
33  if (strpos($a_location, "youtube.com") > 0 ||
34  strpos($a_location, "youtu.be") > 0) {
35  return true;
36  }
37  return false;
38  }
+ Here is the caller graph for this function:

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