Remove posts
This commit is contained in:
parent
20224b03f4
commit
95e6500993
@ -81,19 +81,16 @@ class dbList extends dbJSON
|
||||
public function edit($oldKey, $newName)
|
||||
{
|
||||
$newKey = $this->generateKey($newName);
|
||||
if( isset($this->db[$newKey]) ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error the key already exist');
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->db[$newKey]['name'] = $newName;
|
||||
$this->db[$newKey]['list'] = $this->db[$oldKey]['list'];
|
||||
|
||||
// Remove the old category
|
||||
unset( $this->db[$oldKey] );
|
||||
if( $oldKey != $newKey ) {
|
||||
unset( $this->db[$oldKey] );
|
||||
}
|
||||
|
||||
$this->save();
|
||||
|
||||
return $newKey;
|
||||
}
|
||||
|
||||
@ -133,4 +130,9 @@ class dbList extends dbJSON
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function exists($key)
|
||||
{
|
||||
return isset( $this->db[$key] );
|
||||
}
|
||||
|
||||
}
|
@ -3,88 +3,88 @@
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
function updateBludit()
|
||||
{
|
||||
global $Site;
|
||||
global $dbPosts;
|
||||
global $dbPages;
|
||||
// function updateBludit()
|
||||
// {
|
||||
// global $Site;
|
||||
// global $dbPosts;
|
||||
// global $dbPages;
|
||||
|
||||
// Check if Bludit need to be update.
|
||||
if( ($Site->currentBuild() < BLUDIT_BUILD) || isset($_GET['update']) )
|
||||
{
|
||||
// LOG
|
||||
Log::set('UPDATE SYSTEM - Starting...');
|
||||
// // Check if Bludit need to be update.
|
||||
// if( ($Site->currentBuild() < BLUDIT_BUILD) || isset($_GET['update']) )
|
||||
// {
|
||||
// // LOG
|
||||
// Log::set('UPDATE SYSTEM - Starting...');
|
||||
|
||||
// LOG
|
||||
Log::set('UPDATE SYSTEM - Checking posts.');
|
||||
// // LOG
|
||||
// Log::set('UPDATE SYSTEM - Checking posts.');
|
||||
|
||||
// Update posts
|
||||
foreach($dbPosts->db as $key=>$post) {
|
||||
// // Update posts
|
||||
// foreach($dbPosts->db as $key=>$post) {
|
||||
|
||||
// Dates
|
||||
$date = Date::format($post['date'], 'Y-m-d H:i', DB_DATE_FORMAT);
|
||||
if($date !== false) {
|
||||
$dbPosts->setPostDb($key, 'date', $date);
|
||||
}
|
||||
// // Dates
|
||||
// $date = Date::format($post['date'], 'Y-m-d H:i', DB_DATE_FORMAT);
|
||||
// if($date !== false) {
|
||||
// $dbPosts->setPostDb($key, 'date', $date);
|
||||
// }
|
||||
|
||||
// Checksum
|
||||
if( empty($post['md5file']) ) {
|
||||
$checksum = md5_file(PATH_POSTS.$key.DS.FILENAME);
|
||||
$dbPosts->setPostDb($key, 'md5file', $checksum);
|
||||
}
|
||||
}
|
||||
// // Checksum
|
||||
// if( empty($post['md5file']) ) {
|
||||
// $checksum = md5_file(PATH_POSTS.$key.DS.FILENAME);
|
||||
// $dbPosts->setPostDb($key, 'md5file', $checksum);
|
||||
// }
|
||||
// }
|
||||
|
||||
$dbPosts->save();
|
||||
// $dbPosts->save();
|
||||
|
||||
// LOG
|
||||
Log::set('UPDATE SYSTEM - Checking pages.');
|
||||
// // LOG
|
||||
// Log::set('UPDATE SYSTEM - Checking pages.');
|
||||
|
||||
// Update pages
|
||||
foreach($dbPages->db as $key=>$page) {
|
||||
// // Update pages
|
||||
// foreach($dbPages->db as $key=>$page) {
|
||||
|
||||
$date = Date::format($page['date'], 'Y-m-d H:i', DB_DATE_FORMAT);
|
||||
if($date !== false) {
|
||||
$dbPages->setField($key, 'date', $date);
|
||||
}
|
||||
// $date = Date::format($page['date'], 'Y-m-d H:i', DB_DATE_FORMAT);
|
||||
// if($date !== false) {
|
||||
// $dbPages->setField($key, 'date', $date);
|
||||
// }
|
||||
|
||||
// Checksum
|
||||
if( empty($post['md5file']) ) {
|
||||
$checksum = md5_file(PATH_PAGES.$key.DS.FILENAME);
|
||||
$dbPages->setField($key, 'md5file', $checksum);
|
||||
}
|
||||
}
|
||||
// // Checksum
|
||||
// if( empty($post['md5file']) ) {
|
||||
// $checksum = md5_file(PATH_PAGES.$key.DS.FILENAME);
|
||||
// $dbPages->setField($key, 'md5file', $checksum);
|
||||
// }
|
||||
// }
|
||||
|
||||
$dbPages->save();
|
||||
// $dbPages->save();
|
||||
|
||||
// LOG
|
||||
Log::set('UPDATE SYSTEM - Checking directories.');
|
||||
// // LOG
|
||||
// Log::set('UPDATE SYSTEM - Checking directories.');
|
||||
|
||||
// --- Update directories ---
|
||||
$directories = array(
|
||||
PATH_POSTS,
|
||||
PATH_PAGES,
|
||||
PATH_PLUGINS_DATABASES,
|
||||
PATH_UPLOADS_PROFILES,
|
||||
PATH_UPLOADS_THUMBNAILS,
|
||||
PATH_TMP
|
||||
);
|
||||
// // --- Update directories ---
|
||||
// $directories = array(
|
||||
// PATH_POSTS,
|
||||
// PATH_PAGES,
|
||||
// PATH_PLUGINS_DATABASES,
|
||||
// PATH_UPLOADS_PROFILES,
|
||||
// PATH_UPLOADS_THUMBNAILS,
|
||||
// PATH_TMP
|
||||
// );
|
||||
|
||||
foreach($directories as $dir) {
|
||||
// foreach($directories as $dir) {
|
||||
|
||||
// Check if the directory is already created.
|
||||
if(!file_exists($dir)) {
|
||||
// Create the directory recursive.
|
||||
mkdir($dir, DIR_PERMISSIONS, true);
|
||||
}
|
||||
}
|
||||
// // Check if the directory is already created.
|
||||
// if(!file_exists($dir)) {
|
||||
// // Create the directory recursive.
|
||||
// mkdir($dir, DIR_PERMISSIONS, true);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Set and save the database.
|
||||
$Site->set(array('currentBuild'=>BLUDIT_BUILD));
|
||||
// // Set and save the database.
|
||||
// $Site->set(array('currentBuild'=>BLUDIT_BUILD));
|
||||
|
||||
// LOG
|
||||
Log::set('UPDATE SYSTEM - Updated...');
|
||||
}
|
||||
}
|
||||
// // LOG
|
||||
// Log::set('UPDATE SYSTEM - Updated...');
|
||||
// }
|
||||
// }
|
||||
|
||||
// ============================================================================
|
||||
// Main before POST
|
||||
@ -99,20 +99,7 @@ function updateBludit()
|
||||
// ============================================================================
|
||||
|
||||
// Try update Bludit
|
||||
updateBludit();
|
||||
|
||||
// Get draft posts and schedules
|
||||
$_draftPosts = array();
|
||||
$_scheduledPosts = array();
|
||||
foreach($posts as $Post)
|
||||
{
|
||||
if($Post->draft()) {
|
||||
array_push($_draftPosts, $Post);
|
||||
}
|
||||
elseif($Post->scheduled()) {
|
||||
array_push($_scheduledPosts, $Post);
|
||||
}
|
||||
}
|
||||
//updateBludit();
|
||||
|
||||
// Get draft pages
|
||||
$_draftPages = array();
|
||||
|
@ -16,25 +16,23 @@ if($Login->role()!=='admin') {
|
||||
function edit($oldCategoryKey, $newCategory)
|
||||
{
|
||||
global $Language;
|
||||
global $dbPosts;
|
||||
global $dbPages;
|
||||
global $dbCategories;
|
||||
|
||||
if( Text::isEmpty($oldCategoryKey) || Text::isEmpty($newCategory) ) {
|
||||
Alert::set($Language->g('Empty field'));
|
||||
Redirect::page('admin', 'categories');
|
||||
Alert::set($Language->g('Empty fields'));
|
||||
Redirect::page('categories');
|
||||
}
|
||||
|
||||
|
||||
if( $dbCategories->edit($oldCategoryKey, $newCategory) == false ) {
|
||||
Alert::set($Language->g('Already exist a category'));
|
||||
}
|
||||
else {
|
||||
$dbPages->changeCategory($oldCategoryKey, $newCategory);
|
||||
$dbPosts->changeCategory($oldCategoryKey, $newCategory);
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
}
|
||||
|
||||
Redirect::page('admin', 'categories');
|
||||
Redirect::page('categories');
|
||||
}
|
||||
|
||||
function delete($categoryKey)
|
||||
@ -45,8 +43,7 @@ function delete($categoryKey)
|
||||
$dbCategories->remove($categoryKey);
|
||||
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
|
||||
Redirect::page('admin', 'categories');
|
||||
Redirect::page('categories');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -73,11 +70,11 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
|
||||
$categoryKey = $layout['parameters'];
|
||||
|
||||
if(!$dbCategories->exists($categoryKey)) {
|
||||
if( !$dbCategories->exists($categoryKey) ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the category: '.$categoryKey);
|
||||
Redirect::page('admin', 'categories');
|
||||
Redirect::page('categories');
|
||||
}
|
||||
|
||||
$category = $dbCategories->getName($layout['parameters']);
|
||||
|
||||
$layout['title'] .= ' - '.$Language->g('Edit category').' - '.$category;
|
||||
$layout['title'] .= ' - '.$Language->g('Edit Category').' - '.$category;
|
||||
|
@ -1,21 +0,0 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Check role
|
||||
// ============================================================================
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
// ============================================================================
|
||||
// Main before POST
|
||||
// ============================================================================
|
||||
|
||||
// ============================================================================
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
@ -44,7 +44,7 @@ function add($category)
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
if( add($_POST['category']) ) {
|
||||
Redirect::page('admin', 'categories');
|
||||
Redirect::page('categories');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,22 +16,31 @@ function addPage($args)
|
||||
// Add the page, if the $key is FALSE the creation of the post failure.
|
||||
$key = $dbPages->add($args);
|
||||
|
||||
if($key)
|
||||
{
|
||||
// Re index categories
|
||||
//reIndexCategoriesPages();
|
||||
if($key) {
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Call the plugins after page created.
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Call the plugins after page created
|
||||
Theme::plugins('afterPageCreate');
|
||||
|
||||
// Alert the user
|
||||
Alert::set($Language->g('Page added successfully'));
|
||||
Redirect::page('admin', 'manage-pages');
|
||||
// Create an alert
|
||||
Alert::set( $Language->g('Page added successfully') );
|
||||
|
||||
// Redirect
|
||||
Redirect::page('pages');
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the page.');
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the page');
|
||||
Log::set(__METHOD__.LOG_SEP.'Cleaning database...');
|
||||
$dbPages->delete($key);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -21,9 +21,9 @@ function setSettings($args)
|
||||
// Add slash at the begin and end.
|
||||
// This fields are in the settings->advanced mode
|
||||
$args['url'] = Text::addSlashes($args['url'],false,true);
|
||||
$args['uriPost'] = Text::addSlashes($args['uriPost']);
|
||||
$args['uriPage'] = Text::addSlashes($args['uriPage']);
|
||||
$args['uriTag'] = Text::addSlashes($args['uriTag']);
|
||||
$args['uriCategory'] = Text::addSlashes($args['uriCategory']);
|
||||
|
||||
if(($args['uriPost']==$args['uriPage']) || ($args['uriPost']==$args['uriTag']) || ($args['uriPage']==$args['uriTag']) )
|
||||
{
|
||||
|
@ -53,28 +53,10 @@ function setSettings($args)
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
setSettings($_POST);
|
||||
Redirect::page('admin', $layout['controller']);
|
||||
Redirect::page($layout['controller']);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
||||
|
||||
// Default home page
|
||||
$_homePageList = array(''=>$Language->g('Show blog'));
|
||||
foreach($pagesParents as $parentKey=>$pageList)
|
||||
{
|
||||
foreach($pageList as $Page)
|
||||
{
|
||||
if($parentKey!==NO_PARENT_CHAR) {
|
||||
$parentTitle = $pages[$Page->parentKey()]->title().'->';
|
||||
}
|
||||
else {
|
||||
$parentTitle = '';
|
||||
}
|
||||
|
||||
if($Page->published()) {
|
||||
$_homePageList[$Page->key()] = $Language->g('Page').': '.$parentTitle.$Page->title();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,22 +59,3 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
||||
|
||||
// Default home page
|
||||
$_homePageList = array(''=>$Language->g('Show blog'));
|
||||
foreach($pagesParents as $parentKey=>$pageList)
|
||||
{
|
||||
foreach($pageList as $Page)
|
||||
{
|
||||
if($parentKey!==NO_PARENT_CHAR) {
|
||||
$parentTitle = $pages[$Page->parentKey()]->title().'->';
|
||||
}
|
||||
else {
|
||||
$parentTitle = '';
|
||||
}
|
||||
|
||||
if($Page->published()) {
|
||||
$_homePageList[$Page->key()] = $Language->g('Page').': '.$parentTitle.$Page->title();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,23 +102,17 @@ $(document).ready(function() {
|
||||
</li>
|
||||
|
||||
<li class="uk-nav-header"><?php $L->p('Publish') ?></li>
|
||||
<li <?php echo ($layout['view']=='new-post')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-post' ?>"><?php $L->p('New post') ?></a>
|
||||
</li>
|
||||
<li <?php echo ($layout['view']=='new-page')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New page') ?></a>
|
||||
</li>
|
||||
|
||||
<li class="uk-nav-header"><?php $L->p('Manage') ?></li>
|
||||
<li <?php echo ($layout['view']=='manage-posts')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-posts' ?>"><?php $L->p('Posts') ?></a>
|
||||
</li>
|
||||
<li <?php echo ($layout['view']=='manage-pages')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><?php $L->p('Pages') ?></a>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'pages' ?>"><?php $L->p('Pages') ?></a>
|
||||
</li>
|
||||
<!--<li <?php echo ($layout['view']=='categories')?'class="uk-active"':'' ?>>
|
||||
<li <?php echo ($layout['view']=='categories')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Categories') ?></a>
|
||||
</li>-->
|
||||
</li>
|
||||
<li <?php echo ($layout['view']=='users')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>"><?php $L->p('Users') ?></a>
|
||||
</li>
|
||||
@ -131,7 +125,7 @@ $(document).ready(function() {
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-advanced' ?>"><?php $L->p('Advanced') ?></a>
|
||||
</li>
|
||||
<li <?php echo ($layout['view']=='settings-regional')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-regional' ?>"><?php $L->p('Language and timezone') ?></a>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-regional' ?>"><?php $L->p('Language') ?></a>
|
||||
</li>
|
||||
<li <?php echo ($layout['view']=='plugins')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins' ?>"><?php $L->p('Plugins') ?></a>
|
||||
|
@ -9,18 +9,18 @@ echo '
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.$L->g('Name').'</th>
|
||||
<th>'.$L->g('Key').'</th>
|
||||
<th>'.$L->g('URL').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
|
||||
$categories = $dbCategories->getAll();
|
||||
$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>'.$categoryKey.'</td>';
|
||||
echo '<td><a href="'.DOMAIN.$Url->filters('category', false).$categoryKey.'">'.DOMAIN.$Url->filters('category', false).$categoryKey.'</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
|
@ -66,10 +66,6 @@
|
||||
<table class="uk-table statistics">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><?php $Language->p('Posts') ?></td>
|
||||
<td><?php echo $dbPosts->count() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php $Language->p('Pages') ?></td>
|
||||
<td><?php echo $dbPages->count() ?></td>
|
||||
</tr>
|
||||
@ -89,13 +85,10 @@
|
||||
<h4 class="panel-title"><?php $L->p('Drafts') ?></h4>
|
||||
<ul class="uk-list">
|
||||
<?php
|
||||
if( empty($_draftPosts) && empty($_draftPages) ) {
|
||||
if( empty($_draftPages) ) {
|
||||
echo '<li>'.$Language->g('There are no drafts').'</li>';
|
||||
}
|
||||
else {
|
||||
foreach($_draftPosts as $Post) {
|
||||
echo '<li><span class="label-draft">'.$Language->g('Post').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->title()?$Post->title():'['.$Language->g('Empty title').'] ').'</a></li>';
|
||||
}
|
||||
foreach($_draftPages as $Page) {
|
||||
echo '<li><span class="label-draft">'.$Language->g('Page').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->title()?$Page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
|
||||
}
|
||||
|
@ -1,207 +0,0 @@
|
||||
<?php
|
||||
|
||||
HTML::title(array('title'=>$L->g('Edit post'), 'icon'=>'pencil'));
|
||||
|
||||
HTML::formOpen(array('class'=>'uk-form-stacked'));
|
||||
|
||||
// Security token
|
||||
HTML::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
));
|
||||
|
||||
// Key input
|
||||
HTML::formInputHidden(array(
|
||||
'name'=>'key',
|
||||
'value'=>$_Post->key()
|
||||
));
|
||||
|
||||
// LEFT SIDE
|
||||
// --------------------------------------------------------------------
|
||||
echo '<div class="uk-grid uk-grid-medium">';
|
||||
echo '<div class="bl-publish-view uk-width-8-10">';
|
||||
|
||||
// Title input
|
||||
HTML::formInputText(array(
|
||||
'name'=>'title',
|
||||
'value'=>$_Post->title(),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'placeholder'=>$L->g('Title')
|
||||
));
|
||||
|
||||
// Content input
|
||||
HTML::formTextarea(array(
|
||||
'name'=>'content',
|
||||
'value'=>$_Post->contentRaw(false),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'placeholder'=>''
|
||||
));
|
||||
|
||||
// Form buttons
|
||||
echo '<div class="uk-form-row uk-margin-bottom">
|
||||
<button class="uk-button uk-button-primary" type="submit">'.$L->g('Save').'</button>
|
||||
<button class="uk-button uk-button-primary" type="button" id="jsSaveDraft">'.$L->g('Save as draft').'</button>
|
||||
<button id="jsdelete-post" name="delete-post" class="uk-button" type="submit">'.$L->g('Delete').'</button>
|
||||
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'manage-posts">'.$L->g('Cancel').'</a>
|
||||
</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
// RIGHT SIDE
|
||||
// --------------------------------------------------------------------
|
||||
echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
|
||||
echo '<ul>';
|
||||
|
||||
// GENERAL TAB
|
||||
// --------------------------------------------------------------------
|
||||
echo '<li><h2 class="sidebar-button" data-view="sidebar-general-view"><i class="uk-icon-angle-down"></i> '.$L->g('General').'</h2></li>';
|
||||
echo '<li id="sidebar-general-view" class="sidebar-view">';
|
||||
|
||||
// Category
|
||||
/*
|
||||
HTML::formSelect(array(
|
||||
'name'=>'category',
|
||||
'label'=>$L->g('Category'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>$dbCategories->getAll(),
|
||||
'selected'=>$_Post->category(),
|
||||
'tip'=>'',
|
||||
'addEmptySpace'=>true
|
||||
));*/
|
||||
|
||||
// Description input
|
||||
HTML::formTextarea(array(
|
||||
'name'=>'description',
|
||||
'label'=>$L->g('description'),
|
||||
'value'=>$_Post->description(),
|
||||
'rows'=>'4',
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'tip'=>$L->g('this-field-can-help-describe-the-content')
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
|
||||
// IMAGES TAB
|
||||
// --------------------------------------------------------------------
|
||||
echo '<li><h2 class="sidebar-button" data-view="sidebar-images-view"><i class="uk-icon-angle-down"></i> '.$L->g('Images').'</h2></li>';
|
||||
echo '<li id="sidebar-images-view" class="sidebar-view">';
|
||||
|
||||
// --- BLUDIT COVER IMAGE ---
|
||||
HTML::bluditCoverImage($_Post->coverImage(false));
|
||||
|
||||
// --- BLUDIT QUICK IMAGES ---
|
||||
HTML::bluditQuickImages();
|
||||
|
||||
// --- BLUDIT IMAGES V8 ---
|
||||
HTML::bluditImagesV8();
|
||||
|
||||
// --- BLUDIT MENU V8 ---
|
||||
HTML::bluditMenuV8();
|
||||
|
||||
echo '</li>';
|
||||
|
||||
// TAGS
|
||||
// --------------------------------------------------------------------
|
||||
echo '<li><h2 class="sidebar-button" data-view="sidebar-tags-view"><i class="uk-icon-angle-down"></i> '.$L->g('Tags').'</h2></li>';
|
||||
echo '<li id="sidebar-tags-view" class="sidebar-view">';
|
||||
|
||||
// Tags input
|
||||
HTML::tags(array(
|
||||
'name'=>'tags',
|
||||
'label'=>$L->g('Tags'),
|
||||
'allTags'=>$dbTags->getAll(),
|
||||
'selectedTags'=>$_Post->tags(true)
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
|
||||
// ADVANCED TAB
|
||||
// --------------------------------------------------------------------
|
||||
echo '<li><h2 class="sidebar-button" data-view="sidebar-advanced-view"><i class="uk-icon-angle-down"></i> '.$L->g('Advanced').'</h2></li>';
|
||||
echo '<li id="sidebar-advanced-view" class="sidebar-view">';
|
||||
|
||||
// Status input
|
||||
HTML::formSelect(array(
|
||||
'name'=>'status',
|
||||
'label'=>$L->g('Status'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>array('published'=>$L->g('Published'), 'draft'=>$L->g('Draft')),
|
||||
'selected'=>($_Post->draft()?'draft':'published'),
|
||||
'tip'=>''
|
||||
));
|
||||
|
||||
// Date input
|
||||
HTML::formInputText(array(
|
||||
'name'=>'date',
|
||||
'value'=>$_Post->dateRaw(),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'tip'=>$L->g('To schedule the post just select the date and time'),
|
||||
'label'=>$L->g('Date')
|
||||
));
|
||||
|
||||
// Slug input
|
||||
HTML::formInputText(array(
|
||||
'name'=>'slug',
|
||||
'value'=>$_Post->slug(),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'tip'=>$L->g('you-can-modify-the-url-which-identifies'),
|
||||
'label'=>$L->g('Friendly URL')
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
HTML::formClose();
|
||||
|
||||
?>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var key = $("#jskey").val();
|
||||
|
||||
$("#jsdate").datetimepicker({format:"<?php echo DB_DATE_FORMAT ?>"});
|
||||
|
||||
$("#jstitle").keyup(function() {
|
||||
var slug = $(this).val();
|
||||
checkSlugPost(slug, key, $("#jsslug"));
|
||||
});
|
||||
|
||||
$("#jsslug").keyup(function() {
|
||||
var slug = $("#jsslug").val();
|
||||
checkSlugPost(slug, key, $("#jsslug"));
|
||||
});
|
||||
|
||||
$("#jsdelete-post").click(function() {
|
||||
if(confirm("<?php $Language->p('confirm-delete-this-action-cannot-be-undone') ?>")==false) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Button Save as draft
|
||||
$("#jsSaveDraft").on("click", function() {
|
||||
$("#jsstatus").val("draft");
|
||||
$(".uk-form").submit();
|
||||
});
|
||||
|
||||
// Right sidebar
|
||||
$(".sidebar-button").click(function() {
|
||||
var view = "#" + $(this).data("view");
|
||||
|
||||
if( $(view).is(":visible") ) {
|
||||
$(view).hide();
|
||||
}
|
||||
else {
|
||||
$(".sidebar-view").hide();
|
||||
$(view).show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
HTML::title(array('title'=>$L->g('Manage pages'), 'icon'=>'folder'));
|
||||
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-page"><i class="uk-icon-plus"></i> '.$L->g('Add a new page').'</a>';
|
||||
|
||||
echo '
|
||||
<table class="uk-table uk-table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.$L->g('Title').'</th>
|
||||
<th class="uk-text-center">'.$L->g('Position').'</th>
|
||||
<th>'.$L->g('Friendly URL').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
|
||||
foreach($pagesParents[NO_PARENT_CHAR] as $key=>$db)
|
||||
{
|
||||
// Parent page
|
||||
$Page = $pages[$key];
|
||||
|
||||
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$Page->key() : '/'.$Url->filters('page').'/'.$Page->key();
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>';
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->published()?'':'<span class="label-draft">'.$Language->g('Draft').'</span> ').($Page->title()?$Page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a>';
|
||||
echo '</td>';
|
||||
echo '<td class="uk-text-center">'.$Page->position().'</td>';
|
||||
echo '<td><a target="_blank" href="'.$Page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// If the page has children
|
||||
if(isset($pagesParents[$Page->key()]))
|
||||
{
|
||||
// Get the children
|
||||
$children = $pagesParents[$Page->key()];
|
||||
|
||||
foreach($children as $keyChildren=>$dbChildren)
|
||||
{
|
||||
// Parent page
|
||||
$Page = $pages[$keyChildren];
|
||||
|
||||
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$Page->key() : '/'.$Url->filters('page').'/'.$Page->key();
|
||||
|
||||
echo '<tr class="children">';
|
||||
echo '<td class="children">';
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->published()?'':'<span class="label-draft">'.$Language->g('Draft').'</span> ').($Page->title()?$Page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a>';
|
||||
echo '</td>';
|
||||
echo '<td class="uk-text-center">'.$Page->position().'</td>';
|
||||
echo '<td><a target="_blank" href="'.$Page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>
|
||||
</table>
|
||||
';
|
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
HTML::title(array('title'=>$L->g('Manage posts'), 'icon'=>'folder'));
|
||||
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-post"><i class="uk-icon-plus"></i> '.$L->g('Add a new post').'</a>';
|
||||
|
||||
echo '
|
||||
<table class="uk-table uk-table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.$L->g('Title').'</th>
|
||||
<th class="uk-text-center">'.$L->g('Published date').'</th>
|
||||
<th>'.$L->g('Friendly URL').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
|
||||
foreach($posts as $Post)
|
||||
{
|
||||
$status = false;
|
||||
if($Post->scheduled()) {
|
||||
$status = $Language->g('Scheduled');
|
||||
}
|
||||
elseif(!$Post->published()) {
|
||||
$status = $Language->g('Draft');
|
||||
}
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($status?'<span class="label-draft">'.$status.'</span>':'').($Post->title()?$Post->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a></td>';
|
||||
echo '<td class="uk-text-center">'.$Post->dateRaw().'</td>';
|
||||
|
||||
$friendlyURL = Text::isEmpty($Url->filters('post')) ? '/'.$Post->key() : '/'.$Url->filters('post').'/'.$Post->key();
|
||||
|
||||
echo '<td><a target="_blank" href="'.$Post->permalink().'">'.$friendlyURL.'</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>
|
||||
</table>
|
||||
';
|
||||
|
||||
?>
|
||||
|
||||
<div id="paginator">
|
||||
<ul>
|
||||
<?php
|
||||
if(Paginator::get('showNewer')) {
|
||||
echo '<li class="first"><a href="'.HTML_PATH_ADMIN_ROOT.'manage-posts?page=0">« '.$Language->g('First page').'</a></li>';
|
||||
echo '<li class="previous"><a href="'.HTML_PATH_ADMIN_ROOT.'manage-posts?page='.Paginator::get('prevPage').'">« '.$Language->g('Prev page').'</a></li>';
|
||||
}
|
||||
|
||||
echo '<li class="list">'.(Paginator::get('currentPage')+1).' / '.(Paginator::get('numberOfPages')+1).'</li>';
|
||||
|
||||
if(Paginator::get('showOlder')) {
|
||||
echo '<li class="next"><a href="'.HTML_PATH_ADMIN_ROOT.'manage-posts?page='.Paginator::get('nextPage').'">'.$Language->g('Next page').' »</a></li>';
|
||||
echo '<li class="last"><a href="'.HTML_PATH_ADMIN_ROOT.'manage-posts?page='.Paginator::get('numberOfPages').'">'.$Language->g('Last page').' »</a></li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
@ -23,4 +23,4 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
HTML::formClose();
|
||||
HTML::formClose();
|
@ -52,16 +52,15 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
echo '<li id="sidebar-general-view" class="sidebar-view">';
|
||||
|
||||
// Category
|
||||
/*
|
||||
HTML::formSelect(array(
|
||||
'name'=>'category',
|
||||
'label'=>$L->g('Category'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>$dbCategories->getAll(),
|
||||
'options'=>$dbCategories->getKeyNameArray(),
|
||||
'selected'=>'',
|
||||
'tip'=>'',
|
||||
'addEmptySpace'=>true
|
||||
));*/
|
||||
));
|
||||
|
||||
// Description input
|
||||
HTML::formTextarea(array(
|
||||
@ -124,18 +123,30 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
'tip'=>''
|
||||
));
|
||||
|
||||
// Date input
|
||||
HTML::formInputText(array(
|
||||
'name'=>'date',
|
||||
'value'=>Date::current(DB_DATE_FORMAT),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'tip'=>$L->g('To schedule the post just select the date and time'),
|
||||
'label'=>$L->g('Date')
|
||||
));
|
||||
|
||||
// Parent input
|
||||
$options = array();
|
||||
$options[NO_PARENT_CHAR] = '('.$Language->g('No parent').')';
|
||||
$options += $dbPages->parentKeyList();
|
||||
$parents = $dbPages->getParents(true);
|
||||
foreach( $parents as $key=>$fields ) {
|
||||
$options[$key] = $pagesKey[$key]->title();
|
||||
}
|
||||
|
||||
HTML::formSelect(array(
|
||||
'name'=>'parent',
|
||||
'label'=>$L->g('Parent'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>$options,
|
||||
'selected'=>NO_PARENT_CHAR,
|
||||
'tip'=>''
|
||||
'selected'=>'',
|
||||
'tip'=>'',
|
||||
'addEmptySpace'=>true
|
||||
));
|
||||
|
||||
// Position input
|
||||
@ -169,6 +180,7 @@ HTML::formClose();
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$("#jsdate").datetimepicker({format:"<?php echo DB_DATE_FORMAT ?>"});
|
||||
|
||||
$("#jsslug").keyup(function() {
|
||||
var text = $(this).val();
|
||||
|
@ -1,191 +0,0 @@
|
||||
<?php
|
||||
|
||||
HTML::title(array('title'=>$L->g('New post'), 'icon'=>'pencil'));
|
||||
|
||||
HTML::formOpen(array('class'=>'uk-form-stacked'));
|
||||
|
||||
// Security token
|
||||
HTML::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
));
|
||||
|
||||
// LEFT SIDE
|
||||
// --------------------------------------------------------------------
|
||||
echo '<div class="uk-grid uk-grid-medium">';
|
||||
echo '<div class="bl-publish-view uk-width-8-10">';
|
||||
|
||||
// Title input
|
||||
HTML::formInputText(array(
|
||||
'name'=>'title',
|
||||
'value'=>'',
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'placeholder'=>$L->g('Title')
|
||||
));
|
||||
|
||||
// Content input
|
||||
HTML::formTextarea(array(
|
||||
'name'=>'content',
|
||||
'value'=>'',
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'placeholder'=>''
|
||||
));
|
||||
|
||||
// Form buttons
|
||||
echo '<div class="uk-form-row uk-margin-bottom">
|
||||
<button class="uk-button uk-button-primary" type="submit">'.$L->g('Save').'</button>
|
||||
<button class="uk-button uk-button-primary" type="button" id="jsSaveDraft">'.$L->g('Save as draft').'</button>
|
||||
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'manage-posts">'.$L->g('Cancel').'</a>
|
||||
</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
// RIGHT SIDE
|
||||
// --------------------------------------------------------------------
|
||||
echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
|
||||
echo '<ul>';
|
||||
|
||||
// GENERAL TAB
|
||||
// --------------------------------------------------------------------
|
||||
echo '<li><h2 class="sidebar-button" data-view="sidebar-general-view"><i class="uk-icon-angle-down"></i> '.$L->g('General').'</h2></li>';
|
||||
echo '<li id="sidebar-general-view" class="sidebar-view">';
|
||||
|
||||
/*
|
||||
HTML::formSelect(array(
|
||||
'name'=>'category',
|
||||
'label'=>$L->g('Category'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>$dbCategories->getAll(),
|
||||
'selected'=>'',
|
||||
'tip'=>'',
|
||||
'addEmptySpace'=>true
|
||||
));*/
|
||||
|
||||
// Description input
|
||||
HTML::formTextarea(array(
|
||||
'name'=>'description',
|
||||
'label'=>$L->g('description'),
|
||||
'value'=>'',
|
||||
'rows'=>'4',
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'tip'=>$L->g('this-field-can-help-describe-the-content')
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
|
||||
// IMAGES TAB
|
||||
// --------------------------------------------------------------------
|
||||
echo '<li><h2 class="sidebar-button" data-view="sidebar-images-view"><i class="uk-icon-angle-down"></i> '.$L->g('Images').'</h2></li>';
|
||||
echo '<li id="sidebar-images-view" class="sidebar-view">';
|
||||
|
||||
// --- BLUDIT COVER IMAGE ---
|
||||
HTML::bluditCoverImage();
|
||||
|
||||
// --- BLUDIT QUICK IMAGES ---
|
||||
HTML::bluditQuickImages();
|
||||
|
||||
// --- BLUDIT IMAGES V8 ---
|
||||
HTML::bluditImagesV8();
|
||||
|
||||
// --- BLUDIT MENU V8 ---
|
||||
HTML::bluditMenuV8();
|
||||
|
||||
echo '</li>';
|
||||
|
||||
// TAGS
|
||||
// --------------------------------------------------------------------
|
||||
echo '<li><h2 class="sidebar-button" data-view="sidebar-tags-view"><i class="uk-icon-angle-down"></i> '.$L->g('Tags').'</h2></li>';
|
||||
echo '<li id="sidebar-tags-view" class="sidebar-view">';
|
||||
|
||||
// Tags input
|
||||
HTML::tags(array(
|
||||
'name'=>'tags',
|
||||
'label'=>'',
|
||||
'allTags'=>$dbTags->getAll(),
|
||||
'selectedTags'=>array()
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
|
||||
// ADVANCED TAB
|
||||
// --------------------------------------------------------------------
|
||||
echo '<li><h2 class="sidebar-button" data-view="sidebar-advanced-view"><i class="uk-icon-angle-down"></i> '.$L->g('Advanced').'</h2></li>';
|
||||
echo '<li id="sidebar-advanced-view" class="sidebar-view">';
|
||||
|
||||
// Status input
|
||||
HTML::formSelect(array(
|
||||
'name'=>'status',
|
||||
'label'=>$L->g('Status'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>array('published'=>$L->g('Published'), 'draft'=>$L->g('Draft')),
|
||||
'selected'=>'published',
|
||||
'tip'=>''
|
||||
));
|
||||
|
||||
// Date input
|
||||
HTML::formInputText(array(
|
||||
'name'=>'date',
|
||||
'value'=>Date::current(DB_DATE_FORMAT),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'tip'=>$L->g('To schedule the post just select the date and time'),
|
||||
'label'=>$L->g('Date')
|
||||
));
|
||||
|
||||
// Slug input
|
||||
HTML::formInputText(array(
|
||||
'name'=>'slug',
|
||||
'value'=>'',
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'tip'=>$L->g('you-can-modify-the-url-which-identifies'),
|
||||
'label'=>$L->g('Friendly URL')
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
HTML::formClose();
|
||||
|
||||
?>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#jsdate").datetimepicker({format:"<?php echo DB_DATE_FORMAT ?>"});
|
||||
|
||||
$("#jstitle").keyup(function() {
|
||||
var slug = $(this).val();
|
||||
checkSlugPost(slug, "", $("#jsslug"));
|
||||
});
|
||||
|
||||
$("#jsslug").keyup(function() {
|
||||
var slug = $("#jsslug").val();
|
||||
checkSlugPost(slug, "", $("#jsslug"));
|
||||
});
|
||||
|
||||
// Button Save as draft
|
||||
$("#jsSaveDraft").on("click", function() {
|
||||
$("#jsstatus").val("draft");
|
||||
$(".uk-form").submit();
|
||||
});
|
||||
|
||||
// Right sidebar
|
||||
$(".sidebar-button").click(function() {
|
||||
var view = "#" + $(this).data("view");
|
||||
|
||||
if( $(view).is(":visible") ) {
|
||||
$(view).hide();
|
||||
}
|
||||
else {
|
||||
$(".sidebar-view").hide();
|
||||
$(view).show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
39
bl-kernel/admin/views/pages.php
Normal file
39
bl-kernel/admin/views/pages.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
HTML::title(array('title'=>$L->g('Manage pages'), 'icon'=>'folder'));
|
||||
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-page"><i class="uk-icon-plus"></i> '.$L->g('Add a new page').'</a>';
|
||||
|
||||
echo '
|
||||
<table class="uk-table uk-table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.$L->g('Title').'</th>
|
||||
<th class="uk-text-center">'.$L->g('Position').'</th>
|
||||
<th>'.$L->g('URL').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
|
||||
foreach($pages as $page)
|
||||
{
|
||||
$status = false;
|
||||
if($page->scheduled()) {
|
||||
$status = $Language->g('Scheduled');
|
||||
}
|
||||
elseif(!$page->published()) {
|
||||
$status = $Language->g('Draft');
|
||||
}
|
||||
echo '<tr>';
|
||||
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($status?'<span class="label-draft">'.$status.'</span>':'').($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a></td>';
|
||||
echo '<td class="uk-text-center">'.$page->dateRaw().'</td>';
|
||||
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$page->key() : '/'.$Url->filters('page').'/'.$page->key();
|
||||
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>
|
||||
</table>
|
||||
';
|
@ -92,4 +92,4 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
HTML::formClose();
|
||||
HTML::formClose();
|
@ -44,8 +44,7 @@ else
|
||||
{
|
||||
// Boot rules
|
||||
include(PATH_RULES.'60.plugins.php');
|
||||
include(PATH_RULES.'70.posts.php');
|
||||
include(PATH_RULES.'71.pages.php');
|
||||
include(PATH_RULES.'69.pages.php');
|
||||
include(PATH_RULES.'99.header.php');
|
||||
include(PATH_RULES.'99.paginator.php');
|
||||
include(PATH_RULES.'99.themes.php');
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// Bludit version
|
||||
define('BLUDIT_VERSION', '1.6-beta');
|
||||
define('BLUDIT_CODENAME', '');
|
||||
define('BLUDIT_RELEASE_DATE', '');
|
||||
define('BLUDIT_BUILD', '');
|
||||
define('BLUDIT_VERSION', '2.0');
|
||||
define('BLUDIT_CODENAME', 'Next');
|
||||
define('BLUDIT_RELEASE_DATE', '2017-10-10');
|
||||
define('BLUDIT_BUILD', '20171010');
|
||||
|
||||
// Debug mode
|
||||
// Change to FALSE, for prevent warning or error on browser
|
||||
// Change to FALSE, for prevent warning or errors on browser
|
||||
define('DEBUG_MODE', TRUE);
|
||||
error_reporting(0); // Turn off all error reporting
|
||||
if(DEBUG_MODE) {
|
||||
@ -33,7 +33,6 @@ define('PATH_HELPERS', PATH_KERNEL.'helpers'.DS);
|
||||
define('PATH_AJAX', PATH_KERNEL.'ajax'.DS);
|
||||
define('PATH_JS', PATH_KERNEL.'js'.DS);
|
||||
|
||||
define('PATH_POSTS', PATH_CONTENT.'posts'.DS);
|
||||
define('PATH_PAGES', PATH_CONTENT.'pages'.DS);
|
||||
define('PATH_DATABASES', PATH_CONTENT.'databases'.DS);
|
||||
define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases'.DS.'plugins'.DS);
|
||||
@ -54,6 +53,7 @@ define('DEBUG_FILE', PATH_CONTENT.'debug.txt');
|
||||
define('DB_PAGES', PATH_DATABASES.'pages.php');
|
||||
define('DB_SITE', PATH_DATABASES.'site.php');
|
||||
define('DB_CATEGORIES', PATH_DATABASES.'categories.php');
|
||||
define('DB_TAGS', PATH_DATABASES.'tags.php');
|
||||
|
||||
// ADMIN URI FILTER
|
||||
define('ADMIN_URI_FILTER', '/admin/');
|
||||
@ -66,7 +66,7 @@ if(!defined('JSON_PRETTY_PRINT')) {
|
||||
define('JSON_PRETTY_PRINT', 128);
|
||||
}
|
||||
|
||||
// Protecting against Symlink attacks.
|
||||
// Protecting against Symlink attacks
|
||||
define('CHECK_SYMBOLIC_LINKS', TRUE);
|
||||
|
||||
// Auto scroll
|
||||
@ -103,16 +103,16 @@ define('NO_PARENT_CHAR', '3849abb4cb7abd24c2d8dac17b216f17');
|
||||
// Items per page for admin area
|
||||
define('ITEMS_PER_PAGE_ADMIN', 10);
|
||||
|
||||
// Enable or disable Cli mode
|
||||
// Cli mode, enable or disable
|
||||
define('CLI_MODE', FALSE);
|
||||
|
||||
// Cli mode status for new posts/pages
|
||||
// Cli mode, status for new pages
|
||||
define('CLI_STATUS', 'published');
|
||||
|
||||
// Cli mode username for new posts/pages
|
||||
// Cli mode, username for new pages
|
||||
define('CLI_USERNAME', 'admin');
|
||||
|
||||
// Filename for posts and pages, you can change it, for example, for index.md
|
||||
// Filename
|
||||
define('FILENAME', 'index.txt');
|
||||
|
||||
// Database date format
|
||||
@ -133,29 +133,27 @@ define('CHARSET', 'UTF-8');
|
||||
// EXTREME FRIENDLY URL, TRUE for dissmiss internet standard. Experimental!
|
||||
define('EXTREME_FRIENDLY_URL', FALSE);
|
||||
|
||||
// Directory permissions
|
||||
// Permissions for new directories
|
||||
define('DIR_PERMISSIONS', 0755);
|
||||
|
||||
// Set internal character encoding.
|
||||
// Set internal character encoding
|
||||
mb_internal_encoding(CHARSET);
|
||||
|
||||
// Set HTTP output character encoding.
|
||||
// Set HTTP output character encoding
|
||||
mb_http_output(CHARSET);
|
||||
|
||||
// Inclde Abstract Classes
|
||||
include(PATH_ABSTRACT.'dbjson.class.php');
|
||||
include(PATH_ABSTRACT.'content.class.php');
|
||||
include(PATH_ABSTRACT.'dblist.class.php');
|
||||
include(PATH_ABSTRACT.'plugin.class.php');
|
||||
|
||||
// Inclde Classes
|
||||
include(PATH_KERNEL.'dbposts.class.php');
|
||||
include(PATH_KERNEL.'dbpages.class.php');
|
||||
include(PATH_KERNEL.'dbusers.class.php');
|
||||
include(PATH_KERNEL.'dbtags.class.php');
|
||||
include(PATH_KERNEL.'dblanguage.class.php');
|
||||
include(PATH_KERNEL.'dbsite.class.php');
|
||||
include(PATH_KERNEL.'dbcategories.class.php');
|
||||
include(PATH_KERNEL.'post.class.php');
|
||||
include(PATH_KERNEL.'page.class.php');
|
||||
include(PATH_KERNEL.'user.class.php');
|
||||
include(PATH_KERNEL.'url.class.php');
|
||||
@ -185,12 +183,10 @@ include(PATH_HELPERS.'image.class.php');
|
||||
// Session
|
||||
Session::start();
|
||||
if(Session::started()===false) {
|
||||
Log::set('init.php'.LOG_SEP.'Error occurred when trying to start the session.');
|
||||
exit('Bludit. Failed to start session.');
|
||||
exit('Bludit CMS. Session initialization failure.');
|
||||
}
|
||||
|
||||
// Objects
|
||||
$dbPosts = new dbPosts();
|
||||
$dbPages = new dbPages();
|
||||
$dbUsers = new dbUsers();
|
||||
$dbTags = new dbTags();
|
||||
@ -244,26 +240,17 @@ define('HTML_PATH_UPLOADS_PROFILES', HTML_PATH_UPLOADS.'profiles/');
|
||||
define('HTML_PATH_UPLOADS_THUMBNAILS', HTML_PATH_UPLOADS.'thumbnails/');
|
||||
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/');
|
||||
|
||||
define('JQUERY', HTML_PATH_ADMIN_THEME_JS.'jquery.min.js');
|
||||
define('JQUERY', HTML_PATH_ROOT.'bl-kernel/js/jquery.min.js');
|
||||
|
||||
// --- PHP paths with dependency ---
|
||||
// This paths are absolutes for the OS.
|
||||
|
||||
// This paths are absolutes for the OS
|
||||
// Depreacted, use THEME_DIR and THEME_DIR_XXX
|
||||
define('PATH_THEME', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS);
|
||||
define('PATH_THEME_PHP', PATH_THEME.'php'.DS);
|
||||
define('PATH_THEME_CSS', PATH_THEME.'css'.DS);
|
||||
define('PATH_THEME_JS', PATH_THEME.'js'.DS);
|
||||
define('PATH_THEME_IMG', PATH_THEME.'img'.DS);
|
||||
define('PATH_THEME_LANG', PATH_THEME.'languages'.DS);
|
||||
|
||||
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS);
|
||||
define('THEME_DIR_PHP', PATH_THEME.'php'.DS);
|
||||
define('THEME_DIR_CSS', PATH_THEME.'css'.DS);
|
||||
define('THEME_DIR_JS', PATH_THEME.'js'.DS);
|
||||
define('THEME_DIR_IMG', PATH_THEME.'img'.DS);
|
||||
define('THEME_DIR_LANG', PATH_THEME.'languages'.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);
|
||||
define('THEME_DIR_IMG', THEME_DIR.'img'.DS);
|
||||
define('THEME_DIR_LANG', THEME_DIR.'languages'.DS);
|
||||
|
||||
// --- Absolute paths with domain ---
|
||||
// This paths are absolutes for the user / web browsing.
|
||||
@ -283,3 +270,8 @@ $Url->checkFilters( $Site->uriFilters() );
|
||||
|
||||
// --- Objects shortcuts ---
|
||||
$L = $Language;
|
||||
|
||||
// DEBUG: Print constants
|
||||
// $arr = array_filter(get_defined_constants(), 'is_string');
|
||||
// echo json_encode($arr);
|
||||
// exit;
|
@ -13,6 +13,12 @@ $allPages = array();
|
||||
// Object Page for the page filtered bye the user
|
||||
$page = false;
|
||||
|
||||
// Array with all page parents published
|
||||
//$pageParents = array();
|
||||
|
||||
// Array with all published pages, the array is a key=>Page-object
|
||||
$pagesKey = array();
|
||||
|
||||
// ============================================================================
|
||||
// Main
|
||||
// ============================================================================
|
||||
@ -45,16 +51,16 @@ if( $Url->whereAmI()==='page' ) {
|
||||
}
|
||||
}
|
||||
elseif( $Url->whereAmI()==='tag' ) {
|
||||
$pages = buildPagesByTag();
|
||||
buildPagesByTag();
|
||||
}
|
||||
elseif( $Url->whereAmI()==='category' ) {
|
||||
$pages = buildPagesByCategory();
|
||||
buildPagesByCategory();
|
||||
}
|
||||
elseif( $Url->whereAmI()==='home' ) {
|
||||
$pages = buildPagesForHome();
|
||||
buildPagesForHome();
|
||||
}
|
||||
elseif( $Url->whereAmI()==='admin' ) {
|
||||
$pages = buildPagesForAdmin();
|
||||
buildPagesForAdmin();
|
||||
}
|
||||
|
||||
if( $Url->notFound() ) {
|
||||
|
@ -1,34 +1,39 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// Current page number.
|
||||
// Current page number
|
||||
$currentPage = $Url->pageNumber();
|
||||
Paginator::set('currentPage', $currentPage);
|
||||
|
||||
// Number of pages.
|
||||
if($Url->whereAmI()=='admin') {
|
||||
$postPerPage = POSTS_PER_PAGE_ADMIN;
|
||||
$numberOfPosts = $dbPosts->numberPost(true); // published and drafts
|
||||
$itemsPerPage = ITEMS_PER_PAGE_ADMIN;
|
||||
$amountOfItems = $dbPages->count(false);
|
||||
}
|
||||
elseif($Url->whereAmI()=='tag') {
|
||||
$postPerPage = $Site->postsPerPage();
|
||||
$itemsPerPage = $Site->itemsPerPage();
|
||||
$tagKey = $Url->slug();
|
||||
$numberOfPosts = $dbTags->countPostsByTag($tagKey);
|
||||
$amountOfItems = $dbTags->countPagesByTag($tagKey);
|
||||
}
|
||||
elseif($Url->whereAmI()=='category') {
|
||||
$itemsPerPage = $Site->itemsPerPage();
|
||||
$categoryKey = $Url->slug();
|
||||
$amountOfItems = $dbCategories->countPagesByCategory($categoryKey);
|
||||
}
|
||||
else {
|
||||
$postPerPage = $Site->postsPerPage();
|
||||
$numberOfPosts = $dbPosts->numberPost(false); // published
|
||||
$itemsPerPage = $Site->itemsPerPage();
|
||||
$amountOfItems = $dbPages->count(true);
|
||||
}
|
||||
|
||||
// Post per page.
|
||||
Paginator::set('postPerPage', $postPerPage);
|
||||
// Items per page
|
||||
Paginator::set('itemsPerPage', $itemsPerPage);
|
||||
|
||||
// Number of posts
|
||||
Paginator::set('numberOfPosts', $numberOfPosts);
|
||||
// Amount of items
|
||||
Paginator::set('amountOfItems', $amountOfItems);
|
||||
|
||||
$numberOfPages = (int) max(ceil($numberOfPosts / $postPerPage) -1, 0);
|
||||
Paginator::set('numberOfPages', $numberOfPages);
|
||||
// Amount of pages
|
||||
$amountOfPages = (int) max(ceil($amountOfItems / $itemsPerPage) -1, 0);
|
||||
Paginator::set('amountOfPages', $amountOfPages);
|
||||
|
||||
$showOlder = $numberOfPages > $currentPage;
|
||||
$showOlder = $amountOfPages > $currentPage;
|
||||
Paginator::set('showOlder', $showOlder);
|
||||
|
||||
$showNewer = $currentPage > 0;
|
||||
@ -40,5 +45,5 @@ Paginator::set('show', true);
|
||||
$nextPage = max(0, $currentPage+1);
|
||||
Paginator::set('nextPage', $nextPage);
|
||||
|
||||
$prevPage = min($numberOfPages, $currentPage-1);
|
||||
$prevPage = min($amountOfPages, $currentPage-1);
|
||||
Paginator::set('prevPage', $prevPage);
|
||||
|
@ -67,9 +67,9 @@ function buildThemes()
|
||||
// ============================================================================
|
||||
|
||||
// Load the language file
|
||||
$languageFilename = PATH_THEME.'languages'.DS.$Site->locale().'.json';
|
||||
$languageFilename = THEME_DIR.'languages'.DS.$Site->locale().'.json';
|
||||
if( !Sanitize::pathFile($languageFilename) ) {
|
||||
$languageFilename = PATH_THEME.'languages'.DS.'en_US.json';
|
||||
$languageFilename = THEME_DIR.'languages'.DS.'en_US.json';
|
||||
}
|
||||
|
||||
if( Sanitize::pathFile($languageFilename) )
|
||||
|
@ -7,8 +7,7 @@ include(PATH_RULES.'60.plugins.php');
|
||||
Theme::plugins('beforeRulesLoad');
|
||||
|
||||
// Load rules
|
||||
include(PATH_RULES.'70.posts.php');
|
||||
include(PATH_RULES.'71.pages.php');
|
||||
include(PATH_RULES.'69.pages.php');
|
||||
include(PATH_RULES.'99.header.php');
|
||||
include(PATH_RULES.'99.paginator.php');
|
||||
include(PATH_RULES.'99.themes.php');
|
||||
|
@ -44,8 +44,18 @@ class dbPages extends dbJSON
|
||||
// Generate UUID
|
||||
$args['uuid'] = md5( uniqid() );
|
||||
|
||||
// Get current date
|
||||
$args['date'] = Date::current(DB_DATE_FORMAT);
|
||||
// Date
|
||||
$currentDate = Date::current(DB_DATE_FORMAT);
|
||||
|
||||
// Validate date
|
||||
if(!Valid::date($args['date'], DB_DATE_FORMAT)) {
|
||||
$args['date'] = $currentDate;
|
||||
}
|
||||
|
||||
// Schedule page
|
||||
if( ($args['date']>$currentDate) && ($args['status']=='published') ) {
|
||||
$args['status'] = 'scheduled';
|
||||
}
|
||||
|
||||
foreach($this->dbFields as $field=>$options) {
|
||||
if( isset($args[$field]) ) {
|
||||
@ -93,8 +103,13 @@ class dbPages extends dbJSON
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save the database
|
||||
// Insert in database
|
||||
$this->db[$key] = $dataForDb;
|
||||
|
||||
// Sort database
|
||||
$this->sortByDate();
|
||||
|
||||
// Save database
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
@ -181,8 +196,13 @@ class dbPages extends dbJSON
|
||||
// Remove the old key
|
||||
unset( $this->db[$args['key']] );
|
||||
|
||||
// Save the database
|
||||
// Insert in database
|
||||
$this->db[$newKey] = $dataForDb;
|
||||
|
||||
// Sort database
|
||||
$this->sortByDate();
|
||||
|
||||
// Save database
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
@ -268,7 +288,7 @@ class dbPages extends dbJSON
|
||||
// Returns the amount of pages
|
||||
// (boolean) $total, TRUE returns the total of pages
|
||||
// (boolean) $total, FALSE returns the total of published pages (without draft and scheduled)
|
||||
public function numberPages($onlyPublished=true)
|
||||
public function count($onlyPublished=true)
|
||||
{
|
||||
if( $onlyPublished ) {
|
||||
$db = $this->getPublishedDB();
|
||||
@ -278,6 +298,43 @@ class dbPages extends dbJSON
|
||||
return count($this->db);
|
||||
}
|
||||
|
||||
public function getParents($onlyPublished=true)
|
||||
{
|
||||
if( $onlyPublished ) {
|
||||
$db = $this->getPublishedDB();
|
||||
}
|
||||
else {
|
||||
$db = $this->db;
|
||||
}
|
||||
|
||||
foreach( $db as $key=>$fields ) {
|
||||
if( Text::stringContains($key, '/') ) {
|
||||
unset($db[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $db;
|
||||
}
|
||||
|
||||
// Sort pages by date
|
||||
public function sortByDate($HighToLow=true)
|
||||
{
|
||||
if($HighToLow) {
|
||||
uasort($this->db, array($this, 'sortHighToLow'));
|
||||
}
|
||||
else {
|
||||
uasort($this->db, array($this, 'sortLowToHigh'));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function sortLowToHigh($a, $b) {
|
||||
return $a['date']>$b['date'];
|
||||
}
|
||||
private function sortHighToLow($a, $b) {
|
||||
return $a['date']<$b['date'];
|
||||
}
|
||||
|
||||
// ----- OLD
|
||||
|
||||
// Set a field of the database
|
||||
@ -396,14 +453,6 @@ class dbPages extends dbJSON
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
$count = parent::count();
|
||||
|
||||
// DEBUG: Less than - 1 because the error page.
|
||||
return $count - 1;
|
||||
}
|
||||
|
||||
// Return TRUE if there are new pages published, FALSE otherwise.
|
||||
public function scheduler()
|
||||
{
|
||||
@ -437,258 +486,4 @@ class dbPages extends dbJSON
|
||||
return false;
|
||||
}
|
||||
|
||||
// --- OLD
|
||||
public function cliMode()
|
||||
{
|
||||
// LOG
|
||||
Log::set('CLI MODE - PAGES - Starting...');
|
||||
|
||||
$pageList = array();
|
||||
|
||||
$pagesDirectories = Filesystem::listDirectories(PATH_PAGES);
|
||||
foreach( $pagesDirectories as $directory ) {
|
||||
|
||||
if( Sanitize::pathFile($directory.DS.FILENAME) ) {
|
||||
|
||||
// The key is the directory name
|
||||
$key = basename($directory);
|
||||
|
||||
// Add the page key to the list
|
||||
$pageList[$key] = true;
|
||||
|
||||
// LOG
|
||||
Log::set('CLI MODE - Page found, key: '.$key);
|
||||
|
||||
// Search sub-pages
|
||||
$subPaths = Filesystem::listDirectories($directory.DS);
|
||||
foreach( $subPaths as $subDirectory )
|
||||
{
|
||||
// The key of the sub-page
|
||||
$subKey = basename($subDirectory);
|
||||
|
||||
if( Sanitize::pathFile($subDirectory.DS.FILENAME) ) {
|
||||
|
||||
// Add the key of the sub-page, the key is composed by the directory/subdirectory
|
||||
$pageList[$key.'/'.$subKey] = true;
|
||||
|
||||
// LOG
|
||||
Log::set('CLI MODE - Page found, key: '.$key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $pageList as $key=>$value ) {
|
||||
|
||||
if( !isset($this->db[$key]) ) {
|
||||
|
||||
// LOG
|
||||
Log::set('CLI MODE - The page is not in the database, key: '.$key);
|
||||
|
||||
// Insert new post
|
||||
$this->cliModeInsert($key);
|
||||
}
|
||||
else {
|
||||
$checksum = md5_file(PATH_PAGES.$key.DS.FILENAME);
|
||||
|
||||
// If checksum is different, update the post
|
||||
if( !isset($this->db[$key]['md5file']) ||
|
||||
$this->db[$key]['md5file']!==$checksum ) {
|
||||
|
||||
// LOG
|
||||
Log::set('CLI MODE - Different md5 checksum, key: '.$key);
|
||||
|
||||
// Update the post
|
||||
$this->cliModeInsert($key, $update=true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LOG
|
||||
Log::set('CLI MODE - Cleaning database...');
|
||||
|
||||
foreach( array_diff_key($this->db, $pageList) as $key=>$data ) {
|
||||
|
||||
// LOG
|
||||
Log::set('CLI MODE - Removing page from database, key: '.$key);
|
||||
|
||||
// Remove the page from database
|
||||
unset( $this->db[$key] );
|
||||
}
|
||||
|
||||
// Save the database
|
||||
$this->save();
|
||||
|
||||
// LOG
|
||||
Log::set('CLI MODE - PAGES - Finishing...');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function cliModeInsert($key, $update=false)
|
||||
{
|
||||
if($update) {
|
||||
// LOG
|
||||
Log::set('CLI MODE - cliModeInsert() - Updating the page, key: '.$key);
|
||||
|
||||
// Database from the current database
|
||||
$dataForDb = $this->db[$key];
|
||||
$dataForDb['dateModified'] = Date::current(DB_DATE_FORMAT);
|
||||
}
|
||||
else {
|
||||
// LOG
|
||||
Log::set('CLI MODE - cliModeInsert() - Inserting the new post, key: '.$key);
|
||||
|
||||
// Database for the new page, fields with the default values
|
||||
$dataForDb = array();
|
||||
foreach( $this->dbFields as $field=>$options ) {
|
||||
|
||||
if( !$options['inFile'] ) {
|
||||
$dataForDb[$field] = $options['value'];
|
||||
}
|
||||
}
|
||||
|
||||
// Fields and value predefined in init.php
|
||||
$dataForDb['username'] = CLI_USERNAME;
|
||||
$dataForDb['status'] = CLI_STATUS;
|
||||
$dataForDb['date'] = Date::current(DB_DATE_FORMAT);
|
||||
}
|
||||
|
||||
// MD5 checksum
|
||||
$dataForDb['md5file'] = md5_file(PATH_PAGES.$key.DS.FILENAME);
|
||||
|
||||
// Generate the Object from the file
|
||||
$Page = new Page($key);
|
||||
|
||||
foreach( $this->dbFields as $field=>$options ) {
|
||||
|
||||
if( !$options['inFile'] ) {
|
||||
|
||||
// Get the field from the file
|
||||
// If the field doesn't exist, the function returns FALSE
|
||||
$data = $Page->getField($field);
|
||||
|
||||
if( $data!==false ) {
|
||||
|
||||
$tmpValue = '';
|
||||
|
||||
if( $field=='tags' ) {
|
||||
$tmpValue = $this->generateTags($data);
|
||||
}
|
||||
elseif( $field=='date' ) {
|
||||
|
||||
// Validate format date from file
|
||||
if( Valid::date($data, DB_DATE_FORMAT) ) {
|
||||
|
||||
$tmpValue = $data;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$tmpValue = Sanitize::html($data);
|
||||
}
|
||||
|
||||
settype($tmpValue, gettype($options['value']));
|
||||
$dataForDb[$field] = $tmpValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert row in the database
|
||||
$this->db[$key] = $dataForDb;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function regenerateCli()
|
||||
{
|
||||
$db = $this->db;
|
||||
$newPaths = array();
|
||||
$fields = array();
|
||||
|
||||
// Default fields and value
|
||||
foreach($this->dbFields as $field=>$options) {
|
||||
if(!$options['inFile']) {
|
||||
$fields[$field] = $options['value'];
|
||||
}
|
||||
}
|
||||
|
||||
//$tmpPaths = glob(PATH_PAGES.'*', GLOB_ONLYDIR);
|
||||
$tmpPaths = Filesystem::listDirectories(PATH_PAGES);
|
||||
foreach($tmpPaths as $directory)
|
||||
{
|
||||
$key = basename($directory);
|
||||
|
||||
if(file_exists($directory.DS.FILENAME)) {
|
||||
// The key is the directory name
|
||||
$newPaths[$key] = true;
|
||||
}
|
||||
|
||||
// Recovery pages from subdirectories
|
||||
//$subPaths = glob($directory.DS.'*', GLOB_ONLYDIR);
|
||||
$subPaths = Filesystem::listDirectories($directory.DS);
|
||||
foreach($subPaths as $subDirectory)
|
||||
{
|
||||
$subKey = basename($subDirectory);
|
||||
|
||||
if(file_exists($subDirectory.DS.FILENAME)) {
|
||||
// The key is composed by the directory/subdirectory
|
||||
$newPaths[$key.'/'.$subKey] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($newPaths as $key=>$value)
|
||||
{
|
||||
if(!isset($this->db[$key]))
|
||||
{
|
||||
// Default values for the new pages.
|
||||
$fields['status'] = CLI_STATUS;
|
||||
$fields['date'] = Date::current(DB_DATE_FORMAT);
|
||||
$fields['username'] = 'admin';
|
||||
|
||||
// Create the entry for the new page.
|
||||
$this->db[$key] = $fields;
|
||||
}
|
||||
|
||||
$Page = new Page($key);
|
||||
|
||||
// Update all fields from FILE to DATABASE.
|
||||
foreach($fields as $f=>$v)
|
||||
{
|
||||
// If the field exists on the FILE, update it.
|
||||
if($Page->getField($f))
|
||||
{
|
||||
$valueFromFile = $Page->getField($f);
|
||||
|
||||
if($f=='tags') {
|
||||
// Generate tags array.
|
||||
$this->db[$key]['tags'] = $this->generateTags($valueFromFile);
|
||||
}
|
||||
elseif($f=='date') {
|
||||
// Validate Date from file
|
||||
if(Valid::date($valueFromFile, DB_DATE_FORMAT)) {
|
||||
$this->db[$key]['date'] = $valueFromFile;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Sanitize the values from file.
|
||||
$this->db[$key][$f] = Sanitize::html($valueFromFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove old pages from db
|
||||
foreach( array_diff_key($db, $newPaths) as $key=>$data ) {
|
||||
unset($this->db[$key]);
|
||||
}
|
||||
|
||||
// Save the database.
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->db!=$db;
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +111,9 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
|
||||
global $dbPages;
|
||||
global $dbCategories;
|
||||
global $Site;
|
||||
global $Url;
|
||||
global $pagesKey;
|
||||
global $pages;
|
||||
|
||||
// Get the page number from URL
|
||||
$pageNumber = $Url->pageNumber();
|
||||
@ -122,15 +125,15 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
|
||||
}
|
||||
elseif($for=='home') {
|
||||
$onlyPublished = true;
|
||||
$amountOfItems = $Site->postsPerPage();
|
||||
$amountOfItems = $Site->itemsPerPage();
|
||||
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
}
|
||||
elseif($for=='category') {
|
||||
$amountOfItems = $Site->postsPerPage();
|
||||
$amountOfItems = $Site->itemsPerPage();
|
||||
$list = $dbCategories->getList($categoryKey, $pageNumber, $amountOfItems);
|
||||
}
|
||||
elseif($for=='tag') {
|
||||
$amountOfItems = $Site->postsPerPage();
|
||||
$amountOfItems = $Site->itemsPerPage();
|
||||
$list = $dbTags->getList($tagKey, $pageNumber, $amountOfItems);
|
||||
}
|
||||
|
||||
@ -139,10 +142,14 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
|
||||
$Url->setNotFound(true);
|
||||
}
|
||||
|
||||
$pages = array();
|
||||
$pages = array(); // global variable
|
||||
$pagesKey = array(); // global variable
|
||||
foreach($list as $pageKey=>$fields) {
|
||||
$page = buildPage($pageKey);
|
||||
if($page!==false) {
|
||||
// $pagesKey
|
||||
$pagesKey[$pageKey] = $page;
|
||||
// $pages
|
||||
array_push($pages, $page);
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,8 @@
|
||||
class Paginator {
|
||||
|
||||
public static $pager = array(
|
||||
'numberOfPostsAndDraft'=>0,
|
||||
'numberOfPosts'=>0,
|
||||
'numberOfPages'=>0,
|
||||
'itemsPerPage'=>0,
|
||||
'amountOfPages'=>0,
|
||||
'nextPage'=>0,
|
||||
'prevPage'=>0,
|
||||
'currentPage'=>0,
|
||||
|
@ -4,8 +4,7 @@ class Redirect {
|
||||
|
||||
public static function url($url)
|
||||
{
|
||||
if(!headers_sent())
|
||||
{
|
||||
if(!headers_sent()) {
|
||||
header("Location:".$url, TRUE, 302);
|
||||
exit;
|
||||
}
|
||||
@ -13,9 +12,10 @@ class Redirect {
|
||||
exit('<meta http-equiv="refresh" content="0; url='.$url.'"/>');
|
||||
}
|
||||
|
||||
public static function page($base, $page)
|
||||
public static function page($page)
|
||||
{
|
||||
self::url(HTML_PATH_ROOT.$base.'/'.$page);
|
||||
$base = ltrim(ADMIN_URI_FILTER, '/');
|
||||
self::url(HTML_PATH_ROOT.$base.$page);
|
||||
}
|
||||
|
||||
public static function home()
|
||||
@ -23,4 +23,4 @@ class Redirect {
|
||||
self::url(HTML_PATH_ROOT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -45,12 +45,12 @@ class Text {
|
||||
'А'=>'A', 'Б'=>'B', 'В'=>'V', 'Г'=>'G', 'Д'=>'D', 'Е'=>'E', 'Ж'=>'Zh', 'З'=>'Z',
|
||||
'И'=>'I', 'Й'=>'J', 'К'=>'K', 'Л'=>'L', 'М'=>'M', 'Н'=>'N', 'О'=>'O', 'П'=>'P',
|
||||
'Р'=>'R', 'С'=>'S', 'Т'=>'T', 'У'=>'U', 'Ф'=>'F', 'Х'=>'H', 'Ц'=>'C', 'Ч'=>'Ch',
|
||||
'Ш'=>'Sh', 'Щ'=>'Sh', 'Ъ'=>'', 'Ь'=>'J','Ю'=>'Yu','Я'=>'Ya',
|
||||
'Ш'=>'Sh', 'Щ'=>'Sh', 'Ъ'=>'', 'Ь'=>'J','Ю'=>'Yu','Я'=>'Ya',
|
||||
'а'=>'a', 'б'=>'b', 'в'=>'v', 'г'=>'g', 'д'=>'d', 'е'=>'e', 'ж'=>'zh','з'=>'z',
|
||||
'и'=>'i', 'й'=>'j', 'к'=>'k', 'л'=>'l', 'м'=>'m', 'н'=>'n', 'о'=>'o','п'=>'p',
|
||||
'р'=>'r', 'с'=>'s', 'т'=>'t', 'у'=>'u', 'ф'=>'f', 'х'=>'h', 'ц'=>'c', 'ч'=>'ch',
|
||||
'ш'=>'sh', 'щ'=>'sh', 'ъ'=>'', 'ь'=>'j', 'ю'=>'yu', 'я'=>'ya',
|
||||
|
||||
|
||||
// Ukrainian
|
||||
'Є'=>'Ye', 'І'=>'I', 'Ї'=>'Yi', 'Ґ'=>'G',
|
||||
'є'=>'ye', 'і'=>'i', 'ї'=>'yi', 'ґ'=>'g',
|
||||
@ -174,6 +174,11 @@ class Text {
|
||||
return mb_strpos($string, $substring, 0, 'UTF-8');
|
||||
}
|
||||
|
||||
public static function stringContains($string, $substring)
|
||||
{
|
||||
return (self::stringPosition($string, $substring) !== false);
|
||||
}
|
||||
|
||||
// Returns the portion of string specified by the start and length parameters.
|
||||
public static function cut($string, $start, $length)
|
||||
{
|
||||
|
4
bl-kernel/js/jquery.min.js
vendored
Normal file
4
bl-kernel/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -58,6 +58,8 @@ class Page {
|
||||
$implode = implode($output);
|
||||
$this->vars['contentRaw'] = $implode;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns TRUE if the content is loaded correctly, FALSE otherwise
|
||||
@ -145,6 +147,36 @@ class Page {
|
||||
return $date;
|
||||
}
|
||||
|
||||
// Returns the permalink
|
||||
// (boolean) $absolute, TRUE returns the page link with the DOMAIN, FALSE without the DOMAIN
|
||||
public function permalink($absolute=false)
|
||||
{
|
||||
global $Url;
|
||||
global $Site;
|
||||
|
||||
$url = trim(DOMAIN_BASE,'/');
|
||||
$key = $this->key();
|
||||
$filter = trim($Url->filters('page'), '/');
|
||||
$htmlPath = trim(HTML_PATH_ROOT,'/');
|
||||
|
||||
if(empty($filter)) {
|
||||
$tmp = $key;
|
||||
}
|
||||
else {
|
||||
$tmp = $filter.'/'.$key;
|
||||
}
|
||||
|
||||
if($absolute) {
|
||||
return $url.'/'.$tmp;
|
||||
}
|
||||
|
||||
if(empty($htmlPath)) {
|
||||
return '/'.$tmp;
|
||||
}
|
||||
|
||||
return '/'.$htmlPath.'/'.$tmp;
|
||||
}
|
||||
|
||||
// ---- OLD
|
||||
|
||||
// Returns the user object
|
||||
@ -161,12 +193,6 @@ class Page {
|
||||
return $User;
|
||||
}
|
||||
|
||||
// Returns TRUE if the post is scheduled, FALSE otherwise.
|
||||
public function scheduled()
|
||||
{
|
||||
return ($this->getField('status')==='scheduled');
|
||||
}
|
||||
|
||||
// Returns the username who created the post/page
|
||||
public function username()
|
||||
{
|
||||
@ -246,37 +272,7 @@ class Page {
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the permalink
|
||||
// (boolean) $absolute, TRUE returns the post/page link with the DOMAIN, FALSE without the DOMAIN
|
||||
public function permalink($absolute=false)
|
||||
{
|
||||
global $Url;
|
||||
global $Site;
|
||||
|
||||
$filterType = $this->getField('filterType');
|
||||
|
||||
$url = trim(DOMAIN_BASE,'/');
|
||||
$key = $this->key();
|
||||
$filter = trim($Url->filters($filterType), '/');
|
||||
$htmlPath = trim(HTML_PATH_ROOT,'/');
|
||||
|
||||
if(empty($filter)) {
|
||||
$tmp = $key;
|
||||
}
|
||||
else {
|
||||
$tmp = $filter.'/'.$key;
|
||||
}
|
||||
|
||||
if($absolute) {
|
||||
return $url.'/'.$tmp;
|
||||
}
|
||||
|
||||
if(empty($htmlPath)) {
|
||||
return '/'.$tmp;
|
||||
}
|
||||
|
||||
return '/'.$htmlPath.'/'.$tmp;
|
||||
}
|
||||
|
||||
public function json($returnsArray=false)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user