From 60b84a9db5822b98a3e18a842901c2f0c323e032 Mon Sep 17 00:00:00 2001 From: gweltas Date: Sun, 22 Feb 2004 02:43:13 +0000 Subject: Template migration git-svn-id: http://piwigo.org/svn/trunk@369 68402e56-0260-453c-a942-63ccdbb3a9ee --- about.php | 4 +- category.php | 4 +- comments.php | 4 +- identification.php | 4 +- language/en_UK.iso-8859-1/admin.lang.php | 1 - language/en_UK.iso-8859-1/common.lang.php | 1 + picture.php | 4 +- profile.php | 26 +--- register.php | 4 +- search.php | 4 +- template/default/upload.tpl | 104 ++++++++++++++++ template/default/upload.vtp | 104 ---------------- upload.php | 191 ++++++++++++++---------------- 13 files changed, 208 insertions(+), 247 deletions(-) create mode 100644 template/default/upload.tpl delete mode 100644 template/default/upload.vtp diff --git a/about.php b/about.php index 16b8f1786..ed1bbef1e 100644 --- a/about.php +++ b/about.php @@ -33,7 +33,7 @@ include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); // Start output of page // $title= $lang['about_page_title']; -include('include/page_header.php'); +include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames(array('about'=>'about.tpl')); initialize_template(); @@ -47,5 +47,5 @@ $template->assign_vars(array( ); $template->pparse('about'); -include('include/page_tail.php'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> diff --git a/category.php b/category.php index 1b445efb3..060440b68 100644 --- a/category.php +++ b/category.php @@ -115,7 +115,7 @@ $page['structure'] = update_structure( $page['structure'] ); // Start output of page // $title = $page['title']; -include('include/page_header.php'); +include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames( array('category'=>'category.tpl') ); initialize_template(); @@ -482,5 +482,5 @@ pwg_log( 'category', $page['title'] ); mysql_close(); $template->pparse('category'); -include('include/page_tail.php'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> diff --git a/comments.php b/comments.php index c3e2d6ee3..19503ccaa 100644 --- a/comments.php +++ b/comments.php @@ -42,7 +42,7 @@ $array_cat_site_id = array(); // Start output of page // $title= $lang['title_comments']; -include('include/page_header.php'); +include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames( array('comments'=>'comments.tpl') ); initialize_template(); @@ -167,5 +167,5 @@ while ( $row = mysql_fetch_array( $result ) ) } //----------------------------------------------------------- html code display $template->pparse('comments'); -include('include/page_tail.php'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> diff --git a/identification.php b/identification.php index 88a2a5f96..9c3abd6aa 100644 --- a/identification.php +++ b/identification.php @@ -57,7 +57,7 @@ if ( isset( $_POST['login'] ) ) // Start output of page // $title = $lang['ident_page_title']; -include('include/page_header.php'); +include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames( array('identification'=>'identification.tpl') ); initialize_template(); @@ -95,5 +95,5 @@ if ( $conf['access'] == 'free' ) } //----------------------------------------------------------- html code display $template->pparse('identification'); -include('include/page_tail.php'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> diff --git a/language/en_UK.iso-8859-1/admin.lang.php b/language/en_UK.iso-8859-1/admin.lang.php index e0bfcc38a..7e641edad 100644 --- a/language/en_UK.iso-8859-1/admin.lang.php +++ b/language/en_UK.iso-8859-1/admin.lang.php @@ -273,7 +273,6 @@ $lang['infoimage_keyword_separation'] = '(separate with coma ",")'; $lang['infoimage_addtoall'] = 'add to all'; $lang['infoimage_removefromall'] = 'remove from all'; $lang['infoimage_associate'] = 'Associate to the category'; -$lang['update_wrong_dirname'] = 'The name of directories and files must be composed of letters, figures, "-", "_" or "."'; $lang['stats_pages_seen'] = 'pages seen'; $lang['stats_visitors'] = 'guests'; $lang['stats_empty'] = 'empty history'; diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php index 18aaa461a..b8dc8ed48 100644 --- a/language/en_UK.iso-8859-1/common.lang.php +++ b/language/en_UK.iso-8859-1/common.lang.php @@ -232,5 +232,6 @@ $lang['title_comments'] = 'Users comments'; $lang['stats_last_days'] = 'last days'; $lang['hint_comments'] = 'See last users comments'; $lang['menu_login'] = 'login'; +$lang['update_wrong_dirname'] = 'The name of directories and files must be composed of letters, figures, "-", "_" or "."'; ?> \ No newline at end of file diff --git a/picture.php b/picture.php index 16d75ecfe..47f0d51d1 100644 --- a/picture.php +++ b/picture.php @@ -232,7 +232,7 @@ else $picture_size = get_picture_size( $original_width, $original_height, $user['maxwidth'], $user['maxheight'] ); -include('include/page_header.php'); +include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames(array('picture'=>'picture.tpl')); initialize_template(); @@ -584,5 +584,5 @@ pwg_log( 'picture', $title_img, $picture['current']['file'] ); mysql_close(); $template->pparse('picture'); -include('include/page_tail.php'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> diff --git a/profile.php b/profile.php index 97968221d..2fb1b9de3 100644 --- a/profile.php +++ b/profile.php @@ -131,7 +131,7 @@ if ( isset( $_POST['submit'] ) ) // Start output of page // $title = $lang['customize_page_title']; -include('include/page_header.php'); +include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames(array('profile'=>'profile.tpl')); initialize_template(); @@ -223,29 +223,7 @@ $template->assign_block_vars('radio',array( 'F_OPTIONS'=>make_radio('show_nb_comments', array(true=>$lang['yes'], false=>$lang['no']), $user['show_nb_comments'], true) )); -//--------------------------------------------------------------- create cookie -if ( $conf['authorize_cookies'] ) -{ - $vtp->addSession( $handle, 'cookie' ); - $options = array( - array( 'message' => '1 '.$lang['customize_day'], - 'value' => time() + 24*60*60 ), - array( 'message' => '1 '.$lang['customize_week'], - 'value' => time() + 7*24*60*60 ), - array( 'message' => '1 '.$lang['customize_month'], - 'value' => time() + 30*24*60*60 ), - array( 'message' => '1 '.$lang['customize_year'], - 'value' => time() + 365*24*60*60 ) - ); - foreach ( $options as $option ) { - $vtp->addSession( $handle, 'expiration_option' ); - $vtp->setVar( $handle, 'expiration_option.option', $option['message'] ); - $vtp->setVar( $handle, 'expiration_option.value', $option['value'] ); - $vtp->closeSession( $handle, 'expiration_option' ); - } - $vtp->closeSession( $handle, 'cookie' ); -} //----------------------------------------------------------- html code display $template->pparse('profile'); -include('include/page_tail.php'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> diff --git a/register.php b/register.php index c2378718e..d32eb0d31 100644 --- a/register.php +++ b/register.php @@ -59,7 +59,7 @@ $email = empty($_POST['login'])?$_POST['login']:''; // Start output of page // $title= $lang['register_page_title']; -include('include/page_header.php'); +include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames( array('register'=>'register.tpl') ); initialize_template(); @@ -89,5 +89,5 @@ if ( sizeof( $errors ) != 0 ) } $template->pparse('register'); -include('include/page_tail.php'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> diff --git a/search.php b/search.php index b320d0ca9..48aa84f45 100644 --- a/search.php +++ b/search.php @@ -66,7 +66,7 @@ if ( isset( $_POST['search'] ) ) // Start output of page // $title= $lang['search_title']; -include('include/page_header.php'); +include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames( array('search'=>'search.tpl') ); initialize_template(); @@ -100,5 +100,5 @@ if ( sizeof( $error ) != 0 ) pwg_log( 'search', $title ); mysql_close(); $template->pparse('search'); -include('include/page_tail.php'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> diff --git a/template/default/upload.tpl b/template/default/upload.tpl new file mode 100644 index 000000000..e65714dce --- /dev/null +++ b/template/default/upload.tpl @@ -0,0 +1,104 @@ + + + + +
+ {T_START}1px{T_BEGIN} +
{L_TITLE}
+ {T_END} +
 
