ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 {
42 return true;
43 }
44 return false;
45 }
46
50 static function extractYouTubeParameters($a_location)
51 {
52 $par = array();
53 $pos1 = strpos($a_location, "v=");
54 $pos2 = strpos($a_location, "&", $pos1);
55 if ($pos1 > 0)
56 {
57 $len = ($pos2 > 0)
58 ? $pos2
59 : strlen($a_location);
60 $par["v"] = substr($a_location, $pos1+2, $len - ($pos1+2));
61 }
62
63 return $par;
64 }
65
69 static function isFlickr($a_location)
70 {
71 if (strpos($a_location, "flickr.com") > 0)
72 {
73 return true;
74 }
75 return false;
76 }
77
81 static function extractFlickrParameters($a_location)
82 {
83 $par = array();
84 $pos1 = strpos($a_location, "flickr.com/photos/");
85 $pos2 = strpos($a_location, "/", $pos1+18);
86 if ($pos1 > 0)
87 {
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 {
99 $len = ($pos2 > 0)
100 ? $pos2
101 : strlen($a_location);
102 $par["tags"] = substr($a_location, $pos1+6, $len - ($pos1+6));
103 }
104
105 // sets
106 $pos1 = strpos($a_location, "/sets/");
107 $pos2 = strpos($a_location, "/", $pos1+6);
108 if ($pos1 > 0)
109 {
110 $len = ($pos2 > 0)
111 ? $pos2
112 : $a_location;
113 $par["sets"] = substr($a_location, $pos1+6, $len - ($pos1+6));
114 }
115
116 return $par;
117 }
118
122 static function isGoogleVideo($a_location)
123 {
124 if (strpos($a_location, "video.google") > 0)
125 {
126 return true;
127 }
128 return false;
129 }
130
134 static function extractGoogleVideoParameters($a_location)
135 {
136 $par = array();
137 $pos1 = strpos($a_location, "docid=");
138 $pos2 = strpos($a_location, "&", $pos1 + 6);
139 if ($pos1 > 0)
140 {
141 $len = ($pos2 > 0)
142 ? $pos2
143 : strlen($a_location);
144 $par["docid"] = substr($a_location, $pos1+6, $len - ($pos1+6));
145 }
146
147 return $par;
148 }
149
153 static function isVimeo($a_location)
154 {
155 if (strpos($a_location, "vimeo.com") > 0)
156 {
157 return true;
158 }
159 return false;
160 }
161
165 static function extractVimeoParameters($a_location)
166 {
167 $par = array();
168 $pos1 = strpos($a_location, "vimeo.com/");
169 $pos2 = strpos($a_location, "&", $pos1 + 10);
170 if ($pos1 > 0)
171 {
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 }
180
184 static function isGoogleDocument($a_location)
185 {
186 if (strpos($a_location, "docs.google") > 0)
187 {
188 return true;
189 }
190 return false;
191 }
192
196 static function extractGoogleDocumentParameters($a_location)
197 {
198 $par = array();
199 $pos1 = strpos($a_location, "id=");
200 $pos2 = strpos($a_location, "&", $pos1 + 3);
201 if ($pos1 > 0)
202 {
203 $len = ($pos2 > 0)
204 ? $pos2
205 : strlen($a_location);
206 $par["docid"] = substr($a_location, $pos1+3, $len - ($pos1+3));
207 }
208 $pos1 = strpos($a_location, "docID=");
209 $pos2 = strpos($a_location, "&", $pos1 + 6);
210 if ($pos1 > 0)
211 {
212 $len = ($pos2 > 0)
213 ? $pos2
214 : strlen($a_location);
215 $par["docid"] = substr($a_location, $pos1+6, $len - ($pos1+6));
216 }
217 if (strpos($a_location, "Presentation?") > 0)
218 {
219 $par["type"] = "Presentation";
220 }
221 if (strpos($a_location, "View?") > 0)
222 {
223 $par["type"] = "Document";
224 }
225
226 return $par;
227 }
228
232 static function extractUrlParameters($a_location, $a_parameter)
233 {
234 if (!is_array($a_parameter))
235 {
236 $a_parameter = array();
237 }
238
239 $ext_par = array();
240
241 // YouTube
242 if (ilExternalMediaAnalyzer::isYouTube($a_location))
243 {
245 $a_parameter = array();
246 }
247
248 // Flickr
249 if (ilExternalMediaAnalyzer::isFlickr($a_location))
250 {
252 $a_parameter = array();
253 }
254
255 // GoogleVideo
257 {
259 $a_parameter = array();
260 }
261
262 // GoogleDocs
264 {
266 $a_parameter = array();
267 }
268
269 foreach($ext_par as $name => $value)
270 {
271 $a_parameter[$name] = $value;
272 }
273
274 return $a_parameter;
275 }
276}
277?>
Analyzes external media locations and extracts important information into parameter field.
static extractUrlParameters($a_location, $a_parameter)
Extract URL information to parameter array.
static extractYouTubeParameters($a_location)
Extract YouTube Parameter.
static extractFlickrParameters($a_location)
Extract Flickr Parameter.
static isVimeo($a_location)
Identify Vimeo links.
static isGoogleDocument($a_location)
Identify Google Document links.
static extractGoogleVideoParameters($a_location)
Extract GoogleVideo Parameter.
static extractVimeoParameters($a_location)
Extract Vimeo Parameter.
static isGoogleVideo($a_location)
Identify GoogleVideo links.
static isFlickr($a_location)
Identify Flickr links.
static extractGoogleDocumentParameters($a_location)
Extract GoogleDocument Parameter.
static isYouTube($a_location)
Identify YouTube links.