Changeset 29627


Ignore:
Timestamp:
09/18/14 15:53:51 (5 years ago)
Author:
mistic100
Message:

remove "safe mode" checkbox, now fully automatic

Location:
extensions/gvideo
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • extensions/gvideo/admin.php

    r26524 r29627  
    44global $template, $page, $conf; 
    55 
    6 load_language('plugin.lang', GVIDEO_PATH); 
    7  
    86$page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : $page['tab'] = 'add'; 
    97 
    108if ($page['tab'] != 'photo') 
    119{ 
     10  load_language('plugin.lang', GVIDEO_PATH); 
     11   
    1212  // tabsheet 
    1313  include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 
  • extensions/gvideo/admin/add.php

    r28268 r29627  
    1818      $page['errors'][] = l10n('Please fill the video URL'); 
    1919    } 
    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 ) 
    2121    { 
    22       if (isset($_POST['safe_mode'])) 
     22      $page['errors'][] = l10n('an error happened'); 
     23    } 
     24    else 
     25    { 
     26      if ($safe_mode === true) 
    2327      { 
    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'); 
    2530      } 
    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       
    3632      if ($_POST['size_common'] == 'true') 
    3733      { 
  • extensions/gvideo/admin/photo.php

    r28268 r29627  
    5656    else if ($gvideo['url']!=$_POST['url']) 
    5757    { 
    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'); 
    6961      } 
    7062    } 
    7163    else 
    7264    { 
     65      $safe_mode = false; 
    7366      $video = $gvideo; 
    7467    } 
     
    7669    if (count($page['errors']) == 0) 
    7770    { 
    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       
    7977      if ($gvideo['url'] != $video['url']) 
    8078      { 
  • extensions/gvideo/admin/template/add.tpl

    r28268 r29627  
    124124<p style="text-align:left;"> 
    125125  <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> 
    131126</p> 
    132127 
  • extensions/gvideo/admin/template/photo.tpl

    r28268 r29627  
    108108     
    109109    <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} 
    112110      <input class="submit" type="submit" value="{'Save Settings'|translate}" name="save_properties"> 
    113111    </p> 
  • extensions/gvideo/include/functions.inc.php

    r29299 r29627  
    22defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 
    33 
    4 function parse_video_url($source_url, $safe_mode=false) 
     4function parse_video_url($source_url, &$safe_mode=false) 
    55{ 
    66  $source_url = 'http://'.preg_replace('#^http(s?)://#', null, trim($source_url)); 
     
    4646      $video['title'] = 'YouTube #'.$video['video_id']; 
    4747       
    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      { 
    5457        if (strip_tags($json) == 'GDataInvalidRequestUriExceptionInvalid id') return false; // unknown video 
    5558        if (strip_tags($json) == 'GDataServiceForbiddenExceptionPrivate video') return false; // private video 
     
    8285      $video['title'] = 'Vimeo #'.$video['video_id']; 
    8386       
    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.') 
    9198        { 
    9299          $json = json_decode($json, true); 
     
    105112          $json = gvideo_download_remote_file($api_url_2, true); 
    106113           
    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          } 
    116128        } 
    117129         
     130        // default thumbnail has no extension 
    118131        if ($video['thumbnail'] == 'http://i.vimeocdn.com/video/default_640') 
    119132        { 
     
    146159      $video['title'] = 'Dailymotion #'.$video['video_id']; 
    147160       
    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      { 
    155170        $json = json_decode($json, true); 
     171         
    156172        if (@$json['error']['type'] == 'access_forbidden') return false; // private video 
    157         $json['thumbnail_large_url'] = preg_replace('#\?([0-9]+)$#', null, $json['thumbnail_large_url']); 
    158173         
    159174        $video = array_merge($video, array( 
    160175          'title' => $json['title'], 
    161176          'description' => $json['description'], 
    162           'thumbnail' => $json['thumbnail_large_url'], 
     177          'thumbnail' => preg_replace('#\?([0-9]+)$#', null, $json['thumbnail_large_url']), 
    163178          'author' => $json['owner.username'], 
    164179          'tags' => implode(',', $json['tags']), 
     
    170185       
    171186    /* wat */ 
     187    // URL doesn't contain ID... require to contact host 
    172188    case 'wat': 
    173189    { 
    174       if ($safe_mode) return false; 
    175        
    176190      $html = gvideo_download_remote_file($source_url, true); 
    177191 
    178       if ($html===false || $html=='file_error') return false; 
     192      if ($json===false || $json=='file_error') 
     193      { 
     194        return false; 
     195      } 
    179196       
    180197      $video['type'] = 'wat'; 
     
    214231      $video['title'] = 'Wideo #'.$video['video_id']; 
    215232       
    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      { 
    222241        preg_match('#<meta property="og:title" content="([^">]*)" />#', $html, $matches); 
    223242        $video['title'] = $matches[1]; 
  • extensions/gvideo/language/en_UK/plugin.lang.php

    r28268 r29627  
    2626$lang['Vimeo player'] = 'Vimeo player'; 
    2727$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.'; 
    3128$lang['Video properties'] = 'Video properties'; 
    3229$lang['Show privacy details'] = 'Show privacy details'; 
     
    4441$lang['Width and height must be integers'] = 'Width and height must be integers'; 
    4542$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'; 
    4744?> 
  • extensions/gvideo/language/fr_FR/plugin.lang.php

    r28268 r29627  
    2626$lang['Vimeo player'] = 'Lecteur Vimeo'; 
    2727$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.'; 
    3128$lang['Video properties'] = 'Propriétés vidéo'; 
    3229$lang['Show privacy details'] = 'A propos des vidéos privées'; 
     
    4441$lang['Width and height must be integers'] = 'Hauteur et largeur doivent être des entiers'; 
    4542$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'; 
    4744?> 
  • extensions/gvideo/main.inc.php

    r28842 r29627  
    6767   
    6868  global $gvideo, $page; 
     69   
     70  load_language('plugin.lang', GVIDEO_PATH); 
    6971 
    7072  if ($page['tab'] == 'properties') 
    7173  { 
    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"'); 
    7375  } 
    7476   
Note: See TracChangeset for help on using the changeset viewer.