diff options
author | plegall <plg@piwigo.org> | 2016-02-01 10:20:57 +0100 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2016-02-01 10:20:57 +0100 |
commit | da8d2b2af0e38715a929b3d4b900ee793cdfb3e8 (patch) | |
tree | 386658eb909674adbb0c2afbe756bdbf9a895d37 /admin/include | |
parent | 70726892e031553563899783d9caab4d2c2e5b65 (diff) | |
parent | 2fcf276811723d300b4d4c08675994339a6688fa (diff) |
Merge branch 'master' into translation
Diffstat (limited to 'admin/include')
25 files changed, 344 insertions, 147 deletions
diff --git a/admin/include/add_core_tabs.inc.php b/admin/include/add_core_tabs.inc.php index 28cf1ce9e..9cef0f064 100644 --- a/admin/include/add_core_tabs.inc.php +++ b/admin/include/add_core_tabs.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ diff --git a/admin/include/albums_tab.inc.php b/admin/include/albums_tab.inc.php index 399778d01..8bccb5378 100644 --- a/admin/include/albums_tab.inc.php +++ b/admin/include/albums_tab.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ diff --git a/admin/include/c13y_internal.class.php b/admin/include/c13y_internal.class.php index 10375095a..acf4a32b6 100644 --- a/admin/include/c13y_internal.class.php +++ b/admin/include/c13y_internal.class.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -23,7 +23,7 @@ class c13y_internal { - function c13y_internal() + function __construct() { add_event_handler('list_check_integrity', array(&$this, 'c13y_version')); add_event_handler('list_check_integrity', array(&$this, 'c13y_exif')); diff --git a/admin/include/check_integrity.class.php b/admin/include/check_integrity.class.php index 66ff1db8f..bf2104175 100644 --- a/admin/include/check_integrity.class.php +++ b/admin/include/check_integrity.class.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -27,7 +27,7 @@ class check_integrity var $retrieve_list; var $build_ignore_list; - function check_integrity() + function __construct() { $this->ignore_list = array(); $this->retrieve_list = array(); diff --git a/admin/include/configuration_sizes_process.inc.php b/admin/include/configuration_sizes_process.inc.php index a731aa55f..92d746d4b 100644 --- a/admin/include/configuration_sizes_process.inc.php +++ b/admin/include/configuration_sizes_process.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ diff --git a/admin/include/configuration_watermark_process.inc.php b/admin/include/configuration_watermark_process.inc.php index ad23d92a2..bc1451791 100644 --- a/admin/include/configuration_watermark_process.inc.php +++ b/admin/include/configuration_watermark_process.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -126,6 +126,7 @@ if (count($errors) == 0) $watermark->xpos = intval($pwatermark['xpos']); $watermark->ypos = intval($pwatermark['ypos']); $watermark->xrepeat = intval($pwatermark['xrepeat']); + $watermark->yrepeat = intval($pwatermark['yrepeat']); $watermark->opacity = intval($pwatermark['opacity']); $watermark->min_size = array(intval($pwatermark['minw']),intval($pwatermark['minh'])); @@ -135,6 +136,7 @@ if (count($errors) == 0) || $watermark->xpos != $old_watermark->xpos || $watermark->ypos != $old_watermark->ypos || $watermark->xrepeat != $old_watermark->xrepeat + || $watermark->yrepeat != $old_watermark->yrepeat || $watermark->opacity != $old_watermark->opacity; // save the new watermark configuration diff --git a/admin/include/functions.php b/admin/include/functions.php index 7d29f5734..4d3ccebe6 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -180,6 +180,25 @@ function delete_element_files($ids) } $new_ids = array(); + $formats_of = array(); + + $query = ' +SELECT + image_id, + ext + FROM '.IMAGE_FORMAT_TABLE.' + WHERE image_id IN ('.implode(',', $ids).') +;'; + $result = pwg_query($query); + while ($row = pwg_db_fetch_assoc($result)) + { + if (!isset($formats_of[ $row['image_id'] ])) + { + $formats_of[ $row['image_id'] ] = array(); + } + + $formats_of[ $row['image_id'] ][] = $row['ext']; + } $query = ' SELECT @@ -205,6 +224,14 @@ SELECT $files[] = original_to_representative( $files[0], $row['representative_ext']); } + if (isset($formats_of[ $row['id'] ])) + { + foreach ($formats_of[ $row['id'] ] as $format_ext) + { + $files[] = original_to_format($files[0], $format_ext); + } + } + $ok = true; if (!isset($conf['never_delete_originals'])) { @@ -277,6 +304,13 @@ DELETE FROM '.IMAGE_CATEGORY_TABLE.' ;'; pwg_query($query); + // destruction of the formats + $query = ' +DELETE FROM '.IMAGE_FORMAT_TABLE.' + WHERE image_id IN ('. $ids_str .') +;'; + pwg_query($query); + // destruction of the links between images and tags $query = ' DELETE FROM '.IMAGE_TAG_TABLE.' @@ -358,6 +392,7 @@ function delete_user($user_id) CADDIE_TABLE, // deletion of piwigo specific informations USER_INFOS_TABLE, + USER_AUTH_KEYS_TABLE ); foreach ($tables as $table) @@ -540,6 +575,7 @@ function get_fs_directories($path, $recursive = true) '.', '..', '.svn', 'thumbnail', 'pwg_high', 'pwg_representative', + 'pwg_format', ) ); $exclude_folders = array_flip($exclude_folders); @@ -887,6 +923,25 @@ SELECT uppercats } /** + */ +function get_category_representant_properties($image_id) +{ + $query = ' +SELECT id,representative_ext,path + FROM '.IMAGES_TABLE.' + WHERE id = '.$image_id.' +;'; + $row = pwg_db_fetch_assoc(pwg_query($query)); + $src = DerivativeImage::thumb_url($row); + $url = get_root_url().'admin.php?page=photo-'.$image_id; + + return array( + 'src' => $src, + 'url' => $url + ); +} + +/** * Set a new random representant to the categories. * * @param int[] $categories @@ -2775,4 +2830,51 @@ SELECT CONCAT( } return $keys; -}
\ No newline at end of file +} + +/** + * Return the list of image ids associated to no album + * + * @return int[] $image_ids + */ +function get_orphans() +{ + $query = ' +SELECT + id + FROM '.IMAGES_TABLE.' + LEFT JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id + WHERE category_id is null +;'; + + return query2array($query, null, 'id'); +} + +/** + * save the rank depending on given images order + * + * The list of ordered images id is supposed to be in the same parent + * category + * + * @param int category_id + * @param int[] images + * @return void + */ +function save_images_order($category_id, $images) +{ + $current_rank = 0; + $datas = array(); + foreach ($images as $id) + { + $datas[] = array( + 'category_id' => $category_id, + 'image_id' => $id, + 'rank' => ++$current_rank, + ); + } + $fields = array( + 'primary' => array('image_id', 'category_id'), + 'update' => array('rank') + ); + mass_updates(IMAGE_CATEGORY_TABLE, $fields, $datas); +} diff --git a/admin/include/functions_history.inc.php b/admin/include/functions_history.inc.php index e2bcc4d62..55783fd74 100644 --- a/admin/include/functions_history.inc.php +++ b/admin/include/functions_history.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ diff --git a/admin/include/functions_install.inc.php b/admin/include/functions_install.inc.php index a97835583..5a68964f8 100644 --- a/admin/include/functions_install.inc.php +++ b/admin/include/functions_install.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ diff --git a/admin/include/functions_metadata.php b/admin/include/functions_metadata.php index da0703774..1b5b5bb73 100644 --- a/admin/include/functions_metadata.php +++ b/admin/include/functions_metadata.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ diff --git a/admin/include/functions_notification_by_mail.inc.php b/admin/include/functions_notification_by_mail.inc.php index 8d0fe2621..204be5c33 100644 --- a/admin/include/functions_notification_by_mail.inc.php +++ b/admin/include/functions_notification_by_mail.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -125,12 +125,12 @@ select U.'.$conf['user_fields']['username'].' as username, U.'.$conf['user_fields']['email'].' as mail_address, N.enabled, - N.last_send -from - '.USER_MAIL_NOTIFICATION_TABLE.' as N, - '.USERS_TABLE.' as U -where - N.user_id = U.'.$conf['user_fields']['id']; + N.last_send, + UI.status +from '.USER_MAIL_NOTIFICATION_TABLE.' as N + JOIN '.USERS_TABLE.' as U on N.user_id = U.'.$conf['user_fields']['id'].' + JOIN '.USER_INFOS_TABLE.' as UI on UI.user_id = N.user_id +where 1=1'; if ($action == 'send') { @@ -159,7 +159,7 @@ order by'; else { $query .= ' - username;'; + username'; } $query .= ';'; diff --git a/admin/include/functions_permalinks.php b/admin/include/functions_permalinks.php index 6c8ae4aac..db0679661 100644 --- a/admin/include/functions_permalinks.php +++ b/admin/include/functions_permalinks.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ diff --git a/admin/include/functions_plugins.inc.php b/admin/include/functions_plugins.inc.php index fb98c799c..8605f1ff2 100644 --- a/admin/include/functions_plugins.inc.php +++ b/admin/include/functions_plugins.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ diff --git a/admin/include/functions_upgrade.php b/admin/include/functions_upgrade.php index b7a8763c5..bf6ef2b88 100644 --- a/admin/include/functions_upgrade.php +++ b/admin/include/functions_upgrade.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -174,10 +174,7 @@ UPDATE '.PREFIX_TABLE.'user_infos // Deactivate all templates function deactivate_templates() { - $query = ' - UPDATE '.PREFIX_TABLE.'config - SET value = \''. array() .'\' - WHERE param = \'extents_for_templates\';'; + conf_update_param('extents_for_templates', array()); } // Check access rights @@ -322,4 +319,4 @@ function upgrade_db_connect() my_error(l10n($e->getMessage()), true); } } -?>
\ No newline at end of file +?> diff --git a/admin/include/functions_upload.inc.php b/admin/include/functions_upload.inc.php index d0ef6e67d..17e78a200 100644 --- a/admin/include/functions_upload.inc.php +++ b/admin/include/functions_upload.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -268,104 +268,19 @@ SELECT } @chmod($file_path, 0644); - if ($is_tiff and pwg_image::get_library() == 'ext_imagick') - { - // move the uploaded file to pwg_representative sub-directory - $representative_file_path = dirname($file_path).'/pwg_representative/'; - $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.'; - - $representative_ext = $conf['tiff_representative_ext']; - $representative_file_path.= $representative_ext; - - prepare_directory(dirname($representative_file_path)); - - $exec = $conf['ext_imagick_dir'].'convert'; - - if ('jpg' == $conf['tiff_representative_ext']) - { - $exec .= ' -quality 98'; - } - - $exec .= ' "'.realpath($file_path).'"'; - - $dest = pathinfo($representative_file_path); - $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"'; - - $exec .= ' 2>&1'; - @exec($exec, $returnarray); - - // sometimes ImageMagick creates file-0.jpg (full size) + file-1.jpg - // (thumbnail). I don't know how to avoid it. - $representative_file_abspath = realpath($dest['dirname']).'/'.$dest['basename']; - if (!file_exists($representative_file_abspath)) - { - $first_file_abspath = preg_replace( - '/\.'.$representative_ext.'$/', - '-0.'.$representative_ext, - $representative_file_abspath - ); - - if (file_exists($first_file_abspath)) - { - rename($first_file_abspath, $representative_file_abspath); - } - } - } + // handle the uploaded file type by potentially making a + // pwg_representative file. + $representative_ext = trigger_change('upload_file', null, $file_path); - // - // generate pwg_representative in case of video - // - $ffmpeg_video_exts = array( // extensions tested with FFmpeg - 'wmv','mov','mkv','mp4','mpg','flv','asf','xvid','divx','mpeg', - 'avi','rm', - ); + global $logger; + $logger->info("Handling " . (string)$file_path . " got " . (string)$representative_ext); - if (isset($original_extension) and in_array($original_extension, $ffmpeg_video_exts)) - { - $representative_file_path = dirname($file_path).'/pwg_representative/'; - $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.'; - - $representative_ext = 'jpg'; - $representative_file_path.= $representative_ext; - - prepare_directory(dirname($representative_file_path)); - - $second = 1; - - $ffmpeg = $conf['ffmpeg_dir'].'ffmpeg'; - $ffmpeg.= ' -i "'.$file_path.'"'; - $ffmpeg.= ' -an -ss '.$second; - $ffmpeg.= ' -t 1 -r 1 -y -vcodec mjpeg -f mjpeg'; - $ffmpeg.= ' "'.$representative_file_path.'"'; - - // file_put_contents('/tmp/ffmpeg.log', "\n==== ".date('c')."\n".__FUNCTION__.' : '.$ffmpeg."\n", FILE_APPEND); - - @exec($ffmpeg); - - if (!file_exists($representative_file_path)) - { - $representative_ext = null; - } - } - - if (isset($original_extension) and 'pdf' == $original_extension and pwg_image::get_library() == 'ext_imagick') - { - $representative_file_path = dirname($file_path).'/pwg_representative/'; - $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.'; - - $representative_ext = 'jpg'; - $representative_file_path.= $representative_ext; - - prepare_directory(dirname($representative_file_path)); - - $exec = $conf['ext_imagick_dir'].'convert'; - $exec.= ' -quality 98'; - $exec.= ' "'.realpath($file_path).'"[0]'; - - $dest = pathinfo($representative_file_path); - $exec.= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"'; - $exec.= ' 2>&1'; - @exec($exec, $returnarray); + // If it is set to either true (the file didn't need a + // representative generated) or false (the generation of the + // representative failed), set it to null because we have no + // representative file. + if (is_bool($representative_ext)) { + $representative_ext = null; } if (pwg_image::get_library() != 'gd') @@ -492,6 +407,168 @@ SELECT return $image_id; } +add_event_handler('upload_file', 'upload_file_pdf'); +function upload_file_pdf($representative_ext, $file_path) +{ + global $logger, $conf; + + $logger->info(__FUNCTION__.', $file_path = '.$file_path.', $representative_ext = '.$representative_ext); + + if (isset($representative_ext)) + { + return $representative_ext; + } + + if (pwg_image::get_library() != 'ext_imagick') + { + return $representative_ext; + } + + if (!in_array(strtolower(get_extension($file_path)), array('pdf'))) + { + return $representative_ext; + } + + $ext = conf_get_param('pdf_representative_ext', 'jpg'); + $jpg_quality = conf_get_param('pdf_jpg_quality', 90); + + // move the uploaded file to pwg_representative sub-directory + $representative_file_path = original_to_representative($file_path, $ext); + prepare_directory(dirname($representative_file_path)); + + $exec = $conf['ext_imagick_dir'].'convert'; + if ('jpg' == $ext) + { + $exec.= ' -quality '.$jpg_quality; + } + $exec.= ' "'.realpath($file_path).'"[0]'; + $exec.= ' "'.$representative_file_path.'"'; + $exec.= ' 2>&1'; + @exec($exec, $returnarray); + + // Return the extension (if successful) or false (if failed) + if (file_exists($representative_file_path)) + { + $representative_ext = $ext; + } + + return $representative_ext; +} + +add_event_handler('upload_file', 'upload_file_tiff'); +function upload_file_tiff($representative_ext, $file_path) +{ + global $logger, $conf; + + $logger->info(__FUNCTION__.', $file_path = '.$file_path.', $representative_ext = '.$representative_ext); + + if (isset($representative_ext)) + { + return $representative_ext; + } + + if (pwg_image::get_library() != 'ext_imagick') + { + return $representative_ext; + } + + if (!in_array(strtolower(get_extension($file_path)), array('tif', 'tiff'))) + { + return $representative_ext; + } + + // move the uploaded file to pwg_representative sub-directory + $representative_file_path = dirname($file_path).'/pwg_representative/'; + $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.'; + + $representative_ext = $conf['tiff_representative_ext']; + $representative_file_path.= $representative_ext; + + prepare_directory(dirname($representative_file_path)); + + $exec = $conf['ext_imagick_dir'].'convert'; + + if ('jpg' == $conf['tiff_representative_ext']) + { + $exec .= ' -quality 98'; + } + + $exec .= ' "'.realpath($file_path).'"'; + + $dest = pathinfo($representative_file_path); + $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"'; + + $exec .= ' 2>&1'; + @exec($exec, $returnarray); + + // sometimes ImageMagick creates file-0.jpg (full size) + file-1.jpg + // (thumbnail). I don't know how to avoid it. + $representative_file_abspath = realpath($dest['dirname']).'/'.$dest['basename']; + if (!file_exists($representative_file_abspath)) + { + $first_file_abspath = preg_replace( + '/\.'.$representative_ext.'$/', + '-0.'.$representative_ext, + $representative_file_abspath + ); + + if (file_exists($first_file_abspath)) + { + rename($first_file_abspath, $representative_file_abspath); + } + } + + return get_extension($representative_file_abspath); +} + +add_event_handler('upload_file', 'upload_file_video'); +function upload_file_video($representative_ext, $file_path) +{ + global $logger, $conf; + + $logger->info(__FUNCTION__.', $file_path = '.$file_path.', $representative_ext = '.$representative_ext); + + if (isset($representative_ext)) + { + return $representative_ext; + } + + $ffmpeg_video_exts = array( // extensions tested with FFmpeg + 'wmv','mov','mkv','mp4','mpg','flv','asf','xvid','divx','mpeg', + 'avi','rm', + ); + + if (!in_array(strtolower(get_extension($file_path)), $ffmpeg_video_exts)) + { + return $representative_ext; + } + + $representative_file_path = dirname($file_path).'/pwg_representative/'; + $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.'; + + $representative_ext = 'jpg'; + $representative_file_path.= $representative_ext; + + prepare_directory(dirname($representative_file_path)); + + $second = 1; + + $ffmpeg = $conf['ffmpeg_dir'].'ffmpeg'; + $ffmpeg.= ' -i "'.$file_path.'"'; + $ffmpeg.= ' -an -ss '.$second; + $ffmpeg.= ' -t 1 -r 1 -y -vcodec mjpeg -f mjpeg'; + $ffmpeg.= ' "'.$representative_file_path.'"'; + + @exec($ffmpeg); + + if (!file_exists($representative_file_path)) + { + return null; + } + + return $representative_ext; +} + function prepare_directory($directory) { if (!is_dir($directory)) { diff --git a/admin/include/image.class.php b/admin/include/image.class.php index ee9b9bb12..e713a84c9 100644 --- a/admin/include/image.class.php +++ b/admin/include/image.class.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ diff --git a/admin/include/index.php b/admin/include/index.php index c8de97f60..0b96c3efa 100644 --- a/admin/include/index.php +++ b/admin/include/index.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ diff --git a/admin/include/languages.class.php b/admin/include/languages.class.php index 351e36d53..6f6780592 100644 --- a/admin/include/languages.class.php +++ b/admin/include/languages.class.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -30,7 +30,7 @@ class languages /** * Initialize $fs_languages and $db_languages */ - function languages($target_charset = null) + function __construct($target_charset = null) { $this->get_fs_languages($target_charset); } @@ -408,4 +408,4 @@ UPDATE '.USER_INFOS_TABLE.' return strcmp(strtolower($a['extension_name']), strtolower($b['extension_name'])); } } -?>
\ No newline at end of file +?> diff --git a/admin/include/mysqldump.php b/admin/include/mysqldump.php index 515d86ae9..1432675c8 100644 --- a/admin/include/mysqldump.php +++ b/admin/include/mysqldump.php @@ -59,7 +59,7 @@ class MySQLDump { * @param boolean $compress It defines if the output file is compress (gzip) or not
* @param boolean $hexValue It defines if the outup values are base-16 or not
*/
- function MYSQLDump($db = null, $filepath = 'dump.sql', $compress = false, $hexValue = false){
+ function __construct($db = null, $filepath = 'dump.sql', $compress = false, $hexValue = false){
$this->compress = $compress;
if ( !$this->setOutputFile($filepath) )
return false;
@@ -418,4 +418,4 @@ class MySQLDump { @fclose($file);
}
}
-?>
\ No newline at end of file +?>
diff --git a/admin/include/pclzip.lib.php b/admin/include/pclzip.lib.php index e7facc1ea..c2d09a50c 100644 --- a/admin/include/pclzip.lib.php +++ b/admin/include/pclzip.lib.php @@ -212,7 +212,7 @@ // Note that no real action is taken, if the archive does not exist it is not // created. Use create() for that. // -------------------------------------------------------------------------------- - function PclZip($p_zipname) + function __construct($p_zipname) { // ----- Tests the zlib diff --git a/admin/include/photos_add_direct_prepare.inc.php b/admin/include/photos_add_direct_prepare.inc.php index 34b025f13..4d852fee4 100644 --- a/admin/include/photos_add_direct_prepare.inc.php +++ b/admin/include/photos_add_direct_prepare.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -44,6 +44,7 @@ $template->assign( 'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL, 'upload_max_filesize' => $upload_max_filesize, 'upload_max_filesize_shorthand' => $upload_max_filesize_shorthand, + 'chunk_size' => $conf['upload_form_chunk_size'], ) ); @@ -229,4 +230,4 @@ if (!isset($_SESSION['upload_hide_warnings'])) ); } -?>
\ No newline at end of file +?> diff --git a/admin/include/plugins.class.php b/admin/include/plugins.class.php index 71093a6c1..8b4b82b75 100644 --- a/admin/include/plugins.class.php +++ b/admin/include/plugins.class.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -69,7 +69,7 @@ class plugins /** * Initialize $fs_plugins and $db_plugins_by_id */ - function plugins() + function __construct() { $this->get_fs_plugins(); @@ -716,4 +716,4 @@ DELETE FROM '. PLUGINS_TABLE .' $this->fs_plugins = $active_plugins + $inactive_plugins + $not_installed; } } -?>
\ No newline at end of file +?> diff --git a/admin/include/tabsheet.class.php b/admin/include/tabsheet.class.php index c7681b611..cb89886fe 100644 --- a/admin/include/tabsheet.class.php +++ b/admin/include/tabsheet.class.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -33,7 +33,7 @@ class tabsheet $name is the tabsheet's name inside the template .tpl file $titlename in the template is affected by $titlename value */ - function tabsheet($name = 'TABSHEET', $titlename = 'TABSHEET_TITLE') + function __construct($name = 'TABSHEET', $titlename = 'TABSHEET_TITLE') { $this->sheets = array(); $this->uniqid = null; diff --git a/admin/include/themes.class.php b/admin/include/themes.class.php index df0e29e66..6d55e11bd 100644 --- a/admin/include/themes.class.php +++ b/admin/include/themes.class.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ @@ -60,7 +60,7 @@ class themes /** * Initialize $fs_themes and $db_themes_by_id */ - function themes() + function __construct() { $this->get_fs_themes(); @@ -736,4 +736,4 @@ SELECT } } -?>
\ No newline at end of file +?> diff --git a/admin/include/updates.class.php b/admin/include/updates.class.php index 17a3b2578..d4e178f8a 100644 --- a/admin/include/updates.class.php +++ b/admin/include/updates.class.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2016 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 |
// +-----------------------------------------------------------------------+
@@ -135,15 +135,33 @@ class updates {
return false;
}
+
+ $servers = array();
+
foreach ($pem_exts as $ext)
{
if (isset($ext_to_check[$ext['extension_id']]))
{
- $server = 'server_'.$ext_to_check[$ext['extension_id']];
- $this->$ext_to_check[$ext['extension_id']]->$server += array($ext['extension_id'] => $ext);
+ $type = $ext_to_check[$ext['extension_id']];
+
+ if (!isset($servers[$type]))
+ {
+ $servers[$type] = array();
+ }
+
+ $servers[$type][ $ext['extension_id'] ] = $ext;
+
unset($ext_to_check[$ext['extension_id']]);
}
}
+
+ foreach ($servers as $server_type => $extension_list)
+ {
+ $server_string = 'server_'.$server_type;
+
+ $this->$server_type->$server_string = $extension_list;
+ }
+
$this->check_missing_extensions($ext_to_check);
return true;
}
|