changes variables names

This commit is contained in:
Diego Najar 2018-08-02 22:33:53 +02:00
parent b04587813e
commit 077bc21434
20 changed files with 80 additions and 116 deletions

View File

@ -28,6 +28,11 @@ class dbList extends dbJSON
parent::__construct($file);
}
public function keys()
{
return array_keys($this->db);
}
// Returns the list of keys filter by pageNumber
public function getList($key, $pageNumber, $amountOfItems)
{

View File

@ -65,23 +65,6 @@ class Plugin {
}
}
// DEPRECATED
// 2017-06-19
public function setDb($args)
{
foreach($this->dbFields as $key=>$value) {
if( isset($args[$key]) ) {
$value = Sanitize::html( $args[$key] );
if($value==='false') { $value = false; }
elseif($value==='true') { $value = true; }
settype($value, gettype($this->dbFields[$key]));
$this->db[$key] = $value;
}
}
$this->save();
}
public function save()
{
$tmp = new dbJSON($this->filenameDb);
@ -152,25 +135,6 @@ class Plugin {
return false;
}
// DEPRECATED
// 2017-06-16
public function getDbField($key, $html=true)
{
if(isset($this->db[$key])) {
if($html) {
// All fields from DBField are sanitized.
return $this->db[$key];
}
else {
// Decode HTML tags, this action unsanitized the variable.
return Sanitize::htmlDecode($this->db[$key]);
}
}
return '';
}
public function label()
{
return $this->getMetadata('label');

View File

@ -33,12 +33,12 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// ============================================================================
$categoryKey = $layout['parameters'];
if (!$dbCategories->exists($categoryKey)) {
if (!$categories->exists($categoryKey)) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the category: '.$categoryKey);
Redirect::page('categories');
}
$categoryMap = $dbCategories->getMap($categoryKey);
$categoryMap = $categories->getMap($categoryKey);
// Title of the page
$layout['title'] .= ' - '.$Language->g('Edit Category').' [ '.$categoryMap['name'] . ' ] ';

View File

@ -19,11 +19,11 @@ echo '
<tbody>
';
$categories = $dbCategories->getKeyNameArray();
foreach ($categories as $categoryKey=>$category) {
foreach ($categories->keys() as $key) {
$category = new Category($key);
echo '<tr>';
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-category/'.$categoryKey.'">'.$category.'</a></td>';
echo '<td><a href="'.DOMAIN_CATEGORIES.$categoryKey.'">'.$url->filters('category', false).$categoryKey.'</a></td>';
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-category/'.$key.'">'.$category->name().'</a></td>';
echo '<td><a href="'.$category->permalink().'">'.$url->filters('category', false).$key.'</a></td>';
echo '</tr>';
}

View File

@ -296,7 +296,7 @@
'selected'=>$page->categoryKey(),
'class'=>'',
'emptyOption'=>'- Uncategorized -',
'options'=>$dbCategories->getKeyNameArray()
'options'=>$categories->getKeyNameArray()
));
?>
</div>

View File

@ -230,7 +230,7 @@
'selected'=>'',
'class'=>'',
'emptyOption'=>'- Uncategorized -',
'options'=>$dbCategories->getKeyNameArray()
'options'=>$categories->getKeyNameArray()
));
?>
</div>

View File

