	<?php if(@$error): ?>

		<div class="alert alert-dismissible alert-danger">

			<button type="button" class="close" data-dismiss="alert">×</button>

			<strong>Hata!</strong> <?=$errorText?>

		</div>

	<?php endif; ?>

	<?php if(@$success): ?>

		<div class="alert alert-dismissible alert-success">

			<button type="button" class="close" data-dismiss="alert">×</button>

			<strong>Başarılı!</strong> <?=$success?>

		</div>

	<?php endif; ?>



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



		<a href="<?=admin_url('appearence/blog/add')?>" class="btn btn-success" style="margin-bottom:20px;">Yeni Blog Ekle</a>

		<div class="panel panel-default">

			<div class="panel-body" style="padding:0;">

				<table class="table" style="margin-bottom:0;">

					<thead>

						<tr>

							<th class="p-l" width="45%">Blog Başlığı</th>

							<th>Yayın Tarihi</th>

							<th></th>

						</tr>

					</thead>

					<tbody>

						<?php foreach($blog as $row): ?>

							<tr>

								<td><?=$row["blog_title"]?></td>

								<td><?=str_date($row["blog_date"])?></td>

								<td>

									<div class="dropdown pull-right">

										<button class="btn btn-xs btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">İşlemler<span class="caret"></span></button>

										<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">

											<li><a href="<?=site('blog/'. $row["blog_url"])?>" target="_blank">Görüntüle</a></li>

											<li><a href="<?=admin_url('appearence/blog/edit/'. $row["id"])?>">Düzenle</a></li>

											<li><a href="#" onclick="delete_blog(<?=$row["id"];?>)">Sil</a></li>

										</ul>

									</div>

								</td>

							</tr>

						<?php endforeach; ?>

					</tbody>

				</table>

			</div>

		</div>



	<?php elseif(route(3) == "add"): ?>
		<div class="panel panel-default">
			<div class="panel-body">
				<form id="add_blog" onsubmit="return false;" data-reset="1">

					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>Blog Başlığı</b></span>
							<input type="text" name="blog_title" id="blog_title" class="form-control">
						</div>
					</div>

					<div class="form-group">
						<textarea type="text" name="blog_content" class="form-control" id="editor"></textarea>
					</div>

					<div class="form-group">
						<span class="input-group-addon"><b>SEO Önizleme</b></span>
					</div>
					<div class="google-preview">
					  	<div class="google-preview-title" id="google_preview_title">Burası Blog Başlığınız</div>
					 	<div class="google-preview-link"><?=site('blog/')?><b id="google_preview_url">burasi-blog-linkiniz</b></div>
					  	<div class="google-preview-description" id="google_preview_desc">Burası blog yazınız için olan google'da gözükecek seo açıklamanızdır. SEO Açıklaması kısmını değiştirdiğiniz zaman burası otomatik olarak güncellenecektir.</div> 
					</div>
					<div class="form-group">
						<span class="input-group-addon"><b>SEO Ayarları</b></span>
					</div>
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>URL</b></span>
							<input type="text" name="blog_url"  id="blog_url" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>SEO Başlık</b></span>
							<input type="text" name="blog_seotitle"  id="seo_title" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>SEO Açıklaması</b></span>
							<textarea class="form-control"  id="seo_desc" name="blog_seodesc"></textarea>
						</div>
					</div>
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>SEO Anahtar Kelimeler</b></span>
							<input type="text" name="blog_seokeyw"  id="seo_keyw" class="form-control">
						</div>
					</div>

					<div class="form-group text-right">

						<a href="<?=admin_url('appearence/blog')?>" class="btn btn-warning">Bloglara Geri Dön</a>

						<button type="submit" class="btn btn-success">Blog Oluştur</button>

					</div>

				</form>

			</div>

		</div>



	<?php elseif(route(3) == "edit"): ?>



		<div class="panel panel-default">
			<div class="panel-body">
				<form id="update_blog" onsubmit="return false;" data-reset="0">
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>Blog Başlığı</b></span>
							<input type="text" name="blog_title" id="blog_title" class="form-control" value="<?=$blog['blog_title']?>">
						</div>
					</div>
					<div class="form-group">
						<textarea type="text" name="blog_content" class="form-control" id="editor"><?=$blog['blog_content']?></textarea>
					</div>
					<div class="form-group">
						<span class="input-group-addon"><b>SEO Önizleme</b></span>
					</div>
					<div class="google-preview">
					  	<div class="google-preview-title" id="google_preview_title"><?=$blog['blog_title']?></div>
					 	<div class="google-preview-link"><?=site('blog/')?><b id="google_preview_url"><?=$blog['blog_url']?></b></div>
					  	<div class="google-preview-description" id="google_preview_desc"><?=$blog['blog_seodesc']?></div> 
					</div>
					<div class="form-group">
						<span class="input-group-addon"><b>SEO Ayarları</b></span>
					</div>
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>URL</b></span>
							<input type="text" name="blog_url"  id="blog_url" class="form-control" value="<?=$blog['blog_url']?>">
						</div>
					</div>
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>SEO Başlık</b></span>
							<input type="text" name="blog_seotitle"  id="seo_title" class="form-control" value="<?=$blog['blog_seotitle']?>">
						</div>
					</div>
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>SEO Açıklaması</b></span>
							<textarea class="form-control"  id="seo_desc" name="blog_seodesc"><?=$blog['blog_seodesc']?></textarea>
						</div>
					</div>
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>SEO Anahtar Kelimeler</b></span>
							<input type="text" name="blog_seokeyw"  id="seo_keyw" class="form-control" value="<?=$blog['blog_seokeyw']?>">
						</div>
					</div>
					<input type="text" name="id" value="<?=$blog['id']?>" style="display: none;">
					<div class="form-group text-right">
						<a href="<?=admin_url('appearence/blog')?>" class="btn btn-warning">Bloglara Geri Dön</a>
						<button type="submit" class="btn btn-success">Güncelle</button>
					</div>
				</form>
			</div>
		</div>

	<?php endif; ?>

	<script src="<?=admin_public_url('assets/js/jquery.min.js')?>?v=<?=time()?>"></script>
		<script>

			$("#seo_title").change(function(){
				var seo_title 	= document.getElementById("seo_title");
				$('#google_preview_title').html(seo_title.value);
			});

			$("#blog_url").change(function(){
				var blog_url 	= document.getElementById("blog_url");
				$('#google_preview_url').html(blog_url.value);
			});

			$("#seo_desc").change(function(){
				var seo_desc 	= document.getElementById("seo_desc");
				$('#google_preview_desc').html(seo_desc.value);
			});

			function createSEOLink (link) {
			    var trMap = {
			        'çÇ':'c',
			        'ğĞ':'g',
			        'şŞ':'s',
			        'üÜ':'u',
			        'ıİ':'i',
			        'öÖ':'o'
			    };

			    for(var key in trMap) {
			        link = link.replace(new RegExp('['+key+']','g'), trMap[key]);
			    }
			    return  link.replace(/[^-a-zA-Z0-9\s]+/ig, '')
			                .replace(/\s/gi, "-")
			                .replace(/[-]+/gi, "-")
			                .toLowerCase();
			}

			$("#blog_title").change(function(){
				var blog_title 	= document.getElementById("blog_title");
				$('#blog_url').val(createSEOLink(blog_title.value));
				$('#google_preview_url').html(createSEOLink(blog_title.value));
			});

		</script>