From aac81a8a382f7ec527e22d6dee959400d77e1a21 Mon Sep 17 00:00:00 2001 From: z0rglub Date: Sun, 18 May 2003 21:42:32 +0000 Subject: *** empty log message *** git-svn-id: http://piwigo.org/svn/trunk@14 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/edit_cat.php | 188 +++++++++--------- admin/include/functions.php | 4 +- admin/infos_images.php | 450 +++++++++++++++++++++----------------------- 3 files changed, 303 insertions(+), 339 deletions(-) (limited to 'admin') diff --git a/admin/edit_cat.php b/admin/edit_cat.php index c813bac66..9075039cc 100644 --- a/admin/edit_cat.php +++ b/admin/edit_cat.php @@ -1,9 +1,9 @@ * * * ***************************************************************************/ @@ -14,103 +14,87 @@ * the Free Software Foundation; * * * ***************************************************************************/ - include_once( "./include/isadmin.inc.php" ); - - if ( $HTTP_GET_VARS['valider'] == 1 ) - { - $query = "update PREFIX_TABLE"."categories "; - if ( $HTTP_POST_VARS['name'] == "" ) - { - $query.= "set name = NULL, "; - } - else - { - $query.= "set name = '".htmlspecialchars( $HTTP_POST_VARS['name'], ENT_QUOTES)."', "; - } - if ( $HTTP_POST_VARS['comment'] == "" ) - { - $query.= "comment = NULL, "; - } - else - { - $query.= "comment = '".htmlspecialchars( $HTTP_POST_VARS['comment'], ENT_QUOTES )."', "; - } - $query.= "status = '".$HTTP_POST_VARS['status']."' "; - $query.= "where id = '".$HTTP_GET_VARS['cat']."';"; - mysql_query( $query ); - - $result = mysql_query( "select id from PREFIX_TABLE"."users where pseudo != '".$conf['webmaster']."';" ); - while ( $row = mysql_fetch_array ( $result ) ) - { - check_favorites( $row['id'] ); - } - - echo"
".$lang['editcat_confirm']." [ ".$lang['editcat_back']." ]
"; - } - - echo " -
- "; - $query = "select a.id,name,dir,status,comment,id_uppercat,site_id,galleries_url"; - $query.= " from PREFIX_TABLE"."categories as a, PREFIX_TABLE"."sites as b"; - $query.= " where a.id = ".$HTTP_GET_VARS['cat']; - $query.= " and a.site_id = b.id;"; - $row = mysql_fetch_array( mysql_query( $query ) ); - $result = get_cat_info( $row['id'] ); - $array_cat_names = $result['name']; - echo " - - - "; - if ( $row['site_id'] != 1 ) - { - echo " - - - - "; - } - echo " - - - - - - - - - - - - - - - - - - -
".$lang['editcat_title1']." ".$lang['category']." \"".get_cat_display_name( $array_cat_names, " - ", "font-style:italic;" )."\" [ dir : ".$row['dir']." ]
Server".$row['galleries_url']."
".$lang['editcat_name']."
".$lang['editcat_comment']."
".$lang['editcat_status']." - - ".$lang['editcat_status_info']." -
 
