<?php
include('views/_header.tpl.php');
?>

		<link rel="stylesheet" href="/3rdparty/ckeditoradv/plugins/layoutmanager/css/bootstrap.css"/>
		<link rel="stylesheet" href="/3rdparty/ckeditoradv/plugins/layoutmanager/css/style.css"/>
		
		<script src="/3rdparty/cms/ckeditor.js"></script>

<style>
#pageinfo input, #pageinfo textarea {
	width: 98%;
}
.form textarea.txt {
    height: 75px;
}
.main-footer { display:none; }
#footer { padding-top:0px; }
.half { background:yellow; width: 50%; height:auto;  float:left; display:inline-block; }
/******************************************************************************/ 
@media screen and (max-device-width:  480px), screen and (max-width:  480px) {
	.half { background:none; width: 98%; height:auto;  display:block; }	
}	
</style>

<div class="home-feature-category" style="background:none; border:none;">
   <div class="container_12 clearfix">
       <div class="grid_12 marked-category">

		<h3>
			Edit Page - <a href="/<?= $page['slug'] ?>">Preview Page <i class="fa fa-external-link"></i></a>
		</h3>
		
		<form method="post" class="form form-profile" style="padding-top:0px; background:none; padding:0px;">
			<table id="pageinfo" style="width:100%; margin:0px;">
				<tr>
					<td style="width:120px">Page Title:</td><td><input name="name" value="<?= $page['name'] ?>" class="txt fill-width" /></td>
				</tr>
				<tr>
					<td>Meta Keywords:</td><td><input name="meta_keywords" value="<?= $page['meta_keywords'] ?>" class="txt" /></td>
				</tr>
				<tr>
					<td>Meta Description:</td><td><textarea name="meta_description" class="txt" rows="10"><?= $page['meta_description'] ?></textarea></td>
				</tr>
			</table>
			
			<style>
			#pageinfo input, #pageinfo textarea {
				width: 300px;
			}
			</style>
			
			<br />
			<textarea class="ckeditor" name="content"><?= $page['content'] ?></textarea><br />
			
			<div>
					
			
				<input type="checkbox" name="show_sidebar" <?= !empty($page['sidebar_content'])? 'checked=""' : ''?> id="show_sidebar">

				Display sidebar			
				<div>
					<br>
					<textarea class="ckeditor" name="sidebar_content"><?= $page['sidebar_content'] ?></textarea><br />
				</div>
				
			</div>
			
			<label>
				<input type="checkbox" name="widgets[]" <?=in_array('recent_posts', $widgets)? 'checked=""' : ''?> value="recent_posts"> Recent posts widget
				<select name="recent_posts_filter_type" id="recent_posts_filter">
					<option value="none">Sitewide</option>
					<option value="user" <?php if ($page['recent_posts_filter_type'] == 'user') { echo 'selected="selected"'; } ?>>By user</option>
					<option value="category" <?php if ($page['recent_posts_filter_type'] == 'category') { echo 'selected="selected"'; } ?>>By category</option>
				</select>
				<?php
					
// 				print_r($user_list);
// 				print_r($category_list);
					
				?>
				<select class="recent_filter" name="user_filter">
					<?php
						
					foreach ($user_list as $u) {
						if ($u['name']) {
							$selected = '';
							if ($u['id'] == $page['recent_posts_filter_id']) {
								$selected = 'selected="selected"';
							}
						
							echo "<option $selected value='{$u['id']}'>{$u['name']}</option>";
						}
					}
						
					?>
				</select>
				<select class="recent_filter" name="category_filter">
					<?php
						
					foreach ($category_list as $cat) {
						$selected = '';
						if ($cat['id'] == $page['recent_posts_filter_id']) {
							$selected = 'selected="selected"';
						}
						echo "<option $selected value='{$cat['id']}'>{$cat['title']}</option>";
					}
						
					?>
				</select>
			</label>
			
			<br><br>
			
			<input type="submit" value="Submit" class="btn btn-blue" style="font-weight:300" />
			<input type="button" value="Cancel" class="btn btn-black" onclick="location = '/admin/'" /> 
			<br /><br />
			Tip: Press F11 to use full-screen mode on PCs while editing
		</form>
		
		</div>
	</div>
</div>

<script>
$('#recent_posts_filter').change(function () {
	$('.recent_filter').hide();
	
	if ($(this).val() == 'user') {
		$('[name=user_filter]').show();
	}
	
	if ($(this).val() == 'category') {
		$('[name=category_filter]').show();
	}
})

$('#recent_posts_filter').change();
</script>

<style>
[name=user_filter] { display:none; }
[name=category_filter] { display:none; }
</style>

<?php

include('views/_footer.tpl.php');

?>