aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--action.php18
-rw-r--r--admin/include/functions.php13
-rw-r--r--admin/picture_modify.php8
-rw-r--r--admin/themes/default/template/picture_modify.tpl12
-rw-r--r--include/derivative.inc.php3
-rw-r--r--include/functions.inc.php14
-rw-r--r--include/functions_picture.inc.php153
-rw-r--r--include/functions_url.inc.php34
-rw-r--r--include/ws_functions.inc.php5
-rw-r--r--picture.php34
-rw-r--r--themes/default/template/picture_content.tpl9
-rw-r--r--tools/triggers_list.php6
12 files changed, 86 insertions, 223 deletions
diff --git a/action.php b/action.php
index e75f60aec..4099538d7 100644
--- a/action.php
+++ b/action.php
@@ -60,7 +60,7 @@ function do_error( $code, $str )
if (!isset($_GET['id'])
or !is_numeric($_GET['id'])
or !isset($_GET['part'])
- or !in_array($_GET['part'], array('t','e','i','h') ) )
+ or !in_array($_GET['part'], array('e','r') ) )
{
do_error(400, 'Invalid request - id/part');
}
@@ -102,21 +102,15 @@ include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
$file='';
switch ($_GET['part'])
{
- case 't':
- $file = get_thumbnail_path($element_info);
- break;
case 'e':
- $file = get_element_path($element_info);
- break;
- case 'i':
- $file = get_image_path($element_info);
- break;
- case 'h':
if ( $user['enabled_high']!='true' )
{
do_error(401, 'Access denied h');
}
- $file = get_high_path($element_info);
+ $file = get_element_path($element_info);
+ break;
+ case 'r':
+ $file = original_to_representative( get_element_path($element_info), $element_info['representative_ext'] );
break;
}
@@ -175,7 +169,7 @@ if (!isset($ctype))
$http_headers[] = 'Content-Type: '.$ctype;
-if (!isset($_GET['view']))
+if (isset($_GET['download']))
{
$http_headers[] = 'Content-Disposition: attachment; filename="'.$element_info['file'].'";';
$http_headers[] = 'Content-Transfer-Encoding: binary';
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 0669c8d6d..59e59e5c2 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -200,21 +200,12 @@ SELECT
$files = array();
$files[] = get_element_path($row);
- if (!empty($row['tn_ext']))
- {
- $files[] = get_thumbnail_path($row);
- }
-
- if (!empty($row['has_high']) and get_boolean($row['has_high']))
- {
- $files[] = get_high_path($row);
- }
-
+
if (!empty($row['representative_ext']))
{
$pi = pathinfo($row['path']);
$file_wo_ext = get_filename_wo_extension($pi['basename']);
- $files[] = PHPWG_ROOT_PATH.$pi['dirname'].'/pwg_representative/'.$file_wo_ext.'.'.$row['representative_ext'];
+ $files[] = original_to_representative( $files[0], $row['representative_ext']);
}
$ok = true;
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
index a4bde5179..3f4cda248 100644
--- a/admin/picture_modify.php
+++ b/admin/picture_modify.php
@@ -303,14 +303,6 @@ $template->assign(
)
);
-if ($row['has_high'] == 'true')
-{
- $template->assign(array(
- 'HIGH_FILESIZE' => isset($row['high_filesize']) ? $row['high_filesize'].' KB' : l10n('unknown'),
- 'HIGH_DIMENSIONS' => isset($row['high_width']) ? $row['high_width'].' * '.$row['high_height'] : l10n('unknown'),
- ));
-}
-
// image level options
$selected_level = isset($_POST['level']) ? $_POST['level'] : $row['level'];
$template->assign(
diff --git a/admin/themes/default/template/picture_modify.tpl b/admin/themes/default/template/picture_modify.tpl
index 943c11253..cddd1ba78 100644
--- a/admin/themes/default/template/picture_modify.tpl
+++ b/admin/themes/default/template/picture_modify.tpl
@@ -66,18 +66,6 @@ pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#da
<td>{$FILESIZE}</td>
</tr>
-{if isset($HIGH_FILESIZE) }
- <tr>
- <td><strong>{'High dimensions'|@translate}</strong></td>
- <td>{$HIGH_DIMENSIONS}</td>
- </tr>
-
- <tr>
- <td><strong>{'High filesize'|@translate}</strong></td>
- <td>{$HIGH_FILESIZE}</td>
- </tr>
-{/if}
-
<tr>
<td><strong>{'Storage album'|@translate}</strong></td>
<td>{$STORAGE_CATEGORY}</td>
diff --git a/include/derivative.inc.php b/include/derivative.inc.php
index 282b500ec..0c888f693 100644
--- a/include/derivative.inc.php
+++ b/include/derivative.inc.php
@@ -138,9 +138,8 @@ final class DerivativeImage
return get_root_url().$rel_url;
}
- static function get_all($infos)
+ static function get_all($src_image)
{
- $src_image = new SrcImage($infos);
$ret = array();
foreach (ImageStdParams::get_defined_type_map() as $type => $params)
{
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 80b25281b..0871f8110 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -740,6 +740,20 @@ function original_to_representative($path, $representative_ext)
return substr_replace($path, $representative_ext, $pos+1);
}
+/**
+ * @param element_info array containing element information from db;
+ * at least 'id', 'path' should be present
+ */
+function get_element_path($element_info)
+{
+ $path = $element_info['path'];
+ if ( !url_is_remote($path) )
+ {
+ $path = PHPWG_ROOT_PATH.$path;
+ }
+ return $path;
+}
+
/* Returns the PATH to the thumbnail to be displayed. If the element does not
* have a thumbnail, the default mime image path is returned. The PATH can be
diff --git a/include/functions_picture.inc.php b/include/functions_picture.inc.php
index 3eb90af0b..85de60b14 100644
--- a/include/functions_picture.inc.php
+++ b/include/functions_picture.inc.php
@@ -21,48 +21,6 @@
// | USA. |
// +-----------------------------------------------------------------------+
-/**
- * @param element_info array containing element information from db;
- * at least 'id', 'path' should be present
- */
-function get_element_path($element_info)
-{
- $path = get_element_location($element_info);
- if ( !url_is_remote($path) )
- {
- $path = PHPWG_ROOT_PATH.$path;
- }
- return $path;
-}
-
-/*
- * @param element_info array containing element information from db;
- * at least 'id', 'path' should be present
- */
-function get_element_url($element_info)
-{
- $url = get_element_location($element_info);
- if ( !url_is_remote($url) )
- {
- $url = embellish_url(get_root_url().$url);
- }
- // plugins want another url ?
- return trigger_event('get_element_url', $url, $element_info);
-}
-
-/**
- * Returns the relative path of the element with regards to to the root
- * of PWG (not the current page). This function is not intended to be
- * called directly from code.
- * @param element_info array containing element information from db;
- * at least 'id', 'path' should be present
- */
-function get_element_location($element_info)
-{
- // maybe a cached watermark ?
- return trigger_event('get_element_location',
- $element_info['path'], $element_info);
-}
/*
@@ -83,100 +41,6 @@ function get_image_name($name, $filename)
}
}
-
-/**
- * Returns the PATH to the image to be displayed in the picture page. If the
- * element is not a picture, then the representative image or the default
- * mime image. The path can be used in the php script, but not sent to the
- * browser.
- * @param element_info array containing element information from db;
- * at least 'id', 'path', 'representative_ext' should be present
- */
-function get_image_path($element_info)
-{
- global $conf;
- $ext = get_extension($element_info['path']);
- if (in_array($ext, $conf['picture_ext']))
- {
- if (isset($element_info['element_path']) )
- {
- return $element_info['element_path'];
- }
- return get_element_path($element_info);
- }
-
- $path = get_image_location($element_info);
- if ( !url_is_remote($path) )
- {
- $path = PHPWG_ROOT_PATH.$path;
- }
- return $path;
-}
-
-/**
- * Returns the URL of the image to be displayed in the picture page. If the
- * element is not a picture, then the representative image or the default
- * mime image. The URL can't be used in the php script, but can be sent to the
- * browser.
- * @param element_info array containing element information from db;
- * at least 'id', 'path', 'representative_ext' should be present
- */
-function get_image_url($element_info)
-{
- global $conf;
- $ext = get_extension($element_info['path']);
- if (in_array($ext, $conf['picture_ext']))
- {
- if (isset($element_info['element_url']) )
- {
- return $element_info['element_url'];
- }
- return get_element_url($element_info);
- }
-
- $url = get_image_location($element_info);
- if ( !url_is_remote($url) )
- {
- $url = embellish_url(get_root_url().$url);
- }
- return $url;
-}
-
-/**
- * Returns the relative path of the image (element/representative/mimetype)
- * with regards to the root of PWG (not the current page). This function
- * is not intended to be called directly from code.
- * @param element_info array containing element information from db;
- * at least 'id', 'path', 'representative_ext' should be present
- */
-function get_image_location($element_info)
-{
- if (isset($element_info['representative_ext'])
- and $element_info['representative_ext'] != '')
- {
- $pi = pathinfo($element_info['path']);
- $file_wo_ext = get_filename_wo_extension($pi['basename']);
- $path =
- $pi['dirname'].'/pwg_representative/'
- .$file_wo_ext.'.'.$element_info['representative_ext'];
- }
- else
- {
- $ext = get_extension($element_info['path']);
- $path = get_themeconf('mime_icon_dir');
- $path.= strtolower($ext).'.png';
- if ( !file_exists(PHPWG_ROOT_PATH.$path)
- and !empty($element_info['tn_ext']) )
- {
- $path = get_thumbnail_location($element_info);
- }
- }
-
- // plugins want another location ?
- return trigger_event( 'get_image_location', $path, $element_info);
-}
-
-
/*
* @param element_info array containing element information from db;
* at least 'id', 'path', 'has_high' should be present
@@ -222,23 +86,6 @@ function get_high_location($element_info)
}
-/**
- * @param what_part string one of 't' (thumbnail), 'e' (element), 'i' (image),
- * 'h' (high resolution image)
- * @param element_info array containing element information from db;
- * at least 'id', 'path' should be present
- */
-function get_download_url($what_part, $element_info)
-{
- $url = get_root_url().'action.php';
- $url = add_url_params($url,
- array(
- 'id' => $element_info['id'],
- 'part' => $what_part,
- )
- );
- return trigger_event( 'get_download_url', $url, $element_info);
-}
/*
* get slideshow default params into array
diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php
index d290e3da1..c395f3541 100644
--- a/include/functions_url.inc.php
+++ b/include/functions_url.inc.php
@@ -660,6 +660,40 @@ function parse_well_known_params_url($tokens, &$i)
return $page;
}
+
+/**
+ * @param id image id
+ * @param what_part string one of 'e' (element), 'r' (representative)
+ */
+function get_action_url($id, $what_part, $download)
+{
+ $params = array(
+ 'id' => $id,
+ 'part' => $what_part,
+ );
+ if ($download)
+ {
+ $params['download'] = null;
+ }
+
+ return add_url_params(get_root_url().'action.php', $params);
+}
+
+/*
+ * @param element_info array containing element information from db;
+ * at least 'id', 'path' should be present
+ */
+function get_element_url($element_info)
+{
+ $url = $element_info['path'];
+ if ( !url_is_remote($url) )
+ {
+ $url = embellish_url(get_root_url().$url);
+ }
+ return $url;
+}
+
+
/**
* Indicate to build url with full path
*
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 2c14feac4..b0ac24362 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -147,13 +147,16 @@ function ws_std_image_sql_order( $params, $tbl_name='' )
function ws_std_get_urls($image_row)
{
$ret = array();
+
+ $src_image = new SrcImage($image_row);
+
global $user;
if ($user['enabled_high'])
{
$ret['element_url'] = get_element_url($image_row);
}
- $derivatives = DerivativeImage::get_all($image_row);
+ $derivatives = DerivativeImage::get_all($src_image);
$derivatives_arr = array();
foreach($derivatives as $type=>$derivative)
{
diff --git a/picture.php b/picture.php
index 57f4e9fed..7f5878e60 100644
--- a/picture.php
+++ b/picture.php
@@ -162,7 +162,8 @@ function default_picture_content($content, $element_info)
$deriv_type = pwg_get_session_var('picture_deriv', IMG_LARGE);
$selected_derivative = $element_info['derivatives'][$deriv_type];
- $available_derivatives = array();
+ $unique_derivatives = array();
+ $show_original = isset($element_info['element_url']);
$added = array();
foreach($element_info['derivatives'] as $type => $derivative)
{
@@ -170,14 +171,20 @@ function default_picture_content($content, $element_info)
if (isset($added[$url]))
continue;
$added[$url] = 1;
- $available_derivatives[] = $type;
+ $show_original &= !($derivative->same_as_source());
+ $unique_derivatives[$type]= $derivative;
}
- global $user, $page, $template;
+ global $page, $template;
+ if ($show_original)
+ {
+ $template->assign( 'U_ORIGINAL', $element_info['element_url'] );
+ }
+
$template->append('current', array(
'selected_derivative' => $selected_derivative,
- 'available_derivative_types' => $available_derivatives,
+ 'unique_derivatives' => $unique_derivatives,
), true);
@@ -491,27 +498,24 @@ while ($row = pwg_db_fetch_assoc($result))
$i = 'current';
}
-
-
- $row['derivatives'] = DerivativeImage::get_all($row);
- $row['src_image'] = $row['derivatives'][IMG_THUMB]->src_image;
+ $row['src_image'] = new SrcImage($row);
+ $row['derivatives'] = DerivativeImage::get_all($row['src_image']);
- // ------ build element_path and element_url
- $row['element_path'] = get_element_path($row);
- $row['element_url'] = get_element_url($row);
-
if ($i=='current')
{
+ $row['element_path'] = get_element_path($row);
+
if ( $row['src_image']->is_original() )
- {
+ {// we have a photo
if ( $user['enabled_high']=='true' )
{
- $row['download_url'] = get_download_url('e',$row);
+ $row['element_url'] = $row['src_image']->get_url();
+ $row['download_url'] = get_action_url($row['id'], 'e', true);
}
}
else
{ // not a pic - need download link
- $row['download_url'] = $row['element_url'];
+ $row['download_url'] = $row['element_url'] = get_element_url($row);;
}
}
diff --git a/themes/default/template/picture_content.tpl b/themes/default/template/picture_content.tpl
index 6fc743a02..47dcd5560 100644
--- a/themes/default/template/picture_content.tpl
+++ b/themes/default/template/picture_content.tpl
@@ -2,7 +2,7 @@
{if isset($COMMENT_IMG)}
title="{$COMMENT_IMG|@strip_tags:false|@replace:'"':' '}" {else} title="{$current.TITLE|@replace:'"':' '} - {$ALT_IMG}"
{/if}>
-{if count($current.available_derivative_types)>1}
+{if count($current.unique_derivatives)>1}
{footer_script}{literal}
function changeImgSrc(url,type,display)
{
@@ -34,8 +34,11 @@ function toggleDerivativeSwitchBox()
{/literal}{/footer_script}
<a id="derivativeSwitchLink" onclick="toggleDerivativeSwitchBox()" style="cursor:pointer">{$current.selected_derivative->get_type()|@translate}</a>
<div id="derivativeSwitchBox" onclick="toggleDerivativeSwitchBox()" style="display:none">
-{foreach from=$current.available_derivative_types item=derivative_type}
-<a onclick="changeImgSrc('{$current.derivatives[$derivative_type]->get_url()|@escape:javascript}', '{$derivative_type}', '{$derivative_type|@translate|@escape:javascript}')" style="cursor:pointer">{$derivative_type|@translate} ({$current.derivatives[$derivative_type]->get_size_hr()})</a><br>
+{foreach from=$current.unique_derivatives item=derivative key=derivative_type}
+<a href="javascript:changeImgSrc('{$derivative->get_url()|@escape:javascript}', '{$derivative_type}', '{$derivative->get_type()|@translate|@escape:javascript}')" style="cursor:pointer">{$derivative->get_type()|@translate} ({$derivative->get_size_hr()})</a><br>
{/foreach}
+{if isset($U_ORIGINAL)}
+<a href="javascript:phpWGOpenWindow('{$U_ORIGINAL}','xxx','scrollbars=yes,toolbar=no,status=no,resizable=yes')" title="{'Click on the photo to see it in high definition'|@translate}">{'original'|@translate}</a>
+{/if}
</div>
{/if} \ No newline at end of file
diff --git a/tools/triggers_list.php b/tools/triggers_list.php
index 769971bff..f23f3c10b 100644
--- a/tools/triggers_list.php
+++ b/tools/triggers_list.php
@@ -161,12 +161,6 @@ array(
'files' => array('include\functions_picture.inc.php (get_download_url'),
),
array(
- 'name' => 'get_element_location',
- 'type' => 'trigger_event',
- 'vars' => array('string' => 'path', 'array' => 'element_info'),
- 'files' => array('include\functions_picture.inc.php (get_element_location)'),
-),
-array(
'name' => 'get_element_metadata_available',
'type' => 'trigger_event',
'vars' => array('bool' => '', 'string' => 'element_path'),