Template migration

git-svn-id: http://piwigo.org/svn/trunk@355 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
gweltas 2004-02-08 01:28:18 +00:00
commit 135346f2fc
8 changed files with 230 additions and 306 deletions

View file

@ -29,54 +29,77 @@
$phpwg_root_path = './';
include_once( $phpwg_root_path.'include/common.inc.php' );
//------------------------------------------------------------------- functions
function display_pictures( $mysql_result, $maxtime, $forbidden_cat_ids )
//--------------------------------------------------- number of days to display
if ( isset( $_GET['last_days'] ) ) define( 'MAX_DAYS', $_GET['last_days'] );
else define( 'MAX_DAYS', 0 );
//----------------------------------------- non specific section initialization
$array_cat_directories = array();
$array_cat_names = array();
$array_cat_site_id = array();
//------------------------------------------------------- last comments display
//
// Start output of page
//
$title= $lang['title_comments'];
include('include/page_header.php');
$template->set_filenames( array('comments'=>'comments.tpl') );
initialize_template();
$template->assign_vars(array(
'L_TITLE' => $lang['title_comments'],
'L_STATS' => $lang['stats_last_days'],
'L_RETURN' => $lang['search_return_main_page'],
'U_HOME' => add_session_id( 'category.php' )
)
);
foreach ( $conf['last_days'] as $option ) {
$url = './comments.php?last_days='.($option - 1);
$template->assign_block_vars('last_day_option', array (
'OPTION'=>$option,
'T_STYLE'=>(( $option == MAX_DAYS + 1 )?'text-decoration:underline;':''),
'U_OPTION'=>add_session_id( $url )
));
}
// 1. retrieving picture ids which have comments recently added
$date = date( 'Y-m-d', time() - ( MAX_DAYS*24*60*60 ) );
list($year,$month,$day) = explode( '-', $date);
$maxtime = mktime( 0,0,0,$month,$day,$year );
$query = 'SELECT DISTINCT(ic.image_id) as image_id,';
$query .= '(ic.category_id) as category_id';
$query.= ' FROM '.PREFIX_TABLE.'comments AS c';
$query.= ', '.PREFIX_TABLE.'image_category AS ic';
$query.= ' WHERE c.image_id = ic.image_id';
$query.= ' AND date > '.$maxtime;
$query.= " AND validated = 'true'";
// we must not show pictures of a forbidden category
if ( $user['forbidden_categories'] != '' )
{
global $vtp,$handle,$lang,$conf,
$array_cat_directories,$array_cat_site_id,$array_cat_names;
$query.= ' AND category_id NOT IN ';
$query.= '('.$user['forbidden_categories'].')';
}
$query.= ' ORDER BY ic.image_id DESC';
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $mysql_result ) )
while ( $row = mysql_fetch_array( $result ) )
{
$vtp->addSession( $handle, 'picture' );
// 1. find a category wich is authorized for the user to display a
// category name.
$query = 'SELECT category_id';
$query.= ' FROM '.PREFIX_TABLE.'image_category';
$query.= ' WHERE image_id = '.$row['image_id'];
if ( count( $forbidden_cat_ids ) > 0 )
{
$query.= ' AND category_id NOT IN (';
foreach ( $forbidden_cat_ids as $i => $restricted_cat ) {
if ( $i > 0 ) $query.= ',';
$query.= $restricted_cat;
}
$query.= ')';
}
$query.= ' ORDER BY RAND()';
$query.= ';';
$subrow = mysql_fetch_array( mysql_query( $query ) );
$category_id = $subrow['category_id'];
$category_id=$row['category_id'];
if ( !isset($array_cat_directories[$category_id]))
{
$array_cat_directories[$category_id] =
get_complete_dir( $category_id );
$cat_result = get_cat_info( $category_id );
$array_cat_site_id[$category_id] = $cat_result['site_id'];
$array_cat_names[$category_id] =
get_cat_display_name( $cat_result['name'], ' > ', '' );
}
// 2. for each picture, getting informations for displaying thumbnail and
// for each picture, getting informations for displaying thumbnail and
// link to the full size picture
$query = 'SELECT name,file,storage_category_id as cat_id,tn_ext';
$query.= ' FROM '.PREFIX_TABLE.'images';
$query.= ' FROM '.IMAGES_TABLE;
$query.= ' WHERE id = '.$row['image_id'];
$query.= ';';
$subresult = mysql_query( $query );
$subrow = mysql_fetch_array( $subresult );
if ( $array_cat_directories[$subrow['cat_id']] == '' )
if ( !isset($array_cat_directories[$subrow['cat_id']]) )
{
$array_cat_directories[$subrow['cat_id']] =
get_complete_dir( $subrow['cat_id'] );
@ -92,19 +115,23 @@ function display_pictures( $mysql_result, $maxtime, $forbidden_cat_ids )
if ( $subrow['name'] != '' ) $name.= $subrow['name'];
else $name.= str_replace( '_', ' ', $file );
$name.= ' [ '.$subrow['file'].' ]';
$vtp->setVar( $handle, 'picture.title', $name );
// source of the thumbnail picture
$src = $array_cat_directories[$subrow['cat_id']];
$src.= 'thumbnail/'.$conf['prefix_thumbnail'];
$src.= $file.'.'.$subrow['tn_ext'];
$vtp->setVar( $handle, 'picture.thumb_src', $src );
// link to the full size picture
$url = './picture.php?cat='.$category_id;
$url.= '&image_id='.$row['image_id'];
$vtp->setVar( $handle, 'picture.thumb_url', add_session_id( $url ) );
// 3. for each picture, retrieving all comments
$template->assign_block_vars('picture',array(
'TITLE_IMG'=>$name,
'I_THUMB'=>$src,
'U_THUMB'=>add_session_id( $url )
));
// for each picture, retrieving all comments
$query = 'SELECT id,date,author,content';
$query.= ' FROM '.PREFIX_TABLE.'comments';
$query.= ' FROM '.COMMENTS_TABLE;
$query.= ' WHERE image_id = '.$row['image_id'];
$query.= ' AND date > '.$maxtime;
$query.= " AND validated = 'true'";
@ -113,13 +140,8 @@ function display_pictures( $mysql_result, $maxtime, $forbidden_cat_ids )
$handleresult = mysql_query( $query );
while ( $subrow = mysql_fetch_array( $handleresult ) )
{
$vtp->addSession( $handle, 'comment' );
$author = $subrow['author'];
if ( $subrow['author'] == '' ) $author = $lang['guest'];
$vtp->setVar( $handle, 'comment.author', $author );
$displayed_date = format_date( $subrow['date'], 'unix', true );
$vtp->setVar( $handle, 'comment.date', $displayed_date );
$content = nl2br( $subrow['content'] );
// replace _word_ by an underlined word
@ -136,66 +158,14 @@ function display_pictures( $mysql_result, $maxtime, $forbidden_cat_ids )
$pattern = '/\/([^\s]*)\//';
$replacement = '<span style="font-style:italic;">\1</span>';
$content = preg_replace( $pattern, $replacement, $content );
$vtp->setVar( $handle, 'comment.content', $content );
$vtp->closeSession( $handle, 'comment' );
$template->assign_block_vars('picture.comment',array(
'AUTHOR'=>$author,
'DATE'=>format_date( $subrow['date'], 'unix', true ),
'CONTENT'=>$content,
));
}
$vtp->closeSession( $handle, 'picture' );
}
}
//----------------------------------------------------- template initialization
//
// Start output of page
//
$title= $lang['title_comments'];
include('include/page_header.php');
$handle = $vtp->Open( './template/'.$user['template'].'/comments.vtp' );
initialize_template();
$tpl = array( 'title_comments','stats_last_days','search_return_main_page' );
templatize_array( $tpl, 'lang', $handle );
//--------------------------------------------------- number of days to display
if ( isset( $_GET['last_days'] ) ) define( 'MAX_DAYS', $_GET['last_days'] );
else define( 'MAX_DAYS', 0 );
//----------------------------------------- non specific section initialization
$array_cat_directories = array();
$array_cat_names = array();
$array_cat_site_id = array();
//------------------------------------------------------- last comments display
foreach ( $conf['last_days'] as $option ) {
$vtp->addSession( $handle, 'last_day_option' );
$vtp->setVar( $handle, 'last_day_option.option', $option );
$url = './comments.php';
$url.= '?last_days='.($option - 1);
$vtp->setVar( $handle, 'last_day_option.link', add_session_id( $url ) );
$style = '';
if ( $option == MAX_DAYS + 1 ) $style = 'text-decoration:underline;';
$vtp->setVar( $handle, 'last_day_option.style', $style );
$vtp->closeSession( $handle, 'last_day_option' );
}
$vtp->setVar( $handle, 'back_url', add_session_id( './category.php' ) );
// 1. retrieving picture ids which have comments recently added
$date = date( 'Y-m-d', time() - ( MAX_DAYS*24*60*60 ) );
list($year,$month,$day) = explode( '-', $date);
$maxtime = mktime( 0,0,0,$month,$day,$year );
$query = 'SELECT DISTINCT(ic.image_id) as image_id';
$query.= ' FROM '.PREFIX_TABLE.'comments AS c';
$query.= ', '.PREFIX_TABLE.'image_category AS ic';
$query.= ' WHERE c.image_id = ic.image_id';
$query.= ' AND date > '.$maxtime;
$query.= " AND validated = 'true'";
// we must not show pictures of a forbidden category
if ( $user['forbidden_categories'] != '' )
{
$query.= ' AND category_id NOT IN ';
$query.= '('.$user['forbidden_categories'].')';
}
$query.= ' ORDER BY ic.image_id DESC';
$query.= ';';
$result = mysql_query( $query );
display_pictures( $result, $maxtime, $user['restrictions'] );
//----------------------------------------------------------- html code display
$code = $vtp->Display( $handle, 0 );
echo $code;
$template->pparse('comments');
include('include/page_tail.php');
?>

View file

@ -68,69 +68,37 @@ if ( isset( $_POST['search'] ) )
$title= $lang['search_title'];
include('include/page_header.php');
$handle = $vtp->Open( './template/'.$user['template'].'/search.vtp' );
$template->set_filenames( array('search'=>'search.tpl') );
initialize_template();
$tpl = array( 'search_title','search_return_main_page','submit',
'search_comments' );
templatize_array( $tpl, 'lang', $handle );
//----------------------------------------------------------------- form action
$vtp->setGlobalVar( $handle, 'form_action', add_session_id( './search.php' ) );
$template->assign_vars(array(
'L_TITLE' => $lang['search_title'],
'L_COMMENTS' => $lang['search_comments'],
'L_RETURN' => $lang['search_return_main_page'],
'L_SUBMIT' => $lang['submit'],
'L_SEARCH'=>$lang['search_field_search'].' *',
'L_SEARCH_OR'=>$lang['search_mode_or'],
'L_SEARCH_AND'=>$lang['search_mode_and'],
'F_ACTION' => add_session_id( 'search.php' ),
'F_TEXT_VALUE' => isset($_POST['search'])?$_POST['search']:'',
'U_HOME' => add_session_id( 'category.php' )
)
);
//-------------------------------------------------------------- errors display
if ( sizeof( $error ) != 0 )
{
$vtp->addSession( $handle, 'errors' );
$template->assign_block_vars('errors',array());
for ( $i = 0; $i < sizeof( $error ); $i++ )
{
$vtp->addSession( $handle, 'li' );
$vtp->setVar( $handle, 'li.li', $error[$i] );
$vtp->closeSession( $handle, 'li' );
$template->assign_block_vars('errors.error',array('ERROR'=>$error[$i]));
}
$vtp->closeSession( $handle, 'errors' );
}
//------------------------------------------------------------------------ form
// search field
$vtp->addSession( $handle, 'line' );
$vtp->setVar( $handle, 'line.name', $lang['search_field_search'].' *' );
$vtp->addSession( $handle, 'text' );
$vtp->setVar( $handle, 'text.size', '40' );
$vtp->setVar( $handle, 'text.name', 'search' );
if (isset($_POST['search']))
$vtp->setVar( $handle, 'text.value', $_POST['search'] );
$vtp->closeSession( $handle, 'text' );
$vtp->closeSession( $handle, 'line' );
// mode of search : match all words or at least one of this words
$vtp->addSession( $handle, 'line' );
$vtp->addSession( $handle, 'group' );
$vtp->addSession( $handle, 'radio' );
$vtp->setVar( $handle, 'radio.name', 'mode' );
$vtp->setVar( $handle, 'radio.value', 'OR' );
$vtp->setVar( $handle, 'radio.option', $lang['search_mode_or'] );
if (!isset($_POST['mode']) || $_POST['mode'] == 'OR' )
{
$vtp->setVar( $handle, 'radio.checked', ' checked="checked"' );
}
$vtp->closeSession( $handle, 'radio' );
$vtp->addSession( $handle, 'radio' );
$vtp->setVar( $handle, 'radio.name', 'mode' );
$vtp->setVar( $handle, 'radio.value', 'AND' );
$vtp->setVar( $handle, 'radio.option', $lang['search_mode_and'] );
if ( isset($_POST['mode']) && $_POST['mode'] == 'AND' )
{
$vtp->setVar( $handle, 'radio.checked', ' checked="checked"' );
}
$vtp->closeSession( $handle, 'radio' );
$vtp->closeSession( $handle, 'group' );
$vtp->closeSession( $handle, 'line' );
//---------------------------------------------------- return to main page link
$vtp->setGlobalVar( $handle, 'back_url', add_session_id( './category.php' ) );
//----------------------------------------------------------- html code display
$code = $vtp->Display( $handle, 0 );
echo $code;
//------------------------------------------------------------ log informations
pwg_log( 'search', $title );
mysql_close();
$template->pparse('search');
include('include/page_tail.php');
?>

View file

@ -1,7 +1,7 @@
<table style="width:100%;">
<tr>
<td valign="top" style="width:1%;padding:10px;">
{F_START}100%{F_BEGIN}
{T_START}100%{T_BEGIN}
<div class="titreMenu">
<a href="{U_HOME}">{L_CATEGORIES}</a>
</div>
@ -30,9 +30,9 @@
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="{T_COLLAPSED}" alt='' />&nbsp;<a href="{U_MOST_VISITED}"><span title="{L_MOST_VISITED_HINT}" style="font-weight:bold;">{S_TOP}&nbsp;{L_MOST_VISITED}</span></a>
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="{T_COLLAPSED}" alt='' />&nbsp;<a href="{U_RECENT}"><span title="{L_RECENT_HINT}" style="font-weight:bold;">{L_RECENT}</span></a> {T_SHORT}
</div>
{F_END}
{T_END}
<div style="margin-bottom:5px;">&nbsp;</div>
{F_START}100%{F_BEGIN}
{T_START}100%{T_BEGIN}
<div class="titreMenu">{L_SUMMARY}</div>
<div class="menu">
<!-- BEGIN summary -->
@ -42,15 +42,15 @@
<br />&nbsp;<img src="{T_COLLAPSED}" alt=''/>&nbsp;<a href="{upload.U_UPLOAD}">{L_UPLOAD}</a>
<!-- END upload -->
</div>
{F_END}
{T_END}
</td>
<td style="padding:5px;width:99%;" valign="top">
<table style="width:100%;">
<tr>
<td align="center">
{F_START}1%{F_BEGIN}
{T_START}1%{T_BEGIN}
<div class="titrePage">{TITLE}</div>
{F_END}
{T_END}
<div style="margin-bottom:5px;">&nbsp;</div>
<!-- BEGIN thumbnails -->
<table class="thumbnail">
@ -94,7 +94,7 @@
</tr>
<tr>
<td align="right">
{F_START}1%{F_BEGIN}
{T_START}1%{T_BEGIN}
<div class="info">
{L_USER}&nbsp;{USERNAME}<br />
{L_RECENT_IMG}&nbsp;{S_SHORT_PERIOD}&nbsp;{L_DAYS}
@ -103,7 +103,7 @@
{T_LONG}<br />
{L_SEND_MAIL}&nbsp;<a href="mailto:{S_MAIL}?subject={L_TITLE_MAIL}"><span style="font-weight:bold;">{S_WEBMASTER}</span></a>
</div>
{F_END}
{T_END}
</td>
</tr>
</table>

