Title in database, improves on Page Object, Perfomance improvements, TinyMCE and Bootstrap updated

This commit is contained in:
Diego Najar 2018-07-17 19:13:01 +02:00
parent 8cfd7df062
commit d852cada22
68 changed files with 1017 additions and 743 deletions

View File

@ -313,7 +313,7 @@ class Plugin {
// Example: https://www.mybludit.com/api/foo/bar // Example: https://www.mybludit.com/api/foo/bar
public function webhook($URI=false, $returnsAfterURI=false, $fixed=true) public function webhook($URI=false, $returnsAfterURI=false, $fixed=true)
{ {
global $Url; global $url;
if (empty($URI)) { if (empty($URI)) {
return false; return false;
@ -321,7 +321,7 @@ class Plugin {
// Check URI start with the webhook // Check URI start with the webhook
$startString = HTML_PATH_ROOT.$URI; $startString = HTML_PATH_ROOT.$URI;
$URI = $Url->uri(); $URI = $url->uri();
$length = mb_strlen($startString, CHARSET); $length = mb_strlen($startString, CHARSET);
if (mb_substr($URI, 0, $length)!=$startString) { if (mb_substr($URI, 0, $length)!=$startString) {
return false; return false;

View File

@ -25,11 +25,11 @@ checkRole(array('admin', 'moderator'));
// List of published pages // List of published pages
$onlyPublished = true; $onlyPublished = true;
$amountOfItems = ITEMS_PER_PAGE_ADMIN; $amountOfItems = ITEMS_PER_PAGE_ADMIN;
$pageNumber = $Url->pageNumber(); $pageNumber = $url->pageNumber();
$published = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); $published = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
// Check if out of range the pageNumber // Check if out of range the pageNumber
if (empty($published) && $Url->pageNumber()>1) { if (empty($published) && $url->pageNumber()>1) {
Redirect::page('content'); Redirect::page('content');
} }

View File

@ -4,18 +4,18 @@
// Functions // Functions
// ============================================================================ // ============================================================================
function updateBludit() { function updateBludit() {
global $Site; global $site;
// Check if Bludit need to be update. // Check if Bludit need to be update.
if( ($Site->currentBuild() < BLUDIT_BUILD) || isset($_GET['update']) ) { if( ($site->currentBuild() < BLUDIT_BUILD) || isset($_GET['update']) ) {
Log::set('UPDATE SYSTEM - Starting.'); Log::set('UPDATE SYSTEM - Starting.');
// From Bludit v2.0.x to v2.1.x // From Bludit v2.0.x to v2.1.x
if ($Site->currentBuild() < '20171102') { if ($site->currentBuild() < '20171102') {
// Nothing to do // Nothing to do
} }
// Set the current build number // Set the current build number
$Site->set(array('currentBuild'=>BLUDIT_BUILD)); $site->set(array('currentBuild'=>BLUDIT_BUILD));
Log::set('UPDATE SYSTEM - Finished.'); Log::set('UPDATE SYSTEM - Finished.');
} }
} }

View File

@ -53,10 +53,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// ============================================================================ // ============================================================================
// Main after POST // Main after POST
// ============================================================================ // ============================================================================
try {
$pageKey = $layout['parameters']; $pageKey = $layout['parameters'];
$page = buildPage($pageKey); $page = new PageX($pageKey);
if ($page===false) { } catch (Exception $e) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$pageKey); Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$pageKey, LOG_TYPE_ERROR);
Redirect::page('content'); Redirect::page('content');
} }

View File

@ -25,7 +25,7 @@ $themeDirname = $layout['parameters'];
if( Sanitize::pathFile(PATH_THEMES.$themeDirname) ) { if( Sanitize::pathFile(PATH_THEMES.$themeDirname) ) {
// Set the theme // Set the theme
$Site->set(array('theme'=>$themeDirname)); $site->set(array('theme'=>$themeDirname));
// Add to syslog // Add to syslog
$syslog->add(array( $syslog->add(array(

View File

@ -10,11 +10,11 @@
function checkLogin($args) function checkLogin($args)
{ {
global $Security; global $security;
global $login; global $login;
global $Language; global $Language;
if ($Security->isBlocked()) { if ($security->isBlocked()) {
Alert::set($Language->g('IP address has been blocked').'<br>'.$Language->g('Try again in a few minutes'), ALERT_STATUS_FAIL); Alert::set($Language->g('IP address has been blocked').'<br>'.$Language->g('Try again in a few minutes'), ALERT_STATUS_FAIL);
return false; return false;
} }
@ -24,13 +24,13 @@ function checkLogin($args)
$login->setRememberMe($_POST['username']); $login->setRememberMe($_POST['username']);
} }
// Renew the token. This token will be the same inside the session for multiple forms. // Renew the token. This token will be the same inside the session for multiple forms.
$Security->generateTokenCSRF(); $security->generateTokenCSRF();
Redirect::page('dashboard'); Redirect::page('dashboard');
return true; return true;
} }
// Bruteforce protection, add IP to the blacklist // Bruteforce protection, add IP to the blacklist
$Security->addToBlacklist(); $security->addToBlacklist();
// Create alert // Create alert
Alert::set($Language->g('Username or password incorrect'), ALERT_STATUS_FAIL); Alert::set($Language->g('Username or password incorrect'), ALERT_STATUS_FAIL);
@ -40,15 +40,15 @@ function checkLogin($args)
function checkRememberMe() function checkRememberMe()
{ {
global $Security; global $security;
global $login; global $login;
if ($Security->isBlocked()) { if ($security->isBlocked()) {
return false; return false;
} }
if ($login->verifyUserByRemember()) { if ($login->verifyUserByRemember()) {
$Security->generateTokenCSRF(); $security->generateTokenCSRF();
Redirect::page('dashboard'); Redirect::page('dashboard');
return true; return true;
} }

View File

@ -20,7 +20,7 @@ checkRole(array('admin'));
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
$Site->set($_POST); $site->set($_POST);
} }
// ============================================================================ // ============================================================================

View File

@ -26,7 +26,7 @@ $amountOfPages = count($listOfFilesByPage);
<!-- Form and Input file --> <!-- Form and Input file -->
<form name="bluditFormUpload" id="jsbluditFormUpload" enctype="multipart/form-data"> <form name="bluditFormUpload" id="jsbluditFormUpload" enctype="multipart/form-data">
<input type="hidden" name="tokenCSRF" value="<?php echo $Security->getTokenCSRF() ?>"> <input type="hidden" name="tokenCSRF" value="<?php echo $security->getTokenCSRF() ?>">
<div class="custom-file"> <div class="custom-file">
<input type="file" class="custom-file-input" id="jsbluditInputFiles" name="bluditInputFiles[]" multiple> <input type="file" class="custom-file-input" id="jsbluditInputFiles" name="bluditInputFiles[]" multiple>
<label class="custom-file-label" for="jsbluditInputFiles">Choose images</label> <label class="custom-file-label" for="jsbluditInputFiles">Choose images</label>

View File

@ -23,7 +23,7 @@ $categories = $dbCategories->getKeyNameArray();
foreach ($categories as $categoryKey=>$category) { foreach ($categories as $categoryKey=>$category) {
echo '<tr>'; echo '<tr>';
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-category/'.$categoryKey.'">'.$category.'</a></td>'; echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-category/'.$categoryKey.'">'.$category.'</a></td>';
echo '<td><a href="'.DOMAIN_CATEGORIES.$categoryKey.'">'.$Url->filters('category', false).$categoryKey.'</a></td>'; echo '<td><a href="'.DOMAIN_CATEGORIES.$categoryKey.'">'.$url->filters('category', false).$categoryKey.'</a></td>';
echo '</tr>'; echo '</tr>';
} }

View File

@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array('class'=>'plugin-form'));
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
// Print the plugin form // Print the plugin form

View File

@ -3,7 +3,7 @@
echo Bootstrap::pageTitle(array('title'=>$L->g('Content'), 'icon'=>'cog')); echo Bootstrap::pageTitle(array('title'=>$L->g('Content'), 'icon'=>'cog'));
function table($status) { function table($status) {
global $Url; global $url;
global $Language; global $Language;
global $published; global $published;
global $drafts; global $drafts;
@ -77,7 +77,7 @@ function table($status) {
.'</a> .'</a>
</td>'; </td>';
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$page->key() : '/'.$Url->filters('page').'/'.$page->key(); $friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$page->key() : '/'.$url->filters('page').'/'.$page->key();
echo '<td class="d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>'; echo '<td class="d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
echo '<td class="text-center d-none d-sm-table-cell">'.$page->position().'</td>'; echo '<td class="text-center d-none d-sm-table-cell">'.$page->position().'</td>';
@ -93,7 +93,7 @@ function table($status) {
.'</a> .'</a>
</td>'; </td>';
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$child->key() : '/'.$Url->filters('page').'/'.$child->key(); $friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$child->key() : '/'.$url->filters('page').'/'.$child->key();
echo '<td><a target="_blank" href="'.$child->permalink().'">'.$friendlyURL.'</a></td>'; echo '<td><a target="_blank" href="'.$child->permalink().'">'.$friendlyURL.'</a></td>';
echo '<td>'.$child->position().'</td>'; echo '<td>'.$child->position().'</td>';
@ -115,7 +115,7 @@ function table($status) {
.'</a> .'</a>
</td>'; </td>';
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$page->key() : '/'.$Url->filters('page').'/'.$page->key(); $friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$page->key() : '/'.$url->filters('page').'/'.$page->key();
echo '<td class="d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>'; echo '<td class="d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
echo '<td class="text-center d-none d-sm-table-cell">'.( ((ORDER_BY=='position') || ($status!='published'))?$page->position():$page->dateRaw(ADMIN_PANEL_DATE_FORMAT) ).'</td>'; echo '<td class="text-center d-none d-sm-table-cell">'.( ((ORDER_BY=='position') || ($status!='published'))?$page->position():$page->dateRaw(ADMIN_PANEL_DATE_FORMAT) ).'</td>';

View File

@ -34,5 +34,5 @@ $constants = get_defined_constants(true);
printTable('Bludit Constants', $constants['user']); printTable('Bludit Constants', $constants['user']);
// Site object // Site object
printTable('$Site object database',$Site->db); printTable('$Site object database',$site->db);

View File

@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(

View File

@ -21,7 +21,7 @@
// Token CSRF // Token CSRF
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
// Parent // Parent
@ -38,8 +38,8 @@
// Status = published, draft, sticky, static // Status = published, draft, sticky, static
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'status', 'name'=>'type',
'value'=>$page->status() 'value'=>$page->type()
)); ));
// Page current key // Page current key
@ -82,14 +82,31 @@
<div class="alert alert-primary mt-2 mb-2">The content is saved as a draft. To publish it click on the button <b>Publish</b> or if you still working on it click on <b>Save as draft</b>.</div> <div class="alert alert-primary mt-2 mb-2">The content is saved as a draft. To publish it click on the button <b>Publish</b> or if you still working on it click on <b>Save as draft</b>.</div>
<?php endif; ?> <?php endif; ?>
<div class="form-group mt-2">
<button type="button" class="jsbuttonSave btn btn-primary"><?php echo ($page->draft()?$L->g('Publish'):$L->g('Update')) ?></button>
<button type="button" class="jsbuttonDraft btn btn-secondary"><?php echo $L->g('Save as draft') ?></button>
<a href="<?php echo HTML_PATH_ADMIN_ROOT ?>dashboard" class="btn btn-secondary"><?php echo $L->g('Cancel') ?></a>
<?php
if (count($page->children())===0) {
echo '<button type="button" class="jsbuttonDelete btn btn-secondary">'.$L->g('Delete').'</button>';
}
?>
</div>
</div> </div>
<!-- TABS IMAGES --> <!-- TABS IMAGES -->
<div class="tab-pane" id="images" role="tabpanel" aria-labelledby="images-tab"> <div class="tab-pane" id="images" role="tabpanel" aria-labelledby="images-tab">
<?php <div>
echo Bootstrap::formTitle(array('title'=>'Cover image')); <div class="float-right">
<button type="button" class="jsbuttonSave btn btn-primary btn-sm"><?php echo ($page->draft()?$L->g('Publish'):$L->g('Update')) ?></button>
<button type="button" class="jsbuttonDraft btn btn-secondary btn-sm"><?php echo $L->g('Save as draft') ?></button>
</div>
<h4 class="mt-4 mb-4 font-weight-normal">Cover Image</h4>
</div>
<?php
$coverImage = $page->coverImage(false); $coverImage = $page->coverImage(false);
$externalCoverImage = ''; $externalCoverImage = '';
if (filter_var($coverImage, FILTER_VALIDATE_URL)) { if (filter_var($coverImage, FILTER_VALIDATE_URL)) {
@ -115,26 +132,32 @@
<!-- TABS OPTIONS --> <!-- TABS OPTIONS -->
<div class="tab-pane" id="options" role="tabpanel" aria-labelledby="options-tab"> <div class="tab-pane" id="options" role="tabpanel" aria-labelledby="options-tab">
<div>
<div class="float-right">
<button type="button" class="jsbuttonSave btn btn-primary btn-sm"><?php echo ($page->draft()?$L->g('Publish'):$L->g('Update')) ?></button>
<button type="button" class="jsbuttonDraft btn btn-secondary btn-sm"><?php echo $L->g('Save as draft') ?></button>
</div>
<h4 class="mt-4 mb-4 font-weight-normal">Cover Image</h4>
</div>
<?php <?php
echo Bootstrap::formTitle(array('title'=>'Advanced'));
// Date // Date
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'date', 'name'=>'date',
'label'=>'Date', 'label'=>'Date',
'placeholder'=>'', 'placeholder'=>'',
'value'=>$page->date(), 'value'=>$page->dateRaw(),
'tip'=>'Date format: <code>YYYY-MM-DD Hours:Minutes:Seconds</code>' 'tip'=>'Date format: <code>YYYY-MM-DD Hours:Minutes:Seconds</code>'
)); ));
// Type // Type
echo Bootstrap::formSelect(array( echo Bootstrap::formSelect(array(
'name'=>'type', 'name'=>'typeTMP',
'label'=>'Type', 'label'=>'Type',
'selected'=>$page->type(), 'selected'=>$page->type(),
'options'=>array( 'options'=>array(
''=>'- Default -', 'published'=>'- Default -',
'sticky'=>'Sticky', 'sticky'=>'Sticky',
'static'=>'Static' 'static'=>'Static'
), ),
@ -219,18 +242,6 @@
?> ?>
</div> </div>
<hr>
<div class="form-group mt-2">
<button id="jsbuttonSave" type="button" class="btn btn-primary"><?php echo ($page->draft()?$L->g('Publish'):$L->g('Update')) ?></button>
<button id="jsbuttonDraft" type="button" class="btn btn-secondary"><?php echo $L->g('Save as draft') ?></button>
<a href="<?php echo HTML_PATH_ADMIN_ROOT ?>dashboard" class="btn btn-secondary"><?php echo $L->g('Cancel') ?></a>
<?php
if (count($page->children())===0) {
echo '<button id="jsbuttonDelete" type="button" class="btn btn-secondary">'.$L->g('Delete').'</button>';
}
?>
</div>
<!-- Modal for Categories --> <!-- Modal for Categories -->
<div id="jscategoryModal" class="modal fade" tabindex="-1" role="dialog"> <div id="jscategoryModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
@ -337,22 +348,23 @@ $(document).ready(function() {
$("#jsdate").datetimepicker({format:DB_DATE_FORMAT}); $("#jsdate").datetimepicker({format:DB_DATE_FORMAT});
// Button Save // Button Save
$("#jsbuttonSave").on("click", function() { $(".jsbuttonSave").on("click", function() {
$("#jsstatus").val("published"); var type = $("#jstypeTMP option:selected").val();
$("#jstype").val(type);
$("#jscontent").val( editorGetContent() ); $("#jscontent").val( editorGetContent() );
$("#jsform").submit(); $("#jsform").submit();
}); });
// Button Save as draft // Button Save as draft
$("#jsbuttonDraft").on("click", function() { $(".jsbuttonDraft").on("click", function() {
$("#jsstatus").val("draft"); $("#jstype").val("draft");
$("#jscontent").val( editorGetContent() ); $("#jscontent").val( editorGetContent() );
$("#jsform").submit(); $("#jsform").submit();
}); });
// Button Delete // Button Delete
$("#jsbuttonDelete").on("click", function() { $(".jsbuttonDelete").on("click", function() {
$("#jsstatus").val("delete"); $("#jstype").val("delete");
$("#jscontent").val(""); $("#jscontent").val("");
$("#jsform").submit(); $("#jsform").submit();
}); });
@ -362,12 +374,6 @@ $(document).ready(function() {
$("#jscoverImage").val( $(this).val() ); $("#jscoverImage").val( $(this).val() );
}); });
// Type selector modified the status hidden field
$("#jstype").on("change", function() {
var status = $("#jstype option:selected").val();
$("#jsstatus").val(status);
});
// Autosave interval // Autosave interval
// Autosave works when the content of the page is bigger than 100 characters // Autosave works when the content of the page is bigger than 100 characters
setInterval(function() { setInterval(function() {

View File

@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(

View File

@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
echo ' echo '

View File

@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
echo Bootstrap::formInputTextBlock(array( echo Bootstrap::formInputTextBlock(array(

View File

@ -21,7 +21,7 @@
// Token CSRF // Token CSRF
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
// Parent // Parent
@ -38,7 +38,7 @@
// Status = published, draft, sticky, static // Status = published, draft, sticky, static
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'status', 'name'=>'type',
'value'=>'published' 'value'=>'published'
)); ));
@ -72,14 +72,24 @@
<textarea id="jseditor" style="display:none;"></textarea> <textarea id="jseditor" style="display:none;"></textarea>
</div> </div>
<div class="form-group mt-2">
<button type="button" class="jsbuttonSave btn btn-primary"><?php echo $L->g('Publish') ?></button>
<button type="button" class="jsbuttonDraft btn btn-secondary"><?php echo $L->g('Save as draft') ?></button>
<a href="<?php echo HTML_PATH_ADMIN_ROOT ?>dashboard" class="btn btn-secondary"><?php echo $L->g('Cancel') ?></a>
</div>
</div> </div>
<!-- TABS IMAGES --> <!-- TABS IMAGES -->
<div class="tab-pane" id="images" role="tabpanel" aria-labelledby="images-tab"> <div class="tab-pane" id="images" role="tabpanel" aria-labelledby="images-tab">
<?php <div>
echo Bootstrap::formTitle(array('title'=>'Cover image')); <div class="float-right">
?> <button type="button" class="jsbuttonSave btn btn-primary btn-sm"><?php echo $L->g('Publish') ?></button>
<button type="button" class="jsbuttonDraft btn btn-secondary btn-sm"><?php echo $L->g('Save as draft') ?></button>
</div>
<h4 class="mt-4 mb-4 font-weight-normal">Cover Image</h4>
</div>
<img id="jscoverImagePreview" style="width: 350px; height: 200px;" class="img-thumbnail" alt="coverImagePreview" src="<?php echo HTML_PATH_ADMIN_THEME_IMG ?>default.svg" /> <img id="jscoverImagePreview" style="width: 350px; height: 200px;" class="img-thumbnail" alt="coverImagePreview" src="<?php echo HTML_PATH_ADMIN_THEME_IMG ?>default.svg" />
@ -98,10 +108,16 @@
<!-- TABS OPTIONS --> <!-- TABS OPTIONS -->
<div class="tab-pane" id="options" role="tabpanel" aria-labelledby="options-tab"> <div class="tab-pane" id="options" role="tabpanel" aria-labelledby="options-tab">
<div>
<div class="float-right">
<button type="button" class="jsbuttonSave btn btn-primary btn-sm"><?php echo $L->g('Publish') ?></button>
<button type="button" class="jsbuttonDraft btn btn-secondary btn-sm"><?php echo $L->g('Save as draft') ?></button>
</div>
<h4 class="mt-4 mb-4 font-weight-normal">Advanced</h4>
</div>
<?php <?php
echo Bootstrap::formTitle(array('title'=>'Advanced'));
// Date // Date
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'date', 'name'=>'date',
@ -113,11 +129,11 @@
// Type // Type
echo Bootstrap::formSelect(array( echo Bootstrap::formSelect(array(
'name'=>'type', 'name'=>'typeTMP',
'label'=>'Type', 'label'=>'Type',
'selected'=>'', 'selected'=>'',
'options'=>array( 'options'=>array(
''=>'- Default -', 'published'=>'- Default -',
'sticky'=>'Sticky', 'sticky'=>'Sticky',
'static'=>'Static' 'static'=>'Static'
), ),
@ -199,13 +215,6 @@
?> ?>
</div> </div>
<hr>
<div class="form-group mt-2">
<button id="jsbuttonSave" type="button" class="btn btn-primary"><?php echo $L->g('Publish') ?></button>
<button id="jsbuttonDraft" type="button" class="btn btn-secondary"><?php echo $L->g('Save as draft') ?></button>
<a href="<?php echo HTML_PATH_ADMIN_ROOT ?>dashboard" class="btn btn-secondary"><?php echo $L->g('Cancel') ?></a>
</div>
<!-- Modal for Categories --> <!-- Modal for Categories -->
<div id="jscategoryModal" class="modal fade" tabindex="-1" role="dialog"> <div id="jscategoryModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
@ -312,15 +321,16 @@ $(document).ready(function() {
$("#jsdate").datetimepicker({format:DB_DATE_FORMAT}); $("#jsdate").datetimepicker({format:DB_DATE_FORMAT});
// Button Save // Button Save
$("#jsbuttonSave").on("click", function() { $(".jsbuttonSave").on("click", function() {
$("#jsstatus").val("published"); var type = $("#jstypeTMP option:selected").val();
$("#jstype").val(type);
$("#jscontent").val( editorGetContent() ); $("#jscontent").val( editorGetContent() );
$("#jsform").submit(); $("#jsform").submit();
}); });
// Button Save as draft // Button Save as draft
$("#jsbuttonDraft").on("click", function() { $(".jsbuttonDraft").on("click", function() {
$("#jsstatus").val("draft"); $("#jstype").val("draft");
$("#jscontent").val( editorGetContent() ); $("#jscontent").val( editorGetContent() );
$("#jsform").submit(); $("#jsform").submit();
}); });
@ -330,12 +340,6 @@ $(document).ready(function() {
$("#jscoverImage").val( $(this).val() ); $("#jscoverImage").val( $(this).val() );
}); });
// Type selector modified the status hidden field
$("#jstype").on("change", function() {
var status = $("#jstype option:selected").val();
$("#jsstatus").val(status);
});
// Generate slug when the user type the title // Generate slug when the user type the title
$("#jstitle").keyup(function() { $("#jstitle").keyup(function() {
var text = $(this).val(); var text = $(this).val();

View File

@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(

View File

@ -8,7 +8,7 @@ echo '<form class="uk-form" method="post" action="" autocomplete="off">';
HTML::formInputHidden(array( HTML::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
echo '<div class="uk-sortable" data-uk-sortable>'; echo '<div class="uk-sortable" data-uk-sortable>';

View File

@ -28,7 +28,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
// Token CSRF // Token CSRF
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
?> ?>
@ -38,7 +38,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'title', 'name'=>'title',
'label'=>$L->g('Site title'), 'label'=>$L->g('Site title'),
'value'=>$Site->title(), 'value'=>$site->title(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>$L->g('use-this-field-to-name-your-site') 'tip'=>$L->g('use-this-field-to-name-your-site')
@ -47,7 +47,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'slogan', 'name'=>'slogan',
'label'=>$L->g('Site slogan'), 'label'=>$L->g('Site slogan'),
'value'=>$Site->slogan(), 'value'=>$site->slogan(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>$L->g('use-this-field-to-add-a-catchy-phrase') 'tip'=>$L->g('use-this-field-to-add-a-catchy-phrase')
@ -56,7 +56,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'description', 'name'=>'description',
'label'=>$L->g('Site description'), 'label'=>$L->g('Site description'),
'value'=>$Site->description(), 'value'=>$site->description(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>$L->g('you-can-add-a-site-description-to-provide') 'tip'=>$L->g('you-can-add-a-site-description-to-provide')
@ -65,7 +65,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'footer', 'name'=>'footer',
'label'=>$L->g('Footer text'), 'label'=>$L->g('Footer text'),
'value'=>$Site->footer(), 'value'=>$site->footer(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>$L->g('you-can-add-a-small-text-on-the-bottom') 'tip'=>$L->g('you-can-add-a-small-text-on-the-bottom')
@ -89,7 +89,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
'name'=>'itemsPerPage', 'name'=>'itemsPerPage',
'label'=>$L->g('Items per page'), 'label'=>$L->g('Items per page'),
'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>$L->g('All content')), 'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>$L->g('All content')),
'selected'=>$Site->itemsPerPage(), 'selected'=>$site->itemsPerPage(),
'class'=>'', 'class'=>'',
'tip'=>$L->g('Number of items to show per page') 'tip'=>$L->g('Number of items to show per page')
)); ));
@ -98,7 +98,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
'name'=>'orderBy', 'name'=>'orderBy',
'label'=>$L->g('Order content by'), 'label'=>$L->g('Order content by'),
'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')), 'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')),
'selected'=>$Site->orderBy(), 'selected'=>$site->orderBy(),
'class'=>'', 'class'=>'',
'tip'=>$L->g('order-the-content-by-date-to-build-a-blog') 'tip'=>$L->g('order-the-content-by-date-to-build-a-blog')
)); ));
@ -108,7 +108,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'homepage', 'name'=>'homepage',
'label'=>$L->g('Homepage'), 'label'=>$L->g('Homepage'),
'value'=>(Text::isEmpty($Site->homepage())?'':$Site->homepage()), 'value'=>(Text::isEmpty($site->homepage())?'':$site->homepage()),
'class'=>'', 'class'=>'',
'placeholder'=>'Start writing the title of the page', 'placeholder'=>'Start writing the title of the page',
'tip'=>$L->g('Returning page for the main page') 'tip'=>$L->g('Returning page for the main page')
@ -119,7 +119,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
'name'=>'pageNotFound', 'name'=>'pageNotFound',
'label'=>$L->g('Page not found'), 'label'=>$L->g('Page not found'),
'options'=>$homepageOptions, 'options'=>$homepageOptions,
'selected'=>$Site->pageNotFound(), 'selected'=>$site->pageNotFound(),
'class'=>'', 'class'=>'',
'tip'=>$L->g('Returning page when the page doesnt exist') 'tip'=>$L->g('Returning page when the page doesnt exist')
)); ));
@ -129,7 +129,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'emailFrom', 'name'=>'emailFrom',
'label'=>$L->g('Sender email'), 'label'=>$L->g('Sender email'),
'value'=>$Site->emailFrom(), 'value'=>$site->emailFrom(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>$L->g('Emails will be sent from this address') 'tip'=>$L->g('Emails will be sent from this address')
@ -140,7 +140,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'autosaveInterval', 'name'=>'autosaveInterval',
'label'=>$L->g('Interval'), 'label'=>$L->g('Interval'),
'value'=>$Site->autosaveInterval(), 'value'=>$site->autosaveInterval(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>$L->g('Number in minutes for every execution of autosave') 'tip'=>$L->g('Number in minutes for every execution of autosave')
@ -151,7 +151,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'url', 'name'=>'url',
'label'=>'URL', 'label'=>'URL',
'value'=>$Site->url(), 'value'=>$site->url(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>$L->g('full-url-of-your-site'), 'tip'=>$L->g('full-url-of-your-site'),
@ -164,7 +164,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
'name'=>'extremeFriendly', 'name'=>'extremeFriendly',
'label'=>'Allow Unicode', 'label'=>'Allow Unicode',
'options'=>array('true'=>'Enabled', 'false'=>'Disable'), 'options'=>array('true'=>'Enabled', 'false'=>'Disable'),
'selected'=>$Site->extremeFriendly(), 'selected'=>$site->extremeFriendly(),
'class'=>'', 'class'=>'',
'tip'=>'Allow unicode characters in the URL and some part of the system.' 'tip'=>'Allow unicode characters in the URL and some part of the system.'
)); ));
@ -174,7 +174,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'titleFormatHomepage', 'name'=>'titleFormatHomepage',
'label'=>'Homepage', 'label'=>'Homepage',
'value'=>$Site->titleFormatHomepage(), 'value'=>$site->titleFormatHomepage(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'Variables allowed: <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>', 'tip'=>'Variables allowed: <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
@ -184,7 +184,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'titleFormatPages', 'name'=>'titleFormatPages',
'label'=>'Pages', 'label'=>'Pages',
'value'=>$Site->titleFormatPages(), 'value'=>$site->titleFormatPages(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'Variables allowed: <code>{{page-title}}</code> <code>{{page-description}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>', 'tip'=>'Variables allowed: <code>{{page-title}}</code> <code>{{page-description}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
@ -194,7 +194,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'titleFormatCategory', 'name'=>'titleFormatCategory',
'label'=>'Category', 'label'=>'Category',
'value'=>$Site->titleFormatCategory(), 'value'=>$site->titleFormatCategory(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'Variables allowed: <code>{{category-name}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>', 'tip'=>'Variables allowed: <code>{{category-name}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
@ -204,7 +204,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'titleFormatTag', 'name'=>'titleFormatTag',
'label'=>'Tag', 'label'=>'Tag',
'value'=>$Site->titleFormatTag(), 'value'=>$site->titleFormatTag(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'Variables allowed: <code>{{tag-name}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>', 'tip'=>'Variables allowed: <code>{{tag-name}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
@ -216,7 +216,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'uriPage', 'name'=>'uriPage',
'label'=>$L->g('Pages'), 'label'=>$L->g('Pages'),
'value'=>$Site->uriFilters('page'), 'value'=>$site->uriFilters('page'),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>DOMAIN_PAGES 'tip'=>DOMAIN_PAGES
@ -225,7 +225,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'uriTag', 'name'=>'uriTag',
'label'=>$L->g('Tags'), 'label'=>$L->g('Tags'),
'value'=>$Site->uriFilters('tag'), 'value'=>$site->uriFilters('tag'),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>DOMAIN_TAGS 'tip'=>DOMAIN_TAGS
@ -234,7 +234,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'uriCategory', 'name'=>'uriCategory',
'label'=>$L->g('Category'), 'label'=>$L->g('Category'),
'value'=>$Site->uriFilters('category'), 'value'=>$site->uriFilters('category'),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>DOMAIN_CATEGORIES 'tip'=>DOMAIN_CATEGORIES
@ -243,11 +243,11 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'uriBlog', 'name'=>'uriBlog',
'label'=>$L->g('Blog'), 'label'=>$L->g('Blog'),
'value'=>$Site->uriFilters('blog'), 'value'=>$site->uriFilters('blog'),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>DOMAIN.$Site->uriFilters('blog'), 'tip'=>DOMAIN.$site->uriFilters('blog'),
'disabled'=>!$Site->uriFilters('blog') 'disabled'=>!$site->uriFilters('blog')
)); ));
echo ' echo '
@ -265,7 +265,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'twitter', 'name'=>'twitter',
'label'=>'Twitter', 'label'=>'Twitter',
'value'=>$Site->twitter(), 'value'=>$site->twitter(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'' 'tip'=>''
@ -274,7 +274,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'facebook', 'name'=>'facebook',
'label'=>'Facebook', 'label'=>'Facebook',
'value'=>$Site->facebook(), 'value'=>$site->facebook(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'' 'tip'=>''
@ -283,7 +283,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'codepen', 'name'=>'codepen',
'label'=>'Codepen', 'label'=>'Codepen',
'value'=>$Site->codepen(), 'value'=>$site->codepen(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'' 'tip'=>''
@ -292,7 +292,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'googlePlus', 'name'=>'googlePlus',
'label'=>'Google+', 'label'=>'Google+',
'value'=>$Site->googlePlus(), 'value'=>$site->googlePlus(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'' 'tip'=>''
@ -301,7 +301,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'instagram', 'name'=>'instagram',
'label'=>'Instagram', 'label'=>'Instagram',
'value'=>$Site->instagram(), 'value'=>$site->instagram(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'' 'tip'=>''
@ -310,7 +310,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'gitlab', 'name'=>'gitlab',
'label'=>'Gitlab', 'label'=>'Gitlab',
'value'=>$Site->gitlab(), 'value'=>$site->gitlab(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'' 'tip'=>''
@ -319,7 +319,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'github', 'name'=>'github',
'label'=>'Github', 'label'=>'Github',
'value'=>$Site->github(), 'value'=>$site->github(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'' 'tip'=>''
@ -328,7 +328,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'linkedin', 'name'=>'linkedin',
'label'=>'Linkedin', 'label'=>'Linkedin',
'value'=>$Site->linkedin(), 'value'=>$site->linkedin(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>'' 'tip'=>''
@ -351,7 +351,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
'name'=>'language', 'name'=>'language',
'label'=>$L->g('Language'), 'label'=>$L->g('Language'),
'options'=>$Language->getLanguageList(), 'options'=>$Language->getLanguageList(),
'selected'=>$Site->language(), 'selected'=>$site->language(),
'class'=>'', 'class'=>'',
'tip'=>$L->g('select-your-sites-language') 'tip'=>$L->g('select-your-sites-language')
)); ));
@ -360,7 +360,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
'name'=>'timezone', 'name'=>'timezone',
'label'=>$L->g('Timezone'), 'label'=>$L->g('Timezone'),
'options'=>Date::timezoneList(), 'options'=>Date::timezoneList(),
'selected'=>$Site->timezone(), 'selected'=>$site->timezone(),
'class'=>'', 'class'=>'',
'tip'=>$L->g('select-a-timezone-for-a-correct') 'tip'=>$L->g('select-a-timezone-for-a-correct')
)); ));
@ -368,7 +368,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'locale', 'name'=>'locale',
'label'=>$L->g('Locale'), 'label'=>$L->g('Locale'),
'value'=>$Site->locale(), 'value'=>$site->locale(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>$L->g('with-the-locales-you-can-set-the-regional-user-interface') 'tip'=>$L->g('with-the-locales-you-can-set-the-regional-user-interface')
@ -379,10 +379,10 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'dateFormat', 'name'=>'dateFormat',
'label'=>$L->g('Date format'), 'label'=>$L->g('Date format'),
'value'=>$Site->dateFormat(), 'value'=>$site->dateFormat(),
'class'=>'', 'class'=>'',
'placeholder'=>'', 'placeholder'=>'',
'tip'=>$L->g('Current format').': '.Date::current($Site->dateFormat()) 'tip'=>$L->g('Current format').': '.Date::current($site->dateFormat())
)); ));
echo ' echo '

View File

@ -17,13 +17,13 @@ echo '
foreach ($themes as $theme) { foreach ($themes as $theme) {
echo ' echo '
<tr '.($theme['dirname']==$Site->theme()?'class="bg-light"':'').'> <tr '.($theme['dirname']==$site->theme()?'class="bg-light"':'').'>
<td class="align-middle pt-3 pb-3"> <td class="align-middle pt-3 pb-3">
<div>'.$theme['name'].'</div> <div>'.$theme['name'].'</div>
<div class="mt-1"> <div class="mt-1">
'; ';
if ($theme['dirname']!=$Site->theme()) { if ($theme['dirname']!=$site->theme()) {
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'">'.$L->g('Activate').'</a>'; echo '<a href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'">'.$L->g('Activate').'</a>';
} }

View File

@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(

View File

@ -6,7 +6,7 @@ if (Session::started()===false) {
exit('Bludit CMS. Session initialization failure.'); exit('Bludit CMS. Session initialization failure.');
} }
$login = $Login = new Login($dbUsers); $login = $Login = new Login();
$layout = array( $layout = array(
'controller'=>null, 'controller'=>null,
@ -18,7 +18,7 @@ $layout = array(
); );
// Get the view, controller, and the parameters from the URL. // Get the view, controller, and the parameters from the URL.
$explodeSlug = $Url->explodeSlug(); $explodeSlug = $url->explodeSlug();
$layout['controller'] = $layout['view'] = $layout['slug'] = empty($explodeSlug[0])?'dashboard':$explodeSlug[0]; $layout['controller'] = $layout['view'] = $layout['slug'] = empty($explodeSlug[0])?'dashboard':$explodeSlug[0];
unset($explodeSlug[0]); unset($explodeSlug[0]);
$layout['parameters'] = implode('/', $explodeSlug); $layout['parameters'] = implode('/', $explodeSlug);
@ -62,18 +62,18 @@ else
// User not logged. // User not logged.
// Slug is login. // Slug is login.
// Slug is login-email. // Slug is login-email.
if($Url->notFound() || !$login->isLogged() || ($Url->slug()==='login') || ($Url->slug()==='login-email') ) { if($url->notFound() || !$login->isLogged() || ($url->slug()==='login') || ($url->slug()==='login-email') ) {
$layout['controller'] = 'login'; $layout['controller'] = 'login';
$layout['view'] = 'login'; $layout['view'] = 'login';
$layout['template'] = 'login.php'; $layout['template'] = 'login.php';
if ($Url->slug()==='login-email') { if ($url->slug()==='login-email') {
$layout['controller'] = 'login-email'; $layout['controller'] = 'login-email';
$layout['view'] = 'login-email'; $layout['view'] = 'login-email';
} }
// Generate the tokenCSRF for the user not logged, when the user log-in the token will be change. // Generate the tokenCSRF for the user not logged, when the user log-in the token will be change.
$Security->generateTokenCSRF(); $security->generateTokenCSRF();
} }
// Define variables // Define variables
@ -84,8 +84,8 @@ else
Theme::plugins('beforeAdminLoad'); Theme::plugins('beforeAdminLoad');
// Load init.php if the theme has one. // Load init.php if the theme has one.
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().DS.'init.php') ) { if( Sanitize::pathFile(PATH_ADMIN_THEMES, $site->adminTheme().DS.'init.php') ) {
include(PATH_ADMIN_THEMES.$Site->adminTheme().DS.'init.php'); include(PATH_ADMIN_THEMES.$site->adminTheme().DS.'init.php');
} }
// Load controller. // Load controller.
@ -94,8 +94,8 @@ else
} }
// Load view and theme. // Load view and theme.
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().DS.$layout['template']) ) { if( Sanitize::pathFile(PATH_ADMIN_THEMES, $site->adminTheme().DS.$layout['template']) ) {
include(PATH_ADMIN_THEMES.$Site->adminTheme().DS.$layout['template']); include(PATH_ADMIN_THEMES.$site->adminTheme().DS.$layout['template']);
} }
// Load plugins after the admin area is loaded. // Load plugins after the admin area is loaded.

View File

@ -86,6 +86,7 @@ include(PATH_KERNEL.'dbsite.class.php');
include(PATH_KERNEL.'dbcategories.class.php'); include(PATH_KERNEL.'dbcategories.class.php');
include(PATH_KERNEL.'dbsyslog.class.php'); include(PATH_KERNEL.'dbsyslog.class.php');
include(PATH_KERNEL.'page.class.php'); include(PATH_KERNEL.'page.class.php');
include(PATH_KERNEL.'pagex.class.php');
include(PATH_KERNEL.'category.class.php'); include(PATH_KERNEL.'category.class.php');
include(PATH_KERNEL.'tag.class.php'); include(PATH_KERNEL.'tag.class.php');
include(PATH_KERNEL.'user.class.php'); include(PATH_KERNEL.'user.class.php');
@ -119,22 +120,15 @@ if (file_exists(PATH_KERNEL.'bludit.pro.php')) {
include(PATH_KERNEL.'bludit.pro.php'); include(PATH_KERNEL.'bludit.pro.php');
} }
// Session
// Session::start();
// if (Session::started()===false) {
// exit('Bludit CMS. Session initialization failure.');
// }
// Objects // Objects
$dbPages = new dbPages(); $pages = $dbPages = new dbPages(); // DEPRECATED v3.0.0 $dbPages
$dbUsers = new dbUsers(); $dbUsers = new dbUsers();
$dbTags = new dbTags(); $dbTags = new dbTags();
$dbCategories = new dbCategories(); $dbCategories = new dbCategories();
$site = $Site = new dbSite(); $site = new dbSite();
$url = $Url = new Url(); $url = new Url();
$parsedown = $Parsedown = new Parsedown(); $security = new Security();
$security = $Security = new Security(); $syslog = new dbSyslog();
$syslog = $syslog = new dbSyslog();
// --- Relative paths --- // --- Relative paths ---
// This paths are relative for the user / web browsing. // This paths are relative for the user / web browsing.
@ -164,12 +158,12 @@ if (strpos($_SERVER['REQUEST_URI'], $base)!==0) {
define('HTML_PATH_ROOT', $base); define('HTML_PATH_ROOT', $base);
define('HTML_PATH_THEMES', HTML_PATH_ROOT.'bl-themes/'); define('HTML_PATH_THEMES', HTML_PATH_ROOT.'bl-themes/');
define('HTML_PATH_THEME', HTML_PATH_THEMES.$Site->theme().'/'); define('HTML_PATH_THEME', HTML_PATH_THEMES.$site->theme().'/');
define('HTML_PATH_THEME_CSS', HTML_PATH_THEME.'css/'); define('HTML_PATH_THEME_CSS', HTML_PATH_THEME.'css/');
define('HTML_PATH_THEME_JS', HTML_PATH_THEME.'js/'); define('HTML_PATH_THEME_JS', HTML_PATH_THEME.'js/');
define('HTML_PATH_THEME_IMG', HTML_PATH_THEME.'img/'); define('HTML_PATH_THEME_IMG', HTML_PATH_THEME.'img/');
define('HTML_PATH_ADMIN_ROOT', HTML_PATH_ROOT.ADMIN_URI_FILTER.'/'); define('HTML_PATH_ADMIN_ROOT', HTML_PATH_ROOT.ADMIN_URI_FILTER.'/');
define('HTML_PATH_ADMIN_THEME', HTML_PATH_ROOT.'bl-kernel/admin/themes/'.$Site->adminTheme().'/'); define('HTML_PATH_ADMIN_THEME', HTML_PATH_ROOT.'bl-kernel/admin/themes/'.$site->adminTheme().'/');
define('HTML_PATH_ADMIN_THEME_JS', HTML_PATH_ADMIN_THEME.'js/'); define('HTML_PATH_ADMIN_THEME_JS', HTML_PATH_ADMIN_THEME.'js/');
define('HTML_PATH_ADMIN_THEME_CSS', HTML_PATH_ADMIN_THEME.'css/'); define('HTML_PATH_ADMIN_THEME_CSS', HTML_PATH_ADMIN_THEME.'css/');
define('HTML_PATH_ADMIN_THEME_IMG', HTML_PATH_ADMIN_THEME.'img/'); define('HTML_PATH_ADMIN_THEME_IMG', HTML_PATH_ADMIN_THEME.'img/');
@ -182,32 +176,32 @@ define('HTML_PATH_UPLOADS_THUMBNAILS', HTML_PATH_UPLOADS.'thumbnails/');
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/'); define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/');
// --- Objects with dependency --- // --- Objects with dependency ---
$language = $Language = new dbLanguage( $Site->language() ); $language = $Language = new dbLanguage( $site->language() );
$Url->checkFilters( $Site->uriFilters() ); $url->checkFilters( $site->uriFilters() );
// --- CONSTANTS with dependency --- // --- CONSTANTS with dependency ---
// Tag URI filter // Tag URI filter
define('TAG_URI_FILTER', $Url->filters('tag')); define('TAG_URI_FILTER', $url->filters('tag'));
// Category URI filter // Category URI filter
define('CATEGORY_URI_FILTER', $Url->filters('category')); define('CATEGORY_URI_FILTER', $url->filters('category'));
// Page URI filter // Page URI filter
define('PAGE_URI_FILTER', $Url->filters('page')); define('PAGE_URI_FILTER', $url->filters('page'));
// Content order by: date / position // Content order by: date / position
define('ORDER_BY', $Site->orderBy()); define('ORDER_BY', $site->orderBy());
// Allow unicode characters in the URL // Allow unicode characters in the URL
define('EXTREME_FRIENDLY_URL', $Site->extremeFriendly()); define('EXTREME_FRIENDLY_URL', $site->extremeFriendly());
// Minutes to execute the autosave function // Minutes to execute the autosave function
define('AUTOSAVE_INTERVAL', $Site->autosaveInterval()); define('AUTOSAVE_INTERVAL', $site->autosaveInterval());
// --- PHP paths with dependency --- // --- PHP paths with dependency ---
// This paths are absolutes for the OS // This paths are absolutes for the OS
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS); define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$site->theme().DS);
define('THEME_DIR_PHP', THEME_DIR.'php'.DS); define('THEME_DIR_PHP', THEME_DIR.'php'.DS);
define('THEME_DIR_CSS', THEME_DIR.'css'.DS); define('THEME_DIR_CSS', THEME_DIR.'css'.DS);
define('THEME_DIR_JS', THEME_DIR.'js'.DS); define('THEME_DIR_JS', THEME_DIR.'js'.DS);
@ -216,7 +210,7 @@ define('THEME_DIR_LANG', THEME_DIR.'languages'.DS);
// --- Absolute paths with domain --- // --- Absolute paths with domain ---
// This paths are absolutes for the user / web browsing. // This paths are absolutes for the user / web browsing.
define('DOMAIN', $Site->domain()); define('DOMAIN', $site->domain());
define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT); define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT);
define('DOMAIN_CORE_JS', DOMAIN.HTML_PATH_CORE_JS); define('DOMAIN_CORE_JS', DOMAIN.HTML_PATH_CORE_JS);
define('DOMAIN_CORE_CSS', DOMAIN.HTML_PATH_CORE_CSS); define('DOMAIN_CORE_CSS', DOMAIN.HTML_PATH_CORE_CSS);
@ -242,7 +236,7 @@ define('DOMAIN_PAGES', Text::addSlashes(DOMAIN_BASE.PAGE_URI_FILTER, false, tr
$ADMIN_CONTROLLER = ''; $ADMIN_CONTROLLER = '';
$ADMIN_VIEW = ''; $ADMIN_VIEW = '';
$ID_EXECUTION = uniqid(); // string 13 characters long $ID_EXECUTION = uniqid(); // string 13 characters long
$WHERE_AM_I = $Url->whereAmI(); $WHERE_AM_I = $url->whereAmI();
// --- Objects shortcuts --- // --- Objects shortcuts ---
$L = $language; $L = $language;

View File

@ -51,7 +51,7 @@ function buildPlugins()
global $plugins; global $plugins;
global $pluginsEvents; global $pluginsEvents;
global $Language; global $Language;
global $Site; global $site;
// List plugins directories // List plugins directories
$list = Filesystem::listDirectories(PATH_PLUGINS); $list = Filesystem::listDirectories(PATH_PLUGINS);
@ -74,7 +74,7 @@ function buildPlugins()
$Plugin = new $pluginClass; $Plugin = new $pluginClass;
// Check if the plugin is translated // Check if the plugin is translated
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->language().'.json'; $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$site->language().'.json';
if( !Sanitize::pathFile($languageFilename) ) { if( !Sanitize::pathFile($languageFilename) ) {
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.DEFAULT_LANGUAGE_FILE; $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.DEFAULT_LANGUAGE_FILE;
} }

View File

@ -14,59 +14,10 @@
N => Page Object N => Page Object
) )
*/ */
$content = $pages = array(); $content = array();
// Page filtered by the user, is a Page Object // Page filtered by the user, is a Page Object
$page = $Page = false; $page = false;
// Array with pages order by parent
// Sorted by position or date
/*
array(
PARENT => array(
0 => Page Object,
...,
N => Page Object),
"parentKey1" => array(
0 => Page Object,
...,
N => Page Object),
"parentKey2" => array(
0 => Page Object,
...,
N => Page Object),
...
"parentKeyN" => array(
0 => Page Object,
...,
N => Page Object),
)
*/
//$pagesByParent = array(PARENT=>array()); // DEPREACTED
// Array with pages order by parent and by key
/*
array(
PARENT => array(
"parentKey1" => Page Object,
...,
"parentKeyN" => Page Object),
"parentKey1" => array(
"childKeyA" => Page Object,
...,
"childKeyB" => Page Object),
"parentKey2" => array(
"childKeyJ" => Page Object,
...,
"childKeyO" => Page Object),
...
"parentKeyN" => array(
"childKeyW" => Page Object,
...,
"childKeyZ" => Page Object),
)
*/
//$pagesByParentByKey = array(PARENT=>array()); // DEPREACTED
// Array with static content, each item is a Page Object // Array with static content, each item is a Page Object
// Order by position // Order by position
@ -86,10 +37,7 @@ $staticContent = $staticPages = buildStaticPages();
// Execute the scheduler // Execute the scheduler
if ($dbPages->scheduler()) { if ($dbPages->scheduler()) {
// Reindex tags
reindexTags(); reindexTags();
// Reindex categories
reindexCategories(); reindexCategories();
// Add to syslog // Add to syslog
@ -99,45 +47,37 @@ if ($dbPages->scheduler()) {
)); ));
} }
// Generate pages parent tree, only published pages // Set home page if the user defined them
//buildPagesByParent(true, true); if ($site->homepage() && $url->whereAmI()==='home') {
$pageKey = $site->homepage();
// Set home page is the user defined one
if ($Site->homepage() && $Url->whereAmI()==='home') {
$pageKey = $Site->homepage();
if ($dbPages->exists($pageKey)) { if ($dbPages->exists($pageKey)) {
$Url->setSlug($pageKey); $url->setSlug($pageKey);
$Url->setWhereAmI('page'); $url->setWhereAmI('page');
} }
} }
// Build specific page // Build specific page
if ($Url->whereAmI()==='page') { if ($url->whereAmI()==='page') {
buildThePage(); $content[0] = $page = buildThePage();
} }
// Build content by tag // Build content by tag
elseif ($Url->whereAmI()==='tag') { elseif ($url->whereAmI()==='tag') {
buildPagesByTag(); $content = buildPagesByTag();
} }
// Build content by category // Build content by category
elseif ($Url->whereAmI()==='category') { elseif ($url->whereAmI()==='category') {
buildPagesByCategory(); $content = buildPagesByCategory();
} }
// Build content for the homepage // Build content for the homepage
elseif ( ($Url->whereAmI()==='home') || ($Url->whereAmI()==='blog') ) { elseif ( ($url->whereAmI()==='home') || ($url->whereAmI()==='blog') ) {
buildPagesForHome(); $content = buildPagesForHome();
} }
if (isset($pages[0])) { if (isset($content[0])) {
$page = $Page = $pages[0]; $page = $content[0];
} }
// Set page 404 not found // If set notFound, create the page 404
if ($Url->notFound()) { if ($url->notFound()) {
$pageNotFoundKey = $Site->pageNotFound(); $content[0] = $page = buildErrorPage();
$page = buildPage( $pageNotFoundKey );
if ($page===false) {
$page = buildErrorPage();
}
$content[0] = $pages[0] = $Page = $page;
} }

