aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/admin.php4
-rw-r--r--admin/comments.php19
-rw-r--r--admin/configuration.php2
-rw-r--r--admin/include/functions.php148
-rw-r--r--admin/infos_images.php153
-rw-r--r--admin/picture_modify.php270
-rw-r--r--admin/update.php167
-rw-r--r--admin/waiting.php38
-rw-r--r--category.php49
-rw-r--r--include/functions.inc.php26
-rw-r--r--include/functions_category.inc.php95
-rw-r--r--language/francais.php4
-rw-r--r--picture.php79
-rw-r--r--template/default/admin/configuration.vtp2
-rw-r--r--template/default/admin/infos_image.vtp21
-rw-r--r--template/default/admin/picture_modify.vtp101
-rw-r--r--upload.php5
17 files changed, 859 insertions, 324 deletions
diff --git a/admin/admin.php b/admin/admin.php
index 7ea97fdd7..b9b499cf2 100644
--- a/admin/admin.php
+++ b/admin/admin.php
@@ -131,6 +131,10 @@ switch ( $_GET['page'] )
$title = $lang['title_comments'];
$page_valide = true;
break;
+ case 'picture_modify' :
+ $title = $lang['title_picmod'];
+ $page_valide = true;
+ break;
default:
$title = $lang['title_default']; break;
}
diff --git a/admin/comments.php b/admin/comments.php
index 127d495f4..dc9e584ac 100644
--- a/admin/comments.php
+++ b/admin/comments.php
@@ -17,6 +17,7 @@
* *
***************************************************************************/
include_once( './include/isadmin.inc.php' );
+$page['plain_structure'] = get_plain_structure();
//------------------------------------------------------------------- functions
function display_pictures( $mysql_result, $maxtime, $validation_box = false )
{
@@ -28,7 +29,7 @@ function display_pictures( $mysql_result, $maxtime, $validation_box = false )
$vtp->addSession( $sub, 'picture' );
// 2. for each picture, getting informations for displaying thumbnail and
// link to the full size picture
- $query = 'SELECT name,file,cat_id,tn_ext';
+ $query = 'SELECT name,file,storage_category_id as cat_id,tn_ext';
$query.= ' FROM '.PREFIX_TABLE.'images';
$query.= ' WHERE id = '.$row['image_id'];
$query.= ';';
@@ -37,8 +38,9 @@ function display_pictures( $mysql_result, $maxtime, $validation_box = false )
if ( $array_cat_directories[$subrow['cat_id']] == '' )
{
+ $array_cat_directories[$subrow['cat_id']] =
+ get_complete_dir( $subrow['cat_id'] );
$cat_result = get_cat_info( $subrow['cat_id'] );
- $array_cat_directories[$subrow['cat_id']] = $cat_result['dir'];
$array_cat_site_id[$subrow['cat_id']] = $cat_result['site_id'];
$array_cat_names[$subrow['cat_id']] =
get_cat_display_name( $cat_result['name'], ' > ', '' );
@@ -83,10 +85,7 @@ function display_pictures( $mysql_result, $maxtime, $validation_box = false )
{
$vtp->addSession( $sub, 'comment' );
$vtp->setVar( $sub, 'comment.author', $subrow['author'] );
- $displayed_date = $lang['day'][date( "w", $subrow['date'] )];
- $displayed_date.= date( " j ", $subrow['date'] );
- $displayed_date.= $lang['month'][date( "n", $subrow['date'] )];
- $displayed_date.= date( " Y G:i", $subrow['date'] );
+ $displayed_date = format_date( $subrow['date'], 'unix', true );
$vtp->setVar( $sub, 'comment.date', $displayed_date );
$vtp->setVar( $sub, 'comment.content', nl2br( $subrow['content'] ) );
$vtp->addSession( $sub, 'delete' );
@@ -183,11 +182,9 @@ if ( isset( $_GET['last_days'] ) )
$query = 'SELECT DISTINCT(image_id) as image_id';
$query.= ' FROM '.PREFIX_TABLE.'comments';
$query.= ', '.PREFIX_TABLE.'images as images';
- $query.= ', '.PREFIX_TABLE.'categories';
$query.= ' WHERE image_id = images.id';
- $query.= ' AND cat_id = images.cat_id';
$query.= ' AND date > '.$maxtime;
- $query.= ' ORDER BY cat_id ASC,date_available DESC';
+ $query.= ' ORDER BY date_available DESC';
$query.= ';';
$result = mysql_query( $query );
display_pictures( $result, $maxtime );
@@ -221,11 +218,9 @@ if ( isset( $_GET['show_unvalidated'] ) )
$query = 'SELECT DISTINCT(image_id) as image_id';
$query.= ' FROM '.PREFIX_TABLE.'comments as comments';
$query.= ', '.PREFIX_TABLE.'images as images';
- $query.= ', '.PREFIX_TABLE.'categories';
$query.= ' WHERE image_id = images.id';
- $query.= ' AND cat_id = images.cat_id';
$query.= " AND comments.validated = 'false'";
- $query.= ' ORDER BY cat_id ASC,date_available DESC';
+ $query.= ' ORDER BY date_available DESC';
$query.= ';';
$result = mysql_query( $query );
display_pictures( $result, 0, true );
diff --git a/admin/configuration.php b/admin/configuration.php
index de2cc6f26..d2cdda12c 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -259,7 +259,7 @@ $sub = $vtp->Open(
'../template/'.$user['template'].'/admin/configuration.vtp' );
$tpl = array( 'conf_confirmation','remote_site','delete',
- 'conf_remote_site_delete_info','submit' );
+ 'conf_remote_site_delete_info','submit','errors_title' );
templatize_array( $tpl, 'lang', $sub );
//-------------------------------------------------------------- errors display
if ( sizeof( $error ) != 0 )
diff --git a/admin/include/functions.php b/admin/include/functions.php
index dfb4aab90..7115f163b 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -94,6 +94,7 @@ function delete_site( $id )
// The function delete_category deletes the category identified by the $id
// It also deletes (in the database) :
// - all the images of the images (thanks to delete_image, see further)
+// - all the links between images and this category
// - all the restrictions linked to the category
// The function works recursively.
function delete_category( $id )
@@ -101,7 +102,7 @@ function delete_category( $id )
// destruction of all the related images
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$id;
+ $query.= ' WHERE storage_category_id = '.$id;
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
@@ -109,6 +110,12 @@ function delete_category( $id )
delete_image( $row['id'] );
}
+ // destruction of the links between images and this category
+ $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE category_id = '.$id;
+ $query.= ';';
+ mysql_query( $query );
+
// destruction of the access linked to the category
$query = 'DELETE FROM '.PREFIX_TABLE.'user_access';
$query.= ' WHERE cat_id = '.$id;
@@ -140,6 +147,7 @@ function delete_category( $id )
// The function delete_image deletes the image identified by the $id
// It also deletes (in the database) :
// - all the comments related to the image
+// - all the links between categories and this image
// - all the favorites associated to the image
function delete_image( $id )
{
@@ -150,7 +158,13 @@ function delete_image( $id )
$query.= ' WHERE image_id = '.$id;
$query.= ';';
mysql_query( $query );
-
+
+ // destruction of the links between images and this category
+ $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE image_id = '.$id;
+ $query.= ';';
+ mysql_query( $query );
+
// destruction of the favorites associated with the picture
$query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
$query.= ' WHERE image_id = '.$id;
@@ -244,15 +258,28 @@ function check_favorites( $user_id )
$restricted_cat = get_all_restrictions( $user_id, $status );
// retrieving all the favorites for this user and comparing their
// categories to the restricted categories
- $query = 'SELECT image_id, cat_id';
- $query.= ' FROM '.PREFIX_TABLE.'favorites, '.PREFIX_TABLE.'images';
+ $query = 'SELECT image_id';
+ $query.= ' FROM '.PREFIX_TABLE.'favorites';
$query.= ' WHERE user_id = '.$user_id;
- $query.= ' AND id = image_id';
$query.= ';';
$result = mysql_query ( $query );
while ( $row = mysql_fetch_array( $result ) )
{
- if ( in_array( $row['cat_id'], $restricted_cat ) )
+ // for each picture, we have to check all the categories it belongs
+ // to. Indeed if a picture belongs to category_1 and category_2 and that
+ // category_2 is not restricted to the user, he can have the picture as
+ // favorite.
+ $query = 'SELECT DISTINCT(category_id) as category_id';
+ $query.= ' FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE image_id = '.$row['image_id'];
+ $query.= ';';
+ $picture_result = mysql_query( $query );
+ $picture_cat = array();
+ while ( $picture_row = mysql_fetch_array( $picture_result ) )
+ {
+ array_push( $picture_cat, $picture_row['category_id'] );
+ }
+ if ( count( array_diff( $picture_cat, $restricted_cat ) ) > 0 )
{
$query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
$query.= ' WHERE image_id = '.$row['image_id'];
@@ -262,4 +289,113 @@ function check_favorites( $user_id )
}
}
}
+
+// update_category updates calculated informations about a category :
+// date_last and nb_images
+function update_category( $id = 'all' )
+{
+ if ( $id == 'all' )
+ {
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ // recursive call
+ update_category( $row['id'] );
+ }
+ }
+ else if ( is_numeric( $id ) )
+ {
+ // updating the number of pictures
+ $query = 'SELECT COUNT(*) as nb_images';
+ $query.= ' FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE category_id = '.$id;
+ $query.= ';';
+ $row = mysql_fetch_array( mysql_query( $query ) );
+ $query = 'UPDATE '.PREFIX_TABLE.'categories';
+ $query.= ' SET nb_images = '.$row['nb_images'];
+ $query.= ' WHERE id = '.$id;
+ $query.= ';';
+ mysql_query( $query );
+ // updating the date_last
+ $query = 'SELECT date_available';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' WHERE category_id = '.$id;
+ $query.= ' ORDER BY date_available DESC';
+ $query.= ' LIMIT 0,1';
+ $query.= ';';
+ $row = mysql_fetch_array( mysql_query( $query ) );
+ $query = 'UPDATE '.PREFIX_TABLE.'categories';
+ $query.= " SET date_last = '".$row['date_available']."'";
+ $query.= ' WHERE id = '.$id;
+ $query.= ';';
+ mysql_query( $query );
+ }
+}
+
+function check_date_format( $date )
+{
+ // date arrives at this format : DD/MM/YYYY
+ list($day,$month,$year) = explode( '/', $date );
+ return checkdate ( $month, $day, $year );
+}
+
+function date_convert( $date )
+{
+ // date arrives at this format : DD/MM/YYYY
+ // It must be transformed in YYYY-MM-DD
+ list($day,$month,$year) = explode( '/', $date );
+ return $year.'-'.$month.'-'.$day;
+}
+
+function date_convert_back( $date )
+{
+ // date arrives at this format : YYYY-MM-DD
+ // It must be transformed in DD/MM/YYYY
+ if ( $date != '' )
+ {
+ list($year,$month,$day) = explode( '-', $date );
+ return $day.'/'.$month.'/'.$year;
+ }
+ else
+ {
+ return '';
+ }
+}
+
+// get_keywords returns an array with relevant keywords found in the string
+// given in argument. Keywords must be separated by comma in this string.
+// keywords must :
+// - be longer or equal to 3 characters
+// - not contain ', " or blank characters
+// - unique in the string ("test,test" -> "test")
+function get_keywords( $keywords_string )
+{
+ $keywords = array();
+
+ $candidates = explode( ',', $keywords_string );
+ foreach ( $candidates as $candidate ) {
+ if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) )
+ array_push( $keywords, $candidate );
+ }
+
+ return array_unique( $keywords );
+}
+
+function display_categories( $categories, $indent )
+{
+ global $vtp,$sub;
+
+ foreach ( $categories as $category ) {
+ $vtp->addSession( $sub, 'associate_cat' );
+ $vtp->setVar( $sub, 'associate_cat.value', $category['id'] );
+ $content = $indent.'- '.$category['name'];
+ $vtp->setVar( $sub, 'associate_cat.content', $content );
+ $vtp->closeSession( $sub, 'associate_cat' );
+ display_categories( $category['subcats'], $indent.str_repeat(' ',3) );
+ }
+}
?> \ No newline at end of file
diff --git a/admin/infos_images.php b/admin/infos_images.php
index 9a8b77939..8b3392da0 100644
--- a/admin/infos_images.php
+++ b/admin/infos_images.php
@@ -19,64 +19,15 @@
include_once( './include/isadmin.inc.php' );
include_once( '../template/'.$user['template'].'/htmlfunctions.inc.php' );
-//------------------------------------------------------------------- functions
-function check_date_format( $date )
-{
- // date arrives at this format : DD/MM/YYYY
- list($day,$month,$year) = explode( '/', $date );
- return checkdate ( $month, $day, $year );
-}
-
-function date_convert( $date )
-{
- // date arrives at this format : DD/MM/YYYY
- // It must be transformed in YYYY-MM-DD
- list($day,$month,$year) = explode( '/', $date );
- return $year.'-'.$month.'-'.$day;
-}
-
-function date_convert_back( $date )
-{
- // date arrives at this format : YYYY-MM-DD
- // It must be transformed in DD/MM/YYYY
- if ( $date != '' )
- {
- list($year,$month,$day) = explode( '-', $date );
- return $day.'/'.$month.'/'.$year;
- }
- else
- {
- return '';
- }
-}
-
-// get_keywords returns an array with relevant keywords found in the string
-// given in argument. Keywords must be separated by comma in this string.
-// keywords must :
-// - be longer or equal to 3 characters
-// - not contain ', " or blank characters
-// - unique in the string ("test,test" -> "test")
-function get_keywords( $keywords_string )
-{
- $keywords = array();
-
- $candidates = explode( ',', $keywords_string );
- foreach ( $candidates as $candidate ) {
- if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) )
- array_push( $keywords, $candidate );
- }
-
- return array_unique( $keywords );
-}
//-------------------------------------------------------------- initialization
check_cat_id( $_GET['cat_id'] );
-
if ( isset( $page['cat'] ) )
{
//--------------------------------------------------- update individual options
$query = 'SELECT id,file';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$page['cat'];
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' WHERE category_id = '.$page['cat'];
$query.= ';';
$result = mysql_query( $query );
$i = 1;
@@ -121,53 +72,77 @@ if ( isset( $page['cat'] ) )
$query.= 'NULL';
else
{
- $query.= '"';
+ $query.= "'";
foreach ( $keywords_array as $i => $keyword ) {
if ( $i > 0 ) $query.= ',';
$query.= $keyword;
}
- $query.= '"';
+ $query.= "'";
}
$query.= ' WHERE id = '.$row['id'];
$query.= ';';
mysql_query( $query );
}
+ // add link to another category
+ if ( $_POST['check-'.$row['id']] == 1 )
+ {
+ $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
+ $query.= ' (image_id,category_id) VALUES';
+ $query.= ' ('.$row['id'].','.$_POST['associate'].')';
+ $query.= ';';
+ mysql_query( $query );
+ }
}
+ update_category( $_POST['associate'] );
//------------------------------------------------------ update general options
if ( $_POST['use_common_author'] == 1 )
{
- $query = 'UPDATE '.PREFIX_TABLE.'images';
- if ( $_POST['author_cat'] == '' )
- {
- $query.= ' SET author = NULL';
- }
- else
+ $query = 'SELECT image_id';
+ $query.= ' FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE category_id = '.$page['cat'];
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
{
- $query.= ' SET author = ';
- $query.= "'".htmlentities( $_POST['author_cat'], ENT_QUOTES )."'";
+ $query = 'UPDATE '.PREFIX_TABLE.'images';
+ if ( $_POST['author_cat'] == '' )
+ {
+ $query.= ' SET author = NULL';
+ }
+ else
+ {
+ $query.= ' SET author = ';
+ $query.= "'".htmlentities( $_POST['author_cat'], ENT_QUOTES )."'";
+ }
+ $query.= ' WHERE id = '.$row['image_id'];
+ $query.= ';';
+ mysql_query( $query );
}
- $query.= ' WHERE cat_id = '.$page['cat'];
- $query.= ';';
- mysql_query( $query );
}
if ( $_POST['use_common_date_creation'] == 1 )
{
if ( check_date_format( $_POST['date_creation_cat'] ) )
{
$date = date_convert( $_POST['date_creation_cat'] );
- $query = 'UPDATE '.PREFIX_TABLE.'images';
- if ( $_POST['date_creation_cat'] == '' )
- {
- $query.= ' SET date_creation = NULL';
- }
- else
+ $query = 'SELECT image_id';
+ $query.= ' FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE category_id = '.$page['cat'];
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
{
- $query.= " SET date_creation = '".$date."'";
+ $query = 'UPDATE '.PREFIX_TABLE.'images';
+ if ( $_POST['date_creation_cat'] == '' )
+ {
+ $query.= ' SET date_creation = NULL';
+ }
+ else
+ {
+ $query.= " SET date_creation = '".$date."'";
+ }
+ $query.= ' WHERE id = '.$row['image_id'];
+ $query.= ';';
+ mysql_query( $query );
}
- $query.= ' WHERE cat_id = '.$page['cat'];
- $query.= ';';
- mysql_query( $query );
}
else
{
@@ -178,7 +153,8 @@ if ( isset( $page['cat'] ) )
{
$query = 'SELECT id,keywords';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$page['cat'];
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' WHERE category_id = '.$page['cat'];
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
@@ -241,11 +217,9 @@ if ( isset( $page['cat'] ) )
floor( $_GET['num'] / $page['nb_image_page'] ) * $page['nb_image_page'];
}
// retrieving category information
+ $page['plain_structure'] = get_plain_structure();
$result = get_cat_info( $page['cat'] );
- $cat['local_dir'] = $result['local_dir'];
- $cat['dir'] = $result['dir'];
$cat['name'] = $result['name'];
- $cat['site_id'] = $result['site_id'];
$cat['nb_images'] = $result['nb_images'];
//----------------------------------------------------- template initialization
$sub = $vtp->Open('../template/'.$user['template'].'/admin/infos_image.vtp');
@@ -254,8 +228,9 @@ if ( isset( $page['cat'] ) )
'infoimage_title','infoimage_comment',
'infoimage_creation_date','keywords',
'infoimage_addtoall','infoimage_removefromall',
- 'infoimage_keyword_separation' );
+ 'infoimage_keyword_separation','infoimage_associate' );
templatize_array( $tpl, 'lang', $sub );
+ $vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
//------------------------------------------------------------------------ form
$url = './admin.php?page=infos_images&cat_id='.$page['cat'];
$url.= '&start='.$page['start'];
@@ -266,9 +241,13 @@ if ( isset( $page['cat'] ) )
$cat_name = get_cat_display_name( $cat['name'], ' - ', 'font-style:italic;');
$vtp->setVar( $sub, 'cat_name', $cat_name );
+ $array_cat_directories = array();
+
$query = 'SELECT id,file,comment,author,tn_ext,name,date_creation,keywords';
+ $query.= ',storage_category_id,category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$page['cat'];
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' WHERE category_id = '.$page['cat'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$page['start'].','.$page['nb_image_page'];
$query.= ';';
@@ -287,13 +266,15 @@ if ( isset( $page['cat'] ) )
$file = get_filename_wo_extension( $row['file'] );
$vtp->setVar( $sub, 'picture.default_name', $file );
// creating url to thumbnail
- if ( $cat['site_id'] == 1 )
- {
- $thumbnail_url = '../galleries/'.$cat['local_dir'].'/';
+ if ( $array_cat_directories[$row['storage_category_id']] == '' )
+ {
+ $array_cat_directories[$row['storage_category_id']] =
+ get_complete_dir( $row['storage_category_id'] );
}
- else
+ $thumbnail_url = $array_cat_directories[$row['storage_category_id']];
+ if ( preg_match( '/^\.\/galleries/', $thumbnail_url ) )
{
- $thumbnail_url = $cat['dir'];
+ $thumbnail_url = '.'.$thumbnail_url;
}
$thumbnail_url.= 'thumbnail/';
$thumbnail_url.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext'];
@@ -302,6 +283,8 @@ if ( isset( $page['cat'] ) )
$vtp->setVar( $sub, 'picture.url', add_session_id( $url ) );
$vtp->closeSession( $sub, 'picture' );
}
+ $structure = create_structure( '', array() );
+ display_categories( $structure, ' ' );
}
//----------------------------------------------------------- sending html code
$vtp->Parse( $handle , 'sub', $sub );
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
new file mode 100644
index 000000000..804cc8e2c
--- /dev/null
+++ b/admin/picture_modify.php
@@ -0,0 +1,270 @@
+<?php
+/***************************************************************************
+ * picture_modify.php *
+ * ------------------ *
+ * application : PhpWebGallery 1.3 <http://phpwebgallery.net> *
+ * author : Pierrick LE GALL <pierrick@z0rglub.com> *
+ * *
+ * $Id$
+ * *
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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; *
+ * *
+ ***************************************************************************/
+
+include_once( './include/isadmin.inc.php' );
+//----------------------------------------- categories structure initialization
+$page['plain_structure'] = get_plain_structure();
+//--------------------------------------------------------- update informations
+$errors = array();
+// first, we verify whether there is a mistake on the given creation date
+if ( isset( $_POST['creation_date'] ) and $_POST['creation_date'] != '' )
+{
+ if ( !check_date_format( $_POST['creation_date'] ) )
+ array_push( $errors, $lang['err_date'] );
+}
+if ( isset( $_POST['submit'] ) )
+{
+ $query = 'UPDATE '.PREFIX_TABLE.'images';
+
+ $query.= ' SET name = ';
+ if ( $_POST['name'] == '' )
+ $query.= 'NULL';
+ else
+ $query.= "'".htmlentities( $_POST['name'], ENT_QUOTES )."'";
+
+ $query.= ', author = ';
+ if ( $_POST['author'] == '' )
+ $query.= 'NULL';
+ else
+ $query.= "'".htmlentities($_POST['author'],ENT_QUOTES)."'";
+
+ $query.= ', comment = ';
+ if ( $_POST['comment'] == '' )
+ $query.= 'NULL';
+ else
+ $query.= "'".htmlentities($_POST['comment'],ENT_QUOTES)."'";
+
+ $query.= ', date_creation = ';
+ if ( check_date_format( $_POST['creation_date'] ) )
+ $query.= "'".date_convert( $_POST['creation_date'] )."'";
+ else if ( $_POST['creation_date'] == '' )
+ $query.= 'NULL';
+
+ $query.= ', keywords = ';
+ $keywords_array = get_keywords( $_POST['keywords'] );
+ if ( count( $keywords_array ) == 0 )
+ $query.= 'NULL';
+ else
+ {
+ $query.= "'";
+ foreach ( $keywords_array as $i => $keyword ) {
+ if ( $i > 0 ) $query.= ',';
+ $query.= $keyword;
+ }
+ $query.= "'";
+ }
+
+ $query.= ' WHERE id = '.$_GET['image_id'];
+ $query.= ';';
+ mysql_query( $query );
+ // associate with a new category ?
+ if ( $_POST['associate'] != '-1' )
+ {
+ $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
+ $query.= ' (category_id,image_id) VALUES ';
+ $query.= '('.$_POST['associate'].','.$_GET['image_id'].')';
+ $query.= ';';
+ mysql_query( $query);
+ update_category( $_POST['associate'] );
+ }
+ // dissociate any category ?
+ // retrieving all the linked categories
+ $query = 'SELECT DISTINCT(category_id) as category_id';
+ $query.= ' FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE image_id = '.$_GET['image_id'];
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ if ( $_POST['dissociate-'.$row['category_id']] == 1 )
+ {
+ $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE image_id = '.$_GET['image_id'];
+ $query.= ' AND category_id = '.$row['category_id'];
+ $query.= ';';
+ mysql_query( $query );
+ update_category( $row['category_id'] );
+ }
+ }
+}
+//----------------------------------------------------- template initialization
+$sub = $vtp->Open(
+ '../template/'.$user['template'].'/admin/picture_modify.vtp' );
+
+$tpl = array( 'submit','errors_title','picmod_update','picmod_back',
+ 'default','file','size','filesize','registration_date',
+ 'author','creation_date','keywords','comment', 'upload_name',
+ 'dissociate','categories','infoimage_associate',
+ 'cat_image_info' );
+templatize_array( $tpl, 'lang', $sub );
+$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
+//-------------------------------------------------------------- errors display
+if ( count( $errors ) != 0 )
+{
+ $vtp->addSession( $sub, 'errors' );
+ foreach ( $errors as $error ) {
+ $vtp->addSession( $sub, 'li' );
+ $vtp->setVar( $sub, 'li.content', $error );
+ $vtp->closeSession( $sub, 'li' );
+ }
+ $vtp->closeSession( $sub, 'errors' );
+}
+//-------------------------------------------- displaying informations and form
+$action = './admin.php?'.$_SERVER['QUERY_STRING'];
+$vtp->setVar( $sub, 'form_action', $action );
+// retrieving direct information about picture
+$query = 'SELECT file,date_available,date_creation,tn_ext,name,filesize';
+$query.= ',width,height,author,comment,keywords,storage_category_id';
+$query.= ' FROM '.PREFIX_TABLE.'images';
+$query.= ' WHERE id = '.$_GET['image_id'];
+$query.= ';';
+$row = mysql_fetch_array( mysql_query( $query ) );
+// picture title
+if ( $row['name'] == '' )
+{
+ $title = str_replace( '_',' ',get_filename_wo_extension($row['file']) );
+}
+else
+{
+ $title = $row['name'];
+}
+$vtp->setVar( $sub, 'title', $title );
+$vtp->setVar( $sub, 'f_file', $row['file'] );
+$vtp->setVar( $sub, 'f_size', $row['width'].' * '.$row['height'] );
+$vtp->setVar( $sub, 'f_filesize', $row['filesize'].' KB' );
+$vtp->setVar( $sub, 'f_registration_date',format_date($row['date_available']));
+$default_name = str_replace( '_',' ',get_filename_wo_extension($row['file']) );
+$vtp->setVar( $sub, 'default_name', $default_name );
+// if this form is displayed after an unsucceeded submit, we have to display
+// the values filled by the user (wright or wrong).
+if ( count( $errors ) > 0 )
+{
+ $name = $_POST['name'];
+ $author = $_POST['author'];
+ $creation_date = $_POST['creation_date'];
+ $keywords = $_POST['keywords'];
+ $comment = $_POST['comment'];
+}
+else
+{
+ $name = $row['name'];
+ $author = $row['author'];
+ $creation_date = date_convert_back( $row['date_creation'] );
+ $keywords = $row['keywords'];
+ $comment = $row['comment'];
+}
+$vtp->setVar( $sub, 'f_name', $name );
+$vtp->setVar( $sub, 'f_author', $author );
+$vtp->setVar( $sub, 'f_creation_date', $creation_date );
+$vtp->setVar( $sub, 'f_keywords', $keywords );
+$vtp->setVar( $sub, 'f_comment', $comment );
+// retrieving directory where picture is stored (for displaying the
+// thumbnail)
+$thumbnail_url = get_complete_dir( $row['storage_category_id'] );
+$result = get_cat_info( $row['storage_category_id'] );
+$cat_name = get_cat_display_name( $result['name'], ' &gt; ', '' );
+$vtp->setVar( $sub, 'dir', $cat_name );
+if ( $result['site_id'] == 1 ) $thumbnail_url = '.'.$thumbnail_url;
+$file_wo_ext = get_filename_wo_extension( $row['file'] );
+$thumbnail_url.= '/thumbnail/';
+$thumbnail_url.= $conf['prefix_thumbnail'].$file_wo_ext.'.'.$row['tn_ext'];
+$vtp->setVar( $sub, 'thumbnail_url', $thumbnail_url );
+// storage category is linked by default
+$vtp->addSession( $sub, 'linked_category' );
+$vtp->setVar( $sub, 'linked_category.name', $cat_name );
+$url = '../picture.php?image_id='.$_GET['image_id'];
+$url.= '&amp;cat='.$row['storage_category_id'];
+$vtp->setVar( $sub, 'linked_category.url',add_session_id( $url));
+$url = './admin.php?page=infos_images&amp;cat_id='.$row['storage_category_id'];
+$vtp->setVar( $sub, 'linked_category.infos_images_link',add_session_id( $url));
+if ( $result['status'] == 'private' )
+{
+ $private_string = '<span style="color:red;font-weight:bold;">';
+ $private_string.= $lang['private'].'</span>';
+ $vtp->setVar( $sub, 'linked_category.private', $private_string );
+}
+if ( !$result['visible'] )
+{
+ $invisible_string = '<span style="color:red;">';
+ $invisible_string.= $lang['cat_invisible'].'</span>';
+ $vtp->setVar( $sub, 'linked_category.invisible', $invisible_string );
+}
+$vtp->closeSession( $sub, 'linked_category' );
+// retrieving all the linked categories
+$query = 'SELECT DISTINCT(category_id) as category_id,status,visible';
+$query.= ' FROM '.PREFIX_TABLE.'image_category';
+$query.= ','.PREFIX_TABLE.'categories';
+$query.= ' WHERE image_id = '.$_GET['image_id'];
+$query.= ' AND category_id != '.$row['storage_category_id'];
+$query.= ' AND category_id = id';
+$query.= ';';
+$result = mysql_query( $query );
+while ( $row = mysql_fetch_array( $result ) )
+{
+ $vtp->addSession( $sub, 'linked_category' );
+
+ $vtp->addSession( $sub, 'checkbox' );
+ $vtp->setVar( $sub, 'checkbox.id', $row['category_id'] );
+ $vtp->closeSession( $sub, 'checkbox' );
+
+ $cat_infos = get_cat_info( $row['category_id'] );
+ $cat_name = get_cat_display_name( $cat_infos['name'], ' &gt; ', '' );
+ $vtp->setVar( $sub, 'linked_category.name', $cat_name );
+
+ $url = '../picture.php?image_id='.$_GET['image_id'];
+ $url.= '&amp;cat='.$row['category_id'];
+ $vtp->setVar( $sub, 'linked_category.url',add_session_id( $url));
+
+ $url = './admin.php?page=infos_images&amp;cat_id='.$row['category_id'];
+ $vtp->setVar( $sub, 'linked_category.infos_images_link',
+ add_session_id( $url));
+
+ if ( $row['status'] == 'private' )
+ {
+ $private_string = '<span style="color:red;font-weight:bold;">';
+ $private_string.= $lang['private'].'</span>';
+ $vtp->setVar( $sub, 'linked_category.private', $private_string );
+ }
+
+ if ( !get_boolean( $row['visible'] ) )
+ {
+ $invisible_string = '<span style="color:red;">';
+ $invisible_string.= $lang['cat_invisible'].'</span>';
+ $vtp->setVar( $sub, 'linked_category.invisible', $invisible_string );
+ }
+
+ $vtp->closeSession( $sub, 'linked_category' );
+}
+// if there are linked category other than the storage category, we show
+// propose the dissociate text
+if ( mysql_num_rows( $result ) > 0 )
+{
+ $vtp->addSession( $sub, 'dissociate' );
+ $vtp->closeSession( $sub, 'dissociate' );
+}
+// associate to another category ?
+$vtp->addSession( $sub, 'associate_cat' );
+$vtp->setVar( $sub, 'associate_cat.value', '-1' );
+$vtp->setVar( $sub, 'associate_cat.content', '' );
+$vtp->closeSession( $sub, 'associate_cat' );
+$structure = create_structure( '', array() );
+display_categories( $structure, '&nbsp;' );
+//----------------------------------------------------------- sending html code
+$vtp->Parse( $handle , 'sub', $sub );
+?> \ No newline at end of file
diff --git a/admin/update.php b/admin/update.php
index 9e6b07e7d..fb2ea3b4a 100644
--- a/admin/update.php
+++ b/admin/update.php
@@ -30,24 +30,24 @@ function insert_local_category( $cat_id )
if ( is_numeric( $cat_id ) )
{
+ $cat_directory.= '/'.get_local_dir( $cat_id );
$result = get_cat_info( $cat_id );
- $cat_directory.= '/'.$result['local_dir'];
// 1. display the category name to update
$src = '../template/'.$user['template'].'/admin/images/puce.gif';
$output = '<img src="'.$src.'" alt="&gt;" />';
$output.= '<span style="font-weight:bold;">'.$result['name'][0].'</span>';
- $output.= ' [ '.$result['last_dir'].' ]';
+ $output.= ' [ '.$result['dir'].' ]';
$output.= '<div class="retrait">';
-
+
// 2. we search pictures of the category only if the update is for all
// or a cat_id is specified
if ( isset( $page['cat'] ) or $_GET['update'] == 'all' )
{
$output.= insert_local_image( $cat_directory, $cat_id );
- update_cat_info( $cat_id );
+ update_category( $cat_id );
}
}
-
+
// 3. we have to remove the categories of the database not present anymore
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'categories';
@@ -65,17 +65,10 @@ function insert_local_category( $cat_id )
while ( $row = mysql_fetch_array( $result ) )
{
// retrieving the directory
- $rep = '../galleries';
- $resultat = get_cat_info( $row['id'] );
- $rep.= '/'.$resultat['local_dir'];
-
+ $rep = '../galleries/'.get_local_dir( $row['id'] );
// is the directory present ?
- if ( !is_dir( $rep ) )
- {
- delete_category( $row['id'] );
- }
+ if ( !is_dir( $rep ) ) delete_category( $row['id'] );
}
-
// 4. retrieving the sub-directories
$sub_rep = array();
$i = 0;
@@ -93,7 +86,6 @@ function insert_local_category( $cat_id )
}
}
}
-
for ( $i = 0; $i < sizeof( $sub_rep ); $i++ )
{
// 5. Is the category already existing ? we create a subcat if not
@@ -119,14 +111,8 @@ function insert_local_category( $cat_id )
$query = 'INSERT INTO '.PREFIX_TABLE.'categories';
$query.= ' (dir,site_id,id_uppercat) VALUES';
$query.= " ('".$sub_rep[$i]."','".$site_id."'";
- if ( !is_numeric( $cat_id ) )
- {
- $query.= ',NULL';
- }
- else
- {
- $query.= ",'".$cat_id."'";
- }
+ if ( !is_numeric( $cat_id ) ) $query.= ',NULL';
+ else $query.= ",'".$cat_id."'";
$query.= ');';
mysql_query( $query );
$category_id = mysql_insert_id();
@@ -158,7 +144,7 @@ function insert_local_image( $rep, $category_id )
// - don't have the associated thumbnail available anymore
$query = 'SELECT id,file,tn_ext';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$category_id;
+ $query.= ' WHERE storage_category_id = '.$category_id;
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
@@ -199,7 +185,7 @@ function insert_local_image( $rep, $category_id )
// is the picture waiting for validation by an administrator ?
$query = 'SELECT id,validated,infos';
$query.= ' FROM '.PREFIX_TABLE.'waiting';
- $query.= ' WHERE cat_id = '.$category_id;
+ $query.= ' WHERE category_id = '.$category_id;
$query.= " AND file = '".$file."'";
$query.= ';';
$result = mysql_query( $query );
@@ -211,7 +197,7 @@ function insert_local_image( $rep, $category_id )
// is the picture already in the database ?
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$category_id;
+ $query.= ' WHERE storage_category_id = '.$category_id;
$query.= " AND file = '".$file."'";
$query.= ';';
$result = mysql_query( $query );
@@ -266,7 +252,8 @@ function insert_local_image( $rep, $category_id )
// inserting the pictures found in the directory
foreach ( $pictures as $picture ) {
$query = 'INSERT INTO '.PREFIX_TABLE.'images';
- $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height';
+ $query.= ' (file,storage_category_id,date_available,tn_ext';
+ $query.= ',filesize,width,height';
$query.= ',name,author,comment,date_creation)';
$query.= ' VALUES ';
$query.= "('".$picture['file']."','".$category_id."'";
@@ -285,7 +272,20 @@ function insert_local_image( $rep, $category_id )
$query.= ');';
mysql_query( $query );
$count_new++;
-
+ // retrieving the id of newly inserted picture
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= " AND file = '".$picture['file']."'";
+ $query.= ';';
+ list( $image_id ) = mysql_fetch_array( mysql_query( $query ) );
+ // adding the link between this picture and its storage category
+ $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
+ $query.= ' (image_id,category_id) VALUES ';
+ $query.= ' ('.$image_id.','.$category_id.')';
+ $query.= ';';
+ mysql_query( $query );
+
$output.= $picture['file'];
$output.= ' <span style="font-weight:bold;">';
$output.= $lang['update_research_added'].'</span>';
@@ -294,35 +294,6 @@ function insert_local_image( $rep, $category_id )
}
return $output;
}
-
-// The function "update_cat_info" updates the information about the last
-// online image and the number of images in the category
-function update_cat_info( $category_id )
-{
- $query = 'SELECT date_available';
- $query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$category_id;
- $query.= ' ORDER BY date_available DESC';
- $query.= ' LIMIT 0,1';
- $query.= ';';
- $result = mysql_query( $query );
- $row = mysql_fetch_array( $result );
- $date_last = $row['date_available'];
-
- $query = 'SELECT COUNT(*) as nb_images';
- $query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$category_id;
- $result = mysql_query( $query );
- $row = mysql_fetch_array( $result );
- $nb_images = $row['nb_images'];
-
- $query = 'UPDATE '.PREFIX_TABLE.'categories';
- $query.= " SET date_last = '".$date_last."'";
- $query.= ', nb_images = '.$nb_images;
- $query.= ' where id = '.$category_id;
- $query.= ';';
- mysql_query( $query );
-}
// remote_images verifies if a file named "listing.xml" is present is the
// admin directory. If it is the case, creation of a remote picture storage
@@ -341,16 +312,16 @@ function remote_images()
$vtp->setVar( $sub, 'remote_update.url', $url );
// 2. is the site already existing ?
- $query = 'select id';
- $query.= ' from '.PREFIX_TABLE.'sites';
- $query.= " where galleries_url = '".$url."'";
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'sites';
+ $query.= " WHERE galleries_url = '".$url."'";
$query.= ';';
$result = mysql_query( $query );
if ( mysql_num_rows($result ) == 0 )
{
// we have to register this site in the database
- $query = 'insert into '.PREFIX_TABLE.'sites';
- $query.= " (galleries_url) values ('".$url."')";
+ $query = 'INSERT INTO '.PREFIX_TABLE.'sites';
+ $query.= " (galleries_url) VALUES ('".$url."')";
$query.= ';';
mysql_query( $query );
$site_id = mysql_insert_id();
@@ -390,25 +361,25 @@ function insert_remote_category( $xml_dir, $site_id, $id_uppercat, $level )
$output.= '<span style="font-weight:bold;">'.$name.'</span>';
$output.= '<div class="retrait">';
- $query = 'select id';
- $query.= ' from '.PREFIX_TABLE.'categories';
- $query.= ' where site_id = '.$site_id;
- $query.= " and dir = '".$name."'";
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE site_id = '.$site_id;
+ $query.= " AND dir = '".$name."'";
if ( $id_uppercat == 'NULL' )
{
- $query.= ' and id_uppercat is NULL';
+ $query.= ' AND id_uppercat IS NULL';
}
else
{
- $query.= ' and id_uppercat = '.$id_uppercat;
+ $query.= ' AND id_uppercat = '.$id_uppercat;
}
$query.= ';';
$result = mysql_query( $query );
if ( mysql_num_rows( $result ) == 0 )
{
// we have to create the category
- $query = 'insert into '.PREFIX_TABLE.'categories';
- $query.= " (dir,site_id,id_uppercat) values ('".$name."',".$site_id;
+ $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
+ $query.= " (dir,site_id,id_uppercat) VALUES ('".$name."',".$site_id;
if ( !is_numeric( $id_uppercat ) )
{
$query.= ',NULL';
@@ -428,23 +399,23 @@ function insert_remote_category( $xml_dir, $site_id, $id_uppercat, $level )
$category_id = $row['id'];
}
$output.= insert_remote_image( $list_dirs[$i], $category_id );
- update_cat_info( $category_id );
+ update_category( $category_id );
$output.= insert_remote_category( $list_dirs[$i], $site_id,
$category_id, $level+1 );
$output.= '</div>';
}
// we have to remove the categories of the database not present in the xml
// file (ie deleted from the picture storage server)
- $query = 'select dir,id';
- $query.= ' from '.PREFIX_TABLE.'categories';
- $query.= ' where site_id = '.$site_id;
+ $query = 'SELECT dir,id';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE site_id = '.$site_id;
if ( !is_numeric( $id_uppercat ) )
{
- $query.= ' and id_uppercat is NULL';
+ $query.= ' AND id_uppercat IS NULL';
}
else
{
- $query.= ' and id_uppercat = '.$id_uppercat;
+ $query.= ' AND id_uppercat = '.$id_uppercat;
}
$query.= ';';
$result = mysql_query( $query );
@@ -484,18 +455,19 @@ function insert_remote_image( $xml_dir, $category_id )
$pictures[$j] = $file;
// is the picture already existing in the database ?
- $query = 'select id,tn_ext';
- $query.= ' from '.PREFIX_TABLE.'images';
- $query.= ' where cat_id = '.$category_id;
- $query.= " and file = '".$file."'";
+ $query = 'SELECT id,tn_ext';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= " AND file = '".$file."'";
$query.= ';';
$result = mysql_query( $query );
$query = '';
if ( mysql_num_rows( $result ) == 0 )
{
- $query = 'insert into '.PREFIX_TABLE.'images';
- $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height)';
- $query.= ' values (';
+ $query = 'INSERT INTO '.PREFIX_TABLE.'images';
+ $query.= ' (file,storage_category_id,date_available,tn_ext';
+ $query.= ',filesize,width,height)';
+ $query.= ' VALUES (';
$query.= "'".$file."'";
$query.= ",'".$category_id."'";
$query.= ",'".$date."'";
@@ -505,6 +477,19 @@ function insert_remote_image( $xml_dir, $category_id )
$query.= ",'".$height."'";
$query.= ')';
$query.= ';';
+ // retrieving the id of newly inserted picture
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= " AND file = '".$file."'";
+ $query.= ';';
+ list( $image_id ) = mysql_fetch_array( mysql_query( $query ) );
+ // adding the link between this picture and its storage category
+ $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
+ $query.= ' (image_id,category_id) VALUES ';
+ $query.= ' ('.$image_id.','.$category_id.')';
+ $query.= ';';
+ mysql_query( $query );
$output.= $file;
$output.= ' <span style="font-weight:bold;">';
@@ -519,11 +504,11 @@ function insert_remote_image( $xml_dir, $category_id )
$row = mysql_fetch_array( $result );
if ( $row['tn_ext'] != $tn_ext )
{
- $query = 'update '.PREFIX_TABLE.'images';
- $query.= ' set';
+ $query = 'UPDATE '.PREFIX_TABLE.'images';
+ $query.= ' SET';
$query.= " tn_ext = '".$tn_ext."'";
- $query.= ' where cat_id = '.$category_id;
- $query.= " and file = '".$file."'";
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= " AND file = '".$file."'";
$query.= ';';
}
}
@@ -535,9 +520,9 @@ function insert_remote_image( $xml_dir, $category_id )
}
// we have to remove the pictures of the database not present in the xml file
// (ie deleted from the picture storage server)
- $query = 'select id,file';
- $query.= ' from '.PREFIX_TABLE.'images';
- $query.= ' where cat_id = '.$category_id;
+ $query = 'SELECT id,file';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
@@ -557,6 +542,8 @@ $tpl = array( 'update_default_title', 'update_only_cat', 'update_all',
'remote_site', 'update_part_research' );
templatize_array( $tpl, 'lang', $sub );
$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
+//-------------------------------------------------------- categories structure
+$page['plain_structure'] = get_plain_structure();
//-------------------------------------------- introduction : choices of update
// Display choice if "update" var is not specified
check_cat_id( $_GET['update'] );
diff --git a/admin/waiting.php b/admin/waiting.php
index 206705b8f..7b38a387c 100644
--- a/admin/waiting.php
+++ b/admin/waiting.php
@@ -20,7 +20,7 @@ include_once( './include/isadmin.inc.php' );
//--------------------------------------------------------------------- updates
if ( isset( $_POST['submit'] ) )
{
- $query = 'SELECT id,cat_id,file,tn_ext';
+ $query = 'SELECT id,storage_category_id,file,tn_ext';
$query.= ' FROM '.PREFIX_TABLE.'waiting';
$query.= " WHERE validated = 'false'";
$query.= ';';
@@ -39,6 +39,8 @@ if ( isset( $_POST['submit'] ) )
$query.= ' WHERE id = '.$row['id'];
$query.= ';';
mysql_query( $query );
+ // linking logically the picture to its storage category
+ $query = 'INSERT INTO';
}
else
{
@@ -49,14 +51,14 @@ if ( isset( $_POST['submit'] ) )
$query.= ';';
mysql_query( $query );
// deletion of the associated files
- $cat = get_cat_info( $row['cat_id'] );
- unlink( '.'.$cat['dir'].$row['file'] );
+ $dir = get_complete_dir( $row['storage_category_id'] );
+ unlink( '.'.$dir.$row['file'] );
if ( $row['tn_ext'] != '' )
{
$thumbnail = $conf['prefix_thumbnail'];
$thumbnail.= get_filename_wo_extension( $row['file'] );
$thumbnail.= '.'.$row['tn_ext'];
- $url = '.'.$cat['dir'].'thumbnail/'.$thumbnail;
+ $url = '.'.$dir.'thumbnail/'.$thumbnail;
unlink( $url );
}
}
@@ -70,10 +72,11 @@ $tpl = array( 'category','date','author','thumbnail','file','delete',
templatize_array( $tpl, 'lang', $sub );
//---------------------------------------------------------------- form display
$cat_names = array();
-$query = 'SELECT id,cat_id,file,username,mail_address,date,tn_ext';
+$query = 'SELECT id,storage_category_id,file,username,mail_address';
+$query.= ',date,tn_ext';
$query.= ' FROM '.PREFIX_TABLE.'waiting';
$query.= " WHERE validated = 'false'";
-$query.= ' ORDER BY cat_id';
+$query.= ' ORDER BY storage_category_id';
$query.= ';';
$result = mysql_query( $query );
$i = 0;
@@ -85,26 +88,24 @@ while ( $row = mysql_fetch_array( $result ) )
{
$vtp->setVar( $sub, 'picture.class', 'row2' );
}
- if ( !isset( $cat_names[$row['cat_id']] ) )
+ if ( !isset( $cat_names[$row['storage_category_id']] ) )
{
- $cat = get_cat_info( $row['cat_id'] );
- $cat_names[$row['cat_id']] = array();
- $cat_names[$row['cat_id']]['dir'] = '.'.$cat['dir'];
- $cat_names[$row['cat_id']]['display_name'] =
+ $cat = get_cat_info( $row['storage_category_id'] );
+ $cat_names[$row['storage_category_id']] = array();
+ $cat_names[$row['storage_category_id']]['dir'] =
+ '.'.get_complete_dir( $row['storage_category_id'] );
+ $cat_names[$row['storage_category_id']]['display_name'] =
get_cat_display_name( $cat['name'], ' &gt; ', 'font-weight:bold;' );
}
// category name
$vtp->setVar( $sub, 'picture.cat_name',
- $cat_names[$row['cat_id']]['display_name'] );
+ $cat_names[$row['storage_category_id']]['display_name'] );
// date displayed like this (in English ) :
// Sunday 15 June 2003 21:29
- $date = $lang['day'][date( 'w', $row['date'] )]; // Sunday
- $date.= date( ' j ', $row['date'] ); // 15
- $date.= $lang['month'][date( 'n', $row['date'] )]; // June
- $date.= date( ' Y G:i', $row['date'] ); // 2003 21:29
+ $date = format_date( $row['date'], 'unix', true );
$vtp->setVar( $sub, 'picture.date', $date );
// file preview link
- $url = $cat_names[$row['cat_id']]['dir'].$row['file'];
+ $url = $cat_names[$row['storage_category_id']]['dir'].$row['file'];
$vtp->setVar( $sub, 'picture.preview_url', $url );
// file name
$vtp->setVar( $sub, 'picture.file', $row['file'] );
@@ -115,7 +116,8 @@ while ( $row = mysql_fetch_array( $result ) )
$thumbnail = $conf['prefix_thumbnail'];
$thumbnail.= get_filename_wo_extension( $row['file'] );
$thumbnail.= '.'.$row['tn_ext'];
- $url = $cat_names[$row['cat_id']]['dir'].'thumbnail/'.$thumbnail;
+ $url = $cat_names[$row['storage_category_id']]['dir'];
+ $url.= 'thumbnail/'.$thumbnail;
$vtp->setVar( $sub, 'thumbnail.preview_url', $url );
$vtp->setVar( $sub, 'thumbnail.file', $thumbnail );
$vtp->closeSession( $sub, 'thumbnail' );
diff --git a/category.php b/category.php
index 6d8bb68a3..2264be614 100644
--- a/category.php
+++ b/category.php
@@ -231,22 +231,16 @@ else
//------------------------------------------------------------------ thumbnails
if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 )
{
- if ( is_numeric( $page['cat'] ) )
- {
- $cat_directory = $page['cat_dir'];
- }
- else if ( $page['cat'] == 'search' or $page['cat'] == 'fav' )
- {
- $array_cat_directories = array();
- }
+ $array_cat_directories = array();
- $query = 'SELECT id,file,date_available,tn_ext,name,filesize,cat_id';
+ $query = 'SELECT id,file,date_available,tn_ext,name,filesize';
+ $query.= ',storage_category_id,category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
$query.= $page['where'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$page['start'].','.$page['nb_image_page'];
$query.= ';';
- echo $query;
$result = mysql_query( $query );
$vtp->addSession( $handle, 'thumbnails' );
@@ -257,25 +251,18 @@ if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 )
$line_number = 1;
while ( $row = mysql_fetch_array( $result ) )
{
- if ( !is_numeric( $page['cat'] ) )
+ if ( $array_cat_directories[$row['storage_category_id']] == '' )
{
- if ( $array_cat_directories[$row['cat_id']] == '' )
- {
- $cat_result = get_cat_info( $row['cat_id'] );
- $array_cat_directories[$row['cat_id']] = $cat_result['dir'];
- }
- $cat_directory = $array_cat_directories[$row['cat_id']];
+ $array_cat_directories[$row['storage_category_id']] =
+ get_complete_dir( $row['storage_category_id'] );
}
+ $cat_directory = $array_cat_directories[$row['storage_category_id']];
+
$file = get_filename_wo_extension( $row['file'] );
// name of the picture
- if ( $row['name'] != '' )
- {
- $name = $row['name'];
- }
- else
- {
- $name = str_replace( '_', ' ', $file );
- }
+ if ( $row['name'] != '' ) $name = $row['name'];
+ else $name = str_replace( '_', ' ', $file );
+
if ( $page['cat'] == 'search' )
{
$name = replace_search( $name, $_GET['search'] );
@@ -358,16 +345,16 @@ elseif ( ( isset( $page['cat'] )
$cell_number = 1;
$i = 0;
foreach ( $subcats as $subcat_id => $non_empty_id ) {
- $subcat_infos = get_cat_info( $subcat_id );
- $non_empty_infos = get_cat_info( $non_empty_id );
+ $subcat_infos = get_cat_info( $subcat_id );
$name ='[ <span style="font-weight:bold;">';
$name.= $subcat_infos['name'][0];
$name.= '</span> ]';
-
- $query = 'SELECT file,tn_ext';
+
+ $query = 'SELECT file,tn_ext,storage_category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$non_empty_id;
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' WHERE category_id = '.$non_empty_id;
$query.= ' ORDER BY RAND()';
$query.= ' LIMIT 0,1';
$query.= ';';
@@ -377,7 +364,7 @@ elseif ( ( isset( $page['cat'] )
$file = get_filename_wo_extension( $image_row['file'] );
// creating links for thumbnail and associated category
- $thumbnail_link = $non_empty_infos['dir'];
+ $thumbnail_link = get_complete_dir( $image_row['storage_category_id'] );
$thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
$thumbnail_link.= $file.'.'.$image_row['tn_ext'];
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 3345ef55f..e28515e91 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -349,4 +349,30 @@ function templatize_array( $array, $global_array_name, $handle )
$vtp->setGlobalVar( $handle, $value, ${$global_array_name}[$value] );
}
}
+
+function format_date( $date, $type = 'us', $show_time = false )
+{
+ global $lang;
+
+ switch ( $type )
+ {
+ case 'us' :
+ list( $year,$month,$day ) = explode( '-', $date );
+ $unixdate = mktime(0,0,0,$month,$day,$year);
+ break;
+ case 'unix' :
+ $unixdate = $date;
+ break;
+ }
+ $formated_date = $lang['day'][date( "w", $unixdate )];
+ $formated_date.= date( " j ", $unixdate );
+ $formated_date.= $lang['month'][date( "n", $unixdate )];
+ $formated_date.= date( ' Y', $unixdate );
+ if ( $show_time )
+ {
+ $formated_date.= date( ' G:i', $unixdate );
+ }
+
+ return $formated_date;
+}
?> \ No newline at end of file
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 031011b61..dffb6c337 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -94,7 +94,7 @@ function check_cat_id( $cat )
function get_plain_structure()
{
$infos = array( 'name','id','date_last','nb_images','dir','id_uppercat',
- 'rank');
+ 'rank','site_id');
$query = 'SELECT ';
foreach ( $infos as $i => $info ) {
@@ -270,7 +270,7 @@ function count_images( $categories )
// variables :
// $cat['comment']
// $cat['dir']
-// $cat['last_dir']
+// $cat['dir']
// $cat['name'] is an array :
// - $cat['name'][0] is the lowest cat name
// and
@@ -280,11 +280,12 @@ function count_images( $categories )
// $cat['site_id']
function get_cat_info( $id )
{
+ global $page;
+
$cat = array();
- $cat['name'] = array();
$query = 'SELECT nb_images,id_uppercat,comment,site_id,galleries_url,dir';
- $query.= ',date_last,uploadable';
+ $query.= ',date_last,uploadable,status,visible';
$query.= ' FROM '.PREFIX_TABLE.'categories AS a';
$query.= ', '.PREFIX_TABLE.'sites AS b';
$query.= ' WHERE a.id = '.$id;
@@ -294,42 +295,64 @@ function get_cat_info( $id )
$cat['id_uppercat'] = $row['id_uppercat'];
$cat['comment'] = nl2br( $row['comment'] );
$cat['nb_images'] = $row['nb_images'];
- $cat['last_dir'] = $row['dir'];
+ $cat['dir'] = $row['dir'];
$cat['date_last'] = $row['date_last'];
$cat['uploadable'] = get_boolean( $row['uploadable'] );
- $galleries_url = $row['galleries_url'];
+ $cat['status'] = $row['status'];
+ $cat['visible'] = get_boolean( $row['visible'] );
- $cat['dir'] = "";
- $i = 0;
- $is_root = false;
- $row['id_uppercat'] = $id;
- while ( !$is_root )
+ $cat['name'] = array();
+ array_push( $cat['name'], $page['plain_structure'][$id]['name'] );
+ while ( $page['plain_structure'][$id]['id_uppercat'] != '' )
{
- $query = 'SELECT name,dir,id_uppercat';
- $query.= ' FROM '.PREFIX_TABLE.'categories';
- $query.= ' WHERE id = '.$row['id_uppercat'].';';
- $row = mysql_fetch_array( mysql_query( $query ) );
- $cat['dir'] = $row['dir'].'/'.$cat['dir'];
- if ( $row['name'] == "" )
- {
- $cat['name'][$i] = str_replace( "_", " ", $row['dir'] );
- }
- else
- {
- $cat['name'][$i] = $row['name'];
- }
- if ( $row['id_uppercat'] == "" )
- {
- $is_root = true;
- }
- $i++;
+ $id = $page['plain_structure'][$id]['id_uppercat'];
+ array_push( $cat['name'], $page['plain_structure'][$id]['name'] );
}
- $cat['local_dir'] = substr( $cat['dir'], 0 , strlen( $cat['dir'] ) - 1 );
- $cat['dir'] = $galleries_url.$cat['dir'];
-
return $cat;
}
-
+
+// get_complete_dir returns the concatenation of get_site_url and
+// get_local_dir
+// Example : "pets > rex > 1_year_old" is on the the same site as the
+// PhpWebGallery files and this category has 22 for identifier
+// get_complete_dir(22) returns "./galleries/pets/rex/1_year_old/"
+function get_complete_dir( $category_id )
+{
+ return get_site_url( $category_id ).get_local_dir( $category_id );
+}
+
+// get_local_dir returns an array with complete path without the site url
+// Example : "pets > rex > 1_year_old" is on the the same site as the
+// PhpWebGallery files and this category has 22 for identifier
+// get_local_dir(22) returns "pets/rex/1_year_old/"
+function get_local_dir( $category_id )
+{
+ global $page;
+
+ // creating the local path : "root_cat/sub_cat/sub_sub_cat/"
+ $dir = $page['plain_structure'][$category_id]['dir'].'/';
+ while ( $page['plain_structure'][$category_id]['id_uppercat'] != '' )
+ {
+ $category_id = $page['plain_structure'][$category_id]['id_uppercat'];
+ $dir = $page['plain_structure'][$category_id]['dir'].'/'.$dir;
+ }
+ return $dir;
+}
+
+// retrieving the site url : "http://domain.com/gallery/" or
+// simply "./galleries/"
+function get_site_url( $category_id )
+{
+ global $page;
+
+ $query = 'SELECT galleries_url';
+ $query.= ' FROM '.PREFIX_TABLE.'sites';
+ $query.= ' WHERE id = '.$page['plain_structure'][$category_id]['site_id'];
+ $query.= ';';
+ $row = mysql_fetch_array( mysql_query( $query ) );
+ return $row['galleries_url'];
+}
+
// The function get_cat_display_name returns a string containing the list
// of upper categories to the root category from the lowest category shown
// example : "anniversaires - fete mere 2002 - animaux - erika"
@@ -401,7 +424,7 @@ function initialize_category( $calling_page = 'category' )
$page['cat_site_id'] = $result['site_id'];
$page['cat_uploadable'] = $result['uploadable'];
$page['title'] = get_cat_display_name( $page['cat_name'], ' - ', '' );
- $page['where'] = ' WHERE cat_id = '.$page['cat'];
+ $page['where'] = ' WHERE category_id = '.$page['cat'];
}
else
{
@@ -411,7 +434,7 @@ function initialize_category( $calling_page = 'category' )
// we must not show pictures of a forbidden category
$restricted_cats = get_all_restrictions( $user['id'],$user['status'] );
foreach ( $restricted_cats as $restricted_cat ) {
- $where_append.= ' AND cat_id != '.$restricted_cat;
+ $where_append.= ' AND category_id != '.$restricted_cat;
}
}
// search result
@@ -499,7 +522,7 @@ function initialize_category( $calling_page = 'category' )
else if ( $page['cat'] == 'most_visited' )
{
$page['title'] = $conf['top_number'].' '.$lang['most_visited_cat'];
- $page['where'] = ' WHERE cat_id != -1'.$where_append;
+ $page['where'] = ' WHERE category_id != -1'.$where_append;
$conf['order_by'] = ' ORDER BY hit DESC, file ASC';
$page['cat_nb_images'] = $conf['top_number'];
if ( $page['start'] + $user['nb_image_page'] >= $conf['top_number'] )
diff --git a/language/francais.php b/language/francais.php
index f0f4b24eb..5c7307b05 100644
--- a/language/francais.php
+++ b/language/francais.php
@@ -29,6 +29,8 @@ $lang['IP'] = 'IP';
$lang['close'] = 'fermer';
$lang['open'] = 'ouvrir';
$lang['keywords'] = 'mots-clefs';
+$lang['errors_title'] = 'Erreurs';
+$lang['default'] = 'défaut';
// end version 1.3
// page diapo
@@ -264,6 +266,7 @@ if ( $isadmin )
$lang['title_cat_perm'] = 'Modifier les permissions pour la catégorie';
$lang['title_group_perm'] = 'Modifier les permissions pour le groupe';
$lang['title_comments'] = 'Commentaires des visiteurs';
+ $lang['title_picmod'] = 'Modifier les informations d\'une image';
// end version 1.3
$lang['title_categories'] = 'Gestion des catégories';
$lang['title_edit_cat'] = 'Editer une catégorie';
@@ -511,6 +514,7 @@ if ( $isadmin )
$lang['infoimage_keyword_separation'] = '(séparer avec des ",")';
$lang['infoimage_addtoall'] = 'ajouter à tous';
$lang['infoimage_removefromall'] = 'retirer à tous';
+ $lang['infoimage_associate'] = 'Associer à la catégorie';
// end version 1.3
$lang['infoimage_general'] = 'Options générale pour la catégorie';
$lang['infoimage_useforall'] = 'utiliser pour toutes les images ?';
diff --git a/picture.php b/picture.php
index 4261a6205..96605607b 100644
--- a/picture.php
+++ b/picture.php
@@ -23,6 +23,7 @@ include_once( './include/init.inc.php' );
//-------------------------------------------------- access authorization check
check_cat_id( $_GET['cat'] );
check_login_authorization();
+$page['plain_structure'] = get_plain_structure();
if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
{
check_restrictions( $page['cat'] );
@@ -38,8 +39,10 @@ initialize_category( 'picture' );
$cat_directory = $page['cat_dir']; // by default
//------------------------------------- main picture information initialization
$query = 'SELECT id,date_available,comment,hit,keywords';
-$query.= ',author,name,file,date_creation,filesize,width,height,cat_id';
+$query.= ',author,name,file,date_creation,filesize,width,height';
+$query.= ',storage_category_id,category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
+$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
$query.= $page['where'];
$query.= ' AND id = '.$_GET['image_id'];
$query.= $conf['order_by'];
@@ -57,11 +60,13 @@ $page['date_creation'] = $row['date_creation'];
$page['filesize'] = $row['filesize'];
$page['width'] = $row['width'];
$page['height'] = $row['height'];
-$page['cat_id'] = $row['cat_id'];
+$page['category_id'] = $row['category_id'];
$page['keywords'] = $row['keywords'];
+$page['storage_category_id'] = $row['storage_category_id'];
// retrieving the number of the picture in its category (in order)
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'images';
+$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
$query.= $page['where'];
$query.= $conf['order_by'];
$query.= ';';
@@ -123,6 +128,7 @@ if ( isset( $_GET['add_fav'] ) )
}
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
$query.= $page['where'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$page['num'].',1';
@@ -205,8 +211,9 @@ else
if ( $page['num'] >= 1 )
{
$prev = $page['num'] - 1;
- $query = 'SELECT id,name,file,tn_ext,cat_id';
+ $query = 'SELECT id,name,file,tn_ext,storage_category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
$query.= $page['where'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$prev.',1';
@@ -214,20 +221,17 @@ if ( $page['num'] >= 1 )
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );
- if ( !is_numeric( $page['cat'] ) )
+ if ( $array_cat_directories[$row['storage_category_id']] == '' )
{
- if ( $array_cat_directories[$row['cat_id']] == '' )
- {
- $cat_result = get_cat_info( $row['cat_id'] );
- $array_cat_directories[$row['cat_id']] = $cat_result['dir'];
- }
- $cat_directory = $array_cat_directories[$row['cat_id']];
+ $array_cat_directories[$row['storage_category_id']] =
+ get_complete_dir( $row['storage_category_id'] );
}
-
- $file = substr ( $row['file'], 0, strrpos ( $row['file'], '.' ) );
+ $cat_directory = $array_cat_directories[$row['storage_category_id']];
+
+ $file = substr( $row['file'], 0, strrpos ( $row['file'], '.' ) );
$lien_thumbnail = $cat_directory.'/thumbnail/';
$lien_thumbnail.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext'];
-
+
$prev_title = $lang['previous_image'].' : ';
$alt_thumbnaill = '';
if ( $row['name'] != '' ) $alt_thumbnail = $row['name'];
@@ -261,14 +265,16 @@ if ( is_numeric( $page['cat'] ) )
}
else
{
- $cat_result = get_cat_info( $page['cat_id'] );
- if ( $array_cat_directories[$page['cat_id']] == "" )
- {
- $array_cat_directories[$page['cat_id']] = $cat_result['dir'];
- }
- $cat_directory = $array_cat_directories[$page['cat_id']];
$intitule_cat = $page['title'];
}
+
+if ( $array_cat_directories[$page['storage_category_id']] == '' )
+{
+ $array_cat_directories[$page['storage_category_id']] =
+ get_complete_dir( $page['storage_category_id'] );
+}
+$cat_directory = $array_cat_directories[$page['storage_category_id']];
+
$n = $page['num'] + 1;
$intitule_titre = replace_space( $intitule_cat." - " ).$n.'/'.
$intitule_titre.= $page['cat_nb_images']."<br />";
@@ -347,9 +353,8 @@ if ( $page['date_creation'] != "" )
{
$vtp->addSession( $handle, 'info_line' );
$vtp->setVar( $handle, 'info_line.name', $lang['creation_date'].' : ' );
- list( $year,$month,$day ) = explode( '-', $page['date_creation'] );
$vtp->setVar( $handle, 'info_line.content',
- $day.'/'.$month.'/'.$year );
+ format_date( $page['date_creation'] ) );
$vtp->closeSession( $handle, 'info_line' );
}
// date of availability
@@ -357,7 +362,7 @@ $vtp->addSession( $handle, 'info_line' );
$vtp->setVar( $handle, 'info_line.name', $lang['registration_date'].' : ' );
list( $year,$month,$day ) = explode( '-', $page['date_available'] );
$vtp->setVar( $handle, 'info_line.content',
- $day.'/'.$month.'/'.$year );
+ format_date( $page['date_available'] ) );
$vtp->closeSession( $handle, 'info_line' );
// size in pixels
$vtp->addSession( $handle, 'info_line' );
@@ -455,34 +460,31 @@ if ( $page['cat'] == 'fav' )
if ( $user['status'] == "admin" and is_numeric( $page['cat'] ) )
{
$vtp->addSession( $handle, 'modification' );
- $url = './admin/admin.php?page=infos_images&amp;cat_id='.$page['cat'];
- $url.= '&amp;num='.$page['num'];
- $vtp->setVar( $handle, 'modification.link',
- add_session_id( $url )."#".$page['id'] );
+ $url = './admin/admin.php?page=picture_modify&amp;cat_id='.$page['cat'];
+ $url.= '&amp;image_id='.$page['id'];
+ $vtp->setVar( $handle, 'modification.link', add_session_id( $url ) );
$vtp->setVar( $handle, 'modification.name', $lang['link_info_image'] );
}
//---------------------------------------------- next picture thumbnail display
if ( $page['num'] < $page['cat_nb_images']-1 )
{
$next = $page['num'] + 1;
- $query = 'SELECT id,name,file,tn_ext,cat_id';
+ $query = 'SELECT id,name,file,tn_ext,storage_category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
$query.= $page['where'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$next.',1';
$query.= ';';
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );
-
- if ( !is_numeric( $page['cat'] ) )
+
+ if ( $array_cat_directories[$row['storage_category_id']] == '' )
{
- if ( $array_cat_directories[$row['cat_id']] == "" )
- {
- $cat_result = get_cat_info( $row['cat_id'] );
- $array_cat_directories[$row['cat_id']] = $cat_result['dir'];
- }
- $cat_directory = $array_cat_directories[$row['cat_id']];
+ $array_cat_directories[$row['storage_category_id']] =
+ get_complete_dir( $row['storage_category_id'] );
}
+ $cat_directory = $array_cat_directories[$row['storage_category_id']];
$file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") );
$lien_thumbnail = $cat_directory.'thumbnail/';
@@ -629,11 +631,8 @@ if ( $conf['show_comments'] )
{
$vtp->addSession( $handle, 'comment' );
$vtp->setVar( $handle, 'comment.author', $row['author'] );
- $displayed_date = $lang['day'][date( "w", $row['date'] )];
- $displayed_date.= date( " j ", $row['date'] );
- $displayed_date.= $lang['month'][date( "n", $row['date'] )];
- $displayed_date.= date( ' Y G:i', $row['date'] );
- $vtp->setVar( $handle, 'comment.date', $displayed_date );
+ $vtp->setVar( $handle, 'comment.date',
+ format_date( $row['date'], 'unix', true ) );
$vtp->setVar( $handle, 'comment.content', nl2br( $row['content'] ) );
if ( $user['status'] == 'admin' )
{
diff --git a/template/default/admin/configuration.vtp b/template/default/admin/configuration.vtp
index 240f0e408..162e530ee 100644
--- a/template/default/admin/configuration.vtp
+++ b/template/default/admin/configuration.vtp
@@ -1,6 +1,6 @@
<!--VTP_errors-->
<div class="errors">
- <div class="errors_title">Erreurs</div>
+ <div class="errors_title">{#errors_title}</div>
<ul>
<!--VTP_li-->
<li>{#li}</li>
diff --git a/template/default/admin/infos_image.vtp b/template/default/admin/infos_image.vtp
index d9a4e92c5..975621077 100644
--- a/template/default/admin/infos_image.vtp
+++ b/template/default/admin/infos_image.vtp
@@ -42,12 +42,13 @@
</table>
<table width="100%">
<tr>
- <th colspan="6">{#infoimage_detailed}</th>
+ <th colspan="7">{#infoimage_detailed}</th>
</tr>
<tr>
- <td colspan="6" align="center">{#navigation_bar}</td>
+ <td colspan="7" align="center">{#navigation_bar}</td>
</tr>
<tr>
+ <td style="width:0px;">&nbsp;</td>
<td class="row2" style="text-align:center;">{#thumbnail}</td>
<td class="row2" style="text-align:center;">{#infoimage_title}</td>
<td class="row2" style="text-align:center;">{#author}</td>
@@ -57,6 +58,11 @@
</tr>
<!--VTP_picture-->
<tr>
+ <td style="width:0px;">
+ <div style="margin-left:2px;margin-right:2px;">
+ <input type="checkbox" name="check-{#id}" value="1" />
+ </div>
+ </td>
<td style="text-align:center;"><a name="{#link}" href="{#url}"><img src="{#thumbnail_url}" alt="" class="miniature" title="{#filename}" /></td>
<td style="text-align:center;">{#default_name}<br /><input type="text" name="name-{#id}" value="{#name}" maxlength="255"/></td>
<td style="text-align:center;"><input type="text" name="author-{#id}" value="{#author}" maxlength="255"/></td>
@@ -66,6 +72,17 @@
</tr>
<!--/VTP_picture-->
<tr>
+ <td colspan="6">
+ <img src="../template/{#user_template}/admin/images/arrow_up.gif" alt="&lt;" />
+ {#infoimage_associate}
+ <select name="associate">
+ <!--VTP_associate_cat-->
+ <option value="{#value}">{#content}</option>
+ <!--/VTP_associate_cat-->
+ </select>
+ </td>
+ </tr>
+ <tr>
<td colspan="6" style="text-align:center;">
<input type="submit" value="{#submit}" name="submit" />
</td>
diff --git a/template/default/admin/picture_modify.vtp b/template/default/admin/picture_modify.vtp
new file mode 100644
index 000000000..79029ef75
--- /dev/null
+++ b/template/default/admin/picture_modify.vtp
@@ -0,0 +1,101 @@
+<!--VTP_errors-->
+<div class="errors">
+ <div class="errors_title">{#errors_title}</div>
+ <ul>
+ <!--VTP_li-->
+ <li>{#content}</li>
+ <!--/VTP_li-->
+ </ul>
+</div>
+<!--/VTP_errors-->
+<!--VTP_confirmation-->
+<div class="info">
+ {#picmod_update} [ <a href="{#url}">{#picmod_back}</a> ]
+</div>
+<!--/VTP_confirmation-->
+<form method="post" action="{#form_action}">
+ <table style="width:100%;">
+ <tr><th colspan="2">{#title} [ {#dir} &gt; {#f_file} ]</th></tr>
+ <tr>
+ <td colspan="2"><div style="margin-bottom:0px">&nbsp;</div></td>
+ </tr>
+ <tr valign="top">
+ <td style="width:1px;"><img src="{#thumbnail_url}" alt="" class="miniature" /></td>
+ <td>
+ <table>
+ <tr>
+ <td>{#upload_name} :</td>
+ <td><input type="text" name="name" value="{#f_name}" /> [ {#default} : {#default_name} ]</td>
+ </tr>
+ <tr>
+ <td>{#file} :</td>
+ <td>{#f_file}</td>
+ </tr>
+ <tr>
+ <td>{#size} :</td>
+ <td>{#f_size}</td>
+ </tr>
+ <tr>
+ <td>{#filesize} :</td>
+ <td>{#f_filesize}</td>
+ </tr>
+ <tr>
+ <td>{#registration_date} :</td>
+ <td>{#f_registration_date}</td>
+ </tr>
+ <tr>
+ <td>{#author} :</td>
+ <td><input type="text" name="author" value="{#f_author}" /></td>
+ </tr>
+ <tr>
+ <td>{#creation_date} :</td>
+ <td><input type="text" name="creation_date" value="{#f_creation_date}" /></td>
+ </tr>
+ <tr>
+ <td>{#keywords} :</td>
+ <td><input type="text" name="keywords" value="{#f_keywords}" size="50" /></td>
+ </tr>
+ <tr>
+ <td>{#comment} :</td>
+ <td><textarea name="comment" rows="5" cols="50" style="overflow:auto">{#f_comment}</textarea></td>
+ </tr>
+ <tr>
+ <td valign="top">{#categories} :</td>
+ <td>
+ <table>
+ <!--VTP_linked_category-->
+ <tr>
+ <td><!--VTP_checkbox--><input type="checkbox" name="dissociate-{#id}" value="1" /><!--/VTP_checkbox--><a href="{#url}">{#name}</a> [ <a href="{#infos_images_link}">{#cat_image_info}</a> ] {#private} {#invisible}
+ </tr>
+ <!--/VTP_linked_category-->
+ <!--VTP_dissociate-->
+ <tr>
+ <td colspan="2"><img src="../template/{#user_template}/admin/images/arrow_up.gif" alt="&lt;" /> {#dissociate}</td>
+ </tr>
+ <!--/VTP_dissociate-->
+ <tr><td colspan="2">&nbsp;</td></tr>
+ <tr>
+ <td>{#infoimage_associate}
+ <select name="associate">
+ <!--VTP_associate_cat-->
+ <option value="{#value}">{#content}</option>
+ <!--/VTP_associate_cat-->
+ </select>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"><div style="margin-bottom:0px">&nbsp;</div></td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center">
+ <input type="submit" name="submit" value="{#submit}">
+ </td>
+ </tr>
+ </table>
+</form>
diff --git a/upload.php b/upload.php
index abf3ce1a8..44f1d357f 100644
--- a/upload.php
+++ b/upload.php
@@ -205,8 +205,9 @@ if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) )
if ( sizeof( $error ) == 0 )
{
$query = 'insert into '.PREFIX_TABLE.'waiting';
- $query.= ' (cat_id,file,username,mail_address,date,infos) values';
- $query.= " (".$page['cat'].",'".$_FILES['picture']['name']."'";
+ $query.= ' (storage_category_id,file,username,mail_address,date,infos)';
+ $query.= ' values ';
+ $query.= '('.$page['cat'].",'".$_FILES['picture']['name']."'";
$query.= ",'".htmlspecialchars( $_POST['username'], ENT_QUOTES)."'";
$query.= ",'".$_POST['mail_address']."',".time().",'".$xml_infos."')";
$query.= ';';