feature 1489: integrate UploadForm into Piwigo core. The integration is not
100% done, I just "made it work" on trunk. pclzip library was updated to version 2.8.2 for memory usage improvement. git-svn-id: http://piwigo.org/svn/trunk@5089 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
4ac5c0649e
commit
8dc1b99586
16 changed files with 6340 additions and 2952 deletions
|
|
@ -122,6 +122,7 @@ $template->assign(
|
|||
'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',
|
||||
'U_LOGOUT'=> PHPWG_ROOT_PATH.'index.php?act=logout',
|
||||
'U_PLUGINS'=> $link_start.'plugins_list',
|
||||
'U_ADD_PHOTOS' => $link_start.'photos_add',
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
|||
264
admin/include/functions_upload.inc.php
Normal file
264
admin/include/functions_upload.inc.php
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
<?php
|
||||
// TODO
|
||||
// * check md5sum (already exists?)
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_functions.inc.php');
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
|
||||
// Here is the plan
|
||||
//
|
||||
// 1) move uploaded file to upload/2010/01/22/20100122003814-449ada00.jpg
|
||||
//
|
||||
// 2) if taller than max_height or wider than max_width, move to pwg_high
|
||||
// + web sized creation
|
||||
//
|
||||
// 3) thumbnail creation from web sized
|
||||
//
|
||||
// 4) register in database
|
||||
|
||||
function add_uploaded_file($source_filepath, $original_filename=null, $categories=null, $level=null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// current date
|
||||
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
||||
list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4);
|
||||
|
||||
// upload directory hierarchy
|
||||
$upload_dir = sprintf(
|
||||
PHPWG_ROOT_PATH.'upload/%s/%s/%s',
|
||||
$year,
|
||||
$month,
|
||||
$day
|
||||
);
|
||||
|
||||
// compute file path
|
||||
$md5sum = md5_file($source_filepath);
|
||||
$date_string = preg_replace('/[^\d]/', '', $dbnow);
|
||||
$random_string = substr($md5sum, 0, 8);
|
||||
$filename_wo_ext = $date_string.'-'.$random_string;
|
||||
$file_path = $upload_dir.'/'.$filename_wo_ext.'.jpg';
|
||||
|
||||
prepare_directory($upload_dir);
|
||||
if (is_uploaded_file($source_filepath))
|
||||
{
|
||||
move_uploaded_file($source_filepath, $file_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
copy($source_filepath, $file_path);
|
||||
}
|
||||
|
||||
if ($conf['upload_form_websize_resize']
|
||||
and need_resize($file_path, $conf['upload_form_websize_maxwidth'], $conf['upload_form_websize_maxheight']))
|
||||
{
|
||||
$high_path = file_path_for_type($file_path, 'high');
|
||||
$high_dir = dirname($high_path);
|
||||
prepare_directory($high_dir);
|
||||
|
||||
rename($file_path, $high_path);
|
||||
$high_infos = pwg_image_infos($high_path);
|
||||
|
||||
pwg_image_resize(
|
||||
$high_path,
|
||||
$file_path,
|
||||
$conf['upload_form_websize_maxwidth'],
|
||||
$conf['upload_form_websize_maxheight'],
|
||||
$conf['upload_form_websize_quality']
|
||||
);
|
||||
}
|
||||
|
||||
$file_infos = pwg_image_infos($file_path);
|
||||
|
||||
$thumb_path = file_path_for_type($file_path, 'thumb');
|
||||
$thumb_dir = dirname($thumb_path);
|
||||
prepare_directory($thumb_dir);
|
||||
|
||||
pwg_image_resize(
|
||||
$file_path,
|
||||
$thumb_path,
|
||||
$conf['upload_form_thumb_maxwidth'],
|
||||
$conf['upload_form_thumb_maxheight'],
|
||||
$conf['upload_form_thumb_quality']
|
||||
);
|
||||
|
||||
$thumb_infos = pwg_image_infos($thumb_path);
|
||||
|
||||
// database registration
|
||||
$insert = array(
|
||||
'file' => isset($original_filename) ? $original_filename : basename($file_path),
|
||||
'date_available' => $dbnow,
|
||||
'tn_ext' => 'jpg',
|
||||
'path' => preg_replace('/^.*?upload/', './upload', $file_path),
|
||||
'filesize' => $file_infos['filesize'],
|
||||
'width' => $file_infos['width'],
|
||||
'height' => $file_infos['height'],
|
||||
'md5sum' => $md5sum,
|
||||
);
|
||||
|
||||
if (isset($high_infos))
|
||||
{
|
||||
$insert['has_high'] = 'true';
|
||||
$insert['high_filesize'] = $high_infos['filesize'];
|
||||
}
|
||||
|
||||
if (isset($level))
|
||||
{
|
||||
$insert['level'] = $level;
|
||||
}
|
||||
|
||||
mass_inserts(
|
||||
IMAGES_TABLE,
|
||||
array_keys($insert),
|
||||
array($insert)
|
||||
);
|
||||
|
||||
$image_id = mysql_insert_id();
|
||||
|
||||
if (isset($categories) and count($categories) > 0)
|
||||
{
|
||||
associate_images_to_categories(
|
||||
array($image_id),
|
||||
$categories
|
||||
);
|
||||
}
|
||||
|
||||
// update metadata from the uploaded file (exif/iptc)
|
||||
update_metadata(array($image_id=>$file_path));
|
||||
|
||||
invalidate_user_cache();
|
||||
|
||||
return $image_id;
|
||||
}
|
||||
|
||||
function prepare_directory($directory)
|
||||
{
|
||||
if (!is_dir($directory)) {
|
||||
umask(0000);
|
||||
$recursive = true;
|
||||
if (!@mkdir($directory, 0777, $recursive))
|
||||
{
|
||||
die('[prepare_directory] cannot create directory "'.$directory.'"');
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_writable($directory))
|
||||
{
|
||||
// last chance to make the directory writable
|
||||
@chmod($directory, 0777);
|
||||
|
||||
if (!is_writable($directory))
|
||||
{
|
||||
die('[prepare_directory] directory "'.$directory.'" has no write access');
|
||||
}
|
||||
}
|
||||
|
||||
secure_directory($directory);
|
||||
}
|
||||
|
||||
function need_resize($image_filepath, $max_width, $max_height)
|
||||
{
|
||||
list($width, $height) = getimagesize($image_filepath);
|
||||
|
||||
if ($width > $max_width or $height > $max_height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function pwg_image_resize($source_filepath, $destination_filepath, $max_width, $max_height, $quality)
|
||||
{
|
||||
if (!function_exists('gd_info'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// extension of the picture filename
|
||||
$extension = strtolower(get_extension($source_filepath));
|
||||
|
||||
$source_image = null;
|
||||
if (in_array($extension, array('jpg', 'jpeg')))
|
||||
{
|
||||
$source_image = @imagecreatefromjpeg($source_filepath);
|
||||
}
|
||||
else if ($extension == 'png')
|
||||
{
|
||||
$source_image = @imagecreatefrompng($source_filepath);
|
||||
}
|
||||
else
|
||||
{
|
||||
die('unsupported file extension');
|
||||
}
|
||||
|
||||
// width/height
|
||||
$source_width = imagesx($source_image);
|
||||
$source_height = imagesy($source_image);
|
||||
|
||||
$ratio_width = $source_width / $max_width;
|
||||
$ratio_height = $source_height / $max_height;
|
||||
|
||||
// maximal size exceeded ?
|
||||
if ($ratio_width > 1 or $ratio_height > 1)
|
||||
{
|
||||
if ($ratio_width < $ratio_height)
|
||||
{
|
||||
$destination_width = ceil($source_width / $ratio_height);
|
||||
$destination_height = $max_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
$destination_width = $max_width;
|
||||
$destination_height = ceil($source_height / $ratio_width);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// the image doesn't need any resize! We just copy it to the destination
|
||||
copy($source_filepath, $destination_filepath);
|
||||
return true;
|
||||
}
|
||||
|
||||
$destination_image = imagecreatetruecolor($destination_width, $destination_height);
|
||||
|
||||
imagecopyresampled(
|
||||
$destination_image,
|
||||
$source_image,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
$destination_width,
|
||||
$destination_height,
|
||||
$source_width,
|
||||
$source_height
|
||||
);
|
||||
|
||||
imagejpeg($destination_image, $destination_filepath, $quality);
|
||||
// freeing memory ressources
|
||||
imagedestroy($source_image);
|
||||
imagedestroy($destination_image);
|
||||
|
||||
// everything should be OK if we are here!
|
||||
return true;
|
||||
}
|
||||
|
||||
function pwg_image_infos($path)
|
||||
{
|
||||
list($width, $height) = getimagesize($path);
|
||||
$filesize = floor(filesize($path)/1024);
|
||||
|
||||
return array(
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'filesize' => $filesize,
|
||||
);
|
||||
}
|
||||
|
||||
function is_valid_image_extension($extension)
|
||||
{
|
||||
return in_array(strtolower($extension), array('jpg', 'jpeg', 'png'));
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load diff
BIN
admin/include/uploadify/cancel.png
Normal file
BIN
admin/include/uploadify/cancel.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 778 B |
26
admin/include/uploadify/jquery.uploadify.v2.1.0.min.js
vendored
Normal file
26
admin/include/uploadify/jquery.uploadify.v2.1.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
admin/include/uploadify/swfobject.js
Normal file
4
admin/include/uploadify/swfobject.js
Normal file
File diff suppressed because one or more lines are too long
60
admin/include/uploadify/uploadify.css
Normal file
60
admin/include/uploadify/uploadify.css
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
Uploadify v2.1.0
|
||||
Release Date: August 24, 2009
|
||||
|
||||
Copyright (c) 2009 Ronnie Garcia, Travis Nickels
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#fileQueue {
|
||||
width: 420px;
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
border: 1px solid #333;
|
||||
margin: 0 auto 10px auto;
|
||||
padding: 5px 0 10px 0;
|
||||
}
|
||||
|
||||
.uploadifyQueueItem {
|
||||
border: 1px solid #666;
|
||||
background-color: #444;
|
||||
color:#999;
|
||||
margin: 5px auto 0 auto;
|
||||
padding: 10px;
|
||||
width: 350px;
|
||||
|
||||
}
|
||||
.uploadifyError {
|
||||
border: 2px solid #FBCBBC !important;
|
||||
background-color: #FDE5DD !important;
|
||||
}
|
||||
.uploadifyQueueItem .cancel {
|
||||
float: right;
|
||||
}
|
||||
.uploadifyProgress {
|
||||
background-color: #333;
|
||||
border: 1px solid #666;
|
||||
margin-top: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
.uploadifyProgressBar {
|
||||
background-color: #FF3363;
|
||||
width: 1px;
|
||||
height: 3px;
|
||||
}
|
||||
44
admin/include/uploadify/uploadify.php
Normal file
44
admin/include/uploadify/uploadify.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
define('PHPWG_ROOT_PATH','../../../');
|
||||
define('IN_ADMIN', true);
|
||||
|
||||
$_COOKIE['pwg_id'] = $_POST['session_id'];
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
|
||||
|
||||
// check_pwg_token();
|
||||
|
||||
ob_start();
|
||||
print_r($_FILES);
|
||||
print_r($_POST);
|
||||
print_r($user);
|
||||
$tmp = ob_get_contents();
|
||||
ob_end_clean();
|
||||
error_log($tmp, 3, "/tmp/php-".date('YmdHis').'-'.sprintf('%020u', rand()).".log");
|
||||
|
||||
$image_id = add_uploaded_file(
|
||||
$_FILES['Filedata']['tmp_name'],
|
||||
$_FILES['Filedata']['name'],
|
||||
null,
|
||||
8
|
||||
);
|
||||
|
||||
if (!isset($_SESSION['uploads']))
|
||||
{
|
||||
$_SESSION['uploads'] = array();
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['uploads'][ $_POST['upload_id'] ]))
|
||||
{
|
||||
$_SESSION['uploads'][ $_POST['upload_id'] ] = array();
|
||||
}
|
||||
|
||||
array_push(
|
||||
$_SESSION['uploads'][ $_POST['upload_id'] ],
|
||||
$image_id
|
||||
);
|
||||
|
||||
echo "1";
|
||||
?>
|
||||
BIN
admin/include/uploadify/uploadify.swf
Normal file
BIN
admin/include/uploadify/uploadify.swf
Normal file
Binary file not shown.
199
admin/photos_add.php
Normal file
199
admin/photos_add.php
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Piwigo - a PHP based picture gallery |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright(C) 2010 Pierrick LE GALL http://piwigo.org |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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!");
|
||||
}
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
|
||||
|
||||
define(
|
||||
'PHOTOS_ADD_BASE_URL',
|
||||
get_root_url().'admin.php?page=photos_add'
|
||||
);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Check Access and exit when user status is not ok |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
check_status(ACCESS_ADMINISTRATOR);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Load configuration |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// automatic fill of configuration parameters
|
||||
$upload_form_config = array(
|
||||
'websize_resize' => array(
|
||||
'default' => true,
|
||||
'can_be_null' => false,
|
||||
),
|
||||
|
||||
'websize_maxwidth' => array(
|
||||
'default' => 800,
|
||||
'min' => 100,
|
||||
'max' => 1600,
|
||||
'pattern' => '/^\d+$/',
|
||||
'can_be_null' => true,
|
||||
'error_message' => 'The websize maximum width must be a number between %d and %d',
|
||||
),
|
||||
|
||||
'websize_maxheight' => array(
|
||||
'default' => 600,
|
||||
'min' => 100,
|
||||
'max' => 1200,
|
||||
'pattern' => '/^\d+$/',
|
||||
'can_be_null' => true,
|
||||
'error_message' => 'The websize maximum height must be a number between %d and %d',
|
||||
),
|
||||
|
||||
'websize_quality' => array(
|
||||
'default' => 95,
|
||||
'min' => 50,
|
||||
'max' => 100,
|
||||
'pattern' => '/^\d+$/',
|
||||
'can_be_null' => false,
|
||||
'error_message' => 'The websize image quality must be a number between %d and %d',
|
||||
),
|
||||
|
||||
'thumb_maxwidth' => array(
|
||||
'default' => 128,
|
||||
'min' => 50,
|
||||
'max' => 300,
|
||||
'pattern' => '/^\d+$/',
|
||||
'can_be_null' => false,
|
||||
'error_message' => 'The thumbnail maximum width must be a number between %d and %d',
|
||||
),
|
||||
|
||||
'thumb_maxheight' => array(
|
||||
'default' => 96,
|
||||
'min' => 50,
|
||||
'max' => 300,
|
||||
'pattern' => '/^\d+$/',
|
||||
'can_be_null' => false,
|
||||
'error_message' => 'The thumbnail maximum height must be a number between %d and %d',
|
||||
),
|
||||
|
||||
'thumb_quality' => array(
|
||||
'default' => 95,
|
||||
'min' => 50,
|
||||
'max' => 100,
|
||||
'pattern' => '/^\d+$/',
|
||||
'can_be_null' => false,
|
||||
'error_message' => 'The thumbnail image quality must be a number between %d and %d',
|
||||
),
|
||||
);
|
||||
|
||||
$inserts = array();
|
||||
|
||||
foreach ($upload_form_config as $param_shortname => $param)
|
||||
{
|
||||
$param_name = 'upload_form_'.$param_shortname;
|
||||
|
||||
if (!isset($conf[$param_name]))
|
||||
{
|
||||
$param_value = boolean_to_string($param['default']);
|
||||
|
||||
array_push(
|
||||
$inserts,
|
||||
array(
|
||||
'param' => $param_name,
|
||||
'value' => $param_value,
|
||||
)
|
||||
);
|
||||
$conf[$param_name] = $param_value;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($inserts) > 0)
|
||||
{
|
||||
mass_inserts(
|
||||
CONFIG_TABLE,
|
||||
array_keys($inserts[0]),
|
||||
$inserts
|
||||
);
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Tabs |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$tabs = array(
|
||||
array(
|
||||
'code' => 'direct',
|
||||
'label' => 'Upload Photos',
|
||||
),
|
||||
array(
|
||||
'code' => 'settings',
|
||||
'label' => 'Settings',
|
||||
)
|
||||
);
|
||||
|
||||
$tab_codes = array_map(
|
||||
create_function('$a', 'return $a["code"];'),
|
||||
$tabs
|
||||
);
|
||||
|
||||
if (isset($_GET['section']) and in_array($_GET['section'], $tab_codes))
|
||||
{
|
||||
$page['tab'] = $_GET['section'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$page['tab'] = $tabs[0]['code'];
|
||||
}
|
||||
|
||||
$tabsheet = new tabsheet();
|
||||
foreach ($tabs as $tab)
|
||||
{
|
||||
$tabsheet->add(
|
||||
$tab['code'],
|
||||
l10n($tab['label']),
|
||||
PHOTOS_ADD_BASE_URL.'&section='.$tab['code']
|
||||
);
|
||||
}
|
||||
$tabsheet->select($page['tab']);
|
||||
$tabsheet->assign();
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | template init |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$template->set_filenames(
|
||||
array(
|
||||
'plugin_admin_content' => 'photos_add_'.$page['tab'].'.tpl'
|
||||
)
|
||||
);
|
||||
|
||||
// $template->append(
|
||||
// 'head_elements',
|
||||
// '<link rel="stylesheet" type="text/css" href="'.UPLOAD_FORM_PATH.'upload.css">'."\n"
|
||||
// );
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Load the tab |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
include(PHPWG_ROOT_PATH.'admin/photos_add_'.$page['tab'].'.php');
|
||||
?>
|
||||
488
admin/photos_add_direct.php
Normal file
488
admin/photos_add_direct.php
Normal file
|
|
@ -0,0 +1,488 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Piwigo - a PHP based picture gallery |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright(C) 2010 Pierrick LE GALL http://piwigo.org |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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('PHOTOS_ADD_BASE_URL'))
|
||||
{
|
||||
die ("Hacking attempt!");
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | batch management request |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (isset($_GET['batch']))
|
||||
{
|
||||
check_input_parameter('batch', $_GET['batch'], false, '/^\d+(,\d+)*$/');
|
||||
|
||||
$query = '
|
||||
DELETE FROM '.CADDIE_TABLE.'
|
||||
WHERE user_id = '.$user['id'].'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
$inserts = array();
|
||||
foreach (explode(',', $_GET['batch']) as $image_id)
|
||||
{
|
||||
array_push(
|
||||
$inserts,
|
||||
array(
|
||||
'user_id' => $user['id'],
|
||||
'element_id' => $image_id,
|
||||
)
|
||||
);
|
||||
}
|
||||
mass_inserts(
|
||||
CADDIE_TABLE,
|
||||
array_keys($inserts[0]),
|
||||
$inserts
|
||||
);
|
||||
|
||||
redirect(get_root_url().'admin.php?page=element_set&cat=caddie');
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | process form |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (isset($_POST['submit_upload']))
|
||||
{
|
||||
// echo '<pre>POST'."\n"; print_r($_POST); echo '</pre>';
|
||||
// echo '<pre>FILES'."\n"; print_r($_FILES); echo '</pre>';
|
||||
// echo '<pre>SESSION'."\n"; print_r($_SESSION); echo '</pre>';
|
||||
// exit();
|
||||
|
||||
$category_id = null;
|
||||
if ('existing' == $_POST['category_type'])
|
||||
{
|
||||
$category_id = $_POST['category'];
|
||||
}
|
||||
elseif ('new' == $_POST['category_type'])
|
||||
{
|
||||
$output_create = create_virtual_category(
|
||||
$_POST['category_name'],
|
||||
(0 == $_POST['category_parent'] ? null : $_POST['category_parent'])
|
||||
);
|
||||
|
||||
$category_id = $output_create['id'];
|
||||
|
||||
if (isset($output_create['error']))
|
||||
{
|
||||
array_push($page['errors'], $output_create['error']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$category_name = get_cat_display_name_from_id($category_id, 'admin.php?page=cat_modify&cat_id=');
|
||||
// information
|
||||
array_push(
|
||||
$page['infos'],
|
||||
sprintf(
|
||||
l10n('Category "%s" has been added'),
|
||||
'<em>'.$category_name.'</em>'
|
||||
)
|
||||
);
|
||||
// TODO: add the onclick="window.open(this.href); return false;"
|
||||
// attribute with jQuery on upload.tpl side for href containing
|
||||
// "cat_modify"
|
||||
}
|
||||
}
|
||||
|
||||
$image_ids = array();
|
||||
|
||||
if (isset($_FILES) and !empty($_FILES['image_upload']))
|
||||
{
|
||||
$starttime = get_moment();
|
||||
|
||||
foreach ($_FILES['image_upload']['error'] as $idx => $error)
|
||||
{
|
||||
if (UPLOAD_ERR_OK == $error)
|
||||
{
|
||||
$images_to_add = array();
|
||||
|
||||
$extension = pathinfo($_FILES['image_upload']['name'][$idx], PATHINFO_EXTENSION);
|
||||
if ('zip' == strtolower($extension))
|
||||
{
|
||||
$upload_dir = PHPWG_ROOT_PATH.'upload/buffer';
|
||||
prepare_directory($upload_dir);
|
||||
|
||||
$temporary_archive_name = date('YmdHis').'-'.generate_key(10);
|
||||
$archive_path = $upload_dir.'/'.$temporary_archive_name.'.zip';
|
||||
|
||||
move_uploaded_file(
|
||||
$_FILES['image_upload']['tmp_name'][$idx],
|
||||
$archive_path
|
||||
);
|
||||
|
||||
define('PCLZIP_TEMPORARY_DIR', $upload_dir.'/');
|
||||
include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
|
||||
$zip = new PclZip($archive_path);
|
||||
if ($list = $zip->listContent())
|
||||
{
|
||||
$indexes_to_extract = array();
|
||||
|
||||
foreach ($list as $node)
|
||||
{
|
||||
if (1 == $node['folder'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_valid_image_extension(pathinfo($node['filename'], PATHINFO_EXTENSION)))
|
||||
{
|
||||
array_push($indexes_to_extract, $node['index']);
|
||||
|
||||
array_push(
|
||||
$images_to_add,
|
||||
array(
|
||||
'source_filepath' => $upload_dir.'/'.$temporary_archive_name.'/'.$node['filename'],
|
||||
'original_filename' => basename($node['filename']),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($indexes_to_extract) > 0)
|
||||
{
|
||||
$zip->extract(
|
||||
PCLZIP_OPT_PATH, $upload_dir.'/'.$temporary_archive_name,
|
||||
PCLZIP_OPT_BY_INDEX, $indexes_to_extract,
|
||||
PCLZIP_OPT_ADD_TEMP_FILE_ON
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (is_valid_image_extension($extension))
|
||||
{
|
||||
array_push(
|
||||
$images_to_add,
|
||||
array(
|
||||
'source_filepath' => $_FILES['image_upload']['tmp_name'][$idx],
|
||||
'original_filename' => $_FILES['image_upload']['name'][$idx],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($images_to_add as $image_to_add)
|
||||
{
|
||||
$image_id = add_uploaded_file(
|
||||
$image_to_add['source_filepath'],
|
||||
$image_to_add['original_filename'],
|
||||
array($category_id),
|
||||
$_POST['level']
|
||||
);
|
||||
|
||||
array_push($image_ids, $image_id);
|
||||
|
||||
// TODO: if $image_id is not an integer, something went wrong
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$endtime = get_moment();
|
||||
$elapsed = ($endtime - $starttime) * 1000;
|
||||
// printf('%.2f ms', $elapsed);
|
||||
|
||||
} // if (!empty($_FILES))
|
||||
|
||||
if (isset($_POST['upload_id']))
|
||||
{
|
||||
// we're on a multiple upload, with uploadify and so on
|
||||
$image_ids = $_SESSION['uploads'][ $_POST['upload_id'] ];
|
||||
|
||||
associate_images_to_categories(
|
||||
$image_ids,
|
||||
array($category_id)
|
||||
);
|
||||
|
||||
$query = '
|
||||
UPDATE '.IMAGES_TABLE.'
|
||||
SET level = '.$_POST['level'].'
|
||||
WHERE id IN ('.implode(', ', $image_ids).')
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
invalidate_user_cache();
|
||||
}
|
||||
|
||||
$page['thumbnails'] = array();
|
||||
foreach ($image_ids as $image_id)
|
||||
{
|
||||
// we could return the list of properties from the add_uploaded_file
|
||||
// function, but I like the "double check". And it costs nothing
|
||||
// compared to the upload process.
|
||||
$thumbnail = array();
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
file,
|
||||
path,
|
||||
tn_ext
|
||||
FROM '.IMAGES_TABLE.'
|
||||
WHERE id = '.$image_id.'
|
||||
;';
|
||||
$image_infos = mysql_fetch_assoc(pwg_query($query));
|
||||
|
||||
$thumbnail['file'] = $image_infos['file'];
|
||||
|
||||
$thumbnail['src'] = get_thumbnail_location(
|
||||
array(
|
||||
'path' => $image_infos['path'],
|
||||
'tn_ext' => $image_infos['tn_ext'],
|
||||
)
|
||||
);
|
||||
|
||||
// TODO: when implementing this plugin in Piwigo core, we should have
|
||||
// a function get_image_name($name, $file) (if name is null, then
|
||||
// compute a temporary name from filename) that would be also used in
|
||||
// picture.php. UPDATE: in fact, "get_name_from_file($file)" already
|
||||
// exists and is used twice (element_set_unit + comments, but not in
|
||||
// picture.php I don't know why) with the same pattern if
|
||||
// (empty($name)) {$name = get_name_from_file($file)}, a clean
|
||||
// function get_image_name($name, $file) would be better
|
||||
$thumbnail['title'] = get_name_from_file($image_infos['file']);
|
||||
|
||||
$thumbnail['link'] = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'
|
||||
.'&image_id='.$image_id
|
||||
.'&cat_id='.$category_id
|
||||
;
|
||||
|
||||
array_push($page['thumbnails'], $thumbnail);
|
||||
}
|
||||
|
||||
if (!empty($page['thumbnails']))
|
||||
{
|
||||
array_push(
|
||||
$page['infos'],
|
||||
sprintf(
|
||||
l10n('%d photos uploaded'),
|
||||
count($page['thumbnails'])
|
||||
)
|
||||
);
|
||||
|
||||
if (0 != $_POST['level'])
|
||||
{
|
||||
array_push(
|
||||
$page['infos'],
|
||||
sprintf(
|
||||
l10n('Privacy level set to "%s"'),
|
||||
l10n(
|
||||
sprintf('Level %d', $_POST['level'])
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ('existing' == $_POST['category_type'])
|
||||
{
|
||||
$query = '
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||
WHERE category_id = '.$category_id.'
|
||||
;';
|
||||
list($count) = mysql_fetch_row(pwg_query($query));
|
||||
$category_name = get_cat_display_name_from_id($category_id, 'admin.php?page=cat_modify&cat_id=');
|
||||
|
||||
// information
|
||||
array_push(
|
||||
$page['infos'],
|
||||
sprintf(
|
||||
l10n('Category "%s" now contains %d photos'),
|
||||
'<em>'.$category_name.'</em>',
|
||||
$count
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$page['batch_link'] = PHOTOS_ADD_BASE_URL.'&batch='.implode(',', $image_ids);
|
||||
}
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | template init |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$uploadify_path = PHPWG_ROOT_PATH.'admin/include/uploadify';
|
||||
|
||||
$template->assign(
|
||||
array(
|
||||
'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL,
|
||||
'uploadify_path' => $uploadify_path,
|
||||
)
|
||||
);
|
||||
|
||||
$upload_modes = array('html', 'multiple');
|
||||
|
||||
$upload_mode = 'multiple';
|
||||
$upload_switch = 'html';
|
||||
if (isset($_GET['upload_mode']) and in_array($_GET['upload_mode'], $upload_modes))
|
||||
{
|
||||
$index_of_upload_mode = array_flip($upload_modes);
|
||||
$upload_mode_index = $index_of_upload_mode[ $_GET['upload_mode'] ];
|
||||
|
||||
$upload_mode = $_GET['upload_mode'];
|
||||
$upload_switch = $upload_modes[ ($upload_mode_index + 1) % 2 ];
|
||||
}
|
||||
|
||||
$template->assign(
|
||||
array(
|
||||
'upload_mode' => $upload_mode,
|
||||
'switch_url' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_switch,
|
||||
'upload_id' => md5(rand()),
|
||||
'session_id' => session_id(),
|
||||
'pwg_token' => '1234abcd5678efgh',// get_pwg_token(),
|
||||
)
|
||||
);
|
||||
|
||||
$template->append(
|
||||
'head_elements',
|
||||
'<link rel="stylesheet" type="text/css" href="'.$uploadify_path.'/uploadify.css">'."\n"
|
||||
);
|
||||
|
||||
if (isset($page['thumbnails']))
|
||||
{
|
||||
$template->assign(
|
||||
array(
|
||||
'thumbnails' => $page['thumbnails'],
|
||||
)
|
||||
);
|
||||
|
||||
// only display the batch link if we have more than 1 photo
|
||||
if (count($page['thumbnails']) > 1)
|
||||
{
|
||||
$template->assign(
|
||||
array(
|
||||
'batch_link' => $page['batch_link'],
|
||||
'batch_label' => sprintf(
|
||||
l10n('Manage this set of %d photos'),
|
||||
count($page['thumbnails'])
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT id,name,uppercats,global_rank
|
||||
FROM '.CATEGORIES_TABLE.'
|
||||
;';
|
||||
|
||||
display_select_cat_wrapper(
|
||||
$query,
|
||||
array(),
|
||||
'category_options'
|
||||
);
|
||||
|
||||
// image level options
|
||||
$tpl_options = array();
|
||||
foreach (array_reverse($conf['available_permission_levels']) as $level)
|
||||
{
|
||||
$label = null;
|
||||
|
||||
if (0 == $level)
|
||||
{
|
||||
$label = l10n('Everybody');
|
||||
}
|
||||
else
|
||||
{
|
||||
$labels = array();
|
||||
$sub_levels = array_reverse($conf['available_permission_levels']);
|
||||
foreach ($sub_levels as $sub_level)
|
||||
{
|
||||
if ($sub_level == 0 or $sub_level < $level)
|
||||
{
|
||||
break;
|
||||
}
|
||||
array_push(
|
||||
$labels,
|
||||
l10n(
|
||||
sprintf(
|
||||
'Level %d',
|
||||
$sub_level
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$label = implode(', ', $labels);
|
||||
}
|
||||
$tpl_options[$level] = $label;
|
||||
}
|
||||
$selected_level = isset($_POST['level']) ? $_POST['level'] : 0;
|
||||
$template->assign(
|
||||
array(
|
||||
'level_options'=> $tpl_options,
|
||||
'level_options_selected' => array($selected_level)
|
||||
)
|
||||
);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | setup errors |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$setup_errors = array();
|
||||
|
||||
$upload_base_dir = 'upload';
|
||||
$upload_dir = PHPWG_ROOT_PATH.$upload_base_dir;
|
||||
|
||||
if (!is_dir($upload_dir))
|
||||
{
|
||||
if (!is_writable(PHPWG_ROOT_PATH))
|
||||
{
|
||||
array_push(
|
||||
$setup_errors,
|
||||
sprintf(
|
||||
l10n('Create the "%s" directory at the root of your Piwigo installation'),
|
||||
$upload_base_dir
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!is_writable($upload_dir))
|
||||
{
|
||||
@chmod($upload_dir, 0777);
|
||||
|
||||
if (!is_writable($upload_dir))
|
||||
{
|
||||
array_push(
|
||||
$setup_errors,
|
||||
sprintf(
|
||||
l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),
|
||||
$upload_base_dir
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign(
|
||||
array(
|
||||
'setup_errors'=> $setup_errors,
|
||||
)
|
||||
);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | sending html code |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
|
||||
?>
|
||||
155
admin/photos_add_settings.php
Normal file
155
admin/photos_add_settings.php
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Piwigo - a PHP based picture gallery |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright(C) 2010 Pierrick LE GALL http://piwigo.org |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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('PHOTOS_ADD_BASE_URL'))
|
||||
{
|
||||
die ("Hacking attempt!");
|
||||
}
|
||||
|
||||
// by default, the form values are the current configuration
|
||||
// we may overwrite them with the current form values
|
||||
$form_values = array();
|
||||
|
||||
foreach ($upload_form_config as $param_shortname => $param)
|
||||
{
|
||||
$param_name = 'upload_form_'.$param_shortname;
|
||||
$form_values[$param_shortname] = $conf[$param_name];
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | process form |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (isset($_POST['submit']))
|
||||
{
|
||||
$updates = array();
|
||||
|
||||
// let's care about the specific checkbox that disable/enable other
|
||||
// settings
|
||||
$field = 'websize_resize';
|
||||
|
||||
if (empty($_POST[$field]))
|
||||
{
|
||||
$value = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$fields[] = 'websize_maxwidth';
|
||||
$fields[] = 'websize_maxheight';
|
||||
$fields[] = 'websize_quality';
|
||||
|
||||
$value = true;
|
||||
}
|
||||
|
||||
$updates[] = array(
|
||||
'param' => 'upload_form_'.$field,
|
||||
'value' => boolean_to_string($value),
|
||||
);
|
||||
$form_values[$field] = $value;;
|
||||
|
||||
// and now other fields, processed in a generic way
|
||||
$fields[] = 'thumb_maxwidth';
|
||||
$fields[] = 'thumb_maxheight';
|
||||
$fields[] = 'thumb_quality';
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$value = null;
|
||||
if (!empty($_POST[$field]))
|
||||
{
|
||||
$value = $_POST[$field];
|
||||
}
|
||||
$form_values[$field] = $value;
|
||||
|
||||
if ($upload_form_config[$field]['can_be_null'] and empty($value))
|
||||
{
|
||||
$updates[] = array(
|
||||
'param' => 'upload_form_'.$field,
|
||||
'value' => 'false'
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$min = $upload_form_config[$field]['min'];
|
||||
$max = $upload_form_config[$field]['max'];
|
||||
$pattern = $upload_form_config[$field]['pattern'];
|
||||
|
||||
if (preg_match($pattern, $value) and $value >= $min and $value <= $max)
|
||||
{
|
||||
$updates[] = array(
|
||||
'param' => 'upload_form_'.$field,
|
||||
'value' => $value
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push(
|
||||
$page['errors'],
|
||||
sprintf(
|
||||
l10n($upload_form_config[$field]['error_message']),
|
||||
$min,
|
||||
$max
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($page['errors']) == 0)
|
||||
{
|
||||
mass_updates(
|
||||
CONFIG_TABLE,
|
||||
array(
|
||||
'primary' => array('param'),
|
||||
'update' => array('value')
|
||||
),
|
||||
$updates
|
||||
);
|
||||
|
||||
array_push(
|
||||
$page['infos'],
|
||||
l10n('Your configuration settings are saved')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | template init |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// specific case, "websize_resize" is a checkbox
|
||||
$field = 'websize_resize';
|
||||
$form_values[$field] = $form_values[$field] ? 'checked="checked"' : '';
|
||||
|
||||
$template->assign(
|
||||
array(
|
||||
'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL,
|
||||
'values' => $form_values
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | sending html code |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
|
||||
?>
|
||||
|
|
@ -58,6 +58,7 @@ jQuery().ready(function(){ldelim}
|
|||
<dt class="rdion"><span>{'Pictures'|@translate} </span></dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li><a href="{$U_ADD_PHOTOS}">{'Add'|@translate}</a></li>
|
||||
<li><a href="{$U_WAITING}">{'Waiting'|@translate}</a></li>
|
||||
<li><a href="{$U_THUMBNAILS}">{'Thumbnails'|@translate}</a></li>
|
||||
<li><a href="{$U_RATING}">{'Rating'|@translate}</a></li>
|
||||
|
|
|
|||
|
|
@ -498,4 +498,53 @@ ul.holder li.bit-box-focus a.closebutton, ul.holder li.bit-box-focus a.closebutt
|
|||
.hidden { display:none;}
|
||||
|
||||
#demo ul.holder li.bit-input input { padding: 2px 0 1px; border: 1px solid #999; }
|
||||
.ie6fix {height:1px;width:1px; position:absolute;top:0px;left:0px;z-index:1;}
|
||||
.ie6fix {height:1px;width:1px; position:absolute;top:0px;left:0px;z-index:1;}
|
||||
|
||||
/* Add photos, direct mode */
|
||||
#uploadBoxes P {
|
||||
margin:0;
|
||||
margin-bottom:2px;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
#batchLink {
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.category_selection {
|
||||
min-height:65px;
|
||||
margin-top:5px;
|
||||
}
|
||||
|
||||
.category_selection TABLE {
|
||||
margin:0;
|
||||
}
|
||||
|
||||
.formField {
|
||||
width:650px;
|
||||
margin:0 auto 20px auto;
|
||||
padding:10px;
|
||||
border: 2px solid #292929;
|
||||
}
|
||||
|
||||
.formFieldTitle {
|
||||
font-weight:bold;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
|
||||
.formField P {
|
||||
margin:0;
|
||||
}
|
||||
|
||||
.formField TH {
|
||||
text-align:right;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
#uploadFormSettings input[type="text"] {
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
#uploadFormSettings TH {
|
||||
width:50%;
|
||||
}
|
||||
185
admin/template/goto/photos_add_direct.tpl
Normal file
185
admin/template/goto/photos_add_direct.tpl
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
{known_script id="jquery" src=$ROOT_URL|@cat:"template-common/lib/jquery.packed.js"}
|
||||
|
||||
{literal}
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
|
||||
$("input[name=category_type]").click(function () {
|
||||
$("[id^=category_type_]").hide();
|
||||
$("#category_type_"+$(this).attr("value")).show();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
{if $upload_mode eq 'html'}
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
function addUploadBox() {
|
||||
var uploadBox = '<p class="file"><input type="file" size="60" name="image_upload[]" /></p>';
|
||||
$(uploadBox).appendTo("#uploadBoxes");
|
||||
}
|
||||
|
||||
addUploadBox();
|
||||
|
||||
$("#addUploadBox A").click(function () {
|
||||
addUploadBox();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
{elseif $upload_mode eq 'multiple'}
|
||||
<script type="text/javascript" src="{$uploadify_path}/swfobject.js"></script>
|
||||
<script type="text/javascript" src="{$uploadify_path}/jquery.uploadify.v2.1.0.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var uploadify_path = '{$uploadify_path}';
|
||||
var upload_id = '{$upload_id}';
|
||||
var session_id = '{$session_id}';
|
||||
var pwg_token = '{$pwg_token}';
|
||||
var buttonText = 'Browse';
|
||||
|
||||
{literal}
|
||||
jQuery(document).ready(function() {
|
||||
jQuery("#uploadify").uploadify({
|
||||
'uploader' : uploadify_path + '/uploadify.swf',
|
||||
'script' : uploadify_path + '/uploadify.php',
|
||||
'scriptData' : {
|
||||
'upload_id' : upload_id,
|
||||
'session_id' : session_id,
|
||||
'pwg_token' : pwg_token,
|
||||
},
|
||||
'cancelImg' : uploadify_path + '/cancel.png',
|
||||
'queueID' : 'fileQueue',
|
||||
'auto' : false,
|
||||
'displayData' : 'speed',
|
||||
'buttonText' : buttonText,
|
||||
'multi' : true,
|
||||
'onAllComplete' : function(event, data) {
|
||||
if (data.errors) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$("input[name=submit_upload]").click();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
{/literal}
|
||||
</script>
|
||||
{/if}
|
||||
|
||||
<div class="titrePage" style="height:25px">
|
||||
<h2>{'Upload photos'|@translate}</h2>
|
||||
</div>
|
||||
|
||||
{if count($setup_errors) > 0}
|
||||
<div class="errors">
|
||||
<ul>
|
||||
{foreach from=$setup_errors item=error}
|
||||
<li>{$error}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
{else}
|
||||
|
||||
{if !empty($thumbnails)}
|
||||
<fieldset>
|
||||
<legend>{'Uploaded Photos'|@translate}</legend>
|
||||
<div>
|
||||
{foreach from=$thumbnails item=thumbnail}
|
||||
<a href="{$thumbnail.link}" onclick="window.open(this.href); return false;">
|
||||
<img src="{$thumbnail.src}" alt="{$thumbnail.file}" title="{$thumbnail.title}" class="thumbnail">
|
||||
</a>
|
||||
{/foreach}
|
||||
</div>
|
||||
<p id="batchLink"><a href="{$batch_link}">{$batch_label}</a></p>
|
||||
</fieldset>
|
||||
{/if}
|
||||
|
||||
|
||||
<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$F_ACTION}" class="properties">
|
||||
{if $upload_mode eq 'multiple'}
|
||||
<input name="upload_id" value="{$upload_id}" type="hidden">
|
||||
{/if}
|
||||
|
||||
<div class="formField">
|
||||
<div class="formFieldTitle">{'Drop into category'|@translate}</div>
|
||||
|
||||
<label><input type="radio" name="category_type" value="existing"> {'existing category'|@translate}</label>
|
||||
<label><input type="radio" name="category_type" value="new" checked="checked"> {'create a new category'|@translate}</label>
|
||||
|
||||
<div id="category_type_existing" style="display:none" class="category_selection">
|
||||
<select class="categoryDropDown" name="category">
|
||||
{html_options options=$category_options}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="category_type_new" class="category_selection">
|
||||
<table>
|
||||
<tr>
|
||||
<td>{'Parent category'|@translate}</td>
|
||||
<td>
|
||||
<select class="categoryDropDown" name="category_parent">
|
||||
<option value="0">------------</option>
|
||||
{html_options options=$category_options}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{'Category name'|@translate}</td>
|
||||
<td>
|
||||
<input type="text" name="category_name" value="{$F_CATEGORY_NAME}" style="width:400px">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="formField">
|
||||
<div class="formFieldTitle">{'Who can see these photos?'|@translate}</div>
|
||||
|
||||
<select name="level" size="1">
|
||||
{html_options options=$level_options selected=$level_options_selected}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="formField">
|
||||
<div class="formFieldTitle">{'Select files'|@translate}</div>
|
||||
|
||||
{if $upload_mode eq 'html'}
|
||||
<p><a href="{$switch_url}">{'... or switch to the multiple files form'|@translate}</a></p>
|
||||
|
||||
<p>{'JPEG files or ZIP archives with JPEG files inside please.'|@translate}</p>
|
||||
|
||||
<div id="uploadBoxes"></div>
|
||||
<div id="addUploadBox">
|
||||
<a href="javascript:">{'+ Add an upload box'|@translate}</a>
|
||||
</div>
|
||||
|
||||
</div> <!-- formField -->
|
||||
|
||||
<p>
|
||||
<input class="submit" type="submit" name="submit_upload" value="{'Upload'|@translate}" {$TAG_INPUT_ENABLED}/>
|
||||
</p>
|
||||
{elseif $upload_mode eq 'multiple'}
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<input type="file" name="uploadify" id="uploadify" />
|
||||
</p>
|
||||
|
||||
<p><a href="{$switch_url}">{'... or switch to the old style form'|@translate}</a></p>
|
||||
|
||||
<div id="fileQueue"></div>
|
||||
|
||||
</div> <!-- formField -->
|
||||
<p>
|
||||
<input class="submit" type="button" value="{'Upload'|@translate}" onclick="javascript:jQuery('#uploadify').uploadifyUpload()"/>
|
||||
<input type="submit" name="submit_upload" style="display:none"/>
|
||||
</p>
|
||||
{/if}
|
||||
</form>
|
||||
{/if}
|
||||
74
admin/template/goto/photos_add_settings.tpl
Normal file
74
admin/template/goto/photos_add_settings.tpl
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
{literal}
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
function toggleResizeFields() {
|
||||
var checkbox = $("#websize_resize");
|
||||
var needToggle = $("input[name^=websize_]").not(checkbox).parents('tr');
|
||||
|
||||
if ($(checkbox).is(':checked')) {
|
||||
needToggle.show();
|
||||
}
|
||||
else {
|
||||
needToggle.hide();
|
||||
}
|
||||
}
|
||||
|
||||
toggleResizeFields();
|
||||
$("#websize_resize").click(function () {toggleResizeFields()});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
<div class="titrePage" style="height:25px">
|
||||
<h2>{'Upload Photos'|@translate}</h2>
|
||||
</div>
|
||||
|
||||
<form id="uploadFormSettings" enctype="multipart/form-data" method="post" action="{$F_ACTION}" class="properties">
|
||||
|
||||
<div class="formField">
|
||||
<div class="formFieldTitle">{'Web size photo'|@translate}</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th><label for="websize_resize">{'Resize'|@translate}</label></th>
|
||||
<td><input type="checkbox" name="websize_resize" id="websize_resize" {$values.websize_resize}></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{'Maximum Width'|@translate}</th>
|
||||
<td><input type="text" name="websize_maxwidth" value="{$values.websize_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{'Maximum Height'|@translate}</th>
|
||||
<td><input type="text" name="websize_maxheight" value="{$values.websize_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{'Image Quality'|@translate}</th>
|
||||
<td><input type="text" name="websize_quality" value="{$values.websize_quality}" size="3" maxlength="3"> %</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="formField">
|
||||
<div class="formFieldTitle">{'Thumbnail'|@translate}</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>{'Maximum Width'|@translate}</th>
|
||||
<td><input type="text" name="thumb_maxwidth" value="{$values.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{'Maximum Height'|@translate}</th>
|
||||
<td><input type="text" name="thumb_maxheight" value="{$values.thumb_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{'Image Quality'|@translate}</th>
|
||||
<td><input type="text" name="thumb_quality" value="{$values.thumb_quality}" size="3" maxlength="3"> %</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<input class="submit" type="submit" name="submit" value="{'Save Settings'|@translate}"/>
|
||||
</p>
|
||||
|
||||
</form>
|
||||
Loading…
Add table
Add a link
Reference in a new issue