Changes on variables names

This commit is contained in:
Diego Najar 2018-08-03 18:59:23 +02:00
parent 077bc21434
commit 786f73cc5a
25 changed files with 121 additions and 123 deletions

View File

@ -26,17 +26,17 @@ checkRole(array('admin', 'editor'));
$onlyPublished = true; $onlyPublished = true;
$amountOfItems = ITEMS_PER_PAGE_ADMIN; $amountOfItems = ITEMS_PER_PAGE_ADMIN;
$pageNumber = $url->pageNumber(); $pageNumber = $url->pageNumber();
$published = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); $published = $pages->getList($pageNumber, $amountOfItems, $onlyPublished);
// Check if out of range the pageNumber // Check if out of range the pageNumber
if (empty($published) && $url->pageNumber()>1) { if (empty($published) && $url->pageNumber()>1) {
Redirect::page('content'); Redirect::page('content');
} }
$drafts = $dbPages->getDraftDB(true); $drafts = $pages->getDraftDB(true);
$scheduled = $dbPages->getScheduledDB(true); $scheduled = $pages->getScheduledDB(true);
$static = $dbPages->getStaticDB(true); $static = $pages->getStaticDB(true);
$sticky = $dbPages->getStickyDB(true); $sticky = $pages->getStickyDB(true);
// Title of the page // Title of the page
$layout['title'] .= ' - '.$Language->g('Manage content'); $layout['title'] .= ' - '.$Language->g('Manage content');

View File

@ -33,7 +33,7 @@
// UUID // UUID
echo Bootstrap::formInputHidden(array( echo Bootstrap::formInputHidden(array(
'name'=>'uuid', 'name'=>'uuid',
'value'=>$dbPages->generateUUID() 'value'=>$pages->generateUUID()
)); ));
// Status = published, draft, sticky, static // Status = published, draft, sticky, static
@ -154,7 +154,7 @@
'name'=>'position', 'name'=>'position',
'label'=>$L->g('Position'), 'label'=>$L->g('Position'),
'tip'=>'Field used when ordering content by position', 'tip'=>'Field used when ordering content by position',
'value'=>$dbPages->nextPositionNumber() 'value'=>$pages->nextPositionNumber()
)); ));
// Template // Template

View File

