fixes
This commit is contained in:
parent
34d0ca59a6
commit
1ab8659a21
@ -393,11 +393,13 @@ class AdminHandler extends request_handler {
|
||||
|
||||
}
|
||||
|
||||
function GET_auto_edit() {
|
||||
function GET_page_edit() {
|
||||
list($short_name, $saved) = input('short_name, b:saved');
|
||||
|
||||
$page = pages::getByName($short_name);
|
||||
if ($page) {
|
||||
if (!$page)
|
||||
not_found();
|
||||
|
||||
return $this->_get_pageEdit($page,
|
||||
title: $page->title,
|
||||
text: $page->md,
|
||||
@ -406,9 +408,6 @@ class AdminHandler extends request_handler {
|
||||
);
|
||||
}
|
||||
|
||||
not_found();
|
||||
}
|
||||
|
||||
function POST_auto_edit() {
|
||||
list($short_name) = input('short_name');
|
||||
|
||||
|
@ -15,21 +15,32 @@ class MainHandler extends request_handler {
|
||||
list($name) = input('name');
|
||||
|
||||
$page = pages::getByName($name);
|
||||
if ($page)
|
||||
return $this->renderPage($page);
|
||||
|
||||
if (!$page) {
|
||||
if (is_admin()) {
|
||||
set_title($name);
|
||||
render('admin/pageNew',
|
||||
short_name: $name);
|
||||
}
|
||||
not_found();
|
||||
}
|
||||
|
||||
if (!is_admin() && !$page->visible)
|
||||
not_found();
|
||||
|
||||
if ($page->shortName == 'info')
|
||||
set_skin_opts(['head_section' => 'about']);
|
||||
|
||||
set_title($page ? $page->title : '???');
|
||||
render('main/page',
|
||||
unsafe_html: $page->getHtml(is_retina(), getUserTheme()),
|
||||
page_url: $page->getUrl(),
|
||||
short_name: $page->shortName);
|
||||
|
||||
not_found();
|
||||
}
|
||||
|
||||
function GET_post() {
|
||||
global $config;
|
||||
|
||||
ensure_admin();
|
||||
|
||||
list($name, $input_lang) = input('name, lang');
|
||||
@ -46,8 +57,9 @@ class MainHandler extends request_handler {
|
||||
$lang = PostLanguage::getDefault();
|
||||
|
||||
$post = posts::getByName($name);
|
||||
if (!$post)
|
||||
not_found();
|
||||
|
||||
if ($post) {
|
||||
if ($lang == PostLanguage::getDefault() && $input_lang == $lang->value)
|
||||
redirect($post->getUrl());
|
||||
if (!$post->hasLang($lang))
|
||||
@ -97,25 +109,6 @@ class MainHandler extends request_handler {
|
||||
other_langs: $other_langs);
|
||||
}
|
||||
|
||||
not_found();
|
||||
}
|
||||
|
||||
protected function renderPage(Page $page) {
|
||||
global $config;
|
||||
|
||||
if (!is_admin() && !$page->visible && $page->get_id() != $config['index_page_id'])
|
||||
not_found();
|
||||
|
||||
if ($page->shortName == 'info')
|
||||
set_skin_opts(['head_section' => 'about']);
|
||||
|
||||
set_title($page ? $page->title : '???');
|
||||
render('main/page',
|
||||
unsafe_html: $page->getHtml(is_retina(), getUserTheme()),
|
||||
page_url: $page->getUrl(),
|
||||
short_name: $page->shortName);
|
||||
}
|
||||
|
||||
function GET_rss() {
|
||||
global $config;
|
||||
|
||||
@ -125,10 +118,10 @@ class MainHandler extends request_handler {
|
||||
return [
|
||||
'title' => $pt->title,
|
||||
'link' => $post->getUrl(),
|
||||
'pub_date' => date(DATE_RSS, $post->ts),
|
||||
'pub_date' => date(DATE_RSS, $post->getTimestamp()),
|
||||
'description' => $pt->getDescriptionPreview(500)
|
||||
];
|
||||
}, posts::getList(0, 20, filter_by_lang: $lagn));
|
||||
}, is_admin() ? posts::getList(0, 20, filter_by_lang: $lang) : []);
|
||||
|
||||
$ctx = new SkinContext('\\skin\\rss');
|
||||
$body = $ctx->atom(
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once 'lib/stored_config.php';
|
||||
|
||||
const ADMIN_SESSION_TIMEOUT = 86400 * 14;
|
||||
const ADMIN_COOKIE_NAME = 'admin_key';
|
||||
const ADMIN_LOGIN_MAX_LENGTH = 32;
|
||||
|
@ -92,7 +92,7 @@ class Post extends model {
|
||||
return $buf;
|
||||
}
|
||||
|
||||
protected function getTimestamp(): int {
|
||||
public function getTimestamp(): int {
|
||||
return (new DateTime($this->date))->getTimestamp();
|
||||
}
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
function scGet(string $key) {
|
||||
$db = DB();
|
||||
$q = $db->query("SELECT value FROM config WHERE name=?", $key);
|
||||
if (!$db->numRows($q))
|
||||
return null;
|
||||
return $db->result($q);
|
||||
}
|
||||
|
||||
function scSet($key, $value) {
|
||||
$db = DB();
|
||||
return $db->query("REPLACE INTO config (name, value) VALUES (?, ?)", $key, $value);
|
||||
}
|
@ -314,7 +314,7 @@ HTML;
|
||||
|
||||
$js_params = json_encode(['pages' => true, 'edit' => $is_edit]);
|
||||
$js = <<<JS
|
||||
AdminWriteForm.init({$js_params});
|
||||
cur.form = new AdminWriteEditForm({$js_params});
|
||||
JS;
|
||||
|
||||
return [$html, $js];
|
||||
|
Loading…
x
Reference in New Issue
Block a user