+ {T_START}50%{T_BEGIN} + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
    + +
  • {upload_not_successful.errors.error.ERROR}
  • + +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ + + {L_UPLOAD_DONE}
+ + + +
* : {L_MANDATORY}
+ + {T_END} +
\ No newline at end of file diff --git a/template/default/upload.vtp b/template/default/upload.vtp deleted file mode 100644 index 3b618442e..000000000 --- a/template/default/upload.vtp +++ /dev/null @@ -1,104 +0,0 @@ - - - - -
- {#frame_start}1px{#frame_begin} -
{#upload_title}
- {#frame_end} -
 
- {#frame_start}50%{#frame_begin} - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
    - -
  • {#li}
  • - -
-
-
- -
- -
- -
- -
- -
- -
- -
- -
-
- - - {#upload_successful}
- - - -
* : {#mandatory}
- - {#frame_end} -
\ No newline at end of file diff --git a/upload.php b/upload.php index ccde9627d..5a535895f 100644 --- a/upload.php +++ b/upload.php @@ -132,20 +132,6 @@ if ( $page['cat_site_id'] != 1 exit(); } } -//----------------------------------------------------- template initialization -// -// Start output of page -// -$title= $lang['upload_title']; -include('include/page_header.php'); -$handle = $vtp->Open( './template/'.$user['template'].'/upload.vtp' ); -initialize_template(); - -$tpl = array( 'upload_title', 'upload_username', 'mail_address', 'submit', - 'upload_successful', 'search_return_main_page','upload_author', - 'upload_name','upload_creation_date','upload_comment', - 'mandatory' ); -templatize_array( $tpl, 'lang', $handle ); $error = array(); $page['upload_successful'] = false; @@ -163,7 +149,7 @@ if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) ) array_push( $error, $lang['upload_file_exists'] ); } // test de la présence des champs obligatoires - if ( $_FILES['picture']['name'] == '' ) + if ( empty($_FILES['picture']['name'])) { array_push( $error, $lang['upload_filenotfound'] ); } @@ -172,13 +158,13 @@ if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) ) { array_push( $error, $lang['reg_err_mail_address'] ); } - if ( $_POST['username'] == '' ) + if ( empty($_POST['username']) ) { array_push( $error, $lang['upload_err_username'] ); } $date_creation = ''; - if ( $_POST['date_creation'] != '' ) + if ( !empty($_POST['date_creation']) ) { list( $day,$month,$year ) = explode( '/', $_POST['date_creation'] ); // int checkdate ( int month, int day, int year) @@ -205,9 +191,6 @@ if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) ) if ( !preg_match( '/^[a-zA-Z0-9-_.]+$/', $_FILES['picture']['name'] ) ) { - // reload language file with administration labels - $isadmin = true; - include( './language/'.$user['language'].'.php' ); array_push( $error, $lang['update_wrong_dirname'] ); } @@ -224,7 +207,7 @@ if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) ) if ( sizeof( $error ) == 0 ) { - $query = 'insert into '.PREFIX_TABLE.'waiting'; + $query = 'insert into '.WAITING_TABLE; $query.= ' (storage_category_id,file,username,mail_address,date,infos)'; $query.= ' values '; $query.= '('.$page['cat'].",'".$_FILES['picture']['name']."'"; @@ -240,12 +223,13 @@ if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) ) } } } + //------------------------------------------------------------ thumbnail upload if ( isset( $_POST['submit'] ) and isset( $_GET['waiting_id'] ) ) { // upload of the thumbnail $query = 'select file'; - $query.= ' from '.PREFIX_TABLE.'waiting'; + $query.= ' from '.WAITING_TABLE; $query.= ' where id = '.$_GET['waiting_id']; $query.= ';'; $result= mysql_query( $query ); @@ -263,7 +247,7 @@ if ( isset( $_POST['submit'] ) and isset( $_GET['waiting_id'] ) ) } if ( sizeof( $error ) == 0 ) { - $query = 'update '.PREFIX_TABLE.'waiting'; + $query = 'update '.WAITING_TABLE; $query.= " set tn_ext = '".$extension."'"; $query.= ' where id = '.$_GET['waiting_id']; $query.= ';'; @@ -272,129 +256,128 @@ if ( isset( $_POST['submit'] ) and isset( $_GET['waiting_id'] ) ) } } +// +// Start output of page +// +$title= $lang['upload_title']; +include(PHPWG_ROOT_PATH.'include/page_header.php'); +$template->set_filenames(array('upload'=>'upload.tpl')); +initialize_template(); + +$u_form = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat'].'&expand='.$_GET['expand']; +if ( isset( $page['waiting_id'] ) ) +{ +$u_form.= '&waiting_id='.$page['waiting_id']; +} + +if ( isset( $page['waiting_id'] ) ) +{ + $advise_title=$lang['upload_advise_thumbnail'].$_FILES['picture']['name']; +} +else +{ + $advise_title = $lang['upload_advise']; + $advise_title.= get_cat_display_name( $page['cat_name'], ' - ', 'font-style:italic;' ); +} + +$username = !empty($_POST['username'])?$_POST['username']:$user['username']; +$mail_address = !empty($_POST['mail_address'])?$_POST['mail_address']:$user['mail_address']; +$name = !empty($_POST['name'])?$_POST['name']:''; +$author = !empty($_POST['author'])?$_POST['author']:''; +$date_creation = !empty($_POST['date_creation'])?$_POST['date_creation']:''; +$comment = !empty($_POST['comment'])?$_POST['comment']:''; + +$template->assign_vars(array( + 'ADVISE_TITLE' => $advise_title, + 'NAME' => $username, + 'EMAIL' => $mail_address, + 'NAME_IMG' => $name, + 'AUTHOR_IMG' => $author, + 'DATE_IMG' => $date_creation, + 'COMMENT_IMG' => $comment, + + 'L_TITLE' => $lang['upload_title'], + 'L_USERNAME' => $lang['upload_username'], + 'L_EMAIL' => $lang['mail_address'], + 'L_NAME_IMG' => $lang['upload_name'], + 'L_SUBMIT' => $lang['submit'], + 'L_AUTHOR' => $lang['upload_author'], + 'L_CREATION_DATE' => $lang['upload_creation_date'], + 'L_COMMENT' => $lang['upload_comment'], + 'L_RETURN' => $lang['search_return_main_page'], + 'L_UPLOAD_DONE' => $lang['upload_successful'], + 'L_MANDATORY' => $lang['mandatory'], + + 'F_ACTION' => add_session_id( $u_form ), + + 'U_RETURN' => add_session_id(PHPWG_ROOT_PATH.'category.php?'.$_SERVER['QUERY_STRING']) + )); + if ( !$page['upload_successful'] ) { - $vtp->addSession( $handle, 'upload_not_successful' ); + $template->assign_block_vars('upload_not_successful',array()); //-------------------------------------------------------------- errors display - if ( sizeof( $error ) != 0 ) - { - $vtp->addSession( $handle, 'errors' ); - for ( $i = 0; $i < sizeof( $error ); $i++ ) - { - $vtp->addSession( $handle, 'li' ); - $vtp->setVar( $handle, 'li.li', $error[$i] ); - $vtp->closeSession( $handle, 'li' ); - } - $vtp->closeSession( $handle, 'errors' ); - } -//----------------------------------------------------------------- form action - $url = './upload.php?cat='.$page['cat'].'&expand='.$_GET['expand']; - if ( isset( $page['waiting_id'] ) ) +if ( sizeof( $error ) != 0 ) +{ + $template->assign_block_vars('upload_not_successful.errors',array()); + for ( $i = 0; $i < sizeof( $error ); $i++ ) { - $url.= '&waiting_id='.$page['waiting_id']; + $template->assign_block_vars('upload_not_successful.errors.error',array('ERROR'=>$error[$i])); } - $vtp->setGlobalVar( $handle, 'form_action', add_session_id( $url ) ); +} + //--------------------------------------------------------------------- advises - if ( $conf['upload_maxfilesize'] != '' ) + if ( !empty($conf['upload_maxfilesize']) ) { - $vtp->addSession( $handle, 'advise' ); $content = $lang['upload_advise_filesize']; $content.= $conf['upload_maxfilesize'].' KB'; - $vtp->setVar( $handle, 'advise.content', $content ); - $vtp->closeSession( $handle, 'advise' ); + $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$content)); } + if ( isset( $page['waiting_id'] ) ) { - $advise_title=$lang['upload_advise_thumbnail'].$_FILES['picture']['name']; - $vtp->setGlobalVar( $handle, 'advise_title', $advise_title ); - if ( $conf['upload_maxwidth_thumbnail'] != '' ) { - $vtp->addSession( $handle, 'advise' ); - $content = $lang['upload_advise_width']; + $content = $lang['upload_advise_width']; $content.= $conf['upload_maxwidth_thumbnail'].' px'; - $vtp->setVar( $handle, 'advise.content', $content ); - $vtp->closeSession( $handle, 'advise' ); + $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$content)); } if ( $conf['upload_maxheight_thumbnail'] != '' ) { - $vtp->addSession( $handle, 'advise' ); $content = $lang['upload_advise_height']; $content.= $conf['upload_maxheight_thumbnail'].' px'; - $vtp->setVar( $handle, 'advise.content', $content ); - $vtp->closeSession( $handle, 'advise' ); + $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$content)); } } else { - $advise_title = $lang['upload_advise']; - $advise_title.= get_cat_display_name( $page['cat_name'], ' - ', - 'font-style:italic;' ); - $vtp->setGlobalVar( $handle, 'advise_title', $advise_title ); - if ( $conf['upload_maxwidth'] != '' ) { - $vtp->addSession( $handle, 'advise' ); $content = $lang['upload_advise_width']; $content.= $conf['upload_maxwidth'].' px'; - $vtp->setVar( $handle, 'advise.content', $content ); - $vtp->closeSession( $handle, 'advise' ); + $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$content)); } if ( $conf['upload_maxheight'] != '' ) { - $vtp->addSession( $handle, 'advise' ); $content = $lang['upload_advise_height']; $content.= $conf['upload_maxheight'].' px'; - $vtp->setVar( $handle, 'advise.content', $content ); - $vtp->closeSession( $handle, 'advise' ); + $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$content)); } } - $vtp->addSession( $handle, 'advise' ); - $content = $lang['upload_advise_filetype']; - $vtp->setVar( $handle, 'advise.content', $content ); - $vtp->closeSession( $handle, 'advise' ); + $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$lang['upload_advise_filetype'])); + //----------------------------------------- optionnal username and mail address if ( !isset( $page['waiting_id'] ) ) { - $vtp->addSession( $handle, 'fields' ); - // username - if ( isset( $_POST['username'] ) ) $username = $_POST['username']; - else $username = $user['username']; - $vtp->setVar( $handle, 'fields.username', $username ); - // mail address - if ( isset( $_POST['mail_address'] ) )$mail_address=$_POST['mail_address']; - else $mail_address=$user['mail_address']; - $vtp->setGlobalVar( $handle, 'user_mail_address',$user['mail_address'] ); - // name of the picture - if (isset($_POST['name'])) - $vtp->setVar( $handle, 'fields.name', $_POST['name'] ); - // author - if (isset($_POST['author'])) - $vtp->setVar( $handle, 'fields.author', $_POST['author'] ); - // date of creation - if (isset($_POST['date_creation'])) - $vtp->setVar( $handle, 'fields.date_creation', $_POST['date_creation'] ); - // comment - if (isset($_POST['comment'])) - $vtp->setVar( $handle, 'fields.comment', $_POST['comment'] ); - - $vtp->closeSession( $handle, 'fields' ); - - $vtp->addSession( $handle, 'note' ); - $vtp->closeSession( $handle, 'note' ); + $template->assign_block_vars('upload_not_successful.fields',array()); + $template->assign_block_vars('note',array()); } - $vtp->closeSession( $handle, 'upload_not_successful' ); } else { - $vtp->addSession( $handle, 'upload_successful' ); - $vtp->closeSession( $handle, 'upload_successful' ); + $template->assign_block_vars('upload_successful',array()); } -//----------------------------------------------------- return to main page url -$url = './category.php?cat='.$page['cat'].'&expand='.$_GET['expand']; -$vtp->setGlobalVar( $handle, 'return_url', add_session_id( $url ) ); //----------------------------------------------------------- html code display -$code = $vtp->Display( $handle, 0 ); -echo $code; -include('include/page_tail.php'); +$template->pparse('upload'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> -- cgit v1.2.3