diff --git a/.gitignore b/.gitignore index 26dd0e10..6d8587f9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ bl-content/* bl-plugins/timemachine bl-plugins/remote-content -bl-kernel/bludit.pro.php \ No newline at end of file +bl-kernel/bludit.pro.php +bl-themes/docs diff --git a/bl-kernel/admin/controllers/settings-advanced.php b/bl-kernel/admin/controllers/settings-advanced.php index 7b70a5c2..f789a6a5 100644 --- a/bl-kernel/admin/controllers/settings-advanced.php +++ b/bl-kernel/admin/controllers/settings-advanced.php @@ -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(); diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php index 105cbb7e..a1745a68 100644 --- a/bl-kernel/admin/views/edit-content.php +++ b/bl-kernel/admin/views/edit-content.php @@ -162,7 +162,7 @@ echo '
'; // 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 '
'; 'selected'=>$page->parentKey(), 'tip'=>'' )); - } - echo '
'; + echo '
'; + } // Position input HTML::formInputText(array( diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 879f825e..62e33a8d 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -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 diff --git a/bl-kernel/boot/rules/69.pages.php b/bl-kernel/boot/rules/69.pages.php index c40da023..f9d50445 100644 --- a/bl-kernel/boot/rules/69.pages.php +++ b/bl-kernel/boot/rules/69.pages.php @@ -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') { diff --git a/bl-kernel/boot/site.php b/bl-kernel/boot/site.php index c021e1a4..87eef209 100644 --- a/bl-kernel/boot/site.php +++ b/bl-kernel/boot/site.php @@ -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'); } diff --git a/bl-kernel/dbpages.class.php b/bl-kernel/dbpages.class.php index 7c4311d3..942f4910 100644 --- a/bl-kernel/dbpages.class.php +++ b/bl-kernel/dbpages.class.php @@ -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]); } } diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 6b9e1399..886bc153 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -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; } } diff --git a/bl-kernel/helpers/dom.class.php b/bl-kernel/helpers/dom.class.php index d655fb8a..6cbc9252 100644 --- a/bl-kernel/helpers/dom.class.php +++ b/bl-kernel/helpers/dom.class.php @@ -4,6 +4,8 @@ class DOM { public static function getFirstImage($content) { + // Disable warning + libxml_use_internal_errors(true); $dom = new DOMDocument(); $dom->loadHTML(''.$content); $finder = new DomXPath($dom); diff --git a/bl-kernel/parsedownextra.class.php b/bl-kernel/parsedownextra.class.php deleted file mode 100644 index be6966d2..00000000 --- a/bl-kernel/parsedownextra.class.php +++ /dev/null @@ -1,526 +0,0 @@ -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+
\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, ''.$abbreviation.'', $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 .= ' '; - } - - $backLinksMarkup = substr($backLinksMarkup, 1); - - if (substr($text, - 4) === '

') - { - $backLinksMarkup = ' '.$backLinksMarkup; - - $text = substr_replace($text, $backLinksMarkup.'

', - 4); - } - else - { - $text .= "\n".'

'.$backLinksMarkup.'

'; - } - - $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]+[ ]*)'; -} diff --git a/bl-languages/en.json b/bl-languages/en.json index 2fbf334d..8229bb23 100644 --- a/bl-languages/en.json +++ b/bl-languages/en.json @@ -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" -} \ No newline at end of file + "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" +} diff --git a/bl-languages/ru_RU.json b/bl-languages/ru_RU.json index e192da82..64a6dc2c 100644 --- a/bl-languages/ru_RU.json +++ b/bl-languages/ru_RU.json @@ -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": "Далее" } diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index d721dcbe..9e1de637 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -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); diff --git a/bl-plugins/categories/languages/ru_RU.json b/bl-plugins/categories/languages/ru_RU.json new file mode 100644 index 00000000..60be6574 --- /dev/null +++ b/bl-plugins/categories/languages/ru_RU.json @@ -0,0 +1,8 @@ +{ + "plugin-data": + { + "name": "Categories", + "description": "Показывает все категории на боковой панели." + }, + "hide-categories-without-content": "Скрывать пустые категории" +} diff --git a/bl-plugins/disqus/languages/en.json b/bl-plugins/disqus/languages/en.json index ff728f5a..b4b6f9af 100644 --- a/bl-plugins/disqus/languages/en.json +++ b/bl-plugins/disqus/languages/en.json @@ -4,5 +4,7 @@ "name": "Disqus", "description": "Disqus is a comment hosting service for web sites.
It's necessary to be registered on Disqus 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" } diff --git a/bl-plugins/disqus/languages/ru_RU.json b/bl-plugins/disqus/languages/ru_RU.json index 2dd66f3b..f96a82f1 100644 --- a/bl-plugins/disqus/languages/ru_RU.json +++ b/bl-plugins/disqus/languages/ru_RU.json @@ -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 в записях" } diff --git a/bl-plugins/disqus/plugin.php b/bl-plugins/disqus/plugin.php index d5973604..2880809f 100644 --- a/bl-plugins/disqus/plugin.php +++ b/bl-plugins/disqus/plugin.php @@ -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 = '
'; - $html .= ''; + $html .= ''; $html .= ''; $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + 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 = '
'; $html .= ' + '.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.''.PHP_EOL; - $html .= ' - - '.PHP_EOL; - return $html; - } - return false; - } } \ No newline at end of file diff --git a/bl-plugins/opengraph/plugin.php b/bl-plugins/opengraph/plugin.php index ed8b357c..0642bc4c 100644 --- a/bl-plugins/opengraph/plugin.php +++ b/bl-plugins/opengraph/plugin.php @@ -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(''.$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; - } } \ No newline at end of file diff --git a/bl-plugins/simplemde/languages/ru_RU.json b/bl-plugins/simplemde/languages/ru_RU.json new file mode 100644 index 00000000..4f6cc66f --- /dev/null +++ b/bl-plugins/simplemde/languages/ru_RU.json @@ -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 коды" +} diff --git a/bl-plugins/simplemde/plugin.php b/bl-plugins/simplemde/plugin.php index 9dde86bc..a2c11b8e 100644 --- a/bl-plugins/simplemde/plugin.php +++ b/bl-plugins/simplemde/plugin.php @@ -22,28 +22,28 @@ class pluginsimpleMDE extends Plugin { global $Language; $html = '
'; - $html .= ''; + $html .= ''; $html .= ''; $html .= '
'; $html .= '
'; - $html .= ''; + $html .= ''; $html .= ''; $html .= '
'; $html .= '
'; - $html .= ''; + $html .= ''; $html .= ''; $html .= '
'; $html .= '
'; - $html .= ''; + $html .= ''; $html .= ''; $html .= '
'; @@ -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, diff --git a/bl-plugins/tags/languages/ru-RU.json b/bl-plugins/tags/languages/ru-RU.json deleted file mode 100644 index 17c5dc26..00000000 --- a/bl-plugins/tags/languages/ru-RU.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "plugin-data": - { - "name": "Список тэгов", - "description": "Отображает тэги на боковой панели." - } -} diff --git a/bl-plugins/tags/ru_RU.json b/bl-plugins/tags/languages/ru_RU.json similarity index 100% rename from bl-plugins/tags/ru_RU.json rename to bl-plugins/tags/languages/ru_RU.json diff --git a/bl-plugins/twitter-cards/plugin.php b/bl-plugins/twitter-cards/plugin.php index 2456406c..8a9e0def 100644 --- a/bl-plugins/twitter-cards/plugin.php +++ b/bl-plugins/twitter-cards/plugin.php @@ -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 .= ''.PHP_EOL; return $html; } - - // Returns the first image from the HTML content - private function getImage($content) - { - $dom = new DOMDocument(); - $dom->loadHTML(''.$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; - } } \ No newline at end of file diff --git a/index.php b/index.php index 1a6457d2..cd288a5c 100644 --- a/index.php +++ b/index.php @@ -8,8 +8,7 @@ */ // 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'); exit('Install Bludit first.'); }