<?php if(!route(3)): ?>

<div class="panel panel-default">
    
    <div class="panel-heading">
    <b>Mevcut Temalar</b>
  </div>
  <div class="panel-body" >
	<?php
	foreach ($dosyalar as $dosya):
	if ($dosya =='.' || $dosya == '..' || $dosya == 'maintenance-mode.php' || is_file($dosya) ) continue;
	require "mp-content/view/" . $dosya . "/theme/theme.php";
	?>
	<div class="col-lg-4">
		<div class="themes-card themes-card-active">
			<div class="themes-card_preview" style="background-image: url(<?=$themeDetail['themeThumbnail']?>)">
				<div class="themes-card_activate">
					<?php if($settings['site_theme'] == $dosya): ?>
					<button class="btn btn-success">Geçerli Tema</button>
					<?php else: ?>
					<button class="btn btn-danger" onclick="themeChange('<?=$dosya?>')">Aktif Et</button>
					<?php endif; ?>
				</div>
			</div>
			<div class="themes-card_title">
				<?=$themeDetail['themeName']?>
				<a href="<?=admin_url('appearence/themes/'.$dosya)?>" class="btn btn-default btn-xs pull-right">Düzenle</a>
			</div>
		</div>
	</div>
	
	<?php endforeach; ?>
	</div>
<!-------------------------------------------------------------------------------------------------------------------------------------------------->
<!-------------------------------------------------------------------------------------------------------------------------------------------------->
	
<?php else: ?>
	<div class="panel panel-default">
		<div class="panel-heading"><strong><?=$themename?></strong> Düzenleniyor</div>
		<div class="row">
			<div class="col-md-3 padding-md-right-null">
				<div class="panel-body edit-theme">
					<ul>
					<?php foreach($dosyalar as $row): ?>
						<?php if ($row =='.' || $row == '..' || $row == 'assets' || $row == 'theme' ) continue;
						$row = str_replace('.php', '', $row);
						?>
							<li><a href="<?=admin_url('appearence/themes/'.route(3).'/'.$row)?>"><i class="fa fa-file"></i> <?=$row?></a></li>
					<?php endforeach; ?>
					</ul>
				</div>
			</div>
			<div class="col-md-9 padding-md-left-null edit-theme__block-editor">
				<div class="panel-body">
					<div class="row">
						<div class="col-md-12">
							<div class="theme-edit-block">
								<?php if(route(4)): ?>
									<style type="text/css">
										.CodeMirror {
											border: 1px solid #eee;
											height: 500px;
										}
									</style>
									<div class="form-group text-right">
										<button onclick="saveFile('<?=route(3)?>', '<?=route(4);?>')" class="btn btn-success">Kaydet</button>
									</div>
									<textarea id="code">
										<?php
										$myFile = file_get_contents($content);
										echo str_replace(["{", "}"], ["&#123;", "&#125;"], htmlspecialchars($myFile));
										?>
									</textarea>
									<script src="<?=public_url('system/js/codemirror.js');?>"></script>
									<script type="text/javascript">
										var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
											lineWrapping: true,
											lineNumbers: true
										});
									</script>
								<?php else: ?>
								<div class="alert alert-info" role="alert">
									Sol taraftan düzenlemek istediğiniz sayfanın tema kodlarına ulaşabilirsiniz.
								</div>
								<?php endif; ?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php endif; ?>