commit
83747f5550
|
@ -3,3 +3,4 @@ bl-content/*
|
|||
bl-plugins/timemachine
|
||||
bl-plugins/remote-content
|
||||
bl-kernel/bludit.pro.php
|
||||
bl-themes/docs
|
||||
|
|
|
@ -29,11 +29,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
||||
$allPublishedPages = buildAllpages(true);
|
||||
$allPages = buildAllpages($publishedPages=true, $staticPages=true, $draftPages=false, $scheduledPages=false);
|
||||
|
||||
// Homepage select options
|
||||
$homepageOptions = array(' '=>'- '.$L->g('Latest content').' -');
|
||||
foreach($allPublishedPages as $key=>$page) {
|
||||
foreach ($allPages as $key=>$page) {
|
||||
$parentKey = $page->parentKey();
|
||||
if ($parentKey) {
|
||||
$homepageOptions[$key] = $pagesByParentByKey[PARENT][$parentKey]->title() .'->'. $page->title();
|
||||
|
|
|
@ -162,7 +162,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
|||
|
||||
// Parent input
|
||||
// Check if the page has children
|
||||
if(count($page->children())==0) {
|
||||
if (count($page->children())==0) {
|
||||
$options = array(' '=>'- '.$L->g('No parent').' -');
|
||||
$parentsList = $dbPages->getParents();
|
||||
$parentsKey = array_keys($parentsList);
|
||||
|
@ -180,9 +180,9 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
|||
'selected'=>$page->parentKey(),
|
||||
'tip'=>''
|
||||
));
|
||||
}
|
||||
|
||||
echo '<hr>';
|
||||
}
|
||||
|
||||
// Position input
|
||||
HTML::formInputText(array(
|
||||
|
|
|
@ -178,7 +178,6 @@ include(PATH_KERNEL.'user.class.php');
|
|||
include(PATH_KERNEL.'url.class.php');
|
||||
include(PATH_KERNEL.'login.class.php');
|
||||
include(PATH_KERNEL.'parsedown.class.php');
|
||||
include(PATH_KERNEL.'parsedownextra.class.php');
|
||||
include(PATH_KERNEL.'security.class.php');
|
||||
|
||||
// Include functions
|
||||
|
|
|
@ -68,6 +68,16 @@ $pagesByParent = 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();
|
||||
|
||||
// ============================================================================
|
||||
|
@ -90,7 +100,7 @@ if ($dbPages->scheduler()) {
|
|||
}
|
||||
|
||||
// Generate pages parent tree, only published pages
|
||||
buildPagesByParent(true);
|
||||
buildPagesByParent(true, true);
|
||||
|
||||
// Set home page is the user defined one
|
||||
if ($Site->homepage() && $Url->whereAmI()==='home') {
|
||||
|
|
|
@ -16,15 +16,14 @@ include(PATH_RULES.'99.themes.php');
|
|||
Theme::plugins('beforeSiteLoad');
|
||||
|
||||
// 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');
|
||||
}
|
||||
|
||||
// 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');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$Language->p('Please check your theme configuration');
|
||||
}
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ class dbPages extends dbJSON
|
|||
}
|
||||
|
||||
// Returns a database with published pages
|
||||
public function getPublishedDB()
|
||||
public function getPublishedDB($onlyKeys=false)
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach ($tmp as $key=>$fields) {
|
||||
|
@ -272,6 +272,9 @@ class dbPages extends dbJSON
|
|||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
if ($onlyKeys) {
|
||||
return array_keys($tmp);
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
|
@ -293,7 +296,7 @@ class dbPages extends dbJSON
|
|||
}
|
||||
|
||||
// Returns an array with a list of keys/database of draft pages
|
||||
public function getDraftDB()
|
||||
public function getDraftDB($onlyKeys=false)
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach ($tmp as $key=>$fields) {
|
||||
|
@ -301,11 +304,14 @@ class dbPages extends dbJSON
|
|||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
if ($onlyKeys) {
|
||||
return array_keys($tmp);
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// Returns an array with a list of keys/database of scheduled pages
|
||||
public function getScheduledDB()
|
||||
public function getScheduledDB($onlyKeys=false)
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach($tmp as $key=>$fields) {
|
||||
|
@ -313,6 +319,9 @@ class dbPages extends dbJSON
|
|||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
if ($onlyKeys) {
|
||||
return array_keys($tmp);
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
|
@ -386,10 +395,10 @@ class dbPages extends dbJSON
|
|||
// Returns an array with all parents pages key, a parent page is not a child
|
||||
public function getParents()
|
||||
{
|
||||
$db = $this->getPublishedDB();
|
||||
foreach($db as $key=>$fields) {
|
||||
$db = $this->getPublishedDB() + $this->getStaticDB();
|
||||
foreach ($db as $key=>$fields) {
|
||||
// if the key has slash then is a child
|
||||
if( Text::stringContains($key, '/') ) {
|
||||
if (Text::stringContains($key, '/')) {
|
||||
unset($db[$key]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,28 +168,30 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
|
|||
|
||||
// Generate the global variable $pagesByParent, defined on 69.pages.php
|
||||
// (boolean) $allPages, TRUE include all status, FALSE only include published status
|
||||
function buildPagesByParent($onlyPublished=true) {
|
||||
function buildPagesByParent($publishedPages=true, $staticPages=true) {
|
||||
global $dbPages;
|
||||
global $pagesByParent;
|
||||
global $pagesByParentByKey;
|
||||
|
||||
// Get DB
|
||||
$pageNumber = 1;
|
||||
$amountOfItems = -1;
|
||||
$db = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
$onlyKeys = true;
|
||||
$keys = array();
|
||||
if ($publishedPages) {
|
||||
$keys = array_merge($keys, $dbPages->getPublishedDB($onlyKeys));
|
||||
}
|
||||
if ($staticPages) {
|
||||
$keys = array_merge($keys, $dbPages->getStaticDB($onlyKeys));
|
||||
}
|
||||
|
||||
// Get Keys
|
||||
$keys = array_keys($db);
|
||||
foreach($keys as $pageKey) {
|
||||
foreach ($keys as $pageKey) {
|
||||
$page = buildPage($pageKey);
|
||||
if($page!==false) {
|
||||
if ($page!==false) {
|
||||
$parentKey = $page->parentKey();
|
||||
// FALSE if the page is parent
|
||||
if($parentKey===false) {
|
||||
if ($parentKey===false) {
|
||||
array_push($pagesByParent[PARENT], $page);
|
||||
$pagesByParentByKey[PARENT][$page->key()] = $page;
|
||||
} else {
|
||||
if( !isset($pagesByParent[$parentKey]) ) {
|
||||
if (!isset($pagesByParent[$parentKey])) {
|
||||
$pagesByParent[$parentKey] = array();
|
||||
}
|
||||
array_push($pagesByParent[$parentKey], $page);
|
||||
|
@ -221,19 +223,29 @@ function buildStaticPages() {
|
|||
pageKeyN => Page object,
|
||||
)
|
||||
*/
|
||||
function buildAllpages($onlyPublished=true) {
|
||||
function buildAllpages($publishedPages=true, $staticPages=true, $draftPages=true, $scheduledPages=true) {
|
||||
global $dbPages;
|
||||
|
||||
// Get DB
|
||||
$pageNumber = 1;
|
||||
$amountOfItems = -1;
|
||||
$db = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
$onlyKeys = true;
|
||||
$keys = array();
|
||||
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();
|
||||
$keys = array_keys($db);
|
||||
foreach($keys as $pageKey) {
|
||||
foreach ($keys as $pageKey) {
|
||||
$page = buildPage($pageKey);
|
||||
if($page!==false) {
|
||||
if ($page!==false) {
|
||||
$tmp[$page->key()] = $page;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ class DOM {
|
|||
|
||||
public static function getFirstImage($content)
|
||||
{
|
||||
// Disable warning
|
||||
libxml_use_internal_errors(true);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadHTML('<meta http-equiv="content-type" content="text/html; charset=utf-8">'.$content);
|
||||
$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]+[ ]*)';
|
||||
}
|
|
@ -232,5 +232,6 @@
|
|||
"scheduled": "Scheduled",
|
||||
"this-token-is-similar-to-a-password-it-should-not-be-shared": "This token is similar to a password, it should not be shared.",
|
||||
"congratulations-you-have-successfully-installed-your-bludit": "Congratulations you have successfully installed your **Bludit**.",
|
||||
"this-theme-may-not-be-supported-by-this-version-of-bludit": "This theme may not be supported by this version of Bludit"
|
||||
"this-theme-may-not-be-supported-by-this-version-of-bludit": "This theme may not be supported by this version of Bludit",
|
||||
"read-more": "Read more"
|
||||
}
|
|
@ -231,5 +231,6 @@
|
|||
"scheduled": "Запланировано",
|
||||
"this-token-is-similar-to-a-password-it-should-not-be-shared": "Этот токен похож на пароль, он не должен демонстрироваться.",
|
||||
"congratulations-you-have-successfully-installed-your-bludit": "Поздравляем! Вы успешно установили **Bludit**",
|
||||
"this-theme-may-not-be-supported-by-this-version-of-bludit": "Эта тема может не поддерживаться текущей версией Bludit"
|
||||
"this-theme-may-not-be-supported-by-this-version-of-bludit": "Эта тема может не поддерживаться текущей версией Bludit",
|
||||
"read-more": "Далее"
|
||||
}
|
||||
|
|
|
@ -168,14 +168,14 @@ class pluginAPI extends Plugin {
|
|||
$inputs = $_GET;
|
||||
break;
|
||||
case "PUT":
|
||||
$inputs = file_get_contents("php://input");
|
||||
$inputs = '';
|
||||
break;
|
||||
default:
|
||||
$inputs = json_encode(array());
|
||||
break;
|
||||
}
|
||||
|
||||
// Try to get raw data
|
||||
// Try to get raw/json data
|
||||
if (empty($inputs)) {
|
||||
$inputs = file_get_contents('php://input');
|
||||
}
|
||||
|
@ -183,6 +183,25 @@ class pluginAPI extends Plugin {
|
|||
return $this->cleanInputs($inputs);
|
||||
}
|
||||
|
||||
// Returns an array with key=>value
|
||||
// If the content is JSON is parsed to array
|
||||
private function cleanInputs($inputs)
|
||||
{
|
||||
$tmp = array();
|
||||
if (is_array($inputs)) {
|
||||
foreach ($inputs as $key=>$value) {
|
||||
$tmp[$key] = Sanitize::html($value);
|
||||
}
|
||||
} elseif (is_string($inputs)) {
|
||||
$tmp = json_decode($inputs, true);
|
||||
if (json_last_error()!==JSON_ERROR_NONE) {
|
||||
$tmp = array();
|
||||
}
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
private function getEndpointParameters($URI)
|
||||
{
|
||||
// ENDPOINT Parameters
|
||||
|
@ -202,23 +221,6 @@ class pluginAPI extends Plugin {
|
|||
return $parameters;
|
||||
}
|
||||
|
||||
private function cleanInputs($inputs)
|
||||
{
|
||||
$tmp = array();
|
||||
if (is_array($inputs)) {
|
||||
foreach ($inputs as $key=>$value) {
|
||||
$tmp[$key] = Sanitize::html($value);
|
||||
}
|
||||
} elseif(is_string($inputs)) {
|
||||
$tmp = json_decode($inputs, true);
|
||||
if (json_last_error()!==JSON_ERROR_NONE) {
|
||||
$tmp = array();
|
||||
}
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
private function response($code=200, $message='OK', $data=array())
|
||||
{
|
||||
header('HTTP/1.1 '.$code.' '.$message);
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Categories",
|
||||
"description": "Показывает все категории на боковой панели."
|
||||
},
|
||||
"hide-categories-without-content": "Скрывать пустые категории"
|
||||
}
|
|
@ -4,5 +4,7 @@
|
|||
"name": "Disqus",
|
||||
"description": "Disqus is a comment hosting service for web sites.<br>It's necessary to be registered on <a href=\"https://disqus.com\">Disqus</a> to use this service."
|
||||
},
|
||||
"disqus-shortname": "Disqus shortname"
|
||||
"disqus-shortname": "Disqus shortname",
|
||||
"enable-disqus-on-pages": "Disqus on static",
|
||||
"enable-disqus-on-posts": "Disqus on published"
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"description": "Disqus это сервис комментариев для сайтов и блогов. Необходимо быть зарегистрированным на Disqus.com перед использованием плагина."
|
||||
},
|
||||
"disqus-shortname": "Disqus shortname",
|
||||
"enable-disqus-on-pages": "Включить Disqus на страницах",
|
||||
"enable-disqus-on-posts": "Включить Disqus в записях",
|
||||
"enable-disqus-on-default-home-page": "Включить Disqus на домашней странице"
|
||||
"enable-disqus-on-pages": "Disqus на страницах",
|
||||
"enable-disqus-on-posts": "Disqus в записях"
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@ class pluginDisqus extends Plugin {
|
|||
public function init()
|
||||
{
|
||||
$this->dbFields = array(
|
||||
'shortname'=>''
|
||||
'shortname'=>'',
|
||||
'enablePages'=>false,
|
||||
'enablePosts'=>true
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -14,24 +16,44 @@ class pluginDisqus extends Plugin {
|
|||
global $Language;
|
||||
|
||||
$html = '<div>';
|
||||
$html .= '<label>'.$Language->get('Disqus shortname').'</label>';
|
||||
$html .= '<label>'.$Language->get('disqus-shortname').'</label>';
|
||||
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getValue('shortname').'">';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$Language->get('enable-disqus-on-pages').'</label>';
|
||||
$html .= '<select name="enablePages">';
|
||||
$html .= '<option value="true" '.($this->getValue('enablePages')===true?'selected':'').'>'.$Language->get('enabled').'</option>';
|
||||
$html .= '<option value="false" '.($this->getValue('enablePages')===false?'selected':'').'>'.$Language->get('disabled').'</option>';
|
||||
$html .= '</select>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$Language->get('enable-disqus-on-posts').'</label>';
|
||||
$html .= '<select name="enablePosts">';
|
||||
$html .= '<option value="true" '.($this->getValue('enablePosts')===true?'selected':'').'>'.$Language->get('enabled').'</option>';
|
||||
$html .= '<option value="false" '.($this->getValue('enablePosts')===false?'selected':'').'>'.$Language->get('disabled').'</option>';
|
||||
$html .= '</select>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function pageEnd()
|
||||
{
|
||||
global $pages;
|
||||
global $Url;
|
||||
global $Url, $Page;
|
||||
|
||||
$page = $pages[0];
|
||||
if (empty($page)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( (!$Url->notFound()) && ($Url->whereAmI()=='page') && ($page->allowComments()) ) {
|
||||
if ( !$Url->notFound() &&
|
||||
( $Url->whereAmI()=='page' &&
|
||||
(($this->getDbField('enablePosts') && $Page->status()=='published') ||
|
||||
($this->getDbField('enablePages') && $Page->status()=='static'))
|
||||
) &&
|
||||
$page->allowComments() ) {
|
||||
$html = '<div id="disqus_thread"></div>';
|
||||
$html .= '<script type="text/javascript">
|
||||
var disqus_config = function () {
|
||||
|
|
|
@ -60,6 +60,20 @@ class pluginGoogle extends Plugin {
|
|||
$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;
|
||||
}
|
||||
|
||||
|
@ -75,22 +89,4 @@ class pluginGoogle extends Plugin {
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -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 (empty($og['image'])) {
|
||||
// Get the image from the content
|
||||
$src = $this->getImage($content);
|
||||
$src = DOM::getFirstImage($content);
|
||||
if ($src!==false) {
|
||||
$og['image'] = $src;
|
||||
} else {
|
||||
|
@ -103,24 +103,4 @@ class pluginOpenGraph extends Plugin {
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "SimpleMDE",
|
||||
"description": "Редактор с простым интерфейсом для создания markup разметки."
|
||||
},
|
||||
"toolbar": "Панель инструментов",
|
||||
"tab-size": "Размер панели",
|
||||
"autosave": "Автосохранения",
|
||||
"spell-checker": "Проверка орфографии",
|
||||
"content-here-supports-markdown-and-html-code": "Содержимое поддерживаем Markdown и HTML коды"
|
||||
}
|
|
@ -22,28 +22,28 @@ class pluginsimpleMDE extends Plugin {
|
|||
global $Language;
|
||||
|
||||
$html = '<div>';
|
||||
$html .= '<label>'.$Language->get('Toolbar').'</label>';
|
||||
$html .= '<label>'.$Language->get('toolbar').'</label>';
|
||||
$html .= '<input name="toolbar" id="jstoolbar" type="text" value="'.$this->getDbField('toolbar').'">';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$Language->get('Tab size').'</label>';
|
||||
$html .= '<label>'.$Language->get('tab-size').'</label>';
|
||||
$html .= '<input name="tabSize" id="jstabSize" type="text" value="'.$this->getDbField('tabSize').'">';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$Language->get('Autosave').'</label>';
|
||||
$html .= '<label>'.$Language->get('autosave').'</label>';
|
||||
$html .= '<select name="autosave">';
|
||||
$html .= '<option value="true" '.($this->getValue('autosave')===true?'selected':'').'>Enabled</option>';
|
||||
$html .= '<option value="false" '.($this->getValue('autosave')===false?'selected':'').'>Disabled</option>';
|
||||
$html .= '<option value="true" '.($this->getValue('autosave')===true?'selected':'').'>'.$Language->get('enabled').'</option>';
|
||||
$html .= '<option value="false" '.($this->getValue('autosave')===false?'selected':'').'>'.$Language->get('disabled').'</option>';
|
||||
$html .= '</select>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$Language->get('Spell Checker').'</label>';
|
||||
$html .= '<label>'.$Language->get('spell-checker').'</label>';
|
||||
$html .= '<select name="spellChecker">';
|
||||
$html .= '<option value="true" '.($this->getValue('spellChecker')===true?'selected':'').'>Enabled</option>';
|
||||
$html .= '<option value="false" '.($this->getValue('spellChecker')===false?'selected':'').'>Disabled</option>';
|
||||
$html .= '<option value="true" '.($this->getValue('spellChecker')===true?'selected':'').'>'.$Language->get('enabled').'</option>';
|
||||
$html .= '<option value="false" '.($this->getValue('spellChecker')===false?'selected':'').'>'.$Language->get('disabled').'</option>';
|
||||
$html .= '</select>';
|
||||
$html .= '</div>';
|
||||
|
||||
|
@ -116,7 +116,7 @@ class pluginsimpleMDE extends Plugin {
|
|||
toolbarTips: true,
|
||||
toolbarGuideIcon: true,
|
||||
autofocus: false,
|
||||
placeholder: "'.$Language->get('Content here Supports Markdown and HTML code').'",
|
||||
placeholder: "'.$Language->get('content-here-supports-markdown-and-html-code').'",
|
||||
lineWrapping: true,
|
||||
autoDownloadFontAwesome: false,
|
||||
indentWithTabs: true,
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Список тэгов",
|
||||
"description": "Отображает тэги на боковой панели."
|
||||
}
|
||||
}
|
|
@ -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( empty($data['image']) ) {
|
||||
// Get the image from the content
|
||||
$src = $this->getImage($content);
|
||||
$src = DOM::getFirstImage($content);
|
||||
if ($src!==false) {
|
||||
$data['image'] = $src;
|
||||
} else {
|
||||
|
@ -96,25 +96,4 @@ class pluginTwitterCards extends Plugin {
|
|||
$html .= '<meta property="twitter:image" content="'.$data['image'].'">'.PHP_EOL;
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue