ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilExternalMediaAnalyzer.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
38  static function isYouTube($a_location)
39  {
40  if (strpos($a_location, "youtube.com") > 0 ||
41  strpos($a_location, "youtu.be") > 0)
42  {
43  return true;
44  }
45  return false;
46  }
47 
51  static function extractYouTubeParameters($a_location)
52  {
53  $par = array();
54  $pos1 = strpos($a_location, "v=");
55  $pos2 = strpos($a_location, "&", $pos1);
56  if ($pos1 > 0)
57  {
58  $len = ($pos2 > 0)
59  ? $pos2
60  : strlen($a_location);
61  $par["v"] = substr($a_location, $pos1+2, $len - ($pos1+2));
62  }
63  else if (strpos($a_location, "youtu.be") > 0)
64  {
65  //$par["v"] = substr($a_location, strrpos($a_location, "/") + 1);
66  }
67 
68  return $par;
69  }
70 
74  static function isFlickr($a_location)
75  {
76  if (strpos($a_location, "flickr.com") > 0)
77  {
78  return true;
79  }
80  return false;
81  }
82 
86  static function extractFlickrParameters($a_location)
87  {
88  $par = array();
89  $pos1 = strpos($a_location, "flickr.com/photos/");
90  $pos2 = strpos($a_location, "/", $pos1+18);
91  if ($pos1 > 0)
92  {
93  $len = ($pos2 > 0)
94  ? $pos2
95  : $a_location;
96  $par["user_id"] = substr($a_location, $pos1+18, $len - ($pos1+18));
97  }
98 
99  // tags
100  $pos1 = strpos($a_location, "/tags/");
101  $pos2 = strpos($a_location, "/", $pos1+6);
102  if ($pos1 > 0)
103  {
104  $len = ($pos2 > 0)
105  ? $pos2
106  : strlen($a_location);
107  $par["tags"] = substr($a_location, $pos1+6, $len - ($pos1+6));
108  }
109 
110  // sets
111  $pos1 = strpos($a_location, "/sets/");
112  $pos2 = strpos($a_location, "/", $pos1+6);
113  if ($pos1 > 0)
114  {
115  $len = ($pos2 > 0)
116  ? $pos2
117  : $a_location;
118  $par["sets"] = substr($a_location, $pos1+6, $len - ($pos1+6));
119  }
120 
121  return $par;
122  }
123 
127  static function isGoogleVideo($a_location)
128  {
129  if (strpos($a_location, "video.google") > 0)
130  {
131  return true;
132  }
133  return false;
134  }
135 
139  static function extractGoogleVideoParameters($a_location)
140  {
141  $par = array();
142  $pos1 = strpos($a_location, "docid=");
143  $pos2 = strpos($a_location, "&", $pos1 + 6);
144  if ($pos1 > 0)
145  {
146  $len = ($pos2 > 0)
147  ? $pos2
148  : strlen($a_location);
149  $par["docid"] = substr($a_location, $pos1+6, $len - ($pos1+6));
150  }
151 
152  return $par;
153  }
154 
158  static function isVimeo($a_location)
159  {
160  if (strpos($a_location, "vimeo.com") > 0)
161  {
162  return true;
163  }
164  return false;
165  }
166 
170  static function extractVimeoParameters($a_location)
171  {
172  $par = array();
173  $pos1 = strpos($a_location, "vimeo.com/");
174  $pos2 = strpos($a_location, "&", $pos1 + 10);
175  if ($pos1 > 0)
176  {
177  $len = ($pos2 > 0)
178  ? $pos2
179  : strlen($a_location);
180  $par["id"] = substr($a_location, $pos1+10, $len - ($pos1+10));
181  }
182 
183  return $par;
184  }
185 
189  static function isGoogleDocument($a_location)
190  {
191  if (strpos($a_location, "docs.google") > 0)
192  {
193  return true;
194  }
195  return false;
196  }
197 
201  static function extractGoogleDocumentParameters($a_location)
202  {
203  $par = array();
204  $pos1 = strpos($a_location, "id=");
205  $pos2 = strpos($a_location, "&", $pos1 + 3);
206  if ($pos1 > 0)
207  {
208  $len = ($pos2 > 0)
209  ? $pos2
210  : strlen($a_location);
211  $par["docid"] = substr($a_location, $pos1+3, $len - ($pos1+3));
212  }
213  $pos1 = strpos($a_location, "docID=");
214  $pos2 = strpos($a_location, "&", $pos1 + 6);
215  if ($pos1 > 0)
216  {
217  $len = ($pos2 > 0)
218  ? $pos2
219  : strlen($a_location);
220  $par["docid"] = substr($a_location, $pos1+6, $len - ($pos1+6));
221  }
222  if (strpos($a_location, "Presentation?") > 0)
223  {
224  $par["type"] = "Presentation";
225  }
226  if (strpos($a_location, "View?") > 0)
227  {
228  $par["type"] = "Document";
229  }
230 
231  return $par;
232  }
233 
237  static function extractUrlParameters($a_location, $a_parameter)
238  {
239  if (!is_array($a_parameter))
240  {
241  $a_parameter = array();
242  }
243 
244  $ext_par = array();
245 
246  // YouTube
247  if (ilExternalMediaAnalyzer::isYouTube($a_location))
248  {
250  $a_parameter = array();
251  }
252 
253  // Flickr
254  if (ilExternalMediaAnalyzer::isFlickr($a_location))
255  {
256  $ext_par = ilExternalMediaAnalyzer::extractFlickrParameters($a_location);
257  $a_parameter = array();
258  }
259 
260  // GoogleVideo
262  {
264  $a_parameter = array();
265  }
266 
267  // GoogleDocs
269  {
271  $a_parameter = array();
272  }
273 
274  foreach($ext_par as $name => $value)
275  {
276  $a_parameter[$name] = $value;
277  }
278 
279  return $a_parameter;
280  }
281 }
282 ?>
static extractUrlParameters($a_location, $a_parameter)
Extract URL information to parameter array.
static isYouTube($a_location)
Identify YouTube links.
static isGoogleVideo($a_location)
Identify GoogleVideo links.
static extractGoogleDocumentParameters($a_location)
Extract GoogleDocument Parameter.
Analyzes external media locations and extracts important information into parameter field...
static isFlickr($a_location)
Identify Flickr links.
static extractGoogleVideoParameters($a_location)
Extract GoogleVideo Parameter.
static extractVimeoParameters($a_location)
Extract Vimeo Parameter.
static extractFlickrParameters($a_location)
Extract Flickr Parameter.
Create styles array
The data for the language used.
static isVimeo($a_location)
Identify Vimeo links.
static extractYouTubeParameters($a_location)
Extract YouTube Parameter.
static isGoogleDocument($a_location)
Identify Google Document links.