Changeset 26470


Ignore:
Timestamp:
Jan 6, 2014, 4:41:55 PM (10 years ago)
Author:
mistic100
Message:

Update for Piwigo 2.6
TODO: button on Admin Tools bar

Location:
extensions/gvideo
Files:
1 deleted
10 edited
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/gvideo/admin.php

    r19056 r26470  
    11<?php
    2 if (!defined('GVIDEO_PATH')) die('Hacking attempt!');
     2defined('GVIDEO_PATH') or die('Hacking attempt!');
    33
    44global $template, $page, $conf;
    55
    6 if (is_string($conf['gvideo']))
    7 {
    8   $conf['gvideo'] = unserialize($conf['gvideo']);
    9 }
    10 
    116$page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : $page['tab'] = 'add';
    12 
    137
    148if ($page['tab'] != 'photo')
     
    3428 
    3529$template->assign_var_from_handle('ADMIN_CONTENT', 'gvideo_content');
    36 
    37 ?>
  • extensions/gvideo/admin/add.php

    r20804 r26470  
    11<?php
    2 if (!defined('GVIDEO_PATH')) die('Hacking attempt!');
     2defined('GVIDEO_PATH') or die('Hacking attempt!');
    33
    44include_once(GVIDEO_PATH.'include/functions.inc.php');
    55include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
     6
    67
    78if (isset($_POST['add_video']))
     
    1112  if (empty($_POST['url']))
    1213  {
    13     array_push($page['errors'], l10n('Please fill the video URL'));
     14    $page['errors'][] = l10n('Please fill the video URL');
    1415  }
    1516  else if ( ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false )
     
    1718    if (isset($_POST['safe_mode']))
    1819    {
    19       array_push($page['errors'], l10n('an error happened'));
     20      $page['errors'][] = l10n('an error happened');
    2021    }
    2122    else
    2223    {
    23       array_push($page['errors'], l10n('Unable to contact host server'));
    24       array_push($page['errors'], l10n('Try in safe-mode'));
     24      $page['errors'][] = l10n('Unable to contact host server');
     25      $page['errors'][] = l10n('Try in safe-mode');
    2526    }
    2627    $_POST['safe_mode'] = true;
    2728  }
    28  
     29
    2930  if (count($page['errors']) == 0)
    3031  {
     
    3334      $_POST['width'] = $_POST['height'] = '';
    3435    }
    35     else if ( !preg_match('#^([0-9]+)$#', $_POST['width']) or !preg_match('#^([0-9]+)$#', $_POST['height']) )
     36    else if (!preg_match('#^([0-9]+)$#', $_POST['width']) or !preg_match('#^([0-9]+)$#', $_POST['height']))
    3637    {
    37       array_push($page['errors'], l10n('Width and height must be integers'));
     38      $page['errors'][] = l10n('Width and height must be integers');
    3839      $_POST['width'] = $_POST['height'] = '';
    3940    }
     
    5556    $category = pwg_db_fetch_assoc(pwg_query($query));
    5657     
    57     array_push($page['infos'], sprintf(
    58       l10n('Video successfully added. <a href="%s">View</a>'),
     58    $page['infos'][] = l10n(
     59      'Video successfully added. <a href="%s">View</a>',
    5960      make_picture_url(array(
    6061        'image_id' => $image_id,
     
    6566          ),
    6667        ))
    67       ));
     68      );
    6869    unset($_POST);
    6970  }
     
    7273// categories
    7374$query = '
    74 SELECT id,name,uppercats,global_rank
     75SELECT id, name, uppercats, global_rank
    7576  FROM '.CATEGORIES_TABLE.'
    7677;';
     
    101102  ));
    102103
    103 $template->set_filename('gvideo_content', dirname(__FILE__) . '/template/add.tpl');
    104 
    105 ?>
     104$template->set_filename('gvideo_content', realpath(GVIDEO_PATH . 'admin/template/add.tpl'));
  • extensions/gvideo/admin/config.php

    r19056 r26470  
    11<?php
    2 if (!defined('GVIDEO_PATH')) die('Hacking attempt!');
     2defined('GVIDEO_PATH') or die('Hacking attempt!');
    33
    44if (isset($_POST['save_config']))
     
    2828 
    2929  conf_update_param('gvideo', serialize($conf['gvideo']));
    30   array_push($page['infos'], l10n('Information data registered in database'));
     30  $page['infos'][] = l10n('Information data registered in database');
    3131}
    3232
     
    3939
    4040
    41 $template->set_filename('gvideo_content', dirname(__FILE__) . '/template/config.tpl');
    42 
    43 ?>
     41$template->set_filename('gvideo_content', realpath(GVIDEO_PATH . 'admin/template/config.tpl'));
  • extensions/gvideo/admin/photo.php

    r20804 r26470  
    11<?php
    2 // +-----------------------------------------------------------------------+
    3 // | Piwigo - a PHP based photo gallery                                    |
    4 // +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
    6 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    7 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
    8 // +-----------------------------------------------------------------------+
    9 // | This program is free software; you can redistribute it and/or modify  |
    10 // | it under the terms of the GNU General Public License as published by  |
    11 // | the Free Software Foundation                                          |
    12 // |                                                                       |
    13 // | This program is distributed in the hope that it will be useful, but   |
    14 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    16 // | 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, |
    21 // | USA.                                                                  |
    22 // +-----------------------------------------------------------------------+
    23 
    24 if(!defined("PHPWG_ROOT_PATH")) die ("Hacking attempt!");
     2defined('GVIDEO_PATH') or die ("Hacking attempt!");
    253
    264include_once(GVIDEO_PATH.'include/functions.inc.php');
     5include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
    276
    287
     
    309// | Basic checks                                                          |
    3110// +-----------------------------------------------------------------------+
    32 
    3311check_status(ACCESS_ADMINISTRATOR);
    3412
     
    4725$tabsheet->assign();
    4826
     27$page['active_menu'] = get_active_menu('photo');
     28
    4929// +-----------------------------------------------------------------------+
    5030// | Picture infos                                                         |
    5131// +-----------------------------------------------------------------------+
    52 global $gvideo;
     32global $gvideo; // request from GVIDEO_TABLE done when building tabsheet
    5333
    5434$query = '
     
    6848  if (empty($_POST['url']))
    6949  {
    70     array_push($page['errors'], l10n('Please fill the video URL'));
     50    $page['errors'][] = l10n('Please fill the video URL');
    7151  }
    7252  else if ($gvideo['url']!=$_POST['url'])
    7353  {
    74     if( ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false )
     54    if ( ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false )
    7555    {
    7656      if (isset($_POST['safe_mode']))
    7757      {
    78         array_push($page['errors'], l10n('an error happened'));
     58        $page['errors'][] = l10n('an error happened');
    7959      }
    8060      else
    8161      {
    82         array_push($page['errors'], l10n('Unable to contact host server'));
    83         array_push($page['errors'], l10n('Try in safe-mode'));
     62        $page['errors'][] = l10n('Unable to contact host server');
     63        $page['errors'][] = l10n('Try in safe-mode');
    8464      }
    8565    }
     
    9272  if (count($page['errors']) == 0)
    9373  {
    94     include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
    9574
    9675    if ( $gvideo['url'] != $video['url'] )
     
    10079      $thumb_name = $video['type'].'-'.$video['video_id'].'-'.uniqid().'.'.$thumb_ext;
    10180      $thumb_source = $conf['data_location'].$thumb_name;
    102       if ( empty($video['thumbnail']) or gvideo_download_remote_file($video['thumbnail'], $thumb_source) !== true )
     81     
     82      if (empty($video['thumbnail']) or gvideo_download_remote_file($video['thumbnail'], $thumb_source) !== true)
    10383      {
    10484        $thumb_source = $conf['data_location'].get_filename_wo_extension($thumb_name).'.jpg';
     
    11595        );
    11696       
    117       if ( $_POST['sync_description'] and !empty($video['description']) )
     97      if ($_POST['sync_description'] and !empty($video['description']))
    11898      {
    11999        $updates['comment'] = pwg_db_real_escape_string($video['description']);
     
    123103        $updates['comment'] = null;
    124104      }
    125       if ( $_POST['sync_tags'] and !empty($video['tags']) )
     105      if ($_POST['sync_tags'] and !empty($video['tags']))
    126106      {
    127107        set_tags(get_tag_ids(implode(',', $video['tags'])), $image_id);
     
    141121      $_POST['width'] = $_POST['height'] = '';
    142122    }
    143     else if ( !preg_match('#^([0-9]+)$#', $_POST['width']) or !preg_match('#^([0-9]+)$#', $_POST['height']) )
    144     {
    145       array_push($page['errors'], l10n('Width and height must be integers'));
     123    else if (!preg_match('#^([0-9]+)$#', $_POST['width']) or !preg_match('#^([0-9]+)$#', $_POST['height']))
     124    {
     125      $page['errors'][] = l10n('Width and height must be integers');
    146126      $_POST['width'] = $_POST['height'] = '';
    147127    }
     
    167147      );
    168148     
    169     array_push($page['infos'], l10n('Video successfully updated'));
     149    $page['infos'][] = l10n('Video successfully updated');
    170150    $gvideo = array_merge($gvideo, $updates);
    171151  }
     
    177157if (isset($_FILES['photo_update']))
    178158{
    179   include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
    180  
    181159  if ($_FILES['photo_update']['error'] !== UPLOAD_ERR_OK)
    182160  {
    183     array_push($page['errors'],
    184       file_upload_error_message($_FILES['photo_update']['error'])
    185       );
     161    $page['errors'][] = file_upload_error_message($_FILES['photo_update']['error']);
    186162  }
    187163  else
     
    195171      );
    196172
    197     array_push($page['infos'], l10n('The thumbnail was updated'));
     173    $page['infos'][] = l10n('The thumbnail was updated');
    198174  }
    199175}
     
    202178// | Add film frame                                                        |
    203179// +-----------------------------------------------------------------------+
    204 if ( function_exists('imagecreatetruecolor') and isset($_GET['add_film_frame']) )
    205 {
    206   include_once(GVIDEO_PATH . '/include/functions.inc.php');
    207   include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
    208  
     180if (function_exists('imagecreatetruecolor') and isset($_GET['add_film_frame']))
     181{
    209182  $thumb_source = $conf['data_location'].$picture['file'];
    210183 
     
    242215));
    243216
    244 $template->set_filename('gvideo_content', dirname(__FILE__).'/template/photo.tpl');
    245 
    246 ?>
     217$template->set_filename('gvideo_content', realpath(GVIDEO_PATH . 'admin/template/photo.tpl'));
  • extensions/gvideo/admin/template/add.tpl

    r20809 r26470  
    1 {combine_css path=$GVIDEO_PATH|@cat:"admin/template/style.css"}
     1{combine_css path=$GVIDEO_PATH|cat:'admin/template/style.css'}
    22{include file='include/colorbox.inc.tpl'}
    33{include file='include/add_album.inc.tpl'}
    44
    5 {footer_script}{literal}
     5{footer_script}
    66jQuery("input[data-toggle]").change(function() {
    77  $('#'+ $(this).data('toggle')).toggle();
     
    1717  $(".providersInfo").toggle();
    1818});
    19 {/literal}{/footer_script}
     19{/footer_script}
     20
    2021
    2122<div class="titrePage">
     
    2526<form method="post" action="" class="properties">
    2627<fieldset>
    27   <legend>{'Properties'|@translate}</legend>
     28  <legend>{'Properties'|translate}</legend>
    2829 
    2930  <ul>
    3031    <li>
    3132      <label>
    32         <span class="property">{'Album'|@translate}</span>
     33        <span class="property">{'Album'|translate}</span>
    3334        <select style="width:400px" name="category" id="albumSelect" size="1">
    3435          {html_options options=$category_parent_options selected=$POST.category}
    3536        </select>
    3637      </label>
    37       {'... or '|@translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
     38      {'... or '|translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|translate}">{'create a new album'|translate}</a>
    3839    </li>
    3940    <li>
    4041      <label>
    41         <span class="property">{'Video URL'|@translate}</span>
     42        <span class="property">{'Video URL'|translate}</span>
    4243        <input type="text" name="url" value="{$POST.url}" style="width:400px;">
    4344      </label>
     
    4546  {if $gd_available}
    4647    <li>
    47       <span class="property">{'Thumbnail'|@translate}</span>
    48       <label><input type="checkbox" name="add_film_frame" value="true" {if $POST.add_film_frame}checked="checked"{/if}> {'Add film effect'|@translate} </label>
    49       <a class="showInfo" title="<img src='{$GVIDEO_PATH}admin/template/example-frame.jpg'>">i</a>
     48      <span class="property">{'Thumbnail'|translate}</span>
     49      <label><input type="checkbox" name="add_film_frame" value="true" {if $POST.add_film_frame}checked="checked"{/if}> {'Add film effect'|translate} </label>
     50      <a class="icon-info-circled-1 showInfo" title="<img src='{$GVIDEO_PATH}admin/template/example-frame.jpg'>"></a>
    5051    </li>
    5152  {/if}
     
    5455
    5556<fieldset>
    56   <legend>{'Configuration'|@translate}</legend>
     57  <legend>{'Configuration'|translate}</legend>
    5758 
    5859  <ul>
    5960    <li>
    60       <span class="property">{'Video size'|@translate}</span>
    61       <label><input type="radio" name="size_common" value="true" {if $POST.size_common != 'false'}checked="checked"{/if} data-toggle="size"> {'Use common setting'|@translate}</label>
    62       <label><input type="radio" name="size_common" value="false" {if $POST.size_common == 'false'}checked="checked"{/if} data-toggle="size"> {'Change'|@translate}</label>
     61      <span class="property">{'Video size'|translate}</span>
     62      <label><input type="radio" name="size_common" value="true" {if $POST.size_common != 'false'}checked="checked"{/if} data-toggle="size"> {'Use common setting'|translate}</label>
     63      <label><input type="radio" name="size_common" value="false" {if $POST.size_common == 'false'}checked="checked"{/if} data-toggle="size"> {'Change'|translate}</label>
    6364    </li>
    6465    <li {if $POST.size_common != 'false'}style="display:none;"{/if} id="size">
     
    6869    </li>
    6970    <li>
    70       <span class="property">{'Autoplay'|@translate}</span>
    71       <label><input type="radio" name="autoplay_common" value="true" {if $POST.autoplay_common != 'false'}checked="checked"{/if} data-toggle="autoplay"> {'Use common setting'|@translate}</label>
    72       <label><input type="radio" name="autoplay_common" value="false" {if $POST.autoplay_common == 'false'}checked="checked"{/if} data-toggle="autoplay"> {'Change'|@translate}</label>
     71      <span class="property">{'Autoplay'|translate}</span>
     72      <label><input type="radio" name="autoplay_common" value="true" {if $POST.autoplay_common != 'false'}checked="checked"{/if} data-toggle="autoplay"> {'Use common setting'|translate}</label>
     73      <label><input type="radio" name="autoplay_common" value="false" {if $POST.autoplay_common == 'false'}checked="checked"{/if} data-toggle="autoplay"> {'Change'|translate}</label>
    7374    </li>
    7475    <li {if $POST.autoplay_common != 'false'}style="display:none;"{/if} id="autoplay">
    7576      <span class="property">&nbsp;</span>
    76       <label><input type="radio" name="autoplay" value="0" {if $POST.autoplay == '0'}checked="checked"{/if}> {'No'|@translate}</label>
    77       <label><input type="radio" name="autoplay" value="1" {if $POST.autoplay == '1'}checked="checked"{/if}> {'Yes'|@translate}</label>
     77      <label><input type="radio" name="autoplay" value="0" {if $POST.autoplay == '0'}checked="checked"{/if}> {'No'|translate}</label>
     78      <label><input type="radio" name="autoplay" value="1" {if $POST.autoplay == '1'}checked="checked"{/if}> {'Yes'|translate}</label>
    7879    </li>
    7980    <li>
    80       <span class="property">{'Get video description'|@translate}</span>
    81       <label><input type="radio" name="sync_description" value="1" {if $gvideo.sync_description}checked="checked"{/if}> {'Yes'|@translate}</label>
    82       <label><input type="radio" name="sync_description" value="0" {if not $gvideo.sync_description}checked="checked"{/if}> {'No'|@translate}</label>
     81      <span class="property">{'Get video description'|translate}</span>
     82      <label><input type="radio" name="sync_description" value="1" {if $gvideo.sync_description}checked="checked"{/if}> {'Yes'|translate}</label>
     83      <label><input type="radio" name="sync_description" value="0" {if not $gvideo.sync_description}checked="checked"{/if}> {'No'|translate}</label>
    8384    </li>
    8485    <li>
    85       <span class="property">{'Get video tags'|@translate}</span>
    86       <label><input type="radio" name="sync_tags" value="1" {if $gvideo.sync_tags}checked="checked"{/if}> {'Yes'|@translate}</label>
    87       <label><input type="radio" name="sync_tags" value="0" {if not $gvideo.sync_tags}checked="checked"{/if}> {'No'|@translate}</label>
     86      <span class="property">{'Get video tags'|translate}</span>
     87      <label><input type="radio" name="sync_tags" value="1" {if $gvideo.sync_tags}checked="checked"{/if}> {'Yes'|translate}</label>
     88      <label><input type="radio" name="sync_tags" value="0" {if not $gvideo.sync_tags}checked="checked"{/if}> {'No'|translate}</label>
    8889    </li>
    8990  </ul> 
     
    9293
    9394<p style="text-align:left;">
    94   <input type="submit" name="add_video" value="{'Add'|@translate}">
    95   <label style="font-weight:bold;"><input type="checkbox" name="safe_mode" {if $POST.safe_mode}checked="checked"{/if}> {'Safe-mode'|@translate}</label>
    96   <a class="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}">i</a>
     95  <input type="submit" name="add_video" value="{'Add'|translate}">
     96  <label style="font-weight:bold;"><input type="checkbox" name="safe_mode" {if $POST.safe_mode}checked="checked"{/if}> {'Safe-mode'|translate}</label>
     97  <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>
    9798</p>
    9899
    99100<fieldset style="margin-top:40px;">
    100   <legend>{'Supported services'|@translate}</legend>
     101  <legend>{'Supported services'|translate}</legend>
    101102 
    102103  <ul class="services">
     
    104105      <img class="icon" src="{$GVIDEO_PATH}admin/template/icons/youtube.png">
    105106      <a href="http://www.youtube.com" target="_blank">YouTube</a>
    106       <span class="providersInfo">{'Videos can be unlisted but not private.'|@translate}<br></span>
     107      <span class="providersInfo">{'Videos can be unlisted but not private.'|translate}<br></span>
    107108    </li>
    108109    <li>
    109110      <img class="icon" src="{$GVIDEO_PATH}admin/template/icons/vimeo.png">
    110111      <a href="http://www.vimeo.com" target="_blank">Vimeo</a>
    111       <span class="providersInfo">{'Videos can be unlisted and private if the gallery website is within the authorized domains (PRO).'|@translate}<br></span>
     112      <span class="providersInfo">{'Videos can be unlisted and private if the gallery website is within the authorized domains (PRO).'|translate}<br></span>
    112113    </li>
    113114    <li>
    114115      <img class="icon" src="{$GVIDEO_PATH}admin/template/icons/dailymotion.png">
    115116      <a href="http://www.dailymotion.com" target="_blank">Dailymotion</a>
    116       <span class="providersInfo">{'Videos can be private if you use the private permalink.'|@translate}<br></span>
     117      <span class="providersInfo">{'Videos can be private if you use the private permalink.'|translate}<br></span>
    117118    </li>
    118119    <li>
    119120      <img class="icon" src="{$GVIDEO_PATH}admin/template/icons/wat.png">
    120121      <a href="http://www.wat.tv" target="_blank">Wat</a>
    121       <span class="providersInfo" style="font-style:italic;">{'No privacy option.'|@translate}<br></span>
     122      <span class="providersInfo" style="font-style:italic;">{'No privacy option.'|translate}<br></span>
    122123    </li>
    123124    <li>
    124125      <img class="icon" src="{$GVIDEO_PATH}admin/template/icons/wideo.png">
    125126      <a href="http://www.wideo.fr" target="_blank">Wideo</a>
    126       <span class="providersInfo" style="font-style:italic;">{'No privacy option.'|@translate}<br></span>
     127      <span class="providersInfo" style="font-style:italic;">{'No privacy option.'|translate}<br></span>
    127128    </li>
    128129    <li>
    129       <a class="showProvidersInfo">{'Show privacy details'|@translate}</a>
     130      <a class="showProvidersInfo">{'Show privacy details'|translate}</a>
    130131    </li>
    131132  </ul>
  • extensions/gvideo/admin/template/config.tpl

    r19056 r26470  
    1 {combine_css path=$GVIDEO_PATH|@cat:"admin/template/style.css"}
     1{combine_css path=$GVIDEO_PATH|cat:'admin/template/style.css'}
    22
    3 {footer_script}{literal}
     3{footer_script}
    44jQuery('label.color input').change(function() {
    55  $('label.color').removeClass('active');
    66  $('label.color input:checked').parent('label').addClass('active');
    77});
    8 {/literal}{/footer_script}
     8{/footer_script}
     9
    910
    1011<div class="titrePage">
     
    1415<form method="post" action="" class="properties">
    1516<fieldset>
    16   <legend>{'Common configuration'|@translate}</legend>
     17  <legend>{'Common configuration'|translate}</legend>
    1718 
    1819  <ul>
    1920    <li>
    20       <span class="property">{'Video size'|@translate}</span>
     21      <span class="property">{'Video size'|translate}</span>
    2122      <input type="text" name="width" value="{$gvideo.width}" size="4"> &times;
    2223      <input type="text" name="height" value="{$gvideo.height}" size="4"> px
    2324    </li>
    2425    <li>
    25       <span class="property">{'Autoplay'|@translate}</span>
    26       <label><input type="radio" name="autoplay" value="1" {if $gvideo.autoplay}checked="checked"{/if}> {'Yes'|@translate}</label>
    27       <label><input type="radio" name="autoplay" value="0" {if not $gvideo.autoplay}checked="checked"{/if}> {'No'|@translate}</label>
     26      <span class="property">{'Autoplay'|translate}</span>
     27      <label><input type="radio" name="autoplay" value="1" {if $gvideo.autoplay}checked="checked"{/if}> {'Yes'|translate}</label>
     28      <label><input type="radio" name="autoplay" value="0" {if not $gvideo.autoplay}checked="checked"{/if}> {'No'|translate}</label>
    2829    </li>
    2930    <li>
    30       <span class="property">{'Get video description'|@translate}</span>
    31       <label><input type="radio" name="sync_description" value="1" {if $gvideo.sync_description}checked="checked"{/if}> {'Yes'|@translate}</label>
    32       <label><input type="radio" name="sync_description" value="0" {if not $gvideo.sync_description}checked="checked"{/if}> {'No'|@translate}</label>
     31      <span class="property">{'Get video description'|translate}</span>
     32      <label><input type="radio" name="sync_description" value="1" {if $gvideo.sync_description}checked="checked"{/if}> {'Yes'|translate}</label>
     33      <label><input type="radio" name="sync_description" value="0" {if not $gvideo.sync_description}checked="checked"{/if}> {'No'|translate}</label>
    3334    </li>
    3435    <li>
    35       <span class="property">{'Get video tags'|@translate}</span>
    36       <label><input type="radio" name="sync_tags" value="1" {if $gvideo.sync_tags}checked="checked"{/if}> {'Yes'|@translate}</label>
    37       <label><input type="radio" name="sync_tags" value="0" {if not $gvideo.sync_tags}checked="checked"{/if}> {'No'|@translate}</label>
     36      <span class="property">{'Get video tags'|translate}</span>
     37      <label><input type="radio" name="sync_tags" value="1" {if $gvideo.sync_tags}checked="checked"{/if}> {'Yes'|translate}</label>
     38      <label><input type="radio" name="sync_tags" value="0" {if not $gvideo.sync_tags}checked="checked"{/if}> {'No'|translate}</label>
    3839    </li>
    3940  </ul>
     
    4142
    4243<div class="left"><fieldset>
    43   <legend><img class="icon" src="{$GVIDEO_PATH}admin/template/icons/vimeo.png"> {'Vimeo player'|@translate}</legend>
     44  <legend><img class="icon" src="{$GVIDEO_PATH}admin/template/icons/vimeo.png"> {'Vimeo player'|translate}</legend>
    4445 
    4546  <ul>
    4647    <li>
    47       <span class="property">{'Color'|@translate}</span>
     48      <span class="property">{'Color'|translate}</span>
    4849    {foreach from=$vimeo_colors item=color}
    4950      <label class="color {$themeconf.name} {if $gvideo.vimeo.color == $color}active{/if}" style="background:#{$color};"><input type="radio" name="vimeo[color]" value="{$color}" {if $gvideo.vimeo.color == $color}checked="checked"{/if}></label>
     
    5152    </li>
    5253    <li>
    53       <span class="property">{'Display'|@translate}</span>
    54       <label><input type="checkbox" name="vimeo[title]" value="1" {if $gvideo.vimeo.title}checked="checked"{/if}> {'Title'|@translate}</label>
    55       <label><input type="checkbox" name="vimeo[portrait]" value="1" {if $gvideo.vimeo.portrait}checked="checked"{/if}> {'Author portrait'|@translate}</label>
    56       <label><input type="checkbox" name="vimeo[byline]" value="1" {if $gvideo.vimeo.byline}checked="checked"{/if}> {'Author name'|@translate}</label>
     54      <span class="property">{'Display'|translate}</span>
     55      <label><input type="checkbox" name="vimeo[title]" value="1" {if $gvideo.vimeo.title}checked="checked"{/if}> {'Title'|translate}</label>
     56      <label><input type="checkbox" name="vimeo[portrait]" value="1" {if $gvideo.vimeo.portrait}checked="checked"{/if}> {'Author portrait'|translate}</label>
     57      <label><input type="checkbox" name="vimeo[byline]" value="1" {if $gvideo.vimeo.byline}checked="checked"{/if}> {'Author name'|translate}</label>
    5758    </li>
    5859  </ul>
     
    6061
    6162<div class="right"><fieldset>
    62   <legend><img class="icon" src="{$GVIDEO_PATH}admin/template/icons/dailymotion.png"> {'Dailymotion player'|@translate}</legend>
     63  <legend><img class="icon" src="{$GVIDEO_PATH}admin/template/icons/dailymotion.png"> {'Dailymotion player'|translate}</legend>
    6364 
    6465  <ul>
    6566    <li>
    66       <span class="property">{'Color'|@translate}</span>
     67      <span class="property">{'Color'|translate}</span>
    6768    {foreach from=$dailymotion_colors item=color}
    6869      <label class="color {$themeconf.name} {if $gvideo.dailymotion.color == $color}active{/if}" style="background:#{$color};"><input type="radio" name="dailymotion[color]" value="{$color}" {if $gvideo.dailymotion.color == $color}checked="checked"{/if}></label>
     
    7071    </li>
    7172    <li>
    72       <span class="property">{'Display'|@translate}</span>
    73       <label><input type="checkbox" name="dailymotion[logo]" value="1" {if $gvideo.dailymotion.logo}checked="checked"{/if}> {'Logo'|@translate}</label>
    74       <label><input type="checkbox" name="dailymotion[title]" value="1" {if $gvideo.dailymotion.title}checked="checked"{/if}> {'Title'|@translate}</label>
     73      <span class="property">{'Display'|translate}</span>
     74      <label><input type="checkbox" name="dailymotion[logo]" value="1" {if $gvideo.dailymotion.logo}checked="checked"{/if}> {'Logo'|translate}</label>
     75      <label><input type="checkbox" name="dailymotion[title]" value="1" {if $gvideo.dailymotion.title}checked="checked"{/if}> {'Title'|translate}</label>
    7576    </li>
    7677  </ul>
     
    7980<div style="clear:right;"></div>
    8081
    81 <p style="text-align:left;"><input type="submit" name="save_config" value="{'Save Settings'|@translate}"></p>
     82<p style="text-align:left;"><input type="submit" name="save_config" value="{'Save Settings'|translate}"></p>
    8283
    8384</form>
  • extensions/gvideo/admin/template/photo.tpl

    r19213 r26470  
    1 {combine_css path=$GVIDEO_PATH|@cat:"admin/template/style.css"}
     1{combine_css path=$GVIDEO_PATH|cat:'admin/template/style.css'}
    22
    3 {footer_script}{literal}
     3{footer_script}
    44jQuery("input[data-toggle]").change(function() {
    55  $block = $('#'+ $(this).data('toggle'));
     
    1010  }
    1111});
    12 {/literal}
    1312
    1413var border = jQuery("input[name='url']").css('border');
    1514
    16 jQuery("input[name='url']").keyup(function() {ldelim}
    17   if ($(this).val() != "{$GVIDEO.url}") {ldelim}
     15jQuery("input[name='url']").keyup(function() {
     16  if ($(this).val() != "{$GVIDEO.url}") {
    1817    $(this).css('border', '1px solid #c00');
    1918    $(".video_update").show();
    20   } else {ldelim}
     19  }
     20  else {
    2121    $(this).css('border', border);
    2222    $(".video_update").hide();
     
    2525{/footer_script}
    2626
    27 <h2>{$TITLE} &#8250; {'Edit photo'|@translate} {$TABSHEET_TITLE}</h2>
     27
     28<h2>{$TITLE} &#8250; {'Edit photo'|translate} {$TABSHEET_TITLE}</h2>
    2829
    2930<fieldset>
    30   <legend>{'Thumbnail'|@translate}</legend>
     31  <legend>{'Thumbnail'|translate}</legend>
    3132  <table>
    3233    <tr>
    3334      <td id="albumThumbnail">
    34         <img src="{$TN_SRC}" alt="{'Thumbnail'|@translate}" class="Thumbnail">
     35        <img src="{$TN_SRC}" alt="{'Thumbnail'|translate}" class="Thumbnail">
    3536      </td>
    3637      <td id="albumLinks" style="width:400px;vertical-align:top;">
    3738        <ul style="padding-left:15px;margin:0;">
    3839        {if $U_ADD_FILM_FRAME}
    39           <li style="margin:10px 0 20px 0;"><a href="{$U_ADD_FILM_FRAME}">{'Add film effect'|@translate}</a></li>
     40          <li style="margin:10px 0 20px 0;"><a href="{$U_ADD_FILM_FRAME}">{'Add film effect'|translate}</a></li>
    4041        {/if}
    4142       
    4243          <li>
    4344            <form id="photo_update" method="post" action="{$F_ACTION}" enctype="multipart/form-data">
    44               {'Upload a new thumbnail'|@translate}<br>
     45              {'Upload a new thumbnail'|translate}<br>
    4546              <input type="file" size="20" name="photo_update">
    46               <input class="submit" type="submit" value="{'Send'|@translate}" name="photo_update">
     47              <input class="submit" type="submit" value="{'Send'|translate}" name="photo_update">
    4748            </form>
    4849          </li>
     
    5556<form action="{$F_ACTION}" method="post" id="catModify">
    5657  <fieldset>
    57     <legend>{'Properties'|@translate}</legend>
     58    <legend>{'Properties'|translate}</legend>
    5859
    5960    <p>
    60       <b>{'Video URL'|@translate}</b>
     61      <b>{'Video URL'|translate}</b>
    6162      <input type="text" name="url" value="{$GVIDEO.url}" style="width:400px;">
    62       <span class="video_update warning" style="display:none;"> {'Changing the url will reset video description, name and thumbnail'|@translate}</span>
     63      <span class="video_update warning" style="display:none;"> {'Changing the url will reset video description, name and thumbnail'|translate}</span>
    6364    </p>
    6465   
    6566    <p class="video_update">
    66       <b>{'Get video description'|@translate}</b>
    67       <label><input type="radio" name="sync_description" value="1" {if $GVIDEO.sync_description}checked="checked"{/if}> {'Yes'|@translate}</label>
    68       <label><input type="radio" name="sync_description" value="0" {if not $GVIDEO.sync_description}checked="checked"{/if}> {'No'|@translate}</label>
     67      <b>{'Get video description'|translate}</b>
     68      <label><input type="radio" name="sync_description" value="1" {if $GVIDEO.sync_description}checked="checked"{/if}> {'Yes'|translate}</label>
     69      <label><input type="radio" name="sync_description" value="0" {if not $GVIDEO.sync_description}checked="checked"{/if}> {'No'|translate}</label>
    6970    </p>
    7071   
    7172    <p class="video_update">
    72       <b>{'Get video tags'|@translate}</b>
    73       <label><input type="radio" name="sync_tags" value="1" {if $GVIDEO.sync_tags}checked="checked"{/if}> {'Yes'|@translate}</label>
    74       <label><input type="radio" name="sync_tags" value="0" {if not $GVIDEO.sync_tags}checked="checked"{/if}> {'No'|@translate}</label>
     73      <b>{'Get video tags'|translate}</b>
     74      <label><input type="radio" name="sync_tags" value="1" {if $GVIDEO.sync_tags}checked="checked"{/if}> {'Yes'|translate}</label>
     75      <label><input type="radio" name="sync_tags" value="0" {if not $GVIDEO.sync_tags}checked="checked"{/if}> {'No'|translate}</label>
    7576    </p>
    7677   
    7778    <p>
    78       <b>{'Video size'|@translate}</b>
    79       <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>
    80       <label><input type="radio" name="size_common" value="false" {if $GVIDEO.size_common != 'true'}checked="checked"{/if} data-toggle="size"> {'Change'|@translate}</label>
     79      <b>{'Video size'|translate}</b>
     80      <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>
     81      <label><input type="radio" name="size_common" value="false" {if $GVIDEO.size_common != 'true'}checked="checked"{/if} data-toggle="size"> {'Change'|translate}</label>
    8182     
    8283      <span style="display:{if $GVIDEO.size_common == 'true'}none{else}block{/if};" id="size">
     
    8788   
    8889    <p>
    89       <b>{'Autoplay'|@translate}</b>
    90       <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>
    91       <label><input type="radio" name="autoplay_common" value="false" {if $GVIDEO.autoplay_common != 'true'}checked="checked"{/if} data-toggle="autoplay"> {'Change'|@translate}</label>
     90      <b>{'Autoplay'|translate}</b>
     91      <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>
     92      <label><input type="radio" name="autoplay_common" value="false" {if $GVIDEO.autoplay_common != 'true'}checked="checked"{/if} data-toggle="autoplay"> {'Change'|translate}</label>
    9293     
    9394      <span style="display:{if $GVIDEO.autoplay_common == 'true'}none{else}block{/if};" id="autoplay">
    94         <label><input type="radio" name="autoplay" value="0" {if $GVIDEO.autoplay == '0'}checked="checked"{/if}> {'No'|@translate}</label>
    95         <label><input type="radio" name="autoplay" value="1" {if $GVIDEO.autoplay == '1'}checked="checked"{/if}> {'Yes'|@translate}</label>
     95        <label><input type="radio" name="autoplay" value="0" {if $GVIDEO.autoplay == '0'}checked="checked"{/if}> {'No'|translate}</label>
     96        <label><input type="radio" name="autoplay" value="1" {if $GVIDEO.autoplay == '1'}checked="checked"{/if}> {'Yes'|translate}</label>
    9697      </span>
    9798    </p>
    9899
    99100    <p style="margin:0;">
    100       <label style="font-weight:bold;"><input type="checkbox" name="safe_mode"> {'Safe-mode'|@translate}</label>
     101      <label style="font-weight:bold;"><input type="checkbox" name="safe_mode"> {'Safe-mode'|translate}</label>
    101102      <br>
    102       <input class="submit" type="submit" value="{'Save Settings'|@translate}" name="save_properties">
     103      <input class="submit" type="submit" value="{'Save Settings'|translate}" name="save_properties">
    103104    </p>
    104105  </fieldset>
  • extensions/gvideo/admin/template/style.css

    r20809 r26470  
    4242    visibility:hidden;
    4343  }
    44  
    45 .showInfo {
    46   position:static;
    47   display:inline-block;
    48   padding:1px 7px;
    49   width:4px;
    50   height:16px;
    51   line-height:16px;
    52   font-size:0.8em;
    53 }
    5444
    5545ul.services li {
  • extensions/gvideo/include/events.inc.php

    r24342 r26470  
    11<?php
    2 if (!defined('GVIDEO_PATH')) die('Hacking attempt!');
     2defined('GVIDEO_PATH') or die('Hacking attempt!');
    33
    44/**
     
    1111    // remove default parser
    1212    remove_event_handler('render_element_content', 'default_picture_content', EVENT_HANDLER_PRIORITY_NEUTRAL);
    13  
    14     // remove autosize
    15     global $pwg_loaded_plugins, $autosize_ctrl;
    1613   
    17     if ( isset($pwg_loaded_plugins['Autosize']) and isset($autosize_ctrl) )
    18     {
    19       remove_event_handler('render_element_content', array(&$autosize_ctrl, 'autosize_calcContent'), EVENT_HANDLER_PRIORITY_NEUTRAL-11, 2);
    20       remove_event_handler('render_element_content', array(&$autosize_ctrl, 'init_1'), EVENT_HANDLER_PRIORITY_NEUTRAL-9, 2);
    21       remove_event_handler('render_element_content', array(&$autosize_ctrl, 'init'), EVENT_HANDLER_PRIORITY_NEUTRAL-1, 2);
    22       remove_event_handler('render_element_content', array(&$autosize_ctrl, 'init2'), EVENT_HANDLER_PRIORITY_NEUTRAL+1, 2);
    23       remove_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_script_1'));
    24       remove_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_script_2'));
    25       remove_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_script_3'));
    26       remove_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_affiche'), EVENT_HANDLER_PRIORITY_NEUTRAL+21);
    27     }
     14    // add custom parser
     15    add_event_handler('render_element_content', 'gvideo_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
    2816  }
    2917 
     
    4230 
    4331  global $page, $picture, $template, $conf;
    44  
    45   if (is_string($conf['gvideo']))
    46   {
    47     $conf['gvideo'] = unserialize($conf['gvideo']);
    48   }
    4932 
    5033  // remove some actions
     
    8972 
    9073  global $user;
     74  // hide stripped overlay preventing to click on video object
    9175  if (strpos('stripped', $user['theme']) !== false)
    9276  {
    93     $template->append('head_elements', '<style type="text/css">.hideTabs{display:none !important;}</style>');
     77    $template->block_html_style(null, '.hideTabs{ display:none !important; }');
    9478  }
    9579
     
    10993  pwg_query($query);
    11094}
    111 
    112 ?>
  • extensions/gvideo/main.inc.php

    r20804 r26470  
    44Version: auto
    55Description: Add videos from Dailymotion, Youtube, Vimeo, Wideo and Wat.
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=136
    7 Author: Mistic & P@t
     6Plugin URI: auto
     7Author: Mistic
    88Author URI: http://www.strangeplanet.fr
    99*/
    1010
    11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    1212
    1313global $prefixeTable;
    1414
    15 defined('GVIDEO_ID') or define('GVIDEO_ID', basename(dirname(__FILE__)));
     15define('GVIDEO_ID',      basename(dirname(__FILE__)));
    1616define('GVIDEO_PATH',    PHPWG_PLUGINS_PATH . GVIDEO_ID . '/');
    1717define('GVIDEO_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . GVIDEO_ID);
     
    2222add_event_handler('init', 'gvideo_init');
    2323add_event_handler('picture_pictures_data', 'gvideo_prepare_picture');
    24 add_event_handler('render_element_content', 'gvideo_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
    2524
    2625if (defined('IN_ADMIN'))
    2726{
    28   add_event_handler('delete_elements', 'gvideo_delete_elements');
    2927  add_event_handler('get_admin_plugin_menu_links', 'gvideo_admin_menu');
    3028  add_event_handler('tabsheet_before_select','gvideo_tab', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2);
    3129}
    3230
    33 include_once(GVIDEO_PATH . 'include/gvideo.inc.php');
     31add_event_handler('delete_elements', 'gvideo_delete_elements');
     32
     33include_once(GVIDEO_PATH . 'include/events.inc.php');
    3434
    3535
    3636/**
    37  * update & load language
     37 * init
    3838 */
    3939function gvideo_init()
    4040{
    41   global $pwg_loaded_plugins;
     41  global $conf;
    4242 
    43   if (
    44     GVIDEO_VERSION == 'auto' or
    45     $pwg_loaded_plugins[GVIDEO_ID]['version'] == 'auto' or
    46     version_compare($pwg_loaded_plugins[GVIDEO_ID]['version'], GVIDEO_VERSION, '<')
    47   )
    48   {
    49     include_once(GVIDEO_PATH . 'include/install.inc.php');
    50     gvideo_install();
    51    
    52     if ( $pwg_loaded_plugins[GVIDEO_ID]['version'] != 'auto' and GVIDEO_VERSION !='auto' )
    53     {
    54       $query = '
    55 UPDATE '. PLUGINS_TABLE .'
    56 SET version = "'. GVIDEO_VERSION .'"
    57 WHERE id = "'. GVIDEO_ID .'"';
    58       pwg_query($query);
    59      
    60       $pwg_loaded_plugins[GVIDEO_ID]['version'] = GVIDEO_VERSION;
    61      
    62       if (defined('IN_ADMIN'))
    63       {
    64         $_SESSION['page_infos'][] = 'Embedded Videos updated to version '. GVIDEO_VERSION;
    65       }
    66     }
    67   }
     43  include_once(GVIDEO_PATH . 'maintain.inc.php');
     44  $maintain = new gvideo_maintain(GVIDEO_ID);
     45  $maintain->autoUpdate(GVIDEO_VERSION, 'install');
    6846 
    6947  load_language('plugin.lang', GVIDEO_PATH);
     48 
     49  $conf['gvideo'] = unserialize($conf['gvideo']);
    7050}
    7151
     
    7555function gvideo_admin_menu($menu)
    7656{
    77   array_push($menu, array(
     57  $menu[] = array(
    7858    'NAME' => 'Embedded Videos',
    7959    'URL' => GVIDEO_ADMIN,
    80   ));
     60    );
    8161  return $menu;
    8262}
     
    10989  return $sheets;
    11090}
    111 
    112 ?>
  • extensions/gvideo/maintain.inc.php

    r20804 r26470  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    3 
    4 defined('GVIDEO_ID') or define('GVIDEO_ID', basename(dirname(__FILE__)));
    5 include_once(PHPWG_PLUGINS_PATH . GVIDEO_ID . '/include/install.inc.php');
    6 
    7 
    8 /* install */
    9 function plugin_install()
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
     3
     4class gvideo_maintain extends PluginMaintain
    105{
    11   gvideo_install();
     6  private $installed = false;
    127 
    13   define('gvideo_installed', true);
     8  private $default_conf = array(
     9    'autoplay' => 0,
     10    'width' => 640,
     11    'height' => 360,
     12    'sync_description' => 1,
     13    'sync_tags' => 1,
     14    'vimeo' => array(
     15      'title' => 1,
     16      'portrait' => 1,
     17      'byline' => 1,
     18      'color' => '00adef',
     19      ),
     20    'dailymotion' => array(
     21      'logo' => 1,
     22      'title' => 1,
     23      'color' => 'F7FFFD',
     24      ),
     25    'youtube' => array(),
     26    'wat' => array(),
     27    'wideo' => array(),
     28    );
     29   
     30  private $table;
     31 
     32  function __construct($plugin_id)
     33  {
     34    global $prefixeTable;
     35   
     36    parent::__construct($plugin_id);
     37   
     38    $this->table = $prefixeTable . 'image_video';
     39  }
     40
     41  function install($plugin_version, &$errors=array())
     42  {
     43    global $conf;
     44
     45    // add config parameter
     46    if (empty($conf['gvideo']))
     47    {
     48      $conf['gvideo'] = serialize($this->default_conf);
     49      conf_update_param('gvideo', $conf['gvideo']);
     50    }
     51    else
     52    {
     53      $old_conf = is_string($conf['gvideo']) ? unserialize($conf['gvideo']) : $conf['gvideo'];
     54
     55      if (!isset($old_conf['sync_description']))
     56      {
     57        $old_conf['sync_description'] = 1;
     58        $old_conf['sync_tags'] = 1;
     59       
     60        $conf['gvideo'] = serialize($old_conf);
     61        conf_update_param('gvideo', $conf['gvideo']);
     62      }
     63    }
     64
     65    // create table
     66  $query = '
     67CREATE TABLE IF NOT EXISTS `' . $this->table . '` (
     68  `picture_id` mediumint(8) NOT NULL,
     69  `url` varchar(255) DEFAULT NULL,
     70  `type` varchar(64) NOT NULL,
     71  `video_id` varchar(128) NOT NULL,
     72  `width` smallint(9) DEFAULT NULL,
     73  `height` smallint(9) DEFAULT NULL,
     74  `autoplay` tinyint(1) DEFAULT NULL
     75) ENGINE=MyISAM DEFAULT CHARSET=utf8
     76;';
     77    pwg_query($query);
     78   
     79    // update video_id lenght
     80    $query = 'ALTER TABLE `' . $this->table . '` CHANGE `video_id` `video_id` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;';
     81    pwg_query($query);
     82   
     83    // new collumn in images table
     84    $result = pwg_query('SHOW COLUMNS FROM `' . IMAGES_TABLE . '` LIKE "is_gvideo";');
     85    if (!pwg_db_num_rows($result))
     86    {
     87      pwg_query('ALTER TABLE `' . IMAGES_TABLE . '` ADD `is_gvideo` TINYINT(1) NOT NULL DEFAULT 0;');
     88     
     89      $query = '
     90UPDATE `' . IMAGES_TABLE . '`
     91  SET is_gvideo = 1
     92  WHERE id IN(
     93    SELECT picture_id FROM `' . $this->table . '`
     94    )
     95;';
     96      pwg_query($query);
     97    }
     98   
     99    // remove old configuration
     100    if (isset($conf['PY_GVideo']))
     101    {
     102      conf_delete_param('PY_GVideo');
     103    }
     104   
     105    // updade video files
     106    $this->update_24();
     107
     108    $this->installed = true;
     109  }
     110
     111  function activate($plugin_version, &$errors=array())
     112  {
     113    if (!$this->installed)
     114    {
     115      $this->install($plugin_version, $errors);
     116    }
     117  }
     118
     119  function deactivate()
     120  {
     121  }
     122
     123  function uninstall()
     124  {
     125    conf_delete_param('gvideo');
     126
     127    pwg_query('DROP TABLE `' . $this->table . '`;');
     128
     129    pwg_query('ALTER TABLE `'. IMAGES_TABLE .'` DROP `is_gvideo`;');
     130  }
     131 
     132  /**
     133   * update from 2.3 to 2.4
     134   */
     135  function update_24()
     136  {
     137    global $conf;
     138   
     139    // search existing videos
     140  $query = '
     141SELECT *
     142  FROM '.IMAGES_TABLE.'
     143  WHERE
     144    file LIKE "%.gvideo"
     145    OR file LIKE "%.dm"
     146    OR file LIKE "%.ytube"
     147    OR file LIKE "%.wideo"
     148    OR file LIKE "%.vimeo"
     149    OR file LIKE "%.wat"
     150;';
     151    $result = pwg_query($query);
     152   
     153    if (!pwg_db_num_rows($result))
     154    {
     155      return;
     156    }
     157   
     158    if (!isset($conf['prefix_thumbnail']))
     159    {
     160      $conf['prefix_thumbnail'] = 'TN-';
     161    }
     162
     163    if (!isset($conf['dir_thumbnail']))
     164    {
     165      $conf['dir_thumbnail'] = 'thumbnail';
     166    }
     167   
     168    set_time_limit(600);
     169    include_once(gvideo_path . 'include/functions.inc.php');
     170    include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
     171   
     172    $videos_inserts = array();
     173    $images_updates = array();
     174    $images_delete = array();
     175   
     176    while ($img = pwg_db_fetch_assoc($result))
     177    {
     178      $file_content = file_get_contents($img['path']);
     179      list($file['id'], $file['height'], $file['width'], ) = explode('/', $file_content);
     180      $file['type'] = get_extension($img['path']);
     181     
     182      switch ($file['type'])
     183      {
     184        case 'vimeo':
     185          $video = array(
     186            'type' => 'vimeo',
     187            'url' => 'http://vimeo.com/'.$file['id'],
     188            );
     189          break;
     190        case 'dm':
     191          $video = array(
     192            'type' => 'dailymotion',
     193            'url' => 'http://dailymotion.com/video/'.$file['id'],
     194            );
     195          break;
     196        case 'ytube':
     197          $video = array(
     198            'type' => 'youtube',
     199            'url' => 'http://youtube.com/watch?v='.$file['id'],
     200            );
     201          break;
     202        case 'wideo':
     203          $video = array(
     204            'type' => 'wideo',
     205            'url' => 'http://wideo.fr/video/'.$file['id'].'.html',
     206            );
     207          break;
     208        case 'wat':
     209          $video = array(
     210            'type' => 'wat',
     211            'url' => null,
     212            );
     213          break;
     214        case 'gvideo': // closed
     215        default:
     216          $images_delete[] = $img['id'];
     217          continue;
     218      }
     219     
     220      $real_path = str_replace($img['file'], null, str_replace('././', './', $img['path']));
     221     
     222      // get existing thumbnail
     223      $thumb = $real_path.$conf['dir_thumbnail'].'/'.$conf['prefix_thumbnail'].get_filename_wo_extension($img['file']).'.*';
     224      $thumb = glob($thumb);
     225      if (!empty($thumb))
     226      {
     227        $thumb_name = $video['type'].'-'.$file['id'].'-'.uniqid().'.'.get_extension($thumb[0]);
     228        $thumb_source = $conf['data_location'].$thumb_name;
     229        copy($thumb[0], $thumb_source);
     230      }
     231      else
     232      {
     233        $thumb_name = $video['type'].'-'.$file['id'].'-'.uniqid().'.jpg';
     234        $thumb_source = $conf['data_location'].$thumb_name;
     235        copy(gvideo_path.'mimetypes/'.$video['type'].'.jpg', $thumb_source);
     236        add_film_frame($thumb_source);
     237      }
     238     
     239      // update element
     240      $image_id = add_uploaded_file($thumb_source, $thumb_name, null, null, $img['id']);
     241     
     242      // update path and rename the file
     243      $img['new_path'] = $real_path.$thumb_name;
     244      rename($img['path'], $img['new_path']); // why ? what's the purpose of this line ?
     245     
     246      $images_updates[] = array(
     247        'id' => $img['id'],
     248        'path' => $img['new_path'],
     249        'is_gvideo' => 1,
     250        );
     251     
     252      if (empty($file['width'])) $file['width'] = '';
     253      if (empty($file['height'])) $file['height'] = '';
     254     
     255      // register video   
     256      $videos_inserts[] = array(
     257        'picture_id' => $image_id,
     258        'url' => $video['url'],
     259        'type' => $video['type'],
     260        'video_id' => $file['id'],
     261        'width' => $file['width'],
     262        'height' => $file['height'],
     263        'autoplay' => '',
     264        );
     265       
     266      unset($thumb_source, $thumb_name, $file, $video, $url);
     267    }
     268   
     269    // delete obsolete elements
     270    delete_elements($images_delete);
     271   
     272    // registers videos
     273    mass_inserts(
     274      gvideo_table,
     275      array('picture_id', 'url', 'type', 'video_id', 'width', 'height', 'autoplay'),
     276      $videos_inserts
     277      );
     278     
     279    // update images
     280    mass_updates(
     281      IMAGES_TABLE,
     282      array('primary'=>array('id'), 'update'=>array('path', 'is_gvideo')),
     283      $images_updates
     284      );
     285  }
    14286}
    15 
    16 /* activate */
    17 function plugin_activate()
    18 {
    19   if (!defined('gvideo_installed'))
    20   {
    21     gvideo_install();
    22   }
    23 }
    24 
    25 /* uninstall */
    26 function plugin_uninstall()
    27 {
    28   global $prefixeTable;
    29  
    30   pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "gvideo" LIMIT 1;');
    31   pwg_query('DROP TABLE `'.$prefixeTable.'image_video`;');
    32   pwg_query('ALTER TABLE `' . IMAGES_TABLE . '` DROP `is_gvideo`;');
    33 }
    34 
    35 ?>
Note: See TracChangeset for help on using the changeset viewer.