Title in database, improves on Page Object, Perfomance improvements, TinyMCE and Bootstrap updated
This commit is contained in:
parent
8cfd7df062
commit
d852cada22
@ -313,7 +313,7 @@ class Plugin {
|
||||
// Example: https://www.mybludit.com/api/foo/bar
|
||||
public function webhook($URI=false, $returnsAfterURI=false, $fixed=true)
|
||||
{
|
||||
global $Url;
|
||||
global $url;
|
||||
|
||||
if (empty($URI)) {
|
||||
return false;
|
||||
@ -321,7 +321,7 @@ class Plugin {
|
||||
|
||||
// Check URI start with the webhook
|
||||
$startString = HTML_PATH_ROOT.$URI;
|
||||
$URI = $Url->uri();
|
||||
$URI = $url->uri();
|
||||
$length = mb_strlen($startString, CHARSET);
|
||||
if (mb_substr($URI, 0, $length)!=$startString) {
|
||||
return false;
|
||||
|
@ -25,11 +25,11 @@ checkRole(array('admin', 'moderator'));
|
||||
// List of published pages
|
||||
$onlyPublished = true;
|
||||
$amountOfItems = ITEMS_PER_PAGE_ADMIN;
|
||||
$pageNumber = $Url->pageNumber();
|
||||
$pageNumber = $url->pageNumber();
|
||||
$published = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
|
||||
// Check if out of range the pageNumber
|
||||
if (empty($published) && $Url->pageNumber()>1) {
|
||||
if (empty($published) && $url->pageNumber()>1) {
|
||||
Redirect::page('content');
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,18 @@
|
||||
// Functions
|
||||
// ============================================================================
|
||||
function updateBludit() {
|
||||
global $Site;
|
||||
global $site;
|
||||
// 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.');
|
||||
|
||||
// From Bludit v2.0.x to v2.1.x
|
||||
if ($Site->currentBuild() < '20171102') {
|
||||
if ($site->currentBuild() < '20171102') {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
// Set the current build number
|
||||
$Site->set(array('currentBuild'=>BLUDIT_BUILD));
|
||||
$site->set(array('currentBuild'=>BLUDIT_BUILD));
|
||||
Log::set('UPDATE SYSTEM - Finished.');
|
||||
}
|
||||
}
|
||||
|
@ -53,10 +53,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
||||
$pageKey = $layout['parameters'];
|
||||
$page = buildPage($pageKey);
|
||||
if ($page===false) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$pageKey);
|
||||
try {
|
||||
$pageKey = $layout['parameters'];
|
||||
$page = new PageX($pageKey);
|
||||
} catch (Exception $e) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$pageKey, LOG_TYPE_ERROR);
|
||||
Redirect::page('content');
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ $themeDirname = $layout['parameters'];
|
||||
|
||||
if( Sanitize::pathFile(PATH_THEMES.$themeDirname) ) {
|
||||
// Set the theme
|
||||
$Site->set(array('theme'=>$themeDirname));
|
||||
$site->set(array('theme'=>$themeDirname));
|
||||
|
||||
// Add to syslog
|
||||
$syslog->add(array(
|
||||
|
@ -10,11 +10,11 @@
|
||||
|
||||
function checkLogin($args)
|
||||
{
|
||||
global $Security;
|
||||
global $security;
|
||||
global $login;
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
@ -24,13 +24,13 @@ function checkLogin($args)
|
||||
$login->setRememberMe($_POST['username']);
|
||||
}
|
||||
// Renew the token. This token will be the same inside the session for multiple forms.
|
||||
$Security->generateTokenCSRF();
|
||||
$security->generateTokenCSRF();
|
||||
Redirect::page('dashboard');
|
||||
return true;
|
||||
}
|
||||
|
||||
// Bruteforce protection, add IP to the blacklist
|
||||
$Security->addToBlacklist();
|
||||
$security->addToBlacklist();
|
||||
|
||||
// Create alert
|
||||
Alert::set($Language->g('Username or password incorrect'), ALERT_STATUS_FAIL);
|
||||
@ -40,15 +40,15 @@ function checkLogin($args)
|
||||
|
||||
function checkRememberMe()
|
||||
{
|
||||
global $Security;
|
||||
global $security;
|
||||
global $login;
|
||||
|
||||
if ($Security->isBlocked()) {
|
||||
if ($security->isBlocked()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($login->verifyUserByRemember()) {
|
||||
$Security->generateTokenCSRF();
|
||||
$security->generateTokenCSRF();
|
||||
Redirect::page('dashboard');
|
||||
return true;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ checkRole(array('admin'));
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
$Site->set($_POST);
|
||||
$site->set($_POST);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -26,7 +26,7 @@ $amountOfPages = count($listOfFilesByPage);
|
||||
|
||||
<!-- Form and Input file -->
|
||||
<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">
|
||||
<input type="file" class="custom-file-input" id="jsbluditInputFiles" name="bluditInputFiles[]" multiple>
|
||||
<label class="custom-file-label" for="jsbluditInputFiles">Choose images</label>
|
||||
|
@ -23,7 +23,7 @@ $categories = $dbCategories->getKeyNameArray();
|
||||
foreach ($categories as $categoryKey=>$category) {
|
||||
echo '<tr>';
|
||||
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>';
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array('class'=>'plugin-form'));
|
||||
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
'value'=>$security->getTokenCSRF()
|
||||
));
|
||||
|
||||
// Print the plugin form
|
||||
|
@ -3,7 +3,7 @@
|
||||
echo Bootstrap::pageTitle(array('title'=>$L->g('Content'), 'icon'=>'cog'));
|
||||
|
||||
function table($status) {
|
||||
global $Url;
|
||||
global $url;
|
||||
global $Language;
|
||||
global $published;
|
||||
global $drafts;
|
||||
@ -77,7 +77,7 @@ function table($status) {
|
||||
.'</a>
|
||||
</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="text-center d-none d-sm-table-cell">'.$page->position().'</td>';
|
||||
@ -93,7 +93,7 @@ function table($status) {
|
||||
.'</a>
|
||||
</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>'.$child->position().'</td>';
|
||||
@ -115,7 +115,7 @@ function table($status) {
|
||||
.'</a>
|
||||
</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="text-center d-none d-sm-table-cell">'.( ((ORDER_BY=='position') || ($status!='published'))?$page->position():$page->dateRaw(ADMIN_PANEL_DATE_FORMAT) ).'</td>';
|
||||
|
@ -34,5 +34,5 @@ $constants = get_defined_constants(true);
|
||||
printTable('Bludit Constants', $constants['user']);
|
||||
|
||||
// Site object
|
||||
printTable('$Site object database',$Site->db);
|
||||
printTable('$Site object database',$site->db);
|
||||
|
||||
|
@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
|
||||
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
'value'=>$security->getTokenCSRF()
|
||||
));
|
||||
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
|
@ -21,7 +21,7 @@
|
||||
// Token CSRF
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
'value'=>$security->getTokenCSRF()
|
||||
));
|
||||
|
||||
// Parent
|
||||
@ -38,8 +38,8 @@
|
||||
|
||||
// Status = published, draft, sticky, static
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'status',
|
||||
'value'=>$page->status()
|
||||
'name'=>'type',
|
||||
'value'=>$page->type()
|
||||
));
|
||||
|
||||
// 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>
|
||||
<?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>
|
||||
|
||||
<!-- TABS IMAGES -->
|
||||
<div class="tab-pane" id="images" role="tabpanel" aria-labelledby="images-tab">
|
||||
|
||||
<?php
|
||||
echo Bootstrap::formTitle(array('title'=>'Cover image'));
|
||||
<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
|
||||
$coverImage = $page->coverImage(false);
|
||||
$externalCoverImage = '';
|
||||
if (filter_var($coverImage, FILTER_VALIDATE_URL)) {
|
||||
@ -115,26 +132,32 @@
|
||||
|
||||
<!-- TABS OPTIONS -->
|
||||
<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
|
||||
|
||||
echo Bootstrap::formTitle(array('title'=>'Advanced'));
|
||||
|
||||
// Date
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'date',
|
||||
'label'=>'Date',
|
||||
'placeholder'=>'',
|
||||
'value'=>$page->date(),
|
||||
'value'=>$page->dateRaw(),
|
||||
'tip'=>'Date format: <code>YYYY-MM-DD Hours:Minutes:Seconds</code>'
|
||||
));
|
||||
|
||||
// Type
|
||||
echo Bootstrap::formSelect(array(
|
||||
'name'=>'type',
|
||||
'name'=>'typeTMP',
|
||||
'label'=>'Type',
|
||||
'selected'=>$page->type(),
|
||||
'options'=>array(
|
||||
''=>'- Default -',
|
||||
'published'=>'- Default -',
|
||||
'sticky'=>'Sticky',
|
||||
'static'=>'Static'
|
||||
),
|
||||
@ -219,18 +242,6 @@
|
||||
?>
|
||||
</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 -->
|
||||
<div id="jscategoryModal" class="modal fade" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
@ -337,22 +348,23 @@ $(document).ready(function() {
|
||||
$("#jsdate").datetimepicker({format:DB_DATE_FORMAT});
|
||||
|
||||
// Button Save
|
||||
$("#jsbuttonSave").on("click", function() {
|
||||
$("#jsstatus").val("published");
|
||||
$(".jsbuttonSave").on("click", function() {
|
||||
var type = $("#jstypeTMP option:selected").val();
|
||||
$("#jstype").val(type);
|
||||
$("#jscontent").val( editorGetContent() );
|
||||
$("#jsform").submit();
|
||||
});
|
||||
|
||||
// Button Save as draft
|
||||
$("#jsbuttonDraft").on("click", function() {
|
||||
$("#jsstatus").val("draft");
|
||||
$(".jsbuttonDraft").on("click", function() {
|
||||
$("#jstype").val("draft");
|
||||
$("#jscontent").val( editorGetContent() );
|
||||
$("#jsform").submit();
|
||||
});
|
||||
|
||||
// Button Delete
|
||||
$("#jsbuttonDelete").on("click", function() {
|
||||
$("#jsstatus").val("delete");
|
||||
$(".jsbuttonDelete").on("click", function() {
|
||||
$("#jstype").val("delete");
|
||||
$("#jscontent").val("");
|
||||
$("#jsform").submit();
|
||||
});
|
||||
@ -362,12 +374,6 @@ $(document).ready(function() {
|
||||
$("#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 works when the content of the page is bigger than 100 characters
|
||||
setInterval(function() {
|
||||
|
@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
|
||||
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
'value'=>$security->getTokenCSRF()
|
||||
));
|
||||
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
|
@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
|
||||
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
'value'=>$security->getTokenCSRF()
|
||||
));
|
||||
|
||||
echo '
|
||||
|
@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
|
||||
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
'value'=>$security->getTokenCSRF()
|
||||
));
|
||||
|
||||
echo Bootstrap::formInputTextBlock(array(
|
||||
|
@ -21,7 +21,7 @@
|
||||
// Token CSRF
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
'value'=>$security->getTokenCSRF()
|
||||
));
|
||||
|
||||
// Parent
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
// Status = published, draft, sticky, static
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'status',
|
||||
'name'=>'type',
|
||||
'value'=>'published'
|
||||
));
|
||||
|
||||
@ -72,14 +72,24 @@
|
||||
<textarea id="jseditor" style="display:none;"></textarea>
|
||||
</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>
|
||||
|
||||
<!-- TABS IMAGES -->
|
||||
<div class="tab-pane" id="images" role="tabpanel" aria-labelledby="images-tab">
|
||||
|
||||
<?php
|
||||
echo Bootstrap::formTitle(array('title'=>'Cover image'));
|
||||
?>
|
||||
<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">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" />
|
||||
|
||||
@ -98,10 +108,16 @@
|
||||
|
||||
<!-- TABS OPTIONS -->
|
||||
<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
|
||||
|
||||
echo Bootstrap::formTitle(array('title'=>'Advanced'));
|
||||
|
||||
// Date
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'date',
|
||||
@ -113,11 +129,11 @@
|
||||
|
||||
// Type
|
||||
echo Bootstrap::formSelect(array(
|
||||
'name'=>'type',
|
||||
'name'=>'typeTMP',
|
||||
'label'=>'Type',
|
||||
'selected'=>'',
|
||||
'options'=>array(
|
||||
''=>'- Default -',
|
||||
'published'=>'- Default -',
|
||||
'sticky'=>'Sticky',
|
||||
'static'=>'Static'
|
||||
),
|
||||
@ -199,13 +215,6 @@
|
||||
?>
|
||||
</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 -->
|
||||
<div id="jscategoryModal" class="modal fade" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
@ -312,15 +321,16 @@ $(document).ready(function() {
|
||||
$("#jsdate").datetimepicker({format:DB_DATE_FORMAT});
|
||||
|
||||
// Button Save
|
||||
$("#jsbuttonSave").on("click", function() {
|
||||
$("#jsstatus").val("published");
|
||||
$(".jsbuttonSave").on("click", function() {
|
||||
var type = $("#jstypeTMP option:selected").val();
|
||||
$("#jstype").val(type);
|
||||
$("#jscontent").val( editorGetContent() );
|
||||
$("#jsform").submit();
|
||||
});
|
||||
|
||||
// Button Save as draft
|
||||
$("#jsbuttonDraft").on("click", function() {
|
||||
$("#jsstatus").val("draft");
|
||||
$(".jsbuttonDraft").on("click", function() {
|
||||
$("#jstype").val("draft");
|
||||
$("#jscontent").val( editorGetContent() );
|
||||
$("#jsform").submit();
|
||||
});
|
||||
@ -330,12 +340,6 @@ $(document).ready(function() {
|
||||
$("#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
|
||||
$("#jstitle").keyup(function() {
|
||||
var text = $(this).val();
|
||||
|
@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
|
||||
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
'value'=>$security->getTokenCSRF()
|
||||
));
|
||||
|
||||
echo Bootstrap::formInputText(array(
|
||||
|
@ -8,7 +8,7 @@ echo '<form class="uk-form" method="post" action="" autocomplete="off">';
|
||||
|
||||
HTML::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
'value'=>$security->getTokenCSRF()
|
||||
));
|
||||
|
||||
echo '<div class="uk-sortable" data-uk-sortable>';
|
||||
|
@ -28,7 +28,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
// Token CSRF
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'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(
|
||||
'name'=>'title',
|
||||
'label'=>$L->g('Site title'),
|
||||
'value'=>$Site->title(),
|
||||
'value'=>$site->title(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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(
|
||||
'name'=>'slogan',
|
||||
'label'=>$L->g('Site slogan'),
|
||||
'value'=>$Site->slogan(),
|
||||
'value'=>$site->slogan(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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(
|
||||
'name'=>'description',
|
||||
'label'=>$L->g('Site description'),
|
||||
'value'=>$Site->description(),
|
||||
'value'=>$site->description(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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(
|
||||
'name'=>'footer',
|
||||
'label'=>$L->g('Footer text'),
|
||||
'value'=>$Site->footer(),
|
||||
'value'=>$site->footer(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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',
|
||||
'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')),
|
||||
'selected'=>$Site->itemsPerPage(),
|
||||
'selected'=>$site->itemsPerPage(),
|
||||
'class'=>'',
|
||||
'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',
|
||||
'label'=>$L->g('Order content by'),
|
||||
'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')),
|
||||
'selected'=>$Site->orderBy(),
|
||||
'selected'=>$site->orderBy(),
|
||||
'class'=>'',
|
||||
'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(
|
||||
'name'=>'homepage',
|
||||
'label'=>$L->g('Homepage'),
|
||||
'value'=>(Text::isEmpty($Site->homepage())?'':$Site->homepage()),
|
||||
'value'=>(Text::isEmpty($site->homepage())?'':$site->homepage()),
|
||||
'class'=>'',
|
||||
'placeholder'=>'Start writing the title of the 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',
|
||||
'label'=>$L->g('Page not found'),
|
||||
'options'=>$homepageOptions,
|
||||
'selected'=>$Site->pageNotFound(),
|
||||
'selected'=>$site->pageNotFound(),
|
||||
'class'=>'',
|
||||
'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(
|
||||
'name'=>'emailFrom',
|
||||
'label'=>$L->g('Sender email'),
|
||||
'value'=>$Site->emailFrom(),
|
||||
'value'=>$site->emailFrom(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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(
|
||||
'name'=>'autosaveInterval',
|
||||
'label'=>$L->g('Interval'),
|
||||
'value'=>$Site->autosaveInterval(),
|
||||
'value'=>$site->autosaveInterval(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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(
|
||||
'name'=>'url',
|
||||
'label'=>'URL',
|
||||
'value'=>$Site->url(),
|
||||
'value'=>$site->url(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>$L->g('full-url-of-your-site'),
|
||||
@ -164,7 +164,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
'name'=>'extremeFriendly',
|
||||
'label'=>'Allow Unicode',
|
||||
'options'=>array('true'=>'Enabled', 'false'=>'Disable'),
|
||||
'selected'=>$Site->extremeFriendly(),
|
||||
'selected'=>$site->extremeFriendly(),
|
||||
'class'=>'',
|
||||
'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(
|
||||
'name'=>'titleFormatHomepage',
|
||||
'label'=>'Homepage',
|
||||
'value'=>$Site->titleFormatHomepage(),
|
||||
'value'=>$site->titleFormatHomepage(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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(
|
||||
'name'=>'titleFormatPages',
|
||||
'label'=>'Pages',
|
||||
'value'=>$Site->titleFormatPages(),
|
||||
'value'=>$site->titleFormatPages(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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(
|
||||
'name'=>'titleFormatCategory',
|
||||
'label'=>'Category',
|
||||
'value'=>$Site->titleFormatCategory(),
|
||||
'value'=>$site->titleFormatCategory(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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(
|
||||
'name'=>'titleFormatTag',
|
||||
'label'=>'Tag',
|
||||
'value'=>$Site->titleFormatTag(),
|
||||
'value'=>$site->titleFormatTag(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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(
|
||||
'name'=>'uriPage',
|
||||
'label'=>$L->g('Pages'),
|
||||
'value'=>$Site->uriFilters('page'),
|
||||
'value'=>$site->uriFilters('page'),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>DOMAIN_PAGES
|
||||
@ -225,7 +225,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'uriTag',
|
||||
'label'=>$L->g('Tags'),
|
||||
'value'=>$Site->uriFilters('tag'),
|
||||
'value'=>$site->uriFilters('tag'),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>DOMAIN_TAGS
|
||||
@ -234,7 +234,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'uriCategory',
|
||||
'label'=>$L->g('Category'),
|
||||
'value'=>$Site->uriFilters('category'),
|
||||
'value'=>$site->uriFilters('category'),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>DOMAIN_CATEGORIES
|
||||
@ -243,11 +243,11 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'uriBlog',
|
||||
'label'=>$L->g('Blog'),
|
||||
'value'=>$Site->uriFilters('blog'),
|
||||
'value'=>$site->uriFilters('blog'),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>DOMAIN.$Site->uriFilters('blog'),
|
||||
'disabled'=>!$Site->uriFilters('blog')
|
||||
'tip'=>DOMAIN.$site->uriFilters('blog'),
|
||||
'disabled'=>!$site->uriFilters('blog')
|
||||
));
|
||||
|
||||
echo '
|
||||
@ -265,7 +265,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'twitter',
|
||||
'label'=>'Twitter',
|
||||
'value'=>$Site->twitter(),
|
||||
'value'=>$site->twitter(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>''
|
||||
@ -274,7 +274,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'facebook',
|
||||
'label'=>'Facebook',
|
||||
'value'=>$Site->facebook(),
|
||||
'value'=>$site->facebook(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>''
|
||||
@ -283,7 +283,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'codepen',
|
||||
'label'=>'Codepen',
|
||||
'value'=>$Site->codepen(),
|
||||
'value'=>$site->codepen(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>''
|
||||
@ -292,7 +292,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'googlePlus',
|
||||
'label'=>'Google+',
|
||||
'value'=>$Site->googlePlus(),
|
||||
'value'=>$site->googlePlus(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>''
|
||||
@ -301,7 +301,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'instagram',
|
||||
'label'=>'Instagram',
|
||||
'value'=>$Site->instagram(),
|
||||
'value'=>$site->instagram(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>''
|
||||
@ -310,7 +310,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'gitlab',
|
||||
'label'=>'Gitlab',
|
||||
'value'=>$Site->gitlab(),
|
||||
'value'=>$site->gitlab(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>''
|
||||
@ -319,7 +319,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'github',
|
||||
'label'=>'Github',
|
||||
'value'=>$Site->github(),
|
||||
'value'=>$site->github(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>''
|
||||
@ -328,7 +328,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'linkedin',
|
||||
'label'=>'Linkedin',
|
||||
'value'=>$Site->linkedin(),
|
||||
'value'=>$site->linkedin(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>''
|
||||
@ -351,7 +351,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
'name'=>'language',
|
||||
'label'=>$L->g('Language'),
|
||||
'options'=>$Language->getLanguageList(),
|
||||
'selected'=>$Site->language(),
|
||||
'selected'=>$site->language(),
|
||||
'class'=>'',
|
||||
'tip'=>$L->g('select-your-sites-language')
|
||||
));
|
||||
@ -360,7 +360,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
'name'=>'timezone',
|
||||
'label'=>$L->g('Timezone'),
|
||||
'options'=>Date::timezoneList(),
|
||||
'selected'=>$Site->timezone(),
|
||||
'selected'=>$site->timezone(),
|
||||
'class'=>'',
|
||||
'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(
|
||||
'name'=>'locale',
|
||||
'label'=>$L->g('Locale'),
|
||||
'value'=>$Site->locale(),
|
||||
'value'=>$site->locale(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'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(
|
||||
'name'=>'dateFormat',
|
||||
'label'=>$L->g('Date format'),
|
||||
'value'=>$Site->dateFormat(),
|
||||
'value'=>$site->dateFormat(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>$L->g('Current format').': '.Date::current($Site->dateFormat())
|
||||
'tip'=>$L->g('Current format').': '.Date::current($site->dateFormat())
|
||||
));
|
||||
|
||||
echo '
|
||||
|
@ -17,13 +17,13 @@ echo '
|
||||
|
||||
foreach ($themes as $theme) {
|
||||
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">
|
||||
<div>'.$theme['name'].'</div>
|
||||
<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>';
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ echo Bootstrap::formOpen(array());
|
||||
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
'value'=>$security->getTokenCSRF()
|
||||
));
|
||||
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
|
@ -6,7 +6,7 @@ if (Session::started()===false) {
|
||||
exit('Bludit CMS. Session initialization failure.');
|
||||
}
|
||||
|
||||
$login = $Login = new Login($dbUsers);
|
||||
$login = $Login = new Login();
|
||||
|
||||
$layout = array(
|
||||
'controller'=>null,
|
||||
@ -18,7 +18,7 @@ $layout = array(
|
||||
);
|
||||
|
||||
// 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];
|
||||
unset($explodeSlug[0]);
|
||||
$layout['parameters'] = implode('/', $explodeSlug);
|
||||
@ -62,18 +62,18 @@ else
|
||||
// User not logged.
|
||||
// Slug is login.
|
||||
// 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['view'] = 'login';
|
||||
$layout['template'] = 'login.php';
|
||||
|
||||
if ($Url->slug()==='login-email') {
|
||||
if ($url->slug()==='login-email') {
|
||||
$layout['controller'] = 'login-email';
|
||||
$layout['view'] = 'login-email';
|
||||
}
|
||||
|
||||
// Generate the tokenCSRF for the user not logged, when the user log-in the token will be change.
|
||||
$Security->generateTokenCSRF();
|
||||
$security->generateTokenCSRF();
|
||||
}
|
||||
|
||||
// Define variables
|
||||
@ -84,8 +84,8 @@ else
|
||||
Theme::plugins('beforeAdminLoad');
|
||||
|
||||
// Load init.php if the theme has one.
|
||||
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().DS.'init.php') ) {
|
||||
include(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');
|
||||
}
|
||||
|
||||
// Load controller.
|
||||
@ -94,8 +94,8 @@ else
|
||||
}
|
||||
|
||||
// Load view and theme.
|
||||
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().DS.$layout['template']) ) {
|
||||
include(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']);
|
||||
}
|
||||
|
||||
// Load plugins after the admin area is loaded.
|
||||
|
@ -86,6 +86,7 @@ include(PATH_KERNEL.'dbsite.class.php');
|
||||
include(PATH_KERNEL.'dbcategories.class.php');
|
||||
include(PATH_KERNEL.'dbsyslog.class.php');
|
||||
include(PATH_KERNEL.'page.class.php');
|
||||
include(PATH_KERNEL.'pagex.class.php');
|
||||
include(PATH_KERNEL.'category.class.php');
|
||||
include(PATH_KERNEL.'tag.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');
|
||||
}
|
||||
|
||||
// Session
|
||||
// Session::start();
|
||||
// if (Session::started()===false) {
|
||||
// exit('Bludit CMS. Session initialization failure.');
|
||||
// }
|
||||
|
||||
// Objects
|
||||
$dbPages = new dbPages();
|
||||
$dbUsers = new dbUsers();
|
||||
$dbTags = new dbTags();
|
||||
$dbCategories = new dbCategories();
|
||||
$site = $Site = new dbSite();
|
||||
$url = $Url = new Url();
|
||||
$parsedown = $Parsedown = new Parsedown();
|
||||
$security = $Security = new Security();
|
||||
$syslog = $syslog = new dbSyslog();
|
||||
$pages = $dbPages = new dbPages(); // DEPRECATED v3.0.0 $dbPages
|
||||
$dbUsers = new dbUsers();
|
||||
$dbTags = new dbTags();
|
||||
$dbCategories = new dbCategories();
|
||||
$site = new dbSite();
|
||||
$url = new Url();
|
||||
$security = new Security();
|
||||
$syslog = new dbSyslog();
|
||||
|
||||
// --- Relative paths ---
|
||||
// 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_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_JS', HTML_PATH_THEME.'js/');
|
||||
define('HTML_PATH_THEME_IMG', HTML_PATH_THEME.'img/');
|
||||
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_CSS', HTML_PATH_ADMIN_THEME.'css/');
|
||||
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/');
|
||||
|
||||
// --- Objects with dependency ---
|
||||
$language = $Language = new dbLanguage( $Site->language() );
|
||||
$Url->checkFilters( $Site->uriFilters() );
|
||||
$language = $Language = new dbLanguage( $site->language() );
|
||||
$url->checkFilters( $site->uriFilters() );
|
||||
|
||||
// --- CONSTANTS with dependency ---
|
||||
|
||||
// Tag URI filter
|
||||
define('TAG_URI_FILTER', $Url->filters('tag'));
|
||||
define('TAG_URI_FILTER', $url->filters('tag'));
|
||||
|
||||
// Category URI filter
|
||||
define('CATEGORY_URI_FILTER', $Url->filters('category'));
|
||||
define('CATEGORY_URI_FILTER', $url->filters('category'));
|
||||
|
||||
// Page URI filter
|
||||
define('PAGE_URI_FILTER', $Url->filters('page'));
|
||||
define('PAGE_URI_FILTER', $url->filters('page'));
|
||||
|
||||
// Content order by: date / position
|
||||
define('ORDER_BY', $Site->orderBy());
|
||||
define('ORDER_BY', $site->orderBy());
|
||||
|
||||
// Allow unicode characters in the URL
|
||||
define('EXTREME_FRIENDLY_URL', $Site->extremeFriendly());
|
||||
define('EXTREME_FRIENDLY_URL', $site->extremeFriendly());
|
||||
|
||||
// Minutes to execute the autosave function
|
||||
define('AUTOSAVE_INTERVAL', $Site->autosaveInterval());
|
||||
define('AUTOSAVE_INTERVAL', $site->autosaveInterval());
|
||||
|
||||
// --- PHP paths with dependency ---
|
||||
// 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_CSS', THEME_DIR.'css'.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 ---
|
||||
// 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_CORE_JS', DOMAIN.HTML_PATH_CORE_JS);
|
||||
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_VIEW = '';
|
||||
$ID_EXECUTION = uniqid(); // string 13 characters long
|
||||
$WHERE_AM_I = $Url->whereAmI();
|
||||
$WHERE_AM_I = $url->whereAmI();
|
||||
|
||||
// --- Objects shortcuts ---
|
||||
$L = $language;
|
||||
|
@ -51,7 +51,7 @@ function buildPlugins()
|
||||
global $plugins;
|
||||
global $pluginsEvents;
|
||||
global $Language;
|
||||
global $Site;
|
||||
global $site;
|
||||
|
||||
// List plugins directories
|
||||
$list = Filesystem::listDirectories(PATH_PLUGINS);
|
||||
@ -74,7 +74,7 @@ function buildPlugins()
|
||||
$Plugin = new $pluginClass;
|
||||
|
||||
// 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) ) {
|
||||
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.DEFAULT_LANGUAGE_FILE;
|
||||
}
|
||||
|
@ -14,59 +14,10 @@
|
||||
N => Page Object
|
||||
)
|
||||
*/
|
||||
$content = $pages = array();
|
||||
$content = array();
|
||||
|
||||
// Page filtered by the user, is a Page Object
|
||||
$page = $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
|
||||
$page = false;
|
||||
|
||||
// Array with static content, each item is a Page Object
|
||||
// Order by position
|
||||
@ -86,10 +37,7 @@ $staticContent = $staticPages = buildStaticPages();
|
||||
|
||||
// Execute the scheduler
|
||||
if ($dbPages->scheduler()) {
|
||||
// Reindex tags
|
||||
reindexTags();
|
||||
|
||||
// Reindex categories
|
||||
reindexCategories();
|
||||
|
||||
// Add to syslog
|
||||
@ -99,45 +47,37 @@ if ($dbPages->scheduler()) {
|
||||
));
|
||||
}
|
||||
|
||||
// Generate pages parent tree, only published pages
|
||||
//buildPagesByParent(true, true);
|
||||
|
||||
// Set home page is the user defined one
|
||||
if ($Site->homepage() && $Url->whereAmI()==='home') {
|
||||
$pageKey = $Site->homepage();
|
||||
if( $dbPages->exists($pageKey) ) {
|
||||
$Url->setSlug($pageKey);
|
||||
$Url->setWhereAmI('page');
|
||||
// Set home page if the user defined them
|
||||
if ($site->homepage() && $url->whereAmI()==='home') {
|
||||
$pageKey = $site->homepage();
|
||||
if ($dbPages->exists($pageKey)) {
|
||||
$url->setSlug($pageKey);
|
||||
$url->setWhereAmI('page');
|
||||
}
|
||||
}
|
||||
|
||||
// Build specific page
|
||||
if ($Url->whereAmI()==='page') {
|
||||
buildThePage();
|
||||
if ($url->whereAmI()==='page') {
|
||||
$content[0] = $page = buildThePage();
|
||||
}
|
||||
// Build content by tag
|
||||
elseif ($Url->whereAmI()==='tag') {
|
||||
buildPagesByTag();
|
||||
elseif ($url->whereAmI()==='tag') {
|
||||
$content = buildPagesByTag();
|
||||
}
|
||||
// Build content by category
|
||||
elseif ($Url->whereAmI()==='category') {
|
||||
buildPagesByCategory();
|
||||
elseif ($url->whereAmI()==='category') {
|
||||
$content = buildPagesByCategory();
|
||||
}
|
||||
// Build content for the homepage
|
||||
elseif ( ($Url->whereAmI()==='home') || ($Url->whereAmI()==='blog') ) {
|
||||
buildPagesForHome();
|
||||
elseif ( ($url->whereAmI()==='home') || ($url->whereAmI()==='blog') ) {
|
||||
$content = buildPagesForHome();
|
||||
}
|
||||
|
||||
if (isset($pages[0])) {
|
||||
$page = $Page = $pages[0];
|
||||
if (isset($content[0])) {
|
||||
$page = $content[0];
|
||||
}
|
||||
|
||||
// Set page 404 not found
|
||||
if ($Url->notFound()) {
|
||||
$pageNotFoundKey = $Site->pageNotFound();
|
||||
$page = buildPage( $pageNotFoundKey );
|
||||
if ($page===false) {
|
||||
$page = buildErrorPage();
|
||||
}
|
||||
$content[0] = $pages[0] = $Page = $page;
|
||||
// If set notFound, create the page 404
|
||||
if ($url->notFound()) {
|
||||
$content[0] = $page = buildErrorPage();
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
header('HTTP/1.0 '.$Url->httpCode().' '.$Url->httpMessage());
|
||||
header('HTTP/1.0 '.$url->httpCode().' '.$url->httpMessage());
|
||||
|
@ -1,25 +1,25 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// Current page number
|
||||
$currentPage = $Url->pageNumber();
|
||||
$currentPage = $url->pageNumber();
|
||||
Paginator::set('currentPage', $currentPage);
|
||||
|
||||
if($Url->whereAmI()=='admin') {
|
||||
if($url->whereAmI()=='admin') {
|
||||
$itemsPerPage = ITEMS_PER_PAGE_ADMIN;
|
||||
$amountOfItems = $dbPages->count(true);
|
||||
}
|
||||
elseif($Url->whereAmI()=='tag') {
|
||||
$itemsPerPage = $Site->itemsPerPage();
|
||||
$tagKey = $Url->slug();
|
||||
elseif($url->whereAmI()=='tag') {
|
||||
$itemsPerPage = $site->itemsPerPage();
|
||||
$tagKey = $url->slug();
|
||||
$amountOfItems = $dbTags->countPagesByTag($tagKey);
|
||||
}
|
||||
elseif($Url->whereAmI()=='category') {
|
||||
$itemsPerPage = $Site->itemsPerPage();
|
||||
$categoryKey = $Url->slug();
|
||||
elseif($url->whereAmI()=='category') {
|
||||
$itemsPerPage = $site->itemsPerPage();
|
||||
$categoryKey = $url->slug();
|
||||
$amountOfItems = $dbCategories->countPagesByCategory($categoryKey);
|
||||
}
|
||||
else {
|
||||
$itemsPerPage = $Site->itemsPerPage();
|
||||
$itemsPerPage = $site->itemsPerPage();
|
||||
$amountOfItems = $dbPages->count(true);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
$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);
|
||||
Session::destroy();
|
||||
Redirect::page('login');
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
function buildThemes()
|
||||
{
|
||||
global $Site;
|
||||
global $site;
|
||||
|
||||
$themes = array();
|
||||
$themesPaths = Filesystem::listDirectories(PATH_THEMES);
|
||||
@ -18,7 +18,7 @@ function buildThemes()
|
||||
foreach($themesPaths as $themePath)
|
||||
{
|
||||
// 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) ) {
|
||||
$languageFilename = $themePath.DS.'languages'.DS.DEFAULT_LANGUAGE_FILE;
|
||||
}
|
||||
@ -70,7 +70,7 @@ function buildThemes()
|
||||
// ============================================================================
|
||||
|
||||
// Load the language file
|
||||
$languageFilename = THEME_DIR.'languages'.DS.$Site->language().'.json';
|
||||
$languageFilename = THEME_DIR.'languages'.DS.$site->language().'.json';
|
||||
if( !Sanitize::pathFile($languageFilename) ) {
|
||||
$languageFilename = THEME_DIR.'languages'.DS.DEFAULT_LANGUAGE_FILE;
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ include(PATH_RULES.'99.themes.php');
|
||||
Theme::plugins('beforeSiteLoad');
|
||||
|
||||
// Theme init.php
|
||||
if (Sanitize::pathFile(PATH_THEMES, $Site->theme().DS.'init.php')) {
|
||||
include(PATH_THEMES.$Site->theme().DS.'init.php');
|
||||
if (Sanitize::pathFile(PATH_THEMES, $site->theme().DS.'init.php')) {
|
||||
include(PATH_THEMES.$site->theme().DS.'init.php');
|
||||
}
|
||||
|
||||
// Theme HTML
|
||||
if (Sanitize::pathFile(PATH_THEMES, $Site->theme().DS.'index.php')) {
|
||||
include(PATH_THEMES.$Site->theme().DS.'index.php');
|
||||
if (Sanitize::pathFile(PATH_THEMES, $site->theme().DS.'index.php')) {
|
||||
include(PATH_THEMES.$site->theme().DS.'index.php');
|
||||
} else {
|
||||
$Language->p('Please check your theme configuration');
|
||||
}
|
||||
|
4
bl-kernel/css/bootstrap.min.css
vendored
4
bl-kernel/css/bootstrap.min.css
vendored
File diff suppressed because one or more lines are too long
@ -1,29 +1,26 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
class dbPages extends dbJSON
|
||||
{
|
||||
private $parentKeyList = array();
|
||||
class dbPages extends dbJSON {
|
||||
|
||||
private $parentKeyList = array();
|
||||
private $dbFields = array(
|
||||
'title'=> array('inFile'=>true, 'value'=>''),
|
||||
'content'=> array('inFile'=>true, 'value'=>''),
|
||||
'description'=> array('inFile'=>false, 'value'=>''),
|
||||
'username'=> array('inFile'=>false, 'value'=>''),
|
||||
'tags'=> array('inFile'=>false, 'value'=>array()),
|
||||
'status'=> array('inFile'=>false, 'value'=>'published'), // published, draft, sticky, scheduled
|
||||
'type'=> array('inFile'=>false, 'value'=>'post'), // post, page
|
||||
'date'=> array('inFile'=>false, 'value'=>''),
|
||||
'dateModified'=> array('inFile'=>false, 'value'=>''),
|
||||
'position'=> array('inFile'=>false, 'value'=>0),
|
||||
'coverImage'=> array('inFile'=>false, 'value'=>''),
|
||||
'category'=> array('inFile'=>false, 'value'=>''),
|
||||
'md5file'=> array('inFile'=>false, 'value'=>''),
|
||||
'uuid'=> array('inFile'=>false, 'value'=>''),
|
||||
'allowComments'=> array('inFile'=>false, 'value'=>true),
|
||||
'template'=> array('inFile'=>false, 'value'=>''),
|
||||
'noindex'=> array('inFile'=>false, 'value'=>false),
|
||||
'nofollow'=> array('inFile'=>false, 'value'=>false),
|
||||
'noarchive'=> array('inFile'=>false, 'value'=>false)
|
||||
'title'=>'',
|
||||
'description'=>'',
|
||||
'username'=>'',
|
||||
'tags'=>array(),
|
||||
'type'=>'published', // published, draft, sticky, scheduled
|
||||
'date'=>'',
|
||||
'dateModified'=>'',
|
||||
'position'=>0,
|
||||
'coverImage'=>'',
|
||||
'category'=>'',
|
||||
'md5file'=>'',
|
||||
'uuid'=>'',
|
||||
'allowComments'=>true,
|
||||
'template'=>'',
|
||||
'noindex'=>false,
|
||||
'nofollow'=>false,
|
||||
'noarchive'=>false
|
||||
);
|
||||
|
||||
function __construct()
|
||||
@ -31,35 +28,35 @@ class dbPages extends dbJSON
|
||||
parent::__construct(DB_PAGES);
|
||||
}
|
||||
|
||||
public function getDefaultFields()
|
||||
{
|
||||
return $this->dbFields;
|
||||
}
|
||||
|
||||
// Create a new page
|
||||
// This function returns the key of the new page
|
||||
public function add($args, $climode=false)
|
||||
{
|
||||
$dataForDb = array(); // This data will be saved in the database
|
||||
$dataForFile = array(); // This data will be saved in the file
|
||||
$row = array();
|
||||
|
||||
// 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 ($options['inFile'] || is_array($args[$field])) {
|
||||
$value = $args[$field];
|
||||
} else {
|
||||
// Sanitize if will be stored on database
|
||||
$value = Sanitize::html($args[$field]);
|
||||
}
|
||||
// Sanitize if will be stored on database
|
||||
$finalValue = Sanitize::html($args[$field]);
|
||||
} else {
|
||||
// Default value for the field
|
||||
$value = $options['value'];
|
||||
// Default value for the field if not defined
|
||||
$finalValue = $value;
|
||||
}
|
||||
|
||||
$args[$field] = $value;
|
||||
settype($finalValue, gettype($value));
|
||||
$row[$field] = $finalValue;
|
||||
}
|
||||
|
||||
// Tags
|
||||
if (!empty($args['tags'])) {
|
||||
$args['tags'] = $this->generateTags($args['tags']);
|
||||
$row['tags'] = $this->generateTags($args['tags']);
|
||||
} else {
|
||||
$args['tags'] = array();
|
||||
$row['tags'] = array();
|
||||
}
|
||||
|
||||
// Slug from the title or the content
|
||||
@ -73,7 +70,7 @@ class dbPages extends dbJSON
|
||||
|
||||
// Parent
|
||||
if (!isset($args['parent'])) {
|
||||
$args['parent'] = '';
|
||||
$row['parent'] = '';
|
||||
}
|
||||
|
||||
// Generate key
|
||||
@ -81,60 +78,38 @@ class dbPages extends dbJSON
|
||||
|
||||
// Generate UUID
|
||||
if (empty($args['uuid'])) {
|
||||
$args['uuid'] = $this->generateUUID();
|
||||
$row['uuid'] = $this->generateUUID();
|
||||
}
|
||||
|
||||
// Validate date
|
||||
if (!Valid::date($args['date'], DB_DATE_FORMAT)) {
|
||||
$args['date'] = Date::current(DB_DATE_FORMAT);
|
||||
$row['date'] = Date::current(DB_DATE_FORMAT);
|
||||
}
|
||||
|
||||
// Schedule page
|
||||
if (($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['status']=='published')) {
|
||||
$args['status'] = '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 (($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['type']=='published')) {
|
||||
$row['type'] = 'scheduled';
|
||||
}
|
||||
|
||||
if ($climode===false) {
|
||||
// Create the directory
|
||||
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;
|
||||
}
|
||||
|
||||
// Make the index.txt and save the file.
|
||||
$data = implode(PHP_EOL, $dataForFile);
|
||||
if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $data) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
|
||||
// Create the index.txt and save the file
|
||||
if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $args['content']) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the content in the file ['.FILENAME.']',LOG_TYPE_ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Checksum MD5
|
||||
$dataForDb['md5file'] = md5_file(PATH_PAGES.$key.DS.FILENAME);
|
||||
$row['md5file'] = md5_file(PATH_PAGES.$key.DS.FILENAME);
|
||||
|
||||
// Insert in database
|
||||
$this->db[$key] = $dataForDb;
|
||||
$this->db[$key] = $row;
|
||||
|
||||
// Sort database
|
||||
$this->sortBy();
|
||||
@ -147,78 +122,48 @@ class dbPages extends dbJSON
|
||||
|
||||
public function edit($args, $climode=false)
|
||||
{
|
||||
$dataForDb = array();
|
||||
$dataForFile = array();
|
||||
$row = array();
|
||||
|
||||
// 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 ($options['inFile'] || is_array($args[$field])) {
|
||||
$value = $args[$field];
|
||||
} else {
|
||||
// Sanitize if will be stored on database
|
||||
$value = Sanitize::html($args[$field]);
|
||||
}
|
||||
// Sanitize if will be stored on database
|
||||
$finalValue = Sanitize::html($args[$field]);
|
||||
} else {
|
||||
// By default is the current value
|
||||
if (isset($this->db[$args['key']][$field])) {
|
||||
$value = $this->db[$args['key']][$field];
|
||||
} else {
|
||||
$value = $options['value'];
|
||||
}
|
||||
// Default value for the field if not defined
|
||||
$finalValue = $value;
|
||||
}
|
||||
|
||||
$args[$field] = $value;
|
||||
settype($finalValue, gettype($value));
|
||||
$row[$field] = $finalValue;
|
||||
}
|
||||
|
||||
// Tags
|
||||
if (!empty($args['tags'])) {
|
||||
$args['tags'] = $this->generateTags($args['tags']);
|
||||
$row['tags'] = $this->generateTags($args['tags']);
|
||||
} else {
|
||||
$args['tags'] = array();
|
||||
$row['tags'] = array();
|
||||
}
|
||||
|
||||
// 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 ($this->db[$args['key']]['status']=='draft') {
|
||||
$args['date'] = Date::current(DB_DATE_FORMAT);
|
||||
if ($this->db[$args['key']]['type']=='draft') {
|
||||
$row['date'] = Date::current(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
|
||||
$args['dateModified'] = Date::current(DB_DATE_FORMAT);
|
||||
$row['dateModified'] = Date::current(DB_DATE_FORMAT);
|
||||
|
||||
// Schedule page
|
||||
if (($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['status']=='published')) {
|
||||
$args['status'] = '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 (($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['type']=='published')) {
|
||||
$row['type'] = 'scheduled';
|
||||
}
|
||||
|
||||
if ($climode===false) {
|
||||
@ -231,8 +176,7 @@ class dbPages extends dbJSON
|
||||
}
|
||||
|
||||
// Make the index.txt and save the file.
|
||||
$data = implode("\n", $dataForFile);
|
||||
if (file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $data)===false) {
|
||||
if (file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $args['content'])===false) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
|
||||
return false;
|
||||
}
|
||||
@ -245,10 +189,10 @@ class dbPages extends dbJSON
|
||||
$this->reindexChildren($args['key'], $newKey);
|
||||
|
||||
// Checksum MD5
|
||||
$dataForDb['md5file'] = md5_file(PATH_PAGES.$newKey.DS.FILENAME);
|
||||
$row['md5file'] = md5_file(PATH_PAGES.$newKey.DS.FILENAME);
|
||||
|
||||
// Insert in database
|
||||
$this->db[$newKey] = $dataForDb;
|
||||
$this->db[$newKey] = $row;
|
||||
|
||||
// Sort database
|
||||
$this->sortBy();
|
||||
@ -332,15 +276,14 @@ class dbPages extends dbJSON
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
// Change a field's value
|
||||
// Set field = value
|
||||
public function setField($key, $field, $value)
|
||||
{
|
||||
if ($this->exists($key)) {
|
||||
settype($value, gettype($this->dbFields[$field]['value']));
|
||||
settype($value, gettype($this->dbFields[$field]));
|
||||
$this->db[$key][$field] = $value;
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -349,7 +292,7 @@ class dbPages extends dbJSON
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach ($tmp as $key=>$fields) {
|
||||
if ($fields['status']!='published') {
|
||||
if ($fields['type']!='published') {
|
||||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
@ -365,7 +308,7 @@ class dbPages extends dbJSON
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach ($tmp as $key=>$fields) {
|
||||
if ($fields['status']!='static') {
|
||||
if ($fields['type']!='static') {
|
||||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
@ -381,7 +324,7 @@ class dbPages extends dbJSON
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach ($tmp as $key=>$fields) {
|
||||
if($fields['status']!='draft') {
|
||||
if($fields['type']!='draft') {
|
||||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
@ -396,7 +339,7 @@ class dbPages extends dbJSON
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach ($tmp as $key=>$fields) {
|
||||
if($fields['status']!='scheduled') {
|
||||
if($fields['type']!='scheduled') {
|
||||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
@ -411,7 +354,7 @@ class dbPages extends dbJSON
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach ($tmp as $key=>$fields) {
|
||||
if($fields['status']!='sticky') {
|
||||
if($fields['type']!='sticky') {
|
||||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
@ -446,12 +389,12 @@ class dbPages extends dbJSON
|
||||
// Returns the next page key of the current page key
|
||||
public function nextPageKey($currentKey)
|
||||
{
|
||||
if ($this->db[$currentKey]['status']=='published') {
|
||||
if ($this->db[$currentKey]['type']=='published') {
|
||||
$keys = array_keys($this->db);
|
||||
$position = array_search($currentKey, $keys) - 1;
|
||||
if (isset($keys[$position])) {
|
||||
$nextKey = $keys[$position];
|
||||
if ($this->db[$nextKey]['status']=='published') {
|
||||
if ($this->db[$nextKey]['type']=='published') {
|
||||
return $nextKey;
|
||||
}
|
||||
}
|
||||
@ -462,12 +405,12 @@ class dbPages extends dbJSON
|
||||
// Returns the previous page key of the current page key
|
||||
public function previousPageKey($currentKey)
|
||||
{
|
||||
if ($this->db[$currentKey]['status']=='published') {
|
||||
if ($this->db[$currentKey]['type']=='published') {
|
||||
$keys = array_keys($this->db);
|
||||
$position = array_search($currentKey, $keys) + 1;
|
||||
if (isset($keys[$position])) {
|
||||
$prevKey = $keys[$position];
|
||||
if ($this->db[$prevKey]['status']=='published') {
|
||||
if ($this->db[$prevKey]['type']=='published') {
|
||||
return $prevKey;
|
||||
}
|
||||
}
|
||||
@ -641,13 +584,13 @@ class dbPages extends dbJSON
|
||||
|
||||
// The database need to be sorted by date
|
||||
foreach($this->db as $pageKey=>$fields) {
|
||||
if($fields['status']=='scheduled') {
|
||||
if($fields['type']=='scheduled') {
|
||||
if($fields['date']<=$currentDate) {
|
||||
$this->db[$pageKey]['status'] = 'published';
|
||||
$this->db[$pageKey]['type'] = 'published';
|
||||
$saveDatabase = true;
|
||||
}
|
||||
}
|
||||
elseif( ($fields['status']=='published') && (ORDER_BY=='date') ) {
|
||||
elseif( ($fields['type']=='published') && (ORDER_BY=='date') ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -780,8 +723,8 @@ class dbPages extends dbJSON
|
||||
}
|
||||
|
||||
// Status
|
||||
if( !isset($db['status']) ) {
|
||||
$db['status'] = CLI_STATUS;
|
||||
if( !isset($db['type']) ) {
|
||||
$db['type'] = CLI_STATUS;
|
||||
}
|
||||
|
||||
// Owner username
|
||||
|
@ -308,13 +308,10 @@ class dbSite extends dbJSON
|
||||
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()
|
||||
{
|
||||
$pageNotFound = $this->getField('pageNotFound');
|
||||
if( empty($pageNotFound) ) {
|
||||
return false;
|
||||
}
|
||||
return $pageNotFound;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ function buildPage($key) {
|
||||
global $dbUsers;
|
||||
global $dbCategories;
|
||||
global $Parsedown;
|
||||
global $Site;
|
||||
global $site;
|
||||
|
||||
if (empty($key)) {
|
||||
return false;
|
||||
@ -34,7 +34,8 @@ function buildPage($key) {
|
||||
// Parse Markdown
|
||||
$contentRaw = $page->contentRaw();
|
||||
$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)
|
||||
$page->setField('content', $content, true);
|
||||
|
||||
@ -47,7 +48,7 @@ function buildPage($key) {
|
||||
$pageDate = $page->date();
|
||||
$page->setField('dateRaw', $pageDate, true);
|
||||
|
||||
$pageDateFormated = $page->dateRaw( $Site->dateFormat() );
|
||||
$pageDateFormated = $page->dateRaw( $site->dateFormat() );
|
||||
$page->setField('date', $pageDateFormated, true);
|
||||
|
||||
// Generate and set the User object
|
||||
@ -82,46 +83,46 @@ function reindexTags() {
|
||||
return $dbTags->reindex();
|
||||
}
|
||||
|
||||
// Generate on the fly a 404 page-not-found
|
||||
// Returns a Page-Object
|
||||
// Generate the page 404 Not found
|
||||
function buildErrorPage() {
|
||||
global $dbPages;
|
||||
global $Language;
|
||||
global $site;
|
||||
global $language;
|
||||
global $dbUsers;
|
||||
|
||||
$page = new Page(false);
|
||||
$page->setField('title', $Language->get('page-not-found'));
|
||||
$page->setField('content', $Language->get('page-not-found-content'));
|
||||
$page->setField('user', $dbUsers->getUser('admin'));
|
||||
try {
|
||||
$pageNotFoundKey = $site->pageNotFound();
|
||||
$pageNotFound = New PageX($pageNotFoundKey);
|
||||
} 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 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
|
||||
function buildThePage() {
|
||||
global $Url;
|
||||
global $page, $Page;
|
||||
global $content, $pages;
|
||||
global $url;
|
||||
|
||||
$page = $Page = buildPage( $Url->slug() );
|
||||
|
||||
// The page doesn't exist
|
||||
if ($page===false) {
|
||||
$Url->setNotFound();
|
||||
return false;
|
||||
}
|
||||
// The page is NOT published
|
||||
elseif ( $page->scheduled() || $page->draft() ) {
|
||||
$Url->setNotFound();
|
||||
try {
|
||||
$pageKey = $url->slug();
|
||||
$page = New PageX($pageKey);
|
||||
} catch (Exception $e) {
|
||||
$url->setNotFound();
|
||||
return false;
|
||||
}
|
||||
|
||||
// The page was generate successfully
|
||||
$content[0] = $pages[0] = $page;
|
||||
return true;
|
||||
// Check if the page is NOT published
|
||||
if ( !$page->published() ) {
|
||||
$url->setNotFound();
|
||||
return false;
|
||||
}
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
// 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!
|
||||
function buildPagesByCategory() {
|
||||
global $Url;
|
||||
global $url;
|
||||
|
||||
$categoryKey = $Url->slug();
|
||||
$categoryKey = $url->slug();
|
||||
return buildPagesFor('category', $categoryKey, false);
|
||||
}
|
||||
|
||||
// This function is only used from the rule 69.pages.php, DO NOT use this function!
|
||||
function buildPagesByTag() {
|
||||
global $Url;
|
||||
global $url;
|
||||
|
||||
$tagKey = $Url->slug();
|
||||
$tagKey = $url->slug();
|
||||
return buildPagesFor('tag', false, $tagKey);
|
||||
}
|
||||
|
||||
// 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()
|
||||
function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
|
||||
global $dbPages;
|
||||
global $dbCategories;
|
||||
global $dbTags;
|
||||
global $Site;
|
||||
global $Url;
|
||||
global $content, $pages;
|
||||
global $site;
|
||||
global $url;
|
||||
|
||||
// Get the page number from URL
|
||||
$pageNumber = $Url->pageNumber();
|
||||
$pageNumber = $url->pageNumber();
|
||||
|
||||
if ($for=='home') {
|
||||
$onlyPublished = true;
|
||||
$amountOfItems = $Site->itemsPerPage();
|
||||
$amountOfItems = $site->itemsPerPage();
|
||||
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
|
||||
// Include sticky pages only in the first page
|
||||
@ -171,29 +171,30 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
|
||||
}
|
||||
}
|
||||
elseif ($for=='category') {
|
||||
$amountOfItems = $Site->itemsPerPage();
|
||||
$amountOfItems = $site->itemsPerPage();
|
||||
$list = $dbCategories->getList($categoryKey, $pageNumber, $amountOfItems);
|
||||
}
|
||||
elseif ($for=='tag') {
|
||||
$amountOfItems = $Site->itemsPerPage();
|
||||
$amountOfItems = $site->itemsPerPage();
|
||||
$list = $dbTags->getList($tagKey, $pageNumber, $amountOfItems);
|
||||
}
|
||||
|
||||
// There are not items, invalid tag, invalid category, out of range, etc...
|
||||
if ($list===false) {
|
||||
$Url->setNotFound();
|
||||
$url->setNotFound();
|
||||
return false;
|
||||
}
|
||||
|
||||
$pages = array(); // global variable
|
||||
$content = array();
|
||||
foreach ($list as $pageKey) {
|
||||
$page = buildPage($pageKey);
|
||||
if ($page!==false) {
|
||||
array_push($pages, $page);
|
||||
try {
|
||||
$page = new PageX($pageKey);
|
||||
array_push($content, $page);
|
||||
} catch (Exception $e) {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
$content = $pages;
|
||||
return $pages;
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Returns an array with all the static pages as Page-Object
|
||||
@ -203,9 +204,13 @@ function buildStaticPages() {
|
||||
|
||||
$list = array();
|
||||
$staticPages = $dbPages->getStaticDB();
|
||||
foreach ($staticPages as $pageKey) {
|
||||
$staticPage = buildPage($pageKey);
|
||||
array_push($list, $staticPage);
|
||||
foreach ($staticPages as $staticPageKey) {
|
||||
try {
|
||||
$staticPage = new PageX($staticPageKey);
|
||||
array_push($list, $staticPage);
|
||||
} catch (Exception $e) {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
@ -399,10 +404,12 @@ function createPage($args) {
|
||||
global $Language;
|
||||
|
||||
// Check if the autosave page exists for this new page and delete it
|
||||
$autosaveKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
||||
if (!empty($autosaveKey)) {
|
||||
Log::set('Function createPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
|
||||
deletePage($autosaveKey);
|
||||
if (isset($args['uuid'])) {
|
||||
$autosaveKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
||||
if (!empty($autosaveKey)) {
|
||||
Log::set('Function createPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
|
||||
deletePage($autosaveKey);
|
||||
}
|
||||
}
|
||||
|
||||
// The user is always the one loggued
|
||||
@ -443,10 +450,12 @@ function editPage($args) {
|
||||
global $syslog;
|
||||
|
||||
// Check if the autosave page exists for this new page and delete it
|
||||
$pageKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
||||
if (!empty($pageKey)) {
|
||||
Log::set('Function editPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
|
||||
deletePage($pageKey);
|
||||
if (isset($args['uuid'])) {
|
||||
$pageKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
||||
if (!empty($pageKey)) {
|
||||
Log::set('Function editPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
|
||||
deletePage($pageKey);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the key is not empty
|
||||
@ -656,13 +665,13 @@ function createUser($args) {
|
||||
}
|
||||
|
||||
function editSettings($args) {
|
||||
global $Site;
|
||||
global $site;
|
||||
global $syslog;
|
||||
global $Language;
|
||||
global $dbPages;
|
||||
|
||||
if (isset($args['language'])) {
|
||||
if ($args['language']!=$Site->language()) {
|
||||
if ($args['language']!=$site->language()) {
|
||||
$tmp = new dbJSON(PATH_LANGUAGES.$args['language'].'.json', false);
|
||||
if (isset($tmp->db['language-data']['locale'])) {
|
||||
$args['locale'] = $tmp->db['language-data']['locale'];
|
||||
@ -690,10 +699,10 @@ function editSettings($args) {
|
||||
$args['uriBlog'] = '';
|
||||
}
|
||||
|
||||
if ($Site->set($args)) {
|
||||
if ($site->set($args)) {
|
||||
// Check current order-by if changed it reorder the content
|
||||
if ($Site->orderBy()!=ORDER_BY) {
|
||||
if ($Site->orderBy()=='date') {
|
||||
if ($site->orderBy()!=ORDER_BY) {
|
||||
if ($site->orderBy()=='date') {
|
||||
$dbPages->sortByDate();
|
||||
} else {
|
||||
$dbPages->sortByPosition();
|
||||
@ -881,11 +890,11 @@ function getTags() {
|
||||
}
|
||||
|
||||
function activateTheme($themeDirectory) {
|
||||
global $Site;
|
||||
global $site;
|
||||
global $syslog;
|
||||
|
||||
if (Sanitize::pathFile(PATH_THEMES.$themeDirectory)) {
|
||||
$Site->set(array('theme'=>$themeDirname));
|
||||
$site->set(array('theme'=>$themeDirname));
|
||||
|
||||
$syslog->add(array(
|
||||
'dictionaryKey'=>'new-theme-configured',
|
||||
|
@ -87,16 +87,16 @@ class Paginator {
|
||||
// Return the absoulte URL with the page number
|
||||
public static function numberUrl($pageNumber)
|
||||
{
|
||||
global $Url;
|
||||
global $url;
|
||||
|
||||
$domain = trim(DOMAIN_BASE,'/');
|
||||
$filter = trim($Url->activeFilter(), '/');
|
||||
$filter = trim($url->activeFilter(), '/');
|
||||
|
||||
if(empty($filter)) {
|
||||
$url = $domain.'/'.$Url->slug();
|
||||
$url = $domain.'/'.$url->slug();
|
||||
}
|
||||
else {
|
||||
$url = $domain.'/'.$filter.'/'.$Url->slug();
|
||||
$url = $domain.'/'.$filter.'/'.$url->slug();
|
||||
}
|
||||
|
||||
return $url.'?page='.$pageNumber;
|
||||
|
@ -4,26 +4,26 @@ class Theme {
|
||||
|
||||
public static function title()
|
||||
{
|
||||
global $Site;
|
||||
return $Site->title();
|
||||
global $site;
|
||||
return $site->title();
|
||||
}
|
||||
|
||||
public static function description()
|
||||
{
|
||||
global $Site;
|
||||
return $Site->description();
|
||||
global $site;
|
||||
return $site->description();
|
||||
}
|
||||
|
||||
public static function slogan()
|
||||
{
|
||||
global $Site;
|
||||
return $Site->slogan();
|
||||
global $site;
|
||||
return $site->slogan();
|
||||
}
|
||||
|
||||
public static function footer()
|
||||
{
|
||||
global $Site;
|
||||
return $Site->footer();
|
||||
global $site;
|
||||
return $site->footer();
|
||||
}
|
||||
|
||||
public static function rssUrl()
|
||||
@ -44,8 +44,8 @@ class Theme {
|
||||
|
||||
public static function siteUrl()
|
||||
{
|
||||
global $Site;
|
||||
return $Site->url();
|
||||
global $site;
|
||||
return $site->url();
|
||||
}
|
||||
|
||||
public static function adminUrl()
|
||||
@ -100,11 +100,11 @@ class Theme {
|
||||
|
||||
public static function metaTagDescription()
|
||||
{
|
||||
global $Site;
|
||||
global $site;
|
||||
global $WHERE_AM_I;
|
||||
global $page;
|
||||
|
||||
$description = $Site->description();
|
||||
$description = $site->description();
|
||||
|
||||
if( $WHERE_AM_I=='page' ) {
|
||||
$description = $page->description();
|
||||
@ -198,7 +198,7 @@ class Theme {
|
||||
|
||||
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()
|
||||
|
@ -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;
|
||||
});
|
||||
});
|
6
bl-kernel/js/bootstrap-bundle.min.js
vendored
6
bl-kernel/js/bootstrap-bundle.min.js
vendored
File diff suppressed because one or more lines are too long
6
bl-kernel/js/bootstrap.bundle.min.js
vendored
Normal file
6
bl-kernel/js/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -3,76 +3,6 @@
|
||||
// DEPRECATED
|
||||
// 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) {
|
||||
var map = {
|
||||
'&': '&',
|
||||
|
@ -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_THUMBNAILS = "'.HTML_PATH_UPLOADS_THUMBNAILS.'";'.PHP_EOL;
|
||||
echo 'var PARENT = "'.PARENT.'";'.PHP_EOL;
|
||||
|
||||
echo 'var BLUDIT_VERSION = "'.BLUDIT_VERSION.'";'.PHP_EOL;
|
||||
echo 'var BLUDIT_BUILD = "'.BLUDIT_BUILD.'";'.PHP_EOL;
|
||||
|
||||
echo 'var DOMAIN_UPLOADS = "'.DOMAIN_UPLOADS.'";'.PHP_EOL;
|
||||
|
||||
echo 'var DB_DATE_FORMAT = "'.DB_DATE_FORMAT.'";'.PHP_EOL;
|
||||
|
||||
echo 'var AUTOSAVE_INTERVAL = "'.AUTOSAVE_INTERVAL.'";'.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
526
bl-kernel/pagex.class.php
Normal 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';
|
||||
}
|
||||
}
|
@ -44,10 +44,9 @@ class pluginAPI extends Plugin {
|
||||
|
||||
public function beforeAll()
|
||||
{
|
||||
global $Url;
|
||||
global $url;
|
||||
global $dbPages;
|
||||
global $dbUsers;
|
||||
global $login;
|
||||
|
||||
// CHECK URL
|
||||
// ------------------------------------------------------------
|
||||
@ -103,8 +102,8 @@ class pluginAPI extends Plugin {
|
||||
// Get the object user to check the role
|
||||
$user = $dbUsers->getUser($username);
|
||||
if (($user->role()=='admin') && ($user->enabled())) {
|
||||
|
||||
// Loggin the user to create the session
|
||||
$login = new Login();
|
||||
$login->setLogin($username, 'admin');
|
||||
// Enable write permissions
|
||||
$writePermissions = true;
|
||||
@ -262,9 +261,9 @@ class pluginAPI extends Plugin {
|
||||
private function getPage($key)
|
||||
{
|
||||
// Generate the object Page
|
||||
$Page = buildPage($key);
|
||||
$page = buildPage($key);
|
||||
|
||||
if (!$Page) {
|
||||
if (!$page) {
|
||||
return array(
|
||||
'status'=>'1',
|
||||
'message'=>'Page not found.'
|
||||
@ -274,7 +273,7 @@ class pluginAPI extends Plugin {
|
||||
return array(
|
||||
'status'=>'0',
|
||||
'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
|
||||
if (isset($args['content'])) {
|
||||
$args['content'] = Text::htmlDecode($args['content']);
|
||||
$args['content'] = Sanitize::htmlDecode($args['content']);
|
||||
}
|
||||
|
||||
// This function is defined on functions.php
|
||||
|
@ -44,18 +44,18 @@ class pluginDisqus extends Plugin {
|
||||
|
||||
public function pageEnd()
|
||||
{
|
||||
global $pages;
|
||||
global $Url, $Page;
|
||||
global $content;
|
||||
global $url, $page;
|
||||
|
||||
$page = $pages[0];
|
||||
$page = $content[0];
|
||||
if (empty($page)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !$Url->notFound() &&
|
||||
( $Url->whereAmI()=='page' &&
|
||||
(($this->getDbField('enablePosts') && $Page->status()=='published') ||
|
||||
($this->getDbField('enablePages') && $Page->status()=='static'))
|
||||
if ( !$url->notFound() &&
|
||||
( $url->whereAmI()=='page' &&
|
||||
(($this->getDbField('enablePosts') && $page->status()=='published') ||
|
||||
($this->getDbField('enablePages') && $page->status()=='static'))
|
||||
) &&
|
||||
$page->allowComments() ) {
|
||||
$html = '<div id="disqus_thread"></div>';
|
||||
|
@ -50,8 +50,8 @@ class pluginNavigation extends Plugin {
|
||||
public function siteSidebar()
|
||||
{
|
||||
global $Language;
|
||||
global $Url;
|
||||
global $Site;
|
||||
global $url;
|
||||
global $site;
|
||||
global $dbPages;
|
||||
|
||||
// HTML for sidebar
|
||||
@ -69,7 +69,7 @@ class pluginNavigation extends Plugin {
|
||||
// Show Home page link
|
||||
if ($this->getValue('homeLink')) {
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="' . $Site->url() . '">' . $Language->get('Home page') . '</a>';
|
||||
$html .= '<a href="' . $site->url() . '">' . $Language->get('Home page') . '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
|
@ -29,20 +29,20 @@ class pluginOpenGraph extends Plugin {
|
||||
|
||||
public function siteHead()
|
||||
{
|
||||
global $Url;
|
||||
global $Site;
|
||||
global $url;
|
||||
global $site;
|
||||
global $WHERE_AM_I;
|
||||
global $pages;
|
||||
global $page;
|
||||
global $content;
|
||||
|
||||
$og = array(
|
||||
'locale' =>$Site->locale(),
|
||||
'locale' =>$site->locale(),
|
||||
'type' =>'website',
|
||||
'title' =>$Site->title(),
|
||||
'description' =>$Site->description(),
|
||||
'url' =>$Site->url(),
|
||||
'title' =>$site->title(),
|
||||
'description' =>$site->description(),
|
||||
'url' =>$site->url(),
|
||||
'image' =>'',
|
||||
'siteName' =>$Site->title()
|
||||
'siteName' =>$site->title()
|
||||
);
|
||||
|
||||
switch ($WHERE_AM_I) {
|
||||
@ -54,16 +54,16 @@ class pluginOpenGraph extends Plugin {
|
||||
$og['url'] = $page->permalink($absolute=true);
|
||||
$og['image'] = $page->coverImage($absolute=true);
|
||||
|
||||
$content = $page->content();
|
||||
$pageContent = $page->content();
|
||||
break;
|
||||
|
||||
// The user is in the homepage
|
||||
default:
|
||||
$content = '';
|
||||
$pageContent = '';
|
||||
// The image it's from the first page
|
||||
if (isset($pages[0]) ) {
|
||||
$og['image'] = $pages[0]->coverImage($absolute=true);
|
||||
$content = $pages[0]->content();
|
||||
if (isset($content[0]) ) {
|
||||
$og['image'] = $content[0]->coverImage($absolute=true);
|
||||
$pageContent = $content[0]->content();
|
||||
}
|
||||
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 (empty($og['image'])) {
|
||||
// Get the image from the content
|
||||
$src = DOM::getFirstImage($content);
|
||||
$src = DOM::getFirstImage($pageContent);
|
||||
if ($src!==false) {
|
||||
$og['image'] = $src;
|
||||
} else {
|
||||
|
@ -35,9 +35,9 @@ class pluginRSS extends Plugin {
|
||||
|
||||
private function createXML()
|
||||
{
|
||||
global $Site;
|
||||
global $site;
|
||||
global $dbPages;
|
||||
global $Url;
|
||||
global $url;
|
||||
|
||||
// Amount of pages to show
|
||||
$amountOfItems = $this->getValue('amountOfItems');
|
||||
@ -49,17 +49,17 @@ class pluginRSS extends Plugin {
|
||||
$onlyPublished = true;
|
||||
|
||||
// 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 .= '<rss version="2.0">';
|
||||
$xml .= '<channel>';
|
||||
$xml .= '<title>'.$Site->title().'</title>';
|
||||
$xml .= '<link>'.$Site->url().'</link>';
|
||||
$xml .= '<description>'.$Site->description().'</description>';
|
||||
$xml .= '<title>'.$site->title().'</title>';
|
||||
$xml .= '<link>'.$site->url().'</link>';
|
||||
$xml .= '<description>'.$site->description().'</description>';
|
||||
|
||||
// Get keys of pages
|
||||
foreach($pages as $pageKey) {
|
||||
foreach($list as $pageKey) {
|
||||
// Create the page object from the page key
|
||||
$page = buildPage($pageKey);
|
||||
$xml .= '<item>';
|
||||
|
3
bl-plugins/simple-stats/js/chartist.min.js
vendored
3
bl-plugins/simple-stats/js/chartist.min.js
vendored
File diff suppressed because one or more lines are too long
@ -22,23 +22,23 @@ class pluginSitemap extends Plugin {
|
||||
|
||||
private function createXML()
|
||||
{
|
||||
global $Site;
|
||||
global $site;
|
||||
global $dbPages;
|
||||
|
||||
$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
|
||||
|
||||
$xml .= '<url>';
|
||||
$xml .= '<loc>'.$Site->url().'</loc>';
|
||||
$xml .= '<loc>'.$site->url().'</loc>';
|
||||
$xml .= '</url>';
|
||||
|
||||
// Get DB
|
||||
$pageNumber = 1;
|
||||
$amountOfItems = -1;
|
||||
$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
|
||||
$page = buildPage($pageKey);
|
||||
|
||||
|
@ -42,8 +42,8 @@ class pluginStaticPages extends Plugin {
|
||||
public function siteSidebar()
|
||||
{
|
||||
global $Language;
|
||||
global $Url;
|
||||
global $Site;
|
||||
global $url;
|
||||
global $site;
|
||||
global $dbPages;
|
||||
|
||||
// HTML for sidebar
|
||||
@ -61,7 +61,7 @@ class pluginStaticPages extends Plugin {
|
||||
// Show Home page link
|
||||
if ($this->getValue('homeLink')) {
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="' . $Site->url() . '">' . $Language->get('Home page') . '</a>';
|
||||
$html .= '<a href="' . $site->url() . '">' . $Language->get('Home page') . '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ class pluginTags extends Plugin {
|
||||
{
|
||||
global $Language;
|
||||
global $dbTags;
|
||||
global $Url;
|
||||
global $url;
|
||||
|
||||
$filter = $Url->filters('tag');
|
||||
$filter = $url->filters('tag');
|
||||
|
||||
$html = '<div class="plugin plugin-tags">';
|
||||
$html .= '<h2 class="plugin-label">'.$this->getDbField('label').'</h2>';
|
||||
|
@ -2,8 +2,8 @@
|
||||
"author": "TinyMCE",
|
||||
"email": "",
|
||||
"website": "https://www.tinymce.com",
|
||||
"version": "4.7.13",
|
||||
"releaseDate": "2018-05-16",
|
||||
"version": "4.8.0",
|
||||
"releaseDate": "2018-07-11",
|
||||
"license": "GPL v2",
|
||||
"compatible": "3.0",
|
||||
"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
4
bl-plugins/tinymce/tinymce/tinymce.min.js
vendored
4
bl-plugins/tinymce/tinymce/tinymce.min.js
vendored
File diff suppressed because one or more lines are too long
@ -28,17 +28,17 @@ class pluginTwitterCards extends Plugin {
|
||||
|
||||
public function siteHead()
|
||||
{
|
||||
global $Url;
|
||||
global $Site;
|
||||
global $url;
|
||||
global $site;
|
||||
global $WHERE_AM_I;
|
||||
global $pages;
|
||||
global $content;
|
||||
global $page;
|
||||
|
||||
$data = array(
|
||||
'card' =>'summary',
|
||||
'site' =>'',
|
||||
'title' =>$Site->title(),
|
||||
'description' =>$Site->description(),
|
||||
'title' =>$site->title(),
|
||||
'description' =>$site->description(),
|
||||
'image' =>''
|
||||
);
|
||||
|
||||
@ -49,16 +49,16 @@ class pluginTwitterCards extends Plugin {
|
||||
$data['description'] = $page->description();
|
||||
$data['image'] = $page->coverImage($absolute=true);
|
||||
|
||||
$content = $page->content();
|
||||
$pageContent = $page->content();
|
||||
break;
|
||||
|
||||
// The user is in the homepage
|
||||
default:
|
||||
$content = '';
|
||||
$pageContent = '';
|
||||
// The image it's from the first page
|
||||
if(isset($pages[0]) ) {
|
||||
$data['image'] = $pages[0]->coverImage($absolute=true);
|
||||
$content = $pages[0]->content();
|
||||
if(isset($content[0]) ) {
|
||||
$data['image'] = $content[0]->coverImage($absolute=true);
|
||||
$pageContent = $content[0]->content();
|
||||
}
|
||||
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( empty($data['image']) ) {
|
||||
// Get the image from the content
|
||||
$src = DOM::getFirstImage($content);
|
||||
$src = DOM::getFirstImage($pageContent);
|
||||
if ($src!==false) {
|
||||
$data['image'] = $src;
|
||||
} else {
|
||||
|
@ -15,7 +15,7 @@
|
||||
<h1 class="title"><?php echo $page->title(); ?></h1>
|
||||
</a>
|
||||
|
||||
<?php if (!$page->isStatic() && !$Url->notFound()): ?>
|
||||
<?php if (!$page->isStatic() && !$url->notFound()): ?>
|
||||
<!-- Creation date -->
|
||||
<h6 class="card-subtitle mb-3 text-muted"><?php echo $page->date(); ?> - <?php echo $Language->get('Reading time') . ': ' . $page->readingTime() ?></h6>
|
||||
<?php endif ?>
|
||||
|
@ -33,7 +33,7 @@ define('PATH_BOOT', PATH_ROOT.'bl-kernel'.DS.'boot'.DS);
|
||||
require(PATH_BOOT.'init.php');
|
||||
|
||||
// Admin area
|
||||
if ($Url->whereAmI()==='admin') {
|
||||
if ($url->whereAmI()==='admin') {
|
||||
require(PATH_BOOT.'admin.php');
|
||||
}
|
||||
// Site
|
||||
|
33
install.php
33
install.php
@ -307,12 +307,17 @@ function install($adminPassword, $timezone)
|
||||
|
||||
$data = array();
|
||||
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'=>'',
|
||||
'username'=>'admin',
|
||||
'tags'=>array(),
|
||||
'status'=>'published',
|
||||
'type'=>'page',
|
||||
'type'=>'published',
|
||||
'date'=>$currentDate,
|
||||
'dateModified'=>'',
|
||||
'allowComments'=>true,
|
||||
@ -322,8 +327,13 @@ function install($adminPassword, $timezone)
|
||||
'category'=>'',
|
||||
'uuid'=>md5(uniqid()),
|
||||
'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);
|
||||
|
||||
@ -487,19 +497,6 @@ function install($adminPassword, $timezone)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -552,7 +549,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
|
||||
<!-- 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/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>
|
||||
</head>
|
||||
<body class="login">
|
||||
|
Loading…
Reference in New Issue
Block a user