diff options
Diffstat (limited to 'admin/edit_cat.php')
-rw-r--r-- | admin/edit_cat.php | 188 |
1 files changed, 86 insertions, 102 deletions
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 @@ <?php /*************************************************************************** - * edit_cat.php is a part of PhpWebGallery * + * edit_cat.php is * * ------------------- * - * last update : Tuesday, July 16, 2002 * - * email : pierrick@z0rglub.com * + * application : PhpWebGallery 1.3 * + * author : Pierrick LE GALL <pierrick@z0rglub.com> * * * ***************************************************************************/ @@ -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"<div style=\"color:red;text-align:center;\">".$lang['editcat_confirm']." [ <a href=\"".add_session_id_to_url( "./admin.php?page=cat" )."\">".$lang['editcat_back']."</a> ]</div>"; - } - - echo " - <form action=\"".add_session_id_to_url( "./admin.php?page=edit_cat&cat=".$HTTP_GET_VARS['cat']."&valider=1" )."\" method=\"post\"> - <table style=\"width:100%;\">"; - $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 " - <tr> - <th colspan=\"2\">".$lang['editcat_title1']." ".$lang['category']." \"".get_cat_display_name( $array_cat_names, " - ", "font-style:italic;" )."\" [ dir : ".$row['dir']." ]</th> - </tr>"; - if ( $row['site_id'] != 1 ) - { - echo " - <tr> - <td style=\"width:20%;\">Server</td> - <td class=\"row2\">".$row['galleries_url']."</td> - </tr>"; - } - echo " - <tr> - <td style=\"width:20%;\">".$lang['editcat_name']."</td> - <td class=\"row2\"><input type=\"text\" name=\"name\" value=\"".$row['name']."\" maxlength=\"255\"/></td> - </tr> - <tr> - <td style=\"width:20%;\">".$lang['editcat_comment']."</td> - <td class=\"row2\"><textarea name=\"comment\" rows=\"5\" cols=\"50\" style=\"overflow:auto\">".$row['comment']."</textarea></td> - </tr> - <tr> - <td style=\"width:20%;\">".$lang['editcat_status']."</td> - <td class=\"row2\"> - <select name=\"status\">"; - // on récupère toutes les status possibles dans la base - // par l'intermédiaire de la fonction get_enums trouvable - // dans le fichier config.php - $option = get_enums( PREFIX_TABLE."categories", "status" ); - for ( $i = 0; $i < sizeof( $option ); $i++ ) - { - if ( $option[$i] == $row['status'] ) - { - echo" - <option selected>$option[$i]</option>"; - } - else - { - echo" - <option>$option[$i]</option>"; - } - } - echo" - </select> - ".$lang['editcat_status_info']." - </td> - </tr> - <tr> - <td colspan=\"2\"> </td> - </tr> - <tr> - <td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"".$lang['submit']."\"/></td> - </tr> - </table> - </form>"; + +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 |