Bug fixes on page break
This commit is contained in:
parent
20fca17d91
commit
f518909ce0
@ -69,7 +69,9 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
// Main
|
||||
// ============================================================================
|
||||
|
||||
if(!$dbPages->pageExists($layout['parameters'])) {
|
||||
if(!$dbPages->pageExists($layout['parameters']))
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$layout['parameters']);
|
||||
Redirect::page('admin', 'manage-pages');
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,9 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
// Main
|
||||
// ============================================================================
|
||||
|
||||
if(!$dbPosts->postExists($layout['parameters'])) {
|
||||
if(!$dbPosts->postExists($layout['parameters']))
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the post: '.$layout['parameters']);
|
||||
Redirect::page('admin', 'manage-posts');
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ if(!defined('JSON_PRETTY_PRINT')) {
|
||||
define('SALT_LENGTH', 8);
|
||||
|
||||
// Page brake string
|
||||
define('PAGE_BRAKE', '<!-- pagebreak -->');
|
||||
define('PAGE_BREAK', '<!-- pagebreak -->');
|
||||
|
||||
// Bludit version
|
||||
define('BLUDIT_VERSION', 'githubVersion');
|
||||
|
@ -64,8 +64,8 @@ function build_page($key)
|
||||
$Page->setField('contentRaw', $Page->content(), true);
|
||||
|
||||
// Parse markdown content.
|
||||
$content = Text::imgRel2Abs($contentRaw, HTML_PATH_UPLOADS); // Parse img src relative to absolute.
|
||||
$content = $Parsedown->text($content); // Parse Markdown.
|
||||
$content = $Parsedown->text($contentRaw); // Parse Markdown.
|
||||
$content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS); // Parse img src relative to absolute.
|
||||
$Page->setField('content', $content, true);
|
||||
|
||||
// Parse username for the page.
|
||||
|
@ -53,10 +53,15 @@ function buildPost($key)
|
||||
$Post->setField('contentRaw', $contentRaw, true);
|
||||
|
||||
// Parse the content
|
||||
$content = Text::imgRel2Abs($contentRaw, HTML_PATH_UPLOADS); // Parse img src relative to absolute.
|
||||
$content = $Parsedown->text($content); // Parse Markdown.
|
||||
$content = $Parsedown->text($contentRaw); // Parse Markdown.
|
||||
$content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS); // Parse img src relative to absolute.
|
||||
$Post->setField('content', $content, true);
|
||||
|
||||
// Pagebrake
|
||||
$explode = explode(PAGE_BREAK, $content);
|
||||
$Post->setField('breakContent', $explode[0], true);
|
||||
$Post->setField('readMore', !empty($explode[1]), true);
|
||||
|
||||
// Parse username for the post.
|
||||
if( $dbUsers->userExists( $Post->username() ) )
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ class Text {
|
||||
|
||||
public static function imgRel2Abs($string, $base)
|
||||
{
|
||||
return preg_replace("/(src)\=\"([^(http)])(\/)?/", "$1=\"$base$2", $string);
|
||||
return preg_replace('/(src)="([^:"]*)(?:")/', "$1=\"$base$2\"", $string);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,17 +20,11 @@ class Page extends fileContent
|
||||
// This content is markdown parser.
|
||||
// $fullContent, TRUE returns all content, if FALSE returns the first part of the content.
|
||||
// $html, TRUE returns the content without satinize, FALSE otherwise.
|
||||
public function content($fullContent=true, $html=true)
|
||||
public function content($html=true)
|
||||
{
|
||||
// This content is not sanitized.
|
||||
$content = $this->getField('content');
|
||||
|
||||
if(!$fullContent)
|
||||
{
|
||||
$explode = explode(PAGE_BRAKE, $content);
|
||||
$content = $explode[0];
|
||||
}
|
||||
|
||||
if($html) {
|
||||
return $content;
|
||||
}
|
||||
@ -42,17 +36,11 @@ class Page extends fileContent
|
||||
// This content is not markdown parser.
|
||||
// $fullContent, TRUE returns all content, if FALSE returns the first part of the content.
|
||||
// $html, TRUE returns the content without satinize, FALSE otherwise.
|
||||
public function contentRaw($fullContent=true, $html=true)
|
||||
public function contentRaw($html=true)
|
||||
{
|
||||
// This content is not sanitized.
|
||||
$content = $this->getField('contentRaw');
|
||||
|
||||
if(!$fullContent)
|
||||
{
|
||||
$explode = explode(PAGE_BRAKE, $content);
|
||||
$content = $explode[0];
|
||||
}
|
||||
|
||||
if($html) {
|
||||
return $content;
|
||||
}
|
||||
|
@ -27,8 +27,7 @@ class Post extends fileContent
|
||||
|
||||
if(!$fullContent)
|
||||
{
|
||||
$explode = explode(PAGE_BRAKE, $content);
|
||||
$content = $explode[0];
|
||||
$content = $this->getField('breakContent');
|
||||
}
|
||||
|
||||
if($html) {
|
||||
@ -38,21 +37,19 @@ class Post extends fileContent
|
||||
return Sanitize::html($content);
|
||||
}
|
||||
|
||||
public function readMore()
|
||||
{
|
||||
return $this->getField('readMore');
|
||||
}
|
||||
|
||||
// Returns the content.
|
||||
// This content is not markdown parser.
|
||||
// $fullContent, TRUE returns all content, if FALSE returns the first part of the content.
|
||||
// $html, TRUE returns the content without satinize, FALSE otherwise.
|
||||
public function contentRaw($fullContent=true, $html=true)
|
||||
public function contentRaw($html=true)
|
||||
{
|
||||
// This content is not sanitized.
|
||||
$content = $this->getField('contentRaw');
|
||||
|
||||
if(!$fullContent)
|
||||
{
|
||||
$explode = explode(PAGE_BRAKE, $content);
|
||||
$content = $explode[0];
|
||||
}
|
||||
|
||||
if($html) {
|
||||
return $content;
|
||||
}
|
||||
|
@ -15,10 +15,9 @@ class Url
|
||||
// Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character.
|
||||
$decode = urldecode($_SERVER['REQUEST_URI']);
|
||||
|
||||
// Parse, http://php.net/parse_url
|
||||
$parse = parse_url($decode);
|
||||
|
||||
$this->uri = $parse['path'];
|
||||
// remove parameters GET, do not use parse_url because has problem with utf-8.
|
||||
$explode = explode('?', $decode);
|
||||
$this->uri = $explode[0];
|
||||
|
||||
$this->parameters = $_GET;
|
||||
|
||||
|
@ -33,10 +33,15 @@
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
<?php echo $Post->content(false) // FALSE to get the first part of the post ?>
|
||||
<?php
|
||||
// FALSE to get the first part of the post
|
||||
echo $Post->content(false)
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if($Post->readMore()) { ?>
|
||||
<a class="read-more" href="<?php echo $Post->permalink() ?>"><?php $Language->printMe('Read more') ?></a>
|
||||
<?php } ?>
|
||||
|
||||
</section>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user