View file

@ -0,0 +1,61 @@
<table style="width:100%;">
<tr align="center" valign="middle">
<td>
{T_START}1px{T_BEGIN}
<div class="titrePage">{L_TITLE}</div>
{T_END}
<div style="margin-bottom:20px"></div>
{T_START}90%{T_BEGIN}
<table style="width:100%;">
<tr>
<th>
[
<!-- BEGIN last_day_option -->
<a href="{last_day_option.U_OPTION}" style="{last_day_option.T_STYLE}">{last_day_option.OPTION}</a>{T_SEPARATION}
<!-- END last_day_option -->
{L_STATS}
]
[ <a href="{U_HOME}">{L_RETURN}</a> ]
</th>
</tr>
</table>
<!-- BEGIN picture -->
<div style="border:2px solid gray;margin:2px;padding:2px;">
<table style="width:100%;">
<tr>
<td valign="top" style="width:15%;">
<!-- the thumbnail of the picture, linked to the full size page -->
<a href="{picture.U_THUMB}" title="{picture.TITLE_IMG}">
<img src="{picture.I_THUMB}" class="imgLink" alt="{picture.THUMB_ALT_IMG}"/>
</a>
</td>
<td style="padding:10px;width:85%;">
<div style="font-weight:bold;padding-left:10px;text-align:left;">{picture.TITLE_IMG}</div>
<!-- BEGIN comment -->
<table class="tableComment">
<tr>
<td rowspan="2" valign="top" class="cellAuthor">
<div class="commentsAuthor">{picture.comment.AUTHOR}</div>
</td>
<td class="cellInfo">
<div class="commentsInfos">
{picture.comment.DATE}
</div>
</td>
</tr>
<tr>
<td>
<div class="commentsContent">{picture.comment.CONTENT}</div>
</td>
</tr>
</table>
<!-- END comment -->
</td>
</tr>
</table>
</div>
<!-- END picture -->
{T_END}
</td>
</tr>
</table>

