<?php

// -----------------------------------------------------------------------
// This file is part of aroundme
// 
// Copyright (C) 2003, 2005 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
// -----------------------------------------------------------------------

?>

<form action="sn_blog.php" method="post">
<input type="hidden" name="user_id" value="<?php echo $profile['user_id'];?>" />
<?php
if (isset($blog)) {
?>
<input type="hidden" name="blog_id" value="<?php echo $blog['blog_id'];?>" />
<?php }?>

<table width="770" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="180" valign="top">
			<?php
			include $templatePath . "sn_menu.inc.tpl.php";
			?>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />

			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td class="txt_title">
						<?php echo $lang['section_action'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>" class="txt_sub_menu"><?php echo $lang['href_latest_blog'];?></a><br />
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_history=1" class="txt_sub_menu"><?php echo $lang['href_blog_history'];?></a><br />
						
					</td>
				</tr>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="52" alt="" /><br />
			
			<?php
			include $templatePath . "logo.inc.tpl.php";
			?>
		</td>

		<td width="20">&nbsp;</td>


		<td width="570" valign="top">
			<?php
			if (isset($blogs)) {
			foreach($blogs as $key => $i):
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $i['blog_create_datetime'];?>
						<hr />
					</td>
				</tr>
			    <tr>
					<td valign="top">
						<span class="txt_item_title">
						<?php echo $i['blog_title'];?><br />
						</span>
						<?php echo $i['blog_body_display'];?><br />
					</td>
			    </tr>
				<tr>
					<td class="txt_footer">
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_id=<?php echo $i['blog_id'];?>" class="txt_footer_link"><?php echo $lang['href_comments'];?></a>&nbsp;(<?php if (!empty($i['comment_total'])) { echo $i['comment_total'];} else { echo "0";}?>)
						&nbsp;/&nbsp;
						<a href="g_member_profile.php?user_id=<?php echo $profile['user_id'];?>&amp;user_id=<?php echo $i['user_id'];?>" class="txt_footer_link"><?php echo $i['profile_nic'];?></a>
						&nbsp;/&nbsp;
						<?php
						if (isset($i['bookmark']['watch'])) {
						?>
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_id=<?php echo $i['blog_id'];?>&amp;unwatch=1" class="txt_footer_link"><?php echo $lang['href_unwatch_this'];?></a>
						<?php
						}
						else {
						?>
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_id=<?php echo $i['blog_id'];?>&amp;watch=1" class="txt_footer_link"><?php echo $lang['href_watch_this'];?></a>
						<?php
						}
						?>
						&nbsp;/&nbsp;
						<?php
						if (isset($i['bookmark']['recommend'])) {
						?>
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_id=<?php echo $i['blog_id'];?>&amp;unrecommend=1" class="txt_footer_link"><?php echo $lang['href_unrecommend_this'];?></a>
						<?php
						}
						else {
						?>
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_id=<?php echo $i['blog_id'];?>&amp;recommend=1" class="txt_footer_link"><?php echo $lang['href_recommend_this'];?></a>
						<?php
						}
						?>
						<br />
					</td>
				</tr>
				<tr>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
					</td>
				</tr>
			</table>
			
			<?php
			endforeach;
			} elseif (isset($blog)) {
			?>
			<table width="100%" border="0" cellspacing="0" cellpadding="4" class="bg_1">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $blog['blog_create_datetime'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<span class="txt_item_title">
						<?php echo $blog['blog_title'];?><br />
						</span>
						<?php echo $blog['blog_body_display'];?><br />
					</td>
				</tr>
				<tr>
					<td class="txt_footer">
						<a href="g_member_profile.php?user_id=<?php echo $profile['user_id'];?>&amp?user_id=<?php echo $author['user_id'];?>" class="txt_footer_link"><?php echo $author['profile_nic'];?></a>
						&nbsp;/&nbsp;
						<?php
						if (isset($blog['bookmark']['watch'])) {
						?>
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_id=<?php echo $blog['blog_id'];?>&amp;unwatch=1" class="txt_footer_link"><?php echo $lang['href_unwatch_this'];?></a>
						<?php
						}
						else {
						?>
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_id=<?php echo $blog['blog_id'];?>&amp;watch=1" class="txt_footer_link"><?php echo $lang['href_watch_this'];?></a>
						<?php
						}
						?>
						&nbsp;/&nbsp;
						<?php
						if (isset($blog['bookmark']['recommend'])) {
						?>
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_id=<?php echo $blog['blog_id'];?>&amp;unrecommend=1" class="txt_footer_link"><?php echo $lang['href_unrecommend_this'];?></a>
						<?php
						}
						else {
						?>
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_id=<?php echo $blog['blog_id'];?>&amp;recommend=1" class="txt_footer_link"><?php echo $lang['href_recommend_this'];?></a>
						<?php
						}
						?>
						<br />
					</td>
				</tr>
			</table>
			<?php
			} elseif (isset($blog_history)) {
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td class="txt_title" align="right" colspan="2">
						<?php echo $lang['hdr_blog_history'];?><br />
						<hr />
					</td>
				</tr>
				<?php 
				foreach($blog_history as $key => $i):
				?>
			    <tr>
					<td valign="top">
						<a href="sn_blog.php?user_id=<?php echo $profile['user_id'];?>&amp;blog_id=<?php echo $i['blog_id'];?>"><?php echo $i['blog_title'];?></a><br />
						<span class="txt_footer">
						<?php echo $i['blog_synopsis'];?><br />
						</span>
					</td>
					<td valign="top" align="right">
						<?php echo $i['blog_create_datetime'];?><br />
					</td>
			    </tr>
				<tr>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
					</td>
				</tr>
				<?php 
				endforeach;
				?>
			</table>
			
			
			<?php
			}
			else {
			?>
			<table width="100%" border="0" cellspacing="0" cellpadding="4" class="bg_1">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_blog'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['err_no_blogs'];?><br />

					</td>
				</tr>
			</table>
			<?php }?>
			
			
			
			<?php
			if (isset($blog['blog_id'])) {
			?>
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
			
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['section_comments'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (isset($comments)) {
				foreach($comments as $key => $i):
				?>
				<tr>
					<td>
						<table width="100%" cellpadding="4" cellspacing="0" border="0">
							<tr>
								<td class="txt_footer" colspan="2">
									<?php echo $lang['txt_from'];?>: <a href="sn_profile.php?user_id=<?php echo $i['user_id'];?>" class="txt_footer_link"><?php echo $i['profile_nic'];?></a>&nbsp;(<?php echo $lang['txt_joined'];?>: <?php echo $i['profile_create_datetime'];?>, <?php echo $lang['txt_hometown'];?>: <?php echo $i['profile_hometown'];?>)<br />
									<?php echo $lang['txt_comment_datetime'];?>: <?php echo $i['comment_create_datetime'];?><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<?php echo $i['comment_body'];?><br />
								</td>
						    </tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
					</td>
				</tr>
				<?php
				endforeach;
				}
				else {
				?>
				<tr>
					<td>
						<?php echo $lang['err_no_comments'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>

			<?php
			if (!empty($profile['profile_allow_comments']) && !empty($blog['blog_allow_comments'])) {
			?>
			
			<input type="hidden" name="data[comment_body]" value="<?php echo $comment['comment_body'];?>" />
						
			<img src=<?php echo $templatePath;?>img/pixel.png width="1" height="20"><br />

			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<?php
				if (isset($display) && $display = "preview_reply") {
				?>
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_comment_preview'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php echo $comment['display_comment_body'];?><br />
					</td>
			    </tr>
				<tr>
					<td align="right">
						<input type="submit" name="edit_again" class="formInput" value="<?php echo $lang['sub_edit_again'];?>" />&nbsp;&nbsp;
						<input type="submit" name="insert" class="formInput" value="<?php echo $lang['sub_save'];?>" /><br />
					</td>
				</tr>
				<?php
				}
				else {
				?>

				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['section_add_comment'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td class="txt_footer">
						<?php echo $lang['txt_comment_help'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<textarea name="data[comment_body]" rows="5" cols="70" class="formInput"><?php if(isset($comment['comment_body'])) { echo $comment['comment_body'];}?></textarea><br />
					</td>
				</tr>
				<tr>
					<td align="right">
						<input type="submit" name="preview" class="formInput" value="<?php echo $lang['sub_preview'];?>">&nbsp;&nbsp;
						<input type="submit" name="insert" class="formInput" value="<?php echo $lang['sub_add'];?>"><br />
					</td>
				</tr>
				<?php
				}
				?>
			</table>
			<?php
			}
			else {
			?>
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['section_add_comment'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td class="txt_footer">
						<?php echo $lang['txt_no_comment_allowed'];?><br />
					</td>
				</tr>
			</table>
			<?php
			}}
			?>
		</td>
	</tr>
</table>
</form>