Changeset 29627
- Timestamp:
- Sep 18, 2014, 3:53:51 PM (10 years ago)
- Location:
- extensions/gvideo
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/gvideo/admin.php
r26524 r29627 4 4 global $template, $page, $conf; 5 5 6 load_language('plugin.lang', GVIDEO_PATH);7 8 6 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : $page['tab'] = 'add'; 9 7 10 8 if ($page['tab'] != 'photo') 11 9 { 10 load_language('plugin.lang', GVIDEO_PATH); 11 12 12 // tabsheet 13 13 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); -
extensions/gvideo/admin/add.php
r28268 r29627 18 18 $page['errors'][] = l10n('Please fill the video URL'); 19 19 } 20 else if ( ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false )20 else if ( ($video = parse_video_url($_POST['url'], $safe_mode)) === false ) 21 21 { 22 if (isset($_POST['safe_mode'])) 22 $page['errors'][] = l10n('an error happened'); 23 } 24 else 25 { 26 if ($safe_mode === true) 23 27 { 24 $page['errors'][] = l10n('an error happened'); 28 $page['warnings'][] = l10n('Unable to contact host server'); 29 $page['warnings'][] = l10n('Video data like description and thumbnail might be missing'); 25 30 } 26 else 27 { 28 $page['errors'][] = l10n('Unable to contact host server'); 29 $page['errors'][] = l10n('Try in safe-mode'); 30 } 31 $_POST['safe_mode'] = true; 32 } 33 34 if (count($page['errors']) == 0) 35 { 31 36 32 if ($_POST['size_common'] == 'true') 37 33 { -
extensions/gvideo/admin/photo.php
r28268 r29627 56 56 else if ($gvideo['url']!=$_POST['url']) 57 57 { 58 if ( ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false ) 59 { 60 if (isset($_POST['safe_mode'])) 61 { 62 $page['errors'][] = l10n('an error happened'); 63 } 64 else 65 { 66 $page['errors'][] = l10n('Unable to contact host server'); 67 $page['errors'][] = l10n('Try in safe-mode'); 68 } 58 if ( ($video = parse_video_url($_POST['url'], $safe_mode)) === false ) 59 { 60 $page['errors'][] = l10n('an error happened'); 69 61 } 70 62 } 71 63 else 72 64 { 65 $safe_mode = false; 73 66 $video = $gvideo; 74 67 } … … 76 69 if (count($page['errors']) == 0) 77 70 { 78 71 if ($safe_mode === true) 72 { 73 $page['warnings'][] = l10n('Unable to contact host server'); 74 $page['warnings'][] = l10n('Video data like description and thumbnail might be missing'); 75 } 76 79 77 if ($gvideo['url'] != $video['url']) 80 78 { -
extensions/gvideo/admin/template/add.tpl
r28268 r29627 124 124 <p style="text-align:left;"> 125 125 <input type="submit" name="add_video" value="{'Add'|translate}"> 126 127 <span class="embed-hide provider-show">128 <label style="font-weight:bold;"><input type="checkbox" name="safe_mode" {if $POST.safe_mode}checked="checked"{/if}> {'Safe-mode'|translate}</label>129 <a class="icon-info-circled-1 showInfo" title="{'In safe-mode, the plugin does\'t try to contact the video host, usefull on some websites where remote connections are blocked.'|translate|escape:html}"></a>130 </span>131 126 </p> 132 127 -
extensions/gvideo/admin/template/photo.tpl
r28268 r29627 108 108 109 109 <p style="margin:0;"> 110 {if $GVIDEO.type != 'embed'}<label style="font-weight:bold;"><input type="checkbox" name="safe_mode"> {'Safe-mode'|translate}</label>111 <br>{/if}112 110 <input class="submit" type="submit" value="{'Save Settings'|translate}" name="save_properties"> 113 111 </p> -
extensions/gvideo/include/functions.inc.php
r29299 r29627 2 2 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 3 3 4 function parse_video_url($source_url, $safe_mode=false)4 function parse_video_url($source_url, &$safe_mode=false) 5 5 { 6 6 $source_url = 'http://'.preg_replace('#^http(s?)://#', null, trim($source_url)); … … 46 46 $video['title'] = 'YouTube #'.$video['video_id']; 47 47 48 if (!$safe_mode) 49 { 50 $api_url = 'http://gdata.youtube.com/feeds/api/videos/'.$video['video_id'].'?v=2&alt=json'; 51 $json = gvideo_download_remote_file($api_url, true); 52 53 if ($json===false || $json=='file_error') return false; 48 $api_url = 'http://gdata.youtube.com/feeds/api/videos/'.$video['video_id'].'?v=2&alt=json'; 49 $json = gvideo_download_remote_file($api_url, true); 50 51 if ($json===false || $json=='file_error') 52 { 53 $safe_mode = true; 54 } 55 else 56 { 54 57 if (strip_tags($json) == 'GDataInvalidRequestUriExceptionInvalid id') return false; // unknown video 55 58 if (strip_tags($json) == 'GDataServiceForbiddenExceptionPrivate video') return false; // private video … … 82 85 $video['title'] = 'Vimeo #'.$video['video_id']; 83 86 84 if (!$safe_mode) 85 { 86 // simple API for public videos 87 $api_url_1 = 'http://vimeo.com/api/v2/video/'.$video['video_id'].'.json'; 88 $json = gvideo_download_remote_file($api_url_1, true); 89 90 if ($json!==false && $json!='file_error' && trim($json)!=$video['video_id'].' not found.') 87 // simple API for public videos 88 $api_url_1 = 'http://vimeo.com/api/v2/video/'.$video['video_id'].'.json'; 89 $json = gvideo_download_remote_file($api_url_1, true); 90 91 if ($json===false || $json=='file_error') 92 { 93 $safe_mode = true; 94 } 95 else 96 { 97 if (trim($json)!=$video['video_id'].' not found.') 91 98 { 92 99 $json = json_decode($json, true); … … 105 112 $json = gvideo_download_remote_file($api_url_2, true); 106 113 107 if ($json===false || $json=='file_error') return false; 108 109 $json = json_decode($json, true); 110 $video = array_merge($video, array( 111 'title' => $json['title'], 112 'description' => $json['description'], 113 'thumbnail' => $json['thumbnail_url'], 114 'author' => $json['author_name'], 115 )); 114 if ($json===false || $json=='file_error') 115 { 116 $safe_mode = true; 117 } 118 else 119 { 120 $json = json_decode($json, true); 121 $video = array_merge($video, array( 122 'title' => $json['title'], 123 'description' => $json['description'], 124 'thumbnail' => $json['thumbnail_url'], 125 'author' => $json['author_name'], 126 )); 127 } 116 128 } 117 129 130 // default thumbnail has no extension 118 131 if ($video['thumbnail'] == 'http://i.vimeocdn.com/video/default_640') 119 132 { … … 146 159 $video['title'] = 'Dailymotion #'.$video['video_id']; 147 160 148 if (!$safe_mode) 149 { 150 $api_url = 'https://api.dailymotion.com/video/'.$video['video_id'].'?fields=description,thumbnail_large_url,title,owner.username,tags'; // DM doesn't accept non secure connection 151 $json = gvideo_download_remote_file($api_url, true); 152 153 if ($json===false || $json=='file_error') return false; 154 161 $api_url = 'https://api.dailymotion.com/video/'.$video['video_id'].'?fields=description,thumbnail_large_url,title,owner.username,tags'; // DM doesn't accept non secure connection 162 $json = gvideo_download_remote_file($api_url, true); 163 164 if ($json===false || $json=='file_error') 165 { 166 $safe_mode = true; 167 } 168 else 169 { 155 170 $json = json_decode($json, true); 171 156 172 if (@$json['error']['type'] == 'access_forbidden') return false; // private video 157 $json['thumbnail_large_url'] = preg_replace('#\?([0-9]+)$#', null, $json['thumbnail_large_url']);158 173 159 174 $video = array_merge($video, array( 160 175 'title' => $json['title'], 161 176 'description' => $json['description'], 162 'thumbnail' => $json['thumbnail_large_url'],177 'thumbnail' => preg_replace('#\?([0-9]+)$#', null, $json['thumbnail_large_url']), 163 178 'author' => $json['owner.username'], 164 179 'tags' => implode(',', $json['tags']), … … 170 185 171 186 /* wat */ 187 // URL doesn't contain ID... require to contact host 172 188 case 'wat': 173 189 { 174 if ($safe_mode) return false;175 176 190 $html = gvideo_download_remote_file($source_url, true); 177 191 178 if ($html===false || $html=='file_error') return false; 192 if ($json===false || $json=='file_error') 193 { 194 return false; 195 } 179 196 180 197 $video['type'] = 'wat'; … … 214 231 $video['title'] = 'Wideo #'.$video['video_id']; 215 232 216 if (!$safe_mode) 217 { 218 $html = gvideo_download_remote_file($source_url, true); 219 220 if ($html===false || $html=='file_error') return false; 221 233 $html = gvideo_download_remote_file($source_url, true); 234 235 if ($json===false || $json=='file_error') 236 { 237 $safe_mode = true; 238 } 239 else 240 { 222 241 preg_match('#<meta property="og:title" content="([^">]*)" />#', $html, $matches); 223 242 $video['title'] = $matches[1]; -
extensions/gvideo/language/en_UK/plugin.lang.php
r28268 r29627 26 26 $lang['Vimeo player'] = 'Vimeo player'; 27 27 $lang['Dailymotion player'] = 'Dailymotion player'; 28 $lang['Try in safe-mode'] = 'Try in safe-mode';29 $lang['Safe-mode'] = 'Safe-mode';30 $lang['In safe-mode, the plugin does\'t try to contact the video host, usefull on some websites where remote connections are blocked.'] = 'In safe-mode, the plugin does\'t try to contact the video host, usefull on some websites where remote connections are blocked.';31 28 $lang['Video properties'] = 'Video properties'; 32 29 $lang['Show privacy details'] = 'Show privacy details'; … … 44 41 $lang['Width and height must be integers'] = 'Width and height must be integers'; 45 42 $lang['Do not use this form for videos provided by Youtube, Dailymotion, Vimeo, Wat or Wideo.'] = 'Do not use this form for videos provided by Youtube, Dailymotion, Vimeo, Wat or Wideo.'; 46 43 $lang['Video data like description and thumbnail might be missing'] = 'Video data like description and thumbnail might be missing'; 47 44 ?> -
extensions/gvideo/language/fr_FR/plugin.lang.php
r28268 r29627 26 26 $lang['Vimeo player'] = 'Lecteur Vimeo'; 27 27 $lang['Dailymotion player'] = 'Lecteur Dailymotion'; 28 $lang['Try in safe-mode'] = 'Essayez en mode sans échec';29 $lang['Safe-mode'] = 'Mode sans échec';30 $lang['In safe-mode, the plugin does\'t try to contact the video host, usefull on some websites where remote connections are blocked.'] = 'En mode sans échec, le plugin n\'essaye pas de contacter l\'hébergeur de la vidéo, utile sur certains sites où les connexions externes sont bloquées.';31 28 $lang['Video properties'] = 'Propriétés vidéo'; 32 29 $lang['Show privacy details'] = 'A propos des vidéos privées'; … … 44 41 $lang['Width and height must be integers'] = 'Hauteur et largeur doivent être des entiers'; 45 42 $lang['Do not use this form for videos provided by Youtube, Dailymotion, Vimeo, Wat or Wideo.'] = 'N\'utilisez pas ce formulaire pour les vidéos hébergées par Youtube, Dailymotion, Vimeo, Wat or Wideo.'; 46 43 $lang['Video data like description and thumbnail might be missing'] = 'Des données de la vidéo comme sa description ou sa miniature peuvent manquer'; 47 44 ?> -
extensions/gvideo/main.inc.php
r28842 r29627 67 67 68 68 global $gvideo, $page; 69 70 load_language('plugin.lang', GVIDEO_PATH); 69 71 70 72 if ($page['tab'] == 'properties') 71 73 { 72 $page['infos'][] = 'This element is a video added with "Embedded Video"';74 $page['infos'][] = l10n('This element is a video added with "Embedded Video"'); 73 75 } 74 76
Note: See TracChangeset
for help on using the changeset viewer.