Browse Source

Basic Support for SubPages Ready to use.

Must Add CMS Funktions Add/Edit/delete to it.
if Rename a Static page the subFolder must be renamed as well.
pull/74/head
Kanti 11 years ago
parent
commit
fa77cc805b
3 changed files with 79 additions and 17 deletions
  1. +3
    -3
      system/admin/admin.php
  2. +26
    -0
      system/htmly.php
  3. +50
    -14
      system/includes/functions.php

+ 3
- 3
system/admin/admin.php View File

@ -374,7 +374,7 @@ function get_recent_pages() {
echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>'; echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>';
if (config("views.counter") == "true") if (config("views.counter") == "true")
echo '<td>' . $p->views . '</td>'; echo '<td>' . $p->views . '</td>';
echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
echo '<td><a href="' . $p->url . '/add?destination=admin">Add Sub</a> <a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
echo '</tr>'; echo '</tr>';
$shortUrl = substr($p->url,strrpos($p->url, "/") + 1); $shortUrl = substr($p->url,strrpos($p->url, "/") + 1);
@ -384,8 +384,8 @@ function get_recent_pages() {
{ {
echo '<tr class="' . $class . '">'; echo '<tr class="' . $class . '">';
echo '<td> &raquo;<a target="_blank" href="' . $sp->url . '">' . $sp->title . '</a></td>'; echo '<td> &raquo;<a target="_blank" href="' . $sp->url . '">' . $sp->title . '</a></td>';
if (config("views.counter") == "true")
echo '<td>' . $sp->views . '</td>';
if (config("views.counter") == "true")
echo '<td>' . $sp->views . '</td>';
echo '<td><a href="' . $sp->url . '/edit?destination=admin">Edit</a> <a href="' . $sp->url . '/delete?destination=admin">Delete</a></td>'; echo '<td><a href="' . $sp->url . '/edit?destination=admin">Edit</a> <a href="' . $sp->url . '/delete?destination=admin">Delete</a></td>';
echo '</tr>'; echo '</tr>';
} }


+ 26
- 0
system/htmly.php View File

@ -108,6 +108,24 @@ post('/login', function() {
} }
}); });
get("/:static/:sub/edit", function($static,$sub){
echo $static,$sub,"edit";
die();
});
post("/:static/:sub/edit", function($static,$sub){
echo $static,$sub,"edit.";
die();
});
get("/:static/:sub/delete", function($static,$sub){
echo $static,$sub,"delete";
die();
});
post("/:static/:sub/delete", function($static,$sub){
echo $static,$sub,"delete.";
die();
});
// The blog post page // The blog post page
get('/:year/:month/:name', function($year, $month, $name) { get('/:year/:month/:name', function($year, $month, $name) {
@ -1098,6 +1116,14 @@ get('/admin/update/now/:csrf', function($CSRF) {
} }
}); });
get('/:static/add', function($static){
echo $static,"add";
die();
});
post('/:static/add', function($static){
echo $static,"add.";
die();
});
get('/:static/:sub', function($static,$sub) { get('/:static/:sub', function($static,$sub) {


+ 50
- 14
system/includes/functions.php View File

@ -1082,6 +1082,22 @@ function menu() {
} }
} }
function get_title_from_file($v)
{
// Get the contents and convert it to HTML
$content = MarkdownExtra::defaultTransform(file_get_contents($v));
// Extract the title and body
$arr = explode('t-->', $content);
if (isset($arr[1])) {
$title = str_replace('<!--t', '', $arr[0]);
$title = rtrim(ltrim($title, ' '), ' ');
} else {
$title = str_replace('-', ' ', str_replace('.md', '', $base));
}
return $title;
}
// Auto generate menu from static page // Auto generate menu from static page
function get_menu() { function get_menu() {
@ -1116,23 +1132,43 @@ function get_menu() {
$base = str_replace($replaced, '', $v); $base = str_replace($replaced, '', $v);
$url = site_url() . str_replace('.md', '', $base); $url = site_url() . str_replace('.md', '', $base);
// Get the contents and convert it to HTML
$content = MarkdownExtra::defaultTransform(file_get_contents($v));
// Extract the title and body
$arr = explode('t-->', $content);
if (isset($arr[1])) {
$title = str_replace('<!--t', '', $arr[0]);
$title = rtrim(ltrim($title, ' '), ' ');
} else {
$title = str_replace('-', ' ', str_replace('.md', '', $base));
}
$title = get_title_from_file($v);
if (strpos($req, str_replace('.md', '', $base)) !== false) { if (strpos($req, str_replace('.md', '', $base)) !== false) {
echo '<li class="' . $class . ' active"><a href="' . $url . '">' . ucwords($title) . '</a></li>';
$active = ' active';
} else { } else {
echo '<li class="' . $class . '"><a href="' . $url . '">' . ucwords($title) . '</a></li>';
$active = '';
} }
echo '<li class="' . $class . '"' . $active . '>';
$subPages = get_static_sub_pages(str_replace('.md', '', $base));
echo '<a href="' . $url . '">' . ucwords($title) . '</a><br/>';
if(!empty($subPages))
{
echo '<ul>';
$iSub = 0;
$countSub = count($subPages);
foreach($subPages as $index => $sp)
{
$classSub = "item";
if($iSub == 0)
{
$classSub .= " first";
}
if($iSub == $countSub -1)
{
$classSub .= " last";
}
$replacedSub = substr($sp, 0, strrpos($sp, '/')) . '/';
$baseSub = str_replace($replacedSub, '', $sp);
$urlSub = $url . "/" . str_replace('.md', '', $baseSub);
echo '<li class="' . $classSub . '"><a href="' . $urlSub . '">&raquo; ' . get_title_from_file($sp) . '</a></li>';
$iSub++;
}
echo '</ul>';
}
echo '</li>';
} }
echo '</ul>'; echo '</ul>';
} else { } else {


Loading…
Cancel
Save