-
"; + +include_once( './include/isadmin.inc.php' ); +//----------------------------------------------------- template initialization +$sub = $vtp->Open( '../template/'.$user['template'].'/admin/edit_cat.vtp' ); +$tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1', + 'editcat_name', 'editcat_comment', 'editcat_status', + 'editcat_status_info', 'submit' ); +templatize_array( $tpl, 'lang', $sub ); +//--------------------------------------------------------- form criteria check +if ( isset( $_POST['submit'] ) ) +{ + $query = 'UPDATE '.PREFIX_TABLE.'categories'; + if ( $_POST['name'] == '' ) + { + $query.= ' SET name = NULL'; + } + else + { + $query.= " SET name = '".htmlentities( $_POST['name'], ENT_QUOTES)."'"; + } + if ( $_POST['comment'] == '' ) + { + $query.= ', comment = NULL'; + } + else + { + $query.= ", comment = '".htmlentities( $_POST['comment'], ENT_QUOTES )."'"; + } + $query.= ", status = '".$_POST['status']."'"; + $query.= " WHERE id = '".$_GET['cat']."'"; + $query.= ';'; + mysql_query( $query ); + + $query = 'SELECT id'; + $query.= ' FROM '.PREFIX_TABLE.'users'; + $query.= " WHERE username != '".$conf['webmaster']."'"; + $query.= ';'; + $result = mysql_query( $query ); + while ( $row = mysql_fetch_array ( $result ) ) + { + check_favorites( $row['id'] ); + } + $vtp->addSession( $sub, 'confirmation' ); + $url = add_session_id( './admin.php?page=cat' ); + $vtp->setVar( $sub, 'confirmation.back_url', $url ); + $vtp->closeSession( $sub, 'confirmation' ); +} +//------------------------------------------------------------------------ form +$form_action = './admin.php?page=edit_cat&cat='.$_GET['cat']; +$vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) ); + +$query = 'SELECT a.id,name,dir,status,comment'; +$query.= ',id_uppercat,site_id,galleries_url'; +$query.= ' FROM '.PREFIX_TABLE.'categories as a, '.PREFIX_TABLE.'sites as b'; +$query.= ' WHERE a.id = '.$_GET['cat']; +$query.= ' AND a.site_id = b.id'; +$query.= ';'; +$row = mysql_fetch_array( mysql_query( $query ) ); +$result = get_cat_info( $row['id'] ); + +$cat_name = get_cat_display_name( $result['name'], ' - ', '' ); +$vtp->setVar( $sub, 'cat:name', $cat_name ); +$vtp->setVar( $sub, 'cat:dir', $row['dir'] ); +if ( $row['site_id'] != 1 ) +{ + $vtp->addSession( $sub, 'server' ); + $vtp->setVar( $sub, 'server.url', $row['galleries_url'] ); + $vtp->closeSession( $sub, 'server' ); +} +$vtp->setVar( $sub, 'name', $row['name'] ); +$vtp->setVar( $sub, 'comment', $row['comment'] ); +$options = get_enums( PREFIX_TABLE.'categories', 'status' ); +foreach ( $options as $option ) { + $vtp->addSession( $sub, 'status_option' ); + $vtp->setVar( $sub, 'status_option.option', $option ); + if ( $option == $row['status'] ) + { + $vtp->setVar( $sub, 'status_option.selected', ' selected="selected"' ); + } + $vtp->closeSession( $sub, 'status_option' ); +} +//----------------------------------------------------------- sending html code +$vtp->Parse( $handle , 'sub', $sub ); ?> \ No newline at end of file diff --git a/admin/include/functions.php b/admin/include/functions.php index 0828f0e06..ee7068c18 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -15,11 +15,11 @@ * * ***************************************************************************/ -$tab_ext_create_TN = array ( 'jpg', 'png' ); +$tab_ext_create_TN = array ( 'jpg', 'png', 'JPG', 'PNG' ); function is_image( $filename, $create_thumbnail = false ) { - global $conf; + global $conf, $tab_ext_create_TN; if ( is_file ( $filename ) ) { diff --git a/admin/infos_images.php b/admin/infos_images.php index f1921c6d3..92a7a3885 100644 --- a/admin/infos_images.php +++ b/admin/infos_images.php @@ -1,9 +1,9 @@ * * * ***************************************************************************/ @@ -14,235 +14,215 @@ * the Free Software Foundation; * * * ***************************************************************************/ - function check_date_format ( $date ) - { - // la date arrive à ce format : JJ/MM/AAAA - // checkdate ( int month, int day, int year) - $tab_date = explode( "/", $date ); - return checkdate ( $tab_date[1], $tab_date[0], $tab_date[2]); - } - - function date_convert( $date ) - { - // la date arrive à ce format : JJ/MM/AAAA - // il faut la transformer en AAAA-MM-JJ - $tab_date = explode( "/", $date ); - return $tab_date[2]."-".$tab_date[1]."-".$tab_date[0]; - } - - function date_convert_back( $date ) - { - // la date arrive à ce format : AAAA-MM-JJ - // il faut la transformer en JJ/MM/AAAA - if ( $date != "" ) - { - $tab_date = explode( "-", $date ); - return $tab_date[2]."/".$tab_date[1]."/".$tab_date[0]; - } - else - { - return ""; - } - } - - include_once( "./include/isadmin.inc.php" ); - $page['nb_image_page'] = 5; - check_cat_id( $HTTP_GET_VARS['cat_id'] ); - if ( isset( $page['cat'] ) ) - { - //------------------------------------------------------------mises à jour - // 1. options individuelles - $query = "select id,file "; - $query.= "from PREFIX_TABLE"."images "; - $query.= "where cat_id = ".$page['cat']." "; - $result = mysql_query( $query ); - $i = 1; - while ( $row = mysql_fetch_array( $result ) ) - { - $name = "name-".$row['id']; - $author = "author-".$row['id']; - $comment = "comment-".$row['id']; - $date_creation = "date_creation-".$row['id']; - if ( isset( $HTTP_POST_VARS[$name] ) ) - { - $query = "update PREFIX_TABLE"."images "; - if ( $HTTP_POST_VARS[$name] == "" ) - { - $query.= "set name = NULL "; - } - else - { - $query.= "set name = '".htmlspecialchars( $HTTP_POST_VARS[$name], ENT_QUOTES )."' "; - } - if ( $HTTP_POST_VARS[$author] == "" ) - { - $query.= ", author = NULL "; - } - else - { - $query.= ", author = '".htmlspecialchars( $HTTP_POST_VARS[$author], ENT_QUOTES )."' "; - } - if ( $HTTP_POST_VARS[$comment] == "" ) - { - $query.= ", comment = NULL "; - } - else - { - $query.= ", comment = '".htmlspecialchars( $HTTP_POST_VARS[$comment], ENT_QUOTES )."' "; - } - if ( check_date_format( $HTTP_POST_VARS[$date_creation] ) ) - { - $date = date_convert( $HTTP_POST_VARS[$date_creation] ); - $query.= ", date_creation = '$date' "; - } - else if ( $HTTP_POST_VARS[$date_creation] == "" ) - { - $query.= ", date_creation = NULL "; - } - $query.= "where id = '".$row['id']."';"; - mysql_query( $query ); - } - } - // 2. options générales - if ( $HTTP_POST_VARS['use_common_author'] == 1 ) - { - $query = "update PREFIX_TABLE"."images "; - if ( $HTTP_POST_VARS['author_cat'] == "" ) - { - $query.= "set author = NULL "; - } - else - { - $query.= "set author = '".$HTTP_POST_VARS['author_cat']."' "; - } - $query.= "where cat_id = ".$page['cat'].";"; - mysql_query( $query ); - } - if ( $HTTP_POST_VARS['use_common_date_creation'] == 1 ) - { - // la date arrive à ce format : JJ/MM/AAAA - // il faut la transformer en AAAA-MM-JJ - if ( check_date_format( $HTTP_POST_VARS['date_creation_cat'] ) ) - { - $date = date_convert( $HTTP_POST_VARS['date_creation_cat'] ); - $query = "update PREFIX_TABLE"."images "; - if ( $HTTP_POST_VARS['date_creation_cat'] == "" ) - { - $query.= "set date_creation = NULL "; - } - else - { - $query.= "set date_creation = '$date' "; - } - $query.= "where cat_id = ".$page['cat'].";"; - mysql_query( $query ); - } - else - { - echo $lang['infoimage_err_date']; - } - } - //----------------------------------------------------affichage de la page - // détection de la page en cours - if( !isset( $HTTP_GET_VARS['start'] ) || !is_numeric( $HTTP_GET_VARS['start'] ) || ( is_numeric( $HTTP_GET_VARS['start'] ) && $HTTP_GET_VARS['start'] < 0 ) ) - { - $page['start'] = 0; - } - else - { - $page['start'] = $HTTP_GET_VARS['start']; - } - - if ( is_numeric( $HTTP_GET_VARS['num'] ) && $HTTP_GET_VARS['num'] >= 0 ) - { - $page['start'] = floor( $HTTP_GET_VARS['num'] / $page['nb_image_page'] ) * $page['nb_image_page']; - } - // retrieving category information - $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']; - - $url = "./admin.php?page=infos_images&cat_id=".$page['cat']; - $page['navigation_bar'] = create_navigation_bar( $url, $cat['nb_images'], $page['start'], $page['nb_image_page'], "" ); - echo" -
- - - - - - - - - - - - - - -
".$lang['infoimage_general']." \"".get_cat_display_name( $cat['name'], " - ", "font-style:italic;" )."\"
".$lang['author']."
".$lang['infoimage_useforall']."
".$lang['infoimage_creation_date']." [DD/MM/YYYY]
".$lang['infoimage_useforall']."
"; - echo" - - - - - - - - - - - - - - "; - $query = "select id,file,comment,author,tn_ext,name,date_creation"; - $query.= " from PREFIX_TABLE"."images"; - $query.= " where cat_id = ".$page['cat']; - $query.= $conf['order_by']; - $query.= " limit ".$page['start'].",".$page['nb_image_page']; - $query.= ";"; - $result = mysql_query( $query ); - $i = 1; - while ( $row = mysql_fetch_array( $result ) ) - { - echo" - "; - // création des liens vers la miniature - $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") ); - if ( $cat['site_id'] == 1 ) - { - $lien_thumbnail = "../galleries/".$cat['local_dir']."/"; - } - else - { - $lien_thumbnail = $cat['dir']; - } - $lien_thumbnail.= "thumbnail/".$conf['prefixe_thumbnail'].$file.".".$row['tn_ext']; - // création du "style" de la ligne - $style = "style=\"text-align:center;\""; - if ( $i%2 == 0 ) - { - $style.= " class=\"row2\""; - } - echo" - - - - - "; - echo" - "; - $i++; - } - echo" - - - -
".$lang['infoimage_detailed']."
".$page['navigation_bar']."
".$lang['thumbnail']."".$lang['infoimage_title']."".$lang['author']."".$lang['infoimage_comment']."".$lang['infoimage_creation_date']."
\"\"$file
-
"; - } + +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 + // checkdate ( int month, int day, int year) + $tab_date = explode( '/', $date ); + return checkdate ( $tab_date[1], $tab_date[0], $tab_date[2]); +} + +function date_convert( $date ) +{ + // date arrives at this format : DD/MM/YYYY + // It must be transformed in YYYY-MM-DD + $tab_date = explode( '/', $date ); + return $tab_date[2].'-'.$tab_date[1].'-'.$tab_date[0]; +} + +function date_convert_back( $date ) +{ + // date arrives at this format : YYYY-MM-DD + // It must be transformed in DD/MM/YYYY + if ( $date != '' ) + { + $tab_date = explode( '-', $date ); + return $tab_date[2].'/'.$tab_date[1].'/'.$tab_date[0]; + } + else + { + return ''; + } +} +//-------------------------------------------------------------- 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.= ';'; + $result = mysql_query( $query ); + $i = 1; + while ( $row = mysql_fetch_array( $result ) ) + { + $name = 'name-'.$row['id']; + $author = 'author-'.$row['id']; + $comment = 'comment-'.$row['id']; + $date_creation = 'date_creation-'.$row['id']; + if ( isset( $_POST[$name] ) ) + { + $query = 'UPDATE '.PREFIX_TABLE.'images'; + if ( $_POST[$name] == '' ) + { + $query.= ' SET name = NULL'; + } + else + { + $query.= " SET name = '".htmlentities( $_POST[$name], ENT_QUOTES )."'"; + } + if ( $_POST[$author] == '' ) + { + $query.= ', author = NULL'; + } + else + { + $query.= ", author = '".htmlentities($_POST[$author],ENT_QUOTES)."'"; + } + if ( $_POST[$comment] == '' ) + { + $query.= ', comment = NULL'; + } + else + { + $query.= ", comment = '".htmlentities($_POST[$comment],ENT_QUOTES)."'"; + } + if ( check_date_format( $_POST[$date_creation] ) ) + { + $date = date_convert( $_POST[$date_creation] ); + $query.= ", date_creation = '".$date."'"; + } + else if ( $_POST[$date_creation] == '' ) + { + $query.= ', date_creation = NULL'; + } + $query.= ' WHERE id = '.$row['id']; + $query.= ';'; + mysql_query( $query ); + } + } +//------------------------------------------------------ update general options + if ( $_POST['use_common_author'] == 1 ) + { + $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 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.= " SET date_creation = '".$date."'"; + } + $query.= ' WHERE cat_id = '.$page['cat']; + $query.= ';'; + mysql_query( $query ); + } + else + { + echo $lang['infoimage_err_date']; + } + } +//--------------------------------------------------------- form initialization + $page['nb_image_page'] = 5; + + if( !isset( $_GET['start'] ) + or !is_numeric( $_GET['start'] ) + or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) + { + $page['start'] = 0; + } + else + { + $page['start'] = $_GET['start']; + } + + if ( is_numeric( $_GET['num'] ) and $_GET['num'] >= 0 ) + { + $page['start'] = floor( $_GET['num'] / $page['nb_image_page'] ) * $page['nb_image_page']; + } + // retrieving category information + $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'); + $tpl = array( 'infoimage_general','author','infoimage_useforall','submit', + 'infoimage_creation_date','infoimage_detailed','thumbnail', + 'infoimage_title','infoimage_comment', + 'infoimage_creation_date' ); + templatize_array( $tpl, 'lang', $sub ); +//------------------------------------------------------------------------ form + $url = './admin.php?page=infos_images&cat_id='.$page['cat']; + $url.= '&start='.$page['start']; + $vtp->setVar( $sub, 'form_action', add_session_id( $url ) ); + $page['navigation_bar'] = create_navigation_bar( + $url, $cat['nb_images'],$page['start'], $page['nb_image_page'], '' ); + $vtp->setVar( $sub, 'navigation_bar', $page['navigation_bar'] ); + $cat_name = get_cat_display_name( $cat['name'], ' - ', 'font-style:italic;'); + $vtp->setVar( $sub, 'cat_name', $cat_name ); + + $query = 'SELECT id,file,comment,author,tn_ext,name,date_creation'; + $query.= ' FROM '.PREFIX_TABLE.'images'; + $query.= ' WHERE cat_id = '.$page['cat']; + $query.= $conf['order_by']; + $query.= ' LIMIT '.$page['start'].','.$page['nb_image_page']; + $query.= ';'; + $result = mysql_query( $query ); + while ( $row = mysql_fetch_array( $result ) ) + { + $vtp->addSession( $sub, 'picture' ); + $vtp->setVar( $sub, 'picture.id', $row['id'] ); + $vtp->setVar( $sub, 'picture.filename', $row['file'] ); + $vtp->setVar( $sub, 'picture.name', $row['name'] ); + $vtp->setVar( $sub, 'picture.author', $row['author'] ); + $vtp->setVar( $sub, 'picture.comment', $row['comment'] ); + $vtp->setVar( $sub, 'picture.date_creation', + date_convert_back( $row['date_creation'] ) ); + $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'].'/'; + } + else + { + $thumbnail_url = $cat['dir']; + } + $thumbnail_url.= 'thumbnail/'; + $thumbnail_url.= $conf['prefixe_thumbnail'].$file.".".$row['tn_ext']; + $vtp->setVar( $sub, 'picture.thumbnail_url', $thumbnail_url ); + $vtp->closeSession( $sub, 'picture' ); + } +} +//----------------------------------------------------------- sending html code +$vtp->Parse( $handle , 'sub', $sub ); ?> \ No newline at end of file -- cgit v1.2.3