diff options
-rw-r--r-- | admin/remote_site.php | 3 | ||||
-rw-r--r-- | category.php | 32 | ||||
-rw-r--r-- | include/functions.inc.php | 9 | ||||
-rw-r--r-- | include/functions_category.inc.php | 37 | ||||
-rw-r--r-- | install/db/5-database.php | 50 | ||||
-rw-r--r-- | install/phpwebgallery_structure.sql | 7 | ||||
-rw-r--r-- | language/en_UK.iso-8859-1/common.lang.php | 4 | ||||
-rw-r--r-- | language/fr_FR.iso-8859-1/common.lang.php | 2 | ||||
-rw-r--r-- | picture.php | 73 | ||||
-rw-r--r-- | profile.php | 2 | ||||
-rw-r--r-- | template/yoga/category.tpl | 10 | ||||
-rw-r--r-- | template/yoga/content.css | 2 | ||||
-rw-r--r-- | template/yoga/header.tpl | 3 | ||||
-rw-r--r-- | template/yoga/picture.tpl | 3 | ||||
-rw-r--r-- | tools/create_listing_file.php | 37 |
15 files changed, 229 insertions, 45 deletions
diff --git a/admin/remote_site.php b/admin/remote_site.php index 1ce1813a2..86fd6383f 100644 --- a/admin/remote_site.php +++ b/admin/remote_site.php @@ -409,6 +409,7 @@ SELECT file 'keywords', 'name', 'comment', + 'has_high', 'path'); foreach ($optional_atts as $att) { @@ -425,7 +426,7 @@ SELECT file { $dbfields = array('file','storage_category_id','date_available','tn_ext', 'filesize','width','height','date_creation','author', - 'keywords','name','comment','path'); + 'keywords','name','comment','has_high','path'); mass_inserts(IMAGES_TABLE, $dbfields, $inserts); $counts{'new_elements'}+= count($inserts); diff --git a/category.php b/category.php index 5889f505c..323a1975c 100644 --- a/category.php +++ b/category.php @@ -406,6 +406,38 @@ if ( isset ( $page['cat'] ) ) array('COMMENTS' => $page['comment']) ); } + if ($page['cat_nb_images']>0 and + $page['cat'] != 'most_visited' and $page['cat'] != 'best_rated') + { + // image order + $template->assign_block_vars( 'preferred_image_order', array() ); + + if ( isset($_GET['image_order']) ) + { + $order_idx = $_GET['image_order']; + } + else + { + $order_idx = isset($_COOKIE['pwg_image_order']) ? + $_COOKIE['pwg_image_order'] : 0; + } + + $orders = get_category_preferred_image_orders(); + for ( $i = 0; $i < count($orders); $i++) + { + if ($orders[$i][2]) + { + $url = PHPWG_ROOT_PATH.'category.php' + .get_query_string_diff(array('image_order')); + $url .= '&image_order='.$i; + $template->assign_block_vars( 'preferred_image_order.order', array( + 'DISPLAY' => $orders[$i][0], + 'URL' => $url, + 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : '' ), + ) ); + } + } + } } //------------------------------------------------------------ log informations pwg_log( 'category', $page['title'] ); diff --git a/include/functions.inc.php b/include/functions.inc.php index 511da391a..28be6dd2a 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -533,6 +533,15 @@ function get_query_string_diff($rejects = array()) return $query_string; } +function url_is_remote($url) +{ + if (preg_match('/^https?:\/\/[~\/\.\w-]+$/', $url)) + { + return true; + } + return false; +} + /** * returns available templates/themes */ diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index c9fee76f0..908f297d6 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -318,6 +318,20 @@ SELECT galleries_url return $row['galleries_url']; } +// returns an array of image orders available for users/visitors +function get_category_preferred_image_orders() +{ + global $lang, $conf; + return array( + array('Default', '', true), + array($lang['best_rated_cat'], 'average_rate DESC', $conf['rate']), + array($lang['most_visited_cat'], 'hit DESC', true), + array($lang['Creation date'], 'date_creation DESC', true), + array($lang['Availability date'], 'date_available DESC', true) + ); +} + + // initialize_category initializes ;-) the variables in relation // with category : // 1. calculation of the number of pictures in the category @@ -603,6 +617,29 @@ SELECT COUNT(DISTINCT(id)) AS count create_navigation_bar( $url, $page['cat_nb_images'], $page['start'], $user['nb_image_page'], 'back' ); } + + if ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated') + { + $available_image_orders = get_category_preferred_image_orders(); + + $order_idx=0; + if ( isset($_GET['image_order']) ) + { + $order_idx = $_GET['image_order']; + setcookie( 'pwg_image_order', $order_idx, 0 ); + } + else if ( isset($_COOKIE['pwg_image_order']) ) + { + $order_idx = $_COOKIE['pwg_image_order']; + } + + if ( $order_idx > 0 ) + { + $order = $available_image_orders[$order_idx][1]; + $conf['order_by'] = str_replace('ORDER BY ', 'ORDER BY '.$order.',', + $conf['order_by'] ); + } + } } else { diff --git a/install/db/5-database.php b/install/db/5-database.php new file mode 100644 index 000000000..0dc2006d0 --- /dev/null +++ b/install/db/5-database.php @@ -0,0 +1,50 @@ +<?php +// +-----------------------------------------------------------------------+ +// | PhpWebGallery - a PHP based picture gallery | +// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | +// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | +// +-----------------------------------------------------------------------+ +// | branch : BSF (Best So Far) +// | file : $RCSfile$ +// | last update : $Date: 2005-09-21 00:04:57 +0200 (mer, 21 sep 2005) $ +// | last modifier : $Author: plg $ +// | revision : $Revision: 870 $ +// +-----------------------------------------------------------------------+ +// | 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!'); +} + +$upgrade_description = 'Update images table with has_high column'; + +// +-----------------------------------------------------------------------+ +// | Upgrade content | +// +-----------------------------------------------------------------------+ + +// column user_id becomes data of type text +$query = " +ALTER TABLE ".PREFIX_TABLE."images ADD COLUMN has_high ENUM('true') DEFAULT NULL AFTER average_rate; +"; +pwg_query($query); + +echo +"\n" +.'Column has_high '.PREFIX_TABLE.'images added' +."\n" +; +?> diff --git a/install/phpwebgallery_structure.sql b/install/phpwebgallery_structure.sql index 9e50885f6..cdc3c5dbc 100644 --- a/install/phpwebgallery_structure.sql +++ b/install/phpwebgallery_structure.sql @@ -1,8 +1,8 @@ --- MySQL dump 9.11 +-- MySQL dump 10.9 -- --- Host: localhost Database: pwg-bsf +-- Host: localhost Database: pwg_dev_bsf -- ------------------------------------------------------ --- Server version 4.0.24_Debian-10-log +-- Server version 4.1.15-nt -- -- Table structure for table `phpwebgallery_caddie` @@ -155,6 +155,7 @@ CREATE TABLE `phpwebgallery_images` ( `representative_ext` varchar(4) default NULL, `date_metadata_update` date default NULL, `average_rate` float(5,2) unsigned default NULL, + `has_high` enum('true') default NULL, `path` varchar(255) NOT NULL default '', PRIMARY KEY (`id`), KEY `images_i2` (`date_available`), diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php index 94f37d00c..13bd4eefc 100644 --- a/language/en_UK.iso-8859-1/common.lang.php +++ b/language/en_UK.iso-8859-1/common.lang.php @@ -43,6 +43,7 @@ $lang['%d waiting elements'] = '%d waiting elements'; $lang['About'] = 'About'; $lang['At least one listed rule must be satisfied.'] = 'At least one listed rule must be satisfied.'; $lang['Author'] = 'Author'; +$lang['Availability date'] = 'Availability date'; $lang['Average rate'] = 'Average rate'; $lang['Categories'] = 'Categories'; $lang['Category'] = 'Category'; @@ -53,6 +54,7 @@ $lang['Connection'] = 'Connection'; $lang['Contact webmaster'] = 'Contact webmaster'; $lang['Create a new account'] = 'Create a new account'; $lang['Created on'] = 'Created on'; +$lang['Creation date'] = 'Creation date'; $lang['Current password is wrong'] = 'Current password is wrong'; $lang['Dimensions'] = 'Dimensions'; $lang['Display'] = 'Display'; @@ -121,7 +123,7 @@ $lang['became available after %s (%s)'] = 'became available after %s (%s)'; $lang['became available before %s (%s)'] = 'became available before %s (%s)'; $lang['became available between %s (%s) and %s (%s)'] = 'became available between %s (%s) and %s (%s)'; $lang['became available on %s'] = 'became available on %s'; -$lang['best_rated_cat'] = 'best rated'; +$lang['best_rated_cat'] = 'Best rated'; $lang['best_rated_cat_hint'] = 'displays best rated items'; $lang['caddie'] = 'caddie'; $lang['calendar'] = 'Calendar'; diff --git a/language/fr_FR.iso-8859-1/common.lang.php b/language/fr_FR.iso-8859-1/common.lang.php index 9b2b07702..055d66903 100644 --- a/language/fr_FR.iso-8859-1/common.lang.php +++ b/language/fr_FR.iso-8859-1/common.lang.php @@ -42,6 +42,7 @@ $lang['%d new users'] = '%d nouveaux utilisateurs'; $lang['About'] = 'À propos'; $lang['At least one listed rule must be satisfied.'] = 'Au moins un des critères doit être satisfait.'; $lang['Author'] = 'Auteur'; +$lang['Availability date'] = 'Date de disponibilité'; $lang['Average rate'] = 'Note moyenne'; $lang['Categories'] = 'Catégories'; $lang['Category'] = 'Catégorie'; @@ -52,6 +53,7 @@ $lang['Connection'] = 'Connexion'; $lang['Contact webmaster'] = 'Contacter le webmestre'; $lang['Create a new account'] = 'Créer un nouveau compte'; $lang['Created on'] = 'Créée le'; +$lang['Creation date'] = 'Date de création'; $lang['Current password is wrong'] = 'Erreur sur le mot de passe actuel'; $lang['Dimensions'] = 'Dimensions'; $lang['Display'] = 'Affichage'; diff --git a/picture.php b/picture.php index 11353de52..2b53b4868 100644 --- a/picture.php +++ b/picture.php @@ -247,12 +247,22 @@ foreach (array('prev', 'current', 'next') as $i) $picture[$i]['src'] = $row['path']; // if we are working on the "current" element, we search if there is a // high quality picture - // FIXME : with remote pictures, this "remote fopen" takes long... if ($i == 'current') { - if (@fopen($cat_directory.'/pwg_high/'.$row['file'], 'r')) + $url_high=$cat_directory.'/pwg_high/'.$row['file']; + if (url_is_remote($cat_directory)) { - $picture[$i]['high'] = $cat_directory.'/pwg_high/'.$row['file']; + if ($row['has_high']) + { + $picture[$i]['high'] = $url_high; + } + } + else + { + if (@fopen($url_high, 'r')) + { + $picture[$i]['high'] = $url_high; + } } } } @@ -526,6 +536,31 @@ if ($metadata_showable and !isset($_GET['show_metadata'])) } $page['body_id'] = 'thePicturePage'; +//-------------------------------------------------------- navigation management +if ($has_prev) +{ + $template->assign_block_vars( + 'previous', + array( + 'TITLE_IMG' => $picture['prev']['name'], + 'IMG' => $picture['prev']['thumbnail'], + 'U_IMG' => $picture['prev']['url'], + 'U_IMG_SRC' => $picture['prev']['src'] + )); +} + +if ($has_next) +{ + $template->assign_block_vars( + 'next', + array( + 'TITLE_IMG' => $picture['next']['name'], + 'IMG' => $picture['next']['thumbnail'], + 'U_IMG' => $picture['next']['url'], + 'U_IMG_SRC' => $picture['next']['src'] // allow navigator to preload + )); +} + include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames(array('picture'=>'picture.tpl')); @@ -585,15 +620,10 @@ if (!$picture['current']['is_picture']) // display a high quality link if present if (isset($picture['current']['high'])) { - $full_size = @getimagesize($picture['current']['high']); - $full_width = $full_size[0]; - $full_height = $full_size[1]; $uuid = uniqid(rand()); $template->assign_block_vars('high', array( 'U_HIGH' => $picture['current']['high'], - 'UUID'=>$uuid, - 'WIDTH_IMG'=>($full_width + 40), - 'HEIGHT_IMG'=>($full_height + 40) + 'UUID'=>$uuid )); $template->assign_block_vars( 'download', @@ -673,31 +703,6 @@ if ( $user['status'] == 'admin' ) $template->assign_block_vars('admin', array()); } -//-------------------------------------------------------- navigation management -if ($has_prev) -{ - $template->assign_block_vars( - 'previous', - array( - 'TITLE_IMG' => $picture['prev']['name'], - 'IMG' => $picture['prev']['thumbnail'], - 'U_IMG' => $picture['prev']['url'], - 'U_IMG_SRC' => $picture['prev']['src'] - )); -} - -if ($has_next) -{ - $template->assign_block_vars( - 'next', - array( - 'TITLE_IMG' => $picture['next']['name'], - 'IMG' => $picture['next']['thumbnail'], - 'U_IMG' => $picture['next']['url'], - 'U_IMG_SRC' => $picture['next']['src'] // allow navigator to preload - )); -} - //--------------------------------------------------------- picture information // legend if (isset($picture['current']['comment']) diff --git a/profile.php b/profile.php index a793aa2c4..a92ee12c3 100644 --- a/profile.php +++ b/profile.php @@ -211,7 +211,7 @@ foreach (get_themes() as $pwg_template) { $selected = $_POST['template']==$pwg_template ? 'selected="selected"' : ''; } - else if ($userdata['template'] == $pwg_template) + else if ($userdata['template'].'/'.$userdata['theme'] == $pwg_template) { $selected = 'selected="selected"'; } diff --git a/template/yoga/category.tpl b/template/yoga/category.tpl index 1f9e50c66..263342408 100644 --- a/template/yoga/category.tpl +++ b/template/yoga/category.tpl @@ -120,6 +120,16 @@ <li><a href="{search_rules.URL}" style="border:none;" onclick="popuphelp(this.href); return false;" title="{lang:Search rules}"><img src="{themeconf:icon_dir}/search_rules.png" class="button" alt="(?)"></a></li> <!-- END search_rules --> + <!-- BEGIN preferred_image_order --> + <li> + {lang:Sort order}: + <select onchange="document.location = this.options[this.selectedIndex].value;"> + <!-- BEGIN order --> + <option value="{preferred_image_order.order.URL}" {preferred_image_order.order.SELECTED_OPTION}>{preferred_image_order.order.DISPLAY}</option> + <!-- END order --> + </select> + </li> + <!-- END preferred_image_order --> </ul> <h2>{TITLE}</h2> diff --git a/template/yoga/content.css b/template/yoga/content.css index c339b3033..8bb5df33d 100644 --- a/template/yoga/content.css +++ b/template/yoga/content.css @@ -119,10 +119,12 @@ UL.categoryActions { #content UL.categoryActions LI { display: inline; + } #content UL.categoryActions A IMG, UL.categoryActions A { border: none; + margin-bottom: -5px; } /* User comments */ diff --git a/template/yoga/header.tpl b/template/yoga/header.tpl index 1c77d706c..9936a1095 100644 --- a/template/yoga/header.tpl +++ b/template/yoga/header.tpl @@ -11,6 +11,9 @@ the "text/nonsense" prevents gecko based browsers to load it --> <link rel="stylesheet" type="text/css" media="print" href="template/{themeconf:template}/print.css"> <link rel="stylesheet" type="text/css" href="template/{themeconf:template}/default-colors.css"> <link rel="stylesheet" type="text/css" href="template/{themeconf:template}/theme/{themeconf:theme}/theme.css"> +<!-- BEGIN next --> +<link rel="prefetch" href="{next.U_IMG_SRC}"> +<!-- END next --> <!-- BEGIN refresh --> <meta http-equiv="refresh" content="{REFRESH_TIME};url={U_REFRESH}"> <!-- END refresh --> diff --git a/template/yoga/picture.tpl b/template/yoga/picture.tpl index ceafa6a96..1c6387ee6 100644 --- a/template/yoga/picture.tpl +++ b/template/yoga/picture.tpl @@ -39,7 +39,6 @@ <!-- END last --> <!-- BEGIN next --> <a class="navButton next" href="{next.U_IMG}" title="{L_NEXT_IMG}{next.TITLE_IMG}" rel="next"><img src="{themeconf:icon_dir}/right.png" class="button" alt="next"></a> - <link rel="prefetch" href="{next.U_IMG_SRC}"><link rel="prefetch" href="{next.U_IMG}"> <!-- END next --> <a class="navButton up" href="{U_UP}" title="{L_UP_HINT}"><img src="{themeconf:icon_dir}/up.png" class="button" alt="{L_UP_ALT}"></a> <!-- BEGIN previous --> @@ -54,7 +53,7 @@ <div id="theImage"> <!-- BEGIN high --> -<a href="javascript:phpWGOpenWindow('{high.U_HIGH}','{high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes,width={high.WIDTH_IMG},height={high.HEIGHT_IMG}')"> +<a href="javascript:phpWGOpenWindow('{high.U_HIGH}','{high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')"> <!-- END high --> <img src="{SRC_IMG}" style="width:{WIDTH_IMG}px;height:{HEIGHT_IMG}px;" alt="{ALT_IMG}"> <!-- BEGIN high --> diff --git a/tools/create_listing_file.php b/tools/create_listing_file.php index 299e32bab..3ffc525b6 100644 --- a/tools/create_listing_file.php +++ b/tools/create_listing_file.php @@ -280,6 +280,31 @@ function get_representative_files($dir) } /** + * returns an array with high quality/resolution picture files of a directory + * according to $conf['picture_ext'] + * + * @param string $dir + * @return array + */ +function get_high_files($dir) +{ + global $conf; + + $pictures = array(); + if ($opendir = @opendir($dir.'/pwg_high')) + { + while ($file = readdir($opendir)) + { + if (in_array(get_extension($file), $conf['picture_ext'])) + { + array_push($pictures, $file); + } + } + } + return $pictures; +} + +/** * search in $basedir the sub-directories and calls get_pictures * * @return void @@ -347,6 +372,7 @@ function get_pictures($dir, $indent) $fs_files = get_pwg_files($dir); $fs_thumbnails = get_thumb_files($dir); $fs_representatives = get_representative_files($dir); + $fs_highs = get_high_files($dir); $elements = array(); @@ -377,8 +403,8 @@ function get_pictures($dir, $indent) } // 2 cases : the element is a picture or not. Indeed, for a picture - // thumbnail is mandatory and for non picture element, thumbnail and - // representative is optionnal + // thumbnail is mandatory, high is optional and for non picture element, + // thumbnail and representative is optionnal if (in_array(get_extension($fs_file), $conf['picture_ext'])) { // if we found a thumnbnail corresponding to our picture... @@ -389,6 +415,11 @@ function get_pictures($dir, $indent) $element['width'] = $image_size[0]; $element['height'] = $image_size[1]; } + + if ( in_array($fs_file, $fs_highs) ) + { + $element['has_high'] = 'true'; + } if ($conf['use_exif']) { @@ -452,7 +483,7 @@ function get_pictures($dir, $indent) $xml = "\n".$indent.'<root>'; $attributes = array('file','tn_ext','representative_ext','filesize', 'width','height','date_creation','author','keywords', - 'name','comment','path'); + 'name','comment','has_high', 'path'); foreach ($elements as $element) { $xml.= "\n".$indent.' '; |