@ -24,7 +24,7 @@ echo '
<tbody> <tbody>
'; ';
$list = $dbUsers->getAllUsernames(); $list = $users->keys();
foreach ($list as $username) { foreach ($list as $username) {
try { try {
$user = new User($username); $user = new User($username);

View File

@ -5,7 +5,7 @@ $text = isset($_POST['text']) ? $_POST['text'] : '';
$parent = isset($_POST['parentKey']) ? $_POST['parentKey'] : PARENT; $parent = isset($_POST['parentKey']) ? $_POST['parentKey'] : PARENT;
$oldKey = isset($_POST['currentKey']) ? $_POST['currentKey'] : ''; $oldKey = isset($_POST['currentKey']) ? $_POST['currentKey'] : '';
$slug = $dbPages->generateKey($text, $parent, $returnSlug=true, $oldKey); $slug = $pages->generateKey($text, $parent, $returnSlug=true, $oldKey);
exit (json_encode(array( exit (json_encode(array(
'status'=>0, 'status'=>0,

View File

@ -38,7 +38,7 @@ $page = array(
); );
// Get the page key by the UUID // Get the page key by the UUID
$pageKey = $dbPages->getByUUID($autosaveUUID); $pageKey = $pages->getByUUID($autosaveUUID);
// if pageKey is empty means the autosave page doesn't exist // if pageKey is empty means the autosave page doesn't exist
if (empty($pageKey)) { if (empty($pageKey)) {

View File

@ -78,13 +78,13 @@ include(PATH_ABSTRACT.'dblist.class.php');
include(PATH_ABSTRACT.'plugin.class.php'); include(PATH_ABSTRACT.'plugin.class.php');
// Inclde Classes // Inclde Classes
include(PATH_KERNEL.'dbpages.class.php'); include(PATH_KERNEL.'pages.class.php');
include(PATH_KERNEL.'dbusers.class.php'); include(PATH_KERNEL.'users.class.php');
include(PATH_KERNEL.'dbtags.class.php'); include(PATH_KERNEL.'tags.class.php');
include(PATH_KERNEL.'dblanguage.class.php'); include(PATH_KERNEL.'language.class.php');
include(PATH_KERNEL.'dbsite.class.php'); include(PATH_KERNEL.'site.class.php');
include(PATH_KERNEL.'dbcategories.class.php'); include(PATH_KERNEL.'categories.class.php');
include(PATH_KERNEL.'dbsyslog.class.php'); include(PATH_KERNEL.'syslog.class.php');
include(PATH_KERNEL.'pagex.class.php'); include(PATH_KERNEL.'pagex.class.php');
include(PATH_KERNEL.'category.class.php'); include(PATH_KERNEL.'category.class.php');
include(PATH_KERNEL.'tag.class.php'); include(PATH_KERNEL.'tag.class.php');
@ -120,14 +120,14 @@ if (file_exists(PATH_KERNEL.'bludit.pro.php')) {
} }
// Objects // Objects
$pages = $dbPages = new dbPages(); // DEPRECATED v3.0.0 $dbPages $pages = new Pages(); // DEPRECATED v3.0.0 $dbPages
$users = $dbUsers = new dbUsers(); // DEPRECATED v3.0.0 $dbUsers $users = new Users(); // DEPRECATED v3.0.0 $users
$tags = $dbTags = new dbTags(); // DEPRECATED v3.0.0 $dbTags $tags = new Tags(); // DEPRECATED v3.0.0 $dbTags
$categories = $dbCategories = new dbCategories(); // DEPRECATED v3.0.0 $dbCategories $categories = new Categories(); // DEPRECATED v3.0.0 $dbCategories
$site = new dbSite(); $site = new Site();
$url = new Url(); $url = new Url();
$security = new Security(); $security = new Security();
$syslog = new dbSyslog(); $syslog = new Syslog();
// --- Relative paths --- // --- Relative paths ---
// This paths are relative for the user / web browsing. // This paths are relative for the user / web browsing.
@ -175,7 +175,7 @@ define('HTML_PATH_UPLOADS_THUMBNAILS', HTML_PATH_UPLOADS.'thumbnails/');
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/'); define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/');
// --- Objects with dependency --- // --- Objects with dependency ---
$language = $Language = new dbLanguage( $site->language() ); $language = $Language = new Language( $site->language() );
$url->checkFilters( $site->uriFilters() ); $url->checkFilters( $site->uriFilters() );
// --- CONSTANTS with dependency --- // --- CONSTANTS with dependency ---

View File

@ -36,7 +36,7 @@ $staticContent = $staticPages = buildStaticPages();
// ============================================================================ // ============================================================================
// Execute the scheduler // Execute the scheduler
if ($dbPages->scheduler()) { if ($pages->scheduler()) {
reindexTags(); reindexTags();
reindexCategories(); reindexCategories();
@ -50,7 +50,7 @@ if ($dbPages->scheduler()) {
// Set home page if the user defined them // Set home page if the user defined them
if ($site->homepage() && $url->whereAmI()==='home') { if ($site->homepage() && $url->whereAmI()==='home') {
$pageKey = $site->homepage(); $pageKey = $site->homepage();
if ($dbPages->exists($pageKey)) { if ($pages->exists($pageKey)) {
$url->setSlug($pageKey); $url->setSlug($pageKey);
$url->setWhereAmI('page'); $url->setWhereAmI('page');
} }

View File

@ -6,7 +6,7 @@ Paginator::set('currentPage', $currentPage);
if($url->whereAmI()=='admin') { if($url->whereAmI()=='admin') {
$itemsPerPage = ITEMS_PER_PAGE_ADMIN; $itemsPerPage = ITEMS_PER_PAGE_ADMIN;
$amountOfItems = $dbPages->count(true); $amountOfItems = $pages->count(true);
} }
elseif($url->whereAmI()=='tag') { elseif($url->whereAmI()=='tag') {
$itemsPerPage = $site->itemsPerPage(); $itemsPerPage = $site->itemsPerPage();
@ -20,7 +20,7 @@ elseif($url->whereAmI()=='category') {
} }
else { else {
$itemsPerPage = $site->itemsPerPage(); $itemsPerPage = $site->itemsPerPage();
$amountOfItems = $dbPages->count(true); $amountOfItems = $pages->count(true);
} }
// Items per page // Items per page

View File

@ -1,7 +1,7 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
class dbCategories extends dbList class Categories extends dbList {
{
function __construct() function __construct()
{ {
parent::__construct(DB_CATEGORIES); parent::__construct(DB_CATEGORIES);
@ -14,7 +14,7 @@ class dbCategories extends dbList
public function reindex() public function reindex()
{ {
global $dbPages; global $pages;
// Foreach category // Foreach category
foreach ($this->db as $key=>$value) { foreach ($this->db as $key=>$value) {
@ -22,7 +22,7 @@ class dbCategories extends dbList
} }
// Get a database with published pages // Get a database with published pages
$db = $dbPages->getPublishedDB(false); $db = $pages->getPublishedDB(false);
foreach ($db as $pageKey=>$pageFields) { foreach ($db as $pageKey=>$pageFields) {
if (!empty($pageFields['category'])) { if (!empty($pageFields['category'])) {
$categoryKey = $pageFields['category']; $categoryKey = $pageFields['category'];

View File

@ -18,7 +18,7 @@ function reindexTags() {
function buildErrorPage() { function buildErrorPage() {
global $site; global $site;
global $language; global $language;
global $dbUsers; global $users;
try { try {
$pageNotFoundKey = $site->pageNotFound(); $pageNotFoundKey = $site->pageNotFound();
@ -80,7 +80,7 @@ function buildPagesByTag() {
// Generate the global variables $content / $content, defined on 69.pages.php // Generate the global variables $content / $content, defined on 69.pages.php
// This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag() // This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag()
function buildPagesFor($for, $categoryKey=false, $tagKey=false) { function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
global $dbPages; global $pages;
global $categories; global $categories;
global $tags; global $tags;
global $site; global $site;
@ -92,11 +92,11 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
if ($for=='home') { if ($for=='home') {
$onlyPublished = true; $onlyPublished = true;
$amountOfItems = $site->itemsPerPage(); $amountOfItems = $site->itemsPerPage();
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); $list = $pages->getList($pageNumber, $amountOfItems, $onlyPublished);
// Include sticky pages only in the first page // Include sticky pages only in the first page
if ($pageNumber==1) { if ($pageNumber==1) {
$sticky = $dbPages->getStickyDB(); $sticky = $pages->getStickyDB();
$list = array_merge($sticky, $list); $list = array_merge($sticky, $list);
} }
} }
@ -130,10 +130,10 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
// Returns an array with all the static pages as Page-Object // Returns an array with all the static pages as Page-Object
// The static pages are order by position all the time // The static pages are order by position all the time
function buildStaticPages() { function buildStaticPages() {
global $dbPages; global $pages;
$list = array(); $list = array();
$pagesKey = $dbPages->getStaticDB(); $pagesKey = $pages->getStaticDB();
foreach ($pagesKey as $pageKey) { foreach ($pagesKey as $pageKey) {
try { try {
$page = new Page($pageKey); $page = new Page($pageKey);
@ -159,10 +159,10 @@ function buildPage($pageKey) {
// Returns an array with all the parent pages as Page-Object // Returns an array with all the parent pages as Page-Object
// The pages are order by the settings on the system // The pages are order by the settings on the system
function buildParentPages() { function buildParentPages() {
global $dbPages; global $pages;
$list = array(); $list = array();
$pagesKey = $dbPages->getPublishedDB(); $pagesKey = $pages->getPublishedDB();
foreach ($pagesKey as $pageKey) { foreach ($pagesKey as $pageKey) {
try { try {
$page = new Page($pageKey); $page = new Page($pageKey);
@ -265,13 +265,13 @@ function changePluginsPosition($pluginClassList) {
} }
function createPage($args) { function createPage($args) {
global $dbPages; global $pages;
global $syslog; global $syslog;
global $Language; global $Language;
// Check if the autosave page exists for this new page and delete it // Check if the autosave page exists for this new page and delete it
if (isset($args['uuid'])) { if (isset($args['uuid'])) {
$autosaveKey = $dbPages->getByUUID('autosave-'.$args['uuid']); $autosaveKey = $pages->getByUUID('autosave-'.$args['uuid']);
if (!empty($autosaveKey)) { if (!empty($autosaveKey)) {
Log::set('Function createPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO); Log::set('Function createPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
deletePage($autosaveKey); deletePage($autosaveKey);
@ -285,7 +285,7 @@ function createPage($args) {
return false; return false;
} }
$key = $dbPages->add($args); $key = $pages->add($args);
if ($key) { if ($key) {
// Call the plugins after page created // Call the plugins after page created
Theme::plugins('afterPageCreate'); Theme::plugins('afterPageCreate');
@ -312,12 +312,12 @@ function createPage($args) {
} }
function editPage($args) { function editPage($args) {
global $dbPages; global $pages;
global $syslog; global $syslog;
// Check if the autosave page exists for this new page and delete it // Check if the autosave page exists for this new page and delete it
if (isset($args['uuid'])) { if (isset($args['uuid'])) {
$pageKey = $dbPages->getByUUID('autosave-'.$args['uuid']); $pageKey = $pages->getByUUID('autosave-'.$args['uuid']);
if (!empty($pageKey)) { if (!empty($pageKey)) {
Log::set('Function editPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO); Log::set('Function editPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
deletePage($pageKey); deletePage($pageKey);
@ -331,7 +331,7 @@ function editPage($args) {
} }
// Check if the page key exist // Check if the page key exist
if (!$dbPages->exists($args['key'])) { if (!$pages->exists($args['key'])) {
Log::set('Function editPage()'.LOG_SEP.'Page key does not exist, '.$args['key'], LOG_TYPE_ERROR); Log::set('Function editPage()'.LOG_SEP.'Page key does not exist, '.$args['key'], LOG_TYPE_ERROR);
return false; return false;
} }
@ -351,7 +351,7 @@ function editPage($args) {
} }
} }
$key = $dbPages->edit($args); $key = $pages->edit($args);
if ($key) { if ($key) {
// Call the plugins after page modified // Call the plugins after page modified
Theme::plugins('afterPageModify'); Theme::plugins('afterPageModify');
@ -373,10 +373,10 @@ function editPage($args) {
} }
function deletePage($key) { function deletePage($key) {
global $dbPages; global $pages;
global $syslog; global $syslog;
if ($dbPages->delete($key)) { if ($pages->delete($key)) {
// Call the plugins after page deleted // Call the plugins after page deleted
Theme::plugins('afterPageDelete'); Theme::plugins('afterPageDelete');
@ -396,10 +396,10 @@ function deletePage($key) {
} }
function editUser($args) { function editUser($args) {
global $dbUsers; global $users;
global $syslog; global $syslog;
if ($dbUsers->set($args)) { if ($users->set($args)) {
// Add to syslog // Add to syslog
$syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'user-edited', 'dictionaryKey'=>'user-edited',
@ -413,7 +413,7 @@ function editUser($args) {
} }
function disableUser($args) { function disableUser($args) {
global $dbUsers; global $users;
global $login; global $login;
global $syslog; global $syslog;
@ -426,12 +426,12 @@ function disableUser($args) {
} }
// Check if the username exists // Check if the username exists
if (!$dbUsers->exists($username)) { if (!$users->exists($username)) {
return false; return false;
} }
// Disable the user // Disable the user
if ($dbUsers->disableUser($username)) { if ($users->disableUser($username)) {
// Add to syslog // Add to syslog
$syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'user-disabled', 'dictionaryKey'=>'user-disabled',
@ -445,7 +445,7 @@ function disableUser($args) {
} }
function deleteUser($args) { function deleteUser($args) {
global $dbUsers, $dbPages; global $users, $pages;
global $login; global $login;
global $syslog; global $syslog;
@ -464,17 +464,17 @@ function deleteUser($args) {
} }
// Check if the username exists // Check if the username exists
if (!$dbUsers->exists($username)) { if (!$users->exists($username)) {
return false; return false;
} }
if ($deleteContent) { if ($deleteContent) {
$dbPages->deletePagesByUser(array('username'=>$username)); $pages->deletePagesByUser(array('username'=>$username));
} else { } else {
$dbPages->transferPages(array('oldUsername'=>$username)); $pages->transferPages(array('oldUsername'=>$username));
} }
if ($dbUsers->delete($username)) { if ($users->delete($username)) {
// Add to syslog // Add to syslog
$syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'user-deleted', 'dictionaryKey'=>'user-deleted',
@ -488,7 +488,7 @@ function deleteUser($args) {
} }
function createUser($args) { function createUser($args) {
global $dbUsers; global $users;
global $Language; global $Language;
global $syslog; global $syslog;
@ -499,7 +499,7 @@ function createUser($args) {
} }
// Check already exist username // Check already exist username
if ($dbUsers->exists($args['new_username'])) { if ($users->exists($args['new_username'])) {
Alert::set($Language->g('username-already-exists'), ALERT_STATUS_FAIL); Alert::set($Language->g('username-already-exists'), ALERT_STATUS_FAIL);
return false; return false;
} }
@ -524,7 +524,7 @@ function createUser($args) {
$tmp['email'] = $args['email']; $tmp['email'] = $args['email'];
// Add the user to the database // Add the user to the database
if ($dbUsers->add($tmp)) { if ($users->add($tmp)) {
// Add to syslog // Add to syslog
$syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'new-user-created', 'dictionaryKey'=>'new-user-created',
@ -541,7 +541,7 @@ function editSettings($args) {
global $site; global $site;
global $syslog; global $syslog;
global $Language; global $Language;
global $dbPages; global $pages;
if (isset($args['language'])) { if (isset($args['language'])) {
if ($args['language']!=$site->language()) { if ($args['language']!=$site->language()) {
@ -578,11 +578,11 @@ function editSettings($args) {
// Check current order-by if changed it reorder the content // Check current order-by if changed it reorder the content
if ($site->orderBy()!=ORDER_BY) { if ($site->orderBy()!=ORDER_BY) {
if ($site->orderBy()=='date') { if ($site->orderBy()=='date') {
$dbPages->sortByDate(); $pages->sortByDate();
} else { } else {
$dbPages->sortByPosition(); $pages->sortByPosition();
} }
$dbPages->save(); $pages->save();
} }
// Add syslog // Add syslog
@ -600,7 +600,7 @@ function editSettings($args) {
} }
function changeUserPassword($args) { function changeUserPassword($args) {
global $dbUsers; global $users;
global $Language; global $Language;
global $syslog; global $syslog;
@ -620,7 +620,7 @@ function changeUserPassword($args) {
return false; return false;
} }
if ($dbUsers->setPassword(array('username'=>$username, 'password'=>$newPassword))) { if ($users->setPassword(array('username'=>$username, 'password'=>$newPassword))) {
// Add to syslog // Add to syslog
$syslog->add(array( $syslog->add(array(
'dictionaryKey'=>'user-password-changed', 'dictionaryKey'=>'user-password-changed',
@ -690,7 +690,7 @@ function createCategory($category) {
function editCategory($args) { function editCategory($args) {
global $Language; global $Language;
global $dbPages; global $pages;
global $categories; global $categories;
global $syslog; global $syslog;
@ -707,7 +707,7 @@ function editCategory($args) {
} }
// Change the category key in the pages database // Change the category key in the pages database
$dbPages->changeCategory($args['oldKey'], $newCategoryKey); $pages->changeCategory($args['oldKey'], $newCategoryKey);
// Add to syslog // Add to syslog
$syslog->add(array( $syslog->add(array(

View File

@ -1,7 +1,6 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
class dbLanguage extends dbJSON class Language extends dbJSON {
{
public $data; public $data;
public $db; public $db;
public $currentLanguage; public $currentLanguage;

View File

@ -2,14 +2,14 @@
class Login { class Login {
private $dbUsers; private $users;
function __construct() function __construct()
{ {
if (isset($GLOBALS['dbUsers'])) { if (isset($GLOBALS['users'])) {
$this->dbUsers = $GLOBALS['dbUsers']; $this->users = $GLOBALS['users'];
} else { } else {
$this->dbUsers = new dbUsers(); $this->users = new users();
} }
// Start the Session // Start the Session
@ -64,8 +64,8 @@ class Login {
$username = Sanitize::html($username); $username = Sanitize::html($username);
// Set the token on the users database // Set the token on the users database
$token = $this->dbUsers->generateRememberToken(); $token = $this->users->generateRememberToken();
$this->dbUsers->setRememberToken($username, $token); $this->users->setRememberToken($username, $token);
// Set the token on the cookies // Set the token on the cookies
Cookie::set(REMEMBER_COOKIE_USERNAME, $username, REMEMBER_COOKIE_EXPIRE_IN_DAYS); Cookie::set(REMEMBER_COOKIE_USERNAME, $username, REMEMBER_COOKIE_EXPIRE_IN_DAYS);
@ -77,7 +77,7 @@ class Login {
public function invalidateRememberMe() public function invalidateRememberMe()
{ {
// Invalidate all tokens on the user databases // Invalidate all tokens on the user databases
$this->dbUsers->invalidateAllRememberTokens(); $this->users->invalidateAllRememberTokens();
// Destroy the cookies // Destroy the cookies
Cookie::set(REMEMBER_COOKIE_USERNAME, '', -1); Cookie::set(REMEMBER_COOKIE_USERNAME, '', -1);
@ -110,7 +110,7 @@ class Login {
return false; return false;
} }
$passwordHash = $this->dbUsers->generatePasswordHash($password, $user->salt()); $passwordHash = $this->users->generatePasswordHash($password, $user->salt());
if ($passwordHash===$user->password()) { if ($passwordHash===$user->password()) {
$this->setLogin($username, $user->role()); $this->setLogin($username, $user->role());
Log::set(__METHOD__.LOG_SEP.'User logged succeeded by username and password - Username ['.$username.']'); Log::set(__METHOD__.LOG_SEP.'User logged succeeded by username and password - Username ['.$username.']');
@ -143,14 +143,14 @@ class Login {
return false; return false;
} }
if ($username !== $this->dbUsers->getByRememberToken($token)) { if ($username !== $this->users->getByRememberToken($token)) {
$this->invalidateRememberMe(); $this->invalidateRememberMe();
Log::set(__METHOD__.LOG_SEP.'The user has different token or the token doesn\'t exist.'); Log::set(__METHOD__.LOG_SEP.'The user has different token or the token doesn\'t exist.');
return false; return false;
} }
// Validate user and login // Validate user and login
$user = $this->dbUsers->getDb($username); $user = $this->users->getDb($username);
$this->setLogin($username, $user['role']); $this->setLogin($username, $user['role']);
Log::set(__METHOD__.LOG_SEP.'User authenticated via Remember Me.'); Log::set(__METHOD__.LOG_SEP.'User authenticated via Remember Me.');
return true; return true;

View File

@ -1,6 +1,6 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
class dbPages extends dbJSON { class Pages extends dbJSON {
private $parentKeyList = array(); private $parentKeyList = array();
private $dbFields = array( private $dbFields = array(

View File

@ -6,21 +6,21 @@ class Page {
function __construct($key) function __construct($key)
{ {
global $dbPages; global $pages;
$this->vars['key'] = $key; $this->vars['key'] = $key;
// If key is FALSE, the page is create with default values, like an empty page // If key is FALSE, the page is create with default values, like an empty page
// Useful for Page Not Found // Useful for Page Not Found
if ($key===false) { if ($key===false) {
$row = $dbPages->getDefaultFields(); $row = $pages->getDefaultFields();
} else { } else {
if (Text::isEmpty($key) || !$dbPages->exists($key)) { if (Text::isEmpty($key) || !$pages->exists($key)) {
$errorMessage = 'Page not found in database by key ['.$key.']'; $errorMessage = 'Page not found in database by key ['.$key.']';
Log::set(__METHOD__.LOG_SEP.$errorMessage); Log::set(__METHOD__.LOG_SEP.$errorMessage);
throw new Exception($errorMessage); throw new Exception($errorMessage);
} }
$row = $dbPages->getPageDB($key); $row = $pages->getPageDB($key);
} }
foreach ($row as $field=>$value) { foreach ($row as $field=>$value) {
@ -151,15 +151,15 @@ class Page {
// Returns the previous page key // Returns the previous page key
public function previousKey() public function previousKey()
{ {
global $dbPages; global $pages;
return $dbPages->previousPageKey($this->key()); return $pages->previousPageKey($this->key());
} }
// Returns the next page key // Returns the next page key
public function nextKey() public function nextKey()
{ {
global $dbPages; global $pages;
return $dbPages->nextPageKey($this->key()); return $pages->nextPageKey($this->key());
} }
// Returns the category name // Returns the category name
@ -459,17 +459,17 @@ class Page {
// Returns an array with all children's keys // Returns an array with all children's keys
public function childrenKeys() public function childrenKeys()
{ {
global $dbPages; global $pages;
$key = $this->key(); $key = $this->key();
return $dbPages->getChildren($key); return $pages->getChildren($key);
} }
// Returns an array with all children as Page-Object // Returns an array with all children as Page-Object
public function children() public function children()
{ {
global $dbPages; global $pages;
$list = array(); $list = array();
$childrenKeys = $dbPages->getChildren($this->key()); $childrenKeys = $pages->getChildren($this->key());
foreach ($childrenKeys as $childKey) { foreach ($childrenKeys as $childKey) {
try { try {
$child = new Page($childKey); $child = new Page($childKey);

View File

@ -1,7 +1,6 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
class dbSite extends dbJSON class Site extends dbJSON {
{
public $dbFields = array( public $dbFields = array(
'title'=> 'I am Guybrush Threepwood, mighty developer', 'title'=> 'I am Guybrush Threepwood, mighty developer',
'slogan'=> '', 'slogan'=> '',

View File

@ -1,7 +1,7 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
class dbSyslog extends dbJSON class Syslog extends dbJSON {
{
public $dbFields = array( public $dbFields = array(
'date'=> array('inFile'=>false, 'value'=>''), 'date'=> array('inFile'=>false, 'value'=>''),
'dictionaryKey'=> array('inFile'=>false, 'value'=>''), 'dictionaryKey'=> array('inFile'=>false, 'value'=>''),

View File

@ -1,7 +1,7 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
class dbTags extends dbList class Tags extends dbList {
{
function __construct() function __construct()
{ {
parent::__construct(DB_TAGS); parent::__construct(DB_TAGS);
@ -14,10 +14,10 @@ class dbTags extends dbList
public function reindex() public function reindex()
{ {
global $dbPages; global $pages;
// Get a database with published pages // Get a database with published pages
$db = $dbPages->getPublishedDB(false); $db = $pages->getPublishedDB(false);
$tagsIndex = array(); $tagsIndex = array();

View File

@ -5,19 +5,19 @@ class User {
function __construct($username) function __construct($username)
{ {
global $dbUsers; global $users;
$this->vars['username'] = $username; $this->vars['username'] = $username;
if ($username===false) { if ($username===false) {
$row = $dbUsers->getDefaultFields(); $row = $users->getDefaultFields();
} else { } else {
if (Text::isEmpty($username) || !$dbUsers->exists($username)) { if (Text::isEmpty($username) || !$users->exists($username)) {
$errorMessage = 'User not found in database by username ['.$username.']'; $errorMessage = 'User not found in database by username ['.$username.']';
Log::set(__METHOD__.LOG_SEP.$errorMessage); Log::set(__METHOD__.LOG_SEP.$errorMessage);
throw new Exception($errorMessage); throw new Exception($errorMessage);
} }
$row = $dbUsers->getUserDB($username); $row = $users->getUserDB($username);
} }
foreach ($row as $field=>$value) { foreach ($row as $field=>$value) {

View File

@ -1,6 +1,6 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
class dbUsers extends dbJSON { class Users extends dbJSON {
public $dbFields = array( public $dbFields = array(
'firstName'=>'', 'firstName'=>'',
@ -208,7 +208,7 @@ class dbUsers extends dbJSON {
return $this->save(); return $this->save();
} }
public function getAllUsernames() public function keys()
{ {
return array_keys($this->db); return array_keys($this->db);
} }

View File

@ -45,8 +45,8 @@ class pluginAPI extends Plugin {
public function beforeAll() public function beforeAll()
{ {
global $url; global $url;
global $dbPages; global $pages;
global $dbUsers; global $users;
// CHECK URL // CHECK URL
// ------------------------------------------------------------ // ------------------------------------------------------------
@ -96,11 +96,11 @@ class pluginAPI extends Plugin {
if ( !empty($inputs['authentication']) ) { if ( !empty($inputs['authentication']) ) {
// Get the user with the authentication token, FALSE if doesn't exit // Get the user with the authentication token, FALSE if doesn't exit
$username = $dbUsers->getByAuthToken($inputs['authentication']); $username = $users->getByAuthToken($inputs['authentication']);
if ($username!==false) { if ($username!==false) {
// Get the object user to check the role // Get the object user to check the role
$user = $dbUsers->getUser($username); $user = $users->getUser($username);
if (($user->role()=='admin') && ($user->enabled())) { if (($user->role()=='admin') && ($user->enabled())) {
// Loggin the user to create the session // Loggin the user to create the session
$login = new Login(); $login = new Login();
@ -235,12 +235,12 @@ class pluginAPI extends Plugin {
private function getPages() private function getPages()
{ {
global $dbPages; global $pages;
$onlyPublished = true; $onlyPublished = true;
$amountOfItems = $this->getValue('amountOfItems'); $amountOfItems = $this->getValue('amountOfItems');
$pageNumber = 1; $pageNumber = 1;
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); $list = $pages->getList($pageNumber, $amountOfItems, $onlyPublished);
$tmp = array( $tmp = array(
'status'=>'0', 'status'=>'0',

View File

@ -52,7 +52,7 @@ class pluginNavigation extends Plugin {
global $Language; global $Language;
global $url; global $url;
global $site; global $site;
global $dbPages; global $pages;
// HTML for sidebar // HTML for sidebar
$html = '<div class="plugin plugin-navigation">'; $html = '<div class="plugin plugin-navigation">';
@ -101,7 +101,7 @@ class pluginNavigation extends Plugin {
$onlyPublished = true; $onlyPublished = true;
$pageNumber = 1; $pageNumber = 1;
$amountOfItems = $this->getValue('amountOfItems'); $amountOfItems = $this->getValue('amountOfItems');
$publishedPages = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); $publishedPages = $pages->getList($pageNumber, $amountOfItems, $onlyPublished);
foreach ($publishedPages as $pageKey) { foreach ($publishedPages as $pageKey) {
try { try {

View File

@ -36,7 +36,7 @@ class pluginRSS extends Plugin {
private function createXML() private function createXML()
{ {
global $site; global $site;
global $dbPages; global $pages;
global $url; global $url;
// Amount of pages to show // Amount of pages to show
@ -49,7 +49,7 @@ class pluginRSS extends Plugin {
$onlyPublished = true; $onlyPublished = true;
// Get the list of pages // Get the list of pages
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished, true); $list = $pages->getList($pageNumber, $amountOfItems, $onlyPublished, true);
$xml = '<?xml version="1.0" encoding="UTF-8" ?>'; $xml = '<?xml version="1.0" encoding="UTF-8" ?>';
$xml .= '<rss version="2.0">'; $xml .= '<rss version="2.0">';

View File

@ -23,7 +23,7 @@ class pluginSitemap extends Plugin {
private function createXML() private function createXML()
{ {
global $site; global $site;
global $dbPages; global $pages;
$xml = '<?xml version="1.0" encoding="UTF-8" ?>'; $xml = '<?xml version="1.0" encoding="UTF-8" ?>';
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
@ -36,7 +36,7 @@ class pluginSitemap extends Plugin {
$pageNumber = 1; $pageNumber = 1;
$amountOfItems = -1; $amountOfItems = -1;
$onlyPublished = true; $onlyPublished = true;
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); $list = $pages->getList($pageNumber, $amountOfItems, $onlyPublished);
foreach($list as $pageKey) { foreach($list as $pageKey) {
try { try {

View File

@ -44,7 +44,7 @@ class pluginStaticPages extends Plugin {
global $Language; global $Language;
global $url; global $url;
global $site; global $site;
global $dbPages; global $pages;
// HTML for sidebar // HTML for sidebar
$html = '<div class="plugin plugin-static-pages">'; $html = '<div class="plugin plugin-static-pages">';

View File

@ -155,7 +155,7 @@ foreach ($languageFiles as $fname=>$native) {
} }
} }
$Language = new dbLanguage($finalLanguage); $Language = new Language($finalLanguage);
// Set locale // Set locale
setlocale(LC_ALL, $localeFromHTTP); setlocale(LC_ALL, $localeFromHTTP);