mirror of
https://github.com/danpros/htmly.git
synced 2026-04-21 21:16:23 +05:30
ContentManagement of SubPages Finished.
(BUG) Active link if Page and Page/subPage have the same Name.
This commit is contained in:
parent
614c64e62d
commit
be5c20d63e
3 changed files with 17 additions and 7 deletions
|
|
@ -184,7 +184,7 @@ function add_sub_page($title, $url, $content, $static) {
|
||||||
$post_content = stripslashes($post_content);
|
$post_content = stripslashes($post_content);
|
||||||
}
|
}
|
||||||
$filename = $post_url . '.md';
|
$filename = $post_url . '.md';
|
||||||
$dir = 'content/static/' . $static;
|
$dir = 'content/static/' . $static . '/';
|
||||||
if (is_dir($dir)) {
|
if (is_dir($dir)) {
|
||||||
file_put_contents($dir . $filename, print_r($post_content, true));
|
file_put_contents($dir . $filename, print_r($post_content, true));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ get("/:static/:sub/edit", function($static,$sub) {
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
post("/:static/:sub/edit", function() {
|
post("/:static/:sub/edit", function($static,$sub) {
|
||||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||||
|
|
||||||
if(!login())
|
if(!login())
|
||||||
|
|
@ -155,6 +155,10 @@ post("/:static/:sub/edit", function() {
|
||||||
$content = from($_REQUEST, 'content');
|
$content = from($_REQUEST, 'content');
|
||||||
$oldfile = from($_REQUEST, 'oldfile');
|
$oldfile = from($_REQUEST, 'oldfile');
|
||||||
$destination = from($_GET, 'destination');
|
$destination = from($_GET, 'destination');
|
||||||
|
if($destination === null)
|
||||||
|
{
|
||||||
|
$destination = $static . "/" . $sub;
|
||||||
|
}
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
if (!empty($url)) {
|
if (!empty($url)) {
|
||||||
edit_page($title, $url, $content, $oldfile, $destination);
|
edit_page($title, $url, $content, $oldfile, $destination);
|
||||||
|
|
@ -1252,7 +1256,7 @@ get('/:static/add', function($static) {
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
post('/:static/add', function($static) {//not working
|
post('/:static/add', function($static) {
|
||||||
|
|
||||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1099,7 +1099,7 @@ function get_title_from_file($v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto generate menu from static page
|
// Auto generate menu from static page
|
||||||
function get_menu() {
|
function get_menu() {//aktive Link for Sub Pages ::TODO
|
||||||
|
|
||||||
$posts = get_static_pages();
|
$posts = get_static_pages();
|
||||||
$req = $_SERVER['REQUEST_URI'];
|
$req = $_SERVER['REQUEST_URI'];
|
||||||
|
|
@ -1133,13 +1133,16 @@ function get_menu() {
|
||||||
$url = site_url() . str_replace('.md', '', $base);
|
$url = site_url() . str_replace('.md', '', $base);
|
||||||
|
|
||||||
$title = get_title_from_file($v);
|
$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';
|
$active = ' active';
|
||||||
|
$reqBase = '';
|
||||||
} else {
|
} else {
|
||||||
$active = '';
|
$active = '';
|
||||||
}
|
}
|
||||||
echo '<li class="' . $class . ' ' . $active . '">';
|
echo '<li class="' . $class . $active . '">';
|
||||||
|
|
||||||
$subPages = get_static_sub_pages(str_replace('.md', '', $base));
|
$subPages = get_static_sub_pages(str_replace('.md', '', $base));
|
||||||
echo '<a href="' . $url . '">' . ucwords($title) . '</a><br/>';
|
echo '<a href="' . $url . '">' . ucwords($title) . '</a><br/>';
|
||||||
|
|
@ -1162,6 +1165,9 @@ function get_menu() {
|
||||||
}
|
}
|
||||||
$replacedSub = substr($sp, 0, strrpos($sp, '/')) . '/';
|
$replacedSub = substr($sp, 0, strrpos($sp, '/')) . '/';
|
||||||
$baseSub = str_replace($replacedSub, '', $sp);
|
$baseSub = str_replace($replacedSub, '', $sp);
|
||||||
|
if ($reqBase == str_replace('.md', '', $baseSub)) {
|
||||||
|
$classSub .= ' active';
|
||||||
|
}
|
||||||
$urlSub = $url . "/" . str_replace('.md', '', $baseSub);
|
$urlSub = $url . "/" . str_replace('.md', '', $baseSub);
|
||||||
echo '<li class="' . $classSub . '"><a href="' . $urlSub . '">» ' . get_title_from_file($sp) . '</a></li>';
|
echo '<li class="' . $classSub . '"><a href="' . $urlSub . '">» ' . get_title_from_file($sp) . '</a></li>';
|
||||||
$iSub++;
|
$iSub++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue