commit
c6496250dd
|
@ -29,11 +29,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Main after POST
|
// Main after POST
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
$allPublishedPages = buildAllpages(true);
|
$allPages = buildAllpages($publishedPages=true, $staticPages=true, $draftPages=false, $scheduledPages=false);
|
||||||
|
|
||||||
// Homepage select options
|
// Homepage select options
|
||||||
$homepageOptions = array(' '=>'- '.$L->g('Latest content').' -');
|
$homepageOptions = array(' '=>'- '.$L->g('Latest content').' -');
|
||||||
foreach($allPublishedPages as $key=>$page) {
|
foreach ($allPages as $key=>$page) {
|
||||||
$parentKey = $page->parentKey();
|
$parentKey = $page->parentKey();
|
||||||
if ($parentKey) {
|
if ($parentKey) {
|
||||||
$homepageOptions[$key] = $pagesByParentByKey[PARENT][$parentKey]->title() .'->'. $page->title();
|
$homepageOptions[$key] = $pagesByParentByKey[PARENT][$parentKey]->title() .'->'. $page->title();
|
||||||
|
|
|
@ -162,7 +162,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
|
|
||||||
// Parent input
|
// Parent input
|
||||||
// Check if the page has children
|
// Check if the page has children
|
||||||
if(count($page->children())==0) {
|
if (count($page->children())==0) {
|
||||||
$options = array(' '=>'- '.$L->g('No parent').' -');
|
$options = array(' '=>'- '.$L->g('No parent').' -');
|
||||||
$parentsList = $dbPages->getParents();
|
$parentsList = $dbPages->getParents();
|
||||||
$parentsKey = array_keys($parentsList);
|
$parentsKey = array_keys($parentsList);
|
||||||
|
@ -180,9 +180,9 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
'selected'=>$page->parentKey(),
|
'selected'=>$page->parentKey(),
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
));
|
));
|
||||||
}
|
|
||||||
|
|
||||||
echo '<hr>';
|
echo '<hr>';
|
||||||
|
}
|
||||||
|
|
||||||
// Position input
|
// Position input
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||||
|
|
||||||
// Bludit version
|
// Bludit version
|
||||||
define('BLUDIT_VERSION', '2.0');
|
define('BLUDIT_VERSION', '2.0.1');
|
||||||
define('BLUDIT_CODENAME', 'Morty');
|
define('BLUDIT_CODENAME', 'Morty');
|
||||||
define('BLUDIT_RELEASE_DATE', '2017-10-16');
|
define('BLUDIT_RELEASE_DATE', '2017-10-23');
|
||||||
define('BLUDIT_BUILD', '20171016');
|
define('BLUDIT_BUILD', '20171023');
|
||||||
|
|
||||||
// Debug mode
|
// Debug mode
|
||||||
// Change to FALSE, for prevent warning or errors on browser
|
// Change to FALSE, for prevent warning or errors on browser
|
||||||
|
@ -178,7 +178,6 @@ include(PATH_KERNEL.'user.class.php');
|
||||||
include(PATH_KERNEL.'url.class.php');
|
include(PATH_KERNEL.'url.class.php');
|
||||||
include(PATH_KERNEL.'login.class.php');
|
include(PATH_KERNEL.'login.class.php');
|
||||||
include(PATH_KERNEL.'parsedown.class.php');
|
include(PATH_KERNEL.'parsedown.class.php');
|
||||||
include(PATH_KERNEL.'parsedownextra.class.php');
|
|
||||||
include(PATH_KERNEL.'security.class.php');
|
include(PATH_KERNEL.'security.class.php');
|
||||||
|
|
||||||
// Include functions
|
// Include functions
|
||||||
|
|
|
@ -68,6 +68,16 @@ $pagesByParent = array(PARENT=>array());
|
||||||
*/
|
*/
|
||||||
$pagesByParentByKey = array(PARENT=>array());
|
$pagesByParentByKey = array(PARENT=>array());
|
||||||
|
|
||||||
|
// Array with static content, each item is a Page Object
|
||||||
|
// Order by position
|
||||||
|
/*
|
||||||
|
array(
|
||||||
|
0 => Page Object,
|
||||||
|
1 => Page Object,
|
||||||
|
...
|
||||||
|
N => Page Object
|
||||||
|
)
|
||||||
|
*/
|
||||||
$staticContent = $staticPages = buildStaticPages();
|
$staticContent = $staticPages = buildStaticPages();
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -90,7 +100,7 @@ if ($dbPages->scheduler()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate pages parent tree, only published pages
|
// Generate pages parent tree, only published pages
|
||||||
buildPagesByParent(true);
|
buildPagesByParent(true, true);
|
||||||
|
|
||||||
// Set home page is the user defined one
|
// Set home page is the user defined one
|
||||||
if ($Site->homepage() && $Url->whereAmI()==='home') {
|
if ($Site->homepage() && $Url->whereAmI()==='home') {
|
||||||
|
|
|
@ -16,15 +16,14 @@ include(PATH_RULES.'99.themes.php');
|
||||||
Theme::plugins('beforeSiteLoad');
|
Theme::plugins('beforeSiteLoad');
|
||||||
|
|
||||||
// Theme init.php
|
// Theme init.php
|
||||||
if( Sanitize::pathFile(PATH_THEMES, $Site->theme().DS.'init.php') ) {
|
if (Sanitize::pathFile(PATH_THEMES, $Site->theme().DS.'init.php')) {
|
||||||
include(PATH_THEMES.$Site->theme().DS.'init.php');
|
include(PATH_THEMES.$Site->theme().DS.'init.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Theme HTML
|
// Theme HTML
|
||||||
if( Sanitize::pathFile(PATH_THEMES, $Site->theme().DS.'index.php') ) {
|
if (Sanitize::pathFile(PATH_THEMES, $Site->theme().DS.'index.php')) {
|
||||||
include(PATH_THEMES.$Site->theme().DS.'index.php');
|
include(PATH_THEMES.$Site->theme().DS.'index.php');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$Language->p('Please check your theme configuration');
|
$Language->p('Please check your theme configuration');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ class dbPages extends dbJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a database with published pages
|
// Returns a database with published pages
|
||||||
public function getPublishedDB()
|
public function getPublishedDB($onlyKeys=false)
|
||||||
{
|
{
|
||||||
$tmp = $this->db;
|
$tmp = $this->db;
|
||||||
foreach ($tmp as $key=>$fields) {
|
foreach ($tmp as $key=>$fields) {
|
||||||
|
@ -272,6 +272,9 @@ class dbPages extends dbJSON
|
||||||
unset($tmp[$key]);
|
unset($tmp[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($onlyKeys) {
|
||||||
|
return array_keys($tmp);
|
||||||
|
}
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +296,7 @@ class dbPages extends dbJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an array with a list of keys/database of draft pages
|
// Returns an array with a list of keys/database of draft pages
|
||||||
public function getDraftDB()
|
public function getDraftDB($onlyKeys=false)
|
||||||
{
|
{
|
||||||
$tmp = $this->db;
|
$tmp = $this->db;
|
||||||
foreach ($tmp as $key=>$fields) {
|
foreach ($tmp as $key=>$fields) {
|
||||||
|
@ -301,11 +304,14 @@ class dbPages extends dbJSON
|
||||||
unset($tmp[$key]);
|
unset($tmp[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($onlyKeys) {
|
||||||
|
return array_keys($tmp);
|
||||||
|
}
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an array with a list of keys/database of scheduled pages
|
// Returns an array with a list of keys/database of scheduled pages
|
||||||
public function getScheduledDB()
|
public function getScheduledDB($onlyKeys=false)
|
||||||
{
|
{
|
||||||
$tmp = $this->db;
|
$tmp = $this->db;
|
||||||
foreach($tmp as $key=>$fields) {
|
foreach($tmp as $key=>$fields) {
|
||||||
|
@ -313,6 +319,9 @@ class dbPages extends dbJSON
|
||||||
unset($tmp[$key]);
|
unset($tmp[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($onlyKeys) {
|
||||||
|
return array_keys($tmp);
|
||||||
|
}
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,28 +168,30 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
|
||||||
|
|
||||||
// Generate the global variable $pagesByParent, defined on 69.pages.php
|
// Generate the global variable $pagesByParent, defined on 69.pages.php
|
||||||
// (boolean) $allPages, TRUE include all status, FALSE only include published status
|
// (boolean) $allPages, TRUE include all status, FALSE only include published status
|
||||||
function buildPagesByParent($onlyPublished=true) {
|
function buildPagesByParent($publishedPages=true, $staticPages=true) {
|
||||||
global $dbPages;
|
global $dbPages;
|
||||||
global $pagesByParent;
|
global $pagesByParent;
|
||||||
global $pagesByParentByKey;
|
global $pagesByParentByKey;
|
||||||
|
|
||||||
// Get DB
|
$onlyKeys = true;
|
||||||
$pageNumber = 1;
|
$keys = array();
|
||||||
$amountOfItems = -1;
|
if ($publishedPages) {
|
||||||
$db = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
$keys = array_merge($keys, $dbPages->getPublishedDB($onlyKeys));
|
||||||
|
}
|
||||||
|
if ($staticPages) {
|
||||||
|
$keys = array_merge($keys, $dbPages->getStaticDB($onlyKeys));
|
||||||
|
}
|
||||||
|
|
||||||
// Get Keys
|
foreach ($keys as $pageKey) {
|
||||||
$keys = array_keys($db);
|
|
||||||
foreach($keys as $pageKey) {
|
|
||||||
$page = buildPage($pageKey);
|
$page = buildPage($pageKey);
|
||||||
if($page!==false) {
|
if ($page!==false) {
|
||||||
$parentKey = $page->parentKey();
|
$parentKey = $page->parentKey();
|
||||||
// FALSE if the page is parent
|
// FALSE if the page is parent
|
||||||
if($parentKey===false) {
|
if ($parentKey===false) {
|
||||||
array_push($pagesByParent[PARENT], $page);
|
array_push($pagesByParent[PARENT], $page);
|
||||||
$pagesByParentByKey[PARENT][$page->key()] = $page;
|
$pagesByParentByKey[PARENT][$page->key()] = $page;
|
||||||
} else {
|
} else {
|
||||||
if( !isset($pagesByParent[$parentKey]) ) {
|
if (!isset($pagesByParent[$parentKey])) {
|
||||||
$pagesByParent[$parentKey] = array();
|
$pagesByParent[$parentKey] = array();
|
||||||
}
|
}
|
||||||
array_push($pagesByParent[$parentKey], $page);
|
array_push($pagesByParent[$parentKey], $page);
|
||||||
|
@ -221,19 +223,29 @@ function buildStaticPages() {
|
||||||
pageKeyN => Page object,
|
pageKeyN => Page object,
|
||||||
)
|
)
|
||||||
*/
|
*/
|
||||||
function buildAllpages($onlyPublished=true) {
|
function buildAllpages($publishedPages=true, $staticPages=true, $draftPages=true, $scheduledPages=true) {
|
||||||
global $dbPages;
|
global $dbPages;
|
||||||
|
|
||||||
// Get DB
|
// Get DB
|
||||||
$pageNumber = 1;
|
$onlyKeys = true;
|
||||||
$amountOfItems = -1;
|
$keys = array();
|
||||||
$db = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
if ($publishedPages) {
|
||||||
|
$keys = array_merge($keys, $dbPages->getPublishedDB($onlyKeys));
|
||||||
|
}
|
||||||
|
if ($staticPages) {
|
||||||
|
$keys = array_merge($keys, $dbPages->getStaticDB($onlyKeys));
|
||||||
|
}
|
||||||
|
if ($draftPages) {
|
||||||
|
$keys = array_merge($keys, $dbPages->getDraftDB($onlyKeys));
|
||||||
|
}
|
||||||
|
if ($scheduledPages) {
|
||||||
|
$keys = array_merge($keys, $dbPages->getScheduledDB($onlyKeys));
|
||||||
|
}
|
||||||
|
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
$keys = array_keys($db);
|
foreach ($keys as $pageKey) {
|
||||||
foreach($keys as $pageKey) {
|
|
||||||
$page = buildPage($pageKey);
|
$page = buildPage($pageKey);
|
||||||
if($page!==false) {
|
if ($page!==false) {
|
||||||
$tmp[$page->key()] = $page;
|
$tmp[$page->key()] = $page;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ class DOM {
|
||||||
|
|
||||||
public static function getFirstImage($content)
|
public static function getFirstImage($content)
|
||||||
{
|
{
|
||||||
|
// Disable warning
|
||||||
|
libxml_use_internal_errors(true);
|
||||||
$dom = new DOMDocument();
|
$dom = new DOMDocument();
|
||||||
$dom->loadHTML('<meta http-equiv="content-type" content="text/html; charset=utf-8">'.$content);
|
$dom->loadHTML('<meta http-equiv="content-type" content="text/html; charset=utf-8">'.$content);
|
||||||
$finder = new DomXPath($dom);
|
$finder = new DomXPath($dom);
|
||||||
|
|
|
@ -1,526 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Parsedown Extra
|
|
||||||
# https://github.com/erusev/parsedown-extra
|
|
||||||
#
|
|
||||||
# (c) Emanuil Rusev
|
|
||||||
# http://erusev.com
|
|
||||||
#
|
|
||||||
# For the full license information, view the LICENSE file that was distributed
|
|
||||||
# with this source code.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
class ParsedownExtra extends Parsedown
|
|
||||||
{
|
|
||||||
# ~
|
|
||||||
|
|
||||||
const version = '0.7.0';
|
|
||||||
|
|
||||||
# ~
|
|
||||||
|
|
||||||
function __construct()
|
|
||||||
{
|
|
||||||
if (parent::version < '1.5.0')
|
|
||||||
{
|
|
||||||
throw new Exception('ParsedownExtra requires a later version of Parsedown');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->BlockTypes[':'] []= 'DefinitionList';
|
|
||||||
$this->BlockTypes['*'] []= 'Abbreviation';
|
|
||||||
|
|
||||||
# identify footnote definitions before reference definitions
|
|
||||||
array_unshift($this->BlockTypes['['], 'Footnote');
|
|
||||||
|
|
||||||
# identify footnote markers before before links
|
|
||||||
array_unshift($this->InlineTypes['['], 'FootnoteMarker');
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# ~
|
|
||||||
|
|
||||||
function text($text)
|
|
||||||
{
|
|
||||||
$markup = parent::text($text);
|
|
||||||
|
|
||||||
# merge consecutive dl elements
|
|
||||||
|
|
||||||
$markup = preg_replace('/<\/dl>\s+<dl>\s+/', '', $markup);
|
|
||||||
|
|
||||||
# add footnotes
|
|
||||||
|
|
||||||
if (isset($this->DefinitionData['Footnote']))
|
|
||||||
{
|
|
||||||
$Element = $this->buildFootnoteElement();
|
|
||||||
|
|
||||||
$markup .= "\n" . $this->element($Element);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $markup;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Blocks
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# Abbreviation
|
|
||||||
|
|
||||||
protected function blockAbbreviation($Line)
|
|
||||||
{
|
|
||||||
if (preg_match('/^\*\[(.+?)\]:[ ]*(.+?)[ ]*$/', $Line['text'], $matches))
|
|
||||||
{
|
|
||||||
$this->DefinitionData['Abbreviation'][$matches[1]] = $matches[2];
|
|
||||||
|
|
||||||
$Block = array(
|
|
||||||
'hidden' => true,
|
|
||||||
);
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Footnote
|
|
||||||
|
|
||||||
protected function blockFootnote($Line)
|
|
||||||
{
|
|
||||||
if (preg_match('/^\[\^(.+?)\]:[ ]?(.*)$/', $Line['text'], $matches))
|
|
||||||
{
|
|
||||||
$Block = array(
|
|
||||||
'label' => $matches[1],
|
|
||||||
'text' => $matches[2],
|
|
||||||
'hidden' => true,
|
|
||||||
);
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function blockFootnoteContinue($Line, $Block)
|
|
||||||
{
|
|
||||||
if ($Line['text'][0] === '[' and preg_match('/^\[\^(.+?)\]:/', $Line['text']))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($Block['interrupted']))
|
|
||||||
{
|
|
||||||
if ($Line['indent'] >= 4)
|
|
||||||
{
|
|
||||||
$Block['text'] .= "\n\n" . $Line['text'];
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$Block['text'] .= "\n" . $Line['text'];
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function blockFootnoteComplete($Block)
|
|
||||||
{
|
|
||||||
$this->DefinitionData['Footnote'][$Block['label']] = array(
|
|
||||||
'text' => $Block['text'],
|
|
||||||
'count' => null,
|
|
||||||
'number' => null,
|
|
||||||
);
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Definition List
|
|
||||||
|
|
||||||
protected function blockDefinitionList($Line, $Block)
|
|
||||||
{
|
|
||||||
if ( ! isset($Block) or isset($Block['type']))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$Element = array(
|
|
||||||
'name' => 'dl',
|
|
||||||
'handler' => 'elements',
|
|
||||||
'text' => array(),
|
|
||||||
);
|
|
||||||
|
|
||||||
$terms = explode("\n", $Block['element']['text']);
|
|
||||||
|
|
||||||
foreach ($terms as $term)
|
|
||||||
{
|
|
||||||
$Element['text'] []= array(
|
|
||||||
'name' => 'dt',
|
|
||||||
'handler' => 'line',
|
|
||||||
'text' => $term,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$Block['element'] = $Element;
|
|
||||||
|
|
||||||
$Block = $this->addDdElement($Line, $Block);
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function blockDefinitionListContinue($Line, array $Block)
|
|
||||||
{
|
|
||||||
if ($Line['text'][0] === ':')
|
|
||||||
{
|
|
||||||
$Block = $this->addDdElement($Line, $Block);
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isset($Block['interrupted']) and $Line['indent'] === 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($Block['interrupted']))
|
|
||||||
{
|
|
||||||
$Block['dd']['handler'] = 'text';
|
|
||||||
$Block['dd']['text'] .= "\n\n";
|
|
||||||
|
|
||||||
unset($Block['interrupted']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$text = substr($Line['body'], min($Line['indent'], 4));
|
|
||||||
|
|
||||||
$Block['dd']['text'] .= "\n" . $text;
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Header
|
|
||||||
|
|
||||||
protected function blockHeader($Line)
|
|
||||||
{
|
|
||||||
$Block = parent::blockHeader($Line);
|
|
||||||
|
|
||||||
if (preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
|
|
||||||
{
|
|
||||||
$attributeString = $matches[1][0];
|
|
||||||
|
|
||||||
$Block['element']['attributes'] = $this->parseAttributeData($attributeString);
|
|
||||||
|
|
||||||
$Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Markup
|
|
||||||
|
|
||||||
protected function blockMarkupComplete($Block)
|
|
||||||
{
|
|
||||||
if ( ! isset($Block['void']))
|
|
||||||
{
|
|
||||||
$Block['markup'] = $this->processTag($Block['markup']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Setext
|
|
||||||
|
|
||||||
protected function blockSetextHeader($Line, array $Block = null)
|
|
||||||
{
|
|
||||||
$Block = parent::blockSetextHeader($Line, $Block);
|
|
||||||
|
|
||||||
if (preg_match('/[ ]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
|
|
||||||
{
|
|
||||||
$attributeString = $matches[1][0];
|
|
||||||
|
|
||||||
$Block['element']['attributes'] = $this->parseAttributeData($attributeString);
|
|
||||||
|
|
||||||
$Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Inline Elements
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# Footnote Marker
|
|
||||||
|
|
||||||
protected function inlineFootnoteMarker($Excerpt)
|
|
||||||
{
|
|
||||||
if (preg_match('/^\[\^(.+?)\]/', $Excerpt['text'], $matches))
|
|
||||||
{
|
|
||||||
$name = $matches[1];
|
|
||||||
|
|
||||||
if ( ! isset($this->DefinitionData['Footnote'][$name]))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->DefinitionData['Footnote'][$name]['count'] ++;
|
|
||||||
|
|
||||||
if ( ! isset($this->DefinitionData['Footnote'][$name]['number']))
|
|
||||||
{
|
|
||||||
$this->DefinitionData['Footnote'][$name]['number'] = ++ $this->footnoteCount; # » &
|
|
||||||
}
|
|
||||||
|
|
||||||
$Element = array(
|
|
||||||
'name' => 'sup',
|
|
||||||
'attributes' => array('id' => 'fnref'.$this->DefinitionData['Footnote'][$name]['count'].':'.$name),
|
|
||||||
'handler' => 'element',
|
|
||||||
'text' => array(
|
|
||||||
'name' => 'a',
|
|
||||||
'attributes' => array('href' => '#fn:'.$name, 'class' => 'footnote-ref'),
|
|
||||||
'text' => $this->DefinitionData['Footnote'][$name]['number'],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'extent' => strlen($matches[0]),
|
|
||||||
'element' => $Element,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private $footnoteCount = 0;
|
|
||||||
|
|
||||||
#
|
|
||||||
# Link
|
|
||||||
|
|
||||||
protected function inlineLink($Excerpt)
|
|
||||||
{
|
|
||||||
$Link = parent::inlineLink($Excerpt);
|
|
||||||
|
|
||||||
$remainder = substr($Excerpt['text'], $Link['extent']);
|
|
||||||
|
|
||||||
if (preg_match('/^[ ]*{('.$this->regexAttribute.'+)}/', $remainder, $matches))
|
|
||||||
{
|
|
||||||
$Link['element']['attributes'] += $this->parseAttributeData($matches[1]);
|
|
||||||
|
|
||||||
$Link['extent'] += strlen($matches[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $Link;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# ~
|
|
||||||
#
|
|
||||||
|
|
||||||
protected function unmarkedText($text)
|
|
||||||
{
|
|
||||||
$text = parent::unmarkedText($text);
|
|
||||||
|
|
||||||
if (isset($this->DefinitionData['Abbreviation']))
|
|
||||||
{
|
|
||||||
foreach ($this->DefinitionData['Abbreviation'] as $abbreviation => $meaning)
|
|
||||||
{
|
|
||||||
$pattern = '/\b'.preg_quote($abbreviation, '/').'\b/';
|
|
||||||
|
|
||||||
$text = preg_replace($pattern, '<abbr title="'.$meaning.'">'.$abbreviation.'</abbr>', $text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Util Methods
|
|
||||||
#
|
|
||||||
|
|
||||||
protected function addDdElement(array $Line, array $Block)
|
|
||||||
{
|
|
||||||
$text = substr($Line['text'], 1);
|
|
||||||
$text = trim($text);
|
|
||||||
|
|
||||||
unset($Block['dd']);
|
|
||||||
|
|
||||||
$Block['dd'] = array(
|
|
||||||
'name' => 'dd',
|
|
||||||
'handler' => 'line',
|
|
||||||
'text' => $text,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isset($Block['interrupted']))
|
|
||||||
{
|
|
||||||
$Block['dd']['handler'] = 'text';
|
|
||||||
|
|
||||||
unset($Block['interrupted']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$Block['element']['text'] []= & $Block['dd'];
|
|
||||||
|
|
||||||
return $Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function buildFootnoteElement()
|
|
||||||
{
|
|
||||||
$Element = array(
|
|
||||||
'name' => 'div',
|
|
||||||
'attributes' => array('class' => 'footnotes'),
|
|
||||||
'handler' => 'elements',
|
|
||||||
'text' => array(
|
|
||||||
array(
|
|
||||||
'name' => 'hr',
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'name' => 'ol',
|
|
||||||
'handler' => 'elements',
|
|
||||||
'text' => array(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
uasort($this->DefinitionData['Footnote'], 'self::sortFootnotes');
|
|
||||||
|
|
||||||
foreach ($this->DefinitionData['Footnote'] as $definitionId => $DefinitionData)
|
|
||||||
{
|
|
||||||
if ( ! isset($DefinitionData['number']))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$text = $DefinitionData['text'];
|
|
||||||
|
|
||||||
$text = parent::text($text);
|
|
||||||
|
|
||||||
$numbers = range(1, $DefinitionData['count']);
|
|
||||||
|
|
||||||
$backLinksMarkup = '';
|
|
||||||
|
|
||||||
foreach ($numbers as $number)
|
|
||||||
{
|
|
||||||
$backLinksMarkup .= ' <a href="#fnref'.$number.':'.$definitionId.'" rev="footnote" class="footnote-backref">↩</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$backLinksMarkup = substr($backLinksMarkup, 1);
|
|
||||||
|
|
||||||
if (substr($text, - 4) === '</p>')
|
|
||||||
{
|
|
||||||
$backLinksMarkup = ' '.$backLinksMarkup;
|
|
||||||
|
|
||||||
$text = substr_replace($text, $backLinksMarkup.'</p>', - 4);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$text .= "\n".'<p>'.$backLinksMarkup.'</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$Element['text'][1]['text'] []= array(
|
|
||||||
'name' => 'li',
|
|
||||||
'attributes' => array('id' => 'fn:'.$definitionId),
|
|
||||||
'text' => "\n".$text."\n",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $Element;
|
|
||||||
}
|
|
||||||
|
|
||||||
# ~
|
|
||||||
|
|
||||||
protected function parseAttributeData($attributeString)
|
|
||||||
{
|
|
||||||
$Data = array();
|
|
||||||
|
|
||||||
$attributes = preg_split('/[ ]+/', $attributeString, - 1, PREG_SPLIT_NO_EMPTY);
|
|
||||||
|
|
||||||
foreach ($attributes as $attribute)
|
|
||||||
{
|
|
||||||
if ($attribute[0] === '#')
|
|
||||||
{
|
|
||||||
$Data['id'] = substr($attribute, 1);
|
|
||||||
}
|
|
||||||
else # "."
|
|
||||||
{
|
|
||||||
$classes []= substr($attribute, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($classes))
|
|
||||||
{
|
|
||||||
$Data['class'] = implode(' ', $classes);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $Data;
|
|
||||||
}
|
|
||||||
|
|
||||||
# ~
|
|
||||||
|
|
||||||
protected function processTag($elementMarkup) # recursive
|
|
||||||
{
|
|
||||||
# http://stackoverflow.com/q/1148928/200145
|
|
||||||
libxml_use_internal_errors(true);
|
|
||||||
|
|
||||||
$DOMDocument = new DOMDocument;
|
|
||||||
|
|
||||||
# http://stackoverflow.com/q/11309194/200145
|
|
||||||
$elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8');
|
|
||||||
|
|
||||||
# http://stackoverflow.com/q/4879946/200145
|
|
||||||
$DOMDocument->loadHTML($elementMarkup);
|
|
||||||
$DOMDocument->removeChild($DOMDocument->doctype);
|
|
||||||
$DOMDocument->replaceChild($DOMDocument->firstChild->firstChild->firstChild, $DOMDocument->firstChild);
|
|
||||||
|
|
||||||
$elementText = '';
|
|
||||||
|
|
||||||
if ($DOMDocument->documentElement->getAttribute('markdown') === '1')
|
|
||||||
{
|
|
||||||
foreach ($DOMDocument->documentElement->childNodes as $Node)
|
|
||||||
{
|
|
||||||
$elementText .= $DOMDocument->saveHTML($Node);
|
|
||||||
}
|
|
||||||
|
|
||||||
$DOMDocument->documentElement->removeAttribute('markdown');
|
|
||||||
|
|
||||||
$elementText = "\n".$this->text($elementText)."\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach ($DOMDocument->documentElement->childNodes as $Node)
|
|
||||||
{
|
|
||||||
$nodeMarkup = $DOMDocument->saveHTML($Node);
|
|
||||||
|
|
||||||
if ($Node instanceof DOMElement and ! in_array($Node->nodeName, $this->textLevelElements))
|
|
||||||
{
|
|
||||||
$elementText .= $this->processTag($nodeMarkup);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$elementText .= $nodeMarkup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# because we don't want for markup to get encoded
|
|
||||||
$DOMDocument->documentElement->nodeValue = 'placeholder\x1A';
|
|
||||||
|
|
||||||
$markup = $DOMDocument->saveHTML($DOMDocument->documentElement);
|
|
||||||
$markup = str_replace('placeholder\x1A', $elementText, $markup);
|
|
||||||
|
|
||||||
return $markup;
|
|
||||||
}
|
|
||||||
|
|
||||||
# ~
|
|
||||||
|
|
||||||
protected function sortFootnotes($A, $B) # callback
|
|
||||||
{
|
|
||||||
return $A['number'] - $B['number'];
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Fields
|
|
||||||
#
|
|
||||||
|
|
||||||
protected $regexAttribute = '(?:[#.][-\w]+[ ]*)';
|
|
||||||
}
|
|
|
@ -60,6 +60,20 @@ class pluginGoogle extends Plugin {
|
||||||
$html .= "<!-- End Google Tag Manager -->".PHP_EOL;
|
$html .= "<!-- End Google Tag Manager -->".PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Google Analytics
|
||||||
|
if ($this->getValue('google-analytics-tracking-id')) {
|
||||||
|
$html = PHP_EOL.'<!-- Google Analytics -->'.PHP_EOL;
|
||||||
|
$html .= '
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id='.$this->getValue('google-analytics-tracking-id').'"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag("js", new Date());
|
||||||
|
|
||||||
|
gtag("config", "'.$this->getValue('google-analytics-tracking-id').'");
|
||||||
|
</script>'.PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,22 +89,4 @@ class pluginGoogle extends Plugin {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function siteBodyEnd()
|
|
||||||
{
|
|
||||||
// Google Analytics
|
|
||||||
if ($this->getValue('google-analytics-tracking-id')) {
|
|
||||||
$html = PHP_EOL.'<!-- Google Analytics -->'.PHP_EOL;
|
|
||||||
$html .= '
|
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id='.$this->getValue('google-analytics-tracking-id').'"></script>
|
|
||||||
<script>
|
|
||||||
window.dataLayer = window.dataLayer || [];
|
|
||||||
function gtag(){dataLayer.push(arguments);}
|
|
||||||
gtag("js", new Date());
|
|
||||||
|
|
||||||
gtag("config", "'.$this->getValue('google-analytics-tracking-id').'");
|
|
||||||
</script>'.PHP_EOL;
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -26,8 +26,8 @@ class pluginLatestContent extends Plugin {
|
||||||
$html .= '<div>';
|
$html .= '<div>';
|
||||||
$html .= '<label>'.$Language->get('Home link').'</label>';
|
$html .= '<label>'.$Language->get('Home link').'</label>';
|
||||||
$html .= '<select name="homeLink">';
|
$html .= '<select name="homeLink">';
|
||||||
$html .= '<option value="true" '.($this->getValue('showCero')?'checked':'').'>'.$Language->get('Enabled').'</option>';
|
$html .= '<option value="true" '.($this->getValue('homeLink')===true?'selected':'').'>'.$Language->get('Enabled').'</option>';
|
||||||
$html .= '<option value="false" '.($this->getValue('showCero')?'checked':'').'>'.$Language->get('Disabled').'</option>';
|
$html .= '<option value="false" '.($this->getValue('homeLink')===false?'selected':'').'>'.$Language->get('Disabled').'</option>';
|
||||||
$html .= '</select>';
|
$html .= '</select>';
|
||||||
$html .= '<span class="tip">'.$Language->get('Show the home link on the sidebar').'</span>';
|
$html .= '<span class="tip">'.$Language->get('Show the home link on the sidebar').'</span>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
|
@ -89,7 +89,7 @@ class pluginOpenGraph extends Plugin {
|
||||||
// If the page doesn't have a coverImage try to get an image from the HTML content
|
// If the page doesn't have a coverImage try to get an image from the HTML content
|
||||||
if (empty($og['image'])) {
|
if (empty($og['image'])) {
|
||||||
// Get the image from the content
|
// Get the image from the content
|
||||||
$src = $this->getImage($content);
|
$src = DOM::getFirstImage($content);
|
||||||
if ($src!==false) {
|
if ($src!==false) {
|
||||||
$og['image'] = $src;
|
$og['image'] = $src;
|
||||||
} else {
|
} else {
|
||||||
|
@ -103,24 +103,4 @@ class pluginOpenGraph extends Plugin {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the first image from the HTML content
|
|
||||||
private function getImage($content)
|
|
||||||
{
|
|
||||||
$dom = new DOMDocument();
|
|
||||||
$dom->loadHTML('<meta http-equiv="content-type" content="text/html; charset=utf-8">'.$content);
|
|
||||||
$finder = new DomXPath($dom);
|
|
||||||
|
|
||||||
$images = $finder->query("//img");
|
|
||||||
|
|
||||||
if($images->length>0) {
|
|
||||||
// First image from the list
|
|
||||||
$image = $images->item(0);
|
|
||||||
// Get value from attribute src
|
|
||||||
$imgSrc = $image->getAttribute('src');
|
|
||||||
// Returns the image src
|
|
||||||
return $imgSrc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -83,7 +83,7 @@ class pluginTwitterCards extends Plugin {
|
||||||
// If the page doesn't have a coverImage try to get an image from the HTML content
|
// If the page doesn't have a coverImage try to get an image from the HTML content
|
||||||
if( empty($data['image']) ) {
|
if( empty($data['image']) ) {
|
||||||
// Get the image from the content
|
// Get the image from the content
|
||||||
$src = $this->getImage($content);
|
$src = DOM::getFirstImage($content);
|
||||||
if ($src!==false) {
|
if ($src!==false) {
|
||||||
$data['image'] = $src;
|
$data['image'] = $src;
|
||||||
} else {
|
} else {
|
||||||
|
@ -96,25 +96,4 @@ class pluginTwitterCards extends Plugin {
|
||||||
$html .= '<meta property="twitter:image" content="'.$data['image'].'">'.PHP_EOL;
|
$html .= '<meta property="twitter:image" content="'.$data['image'].'">'.PHP_EOL;
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the first image from the HTML content
|
|
||||||
private function getImage($content)
|
|
||||||
{
|
|
||||||
$dom = new DOMDocument();
|
|
||||||
$dom->loadHTML('<meta http-equiv="content-type" content="text/html; charset=utf-8">'.$content);
|
|
||||||
$finder = new DomXPath($dom);
|
|
||||||
|
|
||||||
$images = $finder->query("//img");
|
|
||||||
|
|
||||||
if($images->length>0) {
|
|
||||||
// First image from the list
|
|
||||||
$image = $images->item(0);
|
|
||||||
// Get value from attribute src
|
|
||||||
$imgSrc = $image->getAttribute('src');
|
|
||||||
// Returns the image src
|
|
||||||
return $imgSrc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -39,7 +39,7 @@
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<?php
|
<?php
|
||||||
if(Paginator::showPrev()) {
|
if(Paginator::showPrev()) {
|
||||||
echo '<a class="btn btn-secondary float-left" href="'.Paginator::prevPageUrl().'">← '.$Language->get('Previuos page').'</a>';
|
echo '<a class="btn btn-secondary float-left" href="'.Paginator::prevPageUrl().'">← '.$Language->get('Previous page').'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Paginator::showNext()) {
|
if(Paginator::showNext()) {
|
||||||
|
|
|
@ -57,6 +57,16 @@ article.page footer {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* PAGINATION */
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination > li > a.float-right {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
/* PLUGINS */
|
/* PLUGINS */
|
||||||
|
|
||||||
div.plugin:not(:last-child) {
|
div.plugin:not(:last-child) {
|
||||||
|
|
|
@ -26,3 +26,15 @@
|
||||||
</article>
|
</article>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- Pagination -->
|
||||||
|
<ul class="pagination">
|
||||||
|
<?php
|
||||||
|
if (Paginator::showPrev()) {
|
||||||
|
echo '<li><a href="'.Paginator::prevPageUrl().'">'.$L->get('Previous page').'</a></li>';
|
||||||
|
}
|
||||||
|
if (Paginator::showNext()) {
|
||||||
|
echo '<li><a href="'.Paginator::nextPageUrl().'" class="float-right">'.$L->get('Next page').'</a></li>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
|
|
|
@ -25,11 +25,11 @@
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
<?php
|
<?php
|
||||||
if (Paginator::showPrev()) {
|
if (Paginator::showPrev()) {
|
||||||
echo '<li><a href="'.Paginator::prevPageUrl().'">'.$L->get('Next').'</a></li>';
|
echo '<li><a href="'.Paginator::prevPageUrl().'">'.$L->get('Previous page').'</a></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Paginator::showNext()) {
|
if (Paginator::showNext()) {
|
||||||
echo '<li><a href="'.Paginator::nextPageUrl().'">'.$L->get('Previuos').'</a></li>';
|
echo '<li><a href="'.Paginator::nextPageUrl().'">'.$L->get('Next page').'</a></li>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
|
@ -8,8 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Check if Bludit is installed
|
// Check if Bludit is installed
|
||||||
if( !file_exists('bl-content/databases/site.php') )
|
if (!file_exists('bl-content/databases/site.php')) {
|
||||||
{
|
|
||||||
header('Location:./install.php');
|
header('Location:./install.php');
|
||||||
exit('<a href="./install.php">Install Bludit first.</a>');
|
exit('<a href="./install.php">Install Bludit first.</a>');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue