Index: /extensions/gvideo/admin.php
===================================================================
--- /extensions/gvideo/admin.php	(revision 17625)
+++ /extensions/gvideo/admin.php	(revision 17626)
@@ -6,13 +6,17 @@
 $conf['gvideo'] = unserialize($conf['gvideo']);
 
-// tabsheet
-include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : $page['tab'] = 'add';
-  
-$tabsheet = new tabsheet();
-$tabsheet->add('add', l10n('Add a video'), GVIDEO_ADMIN . '-add');
-$tabsheet->add('config', l10n('Configuration'), GVIDEO_ADMIN . '-config');
-$tabsheet->select($page['tab']);
-$tabsheet->assign();
+
+
+if ($page['tab'] != 'photo')
+{
+  // tabsheet
+  include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
+  $tabsheet = new tabsheet();
+  $tabsheet->add('add', l10n('Add a video'), GVIDEO_ADMIN . '-add');
+  $tabsheet->add('config', l10n('Configuration'), GVIDEO_ADMIN . '-config');
+  $tabsheet->select($page['tab']);
+  $tabsheet->assign();
+}
 
 // include page
Index: /extensions/gvideo/admin/photo.php
===================================================================
--- /extensions/gvideo/admin/photo.php	(revision 17626)
+++ /extensions/gvideo/admin/photo.php	(revision 17626)
@@ -0,0 +1,207 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery                                    |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+if(!defined("PHPWG_ROOT_PATH")) die ("Hacking attempt!");
+
+
+// +-----------------------------------------------------------------------+
+// | Basic checks                                                          |
+// +-----------------------------------------------------------------------+
+
+check_status(ACCESS_ADMINISTRATOR);
+
+check_input_parameter('image_id', $_GET, false, PATTERN_ID);
+
+$admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id'];
+$self_url = GVIDEO_ADMIN.'-photo&amp;image_id='.$_GET['image_id'];
+
+// +-----------------------------------------------------------------------+
+// | Tabs                                                                  |
+// +-----------------------------------------------------------------------+
+include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
+$tabsheet = new tabsheet();
+$tabsheet->set_id('photo');
+$tabsheet->select('gvideo');
+$tabsheet->assign();
+
+// +-----------------------------------------------------------------------+
+// | Picture infos                                                         |
+// +-----------------------------------------------------------------------+
+global $gvideo;
+
+$query = '
+SELECT *
+  FROM '.IMAGES_TABLE.'
+  WHERE id = '.$_GET['image_id'].'
+;';
+$picture = pwg_db_fetch_assoc(pwg_query($query));
+
+
+// +-----------------------------------------------------------------------+
+// | Update properties                                                     |
+// +-----------------------------------------------------------------------+
+if (isset($_POST['save_properties']))
+{
+  // check inputs
+  if (empty($_POST['url']))
+  {
+    array_push($page['errors'], l10n('Please fill the video URL'));
+  }
+  if ( !empty($_POST['url']) and ($video = parse_video_url($_POST['url'])) === false )
+  {
+    array_push($page['errors'], l10n('Unable to contact host server'));
+  }
+  
+  if (count($page['errors']) == 0)
+  {
+    include_once(GVIDEO_PATH.'include/functions.inc.php');
+    include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
+
+    // download thumbnail
+    $thumb_name = $video['type'].'-'.$video['id'].'-'.uniqid().'.'.get_extension($video['thumbnail']);
+    $thumb_source = $conf['data_location'].$thumb_name;
+    if (download_remote_file($video['thumbnail'], $thumb_source) !== true)
+    {
+      $thumb_source = $conf['data_location'].get_filename_wo_extension($thumb_name).'.jpg';
+      copy(GVIDEO_PATH.'mimetypes/'.$video['type'].'.jpg', $thumb_source);
+    }
+    
+    // add image and update infos
+    $image_id = add_uploaded_file($thumb_source, $thumb_name, null, null, $_GET['image_id']);
+    
+    $updates = array(
+      'name' => pwg_db_real_escape_string($video['title']),
+      'comment' => pwg_db_real_escape_string($video['description']),
+      'author' => pwg_db_real_escape_string($video['author']),
+      'is_gvideo' => 1,
+      );
+    
+    single_update(
+      IMAGES_TABLE,
+      $updates,
+      array('id' => $_GET['image_id']),
+      true
+      );
+    
+    // register video
+    if ($_POST['size_common'] == 'true')
+    {
+      $_POST['width'] = $_POST['height'] = '';
+    }
+    if ($_POST['autoplay_common'] == 'true')
+    {
+      $_POST['autoplay'] = '';
+    }
+    
+    $updates = array(
+      'url' => $video['url'],
+      'type' => $video['type'],
+      'video_id' => $video['id'],
+      'width' => $_POST['width'],
+      'height' => $_POST['height'],
+      'autoplay' => $_POST['autoplay'],
+      );
+      
+    single_update(
+      GVIDEO_TABLE,
+      $updates,
+      array('picture_id' => $_GET['image_id']),
+      true
+      );
+      
+    array_push($page['infos'], l10n('Video successfully updated'));
+    unset($_POST);
+  }
+}
+
+// +-----------------------------------------------------------------------+
+// | Update thumbnail (from Photo Update)                                  |
+// +-----------------------------------------------------------------------+
+if (isset($_FILES['photo_update']))
+{
+  include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
+  
+  if ($_FILES['photo_update']['error'] !== UPLOAD_ERR_OK)
+  {
+    array_push($page['errors'],
+      file_upload_error_message($_FILES['photo_update']['error'])
+      );
+  }
+  else
+  {
+    add_uploaded_file(
+      $_FILES['photo_update']['tmp_name'],
+      $_FILES['photo_update']['name'],
+      null,
+      null,
+      $_GET['image_id']
+      );
+
+    array_push($page['infos'], l10n('The thumbnail was updated'));
+  }
+}
+
+// +-----------------------------------------------------------------------+
+// | Add film frame                                                        |
+// +-----------------------------------------------------------------------+
+if ( function_exists('imagecreatetruecolor') and isset($_GET['add_film_frame']) )
+{
+  include_once(GVIDEO_PATH . '/include/functions.inc.php');
+  include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
+  
+  $thumb_source = $conf['data_location'].$picture['file'];
+  
+  add_film_frame($picture['path'], $thumb_source);
+  add_uploaded_file($thumb_source, $picture['file'], null, null, $_GET['image_id']);
+  
+  redirect($self_url);
+}
+
+
+// +-----------------------------------------------------------------------+
+// | Template                                                              |
+// +-----------------------------------------------------------------------+
+if (empty($gvideo['height']))
+{
+  $gvideo['size_common'] = 'true';
+}
+if (empty($gvideo['autoplay']))
+{
+  $gvideo['autoplay_common'] = 'true';
+}
+
+if (function_exists('imagecreatetruecolor'))
+{
+  $template->assign('U_ADD_FILM_FRAME', $self_url.'&amp;add_film_frame=1');
+}
+
+$template->assign(array(
+  'F_ACTION' => $self_url,
+  'GVIDEO' => $gvideo,
+  'TN_SRC' => DerivativeImage::thumb_url($picture).'?'.time(),
+  'TITLE' => render_element_name($picture),
+));
+
+$template->set_filename('gvideo_content', dirname(__FILE__).'/template/photo.tpl');
+
+?>
Index: /extensions/gvideo/admin/template/add.tpl
===================================================================
--- /extensions/gvideo/admin/template/add.tpl	(revision 17625)
+++ /extensions/gvideo/admin/template/add.tpl	(revision 17626)
@@ -37,5 +37,5 @@
       <label>
         <span class="property">{'Video URL'|@translate}</span>
-        <input type="text" name="url" value="{$POST.url}" style="width:400px">
+        <input type="text" name="url" value="{$POST.url}" style="width:400px;">
       </label>
     </li>
Index: /extensions/gvideo/admin/template/photo.tpl
===================================================================
--- /extensions/gvideo/admin/template/photo.tpl	(revision 17626)
+++ /extensions/gvideo/admin/template/photo.tpl	(revision 17626)
@@ -0,0 +1,91 @@
+{combine_css path=$GVIDEO_PATH|@cat:"admin/template/style.css"}
+
+{footer_script}{literal}
+jQuery("input[data-toggle]").change(function() {
+  $block = $('#'+ $(this).data('toggle'));
+  if ($block.is(':visible')) {
+    $block.css('display', 'none');
+  } else {
+    $block.css('display', 'block');
+  }
+});
+{/literal}
+
+var border = jQuery("input[name='url']").css('border');
+
+jQuery("input[name='url']").keyup(function() {ldelim}
+  if ($(this).val() != "{$GVIDEO.url}") {ldelim}
+    $(this).css('border', '1px solid #c00');
+    $("#change_warning").show();
+  } else {ldelim}
+    $(this).css('border', border);
+    $("#change_warning").hide();
+  }
+});
+{/footer_script}
+
+<h2>{$TITLE} &#8250; {'Edit photo'|@translate} {$TABSHEET_TITLE}</h2>
+
+<fieldset>
+  <legend>{'Thumbnail'|@translate}</legend>
+  <table>
+    <tr>
+      <td id="albumThumbnail">
+        <img src="{$TN_SRC}" alt="{'Thumbnail'|@translate}" class="Thumbnail">
+      </td>
+      <td id="albumLinks" style="width:400px;vertical-align:top;">
+        <ul style="padding-left:15px;margin:0;">
+        {if $U_ADD_FILM_FRAME}
+          <li style="margin:10px 0 20px 0;"><a href="{$U_ADD_FILM_FRAME}">{'Add film effect'|@translate}</a></li>
+        {/if}
+        
+          <li>
+            <form id="photo_update" method="post" action="{$F_ACTION}" enctype="multipart/form-data">
+              {'Upload a new thumbnail'|@translate}<br>
+              <input type="file" size="20" name="photo_update">
+              <input class="submit" type="submit" value="{'Send'|@translate}" name="photo_update">
+            </form>
+          </li>
+        </ul>
+      </td>
+    </tr>
+  </table>
+</fieldset>
+
+<form action="{$F_ACTION}" method="post" id="catModify">
+  <fieldset>
+    <legend>{'Properties'|@translate}</legend>
+
+    <p>
+      <b>{'Video URL'|@translate}</b>
+      <input type="text" name="url" value="{$GVIDEO.url}" style="width:400px;">
+      <span id="change_warning" style="display:none;">{'Changing the url will reset video description, name and thumbnail'|@translate}</span>
+    </p>
+
+    <p>
+      <b>{'Video size'|@translate}</b>
+      <label><input type="radio" name="size_common" value="true" {if $GVIDEO.size_common == 'true'}checked="checked"{/if} data-toggle="size"> {'Use common setting'|@translate}</label>
+      <label><input type="radio" name="size_common" value="false" {if $GVIDEO.size_common != 'true'}checked="checked"{/if} data-toggle="size"> {'Change'|@translate}</label>
+      
+      <span {if $GVIDEO.size_common == 'true'}style="display:none;"{/if} id="size">
+        <input type="text" name="width" value="{$GVIDEO.width}" size="4"> &times;
+        <input type="text" name="height" value="{$GVIDEO.height}" size="4"> px
+      </span>
+    </p>
+    
+    <p>
+      <b>{'Autoplay'|@translate}</b>
+      <label><input type="radio" name="autoplay_common" value="true" {if $GVIDEO.autoplay_common == 'true'}checked="checked"{/if} data-toggle="autoplay"> {'Use common setting'|@translate}</label>
+      <label><input type="radio" name="autoplay_common" value="false" {if $GVIDEO.autoplay_common != 'true'}checked="checked"{/if} data-toggle="autoplay"> {'Change'|@translate}</label>
+      
+      <span {if $GVIDEO.autoplay_common == 'true'}style="display:none;"{/if} id="autoplay">
+        <label><input type="radio" name="autoplay" value="0" {if $GVIDEO.autoplay == '0'}checked="checked"{/if}> {'No'|@translate}</label>
+        <label><input type="radio" name="autoplay" value="1" {if $GVIDEO.autoplay == '1'}checked="checked"{/if}> {'Yes'|@translate}</label>
+      </span>
+    </p>
+
+    <p style="margin:0;">
+      <input class="submit" type="submit" value="{'Save Settings'|@translate}" name="save_properties">
+    </p>
+  </fieldset>
+</form>
Index: /extensions/gvideo/admin/template/style.css
===================================================================
--- /extensions/gvideo/admin/template/style.css	(revision 17625)
+++ /extensions/gvideo/admin/template/style.css	(revision 17626)
@@ -57,2 +57,8 @@
   margin-left:20px;
 }