View File

@ -1,3 +1,3 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
header('HTTP/1.0 '.$Url->httpCode().' '.$Url->httpMessage()); header('HTTP/1.0 '.$url->httpCode().' '.$url->httpMessage());

View File

@ -1,25 +1,25 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
// Current page number // Current page number
$currentPage = $Url->pageNumber(); $currentPage = $url->pageNumber();
Paginator::set('currentPage', $currentPage); Paginator::set('currentPage', $currentPage);
if($Url->whereAmI()=='admin') { if($url->whereAmI()=='admin') {
$itemsPerPage = ITEMS_PER_PAGE_ADMIN; $itemsPerPage = ITEMS_PER_PAGE_ADMIN;
$amountOfItems = $dbPages->count(true); $amountOfItems = $dbPages->count(true);
} }
elseif($Url->whereAmI()=='tag') { elseif($url->whereAmI()=='tag') {
$itemsPerPage = $Site->itemsPerPage(); $itemsPerPage = $site->itemsPerPage();
$tagKey = $Url->slug(); $tagKey = $url->slug();
$amountOfItems = $dbTags->countPagesByTag($tagKey); $amountOfItems = $dbTags->countPagesByTag($tagKey);
} }
elseif($Url->whereAmI()=='category') { elseif($url->whereAmI()=='category') {
$itemsPerPage = $Site->itemsPerPage(); $itemsPerPage = $site->itemsPerPage();
$categoryKey = $Url->slug(); $categoryKey = $url->slug();
$amountOfItems = $dbCategories->countPagesByCategory($categoryKey); $amountOfItems = $dbCategories->countPagesByCategory($categoryKey);
} }
else { else {
$itemsPerPage = $Site->itemsPerPage(); $itemsPerPage = $site->itemsPerPage();
$amountOfItems = $dbPages->count(true); $amountOfItems = $dbPages->count(true);
} }

