Paginator
This commit is contained in:
parent
8e2b0f59ab
commit
5c8fcff96c
|
@ -5,7 +5,7 @@
|
|||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
|
@ -16,30 +16,31 @@ if($Login->role()!=='admin') {
|
|||
function addUser($args)
|
||||
{
|
||||
global $dbUsers;
|
||||
global $Language;
|
||||
|
||||
// Check if the username already exist in db.
|
||||
if( $dbUsers->userExists($args['username']) || Text::isEmpty($args['username']) )
|
||||
{
|
||||
Alert::set('Username already exists or is empty');
|
||||
Alert::set($Language->g('username-already-exists-or-is-empty'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate password.
|
||||
if( ($args['password'] != $args['confirm-password'] ) || Text::isEmpty($args['password']) )
|
||||
{
|
||||
Alert::set('The password and confirmation password do not match');
|
||||
Alert::set($Language->g('password-does-not-match-the-confirm-password'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add the user.
|
||||
if( $dbUsers->add($args) )
|
||||
{
|
||||
Alert::set('User has been added successfull');
|
||||
Alert::set($Language->g('user-has-been-added-successfully'));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert::set('Error occurred when trying to add a new user');
|
||||
Alert::set($Language->g('an-error-occurred-while-trying-to-create-the-user-account'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ if($_Plugin->form()===false) {
|
|||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
$_Plugin->setDb($_POST);
|
||||
Alert::set('Configuration has been saved successfully');
|
||||
Alert::set($Language->g('the-changes-have-been-saved'));
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
function editPage($args)
|
||||
{
|
||||
global $dbPages;
|
||||
global $Language;
|
||||
|
||||
// Page status, published or draft.
|
||||
if( isset($args['publish']) ) {
|
||||
|
@ -25,18 +26,19 @@ function editPage($args)
|
|||
{
|
||||
$dbPages->regenerate();
|
||||
|
||||
Alert::set('The page has been saved successfully');
|
||||
Alert::set($Language->g('the-changes-have-been-saved'));
|
||||
Redirect::page('admin', 'edit-page/'.$args['key']);
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert::set('Error occurred when trying to edit the page');
|
||||
Alert::set($Language->g('an-error-occurred-while-trying-to-edit-the-page'));
|
||||
}
|
||||
}
|
||||
|
||||
function deletePage($key)
|
||||
{
|
||||
global $dbPages;
|
||||
global $Language;
|
||||
|
||||
if( $dbPages->delete($key) )
|
||||
{
|
||||
|
@ -45,7 +47,7 @@ function deletePage($key)
|
|||
}
|
||||
else
|
||||
{
|
||||
Alert::set('Error occurred when trying to delete the page');
|
||||
Alert::set('an-error-occurred-while-trying-to-delete-the-page');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
function editPost($args)
|
||||
{
|
||||
global $dbPosts;
|
||||
global $Language;
|
||||
|
||||
// Post status, published or draft.
|
||||
if( isset($args['publish']) ) {
|
||||
|
@ -19,12 +20,12 @@ function editPost($args)
|
|||
// Edit the post.
|
||||
if( $dbPosts->edit($args) )
|
||||
{
|
||||
Alert::set('The post has been saved successfull');
|
||||
Alert::set($Language->g('the-changes-have-been-saved'));
|
||||
Redirect::page('admin', 'edit-post/'.$args['key']);
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert::set('Error occurred when trying to edit the post');
|
||||
Alert::set($Language->g('an-error-occurred-while-trying-to-edit-the-post'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +40,7 @@ function deletePost($key)
|
|||
}
|
||||
else
|
||||
{
|
||||
Alert::set('Error occurred when trying to delete the post');
|
||||
Alert::set('an-error-occurred-while-trying-to-delete-the-post');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
function editUser($args)
|
||||
{
|
||||
global $dbUsers;
|
||||
global $Language;
|
||||
|
||||
if(isset($args['password']))
|
||||
{
|
||||
|
@ -14,7 +15,7 @@ function editUser($args)
|
|||
return $dbUsers->setPassword($args);
|
||||
}
|
||||
else {
|
||||
Alert::set('Passwords are differents');
|
||||
Alert::set($Language->g('password-does-not-match-the-confirm-password'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +39,7 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|||
}
|
||||
|
||||
if( editUser($_POST) ) {
|
||||
Alert::set('User saved successfuly');
|
||||
Alert::set($Language->g('the-changes-have-been-saved'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
function addPage($args)
|
||||
{
|
||||
global $dbPages;
|
||||
global $Language;
|
||||
|
||||
// Page status, published or draft.
|
||||
if( isset($args['publish']) ) {
|
||||
|
@ -24,7 +25,7 @@ function addPage($args)
|
|||
}
|
||||
else
|
||||
{
|
||||
Alert::set('Error occurred when trying to create the page');
|
||||
Alert::set($Language->g('an-error-occurred-while-trying-to-create-the-page'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
function addPost($args)
|
||||
{
|
||||
global $dbPosts;
|
||||
global $Language;
|
||||
|
||||
// Page status, published or draft.
|
||||
if( isset($args['publish']) ) {
|
||||
|
@ -24,7 +25,7 @@ function addPost($args)
|
|||
}
|
||||
else
|
||||
{
|
||||
Alert::set('Error occurred when trying to create the post');
|
||||
Alert::set($Language->g('an-error-occurred-while-trying-to-create-the-post'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ if($Login->role()!=='admin') {
|
|||
function setSettings($args)
|
||||
{
|
||||
global $Site;
|
||||
global $Language;
|
||||
|
||||
if(!isset($args['advancedOptions'])) {
|
||||
$args['advancedOptions'] = 'false';
|
||||
|
@ -31,7 +32,7 @@ function setSettings($args)
|
|||
}
|
||||
|
||||
if( $Site->set($args) ) {
|
||||
Alert::set('Settings has been saved successfully');
|
||||
Alert::set($Language->g('the-changes-have-been-saved'));
|
||||
}
|
||||
else {
|
||||
Alert::set('Error occurred when trying to saved the settings');
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
|
|
|
@ -178,6 +178,39 @@ a.btn-red:hover {
|
|||
color: rgba(255, 255, 255, 0.6) !important;
|
||||
}
|
||||
|
||||
/* ----------- PAGINATOR ----------- */
|
||||
|
||||
#paginator ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 0.9em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#paginator a {
|
||||
color: #2672ec;
|
||||
}
|
||||
|
||||
#paginator li {
|
||||
display: inline;
|
||||
float: none !important;
|
||||
}
|
||||
|
||||
#paginator li.left {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
#paginator li.list {
|
||||
background: #e0e0e0;
|
||||
color: #747474;
|
||||
padding: 2px 11px;
|
||||
}
|
||||
|
||||
#paginator li.right {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
|
||||
/* ----------- PLUGINS ----------- */
|
||||
div.pluginBox {
|
||||
|
|
|
@ -3,15 +3,16 @@
|
|||
function makeNavbar($type)
|
||||
{
|
||||
global $layout;
|
||||
global $Language;
|
||||
|
||||
$navbar['users'] = array(
|
||||
'users'=>array('text'=>'Users'),
|
||||
'add-user'=>array('text'=>'Add new user')
|
||||
'users'=>array('text'=>$Language->g('Users')),
|
||||
'add-user'=>array('text'=>$Language->g('Add a new user'))
|
||||
);
|
||||
|
||||
$navbar['manage'] = array(
|
||||
'manage-posts'=>array('text'=>'Manage posts'),
|
||||
'manage-pages'=>array('text'=>'Manage pages')
|
||||
'manage-posts'=>array('text'=>$Language->g('Manage posts')),
|
||||
'manage-pages'=>array('text'=>$Language->g('Manage pages'))
|
||||
);
|
||||
|
||||
echo '<nav class="navbar sublinks"><ul>';
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -45,7 +45,6 @@
|
|||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="forms-desc">Tip/Help ???</div>
|
||||
</label>
|
||||
|
||||
<?php } ?>
|
||||
|
@ -56,19 +55,19 @@
|
|||
<span class="input-prepend"><?php echo $Site->url() ?><span id="jsparentExample"><?php echo $_Page->parentKey()?$_Page->parentKey().'/':''; ?></span></span>
|
||||
<input id="jsslug" type="text" name="slug" value="<?php echo $_Page->slug() ?>">
|
||||
</div>
|
||||
<span class="forms-desc">You can modify the URL which identifies a page or post using human-readable keywords. No more than 150 characters.</span>
|
||||
<span class="forms-desc"><?php $Language->p('you-can-modify-the-url-which-identifies') ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<?php $Language->p('Description') ?>
|
||||
<input id="jsdescription" type="text" name="description" class="width-50" value="<?php echo $_Page->description() ?>">
|
||||
<span class="forms-desc">This field can help describe the content in a few words. No more than 150 characters.</span>
|
||||
<span class="forms-desc"><?php $Language->p('this-field-can-help-describe-the-content') ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<?php $Language->p('Tags') ?>
|
||||
<input id="jstags" name="tags" type="text" class="width-50" value="<?php echo $_Page->tags() ?>">
|
||||
<span class="forms-desc">Write the tags separeted by comma. eg: tag1, tag2, tag3</span>
|
||||
<span class="forms-desc"><?php $Language->p('write-the-tags-separeted-by-comma') ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
|
|
|
@ -33,19 +33,19 @@
|
|||
<span class="input-prepend"><?php echo $Site->urlPost() ?><span id="jsparentExample"></span></span>
|
||||
<input id="jsslug" type="text" name="slug" value="<?php echo $_Post->slug() ?>">
|
||||
</div>
|
||||
<span class="forms-desc">Short text no more than 150 characters. Special characters not allowed.</span>
|
||||
<span class="forms-desc"><?php $Language->p('you-can-modify-the-url-which-identifies') ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<?php $Language->p('Description') ?>
|
||||
<input id="jsdescription" type="text" name="description" class="width-50" value="<?php echo $_Post->description() ?>">
|
||||
<span class="forms-desc">This field is for Twitter/Facebook/Google+ descriptions. No more than 150 characters.</span>
|
||||
<span class="forms-desc"><?php $Language->p('this-field-can-help-describe-the-content') ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<?php $Language->p('Tags') ?>
|
||||
<input id="jstags" name="tags" type="text" class="width-50" value="<?php echo $_Post->tags() ?>">
|
||||
<span class="forms-desc">Write the tags separeted by comma. eg: tag1, tag2, tag3</span>
|
||||
<span class="forms-desc"><?php $Language->p('write-the-tags-separeted-by-comma') ?></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
<?php
|
||||
}
|
||||
?>
|
||||
<input type="submit" class="btn btn-blue" value="Save" name="user-profile">
|
||||
<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="user-profile">
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>" class="btn"><?php $Language->p('Cancel') ?></a>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -64,7 +64,7 @@
|
|||
<div class="forms-desc"><?php $Language->p('email-will-not-be-publicly-displayed') ?></div>
|
||||
</label>
|
||||
|
||||
<input type="submit" class="btn btn-blue" value="Save" name="user-email">
|
||||
<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="user-email">
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>" class="btn"><?php $Language->p('Cancel') ?></a>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -87,7 +87,7 @@
|
|||
<input type="password" name="confirm-password" class="width-50">
|
||||
</label>
|
||||
|
||||
<input type="submit" class="btn btn-blue" value="Save" name="user-password">
|
||||
<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="user-password">
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>" class="btn"><?php $Language->p('Cancel') ?></a>
|
||||
</form>
|
||||
</div>
|
|
@ -25,3 +25,19 @@
|
|||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="paginator">
|
||||
<ul>
|
||||
<?php
|
||||
if(Paginator::get('showNewer')) {
|
||||
echo '<li class="left"><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="right"><a href="'.HTML_PATH_ADMIN_ROOT.'manage-posts?page='.Paginator::get('nextPage').'">'.$Language->g('Next page').' »</a></li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
|
@ -36,7 +36,6 @@
|
|||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="forms-desc">Tip/Help ???</div>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
|
@ -45,19 +44,19 @@
|
|||
<span class="input-prepend"><?php echo $Site->urlPage() ?><span id="jsparentExample"></span></span>
|
||||
<input id="jsslug" name="slug" type="text">
|
||||
</div>
|
||||
<span class="forms-desc">Short text no more than 150 characters. Special characters not allowed.</span>
|
||||
<span class="forms-desc"><?php $Language->p('you-can-modify-the-url-which-identifies') ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<?php $Language->p('Description') ?>
|
||||
<input id="jsdescription" name="description" type="text" class="width-50">
|
||||
<span class="forms-desc">This field is for Twitter/Facebook/Google+ descriptions. No more than 150 characters.</span>
|
||||
<span class="forms-desc"><?php $Language->p('this-field-can-help-describe-the-content') ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<?php $Language->p('Tags') ?>
|
||||
<input id="jstags" name="tags" type="text" class="width-50">
|
||||
<span class="forms-desc">Write the tags separeted by comma. eg: tag1, tag2, tag3</span>
|
||||
<span class="forms-desc"><?php $Language->p('write-the-tags-separeted-by-comma') ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
|
|
|
@ -31,19 +31,19 @@
|
|||
<span class="input-prepend"><?php echo $Site->urlPost() ?><span id="jsparentExample"></span></span>
|
||||
<input id="jsslug" name="slug" type="text">
|
||||
</div>
|
||||
<span class="forms-desc">Short text no more than 150 characters. Special characters not allowed.</span>
|
||||
<span class="forms-desc"><?php $Language->p('you-can-modify-the-url-which-identifies') ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<?php $Language->p('Description') ?>
|
||||
<input id="jsdescription" name="description" type="text" class="width-50">
|
||||
<span class="forms-desc">This field is for Twitter/Facebook/Google+ descriptions. No more than 150 characters.</span>
|
||||
<span class="forms-desc"><?php $Language->p('this-field-can-help-describe-the-content') ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<?php $Language->p('Tags') ?>
|
||||
<input id="jstags" name="tags" type="text" class="width-50">
|
||||
<span class="forms-desc">Write the tags separeted by comma. eg: tag1, tag2, tag3</span>
|
||||
<span class="forms-desc"><?php $Language->p('write-the-tags-separeted-by-comma') ?></span>
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -164,5 +164,5 @@ $(document).ready(function() {
|
|||
<!-- ===================================== -->
|
||||
|
||||
<div id="about">
|
||||
<p><i class="fa fa-pencil-square-o"></i> Bludit version <?php echo BLUDIT_VERSION.' ('.BLUDIT_RELEASE_DATE.')' ?></p>
|
||||
<p><i class="fa fa-pencil-square-o"></i> <?php $Language->p('Bludit version') ?>: <?php echo BLUDIT_VERSION.' ('.BLUDIT_RELEASE_DATE.')' ?></p>
|
||||
</div>
|
|
@ -28,7 +28,14 @@ class dbJSON
|
|||
$implode = implode($lines);
|
||||
|
||||
// Unserialize, JSON to Array.
|
||||
$this->db = $this->unserialize($implode);
|
||||
$array = $this->unserialize($implode);
|
||||
|
||||
if(empty($array)) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Invalid JSON file: '.$file.', cannot be decoded. Check the file content.');
|
||||
}
|
||||
else {
|
||||
$this->db = $array;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -145,6 +145,7 @@ class Plugin {
|
|||
// Create database
|
||||
$Tmp = new dbJSON($this->filenameDb);
|
||||
$Tmp->db = $this->dbFields;
|
||||
$Tmp->db['position'] = 0;
|
||||
$Tmp->save();
|
||||
|
||||
return true;
|
||||
|
@ -228,4 +229,14 @@ class Plugin {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function beforeSiteLoad()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function afterSiteLoad()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -42,6 +42,7 @@ else
|
|||
include(PATH_RULES.'70.build_pages.php');
|
||||
include(PATH_RULES.'80.plugins.php');
|
||||
include(PATH_RULES.'99.header.php');
|
||||
include(PATH_RULES.'99.paginator.php');
|
||||
|
||||
if($Url->notFound() || !$Login->isLogged() || ($Url->slug()==='login') )
|
||||
{
|
||||
|
|
|
@ -96,6 +96,7 @@ include(PATH_HELPERS.'redirect.class.php');
|
|||
include(PATH_HELPERS.'sanitize.class.php');
|
||||
include(PATH_HELPERS.'filesystem.class.php');
|
||||
include(PATH_HELPERS.'alert.class.php');
|
||||
include(PATH_HELPERS.'paginator.class.php');
|
||||
|
||||
// Session
|
||||
Session::start();
|
||||
|
|
|
@ -11,6 +11,8 @@ $plugins = array(
|
|||
'onAdminHead'=>array(),
|
||||
'onAdminBody'=>array(),
|
||||
'onAdminSidebar'=>array(),
|
||||
'beforeSiteLoad'=>array(),
|
||||
'afterSiteLoad'=>array(),
|
||||
'beforePostsLoad'=>array(),
|
||||
'afterPostsLoad'=>array(),
|
||||
'beforePagesLoad'=>array(),
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// Current page number.
|
||||
$currentPage = $Url->pageNumber();
|
||||
Paginator::set('currentPage', $currentPage);
|
||||
|
||||
// Post per page.
|
||||
$postPerPage = $Site->postsPerPage();
|
||||
Paginator::set('postPerPage', $postPerPage);
|
||||
|
||||
// Number of pages.
|
||||
if($Url->whereAmI()=='admin') {
|
||||
$numberOfPosts = $dbPosts->numberPost(true); // published and drafts
|
||||
}
|
||||
else {
|
||||
$numberOfPosts = $dbPosts->numberPost(false); // published
|
||||
}
|
||||
|
||||
Paginator::set('numberOfPosts', $numberOfPosts);
|
||||
|
||||
$numberOfPages = (int) ceil($numberOfPosts / $postPerPage) -1;
|
||||
Paginator::set('numberOfPages', $numberOfPages);
|
||||
|
||||
$showOlder = $numberOfPages > $currentPage;
|
||||
Paginator::set('showOlder', $showOlder);
|
||||
|
||||
$showNewer = $currentPage > 0;
|
||||
Paginator::set('showNewer', $showNewer);
|
||||
|
||||
$show = $showNewer && $showOlder;
|
||||
Paginator::set('show', true);
|
||||
|
||||
$nextPage = max(0, $currentPage+1);
|
||||
Paginator::set('nextPage', $nextPage);
|
||||
|
||||
$prevPage = min($numberOfPages, $currentPage-1);
|
||||
Paginator::set('prevPage', $prevPage);
|
|
@ -5,6 +5,10 @@ include(PATH_RULES.'70.build_posts.php');
|
|||
include(PATH_RULES.'70.build_pages.php');
|
||||
include(PATH_RULES.'80.plugins.php');
|
||||
include(PATH_RULES.'99.header.php');
|
||||
include(PATH_RULES.'99.paginator.php');
|
||||
|
||||
// Plugins before site loaded
|
||||
Theme::plugins('beforeSiteLoad');
|
||||
|
||||
// Theme init.php
|
||||
if( Sanitize::pathFile(PATH_THEMES, $Site->theme().DS.'init.php') )
|
||||
|
@ -13,3 +17,6 @@ if( Sanitize::pathFile(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');
|
||||
|
||||
// Plugins after site loaded
|
||||
Theme::plugins('afterSiteLoad');
|
|
@ -14,9 +14,25 @@ class dbPosts extends dbJSON
|
|||
'unixTimeModified'=>array('inFile'=>false, 'value'=>0)
|
||||
);
|
||||
|
||||
private $numberPosts = array(
|
||||
'total'=>0,
|
||||
'withoutDrafts'=>0
|
||||
);
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct(PATH_DATABASES.'posts.php');
|
||||
|
||||
$this->numberPosts['total'] = count($this->db);
|
||||
}
|
||||
|
||||
public function numberPost($total=false)
|
||||
{
|
||||
if($total) {
|
||||
return $this->numberPosts['total'];
|
||||
}
|
||||
|
||||
return $this->numberPosts['withoutDrafts'];
|
||||
}
|
||||
|
||||
// Return an array with the database for a page, FALSE otherwise.
|
||||
|
@ -236,21 +252,22 @@ class dbPosts extends dbJSON
|
|||
|
||||
public function getPage($pageNumber, $postPerPage, $draftPosts=false)
|
||||
{
|
||||
$init = (int) $postPerPage * $pageNumber;
|
||||
$end = (int) min( ($init + $postPerPage - 1), count($this->db) - 1 );
|
||||
|
||||
$outrange = $init<0 ? true : $init > $end;
|
||||
|
||||
// DEBUG: Ver una mejor manera de eliminar draft post antes de ordenarlos
|
||||
// DEBUG: Se eliminan antes de ordenarlos porque sino los draft cuentan como publicados en el PostPerPage.
|
||||
if(!$draftPosts){
|
||||
if(!$draftPosts) {
|
||||
$this->removeUnpublished();
|
||||
$this->numberPosts['withoutDrafts'] = count($this->db);
|
||||
}
|
||||
|
||||
$init = (int) $postPerPage * $pageNumber;
|
||||
$end = (int) min( ($init + $postPerPage - 1), count($this->db) - 1 );
|
||||
$outrange = $init<0 ? true : $init > $end;
|
||||
|
||||
// Sort posts
|
||||
$tmp = $this->sortByDate();
|
||||
|
||||
if(!$outrange) {
|
||||
return array_slice($tmp, $init, $end+1, true);
|
||||
return array_slice($tmp, $init, $postPerPage, true);
|
||||
}
|
||||
|
||||
return array();
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
class Paginator {
|
||||
|
||||
public static $pager = array(
|
||||
'numberOfPostsAndDraft'=>0,
|
||||
'numberOfPosts'=>0,
|
||||
'numberOfPages'=>0,
|
||||
'nextPage'=>0,
|
||||
'prevPage'=>0,
|
||||
'currentPage'=>0,
|
||||
'showOlder'=>false,
|
||||
'showNewer'=>false,
|
||||
'show'=>false
|
||||
);
|
||||
|
||||
public static function set($key, $value)
|
||||
{
|
||||
self::$pager[$key] = $value;
|
||||
}
|
||||
|
||||
public static function get($key)
|
||||
{
|
||||
return self::$pager[$key];
|
||||
}
|
||||
|
||||
public static function html($textPrevPage=false, $textNextPage=false, $showPageNumber=false)
|
||||
{
|
||||
global $Language;
|
||||
|
||||
$html = '<div id="paginator">';
|
||||
$html .= '<ul>';
|
||||
|
||||
if(self::get('showNewer'))
|
||||
{
|
||||
if($textPrevPage===false) {
|
||||
$textPrevPage = '« '.$Language->g('Prev page');
|
||||
}
|
||||
|
||||
$html .= '<li class="left">';
|
||||
$html .= '<a href="'.HTML_PATH_ROOT.'?page='.self::get('prevPage').'">'.$textPrevPage.'</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
if($showPageNumber) {
|
||||
$html .= '<li class="list">'.(self::get('currentPage')+1).' / '.(self::get('numberOfPages')+1).'</li>';
|
||||
}
|
||||
|
||||
if(self::get('showOlder'))
|
||||
{
|
||||
if($textNextPage===false) {
|
||||
$textNextPage = $Language->g('Next page').' »';
|
||||
}
|
||||
|
||||
$html .= '<li class="right">';
|
||||
$html .= '<a href="'.HTML_PATH_ROOT.'?page='.self::get('nextPage').'">'.$textNextPage.'</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
"editor": "Editor",
|
||||
"dashboard": "Dashboard",
|
||||
"role": "Role",
|
||||
"post": "Post",
|
||||
"posts": "Posts",
|
||||
"users": "Users",
|
||||
"administrator": "Administrator",
|
||||
|
@ -49,6 +50,8 @@
|
|||
"dasbhoard": "Dasbhoard",
|
||||
"manage": "Manage",
|
||||
"themes": "Themes",
|
||||
"prev-page": "Prev page",
|
||||
"next-page": "Next page",
|
||||
"configure-plugin": "Configure plugin",
|
||||
"confirm-delete-this-action-cannot-be-undone": "Confirm delete, this action cannot be undone.",
|
||||
"site-title": "Site title",
|
||||
|
@ -59,6 +62,7 @@
|
|||
"site-url": "Site url",
|
||||
"writting-settings": "Writting settings",
|
||||
"url-filters": "URL filters",
|
||||
"page": "Page",
|
||||
"pages": "Pages",
|
||||
"home": "Home",
|
||||
"welcome-back": "Welcome back",
|
||||
|
@ -82,11 +86,26 @@
|
|||
"publish-now": "Publish now",
|
||||
"first-name": "First name",
|
||||
"last-name": "Last name",
|
||||
"bludit-version": "Bludit version",
|
||||
"powered-by": "Powered by",
|
||||
"recent-posts": "Recent Posts",
|
||||
"manage-pages": "Manage pages",
|
||||
"advanced-options": "Advanced options",
|
||||
"database-regenerated": "Database regenerated",
|
||||
"the-changes-have-been-saved": "The changes have been saved",
|
||||
"html-markdown-code-supported": "HTML and Markdown code supported.",
|
||||
"enable-more-features-at": "Enable more features at",
|
||||
"username-already-exists-or-is-empty": "Username already exists or is empty",
|
||||
"password-does-not-match-the-confirm-password":"Password does not match the confirm password",
|
||||
"user-has-been-added-successfully": "User has been added successfully",
|
||||
"an-error-occurred-while-trying-to-create-the-user-account": "An error occurred while trying to create the user account",
|
||||
"an-error-occurred-while-trying-to-delete-the-page": "An error occurred while trying to delete the page",
|
||||
"an-error-occurred-while-trying-to-delete-the-post": "An error occurred while trying to delete the post",
|
||||
"an-error-occurred-while-trying-to-create-the-page": "An error occurred while trying to create the page",
|
||||
"an-error-occurred-while-trying-to-create-the-post": "An error occurred while trying to create the post",
|
||||
"an-error-occurred-while-trying-to-edit-the-post": "An error occurred while trying to edit the post",
|
||||
"an-error-occurred-while-trying-to-edit-the-page": "An error occurred while trying to edit the page",
|
||||
"you-do-not-have-sufficient-permissions": "You do not have sufficient permissions to access this page, contact the administrator.",
|
||||
"settings-advanced-writting-settings": "Settings->Advanced->Writting Settings",
|
||||
"new-posts-and-pages-synchronized": "New posts and pages synchronized.",
|
||||
"you-can-choose-the-users-privilege": "You can choose the user's privilege. The editor role only can write pages and posts.",
|
||||
|
@ -101,9 +120,7 @@
|
|||
"select-your-sites-language": "Select your site's language.",
|
||||
"select-a-timezone-for-a-correct": "Select a timezone for a correct date/time display on your site.",
|
||||
"you-can-use-this-field-to-define-a-set-of": "You can use this field to define a set of parameters related to the languege, country and special preferences.",
|
||||
"email": "Email",
|
||||
"email": "Email",
|
||||
"email": "Email",
|
||||
"email": "Email",
|
||||
"email": "Email"
|
||||
"you-can-modify-the-url-which-identifies":"You can modify the URL which identifies a page or post using human-readable keywords. No more than 150 characters.",
|
||||
"this-field-can-help-describe-the-content": "This field can help describe the content in a few words. No more than 150 characters.",
|
||||
"write-the-tags-separeted-by-comma": "Write the tags separeted by comma. eg: tag1, tag2, tag3"
|
||||
}
|
|
@ -7,7 +7,5 @@
|
|||
"author": "Diego",
|
||||
"email": "",
|
||||
"website": ""
|
||||
},
|
||||
|
||||
"test":"test"
|
||||
}
|
||||
}
|
|
@ -75,11 +75,49 @@ div.footer {
|
|||
margin: 30px 0;
|
||||
}
|
||||
|
||||
/* ------------------------
|
||||
Paginator
|
||||
------------------------ */
|
||||
#paginator {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
#paginator a {
|
||||
color: #2672ec;
|
||||
}
|
||||
|
||||
#paginator ul {
|
||||
clear: both;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#paginator li {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#paginator li.left {
|
||||
float: left !important;
|
||||
}
|
||||
|
||||
#paginator li.list {
|
||||
background: #e0e0e0;
|
||||
color: #747474;
|
||||
padding: 2px 11px;
|
||||
}
|
||||
|
||||
#paginator li.right {
|
||||
float: right !important;
|
||||
}
|
||||
|
||||
/* ------------------------
|
||||
Pages and Posts
|
||||
------------------------ */
|
||||
.page,
|
||||
.post {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.page-title,
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
<!-- Footer -->
|
||||
<div class="footer">
|
||||
<p><?php echo $Site->footer(); ?> | Powered by <a target="_blank" href="http://www.bludit.com">Bludit</a></p>
|
||||
<p><?php echo $Site->footer(); ?> | <?php echo $Language->get('Powered by') ?> <a target="_blank" href="http://www.bludit.com">Bludit</a></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h1 class="subhead">Recent Posts</h1>
|
||||
<h1 class="subhead"><?php echo $Language->get('Recent posts') ?></h1>
|
||||
|
||||
<?php foreach ($posts as $Post): ?>
|
||||
|
||||
|
@ -39,3 +39,7 @@
|
|||
</section>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php
|
||||
echo Paginator::html();
|
||||
?>
|
|
@ -1,4 +1,4 @@
|
|||
<h1 class="subhead">Page</h1>
|
||||
<h1 class="subhead"><?php echo $Language->get('Page') ?></h1>
|
||||
|
||||
<section class="page">
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h1 class="subhead">Post</h1>
|
||||
<h1 class="subhead"><?php echo $Language->get('Post') ?></h1>
|
||||
|
||||
<section class="post">
|
||||
|
||||
|
|
Loading…
Reference in New Issue