<?php
include('views/_header_enterprise.tpl.php');
?>
<script src="/3rdparty/ckeditoradv/ckeditor.js"></script>
		<!--<script src="/3rdparty/ckeditoradv/ckeditor.js?id2"></script>-->
		<link rel="stylesheet" href="/3rdparty/ckeditoradv/plugins/layoutmanager/css/bootstrap.css"/>
		<link rel="stylesheet" href="/3rdparty/ckeditoradv/plugins/layoutmanager/css/style.css"/>

<style>
#mmen { display:none; }
#header { background:none; border-bottom:0px; }
.spacer { padding-top:65px; }
#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; }
.halfblock { display:inline-block; width:50%; float:left; }

.form .txt, input.datepicker {
	border: 1px solid #fafafa;
	margin-bottom: 3px;
	padding: 8px 10px;
	background: #eee;
	max-width: 350px;
	width: 98%;
	border-radius: 4px;
	-moz-border-radius: 4px;
	-webkit-border-radius: 4px;
	box-shadow: inset 0 0 0 rgba(0, 0, 0, 0), 0 0 0 rgba(0, 0, 0, 0);
	-moz-box-shadow: inset 0 0 0 rgba(0, 0, 0, 0), 0 0 0 rgba(0, 0, 0, 0);
	-webkit-box-shadow: inset 0 0 0 rgba(0, 0, 0, 0), 0 0 0 rgba(0, 0, 0, 0);
	box-sizing: border-box;
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
	transition: border linear 0.2s, box-shadow linear 0.2s;
	-o-transition: border linear 0.2s, box-shadow linear 0.2s;
	-moz-transition: border linear 0.2s, box-shadow linear 0.2s;
	-webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
}

/* ###################################### */
/* #########   MOBILE STYLES    ######### */
/* ###################################### */

/******************************************************************************/ 
@media screen and (max-device-width:  1024px), screen and (max-width:  1024px) {
	.customcta { top:285px; } 
	.spacer { padding-top: 117px; }
}

/******************************************************************************/ 
@media screen and (max-device-width:  799px), screen and (max-width:  799px) {
	.halfblock { display:block; width:100%; float:none; background:none; }
	.customcta { top:285px; } 
	.spacer { padding-top: 117px; }
}

/******************************************************************************/ 
@media screen and (max-device-width:  667px), screen and (max-width:  667px) {
	.halfblock { display:block; width:100%; float:none; }	
	.customcta { top:285px; } 
	.spacer { padding-top: 117px; }
}

/******************************************************************************/ 
@media screen and (max-device-width:  565px), screen and (max-width:  565px) {
	.halfblock { display:block; width:100%; float:none; }
	.customcta { top:285px; } 
	.spacer { padding-top: 117px; }
}

/******************************************************************************/ 
@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>
			<a href="/admin/"><i class="fa fa-angle-left" aria-hidden="true"></i>Back</a> | 
			Edit Page - <a href="/<?= $page['slug'] ?>" target="_blank">Preview Page <i 
			class="fa fa-television" aria-hidden="true"></i></a>
		</h3>
		
		<form method="post" class="form form-profile" enctype="multipart/form-data" 
		style="padding-top:0px; background:none; padding:0px;">
			<div class="halfblock">
				<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" /> 
						<span style="">Hide? <input type="checkbox" style="width:30px; 
						margin-bottom:6px;" 
						name="hide_title" <?= !empty($page['hide_title'])? 'checked=""' : ''?> />
						</span></td>
					</tr>
					<tr>
						<td style="width:120px">Page URL:</td><td><input name="slug" value="<?= $page['slug'] ?>" 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>
			</div>
			<div class="halfblock">
				<table id="pageinfo" style="width:100%; margin:0px;">
					<tr>
						<td style="width:120px">
							Upload Top BG Image
							<br />
							<input class="txt" type="file" name="image" style="margin:5px 0;">
							
							<?php if($page['image'] !='') { ?>														
								<img src='/<?= $page['image'] ?>' style='height:100px; width:auto;'
								onerror="this.src='/static/system/superskinnybanner.jpg'"
								 />
							<?php } ?>
						</td>
					</tr>
				</table>	
				<br />	
				<a href="/<?= $page['slug'] ?>" target="_blank" 
				style="font-weight:700; font-size:17px;">Preview Page
					<i class="fa fa-television" aria-hidden="true"></i></a>	
			</div>
			<div class="clear"></div>
			
			<style>
			#pageinfo input#show_title { width:auto; float:left; background:blue; }
			#pageinfo input, #pageinfo textarea {
				width: 300px;
			}
			</style>
			
			<br />
			<textarea class="ckeditor" id="ckeditor" name="content" 
			style="height:700px;"><?= $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>

			<h4>CUSTOM TEMPLATES (optional)</h4>
			<div>	
				<input type="checkbox" style="width:30px; margin-bottom:6px;" 
				name="styleone" <?= !empty($page['styleone'])? 'checked=""' : ''?> />			
				Style 1					
			</div>
			<div>	
				<input type="checkbox" style="width:30px; margin-bottom:6px;" name="styletwo" <?= !empty($page['styletwo'])? 'checked=""' : ''?> />			
				Style 2				
			</div>			
			<br>
			
			<div style="position:fixed; width:100%; background:rgba(0,0,0,.85); bottom:0; right:0; left:0; height:105px; text-align:center; padding-top:15px;">
                <input type="submit" value="Submit" class="btn btn-blue" style="font-weight:300; padding:15px 40px;" />
                <input type="button" value="Cancel" class="btn btn-blue" onclick="location = '/admin/'" style="background:#444; font-weight:300; padding:15px 40px;" /> 
			</div>
			
			<br /><br />
			Tip: Press F11 to use full-screen mode on PCs while editing
		</form>
		<br /><br /><br /><br /><br /><br />
		</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');

?>



<script>
CKEDITOR.replace( 'ckeditor' ,{
      height: 700,
	filebrowserBrowseUrl : '/filemanager/dialog.php?type=2&editor=ckeditor&fldr=',
	filebrowserUploadUrl : '/filemanager/dialog.php?type=2&editor=ckeditor&fldr=',
	filebrowserImageBrowseUrl : '/filemanager/dialog.php?type=1&editor=ckeditor&fldr='
});
</script>