+
+#change_warning {
+  display:block;
+  color:#c00;
+  font-weight:bold;
+}
Index: /extensions/gvideo/include/gvideo.inc.php
===================================================================
--- /extensions/gvideo/include/gvideo.inc.php	(revision 17625)
+++ /extensions/gvideo/include/gvideo.inc.php	(revision 17626)
@@ -68,60 +68,3 @@
 }
 
-/**
- * add message and link on edition page
- */
-function gvideo_photo_edit()
-{
-  global $page, $template, $conf;
-  
-  if ($page['page'] != 'photo') return;
-  
-  $query = '
-SELECT *
-  FROM '.GVIDEO_TABLE.'
-  WHERE picture_id = '.$_GET['image_id'].'
-;';
-  $result = pwg_query($query);
-  
-  if (!pwg_db_num_rows($result)) return;
-    
-  $video = pwg_db_fetch_assoc($result);
-    
-  array_push($page['warnings'], l10n('This element is a video added with "Embedded Video"'));
-  
-  if (function_exists('imagecreatetruecolor'))
-  {
-    if (isset($_GET['add_film_frame']))
-    {
-      include_once(GVIDEO_PATH . '/include/functions.inc.php');
-      include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
-      
-      $image_infos = pwg_db_fetch_assoc(pwg_query('SELECT path, file FROM '.IMAGES_TABLE.' WHERE id = '.$_GET['image_id'].';'));
-      $thumb_source = $conf['data_location'].$image_infos['file'];
-      
-      add_film_frame($image_infos['path'], $thumb_source);
-      add_uploaded_file($thumb_source, $image_infos['file'], null, null, $_GET['image_id']);
-      $template->assign('TN_UPDATE', true);
-    }
-    
-    $admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id'];
-    $admin_url_start = $admin_photo_base_url.'-properties';
-    $admin_url_start.= isset($_GET['cat_id']) ? '&amp;cat_id='.$_GET['cat_id'] : '';
-    
-    $template->assign('U_ADD_FILM_FRAME', $admin_url_start.'&amp;add_film_frame=1');
-    $template->set_prefilter('picture_modify', 'gvideo_photo_edit_prefilter');
-  }
-}
-
-function gvideo_photo_edit_prefilter($content)
-{
-  $search[0] = '{if !url_is_remote($PATH)}';
-  $replace[0] = '<li><a href="{$U_ADD_FILM_FRAME}" id="refresh_video">{\'Add film effect\'|@translate}</a></li>'.$search[0];
-  
-  $search[1] = '{$TN_SRC}';
-  $replace[1] = $search[1].'{if $TN_UPDATE}?'.time().'{/if}';
-  
-  return str_replace($search, $replace, $content);
-}
-
 ?>
