<?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_library_edit.php" method="post">
<input type="hidden" name="page" value="<?php echo $library['library_page_name'];?>" />
<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";
			?>


			<?php
			if (isset($library['library_id'])) {
			?>
			<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 class="txt_title">
						<?php echo $lang['hdr_document'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_pagename'];?><br />
						<span class="txt_footer"><?php echo $library['library_page_name'];?></span><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_date'];?><br />
						<span class="txt_footer"><?php echo $library['library_create_datetime'];?></span><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_author'];?><br />
						<span class="txt_footer"><?php echo $lang['txt_last_edit'];?>: <a href="g_member_profile.php?group_id=<?php echo $group['group_id'];?>&amp;user_id=<?php echo $author['user_id'];?>" class="txt_footer_link"><?php echo $author['profile_nic'];?></a><br />
						<?php echo $lang['txt_joined'];?>: <?php echo $author['profile_create_datetime'];?><br />
						<?php echo $lang['txt_hometown'];?>: <?php echo $author['profile_hometown'];?></span><br />
					</td>
				</tr>
			</table>
			<?php
			}
			?>

			<?php
			if (isset($pages)) {
			?>
			<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 class="txt_title">
						<?php echo $lang['hdr_page_names'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php
						foreach($pages as $key => $i):
						echo $i . "<br />";
						endforeach;
						?>
						<br />
					</td>
				</tr>
			</table>
			<?php
			}
			?>

			<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">
			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php echo $lang['hdr_library'];?><br />
						<hr />
					</td>
				</tr>

				<?php
				if (isset($display) && $display == "add_library") {
				?>

				<tr>
					<td>
						<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_library_title'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_library_title_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<input type="text" name="data[library_title]" class="formInput" size="80" value="<?php if (isset($library['library_title'])) echo $library['library_title'];?>" /><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_library_desc'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_library_desc_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<textarea name="data[library_synopsis]" rows="2" cols="85" class="formInput"><?php if (isset($library['library_synopsis'])) echo $library['library_synopsis'];?></textarea><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_library_body'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_library_body_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<textarea name="data[library_body]" rows="10" cols="85" class="formInput"><?php if (isset($library['library_body'])) echo $library['library_body'];?></textarea><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_default'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_default_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top" class="txt_footer">
									<?php
									if (isset($library['library_default']) && $library['library_default'] > 0) {
									    echo $lang['txt_default_set'];
									?>
									<input type="hidden" name="data[library_default]" value="1" />
									<?php
									}
									else {
									?>
									<input type="checkbox" name="data[library_default]" value="1" />

									<?php
									}
									?><br />
								</td>
							</tr>
						</table>
					</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($library['cms_node']) && $library['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($library['cms_group']) && $library['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($library['cms_public']) && $library['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($library['file_id']) && $library['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>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<?php
			}
			?>

			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">

							<tr>
								<td align="right">
									<input type="submit" name="preview_library" value="<?php echo $lang['sub_preview'];?>" class="formInput" />&nbsp;&nbsp;
									<input type="submit" name="insert_library" value="<?php echo $lang['sub_save'];?>" class="formInput" />
									<br />
								</td>
							</tr>
						</table>
					</td>
				</tr>


				<?php
				}
				else if (isset($display) && $display == "preview_library") {
				?>

				<input type="hidden" name="page" value="<?php echo $library['library_page_name'];?>" />
				<input type="hidden" name="data[library_title]" value="<?php echo $library['library_title'];?>" />
				<input type="hidden" name="data[library_synopsis]" value="<?php echo $library['library_synopsis'];?>" />
				<input type="hidden" name="data[library_body]" value="<?php echo $library['library_body'];?>" />
				<input type="hidden" name="data[level_id]" value="<?php if (isset($library['level_id'])) { echo $library['level_id'];}?>" />
				<input type="hidden" name="data[library_default]" value="<?php if (isset($library['library_default'])) { echo $library['library_default'];}?>" />
				<input type="hidden" name="data[file_id]" value="<?php if (isset($library['file_id'])) { echo $library['file_id'];}?>" />
				<input type="hidden" name="data[cms_public]" value="<?php if (isset($library['cms_public'])) { echo $library['cms_public'];}?>" />
				<input type="hidden" name="data[cms_node]" value="<?php if (isset($library['cms_node'])) { echo $library['cms_node'];}?>" />
				<input type="hidden" name="data[cms_group]" value="<?php if (isset($library['cms_group'])) { echo $library['cms_group'];}?>" />

				<tr>
					<td>
						<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
							<tr>
								<td>
									<b><?php echo $lang['txt_library_desc'];?></b><br />
									<?php echo $library['library_synopsis'];?><br />
									<p>
								</td>
							</tr>
							<tr>
								<td>
									<b><?php echo $library['library_title'];?></b><br />
								</td>
							</tr>

							<tr>
								<td>
									<?php echo $library['library_body_display'];?><br />
								</td>
							</tr>
							<tr>
								<td align="right">
									<input type="submit" name="edit_library_again" value="<?php echo $lang['sub_edit'];?>" class="formInput" />&nbsp;&nbsp;
									<input type="submit" name="insert_library" value="<?php echo $lang['sub_save'];?>" class="formInput" />
									<br />
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<?php
				}
				?>
			</table>
		</td>
	</tr>
</table>
</form>
