<?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="g_blog_edit.php" method="post">
<input type="hidden" name="group_id" value="<?php echo $group['group_id'];?>" />

<table width="770" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="180" valign="top">
			<?php
			include $templatePath . "g_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="g_blog.php?group_id=<?php echo $group['group_id'];?>" class="txt_sub_menu"><?php echo $lang['href_list'];?></a><br />
						<a href="g_blog.php?group_id=<?php echo $group['group_id'];?>&amp;add_blog=1" class="txt_sub_menu"><?php echo $lang['href_add_blog'];?></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($display) && $display == "preview_blog") {
			?>
			<input type="hidden" name="data[blog_id]" value="<?php if (isset($blog['blog_id'])) {echo $blog['blog_id'];}?>" />
			<input type="hidden" name="data[page]" value="<?php echo $blog['blog_page_name'];?>" />
			<input type="hidden" name="data[blog_title]" value="<?php echo $blog['blog_title'];?>" />
			<input type="hidden" name="data[blog_synopsis]" value="<?php echo $blog['blog_synopsis'];?>" />
			<input type="hidden" name="data[blog_body]" value="<?php echo $blog['blog_body'];?>" />
			<input type="hidden" name="data[level_id]" value="<?php if (isset($blog['level_id'])) { echo $blog['level_id'];}?>" />
			<input type="hidden" name="data[genre_id]" value="<?php if (isset($blog['genre_id'])) { echo $blog['genre_id'];}?>" />
			<input type="hidden" name="data[file_id]" value="<?php if (isset($blog['file_id'])) { echo $blog['file_id'];}?>" />
			<input type="hidden" name="data[cms_public]" value="<?php if (isset($blog['cms_public'])) { echo $blog['cms_public'];}?>" />
			<input type="hidden" name="data[cms_node]" value="<?php if (isset($blog['cms_node'])) { echo $blog['cms_node'];}?>" />
			<input type="hidden" name="data[cms_group]" value="<?php if (isset($blog['cms_group'])) { echo $blog['cms_group'];}?>" />
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td>
						<?php echo $blog['blog_title'];?><br />
					</td>
				<tr>
					<td colspan="2">
						<?php echo $blog['blog_synopsis'];?><br />
						<p>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<?php echo $blog['blog_body_display'];?><br />
					</td>
				</tr>
				<tr>
					<td align="right" colspan="2">
						<input type="submit" name="edit_blog_again" value="<?php echo $lang['sub_edit_again'];?>" class="formInput" />&nbsp;&nbsp;
						<?php
						if (isset($blog['blog_id'])) {
							$next_action = "update_blog";
						}
						else {
							$next_action = "insert_blog";
						}
						?>

						<input type="submit" name="<?php echo $next_action;?>" value="<?php echo $lang['sub_save'];?>" class="formInput" />
						<br />
					</td>
				</tr>
			</table>
			<?php
			}
			else {
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php echo $lang['hdr_blog'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<b><?php echo $lang['txt_blog_title'];?></b><br />
						<span class="txt_footer"><?php echo $lang['txt_blog_title_help'];?></span><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<input type="text" name="data[blog_title]" class="formInput" size="80" value="<?php if (isset($blog['blog_title'])) echo $blog['blog_title'];?>" /><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<b><?php echo $lang['txt_blog_synopsis'];?></b><br />
						<span class="txt_footer"><?php echo $lang['txt_blog_synopsis_help'];?></span><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<textarea name="data[blog_synopsis]" rows="2" cols="85" class="formInput" /><?php if (isset($blog['blog_synopsis'])) echo $blog['blog_synopsis'];?></textarea><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<b><?php echo $lang['txt_blog_body'];?></b><br />
						<span class="txt_footer"><?php echo $lang['txt_blog_body_help'];?></span><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<textarea name="data[blog_body]" rows="10" cols="85" class="formInput" /><?php if (isset($blog['blog_body'])) echo $blog['blog_body'];?></textarea><br />
					</td>
				</tr>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php echo $lang['section_cms'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php
						if ($this->group_acs->checkPermission($resource_ids['group_cms'], $privilege_ids['allow_cms_public'])) { //resource_id, Priv_id
							if ($cms_node_auto_publish == 1) {
							    $txt_cms_node = $lang['txt_cms_node_auto'];
							}
							else {
								$txt_cms_node = $lang['txt_cms_node'];
							}
							
						?>
						<input type="checkbox" name="data[cms_node]" value="1" <?php if (isset($blog['cms_node']) && $blog['cms_node'] == 1) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $txt_cms_node;?><br />
						<?php
						}
						
						if ($this->group_acs->checkPermission($resource_ids['group_cms'], $privilege_ids['allow_cms_group_home'])) { //resource_id, Priv_id
							if ($group['group_cms_auto_publish'] == 1) {
							    $txt_cms_group = $lang['txt_cms_group_auto'];
							}
							else {
								$txt_cms_group = $lang['txt_cms_group'];
							}
						?>
						<input type="checkbox" name="data[cms_group]" value="1" <?php if (isset($blog['cms_group']) && $blog['cms_group'] == 1) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $txt_cms_group;?><br />
						<?php
						}
						
						if ($this->group_acs->checkPermission($resource_ids['group_cms'], $privilege_ids['allow_cms_public'])) { //resource_id, Priv_id
							if ($group['group_cms_auto_publish'] == 1) {
							    $txt_cms_public = $lang['txt_cms_public_auto'];
							}
							else {
								$txt_cms_public = $lang['txt_cms_public'];
							}
						?>
						<input type="checkbox" name="data[cms_public]" value="1" <?php if (isset($blog['cms_public']) && $blog['cms_public'] == 1) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $txt_cms_public;?><br />
						<?php } ?>
					</td>
				</tr>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			
			<?php
			if (isset($images)) {
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="<?php echo $images_per_row;?>" class="txt_title" align="right">
						<?php echo $lang['hdr_images'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="<?php echo $images_per_row;?>">
						<span class="txt_footer"><?php echo $lang['txt_images_help'];?></span><br />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="<?php echo $images_per_row;?>">
						<input type="radio" value="0" name="data[file_id]" checked />&nbsp;no image<br />
					</td>
				</tr>
				<tr>
					<td>
						<table border="0" cellspacing="0" cellpadding="2" class="table_nested">
							<tr>
								<?php
								$images_per_row = 4;
								$r = 0;
								foreach($images as $key => $i):
			
			
								$selected = "";
									if (isset($blog['file_id']) && $blog['file_id'] == $i['file_id']) {
									    $selected = "checked";
									}
			
								?>
			
								<td valign="top">
									<img src="get_file.php?file=<?php echo $i['file']; ?>" border="0" class="picture" /><br />
									<?php echo $i['file_name']; ?>.<?php echo $i['file_suffix']; ?><br />
									<?php
									foreach($image_thumbs as $key1 => $f):
									?>
									<?php echo $i['file_name']; ?>.<?php echo $f['name']; ?><?php echo $i['file_suffix']; ?><br />
									<?php
									endforeach;
									?>
									<input type="radio" value="<?php echo $i['file_id'];?>" name="data[file_id]" <?php echo $selected;?> /><br />
								</td>
			
								<?php
								$r++;
								if ($r == $images_per_row) {
								    echo "</tr><tr>";
									$r=0;
								}
			
								endforeach;
								if ($r != $images_per_row) {
									$r = $images_per_row-$r;
									print "<td colspan=" . $r . "><br /></td>";
								}
								?>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<?php
			}
			?>
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td align="right">
						<input type="submit" name="preview_blog" value="<?php echo $lang['sub_preview'];?>" class="formInput" />&nbsp;&nbsp;

						<?php
						if (isset($blog['blog_id']) && $blog['blog_id'] > 0) {
						?>
						<input type="hidden" name="data[blog_id]" value="<?php echo $blog['blog_id'];?>" />
						<input type="submit" name="update_blog" value="<?php echo $lang['sub_save'];?>" class="formInput" />
						<?php
						}
						else {
						?>
						<input type="submit" name="insert_blog" value="<?php echo $lang['sub_save'];?>" class="formInput" />
						<?php
						}
						?>
						<br />
					</td>
				</tr>
			</table>
			<?php }?>
			
		</td>
	</tr>
</table>
</form>