View File

@ -19,7 +19,7 @@
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
$token = isset($_POST['tokenCSRF']) ? Sanitize::html($_POST['tokenCSRF']) : false; $token = isset($_POST['tokenCSRF']) ? Sanitize::html($_POST['tokenCSRF']) : false;
if( !$Security->validateTokenCSRF($token) ) { if( !$security->validateTokenCSRF($token) ) {
Log::set(__FILE__.LOG_SEP.'Error occurred when trying to validate the tokenCSRF. Token CSRF ID: '.$token); Log::set(__FILE__.LOG_SEP.'Error occurred when trying to validate the tokenCSRF. Token CSRF ID: '.$token);
Session::destroy(); Session::destroy();
Redirect::page('login'); Redirect::page('login');

View File

@ -10,7 +10,7 @@
function buildThemes() function buildThemes()
{ {
global $Site; global $site;
$themes = array(); $themes = array();
$themesPaths = Filesystem::listDirectories(PATH_THEMES); $themesPaths = Filesystem::listDirectories(PATH_THEMES);
@ -18,7 +18,7 @@ function buildThemes()
foreach($themesPaths as $themePath) foreach($themesPaths as $themePath)
{ {
// Check if the theme is translated. // Check if the theme is translated.
$languageFilename = $themePath.DS.'languages'.DS.$Site->language().'.json'; $languageFilename = $themePath.DS.'languages'.DS.$site->language().'.json';
if( !Sanitize::pathFile($languageFilename) ) { if( !Sanitize::pathFile($languageFilename) ) {
$languageFilename = $themePath.DS.'languages'.DS.DEFAULT_LANGUAGE_FILE; $languageFilename = $themePath.DS.'languages'.DS.DEFAULT_LANGUAGE_FILE;
} }
@ -70,7 +70,7 @@ function buildThemes()
// ============================================================================ // ============================================================================
// Load the language file // Load the language file
$languageFilename = THEME_DIR.'languages'.DS.$Site->language().'.json'; $languageFilename = THEME_DIR.'languages'.DS.$site->language().'.json';
if( !Sanitize::pathFile($languageFilename) ) { if( !Sanitize::pathFile($languageFilename) ) {
$languageFilename = THEME_DIR.'languages'.DS.DEFAULT_LANGUAGE_FILE; $languageFilename = THEME_DIR.'languages'.DS.DEFAULT_LANGUAGE_FILE;
} }

View File

@ -16,13 +16,13 @@ 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');
} }

File diff suppressed because one or more lines are too long

View File

@ -1,29 +1,26 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
class dbPages extends dbJSON class dbPages extends dbJSON {
{
private $parentKeyList = array();
private $parentKeyList = array();
private $dbFields = array( private $dbFields = array(
'title'=> array('inFile'=>true, 'value'=>''), 'title'=>'',
'content'=> array('inFile'=>true, 'value'=>''), 'description'=>'',
'description'=> array('inFile'=>false, 'value'=>''), 'username'=>'',
'username'=> array('inFile'=>false, 'value'=>''), 'tags'=>array(),
'tags'=> array('inFile'=>false, 'value'=>array()), 'type'=>'published', // published, draft, sticky, scheduled
'status'=> array('inFile'=>false, 'value'=>'published'), // published, draft, sticky, scheduled 'date'=>'',
'type'=> array('inFile'=>false, 'value'=>'post'), // post, page 'dateModified'=>'',
'date'=> array('inFile'=>false, 'value'=>''), 'position'=>0,
'dateModified'=> array('inFile'=>false, 'value'=>''), 'coverImage'=>'',
'position'=> array('inFile'=>false, 'value'=>0), 'category'=>'',
'coverImage'=> array('inFile'=>false, 'value'=>''), 'md5file'=>'',
'category'=> array('inFile'=>false, 'value'=>''), 'uuid'=>'',
'md5file'=> array('inFile'=>false, 'value'=>''), 'allowComments'=>true,
'uuid'=> array('inFile'=>false, 'value'=>''), 'template'=>'',
'allowComments'=> array('inFile'=>false, 'value'=>true), 'noindex'=>false,
'template'=> array('inFile'=>false, 'value'=>''), 'nofollow'=>false,
'noindex'=> array('inFile'=>false, 'value'=>false), 'noarchive'=>false
'nofollow'=> array('inFile'=>false, 'value'=>false),
'noarchive'=> array('inFile'=>false, 'value'=>false)
); );
function __construct() function __construct()
@ -31,35 +28,35 @@ class dbPages extends dbJSON
parent::__construct(DB_PAGES); parent::__construct(DB_PAGES);
} }
public function getDefaultFields()
{
return $this->dbFields;
}
// Create a new page // Create a new page
// This function returns the key of the new page // This function returns the key of the new page
public function add($args, $climode=false) public function add($args, $climode=false)
{ {
$dataForDb = array(); // This data will be saved in the database $row = array();
$dataForFile = array(); // This data will be saved in the file
// Check values on args or set default values // Check values on args or set default values
foreach ($this->dbFields as $field=>$options) { foreach ($this->dbFields as $field=>$value) {
if (isset($args[$field])) { if (isset($args[$field])) {
if ($options['inFile'] || is_array($args[$field])) {
$value = $args[$field];
} else {
// Sanitize if will be stored on database // Sanitize if will be stored on database
$value = Sanitize::html($args[$field]); $finalValue = Sanitize::html($args[$field]);
}
} else { } else {
// Default value for the field // Default value for the field if not defined
$value = $options['value']; $finalValue = $value;
} }
settype($finalValue, gettype($value));
$args[$field] = $value; $row[$field] = $finalValue;
} }
// Tags // Tags
if (!empty($args['tags'])) { if (!empty($args['tags'])) {
$args['tags'] = $this->generateTags($args['tags']); $row['tags'] = $this->generateTags($args['tags']);
} else { } else {
$args['tags'] = array(); $row['tags'] = array();
} }
// Slug from the title or the content // Slug from the title or the content
@ -73,7 +70,7 @@ class dbPages extends dbJSON
// Parent // Parent
if (!isset($args['parent'])) { if (!isset($args['parent'])) {
$args['parent'] = ''; $row['parent'] = '';
} }
// Generate key // Generate key
@ -81,60 +78,38 @@ class dbPages extends dbJSON
// Generate UUID // Generate UUID
if (empty($args['uuid'])) { if (empty($args['uuid'])) {
$args['uuid'] = $this->generateUUID(); $row['uuid'] = $this->generateUUID();
} }
// Validate date // Validate date
if (!Valid::date($args['date'], DB_DATE_FORMAT)) { if (!Valid::date($args['date'], DB_DATE_FORMAT)) {
$args['date'] = Date::current(DB_DATE_FORMAT); $row['date'] = Date::current(DB_DATE_FORMAT);
} }
// Schedule page // Schedule page
if (($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['status']=='published')) { if (($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['type']=='published')) {
$args['status'] = 'scheduled'; $row['type'] = 'scheduled';
}
// Set type of the page
if ($args['status']=='static') {
$args['type'] = 'page';
}
// Set type to the variables
foreach ($this->dbFields as $field=>$options) {
$value = $args[$field];
if ($options['inFile']) {
// Save on file
$dataForFile[$field] = $this->stylingFieldsForFile($field, $value);
} else {
// Set type
settype($value, gettype($options['value']));
// Save on database
$dataForDb[$field] = $value;
}
} }
if ($climode===false) { if ($climode===false) {
// Create the directory // Create the directory
if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) { if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_PAGES.$key); Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory ['.PATH_PAGES.$key.']',LOG_TYPE_ERROR);
return false; return false;
} }
// Make the index.txt and save the file. // Create the index.txt and save the file
$data = implode(PHP_EOL, $dataForFile); if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $args['content']) === false ) {
if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $data) === false ) { Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the content in the file ['.FILENAME.']',LOG_TYPE_ERROR);
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
return false; return false;
} }
} }
// Checksum MD5 // Checksum MD5
$dataForDb['md5file'] = md5_file(PATH_PAGES.$key.DS.FILENAME); $row['md5file'] = md5_file(PATH_PAGES.$key.DS.FILENAME);
// Insert in database // Insert in database
$this->db[$key] = $dataForDb; $this->db[$key] = $row;
// Sort database // Sort database
$this->sortBy(); $this->sortBy();
@ -147,78 +122,48 @@ class dbPages extends dbJSON
public function edit($args, $climode=false) public function edit($args, $climode=false)
{ {
$dataForDb = array(); $row = array();
$dataForFile = array();
// Check values on args or set default values // Check values on args or set default values
foreach ($this->dbFields as $field=>$options) { foreach ($this->dbFields as $field=>$value) {
if (isset($args[$field])) { if (isset($args[$field])) {
if ($options['inFile'] || is_array($args[$field])) {
$value = $args[$field];
} else {
// Sanitize if will be stored on database // Sanitize if will be stored on database
$value = Sanitize::html($args[$field]); $finalValue = Sanitize::html($args[$field]);
}
} else { } else {
// By default is the current value // Default value for the field if not defined
if (isset($this->db[$args['key']][$field])) { $finalValue = $value;
$value = $this->db[$args['key']][$field];
} else {
$value = $options['value'];
} }
} settype($finalValue, gettype($value));
$row[$field] = $finalValue;
$args[$field] = $value;
} }
// Tags // Tags
if (!empty($args['tags'])) { if (!empty($args['tags'])) {
$args['tags'] = $this->generateTags($args['tags']); $row['tags'] = $this->generateTags($args['tags']);
} else { } else {
$args['tags'] = array(); $row['tags'] = array();
} }
// Parent // Parent
if (!isset($args['parent'])) { if (!isset($args['parent'])) {
$args['parent'] = ''; $row['parent'] = '';
} }
$newKey = $this->generateKey($args['slug'], $args['parent'], false, $args['key']); $newKey = $this->generateKey($args['slug'], $row['parent'], false, $args['key']);
// If the page is draft then the created time is the current // If the page is draft then the created time is the current
if ($this->db[$args['key']]['status']=='draft') { if ($this->db[$args['key']]['type']=='draft') {
$args['date'] = Date::current(DB_DATE_FORMAT); $row['date'] = Date::current(DB_DATE_FORMAT);
} elseif (!Valid::date($args['date'], DB_DATE_FORMAT)) { } elseif (!Valid::date($args['date'], DB_DATE_FORMAT)) {
$args['date'] = $this->db[$args['key']]['date']; $row['date'] = $this->db[$args['key']]['date'];
} }
// Modified date // Modified date
$args['dateModified'] = Date::current(DB_DATE_FORMAT); $row['dateModified'] = Date::current(DB_DATE_FORMAT);
// Schedule page // Schedule page
if (($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['status']=='published')) { if (($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['type']=='published')) {
$args['status'] = 'scheduled'; $row['type'] = 'scheduled';
}
// Set type of the page
if ($args['status']=='static') {
$args['type'] = 'page';
}
// Set type to the variables
foreach ($this->dbFields as $field=>$options) {
$value = $args[$field];
if ($options['inFile']) {
// Save on file
$dataForFile[$field] = $this->stylingFieldsForFile($field, $value);
} else {
// Set type
settype($value, gettype($options['value']));
// Save on database
$dataForDb[$field] = $value;
}
} }
if ($climode===false) { if ($climode===false) {
@ -231,8 +176,7 @@ class dbPages extends dbJSON
} }
// Make the index.txt and save the file. // Make the index.txt and save the file.
$data = implode("\n", $dataForFile); if (file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $args['content'])===false) {
if (file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $data)===false) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME); Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
return false; return false;
} }
@ -245,10 +189,10 @@ class dbPages extends dbJSON
$this->reindexChildren($args['key'], $newKey); $this->reindexChildren($args['key'], $newKey);
// Checksum MD5 // Checksum MD5
$dataForDb['md5file'] = md5_file(PATH_PAGES.$newKey.DS.FILENAME); $row['md5file'] = md5_file(PATH_PAGES.$newKey.DS.FILENAME);
// Insert in database // Insert in database
$this->db[$newKey] = $dataForDb; $this->db[$newKey] = $row;
// Sort database // Sort database
$this->sortBy(); $this->sortBy();
@ -332,15 +276,14 @@ class dbPages extends dbJSON
return $this->save(); return $this->save();
} }
// Change a field's value // Set field = value
public function setField($key, $field, $value) public function setField($key, $field, $value)
{ {
if ($this->exists($key)) { if ($this->exists($key)) {
settype($value, gettype($this->dbFields[$field]['value'])); settype($value, gettype($this->dbFields[$field]));
$this->db[$key][$field] = $value; $this->db[$key][$field] = $value;
return $this->save(); return $this->save();
} }
return false; return false;
} }
@ -349,7 +292,7 @@ class dbPages extends dbJSON
{ {
$tmp = $this->db; $tmp = $this->db;
foreach ($tmp as $key=>$fields) { foreach ($tmp as $key=>$fields) {
if ($fields['status']!='published') { if ($fields['type']!='published') {
unset($tmp[$key]); unset($tmp[$key]);
} }
} }
@ -365,7 +308,7 @@ class dbPages extends dbJSON
{ {
$tmp = $this->db; $tmp = $this->db;
foreach ($tmp as $key=>$fields) { foreach ($tmp as $key=>$fields) {
if ($fields['status']!='static') { if ($fields['type']!='static') {
unset($tmp[$key]); unset($tmp[$key]);
} }
} }
@ -381,7 +324,7 @@ class dbPages extends dbJSON
{ {
$tmp = $this->db; $tmp = $this->db;
foreach ($tmp as $key=>$fields) { foreach ($tmp as $key=>$fields) {
if($fields['status']!='draft') { if($fields['type']!='draft') {
unset($tmp[$key]); unset($tmp[$key]);
} }
} }
@ -396,7 +339,7 @@ class dbPages extends dbJSON
{ {
$tmp = $this->db; $tmp = $this->db;
foreach ($tmp as $key=>$fields) { foreach ($tmp as $key=>$fields) {
if($fields['status']!='scheduled') { if($fields['type']!='scheduled') {
unset($tmp[$key]); unset($tmp[$key]);
} }
} }
@ -411,7 +354,7 @@ class dbPages extends dbJSON
{ {
$tmp = $this->db; $tmp = $this->db;
foreach ($tmp as $key=>$fields) { foreach ($tmp as $key=>$fields) {
if($fields['status']!='sticky') { if($fields['type']!='sticky') {
unset($tmp[$key]); unset($tmp[$key]);
} }
} }
@ -446,12 +389,12 @@ class dbPages extends dbJSON
// Returns the next page key of the current page key // Returns the next page key of the current page key
public function nextPageKey($currentKey) public function nextPageKey($currentKey)
{ {
if ($this->db[$currentKey]['status']=='published') { if ($this->db[$currentKey]['type']=='published') {
$keys = array_keys($this->db); $keys = array_keys($this->db);
$position = array_search($currentKey, $keys) - 1; $position = array_search($currentKey, $keys) - 1;
if (isset($keys[$position])) { if (isset($keys[$position])) {
$nextKey = $keys[$position]; $nextKey = $keys[$position];
if ($this->db[$nextKey]['status']=='published') { if ($this->db[$nextKey]['type']=='published') {
return $nextKey; return $nextKey;
} }
} }
@ -462,12 +405,12 @@ class dbPages extends dbJSON
// Returns the previous page key of the current page key // Returns the previous page key of the current page key
public function previousPageKey($currentKey) public function previousPageKey($currentKey)
{ {
if ($this->db[$currentKey]['status']=='published') { if ($this->db[$currentKey]['type']=='published') {
$keys = array_keys($this->db); $keys = array_keys($this->db);
$position = array_search($currentKey, $keys) + 1; $position = array_search($currentKey, $keys) + 1;
if (isset($keys[$position])) { if (isset($keys[$position])) {
$prevKey = $keys[$position]; $prevKey = $keys[$position];
if ($this->db[$prevKey]['status']=='published') { if ($this->db[$prevKey]['type']=='published') {
return $prevKey; return $prevKey;
} }
} }
@ -641,13 +584,13 @@ class dbPages extends dbJSON
// The database need to be sorted by date // The database need to be sorted by date
foreach($this->db as $pageKey=>$fields) { foreach($this->db as $pageKey=>$fields) {
if($fields['status']=='scheduled') { if($fields['type']=='scheduled') {
if($fields['date']<=$currentDate) { if($fields['date']<=$currentDate) {
$this->db[$pageKey]['status'] = 'published'; $this->db[$pageKey]['type'] = 'published';
$saveDatabase = true; $saveDatabase = true;
} }
} }
elseif( ($fields['status']=='published') && (ORDER_BY=='date') ) { elseif( ($fields['type']=='published') && (ORDER_BY=='date') ) {
break; break;
} }
} }
@ -780,8 +723,8 @@ class dbPages extends dbJSON
} }
// Status // Status
if( !isset($db['status']) ) { if( !isset($db['type']) ) {
$db['status'] = CLI_STATUS; $db['type'] = CLI_STATUS;
} }
// Owner username // Owner username

View File

@ -308,13 +308,10 @@ class dbSite extends dbJSON
return $homepage; return $homepage;
} }
// Returns the page defined for "Page not found", FALSE if not defined // Returns the page key for the page not found
public function pageNotFound() public function pageNotFound()
{ {
$pageNotFound = $this->getField('pageNotFound'); $pageNotFound = $this->getField('pageNotFound');
if( empty($pageNotFound) ) {
return false;
}
return $pageNotFound; return $pageNotFound;
} }

View File

@ -6,7 +6,7 @@ function buildPage($key) {
global $dbUsers; global $dbUsers;
global $dbCategories; global $dbCategories;
global $Parsedown; global $Parsedown;
global $Site; global $site;
if (empty($key)) { if (empty($key)) {
return false; return false;
@ -34,7 +34,8 @@ function buildPage($key) {
// Parse Markdown // Parse Markdown
$contentRaw = $page->contentRaw(); $contentRaw = $page->contentRaw();
$content = Text::pre2htmlentities($contentRaw); // Parse pre code with htmlentities $content = Text::pre2htmlentities($contentRaw); // Parse pre code with htmlentities
$content = $Parsedown->text($content); // Parse Markdown $parsedown = new Parsedown();
$content = $parsedown->text($content); // Parse Markdown
$content = Text::imgRel2Abs($content, DOMAIN_UPLOADS); // Parse img src relative to absolute (with domain) $content = Text::imgRel2Abs($content, DOMAIN_UPLOADS); // Parse img src relative to absolute (with domain)
$page->setField('content', $content, true); $page->setField('content', $content, true);
@ -47,7 +48,7 @@ function buildPage($key) {
$pageDate = $page->date(); $pageDate = $page->date();
$page->setField('dateRaw', $pageDate, true); $page->setField('dateRaw', $pageDate, true);
$pageDateFormated = $page->dateRaw( $Site->dateFormat() ); $pageDateFormated = $page->dateRaw( $site->dateFormat() );
$page->setField('date', $pageDateFormated, true); $page->setField('date', $pageDateFormated, true);
// Generate and set the User object // Generate and set the User object
@ -82,46 +83,46 @@ function reindexTags() {
return $dbTags->reindex(); return $dbTags->reindex();
} }
// Generate on the fly a 404 page-not-found // Generate the page 404 Not found
// Returns a Page-Object
function buildErrorPage() { function buildErrorPage() {
global $dbPages; global $site;
global $Language; global $language;
global $dbUsers; global $dbUsers;
$page = new Page(false); try {
$page->setField('title', $Language->get('page-not-found')); $pageNotFoundKey = $site->pageNotFound();
$page->setField('content', $Language->get('page-not-found-content')); $pageNotFound = New PageX($pageNotFoundKey);
$page->setField('user', $dbUsers->getUser('admin')); } catch (Exception $e) {
$pageNotFound = New PageX(false);
$pageNotFound->setField('title', $language->get('page-not-found'));
$pageNotFound->setField('content', $language->get('page-not-found-content'));
$pageNotFound->setField('user', $dbUsers->getUser('admin'));
}
return $page; return $pageNotFound;
} }
// This function is only used from the rule 69.pages.php, DO NOT use this function! // This function is only used from the rule 69.pages.php, DO NOT use this function!
// This function generate a particular page from the current slug of the url // This function generate a particular page from the current slug of the url
// The page is stored on the global variable $page
// If the slug has not a page associacted returns FALSE and is set not-found as true // If the slug has not a page associacted returns FALSE and is set not-found as true
function buildThePage() { function buildThePage() {
global $Url; global $url;
global $page, $Page;
global $content, $pages;
$page = $Page = buildPage( $Url->slug() ); try {
$pageKey = $url->slug();
// The page doesn't exist $page = New PageX($pageKey);
if ($page===false) { } catch (Exception $e) {
$Url->setNotFound(); $url->setNotFound();
return false;
}
// The page is NOT published
elseif ( $page->scheduled() || $page->draft() ) {
$Url->setNotFound();
return false; return false;
} }
// The page was generate successfully // Check if the page is NOT published
$content[0] = $pages[0] = $page; if ( !$page->published() ) {
return true; $url->setNotFound();
return false;
}
return $page;
} }
// This function is only used from the rule 69.pages.php, DO NOT use this function! // This function is only used from the rule 69.pages.php, DO NOT use this function!
@ -131,37 +132,36 @@ function buildPagesForHome() {
// This function is only used from the rule 69.pages.php, DO NOT use this function! // This function is only used from the rule 69.pages.php, DO NOT use this function!
function buildPagesByCategory() { function buildPagesByCategory() {
global $Url; global $url;
$categoryKey = $Url->slug(); $categoryKey = $url->slug();
return buildPagesFor('category', $categoryKey, false); return buildPagesFor('category', $categoryKey, false);
} }
// This function is only used from the rule 69.pages.php, DO NOT use this function! // This function is only used from the rule 69.pages.php, DO NOT use this function!
function buildPagesByTag() { function buildPagesByTag() {
global $Url; global $url;
$tagKey = $Url->slug(); $tagKey = $url->slug();
return buildPagesFor('tag', false, $tagKey); return buildPagesFor('tag', false, $tagKey);
} }
// This function is only used from the rule 69.pages.php, DO NOT use this function! // This function is only used from the rule 69.pages.php, DO NOT use this function!
// Generate the global variables $pages / $content, defined on 69.pages.php // Generate the global variables $content / $content, defined on 69.pages.php
// This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag() // This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag()
function buildPagesFor($for, $categoryKey=false, $tagKey=false) { function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
global $dbPages; global $dbPages;
global $dbCategories; global $dbCategories;
global $dbTags; global $dbTags;
global $Site; global $site;
global $Url; global $url;
global $content, $pages;
// Get the page number from URL // Get the page number from URL
$pageNumber = $Url->pageNumber(); $pageNumber = $url->pageNumber();
if ($for=='home') { if ($for=='home') {
$onlyPublished = true; $onlyPublished = true;
$amountOfItems = $Site->itemsPerPage(); $amountOfItems = $site->itemsPerPage();
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); $list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
// Include sticky pages only in the first page // Include sticky pages only in the first page
@ -171,29 +171,30 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
} }
} }
elseif ($for=='category') { elseif ($for=='category') {
$amountOfItems = $Site->itemsPerPage(); $amountOfItems = $site->itemsPerPage();
$list = $dbCategories->getList($categoryKey, $pageNumber, $amountOfItems); $list = $dbCategories->getList($categoryKey, $pageNumber, $amountOfItems);
} }
elseif ($for=='tag') { elseif ($for=='tag') {
$amountOfItems = $Site->itemsPerPage(); $amountOfItems = $site->itemsPerPage();
$list = $dbTags->getList($tagKey, $pageNumber, $amountOfItems); $list = $dbTags->getList($tagKey, $pageNumber, $amountOfItems);
} }
// There are not items, invalid tag, invalid category, out of range, etc... // There are not items, invalid tag, invalid category, out of range, etc...
if ($list===false) { if ($list===false) {
$Url->setNotFound(); $url->setNotFound();
return false; return false;
} }
$pages = array(); // global variable $content = array();
foreach ($list as $pageKey) { foreach ($list as $pageKey) {
$page = buildPage($pageKey); try {
if ($page!==false) { $page = new PageX($pageKey);
array_push($pages, $page); array_push($content, $page);
} catch (Exception $e) {
// continue
} }
} }
$content = $pages; return $content;
return $pages;
} }
// Returns an array with all the static pages as Page-Object // Returns an array with all the static pages as Page-Object
@ -203,9 +204,13 @@ function buildStaticPages() {
$list = array(); $list = array();
$staticPages = $dbPages->getStaticDB(); $staticPages = $dbPages->getStaticDB();
foreach ($staticPages as $pageKey) { foreach ($staticPages as $staticPageKey) {
$staticPage = buildPage($pageKey); try {
$staticPage = new PageX($staticPageKey);
array_push($list, $staticPage); array_push($list, $staticPage);
} catch (Exception $e) {
// continue
}
} }
return $list; return $list;
@ -399,11 +404,13 @@ function createPage($args) {
global $Language; global $Language;
// Check if the autosave page exists for this new page and delete it // Check if the autosave page exists for this new page and delete it
if (isset($args['uuid'])) {
$autosaveKey = $dbPages->getByUUID('autosave-'.$args['uuid']); $autosaveKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
if (!empty($autosaveKey)) { if (!empty($autosaveKey)) {
Log::set('Function createPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO); Log::set('Function createPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
deletePage($autosaveKey); deletePage($autosaveKey);
} }
}
// The user is always the one loggued // The user is always the one loggued
$args['username'] = Session::get('username'); $args['username'] = Session::get('username');
@ -443,11 +450,13 @@ function editPage($args) {
global $syslog; global $syslog;
// Check if the autosave page exists for this new page and delete it // Check if the autosave page exists for this new page and delete it
if (isset($args['uuid'])) {
$pageKey = $dbPages->getByUUID('autosave-'.$args['uuid']); $pageKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
if (!empty($pageKey)) { if (!empty($pageKey)) {
Log::set('Function editPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO); Log::set('Function editPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
deletePage($pageKey); deletePage($pageKey);
} }
}
// Check if the key is not empty // Check if the key is not empty
if (empty($args['key'])) { if (empty($args['key'])) {
@ -656,13 +665,13 @@ function createUser($args) {
} }
function editSettings($args) { function editSettings($args) {
global $Site; global $site;
global $syslog; global $syslog;
global $Language; global $Language;
global $dbPages; global $dbPages;
if (isset($args['language'])) { if (isset($args['language'])) {
if ($args['language']!=$Site->language()) { if ($args['language']!=$site->language()) {
$tmp = new dbJSON(PATH_LANGUAGES.$args['language'].'.json', false); $tmp = new dbJSON(PATH_LANGUAGES.$args['language'].'.json', false);
if (isset($tmp->db['language-data']['locale'])) { if (isset($tmp->db['language-data']['locale'])) {
$args['locale'] = $tmp->db['language-data']['locale']; $args['locale'] = $tmp->db['language-data']['locale'];
@ -690,10 +699,10 @@ function editSettings($args) {
$args['uriBlog'] = ''; $args['uriBlog'] = '';
} }
if ($Site->set($args)) { if ($site->set($args)) {
// Check current order-by if changed it reorder the content // Check current order-by if changed it reorder the content
if ($Site->orderBy()!=ORDER_BY) { if ($site->orderBy()!=ORDER_BY) {
if ($Site->orderBy()=='date') { if ($site->orderBy()=='date') {
$dbPages->sortByDate(); $dbPages->sortByDate();
} else { } else {
$dbPages->sortByPosition(); $dbPages->sortByPosition();
@ -881,11 +890,11 @@ function getTags() {
} }
function activateTheme($themeDirectory) { function activateTheme($themeDirectory) {
global $Site; global $site;
global $syslog; global $syslog;
if (Sanitize::pathFile(PATH_THEMES.$themeDirectory)) { if (Sanitize::pathFile(PATH_THEMES.$themeDirectory)) {
$Site->set(array('theme'=>$themeDirname)); $site->set(array('theme'=>$themeDirname));
$syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'new-theme-configured', 'dictionaryKey'=>'new-theme-configured',

View File

@ -87,16 +87,16 @@ class Paginator {
// Return the absoulte URL with the page number // Return the absoulte URL with the page number
public static function numberUrl($pageNumber) public static function numberUrl($pageNumber)
{ {
global $Url; global $url;
$domain = trim(DOMAIN_BASE,'/'); $domain = trim(DOMAIN_BASE,'/');
$filter = trim($Url->activeFilter(), '/'); $filter = trim($url->activeFilter(), '/');
if(empty($filter)) { if(empty($filter)) {
$url = $domain.'/'.$Url->slug(); $url = $domain.'/'.$url->slug();
} }
else { else {
$url = $domain.'/'.$filter.'/'.$Url->slug(); $url = $domain.'/'.$filter.'/'.$url->slug();
} }
return $url.'?page='.$pageNumber; return $url.'?page='.$pageNumber;

View File

@ -4,26 +4,26 @@ class Theme {
public static function title() public static function title()
{ {
global $Site; global $site;
return $Site->title(); return $site->title();
} }
public static function description() public static function description()
{ {
global $Site; global $site;
return $Site->description(); return $site->description();
} }
public static function slogan() public static function slogan()
{ {
global $Site; global $site;
return $Site->slogan(); return $site->slogan();
} }
public static function footer() public static function footer()
{ {
global $Site; global $site;
return $Site->footer(); return $site->footer();
} }
public static function rssUrl() public static function rssUrl()
@ -44,8 +44,8 @@ class Theme {
public static function siteUrl() public static function siteUrl()
{ {
global $Site; global $site;
return $Site->url(); return $site->url();
} }
public static function adminUrl() public static function adminUrl()
@ -100,11 +100,11 @@ class Theme {
public static function metaTagDescription() public static function metaTagDescription()
{ {
global $Site; global $site;
global $WHERE_AM_I; global $WHERE_AM_I;
global $page; global $page;
$description = $Site->description(); $description = $site->description();
if( $WHERE_AM_I=='page' ) { if( $WHERE_AM_I=='page' ) {
$description = $page->description(); $description = $page->description();
@ -198,7 +198,7 @@ class Theme {
public static function jsBootstrap() public static function jsBootstrap()
{ {
return '<script charset="utf-8" src="'.DOMAIN_CORE_JS.'bootstrap-bundle.min.js?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL; return '<script charset="utf-8" src="'.DOMAIN_CORE_JS.'bootstrap.bundle.min.js?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL;
} }
public static function cssBootstrap() public static function cssBootstrap()

View File

@ -1,65 +0,0 @@
function insertTag() {
var newTag = sanitizeHTML( $("#jstagInput").val() );
if (newTag.trim()=="") {
return true;
}
// Search if the tag exists
var findTag = $("span[data-tag]").filter(function() {
return $(this).attr('data-tag').toLowerCase() == newTag.toLowerCase();
});
// If the tag exits select
// If the tag doesn't exist, insert on the list and select
if (findTag.length > 0) {
findTag.removeClass("unselect").addClass("select");
} else {
$("#jstagList").append("<span data-tag=\""+newTag+"\" class=\"select\">"+newTag+"</span>");
}
// Clean the input field
$("#jstagInput").val("");
return newTag;
}
$(document).ready(function() {
// Click on tag unselected
$(document).on("click", ".unselect", function() {
$(this).removeClass("unselect").addClass("select");
});
// Click on tag selected
$(document).on("click", ".select", function() {
$(this).removeClass("select").addClass("unselect");
});
// Insert tag when click on the button "ADD"
$(document).on("click", "#jstagAdd", function(e) {
// Prevent forum submit
e.preventDefault();
insertTag();
});
// Insert tag when press enter key
$("#jstagInput").keypress(function(e) {
if (e.which == 13) {
insertTag();
}
});
// Before form submit
$("form").submit(function(e) {
// For each span.select make an array then implode with comma glue
var list = $("#jstagList > span.select").map(function() {
return $(this).html();
}).get().join(",");
// Insert the tags separated by comma in the input hidden field
$("#jstags").val( list );
return true;
});
});

File diff suppressed because one or more lines are too long

6
bl-kernel/js/bootstrap.bundle.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -3,76 +3,6 @@
// DEPRECATED // DEPRECATED
// ALL THIS FUNCTIONS ARE DEPREACTED // ALL THIS FUNCTIONS ARE DEPREACTED
var ajaxRequest;
function autosave(title, content) {
var ajaxRequest;
if(ajaxRequest) {
ajaxRequest.abort();
}
ajaxRequest = $.ajax({
type: "POST",
data: {
tokenCSRF: tokenCSRF, // token from env variables
title: title,
content: content
},
url: "<?php echo HTML_PATH_ADMIN_ROOT.'ajax/save-as-draft' ?>"
});
// Callback handler that will be called on success
ajaxRequest.done(function (response, textStatus, jqXHR){
console.log("Autosave done.");
});
// Callback handler that will be called on failure
ajaxRequest.fail(function (jqXHR, textStatus, errorThrown){
console.log("Autosave error on ajax call.");
});
// Callback handler that will be called regardless
// if the request failed or succeeded
ajaxRequest.always(function () {
console.log("Autosave always.");
});
}
function generateSlug(text, parentKey, currentKey, writeResponse) {
if(ajaxRequest) {
ajaxRequest.abort();
}
ajaxRequest = $.ajax({
type: "POST",
data: {
tokenCSRF: tokenCSRF,
text: text,
parentKey: parentKey,
currentKey: currentKey
},
url: "<?php echo HTML_PATH_ADMIN_ROOT.'ajax/slug' ?>"
});
// Callback handler that will be called on success
ajaxRequest.done(function (response, textStatus, jqXHR){
writeResponse.val(response["slug"]);
console.log("DEBUG: AJAX Done function");
});
// Callback handler that will be called on failure
ajaxRequest.fail(function (jqXHR, textStatus, errorThrown){
console.log("DEBUG: AJAX error function");
});
// Callback handler that will be called regardless
// if the request failed or succeeded
ajaxRequest.always(function () {
console.log("DEBUG: AJAX always function");
});
}
function sanitizeHTML(text) { function sanitizeHTML(text) {
var map = { var map = {
'&': '&amp;', '&': '&amp;',

View File

@ -6,18 +6,12 @@ echo 'var HTML_PATH_ADMIN_THEME = "'.HTML_PATH_ADMIN_THEME.'";'.PHP_EOL;
echo 'var HTML_PATH_UPLOADS = "'.HTML_PATH_UPLOADS.'";'.PHP_EOL; echo 'var HTML_PATH_UPLOADS = "'.HTML_PATH_UPLOADS.'";'.PHP_EOL;
echo 'var HTML_PATH_UPLOADS_THUMBNAILS = "'.HTML_PATH_UPLOADS_THUMBNAILS.'";'.PHP_EOL; echo 'var HTML_PATH_UPLOADS_THUMBNAILS = "'.HTML_PATH_UPLOADS_THUMBNAILS.'";'.PHP_EOL;
echo 'var PARENT = "'.PARENT.'";'.PHP_EOL; echo 'var PARENT = "'.PARENT.'";'.PHP_EOL;
echo 'var BLUDIT_VERSION = "'.BLUDIT_VERSION.'";'.PHP_EOL; echo 'var BLUDIT_VERSION = "'.BLUDIT_VERSION.'";'.PHP_EOL;
echo 'var BLUDIT_BUILD = "'.BLUDIT_BUILD.'";'.PHP_EOL; echo 'var BLUDIT_BUILD = "'.BLUDIT_BUILD.'";'.PHP_EOL;
echo 'var DOMAIN_UPLOADS = "'.DOMAIN_UPLOADS.'";'.PHP_EOL; echo 'var DOMAIN_UPLOADS = "'.DOMAIN_UPLOADS.'";'.PHP_EOL;
echo 'var DB_DATE_FORMAT = "'.DB_DATE_FORMAT.'";'.PHP_EOL; echo 'var DB_DATE_FORMAT = "'.DB_DATE_FORMAT.'";'.PHP_EOL;
echo 'var AUTOSAVE_INTERVAL = "'.AUTOSAVE_INTERVAL.'";'.PHP_EOL; echo 'var AUTOSAVE_INTERVAL = "'.AUTOSAVE_INTERVAL.'";'.PHP_EOL;
echo 'var PAGE_BREAK = "'.PAGE_BREAK.'";'.PHP_EOL; echo 'var PAGE_BREAK = "'.PAGE_BREAK.'";'.PHP_EOL;
echo 'var tokenCSRF = "'.$security->getTokenCSRF().'";'.PHP_EOL;
echo 'var tokenCSRF = "'.$Security->getTokenCSRF().'";'.PHP_EOL;
?> ?>

526
bl-kernel/pagex.class.php Normal file
View File

@ -0,0 +1,526 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
class PageX {
private $vars;
function __construct($key)
{
global $dbPages;
$this->vars['key'] = $key;
// If key is FALSE, the page is create with default values, like an empty page
// Useful for Page Not Found
if ($key===false) {
$row = $dbPages->getDefaultFields();
} else {
if (Text::isEmpty($key) || !$dbPages->exists($key)) {
$errorMessage = 'Page not found in database by key ['.$key.']';
Log::set(__METHOD__.LOG_SEP.$errorMessage);
throw new Exception($errorMessage);
}
$row = $dbPages->getPageDB($key);
}
foreach ($row as $field=>$value) {
if ($field=='date') {
$this->setField('dateRaw', $value);
} else {
$this->setField($field, $value);
}
}
}
public function getValue($field)
{
if (isset($this->vars[$field])) {
return $this->vars[$field];
}
return false;
}
// Set a field with a value
public function setField($field, $value)
{
$this->vars[$field] = $value;
return true;
}
// Returns the raw content
// This content is not markdown parser
// (boolean) $sanitize, TRUE returns the content sanitized
public function contentRaw($sanitize=false)
{
$key = $this->key();
$filePath = PATH_PAGES.$key.DS.FILENAME;
$contentRaw = file_get_contents($filePath);
if ($sanitize) {
return Sanitize::html($contentRaw);
}
return $contentRaw;
}
// Returns the content
// This content is markdown parser
// (boolean) $fullContent, TRUE returns all content, if FALSE returns the first part of the content
// (boolean) $noSanitize, TRUE returns the content without sanitized
public function content($sanitize=false)
{
// If already set the content, return it
if (!empty($this->getValue('content'))) {
return $this->getValue('content');
}
$contentRaw = $this->contentRaw();
// Parse pre code with htmlentities
$content = Text::pre2htmlentities($contentRaw);
// Parse Markdown
$parsedown = new Parsedown();
$content = $parsedown->text($content);
// Parse img src relative to absolute (with domain)
$content = Text::imgRel2Abs($content, DOMAIN_UPLOADS);
if ($sanitize) {
return Sanitize::html($content);
}
return $content;
}
// Returns the first part of the content if the content is splited, otherwise is returned the full content
public function contentBreak()
{
$content = $this->content();
$explode = explode(PAGE_BREAK, $content);
return $explode[0];
}
// Returns the date according to locale settings and the format defined in the system
public function date($format=false)
{
$dateRaw = $this->dateRaw();
if ($format===false) {
global $site;
$format = $site->dateFormat();
}
return Date::format($dateRaw, DB_DATE_FORMAT, $format);
}
// Returns the date according to locale settings and format as database stored
public function dateRaw()
{
// This field is set in the constructor
return $this->getValue('dateRaw');
}
// Returns the date according to locale settings and format settings
public function dateModified()
{
return $this->getValue('dateModified');
}
// Returns the username who created the page
public function username()
{
return $this->getValue('username');
}
// TODO: Check if necessary this function
public function getDB()
{
return $this->vars;
}
// Returns the permalink
// (boolean) $absolute, TRUE returns the page link with the DOMAIN, FALSE without the DOMAIN
public function permalink($absolute=true)
{
// Get the key of the page
$key = $this->key();
if($absolute) {
return DOMAIN_PAGES.$key;
}
return HTML_PATH_ROOT.PAGE_URI_FILTER.$key;
}
// Returns the previous page key
public function previousKey()
{
global $dbPages;
return $dbPages->previousPageKey($key);
}
// Returns the next page key
public function nextKey()
{
global $dbPages;
return $dbPages->nextPageKey($key);
}
// Returns the category name
public function category()
{
return $this->categoryMap('name');
}
// Returns the category name
public function categoryTemplate()
{
return $this->categoryMap('template');
}
// Returns the category key
public function categoryKey()
{
return $this->getValue('category');
}
// Returns the category permalink
public function categoryPermalink()
{
return DOMAIN_CATEGORIES.$this->categoryKey();
}
// Returns the field from the array
// categoryMap = array( 'name'=>'', 'list'=>array() )
public function categoryMap($field)
{
global $dbCategories;
$categoryKey = $this->categoryKey();
$map = $dbCategories->getMap($categoryKey);
if ($field=='key') {
return $this->categoryKey();
} elseif($field=='name') {
return $map['name'];
} elseif($field=='list') {
return $map['list'];
}
return false;
}
// Returns the user object
public function user()
{
global $dbUsers;
$username = $this->username();
return $dbUsers->getUser($username);
}
public function template()
{
return $this->getValue('template');
}
// Returns the description field
public function description()
{
return $this->getValue('description');
}
// Returns the tags separated by comma
// (boolean) $returnsArray, TRUE to get the tags as an array, FALSE to get the tags separeted by comma
public function tags($returnsArray=false)
{
$tags = $this->getValue('tags');
if($returnsArray) {
if($tags==false) {
return array();
}
return $tags;
}
else {
if($tags==false) {
return false;
}
// Return string with tags separeted by comma.
return implode(', ', $tags);
}
}
public function json($returnsArray=false)
{
$tmp['key'] = $this->key();
$tmp['title'] = $this->title();
$tmp['content'] = $this->content(); // Markdown parsed
$tmp['contentRaw'] = $this->contentRaw(true); // No Markdown parsed
$tmp['description'] = $this->description();
$tmp['date'] = $this->dateRaw();
$tmp['dateUTC'] = Date::convertToUTC($this->dateRaw(), DB_DATE_FORMAT, DB_DATE_FORMAT);
$tmp['permalink'] = $this->permalink(true);
$tmp['coverImage'] = $this->coverImage(true);
$tmp['coverImageFilename'] = $this->coverImage(false);
if ($returnsArray) {
return $tmp;
}
return json_encode($tmp);
}
// Returns the file name, FALSE there isn't a cover image setted
// If the user defined an External Cover Image the complete URL is going to be returned
// (boolean) $absolute, TRUE returns the absolute path and file name, FALSE just the file name
public function coverImage($absolute=true)
{
$fileName = $this->getValue('coverImage');
if (empty($fileName)) {
return false;
}
// Check if external cover image, is a valid URL
if (filter_var($fileName, FILTER_VALIDATE_URL)) {
return $fileName;
}
if ($absolute) {
return DOMAIN_UPLOADS.$fileName;
}
return $fileName;
}
// Returns the absolute URL of the thumbnail of the cover image, FALSE if the page doen't have cover image
public function thumbCoverImage()
{
$coverImageFilename = $this->coverImage(false);
if ($coverImageFilename==false) {
return false;
}
return DOMAIN_UPLOADS_THUMBNAILS.$coverImageFilename;
}
// Returns TRUE if the content has the text splited
public function readMore()
{
$content = $this->contentRaw();
return Text::stringContains($content, PAGE_BREAK);
}
public function uuid()
{
return $this->getValue('uuid');
}
// Returns the field key
public function key()
{
return $this->getValue('key');
}
// (boolean) Returns TRUE if the page is published, FALSE otherwise
public function published()
{
return ($this->getValue('type')==='published');
}
// (boolean) Returns TRUE if the page is scheduled, FALSE otherwise
public function scheduled()
{
return ($this->getValue('type')==='scheduled');
}
// (boolean) Returns TRUE if the page is draft, FALSE otherwise
public function draft()
{
return ($this->getValue('type')=='draft');
}
// (boolean) Returns TRUE if the page is sticky, FALSE otherwise
public function sticky()
{
return ($this->getValue('type')=='sticky');
}
// (boolean) Returns TRUE if the page is static, FALSE otherwise
public function isStatic()
{
return ($this->getValue('type')=='static');
}
// (string) Returns type of the page
public function type()
{
return $this->getValue('type');
}
// Returns the title field
public function title()
{
return $this->getValue('title');
}
// Returns TRUE if the page has enabled the comments, FALSE otherwise
public function allowComments()
{
return $this->getValue('allowComments');
}
// Returns the page position
public function position()
{
return $this->getValue('position');
}
// Returns the page noindex
public function noindex()
{
return $this->getValue('noindex');
}
// Returns the page nofollow
public function nofollow()
{
return $this->getValue('nofollow');
}
// Returns the page noarchive
public function noarchive()
{
return $this->getValue('noarchive');
}
// Returns the page slug
public function slug()
{
$explode = explode('/', $this->key());
// Remove the parent
if (!empty($explode[1])) {
return $explode[1];
}
return $explode[0];
}
// Returns the parent key, if the page doesn't have a parent returns FALSE
public function parent()
{
return $this->parentKey();
}
// Returns the parent key, if the page doesn't have a parent returns FALSE
public function parentKey()
{
$explode = explode('/', $this->key());
if (isset($explode[1])) {
return $explode[0];
}
return false;
}
// Returns TRUE if the page is a parent, has or not children
public function isParent()
{
return $this->parentKey()===false;
}
// Returns the parent method output, if the page doesn't have a parent returns FALSE
public function parentMethod($method)
{
$parentKey = $this->parentKey();
if ($parentKey) {
$page = buildPage($parentKey);
return $page->{$method}();
}
return false;
}
// Returns TRUE if the page is a child, FALSE otherwise
public function isChild()
{
return $this->parentKey()!==false;
}
// Returns TRUE if the page has children
public function hasChildren()
{
$childrenKeys = $this->childrenKeys();
return !empty($childrenKeys);
}
// Returns an array with all children's keys
public function childrenKeys()
{
global $dbPages;
$key = $this->key();
return $dbPages->getChildren($key);
}
// Returns an array with all children as Page-Object
public function children()
{
global $dbPages;
$list = array();
$childrenKeys = $dbPages->getChildren($this->key());
foreach ($childrenKeys as $childKey) {
$child = buildPage($childKey);
array_push($list, $child);
}
return $list;
}
// Returns the amount of minutes takes to read the page
public function readingTime() {
global $Language;
$words = $this->content(true);
$words = strip_tags($words);
$words = str_word_count($words);
$average = $words / 200;
$minutes = round($average);
if ($minutes>0) {
return $minutes.' '.$Language->get('minutes');
}
return '~1 '.$Language->get('minute');
}
// Returns relative time (e.g. "1 minute ago")
// Based on http://stackoverflow.com/a/18602474
// Modified for Bludit
// $complete = false : short version
// $complete = true : full version
public function relativeTime($complete = false) {
$current = new DateTime;
$past = new DateTime($this->getValue('date'));
$elapsed = $current->diff($past);
$elapsed->w = floor($elapsed->d / 7);
$elapsed->d -= $elapsed->w * 7;
$string = array(
'y' => 'year',
'm' => 'month',
'w' => 'week',
'd' => 'day',
'h' => 'hour',
'i' => 'minute',
's' => 'second',
);
foreach($string as $key => &$value) {
if($elapsed->$key) {
$value = $elapsed->$key . ' ' . $value . ($elapsed->$key > 1 ? 's' : ' ');
} else {
unset($string[$key]);
}
}
if(!$complete) {
$string = array_slice($string, 0 , 1);
}
return $string ? implode(', ', $string) . ' ago' : 'Just now';
}
}

View File

@ -44,10 +44,9 @@ class pluginAPI extends Plugin {
public function beforeAll() public function beforeAll()
{ {
global $Url; global $url;
global $dbPages; global $dbPages;
global $dbUsers; global $dbUsers;
global $login;
// CHECK URL // CHECK URL
// ------------------------------------------------------------ // ------------------------------------------------------------
@ -103,8 +102,8 @@ class pluginAPI extends Plugin {
// Get the object user to check the role // Get the object user to check the role
$user = $dbUsers->getUser($username); $user = $dbUsers->getUser($username);
if (($user->role()=='admin') && ($user->enabled())) { if (($user->role()=='admin') && ($user->enabled())) {
// Loggin the user to create the session // Loggin the user to create the session
$login = new Login();
$login->setLogin($username, 'admin'); $login->setLogin($username, 'admin');
// Enable write permissions // Enable write permissions
$writePermissions = true; $writePermissions = true;
@ -262,9 +261,9 @@ class pluginAPI extends Plugin {
private function getPage($key) private function getPage($key)
{ {
// Generate the object Page // Generate the object Page
$Page = buildPage($key); $page = buildPage($key);
if (!$Page) { if (!$page) {
return array( return array(
'status'=>'1', 'status'=>'1',
'message'=>'Page not found.' 'message'=>'Page not found.'
@ -274,7 +273,7 @@ class pluginAPI extends Plugin {
return array( return array(
'status'=>'0', 'status'=>'0',
'message'=>'Page filtered by key: '.$key, 'message'=>'Page filtered by key: '.$key,
'data'=>$Page->json( $returnsArray=true ) 'data'=>$page->json( $returnsArray=true )
); );
} }
@ -282,7 +281,7 @@ class pluginAPI extends Plugin {
{ {
// Unsanitize content because all values are sanitized // Unsanitize content because all values are sanitized
if (isset($args['content'])) { if (isset($args['content'])) {
$args['content'] = Text::htmlDecode($args['content']); $args['content'] = Sanitize::htmlDecode($args['content']);
} }
// This function is defined on functions.php // This function is defined on functions.php

View File

@ -44,18 +44,18 @@ class pluginDisqus extends Plugin {
public function pageEnd() public function pageEnd()
{ {
global $pages; global $content;
global $Url, $Page; global $url, $page;
$page = $pages[0]; $page = $content[0];
if (empty($page)) { if (empty($page)) {
return false; return false;
} }
if ( !$Url->notFound() && if ( !$url->notFound() &&
( $Url->whereAmI()=='page' && ( $url->whereAmI()=='page' &&
(($this->getDbField('enablePosts') && $Page->status()=='published') || (($this->getDbField('enablePosts') && $page->status()=='published') ||
($this->getDbField('enablePages') && $Page->status()=='static')) ($this->getDbField('enablePages') && $page->status()=='static'))
) && ) &&
$page->allowComments() ) { $page->allowComments() ) {
$html = '<div id="disqus_thread"></div>'; $html = '<div id="disqus_thread"></div>';

View File

@ -50,8 +50,8 @@ class pluginNavigation extends Plugin {
public function siteSidebar() public function siteSidebar()
{ {
global $Language; global $Language;
global $Url; global $url;
global $Site; global $site;
global $dbPages; global $dbPages;
// HTML for sidebar // HTML for sidebar
@ -69,7 +69,7 @@ class pluginNavigation extends Plugin {
// Show Home page link // Show Home page link
if ($this->getValue('homeLink')) { if ($this->getValue('homeLink')) {
$html .= '<li>'; $html .= '<li>';
$html .= '<a href="' . $Site->url() . '">' . $Language->get('Home page') . '</a>'; $html .= '<a href="' . $site->url() . '">' . $Language->get('Home page') . '</a>';
$html .= '</li>'; $html .= '</li>';
} }

View File

@ -29,20 +29,20 @@ class pluginOpenGraph extends Plugin {
public function siteHead() public function siteHead()
{ {
global $Url; global $url;
global $Site; global $site;
global $WHERE_AM_I; global $WHERE_AM_I;
global $pages;
global $page; global $page;
global $content;
$og = array( $og = array(
'locale' =>$Site->locale(), 'locale' =>$site->locale(),
'type' =>'website', 'type' =>'website',
'title' =>$Site->title(), 'title' =>$site->title(),
'description' =>$Site->description(), 'description' =>$site->description(),
'url' =>$Site->url(), 'url' =>$site->url(),
'image' =>'', 'image' =>'',
'siteName' =>$Site->title() 'siteName' =>$site->title()
); );
switch ($WHERE_AM_I) { switch ($WHERE_AM_I) {
@ -54,16 +54,16 @@ class pluginOpenGraph extends Plugin {
$og['url'] = $page->permalink($absolute=true); $og['url'] = $page->permalink($absolute=true);
$og['image'] = $page->coverImage($absolute=true); $og['image'] = $page->coverImage($absolute=true);
$content = $page->content(); $pageContent = $page->content();
break; break;
// The user is in the homepage // The user is in the homepage
default: default:
$content = ''; $pageContent = '';
// The image it's from the first page // The image it's from the first page
if (isset($pages[0]) ) { if (isset($content[0]) ) {
$og['image'] = $pages[0]->coverImage($absolute=true); $og['image'] = $content[0]->coverImage($absolute=true);
$content = $pages[0]->content(); $pageContent = $content[0]->content();
} }
break; break;
} }
@ -79,7 +79,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 = DOM::getFirstImage($content); $src = DOM::getFirstImage($pageContent);
if ($src!==false) { if ($src!==false) {
$og['image'] = $src; $og['image'] = $src;
} else { } else {

View File

@ -35,9 +35,9 @@ class pluginRSS extends Plugin {
private function createXML() private function createXML()
{ {
global $Site; global $site;
global $dbPages; global $dbPages;
global $Url; global $url;
// Amount of pages to show // Amount of pages to show
$amountOfItems = $this->getValue('amountOfItems'); $amountOfItems = $this->getValue('amountOfItems');
@ -49,17 +49,17 @@ class pluginRSS extends Plugin {
$onlyPublished = true; $onlyPublished = true;
// Get the list of pages // Get the list of pages
$pages = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished, true); $list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished, true);
$xml = '<?xml version="1.0" encoding="UTF-8" ?>'; $xml = '<?xml version="1.0" encoding="UTF-8" ?>';
$xml .= '<rss version="2.0">'; $xml .= '<rss version="2.0">';
$xml .= '<channel>'; $xml .= '<channel>';
$xml .= '<title>'.$Site->title().'</title>'; $xml .= '<title>'.$site->title().'</title>';
$xml .= '<link>'.$Site->url().'</link>'; $xml .= '<link>'.$site->url().'</link>';
$xml .= '<description>'.$Site->description().'</description>'; $xml .= '<description>'.$site->description().'</description>';
// Get keys of pages // Get keys of pages
foreach($pages as $pageKey) { foreach($list as $pageKey) {
// Create the page object from the page key // Create the page object from the page key
$page = buildPage($pageKey); $page = buildPage($pageKey);
$xml .= '<item>'; $xml .= '<item>';

File diff suppressed because one or more lines are too long

View File

@ -22,23 +22,23 @@ class pluginSitemap extends Plugin {
private function createXML() private function createXML()
{ {
global $Site; global $site;
global $dbPages; global $dbPages;
$xml = '<?xml version="1.0" encoding="UTF-8" ?>'; $xml = '<?xml version="1.0" encoding="UTF-8" ?>';
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$xml .= '<url>'; $xml .= '<url>';
$xml .= '<loc>'.$Site->url().'</loc>'; $xml .= '<loc>'.$site->url().'</loc>';
$xml .= '</url>'; $xml .= '</url>';
// Get DB // Get DB
$pageNumber = 1; $pageNumber = 1;
$amountOfItems = -1; $amountOfItems = -1;
$onlyPublished = true; $onlyPublished = true;
$pages = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); $list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
foreach($pages as $pageKey) { foreach($list as $pageKey) {
// Create the page object from the page key // Create the page object from the page key
$page = buildPage($pageKey); $page = buildPage($pageKey);

View File

@ -42,8 +42,8 @@ class pluginStaticPages extends Plugin {
public function siteSidebar() public function siteSidebar()
{ {
global $Language; global $Language;
global $Url; global $url;
global $Site; global $site;
global $dbPages; global $dbPages;
// HTML for sidebar // HTML for sidebar
@ -61,7 +61,7 @@ class pluginStaticPages extends Plugin {
// Show Home page link // Show Home page link
if ($this->getValue('homeLink')) { if ($this->getValue('homeLink')) {
$html .= '<li>'; $html .= '<li>';
$html .= '<a href="' . $Site->url() . '">' . $Language->get('Home page') . '</a>'; $html .= '<a href="' . $site->url() . '">' . $Language->get('Home page') . '</a>';
$html .= '</li>'; $html .= '</li>';
} }

View File

@ -30,9 +30,9 @@ class pluginTags extends Plugin {
{ {
global $Language; global $Language;
global $dbTags; global $dbTags;
global $Url; global $url;
$filter = $Url->filters('tag'); $filter = $url->filters('tag');
$html = '<div class="plugin plugin-tags">'; $html = '<div class="plugin plugin-tags">';
$html .= '<h2 class="plugin-label">'.$this->getDbField('label').'</h2>'; $html .= '<h2 class="plugin-label">'.$this->getDbField('label').'</h2>';

View File

@ -2,8 +2,8 @@
"author": "TinyMCE", "author": "TinyMCE",
"email": "", "email": "",
"website": "https://www.tinymce.com", "website": "https://www.tinymce.com",
"version": "4.7.13", "version": "4.8.0",
"releaseDate": "2018-05-16", "releaseDate": "2018-07-11",
"license": "GPL v2", "license": "GPL v2",
"compatible": "3.0", "compatible": "3.0",
"notes": "" "notes": ""

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -28,17 +28,17 @@ class pluginTwitterCards extends Plugin {
public function siteHead() public function siteHead()
{ {
global $Url; global $url;
global $Site; global $site;
global $WHERE_AM_I; global $WHERE_AM_I;
global $pages; global $content;
global $page; global $page;
$data = array( $data = array(
'card' =>'summary', 'card' =>'summary',
'site' =>'', 'site' =>'',
'title' =>$Site->title(), 'title' =>$site->title(),
'description' =>$Site->description(), 'description' =>$site->description(),
'image' =>'' 'image' =>''
); );
@ -49,16 +49,16 @@ class pluginTwitterCards extends Plugin {
$data['description'] = $page->description(); $data['description'] = $page->description();
$data['image'] = $page->coverImage($absolute=true); $data['image'] = $page->coverImage($absolute=true);
$content = $page->content(); $pageContent = $page->content();
break; break;
// The user is in the homepage // The user is in the homepage
default: default:
$content = ''; $pageContent = '';
// The image it's from the first page // The image it's from the first page
if(isset($pages[0]) ) { if(isset($content[0]) ) {
$data['image'] = $pages[0]->coverImage($absolute=true); $data['image'] = $content[0]->coverImage($absolute=true);
$content = $pages[0]->content(); $pageContent = $content[0]->content();
} }
break; break;
} }
@ -72,7 +72,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 = DOM::getFirstImage($content); $src = DOM::getFirstImage($pageContent);
if ($src!==false) { if ($src!==false) {
$data['image'] = $src; $data['image'] = $src;
} else { } else {

View File

@ -15,7 +15,7 @@
<h1 class="title"><?php echo $page->title(); ?></h1> <h1 class="title"><?php echo $page->title(); ?></h1>
</a> </a>
<?php if (!$page->isStatic() && !$Url->notFound()): ?> <?php if (!$page->isStatic() && !$url->notFound()): ?>
<!-- Creation date --> <!-- Creation date -->
<h6 class="card-subtitle mb-3 text-muted"><?php echo $page->date(); ?> - <?php echo $Language->get('Reading time') . ': ' . $page->readingTime() ?></h6> <h6 class="card-subtitle mb-3 text-muted"><?php echo $page->date(); ?> - <?php echo $Language->get('Reading time') . ': ' . $page->readingTime() ?></h6>
<?php endif ?> <?php endif ?>

View File

@ -33,7 +33,7 @@ define('PATH_BOOT', PATH_ROOT.'bl-kernel'.DS.'boot'.DS);
require(PATH_BOOT.'init.php'); require(PATH_BOOT.'init.php');
// Admin area // Admin area
if ($Url->whereAmI()==='admin') { if ($url->whereAmI()==='admin') {
require(PATH_BOOT.'admin.php'); require(PATH_BOOT.'admin.php');
} }
// Site // Site

View File

@ -307,12 +307,17 @@ function install($adminPassword, $timezone)
$data = array(); $data = array();
foreach ($pagesToInstall as $page) { foreach ($pagesToInstall as $page) {
$data[$Language->get($page)]= array(
$slug = $page;
$title = Text::replace('slug','title', $slug);
$content = Text::replace('slug','content', $slug);
$data[$Language->get($slug)]= array(
'title'=>$Language->get($title),
'description'=>'', 'description'=>'',
'username'=>'admin', 'username'=>'admin',
'tags'=>array(), 'tags'=>array(),
'status'=>'published', 'type'=>'published',
'type'=>'page',
'date'=>$currentDate, 'date'=>$currentDate,
'dateModified'=>'', 'dateModified'=>'',
'allowComments'=>true, 'allowComments'=>true,
@ -322,8 +327,13 @@ function install($adminPassword, $timezone)
'category'=>'', 'category'=>'',
'uuid'=>md5(uniqid()), 'uuid'=>md5(uniqid()),
'parent'=>'', 'parent'=>'',
'slug'=>$Language->get($page) 'template'=>'',
'noindex'=>false,
'nofollow'=>false,
'noarchive'=>false
); );
file_put_contents(PATH_PAGES.$Language->get($slug).DS.FILENAME, $Language->get($content), LOCK_EX);
} }
file_put_contents(PATH_DATABASES.'pages.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); file_put_contents(PATH_DATABASES.'pages.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
@ -487,19 +497,6 @@ function install($adminPassword, $timezone)
LOCK_EX LOCK_EX
); );
// Page create-your-own-content
$data = 'Title: '.$Language->get('example-page-1-title').PHP_EOL.'Content: '.PHP_EOL.$Language->get('example-page-1-content');
file_put_contents(PATH_PAGES.$Language->get('example-page-1-slug').DS.FILENAME, $data, LOCK_EX);
// Page set-up-your-new-site
$data = 'Title: '.$Language->get('example-page-2-title').PHP_EOL.'Content: '.PHP_EOL.$Language->get('example-page-2-content');
file_put_contents(PATH_PAGES.$Language->get('example-page-2-slug').DS.FILENAME, $data, LOCK_EX);
// Page follow-bludit
$data = 'Title: '.$Language->get('example-page-3-title').PHP_EOL.'Content: '.PHP_EOL.$Language->get('example-page-3-content');
file_put_contents(PATH_PAGES.$Language->get('example-page-3-slug').DS.FILENAME, $data, LOCK_EX);
// Page about
$data = 'Title: '.$Language->get('example-page-4-title').PHP_EOL.'Content: '.PHP_EOL.$Language->get('example-page-4-content');
file_put_contents(PATH_PAGES.$Language->get('example-page-4-slug').DS.FILENAME, $data, LOCK_EX);
return true; return true;
} }
@ -552,7 +549,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
<!-- Javascript --> <!-- Javascript -->
<script charset="utf-8" src="bl-kernel/js/jquery.min.js?version=<?php echo time() ?>"></script> <script charset="utf-8" src="bl-kernel/js/jquery.min.js?version=<?php echo time() ?>"></script>
<script charset="utf-8" src="bl-kernel/js/bootstrap-bundle.min.js?version=<?php echo time() ?>"></script> <script charset="utf-8" src="bl-kernel/js/bootstrap.bundle.min.js?version=<?php echo time() ?>"></script>
<script charset="utf-8" src="bl-kernel/js/jstz.min.js?version=<?php echo time() ?>"></script> <script charset="utf-8" src="bl-kernel/js/jstz.min.js?version=<?php echo time() ?>"></script>
</head> </head>
<body class="login"> <body class="login">