View file

@ -1,61 +0,0 @@
<table style="width:100%;">
<tr align="center" valign="middle">
<td>
{#frame_start}1px{#frame_begin}
<div class="titrePage">{#title_comments}</div>
{#frame_end}
<div style="margin-bottom:20px"></div>
{#frame_start}90%{#frame_begin}
<table style="width:100%;">
<tr>
<th>
[
<!--VTP_last_day_option-->
<a href="{#link}" style="{#style}">{#option}</a>{#separation}
<!--/VTP_last_day_option-->
{#stats_last_days}
]
[ <a href="{#back_url}">{#search_return_main_page}</a> ]
</th>
</tr>
</table>
<!--VTP_picture-->
<div style="border:2px solid gray;margin:2px;padding:2px;">
<table style="width:100%;">
<tr>
<td valign="top" style="width:15%;">
<!-- the thumbnail of the picture, linked to the full size page -->
<a href="{#thumb_url}" title="{#thumb_title}">
<img src="{#thumb_src}" class="imgLink" alt="{#thumb_alt}"/>
</a>
</td>
<td style="padding:10px;width:85%;">
<div style="font-weight:bold;padding-left:10px;text-align:left;">{#title}</div>
<!--VTP_comment-->
<table class="tableComment">
<tr>
<td rowspan="2" valign="top" class="cellAuthor">
<div class="commentsAuthor">{#author}</div>
</td>
<td class="cellInfo">
<div class="commentsInfos">
{#date}<!--VTP_delete--><a href="{#link}" title="{#comments_del}"><img src="../template/{#user_template}/admin/images/delete.gif" style="border:none;margin-left:5px;" alt="[{#delete}]"/></a><!--/VTP_delete-->
</div>
</td>
</tr>
<tr>
<td>
<div class="commentsContent">{#content}</div>
</td>
</tr>
</table>
<!--/VTP_comment-->
</td>
</tr>
</table>
</div>
<!--/VTP_picture-->
{#frame_end}
</td>
</tr>
</table>

View file

@ -143,9 +143,9 @@ function initialize_template()
global $template, $user, $lang;
$template->assign_vars(array(
'F_START' => get_frame_start(),
'F_BEGIN' => get_frame_begin(),
'F_END' => get_frame_end()
'T_START' => get_frame_start(),
'T_BEGIN' => get_frame_begin(),
'T_END' => get_frame_end()
)
);

View file

@ -0,0 +1,59 @@
<table style="width:100%;height:100%">
<tr align="center" valign="middle">
<td>
{T_START}1px{T_BEGIN}
<div class="titrePage">{L_TITLE}</div>
{T_END}
<div style="margin-bottom:5px;">&nbsp;</div>
{T_START}50%{T_BEGIN}
<div style="margin-left:auto;margin-right:auto;text-align:center;">
<form method="post" action="{F_ACTION}">
<table style="width:80%;margin-left:auto;margin-right:auto;">
<!-- BEGIN errors -->
<tr>
<td colspan="2">
<div class="errors">
<ul>
<!-- BEGIN error -->
<li>{errors.error.ERROR}</li>
<!-- END error -->
</ul>
</div>
</td>
</tr>
<!-- END errors -->
<tr>
<td colspan="2">
<div style="margin-bottom:10px;">&nbsp;</div>
</td>
</tr>
<tr>
<td class="menu">{L_SEARCH}</td>
<td class="menu">
<input type="text" name="search" size="40" value="{F_TEXT_VALUE}" /><br />
<input class="radio" type="radio" name="mode" value="OR" checked="checked" /> {L_SEARCH_OR}
<input class="radio" type="radio" name="mode" value="AND" /> {L_SEARCH_AND}
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" name="submit" value="{L_SUBMIT}" class="bouton" style="margin:10px;" />
</td>
</tr>
<tr>
<td align="center" colspan="2">
<a href="{U_HOME}">[ {L_RETURN} ]</a>
</td>
</tr>
<tr>
<td colspan="2">
<div style="margin-top:10px;">* : {L_COMMENTS}</div>
</td>
</tr>
</table>
</form>
</div>
{T_END}
</td>
</tr>
</table>

View file

@ -1,73 +0,0 @@
<table style="width:100%;height:100%">
<tr align="center" valign="middle">
<td>
{#frame_start}1px{#frame_begin}
<div class="titrePage">{#search_title}</div>
{#frame_end}
<div style="margin-bottom:5px;">&nbsp;</div>
{#frame_start}50%{#frame_begin}
<div style="margin-left:auto;margin-right:auto;text-align:center;">
<form method="post" action="{#form_action}">
<table style="width:80%;margin-left:auto;margin-right:auto;">
<!--VTP_errors-->
<tr>
<td colspan="2">
<div class="errors">
<ul>
<!--VTP_li-->
<li>{#li}</li>
<!--/VTP_li-->
</ul>
</div>
</td>
</tr>
<!--/VTP_errors-->
<tr>
<td colspan="2">
<div style="margin-bottom:10px;">&nbsp;</div>
</td>
</tr>
<!--VTP_line-->
<tr>
<td class="menu">{#name}</td>
<td class="menu">
<!--VTP_select-->
<select name="{#name}">
<!--VTP_option-->
<option{#selected}>{#option}</option>
<!--/VTP_option-->
</select>
<!--/VTP_select-->
<!--VTP_text-->
<input type="text" name="{#name}" size="{#size}" value="{#value}" />
<!--/VTP_text-->
<!--VTP_group-->
<!--VTP_radio-->
<input type="radio" name="{#name}" value="{#value}"{#checked}/>{#option}
<!--/VTP_radio-->
<!--/VTP_group-->
</td>
</tr>
<!--/VTP_line-->
<tr>
<td align="center" colspan="2">
<input type="submit" name="submit" value="{#submit}" class="bouton" style="margin:10px;" />
</td>
</tr>
<tr>
<td align="center" colspan="2">
<a href="{#back_url}">[ {#search_return_main_page} ]</a>
</td>
</tr>
<tr>
<td colspan="2">
<div style="margin-top:10px;">* : {#search_comments}</div>
</td>
</tr>
</table>
</form>
</div>
{#frame_end}
</td>
</tr>
</table>