Index: /extensions/gvideo/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/gvideo/language/en_UK/plugin.lang.php	(revision 17625)
+++ /extensions/gvideo/language/en_UK/plugin.lang.php	(revision 17626)
@@ -18,4 +18,8 @@
 $lang['This element is a video added with "Embedded Video"'] = 'This element is a video added with "Embedded Video"';
 $lang['Add film effect'] = 'Add film effect';
+$lang['Upload a new thumbnail'] = 'Upload a new thumbnail';
+$lang['The thumbnail was updated'] = 'The thumbnail was updated';
+$lang['Video successfully updated'] = 'Video successfully updated';
+$lang['Changing the url will reset video description, name and thumbnail'] = 'Changing the url will reset video description, name and thumbnail';
 
 ?>
Index: /extensions/gvideo/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/gvideo/language/fr_FR/plugin.lang.php	(revision 17625)
+++ /extensions/gvideo/language/fr_FR/plugin.lang.php	(revision 17626)
@@ -18,4 +18,8 @@
 $lang['This element is a video added with "Embedded Video"'] = 'Cet élément est une vidéo ajoutée avec "Embedded Video"';
 $lang['Add film effect'] = 'Ajouter un effet pellicule';
+$lang['Upload a new thumbnail'] = 'Uploader une nouvelle miniature';
+$lang['The thumbnail was updated'] = 'La miniature a été mise à jour';
+$lang['Video successfully updated'] = 'Vidéo mise à jour';
+$lang['Changing the url will reset video description, name and thumbnail'] = 'Changer l\'url réinitialisera le nom, la description et la miniature de la vidéo';
 
 ?>
Index: /extensions/gvideo/main.inc.php
===================================================================
--- /extensions/gvideo/main.inc.php	(revision 17625)
+++ /extensions/gvideo/main.inc.php	(revision 17626)
@@ -24,6 +24,6 @@
 {
   add_event_handler('delete_elements', 'gvideo_delete_elements');
-  add_event_handler('loc_begin_admin_page', 'gvideo_photo_edit');
   add_event_handler('get_admin_plugin_menu_links', 'gvideo_admin_menu');
+  add_event_handler('tabsheet_before_select','gvideo_tab', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2); 
   add_event_handler('init', 'gvideo_init');
   
@@ -41,4 +41,29 @@
     return $menu;
   }
+  
+  function gvideo_tab($sheets, $id)
+  {
+    if ($id != 'photo') return $sheets;
+    
+    $query = '
+SELECT *
+  FROM '.GVIDEO_TABLE.'
+  WHERE picture_id = '.$_GET['image_id'].'
+;';
+    $result = pwg_query($query);
+  
+    if (!pwg_db_num_rows($result)) return $sheets;
+    
+    global $gvideo;
+    $gvideo = pwg_db_fetch_assoc($result);
+    
+    $sheets['gvideo'] = array(
+      'caption' => l10n('Video properties'),
+      'url' => GVIDEO_ADMIN.'-photo&amp;image_id='.$_GET['image_id'],
+      );
+    unset($sheets['coi'], $sheets['update']);
+    
+    return $sheets;
+  }
 }
 
