waiting tpl migration

git-svn-id: http://piwigo.org/svn/trunk@520 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
gweltas 2004-09-11 10:36:03 +00:00
commit c6e6f131fa
6 changed files with 191 additions and 202 deletions

View file

@ -25,6 +25,10 @@
// | USA. | // | USA. |
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
if( !defined("PHPWG_ROOT_PATH") )
{
die ("Hacking attempt!");
}
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
define('CURRENT_DATE', "'".date('Y-m-d')."'"); define('CURRENT_DATE', "'".date('Y-m-d')."'");

View file

@ -24,14 +24,16 @@
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. | // | USA. |
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
include_once( './admin/include/isadmin.inc.php' ); if( !defined("PHPWG_ROOT_PATH") )
{
die ("Hacking attempt!");
}
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
//--------------------------------------------------------------------- updates //--------------------------------------------------------------------- updates
if ( isset( $_POST['submit'] ) ) if ( isset( $_POST['submit'] ) )
{ {
$query = 'SELECT id,storage_category_id,file,tn_ext'; $query = 'SELECT * FROM '.WAITING_TABLE;
$query.= ' FROM '.PREFIX_TABLE.'waiting'; $query.= " WHERE validated = 'false';";
$query.= " WHERE validated = 'false'";
$query.= ';';
$result = mysql_query( $query ); $result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) ) while ( $row = mysql_fetch_array( $result ) )
{ {
@ -42,7 +44,7 @@ if ( isset( $_POST['submit'] ) )
{ {
// The uploaded element was validated, we have to set the // The uploaded element was validated, we have to set the
// "validated" field to "true" // "validated" field to "true"
$query = 'UPDATE '.PREFIX_TABLE.'waiting'; $query = 'UPDATE '.WAITING_TABLE;
$query.= " SET validated = 'true'"; $query.= " SET validated = 'true'";
$query.= ' WHERE id = '.$row['id']; $query.= ' WHERE id = '.$row['id'];
$query.= ';'; $query.= ';';
@ -54,7 +56,7 @@ if ( isset( $_POST['submit'] ) )
{ {
// The uploaded element was refused, we have to delete its reference // The uploaded element was refused, we have to delete its reference
// in the database and to delete the element as well. // in the database and to delete the element as well.
$query = 'DELETE FROM '.PREFIX_TABLE.'waiting'; $query = 'DELETE FROM '.WAITING_TABLE;
$query.= ' WHERE id = '.$row['id']; $query.= ' WHERE id = '.$row['id'];
$query.= ';'; $query.= ';';
mysql_query( $query ); mysql_query( $query );
@ -66,29 +68,37 @@ if ( isset( $_POST['submit'] ) )
$thumbnail = $conf['prefix_thumbnail']; $thumbnail = $conf['prefix_thumbnail'];
$thumbnail.= get_filename_wo_extension( $row['file'] ); $thumbnail.= get_filename_wo_extension( $row['file'] );
$thumbnail.= '.'.$row['tn_ext']; $thumbnail.= '.'.$row['tn_ext'];
$url = '.'.$dir.'thumbnail/'.$thumbnail; $url = PHPWG_ROOT_PATH.$dir.'thumbnail/'.$thumbnail;
unlink( $url ); unlink( $url );
} }
} }
} }
} }
} }
//----------------------------------------------------- template initialization //----------------------------------------------------- template initialization
$sub = $vtp->Open( './template/'.$user['template'].'/admin/waiting.vtp' ); $template->set_filenames(array('waiting'=>'admin/waiting.tpl'));
$tpl = array( 'category','date','author','thumbnail','file','delete', $template->assign_vars(array(
'submit','waiting_update' ); 'L_WAITING_CONFIRMATION'=>$lang['waiting_update'],
templatize_array( $tpl, 'lang', $sub ); 'L_AUTHOR'=>$lang['author'],
'L_THUMBNAIL'=>$lang['thumbnail'],
'L_DATE'=>$lang['date'],
'L_FILE'=>$lang['file'],
'L_CATEGORY'=>$lang['category'],
'L_SUBMIT'=>$lang['submit'],
'L_DELETE'=>$lang['delete'],
'F_ACTION'=>add_session_id(str_replace( '&', '&', $_SERVER['REQUEST_URI'] ))
));
//-------------------------------------------------------- confirmation message //-------------------------------------------------------- confirmation message
if ( isset( $_POST['submit'] ) ) if (isset($_POST['submit']))
{ {
$vtp->addSession( $sub, 'confirmation' ); $template->assign_block_vars('confirmation' ,array());
$vtp->closeSession( $sub, 'confirmation' );
} }
//---------------------------------------------------------------- form display //---------------------------------------------------------------- form display
$cat_names = array(); $cat_names = array();
$query = 'SELECT id,storage_category_id,file,username,mail_address'; $query = 'SELECT * FROM '.WAITING_TABLE;
$query.= ',date,tn_ext';
$query.= ' FROM '.PREFIX_TABLE.'waiting';
$query.= " WHERE validated = 'false'"; $query.= " WHERE validated = 'false'";
$query.= ' ORDER BY storage_category_id'; $query.= ' ORDER BY storage_category_id';
$query.= ';'; $query.= ';';
@ -96,57 +106,45 @@ $result = mysql_query( $query );
$i = 0; $i = 0;
while ( $row = mysql_fetch_array( $result ) ) while ( $row = mysql_fetch_array( $result ) )
{ {
$vtp->addSession( $sub, 'picture' );
$vtp->setVar( $sub, 'picture.id', $row['id'] );
if ( $i++ % 2 == 0 )
{
$vtp->setVar( $sub, 'picture.class', 'row2' );
}
if ( !isset( $cat_names[$row['storage_category_id']] ) ) if ( !isset( $cat_names[$row['storage_category_id']] ) )
{ {
$cat = get_cat_info( $row['storage_category_id'] ); $cat = get_cat_info( $row['storage_category_id'] );
$cat_names[$row['storage_category_id']] = array(); $cat_names[$row['storage_category_id']] = array();
$cat_names[$row['storage_category_id']]['dir'] = $cat_names[$row['storage_category_id']]['dir'] =
'.'.get_complete_dir( $row['storage_category_id'] ); PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] );
$cat_names[$row['storage_category_id']]['display_name'] = $cat_names[$row['storage_category_id']]['display_name'] =
get_cat_display_name( $cat['name'], ' > ', 'font-weight:bold;' ); get_cat_display_name( $cat['name'], ' > ', 'font-weight:bold;' );
} }
// category name $preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file'];
$vtp->setVar( $sub, 'picture.cat_name', $class='row1';
$cat_names[$row['storage_category_id']]['display_name'] ); if ( $i++ % 2== 0 ) $class='row2';
// date displayed like this (in English ) :
// Sunday 15 June 2003 21:29 $template->assign_block_vars('picture' ,array(
$date = format_date( $row['date'], 'unix', true ); 'WAITING_CLASS'=>$class,
$vtp->setVar( $sub, 'picture.date', $date ); 'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'],
// file preview link 'ID_IMG'=>$row['id'],
$url = $cat_names[$row['storage_category_id']]['dir'].$row['file']; 'DATE_IMG'=>format_date( $row['date'], 'unix', true ),
$vtp->setVar( $sub, 'picture.preview_url', $url ); 'FILE_IMG'=>$row['file'],
// file name 'PREVIEW_URL_IMG'=>$preview_url,
$vtp->setVar( $sub, 'picture.file', $row['file'] ); 'UPLOAD_EMAIL'=>$row['mail_address'],
'UPLOAD_USERNAME'=>$row['username']
));
// is there an existing associated thumnail ? // is there an existing associated thumnail ?
if ( isset( $row['tn_ext'] ) and $row['tn_ext'] != '' ) if ( !empty( $row['tn_ext'] ))
{ {
$vtp->addSession( $sub, 'thumbnail' );
$thumbnail = $conf['prefix_thumbnail']; $thumbnail = $conf['prefix_thumbnail'];
$thumbnail.= get_filename_wo_extension( $row['file'] ); $thumbnail.= get_filename_wo_extension( $row['file'] );
$thumbnail.= '.'.$row['tn_ext']; $thumbnail.= '.'.$row['tn_ext'];
$url = $cat_names[$row['storage_category_id']]['dir']; $url = $cat_names[$row['storage_category_id']]['dir'];
$url.= 'thumbnail/'.$thumbnail; $url.= 'thumbnail/'.$thumbnail;
$vtp->setVar( $sub, 'thumbnail.preview_url', $url );
$vtp->setVar( $sub, 'thumbnail.file', $thumbnail ); $template->assign_block_vars('picture.thumbnail' ,array(
$vtp->closeSession( $sub, 'thumbnail' ); 'PREVIEW_URL_TN_IMG'=>$url,
'FILE_TN_IMG'=>$thumbnail
));
} }
else
{
$vtp->addSession( $sub, 'no_thumbnail' );
$vtp->closeSession( $sub, 'no_thumbnail' );
}
// username and associated mail address
$vtp->setVar( $sub, 'picture.mail_address', $row['mail_address'] );
$vtp->setVar( $sub, 'picture.username', $row['username'] );
$vtp->closeSession( $sub, 'picture' );
} }
//----------------------------------------------------------- sending html code //----------------------------------------------------------- sending html code
$vtp->Parse( $handle , 'sub', $sub ); $template->assign_var_from_handle('ADMIN_CONTENT', 'waiting');
?> ?>