@ -121,9 +121,9 @@ if (file_exists(PATH_KERNEL.'bludit.pro.php')) {
// Objects
$pages = $dbPages = new dbPages(); // DEPRECATED v3.0.0 $dbPages
$dbUsers = new dbUsers();
$dbTags = new dbTags();
$dbCategories = new dbCategories();
$users = $dbUsers = new dbUsers(); // DEPRECATED v3.0.0 $dbUsers
$tags = $dbTags = new dbTags(); // DEPRECATED v3.0.0 $dbTags
$categories = $dbCategories = new dbCategories(); // DEPRECATED v3.0.0 $dbCategories
$site = new dbSite();
$url = new Url();
$security = new Security();

View File

@ -11,12 +11,12 @@ if($url->whereAmI()=='admin') {
elseif($url->whereAmI()=='tag') {
$itemsPerPage = $site->itemsPerPage();
$tagKey = $url->slug();
$amountOfItems = $dbTags->countPagesByTag($tagKey);
$amountOfItems = $tags->countPagesByTag($tagKey);
}
elseif($url->whereAmI()=='category') {
$itemsPerPage = $site->itemsPerPage();
$categoryKey = $url->slug();
$amountOfItems = $dbCategories->countPagesByCategory($categoryKey);
$amountOfItems = $categories->countPagesByCategory($categoryKey);
}
else {
$itemsPerPage = $site->itemsPerPage();

View File

@ -6,14 +6,14 @@ class Category {
function __construct($key)
{
global $dbCategories;
if (isset($dbCategories->db[$key])) {
$this->vars['name'] = $dbCategories->db[$key]['name'];
$this->vars['template'] = $dbCategories->db[$key]['template'];
$this->vars['description'] = $dbCategories->db[$key]['description'];
global $categories;
if (isset($categories->db[$key])) {
$this->vars['name'] = $categories->db[$key]['name'];
$this->vars['template'] = $categories->db[$key]['template'];
$this->vars['description'] = $categories->db[$key]['description'];
$this->vars['key'] = $key;
$this->vars['permalink'] = DOMAIN_CATEGORIES . $key;
$this->vars['list'] = $dbCategories->db[$key]['list'];
$this->vars['list'] = $categories->db[$key]['list'];
} else {
$errorMessage = 'Category not found in database by key ['.$key.']';
Log::set(__METHOD__.LOG_SEP.$errorMessage);

View File

@ -3,15 +3,15 @@
// Re-index database of categories
// If you create/edit/remove a page is necessary regenerate the database of categories
function reindexCategories() {
global $dbCategories;
return $dbCategories->reindex();
global $categories;
return $categories->reindex();
}
// Re-index database of tags
// If you create/edit/remove a page is necessary regenerate the database of tags
function reindexTags() {
global $dbTags;
return $dbTags->reindex();
global $tags;
return $tags->reindex();
}
// Generate the page 404 Not found
@ -81,8 +81,8 @@ function buildPagesByTag() {
// This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag()
function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
global $dbPages;
global $dbCategories;
global $dbTags;
global $categories;
global $tags;
global $site;
global $url;
@ -102,11 +102,11 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
}
elseif ($for=='category') {
$amountOfItems = $site->itemsPerPage();
$list = $dbCategories->getList($categoryKey, $pageNumber, $amountOfItems);
$list = $categories->getList($categoryKey, $pageNumber, $amountOfItems);
}
elseif ($for=='tag') {
$amountOfItems = $site->itemsPerPage();
$list = $dbTags->getList($tagKey, $pageNumber, $amountOfItems);
$list = $tags->getList($tagKey, $pageNumber, $amountOfItems);
}
// There are not items, invalid tag, invalid category, out of range, etc...
@ -185,12 +185,6 @@ function getPlugin($pluginClassName) {
return false;
}
// DEPRACTED
// Returns TRUE if the plugin is enabled and installed, FALSE otherwise
function pluginEnabled($pluginClassName) {
return pluginActivated($pluginClassName);
}
// Returns TRUE if the plugin is activaed / installed, FALSE otherwise
function pluginActivated($pluginClassName) {
global $plugins;
@ -670,7 +664,7 @@ function checkRole($allowRoles, $redirect=true) {
// Add a new category to the system
// Returns TRUE is successfully added, FALSE otherwise
function createCategory($category) {
global $dbCategories;
global $categories;
global $Language;
global $syslog;
@ -679,7 +673,7 @@ function createCategory($category) {
return false;
}
if ($dbCategories->add(array('name'=>$category))) {
if ($categories->add(array('name'=>$category))) {
// Add to syslog
$syslog->add(array(
'dictionaryKey'=>'new-category-created',
@ -697,7 +691,7 @@ function createCategory($category) {
function editCategory($args) {
global $Language;
global $dbPages;
global $dbCategories;
global $categories;
global $syslog;
if (Text::isEmpty($args['name']) || Text::isEmpty($args['newKey']) ) {
@ -705,7 +699,7 @@ function editCategory($args) {
return false;
}
$newCategoryKey = $dbCategories->edit($args);
$newCategoryKey = $categories->edit($args);
if ($newCategoryKey==false) {
Alert::set($Language->g('The category already exists'));
@ -727,11 +721,11 @@ function editCategory($args) {
function deleteCategory($args) {
global $Language;
global $dbCategories;
global $categories;
global $syslog;
// Remove the category by key
$dbCategories->remove($args['oldKey']);
$categories->remove($args['oldKey']);
// Remove the category from the pages ? or keep it if the user want to recovery the category ?
@ -748,10 +742,10 @@ function deleteCategory($args) {
// Returns an array with all the categories
// By default, the database of categories is alphanumeric sorted
function getCategories() {
global $dbCategories;
global $categories;
$list = array();
foreach ($dbCategories->db as $key=>$fields) {
foreach ($categories->keys() as $key) {
$category = new Category($key);
array_push($list, $category);
}
@ -771,10 +765,10 @@ function getCategory($key) {
// Returns an array with all the tags
// By default, the database of tags is alphanumeric sorted
function getTags() {
global $dbTags;
global $tags;
$list = array();
foreach ($dbTags->db as $key=>$fields) {
foreach ($tags->db as $key=>$fields) {
$tag = new Tag($key);
array_push($list, $tag);
}

View File

@ -66,8 +66,8 @@ class Theme {
{
global $url;
global $site;
global $dbTags;
global $dbCategories;
global $tags;
global $categories;
global $WHERE_AM_I;
global $page;
@ -110,6 +110,7 @@ class Theme {
global $site;
global $WHERE_AM_I;
global $page;
global $url;
$description = $site->description();

View File

@ -190,9 +190,9 @@ class Page {
// categoryMap = array( 'name'=>'', 'list'=>array() )
public function categoryMap($field)
{
global $dbCategories;
global $categories;
$categoryKey = $this->categoryKey();
$map = $dbCategories->getMap($categoryKey);
$map = $categories->getMap($categoryKey);
if ($field=='key') {
return $this->categoryKey();

View File

@ -6,14 +6,14 @@ class Tag {
function __construct($key)
{
global $dbTags;
if (isset($dbTags->db[$key])) {
$this->vars['name'] = $dbTags->db[$key]['name'];
$this->vars['template'] = $dbTags->db[$key]['template'];
$this->vars['description'] = $dbTags->db[$key]['description'];
global $tags;
if (isset($tags->db[$key])) {
$this->vars['name'] = $tags->db[$key]['name'];
$this->vars['template'] = $tags->db[$key]['template'];
$this->vars['description'] = $tags->db[$key]['description'];
$this->vars['key'] = $key;
$this->vars['permalink'] = DOMAIN_TAGS . $key;
$this->vars['list'] = $dbTags->db[$key]['list'];
$this->vars['list'] = $tags->db[$key]['list'];
} else {
$errorMessage = 'Category not found in database by key ['.$key.']';
Log::set(__METHOD__.LOG_SEP.$errorMessage);

View File

@ -41,7 +41,7 @@ class pluginCategories extends Plugin {
public function siteSidebar()
{
global $Language;
global $dbCategories;
global $categories;
// HTML for sidebar
$html = '<div class="plugin plugin-categories">';
@ -50,7 +50,7 @@ class pluginCategories extends Plugin {
$html .= '<ul>';
// By default the database of categories are alphanumeric sorted
foreach ($dbCategories->db as $key=>$fields) {
foreach ($categories->db as $key=>$fields) {
$count = count($fields['list']);
if (!$this->getValue('hideCero') || $count>0) {
$html .= '<li>';

View File

@ -54,8 +54,8 @@ class pluginDisqus extends Plugin {
if ( !$url->notFound() &&
( $url->whereAmI()=='page' &&
(($this->getDbField('enablePosts') && $page->published()) ||
($this->getDbField('enablePages') && $page->static()))
(($this->getValue('enablePosts') && $page->published()) ||
($this->getValue('enablePages') && $page->static()))
) &&
$page->allowComments() ) {
$html = '<div id="disqus_thread"></div>';

View File

@ -28,7 +28,7 @@ class pluginMaintenanceMode extends Plugin {
$html .= '<div>';
$html .= '<label>'.$Language->get('Message').'</label>';
$html .= '<input name="message" id="jsmessage" type="text" value="'.$this->getDbField('message').'">';
$html .= '<input name="message" id="jsmessage" type="text" value="'.$this->getValue('message').'">';
$html .= '</div>';
return $html;
@ -36,8 +36,8 @@ class pluginMaintenanceMode extends Plugin {
public function beforeAll()
{
if ($this->getDbField('enable')) {
exit( $this->getDbField('message') );
if ($this->getValue('enable')) {
exit( $this->getValue('message') );
}
}
}

View File

@ -22,12 +22,12 @@ class pluginsimpleMDE extends Plugin {
$html = '<div>';
$html .= '<label>'.$Language->get('toolbar').'</label>';
$html .= '<input name="toolbar" id="jstoolbar" type="text" value="'.$this->getDbField('toolbar').'">';
$html .= '<input name="toolbar" id="jstoolbar" type="text" value="'.$this->getValue('toolbar').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('tab-size').'</label>';
$html .= '<input name="tabSize" id="jstabSize" type="text" value="'.$this->getDbField('tabSize').'">';
$html .= '<input name="tabSize" id="jstabSize" type="text" value="'.$this->getValue('tabSize').'">';
$html .= '</div>';
$html .= '<div>';
@ -62,7 +62,7 @@ class pluginsimpleMDE extends Plugin {
}
// Spell Checker
$spellCheckerEnable = $this->getDbField('spellChecker')?'true':'false';
$spellCheckerEnable = $this->getValue('spellChecker')?'true':'false';
// Include plugin's Javascript files
$html = $this->includeJS('simplemde.min.js');
@ -100,9 +100,9 @@ class pluginsimpleMDE extends Plugin {
lineWrapping: true,
autoDownloadFontAwesome: false,
indentWithTabs: true,
tabSize: '.$this->getDbField('tabSize').',
tabSize: '.$this->getValue('tabSize').',
spellChecker: '.$spellCheckerEnable.',
toolbar: ['.Sanitize::htmlDecode($this->getDbField('toolbar')).',
toolbar: ['.Sanitize::htmlDecode($this->getValue('toolbar')).',
"|",
{
name: "pageBreak",

View File

@ -29,18 +29,18 @@ class pluginTags extends Plugin {
public function siteSidebar()
{
global $Language;
global $dbTags;
global $tags;
global $url;
$filter = $url->filters('tag');
$html = '<div class="plugin plugin-tags">';
$html .= '<h2 class="plugin-label">'.$this->getDbField('label').'</h2>';
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
$html .= '<div class="plugin-content">';
$html .= '<ul>';
// By default the database of tags are alphanumeric sorted
foreach( $dbTags->db as $key=>$fields ) {
foreach( $tags->db as $key=>$fields ) {
$html .= '<li>';
$html .= '<a href="'.DOMAIN_TAGS.$key.'">';
$html .= $fields['name'];

View File

@ -22,17 +22,17 @@ class pluginTinymce extends Plugin {
$html = '<div>';
$html .= '<label>'.$Language->get('Toolbar top').'</label>';
$html .= '<input name="toolbar1" id="jstoolbar1" type="text" value="'.$this->getDbField('toolbar1').'">';
$html .= '<input name="toolbar1" id="jstoolbar1" type="text" value="'.$this->getValue('toolbar1').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Toolbar bottom').'</label>';
$html .= '<input name="toolbar2" id="jstoolbar2" type="text" value="'.$this->getDbField('toolbar2').'">';
$html .= '<input name="toolbar2" id="jstoolbar2" type="text" value="'.$this->getValue('toolbar2').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Plugins').'</label>';
$html .= '<input name="plugins" id="jsplugins" type="text" value="'.$this->getDbField('plugins').'">';
$html .= '<input name="plugins" id="jsplugins" type="text" value="'.$this->getValue('plugins').'">';
$html .= '</div>';
return $html;
@ -55,9 +55,9 @@ class pluginTinymce extends Plugin {
global $Language;
$toolbar1 = $this->getDbField('toolbar1');
$toolbar2 = $this->getDbField('toolbar2');
$plugins = $this->getDbField('plugins');
$toolbar1 = $this->getValue('toolbar1');
$toolbar2 = $this->getValue('toolbar2');
$plugins = $this->getValue('plugins');
$lang = 'en';
if (file_exists($this->phpPath().'tinymce'.DS.'langs'.DS.$Language->currentLanguage().'.js')) {

View File

@ -438,17 +438,17 @@ function install($adminPassword, $timezone)
// File categories.php
$data = array(
'general'=>array('name'=>'General', 'list'=>array()),
'music'=>array('name'=>'Music', 'list'=>array()),
'videos'=>array('name'=>'Videos', 'list'=>array())
'general'=>array('name'=>'General', 'description'=>'', 'template'=>'', 'list'=>array()),
'music'=>array('name'=>'Music', 'description'=>'', 'template'=>'', 'list'=>array()),
'videos'=>array('name'=>'Videos', 'description'=>'', 'template'=>'', 'list'=>array())
);
file_put_contents(PATH_DATABASES.'categories.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
// File tags.php
$data = array(
'bludit'=>array('name'=>'Bludit', 'list'=>array('welcome')),
'cms'=>array('name'=>'CMS', 'list'=>array('welcome')),
'flat-files'=>array('name'=>'Flat files', 'list'=>array('welcome'))
'bludit'=>array('name'=>'Bludit', 'description'=>'', 'template'=>'', 'list'=>array('welcome')),
'cms'=>array('name'=>'CMS', 'description'=>'', 'template'=>'', 'list'=>array('welcome')),
'flat-files'=>array('name'=>'Flat files', 'description'=>'', 'template'=>'', 'list'=>array('welcome'))
);
file_put_contents(PATH_DATABASES.'tags.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);