From 5c8fcff96c3c19440a3d4f696ae384b51d44f68a Mon Sep 17 00:00:00 2001 From: dignajar Date: Mon, 20 Jul 2015 00:14:12 -0300 Subject: [PATCH] Paginator --- admin/controllers/add-user.php | 11 +++-- admin/controllers/configure-plugin.php | 4 +- admin/controllers/edit-page.php | 10 ++-- admin/controllers/edit-post.php | 9 ++-- admin/controllers/edit-user.php | 7 +-- admin/controllers/install-plugin.php | 2 +- admin/controllers/new-page.php | 5 +- admin/controllers/new-post.php | 5 +- admin/controllers/settings.php | 7 +-- admin/controllers/uninstall-plugin.php | 2 +- admin/controllers/users.php | 2 +- admin/themes/default/css/default.css | 33 +++++++++++++ admin/themes/default/init.php | 9 ++-- admin/views/dashboard.php | 1 - admin/views/edit-page.php | 7 ++- admin/views/edit-post.php | 6 +-- admin/views/edit-user.php | 6 +-- admin/views/manage-posts.php | 18 ++++++- admin/views/new-page.php | 7 ++- admin/views/new-post.php | 6 +-- admin/views/settings.php | 2 +- kernel/abstract/dbjson.class.php | 9 +++- kernel/abstract/plugin.class.php | 13 ++++- kernel/boot/admin.php | 1 + kernel/boot/init.php | 1 + kernel/boot/rules/80.plugins.php | 2 + kernel/boot/rules/99.paginator.php | 37 +++++++++++++++ kernel/boot/site.php | 7 +++ kernel/dbposts.class.php | 31 +++++++++--- kernel/helpers/paginator.class.php | 66 ++++++++++++++++++++++++++ languages/en_US.json | 27 +++++++++-- languages/es_AR.json | 4 +- themes/pure/css/blog.css | 38 +++++++++++++++ themes/pure/index.php | 2 +- themes/pure/php/home.php | 8 +++- themes/pure/php/page.php | 2 +- themes/pure/php/post.php | 2 +- 37 files changed, 335 insertions(+), 74 deletions(-) create mode 100644 kernel/boot/rules/99.paginator.php create mode 100644 kernel/helpers/paginator.class.php diff --git a/admin/controllers/add-user.php b/admin/controllers/add-user.php index 07f5fdac..9ec0e558 100644 --- a/admin/controllers/add-user.php +++ b/admin/controllers/add-user.php @@ -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; } } diff --git a/admin/controllers/configure-plugin.php b/admin/controllers/configure-plugin.php index 5a58ba75..c4f6b6ee 100644 --- a/admin/controllers/configure-plugin.php +++ b/admin/controllers/configure-plugin.php @@ -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')); } // ============================================================================ diff --git a/admin/controllers/edit-page.php b/admin/controllers/edit-page.php index 960d028c..8c4ad2a2 100644 --- a/admin/controllers/edit-page.php +++ b/admin/controllers/edit-page.php @@ -7,6 +7,7 @@ function editPage($args) { global $dbPages; + global $Language; // Page status, published or draft. if( isset($args['publish']) ) { @@ -25,19 +26,20 @@ 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) ) { Alert::set('The page has been deleted successfully'); @@ -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'); } } diff --git a/admin/controllers/edit-post.php b/admin/controllers/edit-post.php index 93f15456..fb565644 100644 --- a/admin/controllers/edit-post.php +++ b/admin/controllers/edit-post.php @@ -7,7 +7,8 @@ function editPost($args) { global $dbPosts; - + global $Language; + // Post status, published or draft. if( isset($args['publish']) ) { $args['status'] = "published"; @@ -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'); } } diff --git a/admin/controllers/edit-user.php b/admin/controllers/edit-user.php index a697d575..f7c39687 100644 --- a/admin/controllers/edit-user.php +++ b/admin/controllers/edit-user.php @@ -7,14 +7,15 @@ function editUser($args) { global $dbUsers; - + global $Language; + if(isset($args['password'])) { if( ($args['password']===$args['confirm-password']) && !Text::isEmpty($args['password']) ) { 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')); } } diff --git a/admin/controllers/install-plugin.php b/admin/controllers/install-plugin.php index 4fe2ca74..6b615e82 100644 --- a/admin/controllers/install-plugin.php +++ b/admin/controllers/install-plugin.php @@ -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'); } diff --git a/admin/controllers/new-page.php b/admin/controllers/new-page.php index ad9ec932..46c77507 100644 --- a/admin/controllers/new-page.php +++ b/admin/controllers/new-page.php @@ -7,7 +7,8 @@ function addPage($args) { global $dbPages; - + global $Language; + // Page status, published or draft. if( isset($args['publish']) ) { $args['status'] = "published"; @@ -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')); } } diff --git a/admin/controllers/new-post.php b/admin/controllers/new-post.php index 77dcaf55..b69ca85c 100644 --- a/admin/controllers/new-post.php +++ b/admin/controllers/new-post.php @@ -7,7 +7,8 @@ function addPost($args) { global $dbPosts; - + global $Language; + // Page status, published or draft. if( isset($args['publish']) ) { $args['status'] = "published"; @@ -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')); } } diff --git a/admin/controllers/settings.php b/admin/controllers/settings.php index c6285dfa..455b4136 100644 --- a/admin/controllers/settings.php +++ b/admin/controllers/settings.php @@ -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,7 +16,8 @@ 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'); diff --git a/admin/controllers/uninstall-plugin.php b/admin/controllers/uninstall-plugin.php index e8763fe3..93fa0da7 100644 --- a/admin/controllers/uninstall-plugin.php +++ b/admin/controllers/uninstall-plugin.php @@ -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'); } diff --git a/admin/controllers/users.php b/admin/controllers/users.php index cb1667da..901e8d82 100644 --- a/admin/controllers/users.php +++ b/admin/controllers/users.php @@ -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'); } diff --git a/admin/themes/default/css/default.css b/admin/themes/default/css/default.css index ed627d01..25fa6f2f 100644 --- a/admin/themes/default/css/default.css +++ b/admin/themes/default/css/default.css @@ -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 { diff --git a/admin/themes/default/init.php b/admin/themes/default/init.php index 00c835f6..f86fcfdb 100644 --- a/admin/themes/default/init.php +++ b/admin/themes/default/init.php @@ -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 '