View file

@ -0,0 +1,41 @@
<form action="{F_ACTION}" method="post">
<!-- BEGIN confirmation -->
<div class="info">{L_WAITING_CONFIRMATION}</div>
<!-- END confirmation -->
<table style="width:100%;" >
<tr class="throw">
<th style="width:20%;">{L_CATEGORY}</th>
<th style="width:20%;">{L_DATE}</th>
<th style="width:20%;">{L_FILE}</th>
<th style="width:20%;">{L_THUMBNAIL}</th>
<th style="width:20%;">{L_AUTHOR}</th>
<th style="width:1px;">&nbsp;</th>
</tr>
<!-- BEGIN picture -->
<tr>
<td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">{picture.CATEGORY_IMG}</td>
<td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">{picture.DATE_IMG}</td>
<td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">
<a target="_blank" href="{picture.PREVIEW_URL_IMG}">{picture.FILE_IMG}</a>
</td>
<td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">
<!-- BEGIN thumbnail -->
<a target="_blank" href="{picture.thumbnail.PREVIEW_URL_TN_IMG}">{picture.thumbnail.FILE_TN_IMG}</a>
<!-- END thumbnail -->
</td>
<td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">
<a href="mailto:{picture.UPLOAD_EMAIL}">{picture.UPLOAD_USERNAME}</a>
</td>
<td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">
<input type="radio" name="validate-{picture.ID_IMG}" value="true" />{L_SUBMIT}
<input type="radio" name="validate-{picture.ID_IMG}" value="false" />{L_DELETE}
</td>
</tr>
<!-- END picture -->
<tr>
<td colspan="5" align="center">
<input type="submit" name="submit" value="{L_SUBMIT}" class="bouton" />
</td>
</tr>
</table>
</form>

View file

@ -1,42 +0,0 @@
<form action="{#action}" method="post">
<!--VTP_confirmation-->
<div class="info">{#waiting_update}</div>
<!--/VTP_confirmation-->
<table style="width:100%;">
<tr>
<th style="width:20%;">{#category}</th>
<th style="width:20%;">{#date}</th>
<th style="width:20%;">{#file}</th>
<th style="width:20%;">{#thumbnail}</th>
<th style="width:20%;">{#author}</th>
<th style="width:1px;">&nbsp;</th>
</tr>
<!--VTP_picture-->
<tr>
<td class="{#class}" style="white-space:nowrap;">{#cat_name}</td>
<td class="{#class}" style="white-space:nowrap;">{#date}</td>
<td class="{#class}" style="white-space:nowrap;">
<a target="_blank" href="{#preview_url}">{#file}</a>
</td>
<td class="{#class}" style="white-space:nowrap;">
<!--VTP_thumbnail-->
<a target="_blank" href="{#preview_url}">{#file}</a>
<!--/VTP_thumbnail-->
<!--VTP_no_thumbnail-->
&nbsp;
<!--/VTP_no_thumbnail-->
</td>
<td class="{#class}" style="white-space:nowrap;">
<a href="mailto:{#mail_address}">{#username}</a>
</td>
<td class="{#class}" style="white-space:nowrap;">
<input type="radio" name="validate-{#id}" value="true" />{#submit}
<input type="radio" name="validate-{#id}" value="false" />{#delete}
</td>
</tr>
<!--/VTP_picture-->
<tr>
<td colspan="5" align="center"><input type="submit" name="submit" value="{#submit}" style="margin:5px;" /></td>
</tr>
</table>
</form>

View file

@ -1,104 +1,93 @@
<table style="width:100%;height:100%"> <div class="titrePage">{L_TITLE}</div>
<tr align="center" valign="middle"> <!-- BEGIN upload_not_successful -->
<td> <form enctype="multipart/form-data" method="post" action="{F_ACTION}">
{T_START}1px{T_BEGIN} <table style="width:80%;margin-left:auto;margin-right:auto;">
<div class="titrePage">{L_TITLE}</div> <!-- BEGIN errors -->
{T_END} <tr>
<div style="margin-bottom:5px;">&nbsp;</div> <td colspan="2">
{T_START}50%{T_BEGIN} <div class="errors">
<!-- BEGIN upload_not_successful --> <ul>
<form enctype="multipart/form-data" method="post" action="{F_ACTION}"> <!-- BEGIN error -->
<table style="width:80%;margin-left:auto;margin-right:auto;"> <li>{upload_not_successful.errors.error.ERROR}</li>
<!-- BEGIN errors --> <!-- END error -->
<tr> </ul>
<td colspan="2"> </div>
<div class="errors"> </td>
<ul> </tr>
<!-- BEGIN error --> <!-- END errors -->
<li>{upload_not_successful.errors.error.ERROR}</li> <tr>
<!-- END error --> <td colspan="2" class="menu">
</ul> <div style="text-align:center;">{ADVISE_TITLE}</div>
</div> <ul>
</td> <!-- BEGIN advise -->
</tr> <li>{upload_not_successful.advise.ADVISE}</li>
<!-- END errors --> <!-- END advise -->
<tr> </ul>
<td colspan="2" class="menu"> </td>
<div style="text-align:center;">{ADVISE_TITLE}</div> </tr>
<ul> <tr>
<!-- BEGIN advise --> <td colspan="2" align="center" style="padding:10px;">
<li>{upload_not_successful.advise.ADVISE}</li> <input name="picture" type="file" value="" />
<!-- END advise --> </td>
</ul> </tr>
</td> <!-- BEGIN fields -->
</tr> <!-- username -->
<tr> <tr>
<td colspan="2" align="center" style="padding:10px;"> <td class="menu">{L_USERNAME} <span style="color:red;">*</span></td>
<input name="picture" type="file" value="" /> <td align="center" style="padding:10px;">
</td> <input name="username" type="text" value="{NAME}" />
</tr> </td>
<!-- BEGIN fields --> </tr>
<!-- username --> <!-- mail address -->
<tr> <tr>
<td class="menu">{L_USERNAME} <span style="color:red;">*</span></td> <td class="menu">{L_EMAIL} <span style="color:red;">*</span></td>
<td align="center" style="padding:10px;"> <td align="center" style="padding:10px;">
<input name="username" type="text" value="{NAME}" /> <input name="mail_address" type="text" value="{EMAIL}" />
</td> </td>
</tr> </tr>
<!-- mail address --> <!-- name of the picture -->
<tr> <tr>
<td class="menu">{L_EMAIL} <span style="color:red;">*</span></td> <td class="menu">{L_NAME_IMG}</td>
<td align="center" style="padding:10px;"> <td align="center" style="padding:10px;">
<input name="mail_address" type="text" value="{EMAIL}" /> <input name="name" type="text" value="{NAME_IMG}" />
</td> </td>
</tr> </tr>
<!-- name of the picture --> <!-- author -->
<tr> <tr>
<td class="menu">{L_NAME_IMG}</td> <td class="menu">{L_AUTHOR}</td>
<td align="center" style="padding:10px;"> <td align="center" style="padding:10px;">
<input name="name" type="text" value="{NAME_IMG}" /> <input name="author" type="text" value="{AUTHOR_IMG}" />
</td> </td>
</tr> </tr>
<!-- author --> <!-- date of creation -->
<tr> <tr>
<td class="menu">{L_AUTHOR}</td> <td class="menu">{L_CREATION_DATE}</td>
<td align="center" style="padding:10px;"> <td align="center" style="padding:10px;">
<input name="author" type="text" value="{AUTHOR_IMG}" /> <input name="date_creation" type="text" value="{DATE_IMG}" />
</td> </td>
</tr> </tr>
<!-- date of creation --> <!-- comment -->
<tr> <tr>
<td class="menu">{L_CREATION_DATE}</td> <td class="menu">{L_COMMENT}</td>
<td align="center" style="padding:10px;"> <td align="center" style="padding:10px;">
<input name="date_creation" type="text" value="{DATE_IMG}" /> <textarea name="comment" rows="3" cols="40" style="overflow:auto">{COMMENT_IMG}</textarea>
</td> </td>
</tr> </tr>
<!-- comment --> <!-- END fields -->
<tr> <tr>
<td class="menu">{L_COMMENT}</td> <td colspan="2" align="center">
<td align="center" style="padding:10px;"> <input name="submit" type="submit" value="{L_SUBMIT}" class="bouton" />
<textarea name="comment" rows="3" cols="40" style="overflow:auto">{COMMENT_IMG}</textarea> </td>
</td> </tr>
</tr> </table>
<!-- END fields --> </form>
<tr> <!-- END upload_not_successful -->
<td colspan="2" align="center"> <!-- BEGIN upload_successful -->
<input name="submit" type="submit" value="{L_SUBMIT}" /> {L_UPLOAD_DONE}<br />
</td> <!-- END upload_successful -->
</tr> <div style="text-align:center;">
</table> <a href="{U_RETURN}">[ {L_RETURN} ]</a>
</form> </div>
<!-- END upload_not_successful --> <!-- BEGIN note -->
<!-- BEGIN upload_successful --> <div style="text-align:left;"><span style="color:red;">*</span> : {L_MANDATORY}</div>
{L_UPLOAD_DONE}<br /> <!-- END note -->
<!-- END upload_successful -->
<div style="text-align:center;">
<a href="{U_RETURN}">[ {L_RETURN} ]</a>
</div>
<!-- BEGIN note -->
<div style="text-align:left;"><span style="color:red;">*</span> : {L_MANDATORY}</div>
<!-- END note -->
{T_END}
</td>
</tr>
</table>

View file

@ -260,9 +260,8 @@ if ( isset( $_POST['submit'] ) and isset( $_GET['waiting_id'] ) )
$title= $lang['upload_title']; $title= $lang['upload_title'];
include(PHPWG_ROOT_PATH.'include/page_header.php'); include(PHPWG_ROOT_PATH.'include/page_header.php');
$template->set_filenames(array('upload'=>'upload.tpl')); $template->set_filenames(array('upload'=>'upload.tpl'));
initialize_template();
$u_form = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat'].'&amp;expand='.$_GET['expand']; $u_form = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat'];
if ( isset( $page['waiting_id'] ) ) if ( isset( $page['waiting_id'] ) )
{ {
$u_form.= '&amp;waiting_id='.$page['waiting_id']; $u_form.= '&amp;waiting_id='.$page['waiting_id'];