Browse Source

ContentManagement of SubPages Finished.

(BUG) Active link if Page and Page/subPage have the same Name.
pull/74/head
Kanti 11 years ago
parent
commit
be5c20d63e
3 changed files with 17 additions and 7 deletions
  1. +1
    -1
      system/admin/admin.php
  2. +6
    -2
      system/htmly.php
  3. +10
    -4
      system/includes/functions.php

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

@ -184,7 +184,7 @@ function add_sub_page($title, $url, $content, $static) {
$post_content = stripslashes($post_content);
}
$filename = $post_url . '.md';
$dir = 'content/static/' . $static;
$dir = 'content/static/' . $static . '/';
if (is_dir($dir)) {
file_put_contents($dir . $filename, print_r($post_content, true));
} else {


+ 6
- 2
system/htmly.php View File

@ -141,7 +141,7 @@ get("/:static/:sub/edit", function($static,$sub) {
header("location: $login");
}
});
post("/:static/:sub/edit", function() {
post("/:static/:sub/edit", function($static,$sub) {
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
if(!login())
@ -155,6 +155,10 @@ post("/:static/:sub/edit", function() {
$content = from($_REQUEST, 'content');
$oldfile = from($_REQUEST, 'oldfile');
$destination = from($_GET, 'destination');
if($destination === null)
{
$destination = $static . "/" . $sub;
}
if ($proper && !empty($title) && !empty($content)) {
if (!empty($url)) {
edit_page($title, $url, $content, $oldfile, $destination);
@ -1252,7 +1256,7 @@ get('/:static/add', function($static) {
header("location: $login");
}
});
post('/:static/add', function($static) {//not working
post('/:static/add', function($static) {
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));


+ 10
- 4
system/includes/functions.php View File

@ -1099,7 +1099,7 @@ function get_title_from_file($v)
}
// Auto generate menu from static page
function get_menu() {
function get_menu() {//aktive Link for Sub Pages ::TODO
$posts = get_static_pages();
$req = $_SERVER['REQUEST_URI'];
@ -1133,13 +1133,16 @@ function get_menu() {
$url = site_url() . str_replace('.md', '', $base);
$title = get_title_from_file($v);
if (strpos($req, str_replace('.md', '', $base)) !== false) {
$reqBase = str_replace(substr($req, 0, strrpos($req, '/')) . '/', '', $req);
if ($reqBase == str_replace('.md', '', $base)) {
$active = ' active';
$reqBase = '';
} else {
$active = '';
}
echo '<li class="' . $class . ' ' . $active . '">';
echo '<li class="' . $class . $active . '">';
$subPages = get_static_sub_pages(str_replace('.md', '', $base));
echo '<a href="' . $url . '">' . ucwords($title) . '</a><br/>';
@ -1162,6 +1165,9 @@ function get_menu() {
}
$replacedSub = substr($sp, 0, strrpos($sp, '/')) . '/';
$baseSub = str_replace($replacedSub, '', $sp);
if ($reqBase == str_replace('.md', '', $baseSub)) {
$classSub .= ' active';
}
$urlSub = $url . "/" . str_replace('.md', '', $baseSub);
echo '<li class="' . $classSub . '"><a href="' . $urlSub . '">&raquo; ' . get_title_from_file($sp) . '</a></li>';
$iSub++;


Loading…
Cancel
Save