ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 isGoogleDocument($a_location)
154  {
155  if (strpos($a_location, "docs.google") > 0)
156  {
157  return true;
158  }
159  return false;
160  }
161 
165  static function extractGoogleDocumentParameters($a_location)
166  {
167  $par = array();
168  $pos1 = strpos($a_location, "id=");
169  $pos2 = strpos($a_location, "&", $pos1 + 3);
170  if ($pos1 > 0)
171  {
172  $len = ($pos2 > 0)
173  ? $pos2
174  : strlen($a_location);
175  $par["docid"] = substr($a_location, $pos1+3, $len - ($pos1+3));
176  }
177  $pos1 = strpos($a_location, "docID=");
178  $pos2 = strpos($a_location, "&", $pos1 + 6);
179  if ($pos1 > 0)
180  {
181  $len = ($pos2 > 0)
182  ? $pos2
183  : strlen($a_location);
184  $par["docid"] = substr($a_location, $pos1+6, $len - ($pos1+6));
185  }
186  if (strpos($a_location, "Presentation?") > 0)
187  {
188  $par["type"] = "Presentation";
189  }
190  if (strpos($a_location, "View?") > 0)
191  {
192  $par["type"] = "Document";
193  }
194 
195  return $par;
196  }
197 
201  static function extractUrlParameters($a_location, $a_parameter)
202  {
203  if (!is_array($a_parameter))
204  {
205  $a_parameter = array();
206  }
207 
208  $ext_par = array();
209 
210  // YouTube
211  if (ilExternalMediaAnalyzer::isYouTube($a_location))
212  {
214  $a_parameter = array();
215  }
216 
217  // Flickr
218  if (ilExternalMediaAnalyzer::isFlickr($a_location))
219  {
220  $ext_par = ilExternalMediaAnalyzer::extractFlickrParameters($a_location);
221  $a_parameter = array();
222  }
223 
224  // GoogleVideo
226  {
228  $a_parameter = array();
229  }
230 
231  // GoogleDocs
233  {
235  $a_parameter = array();
236  }
237 
238  foreach($ext_par as $name => $value)
239  {
240  $a_parameter[$name] = $value;
241  }
242 
243  return $a_parameter;
244  }
245 }
246 ?>