mirror of
https://github.com/danpros/htmly.git
synced 2026-04-21 21:16:23 +05:30
Improve pages/subpages
Allow to reorder the pages and subpages position. Added doks theme
This commit is contained in:
parent
672aec1278
commit
8d142b7f37
46 changed files with 4860 additions and 94 deletions
|
|
@ -550,6 +550,8 @@ function add_page($title, $url, $content, $draft, $description = null)
|
|||
function add_sub_page($title, $url, $content, $static, $draft, $description = null)
|
||||
{
|
||||
|
||||
$post = find_page($static);
|
||||
$static = pathinfo($post['current']->md, PATHINFO_FILENAME);
|
||||
$post_title = safe_html($title);
|
||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
||||
$description = safe_html($description);
|
||||
|
|
@ -604,10 +606,17 @@ function add_sub_page($title, $url, $content, $static, $draft, $description = nu
|
|||
function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination = null, $description = null, $static = null)
|
||||
{
|
||||
$dir = pathinfo($oldfile, PATHINFO_DIRNAME);
|
||||
$fn = explode('.', pathinfo($oldfile, PATHINFO_FILENAME));
|
||||
if (isset($fn[1])) {
|
||||
$num = $fn[0] . '.';
|
||||
} else {
|
||||
$num = null;
|
||||
}
|
||||
$views = array();
|
||||
$viewsFile = "content/data/views.json";
|
||||
$post_title = safe_html($title);
|
||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
||||
$pUrl = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
||||
$post_url = $num . $pUrl;
|
||||
$description = safe_html($description);
|
||||
if ($description !== null) {
|
||||
if (!empty($description)) {
|
||||
|
|
@ -663,10 +672,16 @@ function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft,
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($static)) {
|
||||
$posturl = site_url() . $static .'/'. $post_url;
|
||||
$cl = explode('.', $post_url);
|
||||
if (isset($cl[1])) {
|
||||
$pu = $cl[1];
|
||||
} else {
|
||||
$posturl = site_url() . $post_url;
|
||||
$pu = $post_url;
|
||||
}
|
||||
if (!empty($static)) {
|
||||
$posturl = site_url() . $static .'/'. $pu;
|
||||
} else {
|
||||
$posturl = site_url() . $pu;
|
||||
}
|
||||
|
||||
rebuilt_cache('all');
|
||||
|
|
@ -957,14 +972,20 @@ function find_draft_page($static = null)
|
|||
$post = new stdClass;
|
||||
|
||||
// The static page URL
|
||||
$url= $v['filename'];
|
||||
$fn = explode('.', $v['filename']);
|
||||
|
||||
if (isset($fn[1])) {
|
||||
$url = $fn[1];
|
||||
} else {
|
||||
$url= $v['filename'];
|
||||
}
|
||||
|
||||
$post->url = site_url() . $url;
|
||||
|
||||
$post->file = $v['dirname'] . '/' . $v['basename'];
|
||||
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
|
||||
|
||||
$post->md = $url;
|
||||
$post->md = $v['basename'];
|
||||
$post->slug = $url;
|
||||
$post->parent = null;
|
||||
|
||||
|
|
@ -1010,8 +1031,14 @@ function find_draft_subpage($static = null, $sub_static = null)
|
|||
|
||||
$post = new stdClass;
|
||||
|
||||
// The static file
|
||||
$url= $v['filename'];
|
||||
// The static page URL
|
||||
$fn = explode('.', $v['filename']);
|
||||
|
||||
if (isset($fn[1])) {
|
||||
$url = $fn[1];
|
||||
} else {
|
||||
$url= $v['filename'];
|
||||
}
|
||||
|
||||
if (is_null($static)) {
|
||||
$parent = str_replace('content/static/', '', dirname($v['dirname']));
|
||||
|
|
@ -1025,7 +1052,7 @@ function find_draft_subpage($static = null, $sub_static = null)
|
|||
$post->file = $v['dirname'] . '/' . $v['basename'];
|
||||
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
|
||||
|
||||
$post->md = $url;
|
||||
$post->md = $v['basename'];
|
||||
$post->slug = $url;
|
||||
|
||||
// Get the contents and convert it to HTML
|
||||
|
|
@ -1463,3 +1490,60 @@ function rename_category_folder($new_name, $old_file)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
// reorder the static page
|
||||
function reorder_pages($pages = null)
|
||||
{
|
||||
|
||||
$i = 1;
|
||||
$arr = array();
|
||||
$dir = 'content/static/';
|
||||
foreach ($pages as $p) {
|
||||
$fn = pathinfo($p, PATHINFO_FILENAME);
|
||||
$num = str_pad($i, 2, 0, STR_PAD_LEFT);
|
||||
$arr = explode('.' , $fn);
|
||||
if (isset($arr[1])) {
|
||||
rename ($dir . $p, $dir . $num . '.' . $arr[1] . '.md');
|
||||
|
||||
if (is_dir($dir . $fn)) {
|
||||
rename($dir . $fn, $dir . $num . '.' . $arr[1]);
|
||||
}
|
||||
|
||||
} else {
|
||||
rename($dir . $p, $dir . $num . '.' . $fn . '.md');
|
||||
|
||||
if (is_dir($dir . $fn)) {
|
||||
rename($dir . $fn, $dir . $num . '.' . $fn);
|
||||
}
|
||||
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
rebuilt_cache();
|
||||
|
||||
}
|
||||
|
||||
// reorder the subpage
|
||||
function reorder_subpages($subpages = null)
|
||||
{
|
||||
$i = 1;
|
||||
$arr = array();
|
||||
$dir = 'content/static/';
|
||||
foreach ($subpages as $sp) {
|
||||
$dn = $dir . pathinfo($sp, PATHINFO_DIRNAME) . '/';
|
||||
$fn = pathinfo($sp, PATHINFO_FILENAME);
|
||||
$num = str_pad($i, 2, 0, STR_PAD_LEFT);
|
||||
$arr = explode('.' , $fn);
|
||||
if (isset($arr[1])) {
|
||||
rename ($dir . $sp, $dn . $num . '.' . $arr[1] . '.md');
|
||||
} else {
|
||||
rename($dir . $sp, $dn . $num . '.' . $fn . '.md');
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
}
|
||||
|
||||
rebuilt_cache();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ $( function() {
|
|||
<label for="pCategory"><?php echo i18n('Category');?> <span class="required">*</span></label>
|
||||
<select id="pCategory" class="form-control" name="category">
|
||||
<?php foreach ($desc as $d):?>
|
||||
<option value="<?php echo $d->md;?>"><?php echo $d->title;?></option>
|
||||
<option value="<?php echo $d->slug;?>"><?php echo $d->title;?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -7,20 +7,24 @@ $desc = get_category_info(null);
|
|||
<a class="btn btn-primary " href="<?php echo site_url();?>add/category"><?php echo i18n('Add_category');?></a>
|
||||
<br><br>
|
||||
<table class="table category-list">
|
||||
<thead>
|
||||
<tr class="head">
|
||||
<th><?php echo i18n('Name');?></th>
|
||||
<th><?php echo i18n('Description');?></th>
|
||||
<th><?php echo i18n('Contents');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($desc as $d):?>
|
||||
<tr>
|
||||
<td><a href="<?php echo site_url();?>admin/categories/<?php echo $d->md;?>"><?php echo $d->title;?></a></td>
|
||||
<td><a href="<?php echo site_url();?>admin/categories/<?php echo $d->slug;?>"><?php echo $d->title;?></a></td>
|
||||
<td><?php echo $d->body;?></td>
|
||||
<td><?php $total = get_draftcount($d->md) + $d->count + get_scheduledcount($d->md); echo $total?></td>
|
||||
<?php if($d->md !== 'uncategorized'):?>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo $d->url;?>/edit?destination=admin/categories"><?php echo i18n('Edit');?></a> <?php if ($d->count == 0 && get_draftcount($d->md) == 0 && get_scheduledcount($d->md) == 0){echo '<a class="btn btn-danger btn-xs" href="' . $d->url . '/delete?destination=admin/categories">' . i18n('Delete') . '</a>';}?></td>
|
||||
<?php endif;?>
|
||||
<td><?php $total = get_draftcount($d->slug) + $d->count + get_scheduledcount($d->slug); echo $total?></td>
|
||||
<?php if($d->slug !== 'uncategorized'):?>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo $d->url;?>/edit?destination=admin/categories"><?php echo i18n('Edit');?></a> <?php if ($d->count == 0 && get_draftcount($d->slug) == 0 && get_scheduledcount($d->slug) == 0){echo '<a class="btn btn-danger btn-xs" href="' . $d->url . '/delete?destination=admin/categories">' . i18n('Delete') . '</a>';}?></td>
|
||||
<?php endif;?>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -6,18 +6,21 @@
|
|||
<br><br>
|
||||
<?php if (!empty($posts)) { ?>
|
||||
<table class="table post-list">
|
||||
<thead>
|
||||
<tr class="head">
|
||||
<th><?php echo i18n('Title');?></th>
|
||||
<th><?php echo i18n('Published');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($posts as $p): ?>
|
||||
<tr>
|
||||
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
|
||||
<td><?php echo format_date($p->date) ?></td>
|
||||
<?php if ($category->url !== site_url() . 'category/uncategorized') {?>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/categories/<?php echo $category->md;?>"><?php echo i18n('Edit');?></a> <a
|
||||
class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/categories/<?php echo $category->md;?>"><?php echo i18n('Delete');?></a></td>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/categories/<?php echo $category->slug;?>"><?php echo i18n('Edit');?></a> <a
|
||||
class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/categories/<?php echo $category->slug;?>"><?php echo i18n('Delete');?></a></td>
|
||||
<?php } else {?>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/categories/uncategorized"><?php echo i18n('Edit');?></a> <a
|
||||
class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/categories/uncategorized"><?php echo i18n('Delete');?></a></td>
|
||||
|
|
@ -25,6 +28,7 @@
|
|||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ $( function() {
|
|||
<label for="pCategory"><?php echo i18n('Category');?> <span class="required">*</span></label>
|
||||
<select id="pCategory" class="form-control" name="category">
|
||||
<?php foreach ($desc as $d):?>
|
||||
<option value="<?php echo $d->md;?>" <?php if($category === $d->md) { echo 'selected="selected"';} ?>><?php echo $d->title;?></option>
|
||||
<option value="<?php echo $d->slug;?>" <?php if($category === $d->slug) { echo 'selected="selected"';} ?>><?php echo $d->title;?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ if ($type == 'is_frontpage') {
|
|||
$oldtitle = $p->title;
|
||||
$olddescription = $p->description;
|
||||
$oldcontent = $p->body;
|
||||
$oldmd = $p->md;
|
||||
$url = 'content/data/category/'. $p->md . '.md';
|
||||
$oldmd = $p->slug;
|
||||
$url = 'content/data/category/'. $p->slug . '.md';
|
||||
} else {
|
||||
|
||||
if (isset($p->file)) {
|
||||
|
|
@ -55,7 +55,13 @@ if ($type == 'is_frontpage') {
|
|||
}
|
||||
$dir = pathinfo($url, PATHINFO_DIRNAME);
|
||||
$oldurl = pathinfo($url, PATHINFO_BASENAME);
|
||||
$oldmd = pathinfo($url, PATHINFO_FILENAME);
|
||||
|
||||
$fn = explode('.', pathinfo($url, PATHINFO_FILENAME));
|
||||
if (isset($fn[1])) {
|
||||
$oldmd = $fn[1];
|
||||
} else {
|
||||
$oldmd = pathinfo($url, PATHINFO_FILENAME);
|
||||
}
|
||||
|
||||
if (isset($p->url)) {
|
||||
$delete = $p->url . '/delete?destination=' . $destination;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
<link href="<?php echo site_url() ?>system/resources/css/adminlte.min.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
|
||||
<script src="<?php echo site_url() ?>system/resources/js/jquery.min.js"></script>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/jquery-ui.min.js"></script>
|
||||
</head>
|
||||
<?php if (login()) { ?>
|
||||
<body class="hold-transition sidebar-mini">
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ function parseMenu($menu) {
|
|||
data: {'json': js},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
location.reload();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<br><br>
|
||||
<?php if (!empty($posts)) { ?>
|
||||
<table class="table post-list">
|
||||
<thead>
|
||||
<tr class="head">
|
||||
<th><?php echo i18n('Title');?></th>
|
||||
<th><?php echo i18n('Published');?></th><?php if (config("views.counter") == "true"): ?>
|
||||
|
|
@ -14,6 +15,8 @@
|
|||
<th><?php echo i18n('Tags');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($posts as $p): ?>
|
||||
<?php if (strpos($p->file, '/scheduled/') == false && strpos($p->file, '/draft/') == false) { ?>
|
||||
<tr>
|
||||
|
|
@ -29,6 +32,7 @@
|
|||
</tr>
|
||||
<?php } ?>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } else {
|
||||
echo i18n('No_posts_found') . '!';
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<br><br>
|
||||
<?php if (!empty($posts)) { ?>
|
||||
<table class="table post-list">
|
||||
<thead>
|
||||
<tr class="head">
|
||||
<th><?php echo i18n('Title');?></th>
|
||||
<th><?php echo i18n('Published');?></th><?php if (config("views.counter") == "true"): ?>
|
||||
|
|
@ -14,6 +15,8 @@
|
|||
<th><?php echo i18n('Tags');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($posts as $p): ?>
|
||||
<tr>
|
||||
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
|
||||
|
|
@ -27,6 +30,7 @@
|
|||
class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/posts"><?php echo i18n('Delete');?></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<br><br>
|
||||
<?php if (!empty($posts)) { ?>
|
||||
<table class="table post-list">
|
||||
<thead>
|
||||
<tr class="head">
|
||||
<th><?php echo i18n('Title');?></th>
|
||||
<th><?php echo i18n('Publish');?></th>
|
||||
|
|
@ -12,6 +13,8 @@
|
|||
<th><?php echo i18n('Tags');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($posts as $p): ?>
|
||||
<tr>
|
||||
<td><?php echo $p->title ?></td>
|
||||
|
|
@ -21,6 +24,7 @@
|
|||
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/scheduled"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/scheduled"><?php echo i18n('Delete');?></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -3,52 +3,68 @@
|
|||
<br>
|
||||
<a class="btn btn-primary right" href="<?php echo site_url();?>add/page"><?php echo i18n('Add_new_page');?></a>
|
||||
<br><br>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
var order;
|
||||
$( "tbody" ).sortable({update: function(e, ui) {
|
||||
order = $(this).sortable('toArray');
|
||||
$("#saveButton").css({"display": "block"});
|
||||
}});
|
||||
|
||||
$("#saveButton").click(function(){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?php echo site_url();?>admin/pages',
|
||||
dataType: 'json',
|
||||
data: {'json': order},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
location.reload();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php if (isset($_SESSION[site_url()]['user'])):?>
|
||||
<?php $posts = find_page();
|
||||
if (!empty($posts)): ?>
|
||||
<table class="table post-list">
|
||||
<tr class="head">
|
||||
<table class="table post-list" id="sortable">
|
||||
<thead>
|
||||
<tr class="head" id="head">
|
||||
<th><?php echo i18n('Title');?> </th>
|
||||
<?php if (config("views.counter") == "true"):?>
|
||||
<th><?php echo i18n('Views');?></th>
|
||||
<?php endif;?>
|
||||
<th><?php echo i18n('Description');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
<th>Subpages</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($posts as $p):?>
|
||||
<?php $dd = find_subpage($p->md); ?>
|
||||
<?php $dr = find_draft_subpage($p->md);?>
|
||||
<tr>
|
||||
<td><a target="_blank" href="<?php echo $p->url;?>"><?php echo $p->title;?></a></td>
|
||||
<?php if (config("views.counter") == "true"):?>
|
||||
<td><i class="nav-icon fa fa-line-chart"></i> <?php echo $p->views;?></td>
|
||||
<?php endif;?>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url;?>/add?destination=admin/pages"><?php echo i18n('Add_sub');?></a> <a class="btn btn-primary btn-xs" href="<?php echo $p->url;?>/edit?destination=admin/pages"><?php echo i18n('Edit');?></a> <?php if (empty($dd) && empty($dr)):?><a class="btn btn-danger btn-xs" href="<?php echo $p->url;?>/delete?destination=admin/pages"><?php echo i18n('Delete');?></a><?php endif;?></td>
|
||||
<?php $dd = find_subpage($p->slug); ?>
|
||||
<?php $dr = find_draft_subpage($p->slug);?>
|
||||
<tr id="<?php echo $p->md;?>" class="sort-item" style="cursor:move;">
|
||||
<td><a href="<?php echo site_url();?>admin/pages/<?php echo $p->slug;?>"><?php echo $p->title;?></a></td>
|
||||
<td><?php echo shorten($p->description, '50');?>...</td>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url;?>/add?destination=admin/pages/<?php echo $p->slug;?>"><?php echo i18n('Add_sub');?></a> <a class="btn btn-primary btn-xs" href="<?php echo $p->url;?>/edit?destination=admin/pages"><?php echo i18n('Edit');?></a> <?php if (empty($dd) && empty($dr)):?><a class="btn btn-danger btn-xs" href="<?php echo $p->url;?>/delete?destination=admin/pages"><?php echo i18n('Delete');?></a><?php endif;?></td>
|
||||
<td>
|
||||
<table>
|
||||
<?php $subPages = find_subpage($p->md);
|
||||
foreach ($subPages as $sp):?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6 col-md-4">
|
||||
<span><a target="_blank" href="<?php echo $sp->url;?>"><?php echo $sp->title;?></a></span>
|
||||
</div>
|
||||
<div class="col-6 col-md-4">
|
||||
<?php if (config("views.counter") == "true"):?>
|
||||
<span><i class="nav-icon fa fa-line-chart"></i> <?php echo $sp->views;?></span>
|
||||
<?php endif;?></div>
|
||||
<div class="col-6 col-md-4">
|
||||
<span><a class="btn btn-primary btn-xs" href="<?php echo $sp->url;?>/edit?destination=admin/pages"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $sp->url;?>/delete?destination=admin/pages"><?php echo i18n('Delete');?></a></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endforeach;?>
|
||||
|
||||
</table>
|
||||
<div><a class="btn btn-primary btn-xs" href="<?php echo site_url();?>admin/pages/<?php echo $p->slug;?>">Manage subpages</a></div><hr>
|
||||
<?php foreach ($dd as $sp):?>
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<span><a target="_blank" href="<?php echo $sp->url;?>"><?php echo $sp->title;?></a></span>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<span><a class="btn btn-primary btn-xs" href="<?php echo $sp->url;?>/edit?destination=admin/pages"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $sp->url;?>/delete?destination=admin/pages"><?php echo i18n('Delete');?></a></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach;?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<button class="btn btn-primary" style="display:none" id="saveButton">Save page order</button>
|
||||
<?php endif;?>
|
||||
<?php endif;?>
|
||||
57
system/admin/views/static-subpages.html.php
Normal file
57
system/admin/views/static-subpages.html.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||
<a href="<?php echo $static->url;?>/edit?destination=admin/pages"><?php echo i18n('Edit');?></a>
|
||||
<h2 class="post-index"><?php echo $static->title ?></h2>
|
||||
<div><?php echo $static->description;?></div>
|
||||
<br>
|
||||
<a class="btn btn-primary right" href="<?php echo $static->url;?>/add?destination=admin/pages/<?php echo $static->slug;?>"><?php echo i18n('Add_sub');?></a>
|
||||
<br><br>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
var order;
|
||||
$( "tbody" ).sortable({update: function(e, ui) {
|
||||
order = $(this).sortable('toArray');
|
||||
$("#saveButton").css({"display": "block"});
|
||||
}});
|
||||
|
||||
$("#saveButton").click(function(){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?php echo site_url();?>admin/pages/<?php echo $static->slug;?>',
|
||||
dataType: 'json',
|
||||
data: {'json': order},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
location.reload();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php $posts = find_subpage($p->slug);?>
|
||||
<?php if (!empty($posts)) { ?>
|
||||
<table class="table post-list">
|
||||
<thead>
|
||||
<tr class="head">
|
||||
<th><?php echo i18n('Title');?></th>
|
||||
<th><?php echo i18n('Description');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($posts as $sp): ?>
|
||||
<tr id="<?php echo $sp->parent;?>/<?php echo $sp->md;?>" style="cursor:move;">
|
||||
<td><a href="<?php echo $sp->url ?>"><?php echo $sp->title ?></a></td>
|
||||
<td><?php echo $sp->description;?></td>
|
||||
<td> <span><a class="btn btn-primary btn-xs" href="<?php echo $sp->url;?>/edit?destination=admin/pages/<?php echo $static->slug;?>"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $sp->url;?>/delete?destination=admin/pages/<?php echo $static->slug;?>"><?php echo i18n('Delete');?></a></span></td>
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<button class="btn btn-primary" style="display:none" id="saveButton">Save page order</button>
|
||||
<?php } else {
|
||||
echo i18n('No_posts_found') . '!';
|
||||
} ?>
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
<br><br>
|
||||
<?php if (!empty($posts)) { ?>
|
||||
<table class="table post-list">
|
||||
<thead>
|
||||
<tr class="head">
|
||||
<th><?php echo i18n('Title');?></th>
|
||||
<th><?php echo i18n('Created');?></th>
|
||||
|
|
@ -12,6 +13,8 @@
|
|||
<th><?php echo i18n('Tags');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($posts as $p): ?>
|
||||
<tr>
|
||||
<td><?php echo $p->title ?></td>
|
||||
|
|
@ -21,6 +24,7 @@
|
|||
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/draft"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/draft"><?php echo i18n('Delete');?></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
|
||||
<br>
|
||||
|
|
@ -55,7 +59,7 @@
|
|||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
<?php foreach ($draftPages as $d): ?>
|
||||
<?php $count = count(find_subpage($d->md)); ?>
|
||||
<?php $count = count(find_subpage($d->md)); ?>
|
||||
<tr>
|
||||
<td><?php echo $d->title ?></td>
|
||||
<td><?php echo format_date($d->lastMod) ?></td>
|
||||
|
|
@ -74,15 +78,15 @@
|
|||
<th><?php echo i18n('Title');?></th>
|
||||
<th><?php echo i18n('Created');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
<th><?php echo i18n('Static_pages');?></th>
|
||||
<th><?php echo i18n('Static_pages');?></th>
|
||||
</tr>
|
||||
<?php foreach ($draftSubpages as $sp): ?>
|
||||
<?php $parent = find_page($sp->parent);?>
|
||||
<?php $parent = find_page($sp->parent);?>
|
||||
<tr>
|
||||
<td><?php echo $sp->title ?></td>
|
||||
<td><?php echo format_date($sp->lastMod) ?></td>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo $sp->url ?>/edit?destination=admin/draft"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $sp->url ?>/delete?destination=admin/draft"><?php echo i18n('Delete');?></a></td>
|
||||
<td><a href="<?php echo $parent['current']->url;?>"><?php echo $parent['current']->title;?></a></td>
|
||||
<td><a href="<?php echo $parent['current']->url;?>"><?php echo $parent['current']->title;?></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<br><br>
|
||||
<?php if (!empty($posts)) { ?>
|
||||
<table class="table post-list">
|
||||
<thead>
|
||||
<tr class="head">
|
||||
<th><?php echo i18n('Title');?></th>
|
||||
<th><?php echo i18n('Published');?></th>
|
||||
|
|
@ -15,6 +16,8 @@
|
|||
<th><?php echo i18n('Tags');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($posts as $p): ?>
|
||||
<tr>
|
||||
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
|
||||
|
|
@ -27,6 +30,7 @@
|
|||
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/mine"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/mine"><?php echo i18n('Delete');?></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -1122,6 +1122,87 @@ get('/admin/pages', function () {
|
|||
die;
|
||||
});
|
||||
|
||||
post('/admin/pages', function () {
|
||||
|
||||
if (login()) {
|
||||
$json = from($_REQUEST, 'json');
|
||||
reorder_pages($json);
|
||||
echo json_encode(array(
|
||||
'message' => 'Page order saved successfully!',
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
// Show admin/pages
|
||||
get('/admin/pages/:static', function ($static)
|
||||
{
|
||||
$user = $_SESSION[site_url()]['user'];
|
||||
$role = user('role', $user);
|
||||
if (login()) {
|
||||
|
||||
config('views.root', 'system/admin/views');
|
||||
if ($role === 'admin') {
|
||||
|
||||
$post = find_page($static);
|
||||
|
||||
if (!$post) {
|
||||
not_found();
|
||||
}
|
||||
|
||||
if (array_key_exists('prev', $post)) {
|
||||
$prev = $post['prev'];
|
||||
} else {
|
||||
$prev = array();
|
||||
}
|
||||
|
||||
if (array_key_exists('next', $post)) {
|
||||
$next = $post['next'];
|
||||
} else {
|
||||
$next = array();
|
||||
}
|
||||
|
||||
$post = $post['current'];
|
||||
|
||||
render('static-subpages', array(
|
||||
'title' => $post->title . ' - ' . blog_title(),
|
||||
'description' => $post->description,
|
||||
'canonical' => $post->url,
|
||||
'bodyclass' => 'in-page ' . strtolower($static),
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . '<a href="'. site_url() .'admin/pages">Pages</a> » ' . $post->title,
|
||||
'p' => $post,
|
||||
'static' => $post,
|
||||
'type' => 'staticSubpage',
|
||||
'prev' => static_prev($prev),
|
||||
'next' => static_next($next),
|
||||
'is_page' => true
|
||||
));
|
||||
} else {
|
||||
render('denied', array(
|
||||
'title' => 'Pages - ' . blog_title(),
|
||||
'description' => strip_tags(blog_description()),
|
||||
'canonical' => site_url(),
|
||||
'type' => 'is_admin-pages',
|
||||
'is_admin' => true,
|
||||
'bodyclass' => 'denied',
|
||||
'breadcrumb' => '',
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
}
|
||||
});
|
||||
|
||||
post('/admin/pages/:static', function ($static) {
|
||||
|
||||
if (login()) {
|
||||
$json = from($_REQUEST, 'json');
|
||||
reorder_subpages($json);
|
||||
echo json_encode(array(
|
||||
'message' => 'Page order saved successfully!',
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
// Show import page
|
||||
get('/admin/import', function () {
|
||||
if (login()) {
|
||||
|
|
@ -2969,7 +3050,7 @@ get('/:static', function ($static) {
|
|||
if (!$post) {
|
||||
not_found();
|
||||
}
|
||||
|
||||
|
||||
if (array_key_exists('prev', $post)) {
|
||||
$prev = $post['prev'];
|
||||
} else {
|
||||
|
|
@ -3048,7 +3129,7 @@ get('/:static/add', function ($static) {
|
|||
'type' => 'is_page',
|
||||
'is_admin' => true,
|
||||
'bodyclass' => 'add-page',
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . $post->url . '">' . $post->title . '</a> » ' . i18n('Add_new_page')
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . site_url() . 'admin/pages/' . $post->slug . '">' . $post->title . '</a> » ' . i18n('Add_new_page')
|
||||
));
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
|
|
@ -3355,7 +3436,7 @@ get('/:static/:sub/edit', function ($static, $sub) {
|
|||
'canonical' => site_url(),
|
||||
'bodyclass' => 'edit-page',
|
||||
'is_admin' => true,
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . $post->url . '">' . $post->title . '</a> » ' . $page->title,
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . site_url() . 'admin/pages/' . $post->slug . '">' . $post->title . '</a> » ' . $page->title,
|
||||
'p' => $page,
|
||||
'static' => $page,
|
||||
'type' => 'subPage',
|
||||
|
|
@ -3457,7 +3538,7 @@ get('/:static/:sub/delete', function ($static, $sub) {
|
|||
'canonical' => site_url(),
|
||||
'bodyclass' => 'delete-page',
|
||||
'is_admin' => true,
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . $post->url . '">' . $post->title . '</a> » ' . $page->title,
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . site_url() . 'admin/pages/' . $post->slug . '">' . $post->title . '</a> » ' . $page->title,
|
||||
'p' => $page,
|
||||
'static' => $page,
|
||||
'type' => 'subPage',
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ function render($view, $locals = null, $layout = null)
|
|||
|
||||
if (($view_root = config('views.root')) == null)
|
||||
error(500, "[views.root] is not set");
|
||||
|
||||
|
||||
$fnc = "{$view_root}/functions.php";
|
||||
|
||||
ob_start();
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ function get_static_subpages($static = null)
|
|||
$stringLen = strlen($static);
|
||||
return array_filter($_sub_page, function ($sub_page) use ($static, $stringLen) {
|
||||
$x = explode("/", $sub_page['dirname']);
|
||||
if ($x[2] == $static) {
|
||||
if (strpos($x[2], $static) !== false) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -126,7 +126,7 @@ function get_draft_subpages($static = null)
|
|||
$stringLen = strlen($static);
|
||||
return array_filter($_draftSubpage, function ($sub_page) use ($static, $stringLen) {
|
||||
$x = explode("/", $sub_page['dirname']);
|
||||
if ($x[2] == $static) {
|
||||
if (strpos($x[2], $static) !== false) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -544,14 +544,20 @@ function get_pages($pages, $page = 1, $perpage = 0)
|
|||
$post = new stdClass;
|
||||
|
||||
// The static page URL
|
||||
$url= $v['filename'];
|
||||
$fn = explode('.', $v['filename']);
|
||||
|
||||
if (isset($fn[1])) {
|
||||
$url = $fn[1];
|
||||
} else {
|
||||
$url= $v['filename'];
|
||||
}
|
||||
|
||||
$post->url = site_url() . $url;
|
||||
|
||||
$post->file = $v['dirname'] . '/' . $v['basename'];
|
||||
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
|
||||
|
||||
$post->md = $url;
|
||||
$post->md = $v['basename'];
|
||||
$post->slug = $url;
|
||||
$post->parent = null;
|
||||
|
||||
|
|
@ -597,18 +603,32 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
|
|||
|
||||
$post = new stdClass;
|
||||
|
||||
$static = str_replace(dirname($v['dirname']) . '/', '', $v['dirname']);
|
||||
$fd = str_replace(dirname($v['dirname']) . '/', '', $v['dirname']);
|
||||
|
||||
$st = explode('.', $fd);
|
||||
if (isset($st[1])) {
|
||||
$static = $st[1];
|
||||
} else {
|
||||
$static = $fd;
|
||||
}
|
||||
|
||||
// The static page URL
|
||||
$url= $v['filename'];
|
||||
$fn = explode('.', $v['filename']);
|
||||
|
||||
if (isset($fn[1])) {
|
||||
$url = $fn[1];
|
||||
} else {
|
||||
$url= $v['filename'];
|
||||
}
|
||||
|
||||
$post->url = site_url() . $static . "/" . $url;
|
||||
|
||||
$post->file = $v['dirname'] . '/' . $v['basename'];
|
||||
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
|
||||
|
||||
$post->md = $url;
|
||||
$post->md = $v['basename'];
|
||||
$post->slug = $url;
|
||||
$post->parent = $static;
|
||||
$post->parent = $fd;
|
||||
|
||||
// Get the contents and convert it to HTML
|
||||
$content = file_get_contents($post->file);
|
||||
|
|
@ -877,7 +897,7 @@ function read_category_info($category)
|
|||
|
||||
$desc->url = site_url() . 'category/' . $url;
|
||||
|
||||
$desc->md = $url;
|
||||
$desc->md = $v['basename'];
|
||||
|
||||
$desc->slug = $url;
|
||||
|
||||
|
|
@ -914,16 +934,16 @@ function default_category($category = null)
|
|||
$desc->url = site_url() . 'category/uncategorized';
|
||||
$desc->slug = 'uncategorized';
|
||||
$desc->body = '<p>' . i18n('Uncategorized_comment') . '</p>';
|
||||
$desc->md = 'uncategorized';
|
||||
$desc->md = 'uncategorized.md';
|
||||
$desc->description = i18n('Uncategorized_comment');
|
||||
$desc->file = '';
|
||||
$desc->count = get_categorycount($desc->md);
|
||||
$desc->count = get_categorycount($desc->slug);
|
||||
} else {
|
||||
$desc->title = $category;
|
||||
$desc->url = site_url() . 'category/' . $category;
|
||||
$desc->slug = $category;
|
||||
$desc->body = '<p>' . i18n('All_blog_posts') . ': ' . $category . '</p>';
|
||||
$desc->md = $category;
|
||||
$desc->md = $category . '.md';
|
||||
$desc->description = i18n('All_blog_posts') . ': ' . $category;
|
||||
$desc->file = '';
|
||||
$desc->count = get_categorycount($category);
|
||||
|
|
@ -950,7 +970,7 @@ function category_list($custom = null) {
|
|||
} else {
|
||||
$arr = get_category_info(null);
|
||||
foreach ($arr as $i => $a) {
|
||||
$cat[] = array($a->md, $a->title, $a->count, $a->description);
|
||||
$cat[] = array($a->slug, $a->title, $a->count, $a->description);
|
||||
}
|
||||
|
||||
$tmp = serialize($cat);
|
||||
|
|
@ -2447,7 +2467,7 @@ function get_title_from_file($v)
|
|||
}
|
||||
|
||||
// Auto generate menu from static page
|
||||
function get_menu($custom)
|
||||
function get_menu($custom = null, $auto = null)
|
||||
{
|
||||
$posts = get_static_pages();
|
||||
$req = $_SERVER['REQUEST_URI'];
|
||||
|
|
@ -2457,17 +2477,20 @@ function get_menu($custom)
|
|||
asort($posts);
|
||||
|
||||
echo '<ul class="nav ' . $custom . '">';
|
||||
if ($req == site_path() . '/' || stripos($req, site_path() . '/?page') !== false) {
|
||||
echo '<li class="item first active"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
|
||||
} else {
|
||||
echo '<li class="item first"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
|
||||
}
|
||||
|
||||
if (config('blog.enable') == 'true' ) {
|
||||
if ($req == site_path() . '/blog' || stripos($req, site_path() . '/blog?page') !== false) {
|
||||
echo '<li class="item active"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
|
||||
|
||||
if (is_null($auto)) {
|
||||
if ($req == site_path() . '/' || stripos($req, site_path() . '/?page') !== false) {
|
||||
echo '<li class="item first active"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
|
||||
} else {
|
||||
echo '<li class="item"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
|
||||
echo '<li class="item first"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
|
||||
}
|
||||
|
||||
if (config('blog.enable') == 'true' ) {
|
||||
if ($req == site_path() . '/blog' || stripos($req, site_path() . '/blog?page') !== false) {
|
||||
echo '<li class="item active"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
|
||||
} else {
|
||||
echo '<li class="item"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2484,7 +2507,15 @@ function get_menu($custom)
|
|||
$i++;
|
||||
|
||||
// Filename string
|
||||
$filename= $v['filename'];
|
||||
|
||||
$fn = explode('.', $v['filename']);
|
||||
|
||||
if (isset($fn[1])) {
|
||||
$filename= $fn[1];
|
||||
} else {
|
||||
$filename= $v['filename'];
|
||||
}
|
||||
|
||||
$url = site_url() . $filename;
|
||||
$parent_file = $v['dirname'] . '/' . $v['basename'];
|
||||
|
||||
|
|
@ -2514,7 +2545,13 @@ function get_menu($custom)
|
|||
$classSub .= " last";
|
||||
}
|
||||
|
||||
$baseSub= $sp['filename'];
|
||||
$bs = explode('.', $sp['filename']);
|
||||
if (isset($bs[1])) {
|
||||
$baseSub = $bs[1];
|
||||
} else {
|
||||
$baseSub= $sp['filename'];
|
||||
}
|
||||
|
||||
$child_file = $sp['dirname'] . '/' . $sp['basename'];
|
||||
if ($req == site_path() . "/" . $filename . "/" . $baseSub) {
|
||||
$classSub .= ' active';
|
||||
|
|
@ -2721,9 +2758,15 @@ function sitemap_page_path()
|
|||
foreach ($posts as $index => $v) {
|
||||
|
||||
$post = new stdClass;
|
||||
|
||||
$fn = explode('.', $v['filename']);
|
||||
|
||||
if (isset($fn[1])) {
|
||||
$filename = $fn[1];
|
||||
} else {
|
||||
$filename= $v['filename'];
|
||||
}
|
||||
|
||||
// Filename
|
||||
$filename= $v['filename'];
|
||||
$file = $v['dirname'] . '/' . $v['basename'];
|
||||
$post->url = site_url() . $filename;
|
||||
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($file)));
|
||||
|
|
|
|||
13
system/resources/js/jquery-ui.min.js
vendored
13
system/resources/js/jquery-ui.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue