commit
5af87f14ad
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
.DS_Store
|
||||
bl-content/*
|
||||
bl-plugins/timemachine
|
||||
bl-plugins/timemachine
|
||||
bl-plugins/remote-content
|
||||
bl-kernel/bludit.pro.php
|
@ -24,7 +24,7 @@ class dbList extends dbJSON
|
||||
parent::__construct($file);
|
||||
}
|
||||
|
||||
private function getList($key, $amountOfItems, $pageNumber)
|
||||
public function getList($key, $pageNumber, $amountOfItems)
|
||||
{
|
||||
if( !isset($this->db[$key]) ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error key does not exist '.$key);
|
||||
@ -33,8 +33,11 @@ class dbList extends dbJSON
|
||||
|
||||
$list = $this->db[$key]['list'];
|
||||
|
||||
// The first page number is 1, so the real is 0
|
||||
$realPageNumber = $pageNumber - 1;
|
||||
|
||||
$total = count($list);
|
||||
$init = (int) $amountOfItems * $pageNumber;
|
||||
$init = (int) $amountOfItems * $realPageNumber;
|
||||
$end = (int) min( ($init + $amountOfItems - 1), $total );
|
||||
$outrange = $init<0 ? true : $init>$end;
|
||||
|
||||
@ -62,6 +65,8 @@ class dbList extends dbJSON
|
||||
|
||||
$this->db[$key]['name'] = $name;
|
||||
$this->db[$key]['list'] = array();
|
||||
|
||||
$this->sortAlphanumeric();
|
||||
$this->save();
|
||||
|
||||
return $key;
|
||||
@ -90,10 +95,18 @@ class dbList extends dbJSON
|
||||
unset( $this->db[$oldKey] );
|
||||
}
|
||||
|
||||
$this->sortAlphanumeric();
|
||||
$this->save();
|
||||
return $newKey;
|
||||
}
|
||||
|
||||
// Sort the categories by "Natural order"
|
||||
private function sortAlphanumeric()
|
||||
{
|
||||
// Sort key alphanumeric strings, a01, a10, b10, c02
|
||||
return ksort($this->db);
|
||||
}
|
||||
|
||||
// Returns the name associated to the key, FALSE if the key doesn't exist
|
||||
public function getName($key)
|
||||
{
|
||||
@ -105,18 +118,13 @@ class dbList extends dbJSON
|
||||
}
|
||||
|
||||
// Returns an array with key=>name of the list
|
||||
public function getKeyNameArray($sortAlphanumeric=true)
|
||||
public function getKeyNameArray()
|
||||
{
|
||||
$tmp = array();
|
||||
foreach($this->db as $key=>$fields) {
|
||||
$tmp[$key] = $fields['name'];
|
||||
}
|
||||
|
||||
// Sort alphanumeric strings, a01, a10, a11, a20
|
||||
if($sortAlphanumeric) {
|
||||
natcasesort($tmp);
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
|
@ -2,25 +2,34 @@
|
||||
|
||||
class Plugin {
|
||||
|
||||
// (string) Plugin's directory name
|
||||
// (string) directory name, just the name
|
||||
// Ex: sitemap
|
||||
public $directoryName;
|
||||
|
||||
// (string) Database path and filename
|
||||
// (string) Absoulute database filename and path
|
||||
// Ex: /www/bludit/bl-content/plugins/sitemap/db.php
|
||||
public $filenameDb;
|
||||
|
||||
// (string) Absoulute metadata filename and path
|
||||
// Ex: /www/bludit/bl-plugins/sitemap/metadata.json
|
||||
public $filenameMetadata;
|
||||
|
||||
// (array) Plugin metadata
|
||||
// Ex: array('author'=>'',...., 'notes'=>'')
|
||||
public $metadata;
|
||||
|
||||
// (string) Class name
|
||||
// Ex: pluginSitemap
|
||||
public $className;
|
||||
|
||||
// (array) Database unserialized
|
||||
public $db;
|
||||
|
||||
// (array) Database fields, only for initialize.
|
||||
// (array) Database fields, only for initialize
|
||||
public $dbFields;
|
||||
|
||||
// (string) Plugin's class name.
|
||||
public $className;
|
||||
|
||||
// (array) Plugin's information.
|
||||
public $metadata;
|
||||
// (boolean) Enable or disable default Save and Cancel button on plugin settings
|
||||
public $formButtons;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
@ -34,10 +43,12 @@ class Plugin {
|
||||
// Class Name
|
||||
$this->className = $reflector->getName();
|
||||
|
||||
// Initialize dbFields from the children.
|
||||
$this->formButtons = true;
|
||||
|
||||
// Call the method init() from the children
|
||||
$this->init();
|
||||
|
||||
// Init empty database
|
||||
// Init empty database with default values
|
||||
$this->db = $this->dbFields;
|
||||
|
||||
$this->filenameDb = PATH_PLUGINS_DATABASES.$this->directoryName.DS.'db.php';
|
||||
@ -47,14 +58,37 @@ class Plugin {
|
||||
$metadataString = file_get_contents($this->filenameMetadata);
|
||||
$this->metadata = json_decode($metadataString, true);
|
||||
|
||||
// If the plugin is installed then get the database.
|
||||
if($this->installed())
|
||||
{
|
||||
// If the plugin is installed then get the database
|
||||
if($this->installed()) {
|
||||
$Tmp = new dbJSON($this->filenameDb);
|
||||
$this->db = $Tmp->db;
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
$tmp->db = $this->db;
|
||||
$tmp->save();
|
||||
}
|
||||
|
||||
public function htmlPath()
|
||||
{
|
||||
return HTML_PATH_PLUGINS.$this->directoryName.'/';
|
||||
@ -70,22 +104,41 @@ class Plugin {
|
||||
return PATH_PLUGINS_DATABASES.$this->directoryName.DS;
|
||||
}
|
||||
|
||||
// Returns the item from plugin-data.
|
||||
// Returns the value of the key from the metadata of the plugin, FALSE if the key doen't exit
|
||||
public function getMetadata($key)
|
||||
{
|
||||
if(isset($this->metadata[$key])) {
|
||||
return $this->metadata[$key];
|
||||
}
|
||||
|
||||
return '';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set a key / value on the metadata of the plugin
|
||||
public function setMetadata($key, $value)
|
||||
{
|
||||
$this->metadata[$key] = $value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns the value of the field from the database
|
||||
// (string) $field
|
||||
// (boolean) $html, TRUE returns the value sanitized, FALSE unsanitized
|
||||
public function getValue($field, $html=true)
|
||||
{
|
||||
if( isset($this->db[$field]) ) {
|
||||
if($html) {
|
||||
return $this->db[$field];
|
||||
}
|
||||
else {
|
||||
return Sanitize::htmlDecode($this->db[$field]);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// DEPRECATED
|
||||
// 2017-06-16
|
||||
public function getDbField($key, $html=true)
|
||||
{
|
||||
if(isset($this->db[$key])) {
|
||||
@ -103,33 +156,6 @@ class Plugin {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function setDb($args)
|
||||
{
|
||||
$tmp = $this->db;
|
||||
|
||||
foreach($this->dbFields as $key=>$value)
|
||||
{
|
||||
if(isset($args[$key]))
|
||||
{
|
||||
// Sanitize value
|
||||
$tmpValue = Sanitize::html( $args[$key] );
|
||||
|
||||
// Set type
|
||||
settype($tmpValue, gettype($value));
|
||||
|
||||
// Set value
|
||||
$tmp[$key] = $tmpValue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db = $tmp;
|
||||
|
||||
// Save db on file
|
||||
$Tmp = new dbJSON($this->filenameDb);
|
||||
$Tmp->db = $tmp;
|
||||
$Tmp->save();
|
||||
}
|
||||
|
||||
public function name()
|
||||
{
|
||||
return $this->getMetadata('name');
|
||||
@ -170,11 +196,22 @@ class Plugin {
|
||||
return $this->className;
|
||||
}
|
||||
|
||||
public function formButtons()
|
||||
{
|
||||
return $this->formButtons;
|
||||
}
|
||||
|
||||
public function isCompatible()
|
||||
{
|
||||
$explode = explode(',', $this->getMetadata('compatible'));
|
||||
|
||||
return in_array(BLUDIT_VERSION, $explode);
|
||||
$bluditRoot = explode('.', BLUDIT_VERSION);
|
||||
$compatible = explode(',', $this->getMetadata('compatible'));
|
||||
foreach( $compatible as $version ) {
|
||||
$root = explode('.', $version);
|
||||
if( $root[0]==$bluditRoot[0] && $root[1]==$bluditRoot[1] ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function directoryName()
|
||||
@ -201,14 +238,8 @@ class Plugin {
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
// Delete all files.
|
||||
$files = Filesystem::listFiles( $this->phpPathDB() );
|
||||
foreach($files as $file) {
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
// Delete the directory.
|
||||
rmdir(PATH_PLUGINS_DATABASES.$this->directoryName);
|
||||
$path = PATH_PLUGINS_DATABASES.$this->directoryName;
|
||||
return Filesystem::deleteRecursive($path);
|
||||
}
|
||||
|
||||
public function installed()
|
||||
@ -216,10 +247,57 @@ class Plugin {
|
||||
return file_exists($this->filenameDb);
|
||||
}
|
||||
|
||||
public function workspace()
|
||||
{
|
||||
return PATH_PLUGINS_DATABASES.$this->directoryName.DS;
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
// This method is used on childre classes.
|
||||
// The user can define your own dbFields.
|
||||
// The user can define his own field of the database
|
||||
}
|
||||
|
||||
public function post()
|
||||
{
|
||||
$args = $_POST;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
// Returns the parameters after the URI, FALSE if the URI doesn't match with the webhook
|
||||
// Example: https://www.mybludit.com/api/foo/bar
|
||||
public function webhook($URI=false, $returnsAfterURI=false)
|
||||
{
|
||||
global $Url;
|
||||
|
||||
if(empty($URI)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check URI start with the webhook
|
||||
$startString = HTML_PATH_ROOT.$URI;
|
||||
$URI = $Url->uri();
|
||||
$length = mb_strlen($startString, CHARSET);
|
||||
if( mb_substr($URI, 0, $length)!=$startString ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($returnsAfterURI) {
|
||||
return mb_substr($URI, $length);
|
||||
}
|
||||
|
||||
Log::set(__METHOD__.LOG_SEP.'Webhook requested.');
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -13,59 +13,6 @@ if($Login->role()!=='admin') {
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function addUser($args)
|
||||
{
|
||||
global $dbUsers;
|
||||
global $Language;
|
||||
|
||||
// Check empty username
|
||||
if( Text::isEmpty($args['new_username']) )
|
||||
{
|
||||
Alert::set($Language->g('username-field-is-empty'), ALERT_STATUS_FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check already exist username
|
||||
if( $dbUsers->userExists($args['new_username']) )
|
||||
{
|
||||
Alert::set($Language->g('username-already-exists'), ALERT_STATUS_FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Password length
|
||||
if( strlen($args['new_password']) < 6 )
|
||||
{
|
||||
Alert::set($Language->g('Password must be at least 6 characters long'), ALERT_STATUS_FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check new password and confirm password are equal
|
||||
if( $args['new_password'] != $args['confirm_password'] )
|
||||
{
|
||||
Alert::set($Language->g('The password and confirmation password do not match'), ALERT_STATUS_FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filter form fields
|
||||
$tmp = array();
|
||||
$tmp['username'] = $args['new_username'];
|
||||
$tmp['password'] = $args['new_password'];
|
||||
$tmp['role'] = $args['role'];
|
||||
$tmp['email'] = $args['email'];
|
||||
|
||||
// Add the user to the database
|
||||
if( $dbUsers->add($tmp) )
|
||||
{
|
||||
Alert::set($Language->g('user-has-been-added-successfully'), ALERT_STATUS_OK);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the account.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main before POST
|
||||
// ============================================================================
|
||||
@ -76,8 +23,8 @@ function addUser($args)
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
if( addUser($_POST) ) {
|
||||
Redirect::page('admin', 'users');
|
||||
if( createUser($_POST) ) {
|
||||
Redirect::page('users');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
Redirect::page('dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -16,24 +16,20 @@ if($Login->role()!=='admin') {
|
||||
// ============================================================================
|
||||
// Main before POST
|
||||
// ============================================================================
|
||||
$_Plugin = false;
|
||||
$plugin = false;
|
||||
$pluginClassName = $layout['parameters'];
|
||||
|
||||
foreach($plugins['all'] as $P)
|
||||
{
|
||||
if($P->className()==$pluginClassName) {
|
||||
$_Plugin = $P;
|
||||
}
|
||||
// Check if the plugin exists
|
||||
if( isset($plugins['all'][$pluginClassName]) ) {
|
||||
$plugin = $plugins['all'][$pluginClassName];
|
||||
}
|
||||
|
||||
// Check if the plugin exists.
|
||||
if($_Plugin===false) {
|
||||
Redirect::page('admin', 'plugins');
|
||||
else {
|
||||
Redirect::page('plugins');
|
||||
}
|
||||
|
||||
// Check if the plugin has the method form()
|
||||
if(!method_exists($_Plugin, 'form')) {
|
||||
Redirect::page('admin', 'plugins');
|
||||
if( !method_exists($plugin, 'form') ) {
|
||||
Redirect::page('plugins');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -42,11 +38,22 @@ if(!method_exists($_Plugin, 'form')) {
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
$_Plugin->setDb($_POST);
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'plugin-configured',
|
||||
'notes'=>$plugin->name()
|
||||
));
|
||||
|
||||
Theme::plugins('afterFormSave');
|
||||
|
||||
Alert::set($Language->g('the-changes-have-been-saved'));
|
||||
// Call the method post of the plugin
|
||||
if( $plugin->post() ) {
|
||||
// Create an alert
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
Redirect::page('configure-plugin/'.$plugin->className());
|
||||
}
|
||||
else {
|
||||
// Create an alert
|
||||
Alert::set( $Language->g('Complete all fields') );
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -7,35 +7,33 @@
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
function addPost($args)
|
||||
{
|
||||
global $dbPosts;
|
||||
global $Language;
|
||||
|
||||
// Add the page, if the $key is FALSE the creation of the post failure.
|
||||
$key = $dbPosts->add($args);
|
||||
function printTable($title, $array) {
|
||||
echo '<h2>'.$title.'</h2>';
|
||||
echo '
|
||||
<table class="uk-table uk-table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="uk-width-1-5"></th>
|
||||
<th class="uk-width-3-5"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
|
||||
if($key) {
|
||||
// Reindex tags, this function is in 70.posts.php
|
||||
reIndexTagsPosts();
|
||||
|
||||
// Re index categories
|
||||
//reIndexCategoriesPosts();
|
||||
|
||||
// Call the plugins after post creation
|
||||
Theme::plugins('afterPostCreate');
|
||||
|
||||
// Alert for the user
|
||||
Alert::set($Language->g('Post added successfully'));
|
||||
Redirect::page('admin', 'manage-posts');
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the post.');
|
||||
Log::set(__METHOD__.LOG_SEP.'Cleaning database...');
|
||||
$dbPosts->delete($key);
|
||||
foreach($array as $key=>$value) {
|
||||
if($value===false) { $value = 'false'; }
|
||||
elseif($value===true) { $value = 'true'; }
|
||||
echo '<tr>';
|
||||
echo '<td>'.$key.'</td>';
|
||||
echo '<td>'.Sanitize::html($value).'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
return false;
|
||||
echo '
|
||||
</tbody>
|
||||
</table>
|
||||
';
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -46,11 +44,6 @@ function addPost($args)
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
addPost($_POST);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
@ -32,6 +32,12 @@ function edit($oldCategoryKey, $newCategory)
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
}
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'category-edited',
|
||||
'notes'=>$newCategory
|
||||
));
|
||||
|
||||
Redirect::page('categories');
|
||||
}
|
||||
|
||||
@ -40,9 +46,19 @@ function delete($categoryKey)
|
||||
global $Language;
|
||||
global $dbCategories;
|
||||
|
||||
// Remove the category by key
|
||||
$dbCategories->remove($categoryKey);
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'category-deleted',
|
||||
'notes'=>$categoryKey
|
||||
));
|
||||
|
||||
// Create an alert
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
|
||||
// Redirect
|
||||
Redirect::page('categories');
|
||||
}
|
||||
|
||||
|
@ -8,57 +8,6 @@
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function editPage($args)
|
||||
{
|
||||
global $dbPages;
|
||||
global $Language;
|
||||
|
||||
if(!isset($args['parent'])) {
|
||||
$args['parent'] = NO_PARENT_CHAR;
|
||||
}
|
||||
|
||||
// Add the page, if the $key is FALSE the creation of the post failure.
|
||||
$key = $dbPages->edit($args);
|
||||
|
||||
if($key)
|
||||
{
|
||||
$dbPages->regenerateCli();
|
||||
|
||||
// Re index categories
|
||||
//reIndexCategoriesPages();
|
||||
|
||||
// Call the plugins after page created.
|
||||
Theme::plugins('afterPageModify');
|
||||
|
||||
// Alert the user
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
Redirect::page('admin', 'edit-page/'.$args['slug']);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the page.');
|
||||
}
|
||||
}
|
||||
|
||||
function deletePage($key)
|
||||
{
|
||||
global $dbPages;
|
||||
global $Language;
|
||||
|
||||
if( $dbPages->delete($key) )
|
||||
{
|
||||
// Call the plugins after post created.
|
||||
Theme::plugins('afterPageDelete');
|
||||
|
||||
Alert::set($Language->g('The page has been deleted successfully'));
|
||||
Redirect::page('admin', 'manage-pages');
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the page.');
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main before POST
|
||||
// ============================================================================
|
||||
@ -70,11 +19,20 @@ function deletePage($key)
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
if( isset($_POST['delete-page']) ) {
|
||||
deletePage($_POST['key']);
|
||||
if( deletePage($_POST['key']) ) {
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
Redirect::page('pages');
|
||||
}
|
||||
}
|
||||
else {
|
||||
editPage($_POST);
|
||||
$key = editPage($_POST);
|
||||
if( $key!==false ) {
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
Redirect::page('edit-page/'.$key);
|
||||
}
|
||||
}
|
||||
|
||||
Redirect::page('pages');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -86,4 +44,6 @@ if( !$dbPages->exists($layout['parameters']) ) {
|
||||
Redirect::page('pages');
|
||||
}
|
||||
|
||||
$page = $pagesKey[$layout['parameters']];
|
||||
$page = $pagesByKey[$layout['parameters']];
|
||||
|
||||
$layout['title'] .= ' - '.$Language->g('Edit Content');
|
@ -1,94 +0,0 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Check role
|
||||
// ============================================================================
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function editPost($args)
|
||||
{
|
||||
global $dbPosts;
|
||||
global $Language;
|
||||
|
||||
// Add the page, if the $key is FALSE the creation of the post failure.
|
||||
$key = $dbPosts->edit($args);
|
||||
|
||||
if($key)
|
||||
{
|
||||
// Reindex tags, this function is in 70.posts.php
|
||||
reIndexTagsPosts();
|
||||
|
||||
// Re index categories
|
||||
//reIndexCategoriesPosts();
|
||||
|
||||
// Call the plugins after post created.
|
||||
Theme::plugins('afterPostModify');
|
||||
|
||||
// Alert the user
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
Redirect::page('admin', 'edit-post/'.$args['slug']);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the post.');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function deletePost($key)
|
||||
{
|
||||
global $dbPosts;
|
||||
global $Language;
|
||||
|
||||
if( $dbPosts->delete($key) )
|
||||
{
|
||||
// Reindex tags, this function is in 70.posts.php
|
||||
reIndexTagsPosts();
|
||||
|
||||
// Call the plugins after post created.
|
||||
Theme::plugins('afterPostDelete');
|
||||
|
||||
Alert::set($Language->g('The post has been deleted successfully'));
|
||||
Redirect::page('admin', 'manage-posts');
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the post.');
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main before POST
|
||||
// ============================================================================
|
||||
|
||||
// ============================================================================
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
if( isset($_POST['delete-post']) ) {
|
||||
deletePost($_POST['key']);
|
||||
}
|
||||
else {
|
||||
editPost($_POST);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
||||
|
||||
if(!$dbPosts->postExists($layout['parameters']))
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the post: '.$layout['parameters']);
|
||||
Redirect::page('admin', 'manage-posts');
|
||||
}
|
||||
|
||||
$_Post = buildPost($layout['parameters']);
|
||||
|
||||
$layout['title'] .= ' - '.$Language->g('Edit post').' - '.$_Post->title();
|
@ -4,70 +4,6 @@
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function disableUser($username) {
|
||||
|
||||
global $dbUsers;
|
||||
global $Language;
|
||||
global $Login;
|
||||
|
||||
// The editors can't disable users
|
||||
if($Login->role()!=='admin') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( $dbUsers->disableUser($username) ) {
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the user.');
|
||||
}
|
||||
}
|
||||
|
||||
function editUser($args)
|
||||
{
|
||||
global $dbUsers;
|
||||
global $Language;
|
||||
|
||||
if( $dbUsers->set($args) ) {
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the user.');
|
||||
}
|
||||
}
|
||||
|
||||
function deleteUser($args, $deleteContent=false)
|
||||
{
|
||||
global $dbUsers;
|
||||
global $dbPosts;
|
||||
global $Language;
|
||||
global $Login;
|
||||
|
||||
// The user admin cannot be deleted.
|
||||
if($args['username']=='admin') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The editors cannot delete users.
|
||||
if($Login->role()!=='admin') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($deleteContent) {
|
||||
$dbPosts->deletePostsByUser($args['username']);
|
||||
}
|
||||
else {
|
||||
$dbPosts->linkPostsToUser($args['username'], 'admin');
|
||||
}
|
||||
|
||||
if( $dbUsers->delete($args['username']) ) {
|
||||
Alert::set($Language->g('User deleted'));
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the user.');
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main before POST
|
||||
// ============================================================================
|
||||
@ -78,18 +14,17 @@ function deleteUser($args, $deleteContent=false)
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
// Prevent editors to administrate other users.
|
||||
if($Login->role()!=='admin')
|
||||
{
|
||||
// Prevent non-administrators to change other users
|
||||
if($Login->role()!=='admin') {
|
||||
$_POST['username'] = $Login->username();
|
||||
unset($_POST['role']);
|
||||
}
|
||||
|
||||
if(isset($_POST['delete-user-all'])) {
|
||||
deleteUser($_POST, true);
|
||||
deleteUser($_POST, $deleteContent=true);
|
||||
}
|
||||
elseif(isset($_POST['delete-user-associate'])) {
|
||||
deleteUser($_POST, false);
|
||||
deleteUser($_POST, $deleteContent=false);
|
||||
}
|
||||
elseif(isset($_POST['disable-user'])) {
|
||||
disableUser($_POST['username']);
|
||||
@ -97,19 +32,22 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
else {
|
||||
editUser($_POST);
|
||||
}
|
||||
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
||||
|
||||
// Prevent non-administrators to change other users
|
||||
if($Login->role()!=='admin') {
|
||||
$layout['parameters'] = $Login->username();
|
||||
}
|
||||
|
||||
$_User = $dbUsers->getUser($layout['parameters']);
|
||||
$User = $dbUsers->getUser($layout['parameters']);
|
||||
|
||||
// If the user doesn't exist, redirect to the users list.
|
||||
if($_User===false) {
|
||||
Redirect::page('admin', 'users');
|
||||
if($User===false) {
|
||||
Redirect::page('users');
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
Redirect::page('dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -26,11 +26,27 @@ if($Login->role()!=='admin') {
|
||||
// ============================================================================
|
||||
$pluginClassName = $layout['parameters'];
|
||||
|
||||
foreach($plugins['all'] as $P)
|
||||
{
|
||||
if($P->className()==$pluginClassName) {
|
||||
$P->install();
|
||||
// Check if the plugin exists
|
||||
if( isset($plugins['all'][$pluginClassName]) ) {
|
||||
$plugin = $plugins['all'][$pluginClassName];
|
||||
|
||||
// Plugins for Bludit PRO
|
||||
$blackList = array('pluginTimeMachine', 'pluginRemoteContent');
|
||||
if( in_array($pluginClassName, $blackList) && !defined('BLUDIT_PRO') ) {
|
||||
Redirect::page('plugins');
|
||||
}
|
||||
|
||||
// Install plugin
|
||||
if( $plugin->install() ) {
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'plugin-installed',
|
||||
'notes'=>$plugin->name()
|
||||
));
|
||||
|
||||
// Create an alert
|
||||
Alert::set($Language->g('Plugin installed'));
|
||||
}
|
||||
}
|
||||
|
||||
Redirect::page('admin', 'plugins');
|
||||
Redirect::page('plugins');
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
Redirect::page('dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -26,14 +26,19 @@ if($Login->role()!=='admin') {
|
||||
// ============================================================================
|
||||
$themeDirname = $layout['parameters'];
|
||||
|
||||
if( Sanitize::pathFile(PATH_THEMES.$themeDirname) )
|
||||
{
|
||||
if( Sanitize::pathFile(PATH_THEMES.$themeDirname) ) {
|
||||
// Set the theme
|
||||
$Site->set(array('theme'=>$themeDirname));
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to install the theme: '.$themeDirname);
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'new-theme-configured',
|
||||
'notes'=>$themeDirname
|
||||
));
|
||||
|
||||
// Create an alert
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
}
|
||||
|
||||
Redirect::page('admin', 'themes');
|
||||
// Redirect
|
||||
Redirect::page('themes');
|
||||
|
@ -30,7 +30,7 @@ function checkPost($args)
|
||||
if($username!=false)
|
||||
{
|
||||
// Generate the token and the token expiration date.
|
||||
$token = $dbUsers->generateTokenEmail($username);
|
||||
$token = $dbUsers->setTokenEmail($username);
|
||||
|
||||
// ---- EMAIL ----
|
||||
$link = $Site->url().'admin/login-email?tokenEmail='.$token.'&username='.$username;
|
||||
|
@ -20,17 +20,17 @@ function checkPost($args)
|
||||
}
|
||||
|
||||
// Verify User sanitize the input
|
||||
if( $Login->verifyUser($_POST['username'], $_POST['password']) )
|
||||
{
|
||||
if( $Login->verifyUser($_POST['username'], $_POST['password']) ) {
|
||||
// Renew the token. This token will be the same inside the session for multiple forms.
|
||||
$Security->generateTokenCSRF();
|
||||
|
||||
Redirect::page('admin', 'dashboard');
|
||||
Redirect::page('dashboard');
|
||||
return true;
|
||||
}
|
||||
|
||||
// Bruteforce protection, add IP to blacklist.
|
||||
$Security->addLoginFail();
|
||||
|
||||
// Create alert
|
||||
Alert::set($Language->g('Username or password incorrect'));
|
||||
|
||||
return false;
|
||||
|
@ -17,6 +17,7 @@ function add($category)
|
||||
{
|
||||
global $dbCategories;
|
||||
global $Language;
|
||||
global $Syslog;
|
||||
|
||||
if( Text::isEmpty($category) ) {
|
||||
Alert::set($Language->g('Category name is empty'), ALERT_STATUS_FAIL);
|
||||
@ -24,8 +25,17 @@ function add($category)
|
||||
}
|
||||
|
||||
if( $dbCategories->add($category) ) {
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'new-category-created',
|
||||
'notes'=>$category
|
||||
));
|
||||
|
||||
// Create an alert
|
||||
Alert::set($Language->g('Category added'), ALERT_STATUS_OK);
|
||||
return true;
|
||||
|
||||
// Redirect
|
||||
Redirect::page('categories');
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the category.');
|
||||
@ -43,9 +53,7 @@ function add($category)
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
if( add($_POST['category']) ) {
|
||||
Redirect::page('categories');
|
||||
}
|
||||
add($_POST['category']);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -8,48 +8,6 @@
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function addPage($args)
|
||||
{
|
||||
global $dbPages;
|
||||
global $Language;
|
||||
global $Syslog;
|
||||
|
||||
// Add the page, if the $key is FALSE the creation of the post failure.
|
||||
$key = $dbPages->add($args);
|
||||
|
||||
if($key) {
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Call the plugins after page created
|
||||
Theme::plugins('afterPageCreate');
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'new-page-created',
|
||||
'notes'=>$args['title']
|
||||
));
|
||||
|
||||
// Create an alert
|
||||
Alert::set( $Language->g('Page added successfully') );
|
||||
|
||||
// Redirect
|
||||
Redirect::page('pages');
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the page');
|
||||
Log::set(__METHOD__.LOG_SEP.'Cleaning database...');
|
||||
$dbPages->delete($key);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main before POST
|
||||
// ============================================================================
|
||||
@ -60,7 +18,11 @@ function addPage($args)
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
addPage($_POST);
|
||||
if( createPage($_POST)!==false ) {
|
||||
Alert::set( $Language->g('Page added successfully') );
|
||||
}
|
||||
|
||||
Redirect::page('pages');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
Redirect::page('dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -17,26 +17,53 @@ function setSettings($args)
|
||||
{
|
||||
global $Site;
|
||||
global $Language;
|
||||
global $Syslog;
|
||||
global $dbPages;
|
||||
|
||||
// Add slash at the begin and end.
|
||||
// This fields are in the settings->advanced mode
|
||||
$args['url'] = Text::addSlashes($args['url'],false,true);
|
||||
// Add slash at the begin and end
|
||||
$args['uriPage'] = Text::addSlashes($args['uriPage']);
|
||||
$args['uriTag'] = Text::addSlashes($args['uriTag']);
|
||||
$args['uriCategory'] = Text::addSlashes($args['uriCategory']);
|
||||
|
||||
if(($args['uriPost']==$args['uriPage']) || ($args['uriPost']==$args['uriTag']) || ($args['uriPage']==$args['uriTag']) )
|
||||
{
|
||||
if( ($args['uriPage']==$args['uriTag']) ||
|
||||
($args['uriPage']==$args['uriCategory']) ||
|
||||
($args['uriTag']==$args['uriCategory'])
|
||||
) {
|
||||
$args = array();
|
||||
}
|
||||
|
||||
if( $Site->set($args) ) {
|
||||
Alert::set($Language->g('the-changes-have-been-saved'));
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the settings.');
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'changes-on-settings',
|
||||
'notes'=>''
|
||||
));
|
||||
|
||||
// Check actual order by, if different than the new settings sort pages
|
||||
if( $Site->orderBy()!=ORDER_BY ) {
|
||||
if( $Site->orderBy()=='date' ) {
|
||||
$dbPages->sortByDate();
|
||||
}
|
||||
else {
|
||||
$dbPages->sortByPosition();
|
||||
}
|
||||
|
||||
// Save database state
|
||||
$dbPages->save();
|
||||
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
}
|
||||
|
||||
// Create an alert
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
}
|
||||
|
||||
// Redirect
|
||||
Redirect::page('settings-advanced');
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -51,7 +78,6 @@ function setSettings($args)
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
setSettings($_POST);
|
||||
Redirect::page('admin', $layout['controller']);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -46,9 +46,6 @@ function setSettings($args)
|
||||
// Redirect
|
||||
Redirect::page('settings-general');
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the settings.');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -18,25 +18,18 @@ function setSettings($args)
|
||||
global $Site;
|
||||
global $Language;
|
||||
|
||||
// Add slash at the begin and end.
|
||||
// This fields are in the settings->advanced mode
|
||||
if(isset($args['form-advanced'])) {
|
||||
$args['url'] = Text::addSlashes($args['url'],false,true);
|
||||
$args['uriPost'] = Text::addSlashes($args['uriPost']);
|
||||
$args['uriPage'] = Text::addSlashes($args['uriPage']);
|
||||
$args['uriTag'] = Text::addSlashes($args['uriTag']);
|
||||
|
||||
if(($args['uriPost']==$args['uriPage']) || ($args['uriPost']==$args['uriTag']) || ($args['uriPage']==$args['uriTag']) )
|
||||
{
|
||||
$args = array();
|
||||
}
|
||||
}
|
||||
|
||||
if( $Site->set($args) ) {
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'changes-on-settings',
|
||||
'notes'=>''
|
||||
));
|
||||
|
||||
// Create alert
|
||||
Alert::set($Language->g('the-changes-have-been-saved'));
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the settings.');
|
||||
|
||||
// Redirect
|
||||
Redirect::page('settings-regional');
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -53,7 +46,6 @@ function setSettings($args)
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
setSettings($_POST);
|
||||
Redirect::page('admin', $layout['controller']);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -1,80 +0,0 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Check role
|
||||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function setSettings($args)
|
||||
{
|
||||
global $Site;
|
||||
global $Language;
|
||||
|
||||
// Add slash at the begin and end.
|
||||
// This fields are in the settings->advanced mode
|
||||
if(isset($args['form-advanced'])) {
|
||||
$args['url'] = Text::addSlashes($args['url'],false,true);
|
||||
$args['uriPost'] = Text::addSlashes($args['uriPost']);
|
||||
$args['uriPage'] = Text::addSlashes($args['uriPage']);
|
||||
$args['uriTag'] = Text::addSlashes($args['uriTag']);
|
||||
|
||||
if(($args['uriPost']==$args['uriPage']) || ($args['uriPost']==$args['uriTag']) || ($args['uriPage']==$args['uriTag']) )
|
||||
{
|
||||
$args = array();
|
||||
}
|
||||
}
|
||||
|
||||
if( $Site->set($args) ) {
|
||||
Alert::set($Language->g('the-changes-have-been-saved'));
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the settings.');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
||||
|
||||
// ============================================================================
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
setSettings($_POST);
|
||||
Redirect::page('admin', $layout['controller']);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
||||
|
||||
// Default home page
|
||||
$_homePageList = array(''=>$Language->g('Show blog'));
|
||||
foreach($pagesParents as $parentKey=>$pageList)
|
||||
{
|
||||
foreach($pageList as $Page)
|
||||
{
|
||||
if($parentKey!==NO_PARENT_CHAR) {
|
||||
$parentTitle = $pages[$Page->parentKey()]->title().'->';
|
||||
}
|
||||
else {
|
||||
$parentTitle = '';
|
||||
}
|
||||
|
||||
if($Page->published()) {
|
||||
$_homePageList[$Page->key()] = $Language->g('Page').': '.$parentTitle.$Page->title();
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
Redirect::page('dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
Redirect::page('dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -29,4 +29,4 @@ $pluginClassName = $layout['parameters'];
|
||||
$Plugin = new $pluginClassName;
|
||||
$Plugin->uninstall();
|
||||
|
||||
Redirect::page('admin', 'plugins');
|
||||
Redirect::page('plugins');
|
||||
|
@ -8,6 +8,7 @@ function setPassword($username, $new_password, $confirm_password)
|
||||
{
|
||||
global $dbUsers;
|
||||
global $Language;
|
||||
global $Syslog;
|
||||
|
||||
// Password length
|
||||
if( strlen($new_password) < 6 )
|
||||
@ -20,6 +21,11 @@ function setPassword($username, $new_password, $confirm_password)
|
||||
{
|
||||
if( $dbUsers->setPassword($username, $new_password) ) {
|
||||
Alert::set($Language->g('The changes have been saved'), ALERT_STATUS_OK);
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'user-password-changed',
|
||||
'notes'=>$username
|
||||
));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -51,7 +57,7 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
}
|
||||
|
||||
if( setPassword($_POST['username'], $_POST['new_password'], $_POST['confirm_password']) ) {
|
||||
Redirect::page('admin', 'users');
|
||||
Redirect::page('users');
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +73,7 @@ $_user = $dbUsers->getDb($layout['parameters']);
|
||||
|
||||
// If the user doesn't exist, redirect to the users list.
|
||||
if($_user===false) {
|
||||
Redirect::page('admin', 'users');
|
||||
Redirect::page('users');
|
||||
}
|
||||
|
||||
$_user['username'] = $layout['parameters'];
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||
Redirect::page('admin', 'dashboard');
|
||||
Redirect::page('dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -11,6 +11,9 @@
|
||||
}
|
||||
|
||||
.label-draft,
|
||||
.label-fixed,
|
||||
.label-sticky,
|
||||
.label-scheduled,
|
||||
.label-empty-title,
|
||||
.label-time {
|
||||
background: #A979D1 none repeat scroll 0 0;
|
||||
@ -24,6 +27,14 @@
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.label-fixed {
|
||||
background: #7BD179;
|
||||
}
|
||||
|
||||
.label-scheduled {
|
||||
background: #7BD179;
|
||||
}
|
||||
|
||||
.label-empty-title {
|
||||
background: #53D192;
|
||||
}
|
||||
@ -87,14 +98,20 @@ body {
|
||||
max-width: 1800px;
|
||||
}
|
||||
|
||||
#bl-navbar img.logo {
|
||||
height: 25px;
|
||||
margin-bottom: 8px;
|
||||
margin-left: 22px;
|
||||
margin-right: 0px;
|
||||
}
|
||||
|
||||
#bl-navbar a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#bl-navbar a.bl-brand {
|
||||
font-size: 20px;
|
||||
line-height: 60px;
|
||||
margin: 0 0 0 35px;
|
||||
#bl-navbar span.bl-brand {
|
||||
font-size: 15px;
|
||||
line-height: 35px;
|
||||
text-transform: uppercase;
|
||||
color: #fff;
|
||||
}
|
||||
@ -105,7 +122,7 @@ body {
|
||||
|
||||
#bl-navbar .bl-navbar-right {
|
||||
float: right;
|
||||
line-height: 60px;
|
||||
line-height: 35px;
|
||||
margin: 0 35px 0 0;
|
||||
}
|
||||
|
||||
@ -196,6 +213,10 @@ div.dashboard-links h4 {
|
||||
margin-bottom: -8px !important;
|
||||
}
|
||||
|
||||
#dashboard-panel .notification-date {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
|
||||
/* FORM
|
||||
---------------------------------------------------------------- */
|
||||
@ -622,82 +643,98 @@ div.plugin-links > span.separator {
|
||||
list-style-type: none;
|
||||
margin: 15px 0;
|
||||
padding: 0;
|
||||
font-size: 0.9em;
|
||||
font-size: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#paginator li.next {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
#paginator li.previous {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
#paginator a {
|
||||
color: #2672ec;
|
||||
}
|
||||
|
||||
#paginator li {
|
||||
display: inline;
|
||||
float: none !important;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
#paginator li.left {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
#paginator li.list {
|
||||
background: #e0e0e0;
|
||||
color: #747474;
|
||||
padding: 2px 11px;
|
||||
margin: 0px 15px;
|
||||
}
|
||||
|
||||
#paginator li.right {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
#paginator li.next {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
#paginator li.previous {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
/* ----------- PLUGINS FORM ----------- */
|
||||
|
||||
#jsformplugin div {
|
||||
margin-bottom: 1.1em;
|
||||
margin-bottom: 15px;
|
||||
display: table;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#jsformplugin label {
|
||||
margin: 0 0 5px 0 !important;
|
||||
#jsformplugin button[type=submit] {
|
||||
margin-left: 200px;
|
||||
border-radius: 2px;
|
||||
padding: 1px 20px;
|
||||
border: 0;
|
||||
box-shadow: inset 0 0 5px rgba(0,0,0,.05);
|
||||
text-shadow: 0 -1px 0 rgba(0,0,0,.1);
|
||||
line-height: 28px;
|
||||
min-height: 30px;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#jsformplugin button[type=submit].blue {
|
||||
background: #007add !important;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#jsformplugin button[type=submit].small {
|
||||
font-size: 0.9em;
|
||||
min-height: 20px;
|
||||
}
|
||||
|
||||
#jsformplugin > div > label,
|
||||
#jsformplugin > div > input[type=text],
|
||||
#jsformplugin > div > input[type=checkbox],
|
||||
#jsformplugin > div > textarea,
|
||||
#jsformplugin > div > select {
|
||||
display: table-cell;
|
||||
}
|
||||
|
||||
#jsformplugin > div > span.tip {
|
||||
color: #999;
|
||||
margin-top: 5px;
|
||||
font-size: 0.9em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#jsformplugin div.tip {
|
||||
font-size: 0.9em;
|
||||
color: #AAAAAA;
|
||||
#jsformplugin > div > label {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
#jsformplugin textarea {
|
||||
min-width: 400px;
|
||||
width: 60%;
|
||||
#jsformplugin > div > textarea,
|
||||
#jsformplugin > div > input[type=text] {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
#jsformplugin > div > select {
|
||||
width: 35%;
|
||||
}
|
||||
|
||||
#jsformplugin > div > textarea {
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
#jsformplugin input[type=text] {
|
||||
min-width: 400px;
|
||||
width: 60%;
|
||||
height: 37px;
|
||||
}
|
||||
@media (max-width: 960px) {
|
||||
|
||||
#jsformplugin input[type="checkbox"] {
|
||||
vertical-align: middle;
|
||||
margin-left: 0px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
#jsformplugin div {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#jsformplugin label.forCheckbox {
|
||||
margin-left: 3px;
|
||||
margin-bottom: 0px !important;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#jsformplugin p {
|
||||
margin-bottom: 0;
|
||||
#jsformplugin button[type=submit] {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
2
bl-kernel/admin/themes/default/css/uikit/form-file.almost-flat.min.css
vendored
Normal file → Executable file
2
bl-kernel/admin/themes/default/css/uikit/form-file.almost-flat.min.css
vendored
Normal file → Executable file
@ -1,2 +1,2 @@
|
||||
/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
.uk-form-file{display:inline-block;vertical-align:middle;position:relative;overflow:hidden}.uk-form-file input[type=file]{position:absolute;top:0;z-index:1;width:100%;opacity:0;cursor:pointer;left:0;font-size:500px}
|
2
bl-kernel/admin/themes/default/css/uikit/placeholder.almost-flat.min.css
vendored
Normal file → Executable file
2
bl-kernel/admin/themes/default/css/uikit/placeholder.almost-flat.min.css
vendored
Normal file → Executable file
@ -1,2 +1,2 @@
|
||||
/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
.uk-placeholder{margin-bottom:15px;padding:15px;border:1px dashed #ddd;background:#fafafa;color:#444}*+.uk-placeholder{margin-top:15px}.uk-placeholder>:last-child{margin-bottom:0}.uk-placeholder-large{padding-top:80px;padding-bottom:80px}
|
2
bl-kernel/admin/themes/default/css/uikit/progress.almost-flat.min.css
vendored
Normal file → Executable file
2
bl-kernel/admin/themes/default/css/uikit/progress.almost-flat.min.css
vendored
Normal file → Executable file
@ -1,2 +1,2 @@
|
||||
/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
.uk-progress{box-sizing:border-box;height:20px;margin-bottom:15px;background:#f5f5f5;overflow:hidden;line-height:20px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.06);border-radius:4px}*+.uk-progress{margin-top:15px}.uk-progress-bar{width:0;height:100%;background:#00a8e6;float:left;-webkit-transition:width .6s ease;transition:width .6s ease;font-size:12px;color:#fff;text-align:center;box-shadow:inset 0 0 5px rgba(0,0,0,.05);text-shadow:0 -1px 0 rgba(0,0,0,.1)}.uk-progress-mini{height:6px}.uk-progress-small{height:12px}.uk-progress-success .uk-progress-bar{background-color:#8cc14c}.uk-progress-warning .uk-progress-bar{background-color:#faa732}.uk-progress-danger .uk-progress-bar{background-color:#da314b}.uk-progress-striped .uk-progress-bar{background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-size:30px 30px}.uk-progress-striped.uk-active .uk-progress-bar{-webkit-animation:uk-progress-bar-stripes 2s linear infinite;animation:uk-progress-bar-stripes 2s linear infinite}@-webkit-keyframes uk-progress-bar-stripes{0%{background-position:0 0}100%{background-position:30px 0}}@keyframes uk-progress-bar-stripes{0%{background-position:0 0}100%{background-position:30px 0}}.uk-progress-mini,.uk-progress-small{border-radius:500px}
|
4
bl-kernel/admin/themes/default/css/uikit/uikit.almost-flat.min.css
vendored
Normal file → Executable file
4
bl-kernel/admin/themes/default/css/uikit/uikit.almost-flat.min.css
vendored
Normal file → Executable file
File diff suppressed because one or more lines are too long
2
bl-kernel/admin/themes/default/css/uikit/upload.almost-flat.min.css
vendored
Normal file → Executable file
2
bl-kernel/admin/themes/default/css/uikit/upload.almost-flat.min.css
vendored
Normal file → Executable file
@ -1,2 +1,2 @@
|
||||
/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
.uk-dragover{box-shadow:0 0 20px rgba(100,100,100,.3)}
|
Binary file not shown.
Before Width: | Height: | Size: 1005 B After Width: | Height: | Size: 1.0 KiB |
13
bl-kernel/admin/themes/default/img/logo.svg
Normal file
13
bl-kernel/admin/themes/default/img/logo.svg
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<pattern id="pattern-0" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse" viewBox="0 0 100 100">
|
||||
<path d="M 0 0 L 50 0 L 50 100 L 0 100 Z" style="fill: black;"/>
|
||||
</pattern>
|
||||
</defs>
|
||||
<path style="fill: rgb(255, 255, 255); stroke: rgb(0, 0, 0); stroke-miterlimit: 4; stroke-dasharray: none; stroke-width: 24.1239;" d="M 145.686 14.63 C 141.613 8.89 130.833 68.155 113.248 128.344 C 108.415 144.89 115.288 161.582 117.782 176.059 C 121.971 183.412 126.134 194.145 129.663 207.523 C 130.852 212.029 131.89 216.619 132.816 221.212 C 123.039 245.985 117.522 274.055 117.522 303.808 C 117.522 331.213 122.224 357.181 130.601 380.471 C 146.382 392.392 161.695 409.741 174.269 431.302 C 180.153 441.39 185.014 451.718 188.888 461.98 C 209.024 476.655 232.243 485.043 256.97 485.043 C 280.324 485.043 302.327 477.571 321.665 464.381 C 325.671 453.331 330.362 441.894 337.169 431.302 C 350.642 410.34 367.256 390.2 384.224 378 C 395.979 359.286 397.512 331.335 396.418 303.808 C 395.283 275.244 391.314 248.191 382.244 224.145 C 383.028 218.304 384.004 212.46 385.214 206.717 C 388.261 192.245 392.179 180.77 396.288 173.244 C 397.911 159.088 403.396 142.737 398.19 126.913 C 377.42 63.769 380.058 117.247 374.011 122.306 C 366.364 128.705 325.935 65.939 327.529 128.344 C 327.702 135.15 328.069 141.8 328.596 148.266 C 307.662 131.942 282.324 152.098 256.136 152.098 C 229.291 152.098 205.058 132.425 183.779 149.512 C 184.059 142.203 184.108 134.65 183.911 126.913 C 182.317 64.508 171.016 50.32 145.686 14.63 Z" id="path2987"/>
|
||||
<path id="path3763" d="M 256.314 390.825 C 246.312 390.825 223.405 410.421 223.405 423.826 C 223.405 427.497 224.537 430.973 226.554 434.092 C 230.352 435.689 234.037 438.012 237.065 440.902 C 238.481 442.253 239.65 443.635 240.582 445.009 C 245.429 446.974 251.018 448.098 256.97 448.098 C 262.593 448.098 267.889 447.097 272.542 445.33 C 273.509 443.851 274.748 442.358 276.274 440.902 C 279.518 437.806 283.517 435.361 287.6 433.762 C 289.485 430.731 290.537 427.367 290.537 423.826 C 290.537 410.421 266.971 390.825 256.314 390.825 Z" style="fill: rgb(0, 0, 0); stroke: rgb(0, 0, 0); stroke-miterlimit: 4; stroke-dasharray: none; stroke-width: 24.1239;"/>
|
||||
<path style="fill: rgb(0, 0, 0); stroke: rgb(0, 0, 0); stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; stroke-dasharray: none; stroke-width: 24.1239;" d="M 228.658 314.39 C 264.037 255.967 201.722 177.034 170.636 242.749 C 156.716 272.177 189.433 341.163 228.658 314.39 Z" id="path3779"/>
|
||||
<path style="fill: rgb(0, 0, 0); stroke: rgb(0, 0, 0); stroke-miterlimit: 4; stroke-width: 18;" d="M 323.461 270.414 C 323.461 276.224 318.143 280.937 311.582 280.937 C 305.022 280.937 299.702 276.224 299.702 270.414 C 299.702 264.6 305.022 259.888 311.582 259.888 C 318.143 259.888 323.461 264.6 323.461 270.414 Z" id="path3785"/>
|
||||
<path style="stroke: rgb(0, 0, 0); stroke-miterlimit: 4; fill: rgb(255, 255, 255); stroke-width: 24.1239;" d="M 232.976 268.819 C 232.976 284.42 220.013 297.069 204.021 297.069 C 188.032 297.069 175.068 284.42 175.068 268.819 C 175.068 253.21 188.032 240.565 204.021 240.565 C 220.013 240.565 232.976 253.21 232.976 268.819 Z" id="path-1"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.2 KiB |
@ -8,7 +8,7 @@
|
||||
<title><?php echo $layout['title'] ?></title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" type="image/x-icon" href="<?php echo HTML_PATH_ADMIN_THEME.'img/favicon.png' ?>">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="<?php echo HTML_PATH_ADMIN_THEME.'img/favicon.png?version='.BLUDIT_VERSION ?>">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo HTML_PATH_ADMIN_THEME.'css/uikit/uikit.almost-flat.min.css?version='.BLUDIT_VERSION ?>">
|
||||
@ -57,16 +57,14 @@ $(document).ready(function() {
|
||||
<div class="uk-offcanvas-bar">
|
||||
<ul class="uk-nav uk-nav-offcanvas">
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'dashboard' ?>"><?php $L->p('Dashboard') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-post' ?>"><?php $L->p('New post') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New page') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-posts' ?>"><?php $L->p('Manage posts') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><?php $L->p('Manage pages') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New content') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><?php $L->p('Manage content') ?></a></li>
|
||||
<?php if($Login->role() == 'admin') { ?>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Manage categories') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>"><?php $L->p('Manage users') ?></a></li>
|
||||
<!-- <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Manage categories') ?></a></li> -->
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-general' ?>"><?php $L->p('General settings') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-advanced' ?>"><?php $L->p('Advanced settings') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-regional' ?>"><?php $L->p('Language and timezone') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-regional' ?>"><?php $L->p('Language') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins' ?>"><?php $L->p('Plugins') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'themes' ?>"><?php $L->p('Themes') ?></a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'about' ?>"><?php $L->p('About') ?></a></li>
|
||||
@ -77,7 +75,8 @@ $(document).ready(function() {
|
||||
|
||||
<div class="bl-navbar-bg">
|
||||
<nav id="bl-navbar">
|
||||
<a href="" class="bl-brand">BLUDIT</a>
|
||||
<img id="bludit-logo" class="logo" src="<?php echo HTML_PATH_ADMIN_THEME ?>img/logo.svg" />
|
||||
<span class="bl-brand">BLUDIT</span>
|
||||
|
||||
<div class="bl-navbar-right">
|
||||
<?php $L->p('Welcome') ?> <?php echo $Login->username() ?> -
|
||||
@ -103,12 +102,12 @@ $(document).ready(function() {
|
||||
|
||||
<li class="uk-nav-header"><?php $L->p('Publish') ?></li>
|
||||
<li <?php echo ($layout['view']=='new-page')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New page') ?></a>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New content') ?></a>
|
||||
</li>
|
||||
|
||||
<li class="uk-nav-header"><?php $L->p('Manage') ?></li>
|
||||
<li <?php echo ($layout['view']=='manage-pages')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'pages' ?>"><?php $L->p('Pages') ?></a>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'pages' ?>"><?php $L->p('Content') ?></a>
|
||||
</li>
|
||||
<li <?php echo ($layout['view']=='categories')?'class="uk-active"':'' ?>>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Categories') ?></a>
|
||||
@ -149,20 +148,6 @@ $(document).ready(function() {
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if( AUTO_SCROLL ) {
|
||||
?>
|
||||
<script>
|
||||
// Auto scroll
|
||||
$(document).ready(function () {
|
||||
$('html, body').animate({
|
||||
scrollTop: $('#bl-view').offset().top
|
||||
}, 'slow');
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<!-- Javascript -->
|
||||
|
6
bl-kernel/admin/themes/default/js/uikit/uikit.min.js
vendored
Normal file → Executable file
6
bl-kernel/admin/themes/default/js/uikit/uikit.min.js
vendored
Normal file → Executable file
File diff suppressed because one or more lines are too long
4
bl-kernel/admin/themes/default/js/uikit/upload.min.js
vendored
Normal file → Executable file
4
bl-kernel/admin/themes/default/js/uikit/upload.min.js
vendored
Normal file → Executable file
@ -1,2 +1,2 @@
|
||||
/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
!function(e){var t;window.UIkit&&(t=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return t||e(UIkit)})}(function(e){"use strict";function t(o,a){function r(t,n){var o=new FormData,a=new XMLHttpRequest;if(n.before(n,t)!==!1){for(var r,i=0;r=t[i];i++)o.append(n.param,r);for(var l in n.params)o.append(l,n.params[l]);a.upload.addEventListener("progress",function(e){var t=e.loaded/e.total*100;n.progress(t,e)},!1),a.addEventListener("loadstart",function(e){n.loadstart(e)},!1),a.addEventListener("load",function(e){n.load(e)},!1),a.addEventListener("loadend",function(e){n.loadend(e)},!1),a.addEventListener("error",function(e){n.error(e)},!1),a.addEventListener("abort",function(e){n.abort(e)},!1),a.open(n.method,n.action,!0),"json"==n.type&&a.setRequestHeader("Accept","application/json"),a.onreadystatechange=function(){if(n.readystatechange(a),4==a.readyState){var t=a.responseText;if("json"==n.type)try{t=e.$.parseJSON(t)}catch(o){t=!1}n.complete(t,a)}},n.beforeSend(a),a.send(o)}}if(!e.support.ajaxupload)return this;if(a=e.$.extend({},t.defaults,a),o.length){if("*.*"!==a.allow)for(var i,l=0;i=o[l];l++)if(!n(a.allow,i.name))return"string"==typeof a.notallowed?alert(a.notallowed):a.notallowed(i,a),void 0;var f=a.complete;if(a.single){var s=o.length,d=0,p=!0;a.beforeAll(o),a.complete=function(e,t){d+=1,f(e,t),a.filelimit&&d>=a.filelimit&&(p=!1),p&&s>d?r([o[d]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){f(e,t),a.allcomplete(e,t)},r(o,a)}}function n(e,t){var n="^"+e.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return n="^"+n+"$",null!==t.match(new RegExp(n,"i"))}return e.component("uploadSelect",{init:function(){var e=this;this.on("change",function(){t(e.element[0].files,e.options);var n=e.element.clone(!0).data("uploadSelect",e);e.element.replaceWith(n),e.element=n})}}),e.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var e=this,n=!1;this.on("drop",function(n){n.originalEvent.dataTransfer&&n.originalEvent.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.originalEvent.dataTransfer.files]),t(n.originalEvent.dataTransfer.files,e.options))}).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}).on("dragover",function(t){t.stopPropagation(),t.preventDefault(),n||(e.element.addClass(e.options.dragoverClass),n=!0)}).on("dragleave",function(t){t.stopPropagation(),t.preventDefault(),e.element.removeClass(e.options.dragoverClass),n=!1})}}),e.support.ajaxupload=function(){function e(){var e=document.createElement("INPUT");return e.type="file","files"in e}function t(){var e=new XMLHttpRequest;return!!(e&&"upload"in e&&"onprogress"in e.upload)}function n(){return!!window.FormData}return e()&&t()&&n()}(),t.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",filelimit:!1,before:function(){},beforeSend:function(){},beforeAll:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(e,t){alert("Only the following file types are allowed: "+t.allow)}},e.Utils.xhrupload=t,t});
|
||||
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
!function(e){var t;window.UIkit2&&(t=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return t||e(UIkit2)})}(function(e){"use strict";function t(o,a){function r(t,n){var o=new FormData,a=new XMLHttpRequest;if(n.before(n,t)!==!1){for(var r,i=0;r=t[i];i++)o.append(n.param,r);for(var l in n.params)o.append(l,n.params[l]);a.upload.addEventListener("progress",function(e){var t=e.loaded/e.total*100;n.progress(t,e)},!1),a.addEventListener("loadstart",function(e){n.loadstart(e)},!1),a.addEventListener("load",function(e){n.load(e)},!1),a.addEventListener("loadend",function(e){n.loadend(e)},!1),a.addEventListener("error",function(e){n.error(e)},!1),a.addEventListener("abort",function(e){n.abort(e)},!1),a.open(n.method,n.action,!0),"json"==n.type&&a.setRequestHeader("Accept","application/json");for(var s in n.headers)a.setRequestHeader(s,n.headers[s]);a.onreadystatechange=function(){if(n.readystatechange(a),4==a.readyState){var t=a.responseText;if("json"==n.type)try{t=e.$.parseJSON(t)}catch(o){t=!1}n.complete(t,a)}},n.beforeSend(a),a.send(o)}}if(!e.support.ajaxupload)return this;if(a=e.$.extend({},t.defaults,a),o.length){if("*.*"!==a.allow)for(var i,l=0;i=o[l];l++)if(!n(a.allow,i.name))return"string"==typeof a.notallowed?alert(a.notallowed):a.notallowed(i,a),void 0;var s=a.complete;if(a.single){var d=o.length,f=0,p=!0;a.beforeAll(o),a.complete=function(e,t){f+=1,s(e,t),a.filelimit&&f>=a.filelimit&&(p=!1),p&&d>f?r([o[f]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){s(e,t),a.allcomplete(e,t)},r(o,a)}}function n(e,t){var n="^"+e.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return n="^"+n+"$",null!==t.match(new RegExp(n,"i"))}return e.component("uploadSelect",{init:function(){var e=this;this.on("change",function(){t(e.element[0].files,e.options);var n=e.element.clone(!0).data("uploadSelect",e);e.element.replaceWith(n),e.element=n})}}),e.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var e=this,n=!1;this.on("drop",function(n){n.originalEvent.dataTransfer&&n.originalEvent.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.originalEvent.dataTransfer.files]),t(n.originalEvent.dataTransfer.files,e.options))}).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}).on("dragover",function(t){t.stopPropagation(),t.preventDefault(),n||(e.element.addClass(e.options.dragoverClass),n=!0)}).on("dragleave",function(t){t.stopPropagation(),t.preventDefault(),e.element.removeClass(e.options.dragoverClass),n=!1})}}),e.support.ajaxupload=function(){function e(){var e=document.createElement("INPUT");return e.type="file","files"in e}function t(){var e=new XMLHttpRequest;return!!(e&&"upload"in e&&"onprogress"in e.upload)}function n(){return!!window.FormData}return e()&&t()&&n()}(),t.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",filelimit:!1,headers:{},before:function(){},beforeSend:function(){},beforeAll:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(e,t){alert("Only the following file types are allowed: "+t.allow)}},e.Utils.xhrupload=t,t});
|
@ -28,16 +28,6 @@ echo '
|
||||
echo '<td>'.BLUDIT_BUILD.'</td>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>PHP version</td>';
|
||||
echo '<td>'.phpversion().'</td>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>PHP modules</td>';
|
||||
echo '<td>'.implode(', ',get_loaded_extensions()).')</td>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -20,7 +20,7 @@ foreach($categories as $categoryKey=>$category)
|
||||
{
|
||||
echo '<tr>';
|
||||
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-category/'.$categoryKey.'">'.$category.'</a></td>';
|
||||
echo '<td><a href="'.DOMAIN.$Url->filters('category', false).$categoryKey.'">'.DOMAIN.$Url->filters('category', false).$categoryKey.'</a></td>';
|
||||
echo '<td><a href="'.DOMAIN_CATEGORIES.$categoryKey.'">'.$Url->filters('category', false).$categoryKey.'</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
HTML::title(array('title'=>$_Plugin->name(), 'icon'=>'puzzle-piece'));
|
||||
HTML::title(array('title'=>$plugin->name(), 'icon'=>'puzzle-piece'));
|
||||
|
||||
HTML::formOpen(array('id'=>'jsformplugin'));
|
||||
|
||||
@ -11,12 +11,14 @@ HTML::formOpen(array('id'=>'jsformplugin'));
|
||||
));
|
||||
|
||||
// Print the plugin form
|
||||
echo $_Plugin->form();
|
||||
echo $plugin->form();
|
||||
|
||||
// Form buttons
|
||||
echo '<div class="uk-form-row uk-margin-bottom">
|
||||
<button class="uk-button uk-button-primary" type="submit">'.$L->g('Save').'</button>
|
||||
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'plugins">'.$L->g('Cancel').'</a>
|
||||
</div>';
|
||||
if($plugin->formButtons()) {
|
||||
// Form buttons
|
||||
echo '<div class="uk-form-row uk-margin-bottom">
|
||||
<button class="uk-button uk-button-primary" type="submit">'.$L->g('Save').'</button>
|
||||
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'plugins">'.$L->g('Cancel').'</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
HTML::formClose();
|
||||
|
@ -4,13 +4,13 @@
|
||||
<div class="uk-width-medium-1-3">
|
||||
|
||||
<div class="uk-panel">
|
||||
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-post' ?>"><i class="uk-icon-pencil"></i> <?php $L->p('New post') ?></a></h4>
|
||||
<p><?php $L->p('Create a new article for your blog') ?></p>
|
||||
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><i class="uk-icon-pencil"></i> <?php $L->p('New content') ?></a></h4>
|
||||
<p><?php $L->p('Create a new page for your site') ?></p>
|
||||
</div>
|
||||
|
||||
<div class="uk-panel">
|
||||
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-posts' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Manage posts') ?></a></h4>
|
||||
<p><?php $L->p('edit-or-remove-your-blogs-posts') ?></p>
|
||||
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'pages' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Manage content') ?></a></h4>
|
||||
<p><?php $L->p('Edit or delete pages from your site') ?></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -18,13 +18,13 @@
|
||||
<div class="uk-width-medium-1-3" style="border-right: 1px solid #E6E6E6; border-left: 1px solid #E6E6E6">
|
||||
|
||||
<div class="uk-panel">
|
||||
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><i class="uk-icon-file-text-o"></i> <?php $L->p('New page') ?></a></h4>
|
||||
<p><?php $L->p('Create a new page for your website') ?></p>
|
||||
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-category' ?>"><i class="uk-icon-file-text-o"></i> <?php $L->p('New category') ?></a></h4>
|
||||
<p><?php $L->p('Create a new category to organize your pages') ?></p>
|
||||
</div>
|
||||
|
||||
<div class="uk-panel">
|
||||
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Manage pages') ?></a></h4>
|
||||
<p><?php $L->p('edit-or-remove-your=pages') ?></p>
|
||||
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Manage categories') ?></a></h4>
|
||||
<p><?php $L->p('Edit or delete your categories') ?></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
<div class="uk-panel">
|
||||
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'add-user' ?>"><i class="uk-icon-user-plus"></i> <?php $L->p('Add a new user') ?></a></h4>
|
||||
<p><?php $L->p('Invite a friend to collaborate on your website') ?></p>
|
||||
<p><?php $L->p('Invite a friend to collaborate on your site') ?></p>
|
||||
</div>
|
||||
|
||||
<div class="uk-panel">
|
||||
@ -61,6 +61,52 @@
|
||||
|
||||
<div class="uk-width-1-3">
|
||||
|
||||
<div class="uk-panel">
|
||||
<h4 class="panel-title"><?php $L->p('Notifications') ?></h4>
|
||||
<ul class="uk-list uk-list-line">
|
||||
<?php
|
||||
$logs = array_slice($Syslog->db, 0, NOTIFICATIONS_AMOUNT);
|
||||
foreach($logs as $log) {
|
||||
$dict = $L->g($log['dictionaryKey']);
|
||||
echo '<li>';
|
||||
echo $dict;
|
||||
if( !empty($log['notes'])) {
|
||||
echo ' ('.$log['notes'].')';
|
||||
}
|
||||
echo '<br><span class="notification-date">';
|
||||
echo Date::format($log['date'], DB_DATE_FORMAT, NOTIFICATIONS_DATE_FORMAT);
|
||||
echo ' - by '.$log['username'];
|
||||
echo '</span>';
|
||||
|
||||
echo '</li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="uk-width-1-3">
|
||||
|
||||
<div class="uk-panel">
|
||||
<h4 class="panel-title"><?php $L->p('Scheduled pages') ?></h4>
|
||||
<ul class="uk-list">
|
||||
<?php
|
||||
$scheduledPages = $dbPages->getScheduledDB();
|
||||
if( empty($scheduledPages) ) {
|
||||
echo '<li>'.$Language->g('There are no scheduled pages').'</li>';
|
||||
}
|
||||
else {
|
||||
$keys = array_keys($scheduledPages);
|
||||
foreach($keys as $key) {
|
||||
$page = buildPage($key);
|
||||
echo '<li><span class="label-time">'.$page->dateRaw(SCHEDULED_DATE_FORMAT).'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="uk-panel">
|
||||
<h4 class="panel-title"><?php $L->p('Statistics') ?></h4>
|
||||
<table class="uk-table statistics">
|
||||
@ -85,12 +131,15 @@
|
||||
<h4 class="panel-title"><?php $L->p('Drafts') ?></h4>
|
||||
<ul class="uk-list">
|
||||
<?php
|
||||
if( empty($_draftPages) ) {
|
||||
echo '<li>'.$Language->g('There are no drafts').'</li>';
|
||||
$draftPages = $dbPages->getDraftDB();
|
||||
if( empty($draftPages) ) {
|
||||
echo '<li>'.$Language->g('There are no draft pages').'</li>';
|
||||
}
|
||||
else {
|
||||
foreach($_draftPages as $Page) {
|
||||
echo '<li><span class="label-draft">'.$Language->g('Page').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->title()?$Page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
|
||||
$keys = array_keys($scheduledPages);
|
||||
foreach($keys as $key) {
|
||||
$page = buildPage($key);
|
||||
echo '<li><span class="label-draft">'.$Language->g('Page').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -99,24 +148,6 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="uk-width-1-3">
|
||||
|
||||
<div class="uk-panel">
|
||||
<h4 class="panel-title"><?php $L->p('Scheduled posts') ?></h4>
|
||||
<ul class="uk-list">
|
||||
<?php
|
||||
if( empty($_scheduledPosts) ) {
|
||||
echo '<li>'.$Language->g('There are no scheduled posts').'</li>';
|
||||
}
|
||||
else {
|
||||
foreach($_scheduledPosts as $Post) {
|
||||
echo '<li><span class="label-time">'.$Post->dateRaw(SCHEDULED_DATE_FORMAT).'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->title()?$Post->title():'['.$Language->g('Empty title').'] ').'</a></li>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
15
bl-kernel/admin/views/developers.php
Normal file
15
bl-kernel/admin/views/developers.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
HTML::title(array('title'=>$L->g('Developers'), 'icon'=>'support'));
|
||||
|
||||
echo '<h2>PHP version: '.phpversion().'</h2>';
|
||||
|
||||
// Constanst defined by Bludit
|
||||
$constants = get_defined_constants(true);
|
||||
printTable('Constants', $constants['user']);
|
||||
|
||||
// Loaded extensions
|
||||
printTable('Loaded extensions',get_loaded_extensions());
|
||||
|
||||
// Site object
|
||||
printTable('$Site object database',$Site->db);
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
HTML::title(array('title'=>$L->g('Edit page'), 'icon'=>'file-text-o'));
|
||||
HTML::title(array('title'=>$L->g('Edit content'), 'icon'=>'file-text-o'));
|
||||
|
||||
HTML::formOpen(array('class'=>'uk-form-stacked'));
|
||||
|
||||
@ -133,8 +133,13 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
'name'=>'status',
|
||||
'label'=>$L->g('Status'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>array('published'=>$L->g('Published'), 'draft'=>$L->g('Draft')),
|
||||
'selected'=>($page->draft()?'draft':'published'),
|
||||
'options'=>array(
|
||||
'published'=>$L->g('Published'),
|
||||
'drpaft'=>$L->g('Draft'),
|
||||
'fixed'=>$L->g('Fixed'),
|
||||
'sticky'=>$L->g('Sticky')
|
||||
),
|
||||
'selected'=>$page->status(),
|
||||
'tip'=>''
|
||||
));
|
||||
|
||||
@ -147,24 +152,28 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
'label'=>$L->g('Date')
|
||||
));
|
||||
|
||||
// If the page is parent then doesn't can have a parent.
|
||||
if(count($page->children())===0)
|
||||
{
|
||||
// Parent input
|
||||
$options = array();
|
||||
$options[NO_PARENT_CHAR] = '('.$Language->g('No parent').')';
|
||||
$options += $dbPages->parentKeyList();
|
||||
unset($options[$page->key()]);
|
||||
// Check if the page has children
|
||||
if(count($page->children())===0) {
|
||||
$options = array();
|
||||
$parentsList = $dbPages->getParents();
|
||||
$parentsKey = array_keys($parentsList);
|
||||
foreach($parentsKey as $pageKey) {
|
||||
$parent = buildPage($pageKey);
|
||||
$options[$pageKey] = $parent->title();
|
||||
}
|
||||
unset($options[$page->key()]);
|
||||
|
||||
HTML::formSelect(array(
|
||||
'name'=>'parent',
|
||||
'label'=>$L->g('Parent'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>$options,
|
||||
'selected'=>$page->parentKey(),
|
||||
'tip'=>''
|
||||
));
|
||||
}
|
||||
HTML::formSelect(array(
|
||||
'name'=>'parent',
|
||||
'label'=>$L->g('Parent'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>$options,
|
||||
'selected'=>$page->parentKey(),
|
||||
'tip'=>'',
|
||||
'addEmptySpace'=>true
|
||||
));
|
||||
}
|
||||
|
||||
// Position input
|
||||
HTML::formInputText(array(
|
||||
|
@ -16,7 +16,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
|
||||
// Security token
|
||||
HTML::formInputHidden(array(
|
||||
'name'=>'username',
|
||||
'value'=>$_User->username()
|
||||
'value'=>$User->username()
|
||||
));
|
||||
|
||||
HTML::legend(array('value'=>$L->g('Profile'), 'class'=>'first-child'));
|
||||
@ -24,7 +24,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
|
||||
HTML::formInputText(array(
|
||||
'name'=>'usernameDisable',
|
||||
'label'=>$L->g('Username'),
|
||||
'value'=>$_User->username(),
|
||||
'value'=>$User->username(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'disabled'=>true,
|
||||
'tip'=>''
|
||||
@ -33,7 +33,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
|
||||
HTML::formInputText(array(
|
||||
'name'=>'firstName',
|
||||
'label'=>$L->g('First name'),
|
||||
'value'=>$_User->firstName(),
|
||||
'value'=>$User->firstName(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>''
|
||||
));
|
||||
@ -41,7 +41,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
|
||||
HTML::formInputText(array(
|
||||
'name'=>'lastName',
|
||||
'label'=>$L->g('Last name'),
|
||||
'value'=>$_User->lastName(),
|
||||
'value'=>$User->lastName(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>''
|
||||
));
|
||||
@ -49,7 +49,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
|
||||
echo '<div class="uk-form-row">
|
||||
<label class="uk-form-label">'.$L->g('password').'</label>
|
||||
<div class="uk-form-controls">
|
||||
<a href="'.HTML_PATH_ADMIN_ROOT.'user-password/'.$_User->username().'">'.$L->g('Change password').'</a>
|
||||
<a href="'.HTML_PATH_ADMIN_ROOT.'user-password/'.$User->username().'">'.$L->g('Change password').'</a>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
@ -59,7 +59,7 @@ if($Login->role()==='admin') {
|
||||
'name'=>'role',
|
||||
'label'=>$L->g('Role'),
|
||||
'options'=>array('editor'=>$L->g('Editor'), 'admin'=>$L->g('Administrator')),
|
||||
'selected'=>$_User->role(),
|
||||
'selected'=>$User->role(),
|
||||
'tip'=>''
|
||||
));
|
||||
|
||||
@ -68,7 +68,7 @@ if($Login->role()==='admin') {
|
||||
HTML::formInputText(array(
|
||||
'name'=>'email',
|
||||
'label'=>$L->g('Email'),
|
||||
'value'=>$_User->email(),
|
||||
'value'=>$User->email(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>$L->g('email-will-not-be-publicly-displayed')
|
||||
));
|
||||
@ -78,7 +78,7 @@ if($Login->role()==='admin') {
|
||||
HTML::formInputText(array(
|
||||
'name'=>'twitter',
|
||||
'label'=>'Twitter',
|
||||
'value'=>$_User->twitter(),
|
||||
'value'=>$User->twitter(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>''
|
||||
));
|
||||
@ -86,7 +86,7 @@ if($Login->role()==='admin') {
|
||||
HTML::formInputText(array(
|
||||
'name'=>'facebook',
|
||||
'label'=>'Facebook',
|
||||
'value'=>$_User->facebook(),
|
||||
'value'=>$User->facebook(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>''
|
||||
));
|
||||
@ -94,7 +94,7 @@ if($Login->role()==='admin') {
|
||||
HTML::formInputText(array(
|
||||
'name'=>'googlePlus',
|
||||
'label'=>'Google+',
|
||||
'value'=>$_User->googlePlus(),
|
||||
'value'=>$User->googlePlus(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>''
|
||||
));
|
||||
@ -102,7 +102,7 @@ if($Login->role()==='admin') {
|
||||
HTML::formInputText(array(
|
||||
'name'=>'instagram',
|
||||
'label'=>'Instagram',
|
||||
'value'=>$_User->instagram(),
|
||||
'value'=>$User->instagram(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>''
|
||||
));
|
||||
@ -114,18 +114,28 @@ if($Login->role()==='admin') {
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
HTML::legend(array('value'=>$L->g('Authentication Token')));
|
||||
|
||||
HTML::formInputText(array(
|
||||
'name'=>'tokenAuth',
|
||||
'label'=>$L->g('Token'),
|
||||
'value'=>$User->tokenAuth(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>$L->g('This token is similar to your password, do not share this token.')
|
||||
));
|
||||
|
||||
HTML::legend(array('value'=>$L->g('Status')));
|
||||
|
||||
HTML::formInputText(array(
|
||||
'name'=>'status',
|
||||
'label'=>$L->g('сurrent status'),
|
||||
'value'=>$_User->enabled()?$L->g('Enabled'):$L->g('Disabled'),
|
||||
'value'=>$User->enabled()?$L->g('Enabled'):$L->g('Disabled'),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'disabled'=>true,
|
||||
'tip'=>$_User->enabled()?'':$L->g('To enable the user you have to set a new password')
|
||||
'tip'=>$User->enabled()?'':$L->g('To enable the user you have to set a new password')
|
||||
));
|
||||
|
||||
if( $_User->enabled() ) {
|
||||
if( $User->enabled() ) {
|
||||
echo '<div class="uk-form-row">
|
||||
<div class="uk-form-controls">
|
||||
<button type="submit" id="jsdisable-user" class="delete-button" name="disable-user"><i class="uk-icon-ban"></i> '.$L->g('Disable the user').'</button>
|
||||
@ -133,7 +143,7 @@ if( $_User->enabled() ) {
|
||||
</div>';
|
||||
}
|
||||
|
||||
if( ($Login->role()==='admin') && ($_User->username()!='admin') ) {
|
||||
if( ($Login->role()==='admin') && ($User->username()!='admin') ) {
|
||||
|
||||
HTML::legend(array('value'=>$L->g('Delete')));
|
||||
|
||||
@ -152,7 +162,7 @@ echo '</div>';
|
||||
|
||||
echo '<div class="uk-width-3-10" style="margin-top: 50px; text-align: center;">';
|
||||
|
||||
HTML::profileUploader($_User->username());
|
||||
HTML::profileUploader($User->username());
|
||||
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
HTML::title(array('title'=>$L->g('New page'), 'icon'=>'file-text-o'));
|
||||
HTML::title(array('title'=>$L->g('New content'), 'icon'=>'file-text-o'));
|
||||
|
||||
HTML::formOpen(array('class'=>'uk-form-stacked'));
|
||||
|
||||
@ -118,7 +118,12 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
'name'=>'status',
|
||||
'label'=>$L->g('Status'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>array('published'=>$L->g('Published'), 'draft'=>$L->g('Draft')),
|
||||
'options'=>array(
|
||||
'published'=>$L->g('Published'),
|
||||
'draft'=>$L->g('Draft'),
|
||||
'fixed'=>$L->g('Fixed'),
|
||||
'sticky'=>$L->g('Sticky')
|
||||
),
|
||||
'selected'=>'published',
|
||||
'tip'=>''
|
||||
));
|
||||
@ -134,9 +139,11 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
|
||||
// Parent input
|
||||
$options = array();
|
||||
$parents = $dbPages->getParents(true);
|
||||
foreach( $parents as $key=>$fields ) {
|
||||
$options[$key] = $pagesKey[$key]->title();
|
||||
$parentsList = $dbPages->getParents();
|
||||
$parentsKey = array_keys($parentsList);
|
||||
foreach($parentsKey as $pageKey) {
|
||||
$parent = buildPage($pageKey);
|
||||
$options[$pageKey] = $parent->title();
|
||||
}
|
||||
|
||||
HTML::formSelect(array(
|
||||
|
@ -1,33 +1,35 @@
|
||||
<?php
|
||||
|
||||
HTML::title(array('title'=>$L->g('Manage pages'), 'icon'=>'folder'));
|
||||
HTML::title(array('title'=>$L->g('Manage content'), 'icon'=>'folder'));
|
||||
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-page"><i class="uk-icon-plus"></i> '.$L->g('Add a new page').'</a>';
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-page"><i class="uk-icon-plus"></i> '.$L->g('Add new content').'</a>';
|
||||
|
||||
echo '
|
||||
<table class="uk-table uk-table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.$L->g('Title').'</th>
|
||||
<th class="uk-text-center">'.$L->g('Position').'</th>
|
||||
';
|
||||
|
||||
echo '<th class="uk-text-center">'.( (ORDER_BY=='date') ? $L->g('Date') : $L->g('Position') ).'</th>';
|
||||
|
||||
echo '
|
||||
<th>'.$L->g('URL').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
|
||||
foreach($pages as $page)
|
||||
{
|
||||
foreach($pages as $page) {
|
||||
$status = false;
|
||||
if($page->scheduled()) {
|
||||
$status = $Language->g('Scheduled');
|
||||
}
|
||||
elseif(!$page->published()) {
|
||||
$status = $Language->g('Draft');
|
||||
if($page->status()!='published') {
|
||||
$status = $Language->g( $page->status() );
|
||||
}
|
||||
echo '<tr>';
|
||||
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($status?'<span class="label-draft">'.$status.'</span>':'').($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a></td>';
|
||||
echo '<td class="uk-text-center">'.$page->dateRaw().'</td>';
|
||||
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($status?'<span class="label-'.$page->status().'">'.$status.'</span>':'').($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a></td>';
|
||||
|
||||
echo '<td class="uk-text-center">'.( (ORDER_BY=='date') ? $page->dateRaw() : $page->position() ).'</td>';
|
||||
|
||||
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$page->key() : '/'.$Url->filters('page').'/'.$page->key();
|
||||
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||
echo '</tr>';
|
||||
@ -36,4 +38,26 @@ foreach($pages as $page)
|
||||
echo '
|
||||
</tbody>
|
||||
</table>
|
||||
';
|
||||
';
|
||||
?>
|
||||
|
||||
<!-- Paginator -->
|
||||
<div id="paginator">
|
||||
<ul>
|
||||
<?php
|
||||
// Show previus page link
|
||||
if(Paginator::showPrev()) {
|
||||
echo '<li class="first"><a href="'.Paginator::prevPageUrl().'" class="previous"><- Previous</a></li>';
|
||||
}
|
||||
|
||||
for($i=1; $i<=Paginator::amountOfPages(); $i++) {
|
||||
echo '<li><a href='.Paginator::absoluteUrl($i).' class="page">'.$i.'</a></li>';
|
||||
}
|
||||
|
||||
// Show next page link
|
||||
if(Paginator::showNext()) {
|
||||
echo '<li class="next"><a href="'.Paginator::nextPageUrl().'" class="next">Next -></a></li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -17,40 +17,39 @@ echo '
|
||||
|
||||
foreach($plugins['all'] as $Plugin)
|
||||
{
|
||||
echo '
|
||||
<tr '.($Plugin->installed()?'class="plugin-installed"':'class="plugin-notInstalled"').'>
|
||||
echo '<tr '.($Plugin->installed()?'class="plugin-installed"':'class="plugin-notInstalled"').'>
|
||||
<td>
|
||||
<div class="plugin-name">
|
||||
';
|
||||
<div class="plugin-name">'.$Plugin->name().'</div>
|
||||
<div class="plugin-links">';
|
||||
|
||||
if($Plugin->installed()) {
|
||||
echo '<a class="uninstall" href="'.HTML_PATH_ADMIN_ROOT.'uninstall-plugin/'.$Plugin->className().'" title="'.$L->g('Deactivate').'"><i class="uk-icon-check-square-o"></i></a> ';
|
||||
if(method_exists($Plugin, 'form')) {
|
||||
echo '<a class="configure" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$Plugin->className().'" title="'.$L->g('Settings').'"><i class="uk-icon-cog settings-icon"></i></a> ';
|
||||
echo '<a class="configure" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$Plugin->className().'">'.$L->g('Settings').'</a>';
|
||||
echo '<span class="separator"> | </span>';
|
||||
}
|
||||
echo '<a class="uninstall" href="'.HTML_PATH_ADMIN_ROOT.'uninstall-plugin/'.$Plugin->className().'">'.$L->g('Deactivate').'</a>';
|
||||
}
|
||||
else {
|
||||
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-plugin/'.$Plugin->className().'" title="'.$L->g('Activate').'"><i class="uk-icon-square-o"></i></a> ';
|
||||
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-plugin/'.$Plugin->className().'">'.$L->g('Activate').'</a>';
|
||||
}
|
||||
|
||||
echo '
|
||||
'.$Plugin->name().'</div>
|
||||
</td>';
|
||||
|
||||
|
||||
echo '</div>';
|
||||
echo '</td>';
|
||||
|
||||
echo '<td>';
|
||||
echo $Plugin->description();
|
||||
echo '</td>';
|
||||
echo '
|
||||
<td class="uk-text-center">';
|
||||
|
||||
echo '<td class="uk-text-center">';
|
||||
if( !$Plugin->isCompatible() ) {
|
||||
echo '<i class="uk-icon-exclamation-triangle incompatible-warning" title="'.$L->g('This plugin may not be supported by this version of Bludit').'"></i>';
|
||||
}
|
||||
echo '<span>'.$Plugin->version().'</span>';
|
||||
echo '</td>';
|
||||
|
||||
echo '<span>'.$Plugin->version().'</span></td>';
|
||||
|
||||
echo '
|
||||
<td class="uk-text-center"><a target="_blank" href="'.$Plugin->website().'">'.$Plugin->author().'</a></td>
|
||||
';
|
||||
echo '<td class="uk-text-center"><a target="_blank" href="'.$Plugin->website().'">'.$Plugin->author().'</a></td>';
|
||||
|
||||
echo '</tr>';
|
||||
}
|
||||
|
@ -4,81 +4,82 @@ HTML::title(array('title'=>$L->g('Advanced settings'), 'icon'=>'cogs'));
|
||||
|
||||
HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||
|
||||
HTML::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
));
|
||||
HTML::formInputHidden(array(
|
||||
'name'=>'tokenCSRF',
|
||||
'value'=>$Security->getTokenCSRF()
|
||||
));
|
||||
|
||||
HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child'));
|
||||
HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child'));
|
||||
|
||||
HTML::formSelect(array(
|
||||
'name'=>'itemsPerPage',
|
||||
'label'=>$L->g('Items per page'),
|
||||
'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8'),
|
||||
'selected'=>$Site->itemsPerPage(),
|
||||
'class'=>'uk-width-1-3 uk-form-medium',
|
||||
'tip'=>$L->g('number-of-posts-to-show-per-page')
|
||||
));
|
||||
HTML::formSelect(array(
|
||||
'name'=>'itemsPerPage',
|
||||
'label'=>$L->g('Items per page'),
|
||||
'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8'),
|
||||
'selected'=>$Site->itemsPerPage(),
|
||||
'class'=>'uk-width-1-3 uk-form-medium',
|
||||
'tip'=>$L->g('Number of items to show per page')
|
||||
));
|
||||
|
||||
HTML::formInputText(array(
|
||||
'name'=>'url',
|
||||
'label'=>$L->g('Site URL'),
|
||||
'value'=>$Site->url(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>$L->g('the-url-of-your-site')
|
||||
));
|
||||
HTML::formInputText(array(
|
||||
'name'=>'url',
|
||||
'label'=>$L->g('Site URL'),
|
||||
'value'=>$Site->url(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>$L->g('the-url-of-your-site')
|
||||
));
|
||||
|
||||
HTML::legend(array('value'=>$L->g('Website or Blog')));
|
||||
HTML::legend(array('value'=>$L->g('Website or Blog')));
|
||||
|
||||
HTML::formSelect(array(
|
||||
'name'=>'orderBy',
|
||||
'label'=>$L->g('Order Pages By'),
|
||||
'options'=>array('date'=>'Date','position'=>'Position'),
|
||||
'selected'=>$Site->orderBy(),
|
||||
'class'=>'uk-width-1-3 uk-form-medium',
|
||||
'tip'=>$L->g('Order the pages by date to create a Blog or order the pages by position to create a Website')
|
||||
));
|
||||
HTML::formSelect(array(
|
||||
'name'=>'orderBy',
|
||||
'label'=>$L->g('Order content By'),
|
||||
'options'=>array('date'=>'Date','position'=>'Position'),
|
||||
'selected'=>$Site->orderBy(),
|
||||
'class'=>'uk-width-1-3 uk-form-medium',
|
||||
'tip'=>$L->g('Order the content by date to create a Blog or order the content by position to create a Website')
|
||||
));
|
||||
|
||||
HTML::legend(array('value'=>$L->g('Email account settings')));
|
||||
HTML::legend(array('value'=>$L->g('Email account settings')));
|
||||
|
||||
HTML::formInputText(array(
|
||||
'name'=>'emailFrom',
|
||||
'label'=>$L->g('Sender email'),
|
||||
'value'=>$Site->emailFrom(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>$L->g('Emails will be sent from this address')
|
||||
));
|
||||
HTML::formInputText(array(
|
||||
'name'=>'emailFrom',
|
||||
'label'=>$L->g('Sender email'),
|
||||
'value'=>$Site->emailFrom(),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>$L->g('Emails will be sent from this address')
|
||||
));
|
||||
|
||||
HTML::legend(array('value'=>$L->g('URL Filters')));
|
||||
HTML::legend(array('value'=>$L->g('URL Filters')));
|
||||
|
||||
HTML::formInputText(array(
|
||||
'name'=>'uriPage',
|
||||
'label'=>$L->g('Pages'),
|
||||
'value'=>$Site->uriFilters('page'),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>''
|
||||
));
|
||||
HTML::formInputText(array(
|
||||
'name'=>'uriPage',
|
||||
'label'=>$L->g('Pages'),
|
||||
'value'=>$Site->uriFilters('page'),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>DOMAIN_PAGES
|
||||
));
|
||||
|
||||
HTML::formInputText(array(
|
||||
'name'=>'uriTag',
|
||||
'label'=>$L->g('Tags'),
|
||||
'value'=>$Site->uriFilters('tag'),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>''
|
||||
));
|
||||
HTML::formInputText(array(
|
||||
'name'=>'uriTag',
|
||||
'label'=>$L->g('Tags'),
|
||||
'value'=>$Site->uriFilters('tag'),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>DOMAIN_TAGS
|
||||
));
|
||||
|
||||
HTML::formInputText(array(
|
||||
'name'=>'uriCategory',
|
||||
'label'=>$L->g('Category'),
|
||||
'value'=>$Site->uriFilters('category'),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>''
|
||||
));
|
||||
HTML::formInputText(array(
|
||||
'name'=>'uriCategory',
|
||||
'label'=>$L->g('Category'),
|
||||
'value'=>$Site->uriFilters('category'),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>DOMAIN_CATEGORIES
|
||||
));
|
||||
|
||||
echo '<div class="uk-form-row">
|
||||
<div class="uk-form-controls">
|
||||
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
|
||||
</div>
|
||||
</div>';
|
||||
echo '<div class="uk-form-row">
|
||||
<div class="uk-form-controls">
|
||||
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
|
||||
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'settings-advanced">'.$L->g('Cancel').'</a>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
HTML::formClose();
|
||||
|
@ -89,6 +89,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||
echo '<div class="uk-form-row">
|
||||
<div class="uk-form-controls">
|
||||
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
|
||||
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'settings-general">'.$L->g('Cancel').'</a>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
|
@ -50,6 +50,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||
echo '<div class="uk-form-row">
|
||||
<div class="uk-form-controls">
|
||||
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
|
||||
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'settings-regional">'.$L->g('Cancel').'</a>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
|
@ -20,34 +20,30 @@ foreach($themes as $theme)
|
||||
echo '
|
||||
<tr '.($theme['dirname']==$Site->theme()?'class="theme-installed"':'class="theme-notInstalled"').'>
|
||||
<td>
|
||||
<div class="plugin-name">
|
||||
<div class="plugin-name">'.$theme['name'].'</div>
|
||||
<div class="plugin-links">
|
||||
';
|
||||
|
||||
if($theme['dirname']!=$Site->theme()) {
|
||||
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'" title="'.$L->g('Activate').'"><i class="uk-icon-square-o"></i></a> ';
|
||||
}
|
||||
else {
|
||||
echo '<i class="uk-icon-check-square-o"></i> ';
|
||||
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'">'.$L->g('Activate').'</a>';
|
||||
}
|
||||
|
||||
echo '
|
||||
'.$theme['name'].'</div>
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
echo '<td>';
|
||||
echo $theme['description'];
|
||||
echo '</td>';
|
||||
echo '
|
||||
<td class="uk-text-center">';
|
||||
|
||||
echo '<td class="uk-text-center">';
|
||||
if( !$theme['compatible'] ) {
|
||||
echo '<i class="uk-icon-exclamation-triangle incompatible-warning" title="This theme is incompatible with Bludit v'.BLUDIT_VERSION.'"></i>';
|
||||
echo '<i class="uk-icon-exclamation-triangle incompatible-warning" title="'.$L->g('This plugin may not be supported by this version of Bludit').'"></i>';
|
||||
}
|
||||
echo $theme['version'].'</td>';
|
||||
echo $theme['version'];
|
||||
echo '</td>';
|
||||
|
||||
echo '
|
||||
<td class="uk-text-center"><a target="_blank" href="'.$theme['website'].'">'.$theme['author'].'</a></td>
|
||||
';
|
||||
echo '<td class="uk-text-center"><a targe="_blank" href="'.$theme['website'].'">'.$theme['author'].'</a></td>';
|
||||
|
||||
echo '</tr>';
|
||||
}
|
||||
|
@ -95,4 +95,4 @@ else
|
||||
// Load plugins after the admin area is loaded.
|
||||
Theme::plugins('afterAdminLoad');
|
||||
|
||||
}
|
||||
}
|
@ -55,9 +55,7 @@ define('DB_SITE', PATH_DATABASES.'site.php');
|
||||
define('DB_CATEGORIES', PATH_DATABASES.'categories.php');
|
||||
define('DB_TAGS', PATH_DATABASES.'tags.php');
|
||||
define('DB_SYSLOG', PATH_DATABASES.'syslog.php');
|
||||
|
||||
// ADMIN URI FILTER
|
||||
define('ADMIN_URI_FILTER', '/admin/');
|
||||
define('DB_USERS', PATH_DATABASES.'users.php');
|
||||
|
||||
// Log separator
|
||||
define('LOG_SEP', ' | ');
|
||||
@ -70,9 +68,6 @@ if(!defined('JSON_PRETTY_PRINT')) {
|
||||
// Protecting against Symlink attacks
|
||||
define('CHECK_SYMBOLIC_LINKS', TRUE);
|
||||
|
||||
// Auto scroll
|
||||
define('AUTO_SCROLL', TRUE);
|
||||
|
||||
// Alert status ok
|
||||
define('ALERT_STATUS_OK', 0);
|
||||
|
||||
@ -125,6 +120,12 @@ define('SITEMAP_DATE_FORMAT', 'Y-m-d');
|
||||
// Date format for Dashboard schedule posts
|
||||
define('SCHEDULED_DATE_FORMAT', 'd M - h:i a');
|
||||
|
||||
// Notifications date format
|
||||
define('NOTIFICATIONS_DATE_FORMAT', 'F j, Y, g:i a');
|
||||
|
||||
// Amount of items to show on notification panel
|
||||
define('NOTIFICATIONS_AMOUNT', 10);
|
||||
|
||||
// Token time to live for login via email. The offset is defined by http://php.net/manual/en/datetime.modify.php
|
||||
define('TOKEN_EMAIL_TTL', '+15 minutes');
|
||||
|
||||
@ -137,6 +138,9 @@ define('EXTREME_FRIENDLY_URL', FALSE);
|
||||
// Permissions for new directories
|
||||
define('DIR_PERMISSIONS', 0755);
|
||||
|
||||
// Admin URI filter
|
||||
define('ADMIN_URI_FILTER', '/admin/');
|
||||
|
||||
// Set internal character encoding
|
||||
mb_internal_encoding(CHARSET);
|
||||
|
||||
@ -181,6 +185,12 @@ include(PATH_HELPERS.'filesystem.class.php');
|
||||
include(PATH_HELPERS.'alert.class.php');
|
||||
include(PATH_HELPERS.'paginator.class.php');
|
||||
include(PATH_HELPERS.'image.class.php');
|
||||
include(PATH_HELPERS.'tcp.class.php');
|
||||
|
||||
// Include Bludit PRO
|
||||
if( file_exists(PATH_KERNEL.'bludit.pro.php') ) {
|
||||
include(PATH_KERNEL.'bludit.pro.php');
|
||||
}
|
||||
|
||||
// Session
|
||||
Session::start();
|
||||
@ -245,9 +255,27 @@ define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/');
|
||||
|
||||
define('JQUERY', HTML_PATH_ROOT.'bl-kernel/js/jquery.min.js');
|
||||
|
||||
// --- Objects with dependency ---
|
||||
$Language = new dbLanguage( $Site->locale() );
|
||||
$Login = new Login( $dbUsers );
|
||||
$Url->checkFilters( $Site->uriFilters() );
|
||||
|
||||
// --- CONSTANTS with dependency ---
|
||||
|
||||
// Tag URI filter
|
||||
define('TAG_URI_FILTER', $Url->filters('tag'));
|
||||
|
||||
// Category URI filter
|
||||
define('CATEGORY_URI_FILTER', $Url->filters('category'));
|
||||
|
||||
// Page URI filter
|
||||
define('PAGE_URI_FILTER', $Url->filters('page'));
|
||||
|
||||
// Content order by: date / position
|
||||
define('ORDER_BY', $Site->orderBy());
|
||||
|
||||
// --- PHP paths with dependency ---
|
||||
// This paths are absolutes for the OS
|
||||
// Depreacted, use THEME_DIR and THEME_DIR_XXX
|
||||
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS);
|
||||
define('THEME_DIR_PHP', THEME_DIR.'php'.DS);
|
||||
define('THEME_DIR_CSS', THEME_DIR.'css'.DS);
|
||||
@ -259,6 +287,7 @@ define('THEME_DIR_LANG', THEME_DIR.'languages'.DS);
|
||||
// This paths are absolutes for the user / web browsing.
|
||||
define('DOMAIN', $Site->domain());
|
||||
define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT);
|
||||
define('DOMAIN_THEME', DOMAIN.HTML_PATH_THEME);
|
||||
define('DOMAIN_THEME_CSS', DOMAIN.HTML_PATH_THEME_CSS);
|
||||
define('DOMAIN_THEME_JS', DOMAIN.HTML_PATH_THEME_JS);
|
||||
define('DOMAIN_THEME_IMG', DOMAIN.HTML_PATH_THEME_IMG);
|
||||
@ -266,22 +295,19 @@ define('DOMAIN_UPLOADS', DOMAIN.HTML_PATH_UPLOADS);
|
||||
define('DOMAIN_UPLOADS_PROFILES', DOMAIN.HTML_PATH_UPLOADS_PROFILES);
|
||||
define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS);
|
||||
|
||||
// --- Objects with dependency ---
|
||||
$Language = new dbLanguage( $Site->locale() );
|
||||
$Login = new Login( $dbUsers );
|
||||
$Url->checkFilters( $Site->uriFilters() );
|
||||
|
||||
// --- Objects shortcuts ---
|
||||
$L = $Language;
|
||||
|
||||
// --- CONSTANTS with dependency ---
|
||||
define('ORDER_BY', $Site->orderBy());
|
||||
define('DOMAIN_TAGS', Text::addSlashes(DOMAIN_BASE.TAG_URI_FILTER, false, true));
|
||||
define('DOMAIN_CATEGORIES', Text::addSlashes(DOMAIN_BASE.CATEGORY_URI_FILTER, false, true));
|
||||
define('DOMAIN_PAGES', Text::addSlashes(DOMAIN_BASE.PAGE_URI_FILTER, false, true));
|
||||
|
||||
$ADMIN_CONTROLLER = '';
|
||||
$ADMIN_VIEW = '';
|
||||
$ID_EXECUTION = uniqid(); // string 13 characters long
|
||||
$WHERE_AM_I = $Url->whereAmI();
|
||||
|
||||
// --- Objects shortcuts ---
|
||||
$L = $Language;
|
||||
|
||||
// DEBUG: Print constants
|
||||
// $arr = array_filter(get_defined_constants(), 'is_string');
|
||||
// echo json_encode($arr);
|
||||
// exit;
|
||||
// exit;
|
||||
|
@ -23,7 +23,8 @@ $plugins = array(
|
||||
'adminSidebar'=>array(),
|
||||
|
||||
'beforeRulesLoad'=>array(),
|
||||
'afterFormSave'=>array(),
|
||||
'beforeAll'=>array(),
|
||||
'afterAll'=>array(),
|
||||
|
||||
'afterPageCreate'=>array(),
|
||||
'afterPageModify'=>array(),
|
||||
@ -91,7 +92,7 @@ function buildPlugins()
|
||||
$Language->add($database);
|
||||
}
|
||||
|
||||
// Push Plugin to array all plugins installed and not installed.
|
||||
// Array with plugin all plugins, installed and not installed
|
||||
$plugins['all'][$pluginClass] = $Plugin;
|
||||
|
||||
// If the plugin is installed, order by hooks.
|
||||
|
@ -7,17 +7,17 @@
|
||||
// Array with all published pages
|
||||
$pages = array();
|
||||
|
||||
// Array with all pages (published, draft, scheduled)
|
||||
// Array with all pages (published, fixed, sticky, draft, scheduled)
|
||||
$allPages = array();
|
||||
|
||||
// Object Page for the page filtered bye the user
|
||||
$page = false;
|
||||
// Object Page for the page filtered by the user
|
||||
$page = $Page = false;
|
||||
|
||||
// Array with all page parents published
|
||||
//$pageParents = array();
|
||||
|
||||
// Array with all published pages, the array is a key=>Page-object
|
||||
$pagesKey = array();
|
||||
$pagesByKey = array();
|
||||
|
||||
// ============================================================================
|
||||
// Main
|
||||
@ -30,20 +30,26 @@ if( $dbPages->scheduler() ) {
|
||||
|
||||
// Reindex categories
|
||||
reindexCategories();
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'page-published-from-scheduler',
|
||||
'notes'=>''
|
||||
));
|
||||
}
|
||||
|
||||
// Build specific page
|
||||
if( $Url->whereAmI()==='page' ) {
|
||||
|
||||
// Build the page
|
||||
$page = buildPage( $Url->slug() );
|
||||
$page = $Page = buildPage( $Url->slug() );
|
||||
|
||||
// The page doesn't exist
|
||||
if($page===false) {
|
||||
$Url->setNotFound(true);
|
||||
}
|
||||
// The page is not published
|
||||
elseif( !$page->published() ) {
|
||||
// The page is not published, still scheduled or draft
|
||||
elseif( $page->scheduled() || $page->draft() ) {
|
||||
$Url->setNotFound(true);
|
||||
}
|
||||
else {
|
||||
@ -63,7 +69,9 @@ elseif( $Url->whereAmI()==='admin' ) {
|
||||
buildPagesForAdmin();
|
||||
}
|
||||
|
||||
// Set page 404 not found
|
||||
if( $Url->notFound() ) {
|
||||
$Url->setWhereAmI('page');
|
||||
$page = new Page('error');
|
||||
$page = buildPage('error');
|
||||
$pages[0] = $page;
|
||||
}
|
||||
|
@ -30,20 +30,25 @@ Paginator::set('itemsPerPage', $itemsPerPage);
|
||||
Paginator::set('amountOfItems', $amountOfItems);
|
||||
|
||||
// Amount of pages
|
||||
$amountOfPages = (int) max(ceil($amountOfItems / $itemsPerPage) -1, 0);
|
||||
$amountOfPages = (int) max(ceil($amountOfItems / $itemsPerPage), 1);
|
||||
Paginator::set('amountOfPages', $amountOfPages);
|
||||
|
||||
$showOlder = $amountOfPages > $currentPage;
|
||||
Paginator::set('showOlder', $showOlder);
|
||||
// TRUE if exists a next page to show
|
||||
$showNext = $amountOfPages > $currentPage;
|
||||
Paginator::set('showNext', $showNext);
|
||||
|
||||
$showNewer = $currentPage > 0;
|
||||
Paginator::set('showNewer', $showNewer);
|
||||
// TRUE if exists a previous page to show
|
||||
$showPrev = $currentPage > Paginator::firstPage();
|
||||
Paginator::set('showPrev', $showPrev);
|
||||
|
||||
$show = $showNewer && $showOlder;
|
||||
Paginator::set('show', true);
|
||||
// TRUE if exists a next and previous page to show
|
||||
$showNextPrev = $showNext && $showPrev;
|
||||
Paginator::set('showNextPrev', $showNextPrev);
|
||||
|
||||
// Integer with the next page
|
||||
$nextPage = max(0, $currentPage+1);
|
||||
Paginator::set('nextPage', $nextPage);
|
||||
|
||||
// Integer with the previous page
|
||||
$prevPage = min($amountOfPages, $currentPage-1);
|
||||
Paginator::set('prevPage', $prevPage);
|
||||
|
@ -45,11 +45,14 @@ function buildThemes()
|
||||
$metadata = json_decode($metadataString, true);
|
||||
|
||||
$database['compatible'] = false;
|
||||
|
||||
if( !empty($metadata['compatible']) ) {
|
||||
$explode = explode(',', $metadata['compatible']);
|
||||
if(in_array(BLUDIT_VERSION, $explode)) {
|
||||
$database['compatible'] = true;
|
||||
$bluditRoot = explode('.', BLUDIT_VERSION);
|
||||
$compatible = explode(',', $metadata['compatible']);
|
||||
foreach( $compatible as $version ) {
|
||||
$root = explode('.', $version);
|
||||
if( $root[0]==$bluditRoot[0] && $root[1]==$bluditRoot[1] ) {
|
||||
$database['compatible'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
// Load plugins rules
|
||||
include(PATH_RULES.'60.plugins.php');
|
||||
|
||||
// Plugins before rules loaded
|
||||
Theme::plugins('beforeRulesLoad');
|
||||
// Plugins before all
|
||||
Theme::plugins('beforeAll');
|
||||
|
||||
// Load rules
|
||||
include(PATH_RULES.'69.pages.php');
|
||||
@ -30,3 +30,6 @@ else {
|
||||
|
||||
// Plugins after site loaded
|
||||
Theme::plugins('afterSiteLoad');
|
||||
|
||||
// Plugins after all
|
||||
Theme::plugins('afterAll');
|
||||
|
@ -21,8 +21,9 @@ class dbCategories extends dbList
|
||||
$this->db[$key]['list'] = array();
|
||||
}
|
||||
|
||||
// Foreach post in the database
|
||||
$db = $dbPages->getDB();
|
||||
// Get a database with published pages
|
||||
$db = $dbPages->getPublishedDB();
|
||||
|
||||
foreach($db as $pageKey=>$pageFields) {
|
||||
if( !empty($pageFields['category']) ) {
|
||||
$categoryKey = $pageFields['category'];
|
||||
|
@ -18,7 +18,7 @@ class dbPages extends dbJSON
|
||||
'category'=> array('inFile'=>false, 'value'=>''),
|
||||
'md5file'=> array('inFile'=>false, 'value'=>''),
|
||||
'uuid'=> array('inFile'=>false, 'value'=>''),
|
||||
'allowComments'=> array('inFile'=>false, 'value'=>false)
|
||||
'allowComments'=> array('inFile'=>false, 'value'=>true)
|
||||
);
|
||||
|
||||
function __construct()
|
||||
@ -27,28 +27,22 @@ class dbPages extends dbJSON
|
||||
}
|
||||
|
||||
// Create a new page
|
||||
public function add($args)
|
||||
public function add($args, $climode=false)
|
||||
{
|
||||
$dataForDb = array(); // This data will be saved in the database
|
||||
$dataForFile = array(); // This data will be saved in the file
|
||||
|
||||
// The user is always the one loggued
|
||||
$args['username'] = Session::get('username');
|
||||
if( Text::isEmpty($args['username']) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Generate key
|
||||
$key = $this->generateKey($args['slug'], $args['parent']);
|
||||
|
||||
// Generate UUID
|
||||
$args['uuid'] = md5( uniqid() );
|
||||
$args['uuid'] = $this->generateUUID();
|
||||
|
||||
// Date
|
||||
$currentDate = Date::current(DB_DATE_FORMAT);
|
||||
|
||||
// Validate date
|
||||
if(!Valid::date($args['date'], DB_DATE_FORMAT)) {
|
||||
if( !Valid::date($args['date'], DB_DATE_FORMAT) ) {
|
||||
$args['date'] = $currentDate;
|
||||
}
|
||||
|
||||
@ -90,48 +84,44 @@ class dbPages extends dbJSON
|
||||
}
|
||||
}
|
||||
|
||||
// Create the directory
|
||||
if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_PAGES.$key);
|
||||
return false;
|
||||
if( $climode===false ) {
|
||||
// Create the directory
|
||||
if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_PAGES.$key);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make the index.txt and save the file.
|
||||
$data = implode("\n", $dataForFile);
|
||||
if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $data) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Make the index.txt and save the file.
|
||||
$data = implode("\n", $dataForFile);
|
||||
if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $data) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
|
||||
return false;
|
||||
}
|
||||
// Checksum MD5
|
||||
$dataForDb['md5file'] = md5_file(PATH_PAGES.$key.DS.FILENAME);
|
||||
|
||||
// Insert in database
|
||||
$this->db[$key] = $dataForDb;
|
||||
|
||||
// Sort database
|
||||
$this->sortByDate();
|
||||
$this->sortBy();
|
||||
|
||||
// Save database
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
$this->save();
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
public function edit($args)
|
||||
public function edit($args, $climode=false)
|
||||
{
|
||||
$dataForDb = array();
|
||||
$dataForFile = array();
|
||||
|
||||
// The user is always the one loggued
|
||||
$args['username'] = Session::get('username');
|
||||
if( Text::isEmpty($args['username']) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$newKey = $this->generateKey($args['slug'], $args['parent'], false, $args['key']);
|
||||
|
||||
// If the page is draft then the time created is now
|
||||
// If the page is draft then the created time is the current
|
||||
if( $this->db[$args['key']]['status']=='draft' ) {
|
||||
$args['date'] = Date::current(DB_DATE_FORMAT);
|
||||
}
|
||||
@ -178,35 +168,37 @@ class dbPages extends dbJSON
|
||||
}
|
||||
}
|
||||
|
||||
// Move the directory from old key to new key.
|
||||
if($newKey!==$args['key']) {
|
||||
if( Filesystem::mv(PATH_PAGES.$args['key'], PATH_PAGES.$newKey) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to move the directory to '.PATH_PAGES.$newKey);
|
||||
if( $climode===false ) {
|
||||
// Move the directory from old key to new key.
|
||||
if($newKey!==$args['key']) {
|
||||
if( Filesystem::mv(PATH_PAGES.$args['key'], PATH_PAGES.$newKey) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to move the directory to '.PATH_PAGES.$newKey);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Make the index.txt and save the file.
|
||||
$data = implode("\n", $dataForFile);
|
||||
if( file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $data) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Make the index.txt and save the file.
|
||||
$data = implode("\n", $dataForFile);
|
||||
if( file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $data) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove the old key
|
||||
unset( $this->db[$args['key']] );
|
||||
|
||||
// Checksum MD5
|
||||
$dataForDb['md5file'] = md5_file(PATH_PAGES.$newKey.DS.FILENAME);
|
||||
|
||||
// Insert in database
|
||||
$this->db[$newKey] = $dataForDb;
|
||||
|
||||
// Sort database
|
||||
$this->sortByDate();
|
||||
$this->sortBy();
|
||||
|
||||
// Save database
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
$this->save();
|
||||
|
||||
return $newKey;
|
||||
}
|
||||
@ -239,6 +231,23 @@ class dbPages extends dbJSON
|
||||
return true;
|
||||
}
|
||||
|
||||
// Change a value of a page
|
||||
public function setField($key, $field, $value)
|
||||
{
|
||||
if( $this->exists($key) ) {
|
||||
settype($value, gettype($this->dbFields[$field]['value']));
|
||||
$this->db[$key][$field] = $value;
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setStatus($key, $value)
|
||||
{
|
||||
return $this->setField($key, 'status', $value);
|
||||
}
|
||||
|
||||
// Returns a database with published pages
|
||||
public function getPublishedDB()
|
||||
{
|
||||
@ -251,6 +260,42 @@ class dbPages extends dbJSON
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// (array) Returns a database with the fixed pages
|
||||
public function getFixedDB()
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach($tmp as $key=>$fields) {
|
||||
if($fields['status']!='fixed') {
|
||||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// Returns a database with drafts pages
|
||||
public function getDraftDB()
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach($tmp as $key=>$fields) {
|
||||
if($fields['status']!='draft') {
|
||||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// Returns a database with drafts pages
|
||||
public function getScheduledDB()
|
||||
{
|
||||
$tmp = $this->db;
|
||||
foreach($tmp as $key=>$fields) {
|
||||
if($fields['status']!='scheduled') {
|
||||
unset($tmp[$key]);
|
||||
}
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// Return an array with the database for a page, FALSE otherwise.
|
||||
public function getPageDB($key)
|
||||
{
|
||||
@ -273,8 +318,14 @@ class dbPages extends dbJSON
|
||||
$db = $this->getPublishedDB();
|
||||
}
|
||||
|
||||
// Remove Error page from the list
|
||||
unset($db['error']);
|
||||
|
||||
// The first page number is 1, so the real is 0
|
||||
$realPageNumber = $pageNumber - 1;
|
||||
|
||||
$total = count($db);
|
||||
$init = (int) $amountOfItems * $pageNumber;
|
||||
$init = (int) $amountOfItems * $realPageNumber;
|
||||
$end = (int) min( ($init + $amountOfItems - 1), $total );
|
||||
$outrange = $init<0 ? true : $init>$end;
|
||||
|
||||
@ -298,87 +349,117 @@ class dbPages extends dbJSON
|
||||
return count($this->db);
|
||||
}
|
||||
|
||||
public function getParents($onlyPublished=true)
|
||||
// Returns an array with all parents pages key, a parent page is not a child
|
||||
public function getParents()
|
||||
{
|
||||
if( $onlyPublished ) {
|
||||
$db = $this->getPublishedDB();
|
||||
}
|
||||
else {
|
||||
$db = $this->db;
|
||||
}
|
||||
|
||||
foreach( $db as $key=>$fields ) {
|
||||
$db = $this->getPublishedDB();
|
||||
foreach($db as $key=>$fields) {
|
||||
// if the key has slash then is a child
|
||||
if( Text::stringContains($key, '/') ) {
|
||||
unset($db[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $db;
|
||||
}
|
||||
|
||||
// Return TRUE if the page exists, FALSE otherwise.
|
||||
// Return TRUE if the page exists, FALSE otherwise
|
||||
public function exists($key)
|
||||
{
|
||||
return isset( $this->db[$key] );
|
||||
}
|
||||
|
||||
public function sortBy()
|
||||
{
|
||||
if( ORDER_BY=='date' ) {
|
||||
return $this->sortByDate(true);
|
||||
} else {
|
||||
return $this->sortByPosition(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort pages by position
|
||||
public function sortByPosition($HighToLow=false)
|
||||
{
|
||||
if($HighToLow) {
|
||||
uasort($this->db, array($this, 'sortByPositionHighToLow'));
|
||||
}
|
||||
else {
|
||||
uasort($this->db, array($this, 'sortByPositionLowToHigh'));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function sortByPositionLowToHigh($a, $b) {
|
||||
return $a['position']>$b['position'];
|
||||
}
|
||||
private function sortByPositionHighToLow($a, $b) {
|
||||
return $a['position']<$b['position'];
|
||||
}
|
||||
|
||||
// Sort pages by date
|
||||
public function sortByDate($HighToLow=true)
|
||||
{
|
||||
if($HighToLow) {
|
||||
uasort($this->db, array($this, 'sortHighToLow'));
|
||||
uasort($this->db, array($this, 'sortByDateHighToLow'));
|
||||
}
|
||||
else {
|
||||
uasort($this->db, array($this, 'sortLowToHigh'));
|
||||
uasort($this->db, array($this, 'sortByDateLowToHigh'));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function sortLowToHigh($a, $b) {
|
||||
private function sortByDateLowToHigh($a, $b) {
|
||||
return $a['date']>$b['date'];
|
||||
}
|
||||
private function sortHighToLow($a, $b) {
|
||||
private function sortByDateHighToLow($a, $b) {
|
||||
return $a['date']<$b['date'];
|
||||
}
|
||||
|
||||
// ----- OLD
|
||||
private function generateUUID() {
|
||||
return md5( uniqid().time() );
|
||||
}
|
||||
|
||||
// Set a field of the database
|
||||
public function setField($key, $field, $value)
|
||||
// Returns TRUE if there are new pages published, FALSE otherwise
|
||||
public function scheduler()
|
||||
{
|
||||
if( $this->exists($key) ) {
|
||||
settype($value, gettype($this->dbFields[$key]['value']));
|
||||
$this->db[$key][$field] = $value;
|
||||
// Get current date
|
||||
$currentDate = Date::current(DB_DATE_FORMAT);
|
||||
$saveDatabase = false;
|
||||
|
||||
// The database need to be sorted by date
|
||||
foreach($this->db as $pageKey=>$fields) {
|
||||
if($fields['status']=='scheduled') {
|
||||
if($fields['date']<=$currentDate) {
|
||||
$this->db[$pageKey]['status'] = 'published';
|
||||
$saveDatabase = true;
|
||||
}
|
||||
}
|
||||
elseif( ($fields['status']=='published') && (ORDER_BY=='date') ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($saveDatabase) {
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
Log::set(__METHOD__.LOG_SEP.'New pages published from the scheduler.');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function parentKeyList()
|
||||
{
|
||||
return $this->parentKeyList;
|
||||
}
|
||||
|
||||
public function parentKeyExists($key)
|
||||
{
|
||||
return isset( $this->parentKeyList[$key] );
|
||||
}
|
||||
|
||||
public function addParentKey($key)
|
||||
{
|
||||
$this->parentKeyList[$key] = $key;
|
||||
}
|
||||
|
||||
// Generate a valid Key/Slug.
|
||||
public function generateKey($text, $parent=NO_PARENT_CHAR, $returnSlug=false, $oldKey='')
|
||||
// Generate a valid Key/Slug
|
||||
public function generateKey($text, $parent=false, $returnSlug=false, $oldKey='')
|
||||
{
|
||||
if(Text::isEmpty($text)) {
|
||||
$text = 'empty';
|
||||
}
|
||||
|
||||
if( Text::isEmpty($parent) || ($parent==NO_PARENT_CHAR) ) {
|
||||
if( empty($parent) ) {
|
||||
$newKey = Text::cleanUrl($text);
|
||||
}
|
||||
else {
|
||||
@ -411,6 +492,116 @@ class dbPages extends dbJSON
|
||||
return $newKey;
|
||||
}
|
||||
|
||||
public function rescanClimode()
|
||||
{
|
||||
Log::set('CLI MODE'.LOG_SEP.'Starting re-scan on pages directory.');
|
||||
$pageList = array();
|
||||
|
||||
// Search for pages
|
||||
$directories = Filesystem::listDirectories(PATH_PAGES, $regex='*', $sortByDate=false);
|
||||
foreach($directories as $directory) {
|
||||
if( Sanitize::pathFile($directory.DS.FILENAME) ) {
|
||||
$pageKey = basename($directory);
|
||||
$pageList[$pageKey] = true;
|
||||
|
||||
// Search for children pages
|
||||
$subDirectories = Filesystem::listDirectories(PATH_PAGES.$pageKey.DS, $regex='*', $sortByDate=false);
|
||||
foreach($subDirectories as $subDirectory) {
|
||||
if( Sanitize::pathFile($subDirectory.DS.FILENAME) ) {
|
||||
$subPageKey = basename($subDirectory);
|
||||
$subPageKey = $pageKey.'/'.$subPageKey;
|
||||
$pageList[$subPageKey] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::set('CLI MODE'.LOG_SEP.'Updating pages...');
|
||||
$keys = array_keys($pageList);
|
||||
foreach($keys as $pageKey) {
|
||||
// Checksum
|
||||
$checksum = md5_file(PATH_PAGES.$pageKey.DS.FILENAME);
|
||||
|
||||
// New page
|
||||
if( !isset($this->db[$pageKey]) ) {
|
||||
$this->verifyFieldsClimode($pageKey, true);
|
||||
}
|
||||
// Update page
|
||||
elseif($this->db[$pageKey]['md5file']!=$checksum) {
|
||||
$this->verifyFieldsClimode($pageKey, false);
|
||||
}
|
||||
}
|
||||
|
||||
Log::set('CLI MODE'.LOG_SEP.'Removing pages...');
|
||||
foreach( array_diff_key($this->db, $pageList) as $pageKey=>$data ) {
|
||||
Log::set('CLI MODE'.LOG_SEP.'Removing page from database, key: '.$pageKey);
|
||||
unset( $this->db[$pageKey] );
|
||||
}
|
||||
$this->save();
|
||||
}
|
||||
|
||||
private function verifyFieldsClimode($key, $insert=true)
|
||||
{
|
||||
$page = new Page($key);
|
||||
$db = $page->getDB();
|
||||
|
||||
// Content from file
|
||||
$db['content'] = $db['contentRaw'];
|
||||
|
||||
// Parent
|
||||
$db['parent'] = '';
|
||||
$db['slug'] = $key;
|
||||
$explodeKey = explode('/', $key);
|
||||
if(isset($explodeKey[1])) {
|
||||
$db['parent'] = $explodeKey[0];
|
||||
$db['slug'] = $explodeKey[1];
|
||||
}
|
||||
|
||||
// Date
|
||||
if( !isset($db['date']) ) {
|
||||
$db['date'] = Date::current(DB_DATE_FORMAT);
|
||||
}
|
||||
|
||||
// Status
|
||||
if( !isset($db['status']) ) {
|
||||
$db['status'] = CLI_STATUS;
|
||||
}
|
||||
|
||||
// Owner username
|
||||
if( !isset($db['username']) ) {
|
||||
$db['username'] = CLI_USERNAME;
|
||||
}
|
||||
|
||||
// New page or update page
|
||||
if($insert) {
|
||||
Log::set('CLI MODE'.LOG_SEP.'New page found, key:'.$key);
|
||||
return $this->add($db, $climode=true);
|
||||
} else {
|
||||
Log::set('CLI MODE'.LOG_SEP.'Different checksum, updating page, key:'.$key);
|
||||
return $this->edit($db, $climode=true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----- OLD
|
||||
|
||||
public function parentKeyList()
|
||||
{
|
||||
return $this->parentKeyList;
|
||||
}
|
||||
|
||||
public function parentKeyExists($key)
|
||||
{
|
||||
return isset( $this->parentKeyList[$key] );
|
||||
}
|
||||
|
||||
public function addParentKey($key)
|
||||
{
|
||||
$this->parentKeyList[$key] = $key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Returns the database
|
||||
public function getDB()
|
||||
{
|
||||
@ -455,37 +646,6 @@ class dbPages extends dbJSON
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
// Return TRUE if there are new pages published, FALSE otherwise.
|
||||
public function scheduler()
|
||||
{
|
||||
// Get current date
|
||||
$currentDate = Date::current(DB_DATE_FORMAT);
|
||||
$saveDatabase = false;
|
||||
|
||||
// The database need to be sorted by date
|
||||
foreach($this->db as $pageKey=>$fields) {
|
||||
if($fields['status']=='scheduled') {
|
||||
if($fields['date']<=$currentDate) {
|
||||
$this->db[$pageKey]['status'] = 'published';
|
||||
$saveDatabase = true;
|
||||
}
|
||||
}
|
||||
elseif($fields['status']=='published') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($saveDatabase) {
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
Log::set(__METHOD__.LOG_SEP.'New pages published from the scheduler.');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ class dbSite extends dbJSON
|
||||
'slogan'=> array('inFile'=>false, 'value'=>''),
|
||||
'description'=> array('inFile'=>false, 'value'=>''),
|
||||
'footer'=> array('inFile'=>false, 'value'=>'I wanna be a pirate!'),
|
||||
'itemsPerPage'=> array('inFile'=>false, 'value'=>''),
|
||||
'itemsPerPage'=> array('inFile'=>false, 'value'=>6),
|
||||
'language'=> array('inFile'=>false, 'value'=>'en'),
|
||||
'locale'=> array('inFile'=>false, 'value'=>'en_US'),
|
||||
'timezone'=> array('inFile'=>false, 'value'=>'America/Argentina/Buenos_Aires'),
|
||||
@ -49,20 +49,13 @@ class dbSite extends dbJSON
|
||||
|
||||
public function set($args)
|
||||
{
|
||||
foreach($args as $field=>$value)
|
||||
{
|
||||
if( isset($this->dbFields[$field]) )
|
||||
{
|
||||
foreach($args as $field=>$value) {
|
||||
if( isset($this->dbFields[$field]) ) {
|
||||
$this->db[$field] = Sanitize::html($value);
|
||||
}
|
||||
}
|
||||
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
// Returns an array with the filters for the url
|
||||
@ -97,6 +90,21 @@ class dbSite extends dbJSON
|
||||
{
|
||||
$filter = $this->getField('uriCategory');
|
||||
return $this->url().ltrim($filter, '/');
|
||||
|
||||
}
|
||||
|
||||
// Returns the URL of the rss.xml file
|
||||
// You need to have enabled the plugin RSS
|
||||
public function rss()
|
||||
{
|
||||
return DOMAIN_BASE.'rss.xml';
|
||||
}
|
||||
|
||||
// Returns the URL of the sitemap.xml file
|
||||
// You need to have enabled the plugin Sitemap
|
||||
public function sitemap()
|
||||
{
|
||||
return DOMAIN_BASE.'sitemap.xml';
|
||||
}
|
||||
|
||||
public function twitter()
|
||||
@ -129,6 +137,21 @@ class dbSite extends dbJSON
|
||||
return $this->getField('orderBy');
|
||||
}
|
||||
|
||||
public function pageError()
|
||||
{
|
||||
return $this->getField('pageError');
|
||||
}
|
||||
|
||||
public function pageAbout()
|
||||
{
|
||||
return $this->getField('pageAbout');
|
||||
}
|
||||
|
||||
public function pageContact()
|
||||
{
|
||||
return $this->getField('pageContact');
|
||||
}
|
||||
|
||||
// Returns the site title
|
||||
public function title()
|
||||
{
|
||||
@ -181,7 +204,7 @@ class dbSite extends dbJSON
|
||||
}
|
||||
|
||||
// Returns the full domain and base url
|
||||
// For example, https://www.domain.com/bludit/
|
||||
// For example, https://www.domain.com/bludit
|
||||
public function url()
|
||||
{
|
||||
return $this->getField('url');
|
||||
|
@ -16,6 +16,27 @@ class dbSyslog extends dbJSON
|
||||
parent::__construct(DB_SYSLOG);
|
||||
}
|
||||
|
||||
// Returns TRUE if the ID of execution exists, FALSE otherwise
|
||||
public function exists($idExecution)
|
||||
{
|
||||
foreach($this->db as $field) {
|
||||
if( $field['idExecution']==$idExecution ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get($idExecution)
|
||||
{
|
||||
foreach($this->db as $field) {
|
||||
if( $field['idExecution']==$idExecution ) {
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function add($args)
|
||||
{
|
||||
global $Language;
|
||||
@ -36,6 +57,9 @@ class dbSyslog extends dbJSON
|
||||
// Insert at beggining of the database
|
||||
array_unshift($this->db, $data);
|
||||
|
||||
// Keep just NOTIFICATIONS_AMOUNT notifications
|
||||
$this->db = array_slice($this->db, 0, NOTIFICATIONS_AMOUNT);
|
||||
|
||||
// Save
|
||||
return $this->save();
|
||||
}
|
||||
|
@ -16,7 +16,9 @@ class dbTags extends dbList
|
||||
{
|
||||
global $dbPages;
|
||||
|
||||
$db = $dbPages->getDB();
|
||||
// Get a database with published pages
|
||||
$db = $dbPages->getPublishedDB();
|
||||
|
||||
$tagsIndex = array();
|
||||
|
||||
foreach($db as $pageKey=>$pageFields) {
|
||||
|
@ -13,6 +13,8 @@ class dbUsers extends dbJSON
|
||||
'registered'=> array('inFile'=>false, 'value'=>'1985-03-15 10:00'),
|
||||
'tokenEmail'=> array('inFile'=>false, 'value'=>''),
|
||||
'tokenEmailTTL'=> array('inFile'=>false, 'value'=>'2009-03-15 14:00'),
|
||||
'tokenAuth'=> array('inFile'=>false, 'value'=>''),
|
||||
'tokenAuthTTL'=> array('inFile'=>false, 'value'=>'2009-03-15 14:00'),
|
||||
'twitter'=> array('inFile'=>false, 'value'=>''),
|
||||
'facebook'=> array('inFile'=>false, 'value'=>''),
|
||||
'googlePlus'=> array('inFile'=>false, 'value'=>''),
|
||||
@ -21,15 +23,86 @@ class dbUsers extends dbJSON
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct(PATH_DATABASES.'users.php');
|
||||
parent::__construct(DB_USERS);
|
||||
}
|
||||
|
||||
// Disable the user
|
||||
public function disableUser($username)
|
||||
{
|
||||
$args['username'] = $username;
|
||||
$args['password'] = '!';
|
||||
|
||||
return $this->set($args);
|
||||
}
|
||||
|
||||
// Return TRUE if the user exists, FALSE otherwise
|
||||
public function exists($username)
|
||||
{
|
||||
return isset($this->db[$username]);
|
||||
}
|
||||
|
||||
// Create a new user
|
||||
public function add($args)
|
||||
{
|
||||
$dataForDb = array();
|
||||
|
||||
// Verify arguments with the database fields
|
||||
foreach($this->dbFields as $field=>$options) {
|
||||
if( isset($args[$field]) ) {
|
||||
$value = Sanitize::html($args[$field]);
|
||||
}
|
||||
else {
|
||||
$value = $options['value'];
|
||||
}
|
||||
|
||||
// Set type
|
||||
settype($value, gettype($options['value']));
|
||||
|
||||
// Save on database
|
||||
$dataForDb[$field] = $value;
|
||||
}
|
||||
|
||||
$dataForDb['registered'] = Date::current(DB_DATE_FORMAT);
|
||||
$dataForDb['salt'] = $this->generateSalt();
|
||||
$dataForDb['password'] = $this->generatePasswordHash($dataForDb['password'], $dataForDb['salt']);
|
||||
$dataForDb['tokenAuth'] = $this->generateAuthToken();
|
||||
|
||||
// Save the database
|
||||
$this->db[$dataForDb['username']] = $dataForDb;
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
// Set the parameters of a user
|
||||
public function set($args)
|
||||
{
|
||||
// Current database of the user
|
||||
$user = $this->db[$args['username']];
|
||||
|
||||
// Verify arguments with the database fields
|
||||
foreach($args as $field=>$value) {
|
||||
if( isset($this->dbFields[$field]) ) {
|
||||
$value = Sanitize::html($value);
|
||||
settype($value, gettype($this->dbFields[$field]['value']));
|
||||
$user[$field] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Save the database
|
||||
$this->db[$args['username']] = $user;
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
// Delete an user
|
||||
public function delete($username)
|
||||
{
|
||||
unset($this->db[$username]);
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
public function getUser($username)
|
||||
{
|
||||
$User = new User();
|
||||
|
||||
if($this->userExists($username))
|
||||
{
|
||||
if($this->exists($username)) {
|
||||
$User = new User();
|
||||
$User->setField('username', $username);
|
||||
|
||||
foreach($this->db[$username] as $key=>$value) {
|
||||
@ -42,16 +115,81 @@ class dbUsers extends dbJSON
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
public function generateAuthToken()
|
||||
{
|
||||
return $this->db;
|
||||
return md5( uniqid().time().DOMAIN );
|
||||
}
|
||||
|
||||
// Return an array with the username databases, filtered by username.
|
||||
public function generateEmailToken()
|
||||
{
|
||||
return $this->generateAuthToken();
|
||||
}
|
||||
|
||||
public function generateSalt()
|
||||
{
|
||||
return Text::randomText(SALT_LENGTH);
|
||||
}
|
||||
|
||||
public function generatePasswordHash($password, $salt)
|
||||
{
|
||||
return sha1($password.$salt);
|
||||
}
|
||||
|
||||
public function setPassword($username, $password)
|
||||
{
|
||||
$salt = $this->generateSalt();
|
||||
$hash = $this->generatePasswordHash($password, $salt);
|
||||
$tokenAuth = $this->generateAuthToken();
|
||||
|
||||
$args['username'] = $username;
|
||||
$args['salt'] = $salt;
|
||||
$args['password'] = $hash;
|
||||
$args['tokenAuth'] = $tokenAuth;
|
||||
|
||||
return $this->set($args);
|
||||
}
|
||||
|
||||
// Return the username associated to an email, FALSE otherwise
|
||||
public function getByEmail($email)
|
||||
{
|
||||
foreach($this->db as $username=>$values) {
|
||||
if($values['email']==$email) {
|
||||
return $username;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns the username with the authentication token assigned, FALSE otherwise
|
||||
public function getByAuthToken($token)
|
||||
{
|
||||
foreach($this->db as $username=>$fields) {
|
||||
if($fields['tokenAuth']==$token) {
|
||||
return $username;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setTokenEmail($username)
|
||||
{
|
||||
// Random hash
|
||||
$token = $this->generateEmailToken();
|
||||
$this->db[$username]['tokenEmail'] = $token;
|
||||
|
||||
// Token time to live, defined by TOKEN_EMAIL_TTL
|
||||
$this->db[$username]['tokenEmailTTL'] = Date::currentOffset(DB_DATE_FORMAT, TOKEN_EMAIL_TTL);
|
||||
|
||||
// Save the database
|
||||
$this->save();
|
||||
return $token;
|
||||
}
|
||||
|
||||
// ---- OLD
|
||||
// Returns array with the username databases filtered by username, FALSE otherwise
|
||||
public function getDb($username)
|
||||
{
|
||||
if($this->userExists($username))
|
||||
{
|
||||
if($this->exists($username)) {
|
||||
$user = $this->db[$username];
|
||||
|
||||
return $user;
|
||||
@ -60,163 +198,10 @@ class dbUsers extends dbJSON
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return the username associated to an email, if the email does not exists return FALSE.
|
||||
public function getByEmail($email)
|
||||
public function getAll()
|
||||
{
|
||||
foreach($this->db as $username=>$values) {
|
||||
if($values['email']==$email) {
|
||||
return $username;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
// Return TRUE if the user exists, FALSE otherwise.
|
||||
public function userExists($username)
|
||||
{
|
||||
return isset($this->db[$username]);
|
||||
}
|
||||
|
||||
public function generateTokenEmail($username)
|
||||
{
|
||||
// Random hash
|
||||
$token = sha1(Text::randomText(SALT_LENGTH).time());
|
||||
$this->db[$username]['tokenEmail'] = $token;
|
||||
|
||||
// Token time to live, defined by TOKEN_EMAIL_TTL
|
||||
$this->db[$username]['tokenEmailTTL'] = Date::currentOffset(DB_DATE_FORMAT, TOKEN_EMAIL_TTL);
|
||||
|
||||
// Save the database
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function setPassword($username, $password)
|
||||
{
|
||||
$salt = Text::randomText(SALT_LENGTH);
|
||||
$hash = sha1($password.$salt);
|
||||
|
||||
$args['username'] = $username;
|
||||
$args['salt'] = $salt;
|
||||
$args['password'] = $hash;
|
||||
|
||||
return $this->set($args);
|
||||
}
|
||||
|
||||
// Disable the user
|
||||
public function disableUser($username)
|
||||
{
|
||||
$args['username'] = $username;
|
||||
$args['password'] = '!';
|
||||
|
||||
return $this->set($args);
|
||||
}
|
||||
|
||||
public function set($args)
|
||||
{
|
||||
$dataForDb = array();
|
||||
|
||||
$user = $this->getDb($args['username']);
|
||||
|
||||
if($user===false)
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the username '.$args['username']);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify arguments with the database fields.
|
||||
foreach($args as $field=>$value)
|
||||
{
|
||||
if( isset($this->dbFields[$field]) )
|
||||
{
|
||||
// Sanitize.
|
||||
$tmpValue = Sanitize::html($value);
|
||||
|
||||
// Set type.
|
||||
settype($tmpValue, gettype($this->dbFields[$field]['value']));
|
||||
|
||||
$user[$field] = $tmpValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Save the database
|
||||
$this->db[$args['username']] = $user;
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delete($username)
|
||||
{
|
||||
unset($this->db[$username]);
|
||||
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function add($args)
|
||||
{
|
||||
$dataForDb = array();
|
||||
|
||||
// Verify arguments with the database fields.
|
||||
foreach($this->dbFields as $field=>$options)
|
||||
{
|
||||
// If the user send the field.
|
||||
if( isset($args[$field]) )
|
||||
{
|
||||
// Sanitize if will be saved on database.
|
||||
if( !$options['inFile'] ) {
|
||||
$tmpValue = Sanitize::html($args[$field]);
|
||||
}
|
||||
else {
|
||||
$tmpValue = $args[$field];
|
||||
}
|
||||
}
|
||||
// Uses a default value for the field.
|
||||
else
|
||||
{
|
||||
$tmpValue = $options['value'];
|
||||
}
|
||||
|
||||
// Set type
|
||||
settype($tmpValue, gettype($options['value']));
|
||||
|
||||
// Save on database
|
||||
$dataForDb[$field] = $tmpValue;
|
||||
}
|
||||
|
||||
// Check if the user alredy exists.
|
||||
if( $this->userExists($dataForDb['username']) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Current date.
|
||||
$dataForDb['registered'] = Date::current(DB_DATE_FORMAT);
|
||||
|
||||
// Password
|
||||
$dataForDb['salt'] = Text::randomText(SALT_LENGTH);
|
||||
$dataForDb['password'] = sha1($dataForDb['password'].$dataForDb['salt']);
|
||||
|
||||
// Save the database
|
||||
$this->db[$dataForDb['username']] = $dataForDb;
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// (object) Returns a Page object, the class is page.class.php, FALSE if something fail to load the page
|
||||
function buildPage($key)
|
||||
{
|
||||
global $dbPages;
|
||||
@ -59,30 +60,14 @@ function buildPage($key)
|
||||
|
||||
function reindexCategories()
|
||||
{
|
||||
global $dbPages;
|
||||
global $dbCategories;
|
||||
|
||||
// Get a database with published pages
|
||||
$db = $dbPages->getPublishedDB();
|
||||
|
||||
// Regenerate the tags
|
||||
$dbCategories->reindex($db);
|
||||
|
||||
return true;
|
||||
return $dbCategories->reindex();
|
||||
}
|
||||
|
||||
function reindexTags()
|
||||
{
|
||||
global $dbPages;
|
||||
global $dbCategories;
|
||||
|
||||
// Get a database with published pages
|
||||
$db = $dbPages->getPublishedDB();
|
||||
|
||||
// Regenerate the tags
|
||||
$dbTags->reindex($db);
|
||||
|
||||
return true;
|
||||
global $dbTags;
|
||||
return $dbTags->reindex();
|
||||
}
|
||||
|
||||
function buildPagesForAdmin()
|
||||
@ -115,9 +100,10 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
|
||||
{
|
||||
global $dbPages;
|
||||
global $dbCategories;
|
||||
global $dbTags;
|
||||
global $Site;
|
||||
global $Url;
|
||||
global $pagesKey;
|
||||
global $pagesByKey;
|
||||
global $pages;
|
||||
|
||||
// Get the page number from URL
|
||||
@ -143,20 +129,265 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
|
||||
}
|
||||
|
||||
// There are not items for the page number then set the page notfound
|
||||
if( empty($list) && $pageNumber>0 ) {
|
||||
if( empty($list) && $pageNumber>1 ) {
|
||||
$Url->setNotFound(true);
|
||||
}
|
||||
|
||||
$pages = array(); // global variable
|
||||
$pagesKey = array(); // global variable
|
||||
$pagesByKey = array(); // global variable
|
||||
foreach($list as $pageKey=>$fields) {
|
||||
$page = buildPage($pageKey);
|
||||
if($page!==false) {
|
||||
// $pagesKey
|
||||
$pagesKey[$pageKey] = $page;
|
||||
// $pagesByKey
|
||||
$pagesByKey[$pageKey] = $page;
|
||||
// $pages
|
||||
array_push($pages, $page);
|
||||
}
|
||||
}
|
||||
return $pages;
|
||||
}
|
||||
|
||||
// Returns TRUE if the plugin is enabled, FALSE otherwise
|
||||
function pluginEnabled($pluginName) {
|
||||
global $plugins;
|
||||
|
||||
$pluginClass = 'plugin'.Text::firstCharUp($pluginName);
|
||||
if( isset($plugins['all'][$pluginClass]) ) {
|
||||
return $plugins['all'][$pluginClass]->installed();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function printDebug($array) {
|
||||
echo '<pre>';
|
||||
var_dump($array);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
function createPage($args) {
|
||||
global $dbPages;
|
||||
global $Syslog;
|
||||
|
||||
// The user is always the one loggued
|
||||
$args['username'] = Session::get('username');
|
||||
if( Text::isEmpty($args['username']) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$key = $dbPages->add($args);
|
||||
if($key) {
|
||||
// Call the plugins after page created
|
||||
Theme::plugins('afterPageCreate');
|
||||
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'new-page-created',
|
||||
'notes'=>$args['title']
|
||||
));
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
Log::set('Function createNewPage()'.LOG_SEP.'Error occurred when trying to create the page');
|
||||
Log::set('Function createNewPage()'.LOG_SEP.'Cleaning database...');
|
||||
$dbPages->delete($key);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function editPage($args) {
|
||||
global $dbPages;
|
||||
global $Syslog;
|
||||
|
||||
// The user is always the one loggued
|
||||
$args['username'] = Session::get('username');
|
||||
if( Text::isEmpty($args['username']) ) {
|
||||
Log::set('Function editPage()'.LOG_SEP.'Empty username.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isset($args['parent'])) {
|
||||
$args['parent'] = NO_PARENT_CHAR;
|
||||
}
|
||||
|
||||
$key = $dbPages->edit($args);
|
||||
if($key) {
|
||||
// Call the plugins after page modified
|
||||
Theme::plugins('afterPageModify');
|
||||
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'page-edited',
|
||||
'notes'=>$args['title']
|
||||
));
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
Log::set('Function editPage()'.LOG_SEP.'ERROR: Something happen when try to edit the page.');
|
||||
return false;
|
||||
}
|
||||
|
||||
function deletePage($key) {
|
||||
global $dbPages;
|
||||
global $Syslog;
|
||||
|
||||
if( $dbPages->delete($key) ) {
|
||||
// Call the plugins after page deleted
|
||||
Theme::plugins('afterPageDelete');
|
||||
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'page-deleted',
|
||||
'notes'=>$key
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function disableUser($username) {
|
||||
global $dbUsers;
|
||||
global $Login;
|
||||
global $Syslog;
|
||||
|
||||
// The editors can't disable users
|
||||
if($Login->role()!=='admin') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( $dbUsers->disableUser($username) ) {
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'user-disabled',
|
||||
'notes'=>$username
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function editUser($args) {
|
||||
global $dbUsers;
|
||||
global $Syslog;
|
||||
|
||||
if( $dbUsers->set($args) ) {
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'user-edited',
|
||||
'notes'=>$args['username']
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function deleteUser($args, $deleteContent=false) {
|
||||
global $dbUsers;
|
||||
global $Login;
|
||||
global $Syslog;
|
||||
|
||||
// The user admin cannot be deleted
|
||||
if($args['username']=='admin') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The editors can't delete users
|
||||
if($Login->role()!=='admin') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($deleteContent) {
|
||||
//$dbPosts->deletePostsByUser($args['username']);
|
||||
}
|
||||
else {
|
||||
//$dbPosts->linkPostsToUser($args['username'], 'admin');
|
||||
}
|
||||
|
||||
if( $dbUsers->delete($args['username']) ) {
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'user-deleted',
|
||||
'notes'=>$args['username']
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function createUser($args) {
|
||||
global $dbUsers;
|
||||
global $Language;
|
||||
global $Syslog;
|
||||
|
||||
// Check empty username
|
||||
if( Text::isEmpty($args['new_username']) ) {
|
||||
Alert::set($Language->g('username-field-is-empty'), ALERT_STATUS_FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check already exist username
|
||||
if( $dbUsers->exists($args['new_username']) ) {
|
||||
Alert::set($Language->g('username-already-exists'), ALERT_STATUS_FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Password length
|
||||
if( strlen($args['new_password']) < 6 ) {
|
||||
Alert::set($Language->g('Password must be at least 6 characters long'), ALERT_STATUS_FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check new password and confirm password are equal
|
||||
if( $args['new_password'] != $args['confirm_password'] ) {
|
||||
Alert::set($Language->g('The password and confirmation password do not match'), ALERT_STATUS_FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filter form fields
|
||||
$tmp = array();
|
||||
$tmp['username'] = $args['new_username'];
|
||||
$tmp['password'] = $args['new_password'];
|
||||
$tmp['role'] = $args['role'];
|
||||
$tmp['email'] = $args['email'];
|
||||
|
||||
// Add the user to the database
|
||||
if( $dbUsers->add($tmp) ) {
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'new-user',
|
||||
'notes'=>$tmp['username']
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
class Filesystem {
|
||||
|
||||
// Returns an array with the absolutes directories.
|
||||
public static function listDirectories($path, $regex='*')
|
||||
public static function listDirectories($path, $regex='*', $sortByDate=false)
|
||||
{
|
||||
$directories = glob($path.$regex, GLOB_ONLYDIR);
|
||||
|
||||
@ -11,6 +11,10 @@ class Filesystem {
|
||||
return array();
|
||||
}
|
||||
|
||||
if($sortByDate) {
|
||||
usort($directories, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
|
||||
}
|
||||
|
||||
return $directories;
|
||||
}
|
||||
|
||||
@ -50,4 +54,44 @@ class Filesystem {
|
||||
return unlink($filename);
|
||||
}
|
||||
|
||||
public static function fileExists($filename)
|
||||
{
|
||||
return file_exists($filename);
|
||||
}
|
||||
|
||||
public static function directoryExists($path)
|
||||
{
|
||||
return file_exists($path);
|
||||
}
|
||||
|
||||
public static function copyRecursive($source, $destination)
|
||||
{
|
||||
$destination = rtrim($destination, '/');
|
||||
|
||||
foreach($iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::SELF_FIRST) as $item) {
|
||||
if($item->isDir()) {
|
||||
@mkdir($destination.DS.$iterator->getSubPathName());
|
||||
} else {
|
||||
copy($item, $destination.DS.$iterator->getSubPathName());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function deleteRecursive($source)
|
||||
{
|
||||
foreach(new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($source, FilesystemIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::CHILD_FIRST) as $item) {
|
||||
if($item->isFile()) {
|
||||
unlink($item);
|
||||
} else {
|
||||
rmdir($item);
|
||||
}
|
||||
}
|
||||
|
||||
return rmdir($source);
|
||||
}
|
||||
}
|
@ -4,13 +4,15 @@ class Paginator {
|
||||
|
||||
public static $pager = array(
|
||||
'itemsPerPage'=>0,
|
||||
'amountOfPages'=>0,
|
||||
'nextPage'=>0,
|
||||
'prevPage'=>0,
|
||||
'currentPage'=>0,
|
||||
'showOlder'=>false,
|
||||
'showNewer'=>false,
|
||||
'show'=>false
|
||||
'amountOfPages'=>1,
|
||||
'amountOfItems'=>0,
|
||||
'firstPage'=>1,
|
||||
'nextPage'=>1,
|
||||
'prevPage'=>1,
|
||||
'currentPage'=>1,
|
||||
'showPrev'=>false,
|
||||
'showNext'=>false,
|
||||
'showNextPrev'=>false
|
||||
);
|
||||
|
||||
public static function set($key, $value)
|
||||
@ -23,58 +25,62 @@ class Paginator {
|
||||
return self::$pager[$key];
|
||||
}
|
||||
|
||||
public static function urlNextPage()
|
||||
public static function amountOfPages()
|
||||
{
|
||||
global $Url;
|
||||
|
||||
$domain = trim(DOMAIN_BASE,'/');
|
||||
$filter = trim($Url->activeFilter(), '/');
|
||||
|
||||
if(empty($filter)) {
|
||||
$url = $domain.'/'.$Url->slug();
|
||||
}
|
||||
else {
|
||||
$url = $domain.'/'.$filter.'/'.$Url->slug();
|
||||
}
|
||||
|
||||
return $url.'?page='.self::get('nextPage');
|
||||
return self::get('amountOfPages');
|
||||
}
|
||||
|
||||
public static function urlPrevPage()
|
||||
public static function nextPage()
|
||||
{
|
||||
global $Url;
|
||||
|
||||
$domain = trim(DOMAIN_BASE,'/');
|
||||
$filter = trim($Url->activeFilter(), '/');
|
||||
|
||||
if(empty($filter)) {
|
||||
$url = $domain.'/'.$Url->slug();
|
||||
}
|
||||
else {
|
||||
$url = $domain.'/'.$filter.'/'.$Url->slug();
|
||||
}
|
||||
|
||||
return $url.'?page='.self::get('prevPage');
|
||||
return self::get('nextPage');
|
||||
}
|
||||
|
||||
public static function urlLastPage()
|
||||
public static function prevPage()
|
||||
{
|
||||
global $Url;
|
||||
|
||||
$domain = trim(DOMAIN_BASE,'/');
|
||||
$filter = trim($Url->activeFilter(), '/');
|
||||
|
||||
if(empty($filter)) {
|
||||
$url = $domain.'/'.$Url->slug();
|
||||
}
|
||||
else {
|
||||
$url = $domain.'/'.$filter.'/'.$Url->slug();
|
||||
}
|
||||
|
||||
return $url.'?page='.self::get('numberOfPages');
|
||||
return self::get('prevPage');
|
||||
}
|
||||
|
||||
public static function urlFirstPage()
|
||||
public static function showNext()
|
||||
{
|
||||
return self::get('showNext');
|
||||
}
|
||||
|
||||
public static function showPrev()
|
||||
{
|
||||
return self::get('showPrev');
|
||||
}
|
||||
|
||||
public static function firstPage()
|
||||
{
|
||||
return self::get('firstPage');
|
||||
}
|
||||
|
||||
// Returns the absolute URL for the first page
|
||||
public static function firstPageUrl()
|
||||
{
|
||||
return self::absoluteUrl( self::firstPage() );
|
||||
}
|
||||
|
||||
// Returns the absolute URL for the last page
|
||||
public static function lastPageUrl()
|
||||
{
|
||||
return self::absoluteUrl( self::amountOfPages() );
|
||||
}
|
||||
|
||||
// Returns the absolute URL for the next page
|
||||
public static function nextPageUrl()
|
||||
{
|
||||
return self::absoluteUrl( self::nextPage() );
|
||||
}
|
||||
|
||||
// Returns the absolute URL for the previous page
|
||||
public static function prevPageUrl()
|
||||
{
|
||||
return self::absoluteUrl( self::prevPage() );
|
||||
}
|
||||
|
||||
// Return the absoulte URL with the current filter
|
||||
public static function absoluteUrl($pageNumber)
|
||||
{
|
||||
global $Url;
|
||||
|
||||
@ -88,7 +94,7 @@ class Paginator {
|
||||
$url = $domain.'/'.$filter.'/'.$Url->slug();
|
||||
}
|
||||
|
||||
return $url.'?page=0';
|
||||
return $url.'?page='.$pageNumber;
|
||||
}
|
||||
|
||||
public static function html($textPrevPage=false, $textNextPage=false, $showPageNumber=false)
|
||||
|
51
bl-kernel/helpers/tcp.class.php
Normal file
51
bl-kernel/helpers/tcp.class.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
class TCP {
|
||||
|
||||
public static function http($url, $method='GET', $verifySSL=true, $timeOut=1, $followRedirections=true, $binary=true, $headers=false)
|
||||
{
|
||||
if( function_exists('curl_version') ) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followRedirections);
|
||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, $binary);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verifySSL);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeOut);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeOut);
|
||||
if($method=='POST') {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
}
|
||||
$output = curl_exec($ch);
|
||||
if($output===false) {
|
||||
Log::set('Curl error: '.curl_error($ch));
|
||||
}
|
||||
curl_close($ch);
|
||||
}
|
||||
else {
|
||||
$options = array(
|
||||
'http'=>array(
|
||||
'method'=>$method,
|
||||
'timeout'=>$timeOut,
|
||||
'follow_location'=>$followRedirections
|
||||
),
|
||||
"ssl"=>array(
|
||||
"verify_peer"=>false,
|
||||
"verify_peer_name"=>false
|
||||
)
|
||||
);
|
||||
$stream = stream_context_create($options);
|
||||
$output = file_get_contents($url, false, $stream);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function download($url, $destination)
|
||||
{
|
||||
$data = self::http($url, $method='GET', $verifySSL=true, $timeOut=3, $followRedirections=true, $binary=true, $headers=false);
|
||||
return file_put_contents($destination, $data);
|
||||
}
|
||||
|
||||
}
|
@ -2,123 +2,111 @@
|
||||
|
||||
class Theme {
|
||||
|
||||
public static function favicon($file='favicon.png', $path=HTML_PATH_THEME_IMG, $typeIcon=true, $echo=true)
|
||||
{
|
||||
$type = 'image/png';
|
||||
if($typeIcon) {
|
||||
$type = 'image/x-icon';
|
||||
}
|
||||
|
||||
$tmp = '<link rel="shortcut icon" href="'.$path.$file.'" type="'.$type.'">'.PHP_EOL;
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function css($files, $path=DOMAIN_THEME_CSS, $echo=true)
|
||||
{
|
||||
if(!is_array($files)) {
|
||||
$files = array($files);
|
||||
}
|
||||
|
||||
$tmp = '';
|
||||
foreach($files as $file) {
|
||||
$tmp .= '<link rel="stylesheet" type="text/css" href="'.$path.$file.'">'.PHP_EOL;
|
||||
}
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function javascript($files, $path=HTML_PATH_THEME_JS, $echo=true)
|
||||
{
|
||||
if(!is_array($files)) {
|
||||
$files = array($files);
|
||||
}
|
||||
|
||||
$tmp = '';
|
||||
foreach($files as $file) {
|
||||
$tmp .= '<script src="'.$path.$file.'"></script>'.PHP_EOL;
|
||||
}
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function title($title=false, $echo=true)
|
||||
// Return the metatag <title> with a predefine structure
|
||||
public static function headTitle()
|
||||
{
|
||||
global $Url;
|
||||
global $Post, $Page;
|
||||
global $Site;
|
||||
global $dbTags;
|
||||
global $dbCategories;
|
||||
global $WHERE_AM_I;
|
||||
global $page;
|
||||
|
||||
$tmp = $title;
|
||||
$title = $Site->title();
|
||||
|
||||
if(empty($title))
|
||||
{
|
||||
if( $Url->whereAmI()=='post' ) {
|
||||
$tmp = $Post->title().' - '.$Site->title();
|
||||
}
|
||||
elseif( $Url->whereAmI()=='page' ) {
|
||||
$tmp = $Page->title().' - '.$Site->title();
|
||||
}
|
||||
elseif( $Url->whereAmI()=='tag' ) {
|
||||
$tag = $dbTags->getName($Url->slug());
|
||||
$tmp = $tag.' - '.$Site->title();
|
||||
}
|
||||
else {
|
||||
$tmp = $Site->title();
|
||||
}
|
||||
if( $WHERE_AM_I=='page' ) {
|
||||
$title = $page->title().' - '.$Site->title();
|
||||
}
|
||||
elseif( $WHERE_AM_I=='tag' ) {
|
||||
$tagKey = $Url->slug();
|
||||
$tagName = $dbTags->getName($tagKey);
|
||||
$title = $tagName.' - '.$Site->title();
|
||||
}
|
||||
elseif( $WHERE_AM_I=='category' ) {
|
||||
$categoryKey = $Url->slug();
|
||||
$categoryName = $dbCategories->getName($categoryKey);
|
||||
$title = $categoryName.' - '.$Site->title();
|
||||
}
|
||||
|
||||
$tmp = '<title>'.$tmp.'</title>'.PHP_EOL;
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
return '<title>'.$title.'</title>'.PHP_EOL;
|
||||
}
|
||||
|
||||
public static function description($description=false, $echo=true)
|
||||
// Return the metatag <decription> with a predefine structure
|
||||
public static function headDescription()
|
||||
{
|
||||
global $Url;
|
||||
global $Post, $Page;
|
||||
global $Site;
|
||||
global $WHERE_AM_I;
|
||||
global $page;
|
||||
|
||||
$tmp = $description;
|
||||
$description = $Site->description();
|
||||
|
||||
if(empty($description))
|
||||
{
|
||||
if( $Url->whereAmI()=='post' ) {
|
||||
$tmp = $Post->description();
|
||||
}
|
||||
elseif( $Url->whereAmI()=='page' ) {
|
||||
$tmp = $Page->description();
|
||||
}
|
||||
else {
|
||||
$tmp = $Site->description();
|
||||
}
|
||||
if( $WHERE_AM_I=='page' ) {
|
||||
$description = $page->description();
|
||||
}
|
||||
|
||||
$tmp = '<meta name="description" content="'.$tmp.'">'.PHP_EOL;
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
return '<meta name="description" content="'.$description.'">'.PHP_EOL;
|
||||
}
|
||||
|
||||
public static function charset($charset)
|
||||
{
|
||||
return '<meta charset="'.$charset.'">'.PHP_EOL;
|
||||
}
|
||||
|
||||
public static function viewport($content)
|
||||
{
|
||||
return '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
|
||||
}
|
||||
|
||||
public static function css($files)
|
||||
{
|
||||
if( !is_array($files) ) {
|
||||
$files = array($files);
|
||||
}
|
||||
|
||||
$links = '';
|
||||
foreach($files as $file) {
|
||||
$links .= '<link rel="stylesheet" type="text/css" href="'.DOMAIN_THEME.$file.'">'.PHP_EOL;
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
public static function javascript($files)
|
||||
{
|
||||
if( !is_array($files) ) {
|
||||
$files = array($files);
|
||||
}
|
||||
|
||||
$scripts = '';
|
||||
foreach($files as $file) {
|
||||
$scripts .= '<script src="'.DOMAIN_THEME.$file.'"></script>'.PHP_EOL;
|
||||
}
|
||||
|
||||
return $scripts;
|
||||
}
|
||||
|
||||
public static function js($files)
|
||||
{
|
||||
return self::javascript($files);
|
||||
}
|
||||
|
||||
public static function plugins($type)
|
||||
{
|
||||
global $plugins;
|
||||
foreach($plugins[$type] as $plugin) {
|
||||
echo call_user_func(array($plugin, $type));
|
||||
}
|
||||
}
|
||||
|
||||
public static function favicon($file='favicon.png', $typeIcon='image/png')
|
||||
{
|
||||
return '<link rel="shortcut icon" href="'.DOMAIN_THEME.$file.'" type="'.$typeIcon.'">'.PHP_EOL;
|
||||
}
|
||||
|
||||
// ---- OLD
|
||||
|
||||
|
||||
|
||||
public static function keywords($keywords, $echo=true)
|
||||
{
|
||||
if(is_array($keywords)) {
|
||||
@ -134,38 +122,6 @@ class Theme {
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function viewport($content='width=device-width, initial-scale=1.0', $echo=true)
|
||||
{
|
||||
$tmp = '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function charset($charset, $echo=true)
|
||||
{
|
||||
$tmp = '<meta charset="'.$charset.'">'.PHP_EOL;
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function plugins($type)
|
||||
{
|
||||
global $plugins;
|
||||
|
||||
foreach($plugins[$type] as $plugin)
|
||||
{
|
||||
echo call_user_func(array($plugin, $type));
|
||||
}
|
||||
}
|
||||
|
||||
public static function jquery($echo=true)
|
||||
{
|
||||
$tmp = '<script src="'.HTML_PATH_ADMIN_THEME_JS.'jquery.min.js'.'"></script>'.PHP_EOL;
|
||||
|
@ -117,7 +117,7 @@ class Login {
|
||||
$this->setLogin($username, $user['role']);
|
||||
|
||||
// Invalidate the current token.
|
||||
$this->dbUsers->generateTokenEmail($username);
|
||||
$this->dbUsers->setTokenEmail($username);
|
||||
|
||||
Log::set(__METHOD__.LOG_SEP.'User logged succeeded by Token-email - Username: '.$username);
|
||||
|
||||
|
@ -18,6 +18,7 @@ class Page {
|
||||
{
|
||||
$filePath = PATH_PAGES.$key.DS.FILENAME;
|
||||
|
||||
// Check if the file exists
|
||||
if( !Sanitize::pathFile($filePath) ) {
|
||||
return false;
|
||||
}
|
||||
@ -25,32 +26,38 @@ class Page {
|
||||
$tmp = 0;
|
||||
$lines = file($filePath);
|
||||
foreach($lines as $lineNumber=>$line) {
|
||||
$parts = array_map('trim', explode(':', $line, 2));
|
||||
// Split the line in 2 parts, limiter by :
|
||||
$parts = explode(':', $line, 2);
|
||||
|
||||
// Lowercase variable
|
||||
// Remove all characters except letters and dash -
|
||||
$parts[0] = preg_replace('/[^A-Za-z\-]/', '', $parts[0]);
|
||||
|
||||
// Lowercase
|
||||
$parts[0] = Text::lowercase($parts[0]);
|
||||
|
||||
// If variables is content then break the foreach and process the content after.
|
||||
if($parts[0]==='content') {
|
||||
// Check if the current line start the content of the page
|
||||
// We have two breakers, the word content or 3 dash ---
|
||||
if( ($parts[0]==='content') || ($parts[0]==='---') ) {
|
||||
$tmp = $lineNumber;
|
||||
break;
|
||||
}
|
||||
|
||||
if( !empty($parts[0]) && !empty($parts[1]) ) {
|
||||
// Sanitize all fields, except Content.
|
||||
$parts[1] = trim($parts[1]);
|
||||
// Sanitize all fields, except the content
|
||||
$this->vars[$parts[0]] = Sanitize::html($parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Process the content
|
||||
if($tmp!==0) {
|
||||
// Next line after "Content:" variable
|
||||
// Next line after "Content:" or "---"
|
||||
$tmp++;
|
||||
|
||||
// Remove lines after Content
|
||||
$output = array_slice($lines, $tmp);
|
||||
|
||||
if(!empty($parts[1])) {
|
||||
if( !empty($parts[1]) ) {
|
||||
array_unshift($output, "\n");
|
||||
array_unshift($output, $parts[1]);
|
||||
}
|
||||
@ -68,6 +75,7 @@ class Page {
|
||||
return($this->vars!==false);
|
||||
}
|
||||
|
||||
// DEPRACTED
|
||||
// Returns the value from the $field, FALSE if the field doesn't exist
|
||||
public function getField($field)
|
||||
{
|
||||
@ -78,6 +86,20 @@ class Page {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getValue($field)
|
||||
{
|
||||
if(isset($this->vars[$field])) {
|
||||
return $this->vars[$field];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDB()
|
||||
{
|
||||
return $this->vars;
|
||||
}
|
||||
|
||||
// Set a field with a value
|
||||
public function setField($field, $value, $overwrite=true)
|
||||
{
|
||||
@ -95,7 +117,7 @@ class Page {
|
||||
public function content($fullContent=true, $noSanitize=true)
|
||||
{
|
||||
// This content is not sanitized.
|
||||
$content = $this->getField('content');
|
||||
$content = $this->getValue('content');
|
||||
|
||||
if(!$fullContent) {
|
||||
return $this->contentBreak();
|
||||
@ -110,7 +132,7 @@ class Page {
|
||||
|
||||
public function contentBreak()
|
||||
{
|
||||
return $this->getField('contentBreak');
|
||||
return $this->getValue('contentBreak');
|
||||
}
|
||||
|
||||
// Returns the raw content
|
||||
@ -119,7 +141,7 @@ class Page {
|
||||
public function contentRaw($noSanitize=true)
|
||||
{
|
||||
// This content is not sanitized.
|
||||
$content = $this->getField('contentRaw');
|
||||
$content = $this->getValue('contentRaw');
|
||||
|
||||
if($noSanitize) {
|
||||
return $content;
|
||||
@ -131,14 +153,14 @@ class Page {
|
||||
// Returns the date according to locale settings and format settings
|
||||
public function date()
|
||||
{
|
||||
return $this->getField('date');
|
||||
return $this->getValue('date');
|
||||
}
|
||||
|
||||
// Returns the date according to locale settings and format as database stored
|
||||
// (string) $format, you can specify the date format
|
||||
public function dateRaw($format=false)
|
||||
{
|
||||
$date = $this->getField('dateRaw');
|
||||
$date = $this->getValue('dateRaw');
|
||||
|
||||
if($format) {
|
||||
return Date::format($date, DB_DATE_FORMAT, $format);
|
||||
@ -149,45 +171,35 @@ class Page {
|
||||
|
||||
// Returns the permalink
|
||||
// (boolean) $absolute, TRUE returns the page link with the DOMAIN, FALSE without the DOMAIN
|
||||
public function permalink($absolute=false)
|
||||
public function permalink($absolute=true)
|
||||
{
|
||||
global $Url;
|
||||
global $Site;
|
||||
|
||||
$url = trim(DOMAIN_BASE,'/');
|
||||
$key = $this->key();
|
||||
$filter = trim($Url->filters('page'), '/');
|
||||
$htmlPath = trim(HTML_PATH_ROOT,'/');
|
||||
|
||||
if(empty($filter)) {
|
||||
$tmp = $key;
|
||||
}
|
||||
else {
|
||||
$tmp = $filter.'/'.$key;
|
||||
}
|
||||
// Get the key of the page
|
||||
$key = $this->getValue('key');
|
||||
|
||||
if($absolute) {
|
||||
return $url.'/'.$tmp;
|
||||
return DOMAIN_PAGES.$key;
|
||||
}
|
||||
|
||||
if(empty($htmlPath)) {
|
||||
return '/'.$tmp;
|
||||
}
|
||||
return HTML_PATH_ROOT.PAGE_URI_FILTER.$key;
|
||||
}
|
||||
|
||||
return '/'.$htmlPath.'/'.$tmp;
|
||||
// Returns the category name
|
||||
public function category()
|
||||
{
|
||||
return $this->categoryMap('name');
|
||||
}
|
||||
|
||||
// Returns the category key
|
||||
public function categoryKey()
|
||||
{
|
||||
return $this->getField('category');
|
||||
return $this->getValue('category');
|
||||
}
|
||||
|
||||
// Returns the field from the array
|
||||
// categoryMap = array( 'name'=>'', 'list'=>array() )
|
||||
public function categoryMap($field)
|
||||
{
|
||||
$map = $this->getField('categoryMap');
|
||||
$map = $this->getValue('categoryMap');
|
||||
|
||||
if($field=='key') {
|
||||
return $this->categoryKey();
|
||||
@ -207,7 +219,7 @@ class Page {
|
||||
public function user($field=false)
|
||||
{
|
||||
// Get the user object.
|
||||
$User = $this->getField('user');
|
||||
$User = $this->getValue('user');
|
||||
|
||||
if($field) {
|
||||
return $User->getField($field);
|
||||
@ -219,13 +231,13 @@ class Page {
|
||||
// Returns the username who created the post/page
|
||||
public function username()
|
||||
{
|
||||
return $this->getField('username');
|
||||
return $this->getValue('username');
|
||||
}
|
||||
|
||||
// Returns the description field
|
||||
public function description()
|
||||
{
|
||||
return $this->getField('description');
|
||||
return $this->getValue('description');
|
||||
}
|
||||
|
||||
|
||||
@ -237,7 +249,7 @@ class Page {
|
||||
// $complete = true : full version
|
||||
public function relativeTime($complete = false) {
|
||||
$current = new DateTime;
|
||||
$past = new DateTime($this->getField('date'));
|
||||
$past = new DateTime($this->getValue('date'));
|
||||
$elapsed = $current->diff($past);
|
||||
|
||||
$elapsed->w = floor($elapsed->d / 7);
|
||||
@ -273,7 +285,7 @@ class Page {
|
||||
// (boolean) $returnsArray, TRUE to get the tags as an array, FALSE to get the tags separeted by comma
|
||||
public function tags($returnsArray=false)
|
||||
{
|
||||
$tags = $this->getField('tags');
|
||||
$tags = $this->getValue('tags');
|
||||
|
||||
if($returnsArray) {
|
||||
if($tags==false) {
|
||||
@ -313,14 +325,13 @@ class Page {
|
||||
// (boolean) $absolute, TRUE returns the absolute path and file name, FALSE just the file name
|
||||
public function coverImage($absolute=true)
|
||||
{
|
||||
$fileName = $this->getField('coverImage');
|
||||
|
||||
$fileName = $this->getValue('coverImage');
|
||||
if(empty($fileName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($absolute) {
|
||||
return HTML_PATH_UPLOADS.$fileName;
|
||||
return DOMAIN_UPLOADS.$fileName;
|
||||
}
|
||||
|
||||
return $fileName;
|
||||
@ -329,54 +340,78 @@ class Page {
|
||||
// Returns TRUE if the content has the text splited
|
||||
public function readMore()
|
||||
{
|
||||
return $this->getField('readMore');
|
||||
return $this->getValue('readMore');
|
||||
}
|
||||
|
||||
public function uuid()
|
||||
{
|
||||
return $this->getField('uuid');
|
||||
return $this->getValue('uuid');
|
||||
}
|
||||
|
||||
// Returns the field key
|
||||
public function key()
|
||||
{
|
||||
return $this->getField('key');
|
||||
return $this->getValue('key');
|
||||
}
|
||||
|
||||
// Returns TRUE if the post/page is published, FALSE otherwise.
|
||||
// (boolean) Returns TRUE if the page is published, FALSE otherwise
|
||||
public function published()
|
||||
{
|
||||
return ($this->getField('status')==='published');
|
||||
return ($this->getValue('status')==='published');
|
||||
}
|
||||
|
||||
// Returns TRUE if the post/page is scheduled, FALSE otherwise.
|
||||
// (boolean) Returns TRUE if the page is scheduled, FALSE otherwise
|
||||
public function scheduled()
|
||||
{
|
||||
return ($this->getField('status')==='scheduled');
|
||||
return ($this->getValue('status')==='scheduled');
|
||||
}
|
||||
|
||||
// Returns TRUE if the post/page is draft, FALSE otherwise.
|
||||
// (boolean) Returns TRUE if the page is draft, FALSE otherwise
|
||||
public function draft()
|
||||
{
|
||||
return ($this->getField('status')=='draft');
|
||||
return ($this->getValue('status')=='draft');
|
||||
}
|
||||
|
||||
// (boolean) Returns TRUE if the page is sticky, FALSE otherwise
|
||||
public function sticky()
|
||||
{
|
||||
return ($this->getValue('status')=='sticky');
|
||||
}
|
||||
|
||||
// (boolean) Returns TRUE if the page is fixed, FALSE otherwise
|
||||
public function fixed()
|
||||
{
|
||||
return ($this->getValue('status')=='fixed');
|
||||
}
|
||||
|
||||
// (string) Returns status of the page
|
||||
public function status()
|
||||
{
|
||||
return $this->getValue('status');
|
||||
}
|
||||
|
||||
// Returns the title field
|
||||
public function title()
|
||||
{
|
||||
return $this->getField('title');
|
||||
return $this->getValue('title');
|
||||
}
|
||||
|
||||
// Returns TRUE if the page has enabled the comments, FALSE otherwise
|
||||
public function allowComments()
|
||||
{
|
||||
return $this->getValue('allowComments');
|
||||
}
|
||||
|
||||
// Returns the page position
|
||||
public function position()
|
||||
{
|
||||
return $this->getField('position');
|
||||
return $this->getValue('position');
|
||||
}
|
||||
|
||||
// Returns the page slug
|
||||
public function slug()
|
||||
{
|
||||
$explode = explode('/', $this->getField('key'));
|
||||
$explode = explode('/', $this->getValue('key'));
|
||||
|
||||
// Check if the page have a parent.
|
||||
if(!empty($explode[1])) {
|
||||
@ -389,7 +424,7 @@ class Page {
|
||||
// Returns the parent key, if the page doesn't have a parent returns FALSE
|
||||
public function parentKey()
|
||||
{
|
||||
$explode = explode('/', $this->getField('key'));
|
||||
$explode = explode('/', $this->getValue('key'));
|
||||
if(isset($explode[1])) {
|
||||
return $explode[0];
|
||||
}
|
||||
@ -413,8 +448,7 @@ class Page {
|
||||
public function children()
|
||||
{
|
||||
$tmp = array();
|
||||
//$paths = glob(PATH_PAGES.$this->getField('key').DS.'*', GLOB_ONLYDIR);
|
||||
$paths = Filesystem::listDirectories(PATH_PAGES.$this->getField('key').DS);
|
||||
$paths = Filesystem::listDirectories(PATH_PAGES.$this->getValue('key').DS);
|
||||
foreach($paths as $path) {
|
||||
array_push($tmp, basename($path));
|
||||
}
|
||||
|
@ -116,6 +116,7 @@ class Url
|
||||
|
||||
public function setWhereAmI($where)
|
||||
{
|
||||
$GLOBALS['WHERE_AM_I'] = $where;
|
||||
$this->whereAmI = $where;
|
||||
}
|
||||
|
||||
@ -127,9 +128,9 @@ class Url
|
||||
public function pageNumber()
|
||||
{
|
||||
if(isset($this->parameters['page'])) {
|
||||
return $this->parameters['page'];
|
||||
return (int)$this->parameters['page'];
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function setNotFound($error=true)
|
||||
|
@ -36,6 +36,11 @@ class User
|
||||
return $this->getField('lastName');
|
||||
}
|
||||
|
||||
public function tokenAuth()
|
||||
{
|
||||
return $this->getField('tokenAuth');
|
||||
}
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->getField('role');
|
||||
|
@ -257,6 +257,16 @@
|
||||
"new-category": "New category",
|
||||
"slug": "slug",
|
||||
"edit-category": "Edit category",
|
||||
"last-page": "Last page",
|
||||
"first-page": "First page"
|
||||
|
||||
"new-theme-configured": "New theme configured",
|
||||
"plugin-configured": "Plugin configured",
|
||||
"new-category-created": "New category created",
|
||||
"new-page-created": "New page created",
|
||||
"page-deleted": "Page deleted",
|
||||
"page-edited": "Page edited",
|
||||
"user-edited": "User edited",
|
||||
"changes-on-settings": "Changes on settings",
|
||||
"plugin-installed": "Plugin installed",
|
||||
"user-password-changed": "User password changed"
|
||||
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
"author": "Bludit",
|
||||
"email": "",
|
||||
"website": "https://plugins.bludit.com",
|
||||
"version": "1.5.2",
|
||||
"releaseDate": "2016-05-28",
|
||||
"version": "2.0",
|
||||
"releaseDate": "2017-05-26",
|
||||
"license": "MIT",
|
||||
"compatible": "1.5.2",
|
||||
"compatible": "2.0",
|
||||
"notes": ""
|
||||
}
|
||||
}
|
@ -15,12 +15,14 @@ class pluginAbout extends Plugin {
|
||||
global $Language;
|
||||
|
||||
$html = '<div>';
|
||||
$html .= '<label>'.$Language->get('Plugin label').'</label>';
|
||||
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
|
||||
$html .= '<label>'.$Language->get('Label').'</label>';
|
||||
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
|
||||
$html .= '<span class="tip">'.$Language->get('Title of the plugin for the sidebar').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$Language->get('About').'</label>';
|
||||
$html .= '<textarea name="text" id="jstext">'.$this->getDbField('text').'</textarea>';
|
||||
$html .= '<textarea name="text" id="jstext">'.$this->getValue('text').'</textarea>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
@ -29,12 +31,12 @@ class pluginAbout extends Plugin {
|
||||
public function siteSidebar()
|
||||
{
|
||||
$html = '<div class="plugin plugin-about">';
|
||||
$html .= '<h2>'.$this->getDbField('label').'</h2>';
|
||||
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
|
||||
$html .= '<div class="plugin-content">';
|
||||
$html .= html_entity_decode(nl2br($this->getDbField('text')));
|
||||
$html .= html_entity_decode(nl2br($this->getValue('text')));
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
"author": "Bludit",
|
||||
"email": "",
|
||||
"website": "https://plugins.bludit.com",
|
||||
"version": "1.5.2",
|
||||
"releaseDate": "2016-05-28",
|
||||
"version": "2.0",
|
||||
"releaseDate": "2017-07-07",
|
||||
"license": "MIT",
|
||||
"compatible": "1.5.2",
|
||||
"compatible": "2.0",
|
||||
"notes": ""
|
||||
}
|
||||
|
@ -2,48 +2,33 @@
|
||||
|
||||
class pluginAPI extends Plugin {
|
||||
|
||||
private $method;
|
||||
|
||||
public function init()
|
||||
{
|
||||
global $Security;
|
||||
|
||||
// This key is used for request such as get the list of all posts and pages
|
||||
$token = md5($Security->key1().time().DOMAIN);
|
||||
// Generate the API Token
|
||||
$token = md5( uniqid().time().DOMAIN );
|
||||
|
||||
$this->dbFields = array(
|
||||
'ping'=>0, // 0 = false, 1 = true
|
||||
'token'=>$token, // Private key
|
||||
'showAllAmount'=>15, // Amount of posts and pages for return
|
||||
'authentication'=>1 // Authentication required
|
||||
'token'=>$token, // API Token
|
||||
'amountOfItems'=>15 // Amount of items to return
|
||||
);
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$html = '';
|
||||
global $Language;
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<p><b>Authorization Key:</b> '.$this->getDbField('token').'</p>';
|
||||
$html .= '<div class="tip">This key is private, do not share it with anyone.</div>';
|
||||
$html = '<div>';
|
||||
$html .= '<label>'.$Language->get('API Token').'</label>';
|
||||
$html .= '<input name="token" type="text" value="'.$this->getValue('token').'">';
|
||||
$html .= '<span class="tip">'.$Language->get('This token is for read only and is regenerated every time you install the plugin').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<p><b>Show all posts:</b> <a href="'.DOMAIN_BASE.'api/show/all/posts/'.$this->getDbField('token').'">'.DOMAIN_BASE.'api/show/all/posts/'.$this->getDbField('token').'</a></p>';
|
||||
$html .= '<div class="tip">Get all posts from this site.</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<p><b>Show all pages:</b> <a href="'.DOMAIN_BASE.'api/show/all/pages/'.$this->getDbField('token').'">'.DOMAIN_BASE.'api/show/all/pages/'.$this->getDbField('token').'</a></p>';
|
||||
$html .= '<div class="tip">Get all pages from this site.</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<p><b>Show post:</b> <a href="'.DOMAIN_BASE.'api/show/post/{POST-NAME}">'.DOMAIN_BASE.'api/show/post/{POST-NAME}</a></p>';
|
||||
$html .= '<div class="tip">Get a particular post, change the {POST-NAME} with the post friendly url.</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<p><b>Show page:</b> <a href="'.DOMAIN_BASE.'api/show/page/{PAGE-NAME}">'.DOMAIN_BASE.'api/show/page/{PAGE-NAME}</a></p>';
|
||||
$html .= '<div class="tip">Get a particular page, change the {PAGE-NAME} with the page friendly url.</div>';
|
||||
$html .= '<label>'.$Language->get('Amount of pages').'</label>';
|
||||
$html .= '<input id="jsamountOfItems" name="amountOfItems" type="text" value="'.$this->getValue('amountOfItems').'">';
|
||||
$html .= '<span class="tip">'.$Language->get('The amount of pages to return when you call to /api/pages').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
@ -53,23 +38,107 @@ class pluginAPI extends Plugin {
|
||||
// API HOOKS
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
public function beforeRulesLoad()
|
||||
public function beforeAll()
|
||||
{
|
||||
global $Url;
|
||||
global $dbPosts;
|
||||
global $dbPages;
|
||||
global $dbUsers;
|
||||
|
||||
// Check if the URI start with /api/
|
||||
$startString = HTML_PATH_ROOT.'api/';
|
||||
$URI = $Url->uri();
|
||||
$length = mb_strlen($startString, CHARSET);
|
||||
if( mb_substr($URI, 0, $length)!=$startString ) {
|
||||
// CHECK URL
|
||||
// ------------------------------------------------------------
|
||||
$URI = $this->webhook('api', $returnsAfterURI=true);
|
||||
if( $URI===false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove the first part of the URI
|
||||
$URI = mb_substr($URI, $length);
|
||||
// METHOD
|
||||
// ------------------------------------------------------------
|
||||
$method = $this->getMethod();
|
||||
|
||||
// INPUTS
|
||||
// ------------------------------------------------------------
|
||||
$inputs = $this->getInputs();
|
||||
|
||||
if( empty($inputs) ) {
|
||||
$this->response(array(
|
||||
'status'=>'1',
|
||||
'message'=>'Missing inputs.'
|
||||
));
|
||||
}
|
||||
|
||||
// PARAMETERS
|
||||
// ------------------------------------------------------------
|
||||
$parameters = $this->getParameters($URI);
|
||||
|
||||
if( empty($parameters) ) {
|
||||
$this->response(array(
|
||||
'status'=>'1',
|
||||
'message'=>'Missing parameters.'
|
||||
));
|
||||
}
|
||||
|
||||
// API TOKEN
|
||||
// ------------------------------------------------------------
|
||||
$tokenAPI = $this->getValue('token');
|
||||
|
||||
// Check empty token
|
||||
if( empty($inputs['token']) ) {
|
||||
$this->response(array(
|
||||
'status'=>'1',
|
||||
'message'=>'Missing API token.'
|
||||
));
|
||||
}
|
||||
|
||||
// Check the token is valid
|
||||
if( $inputs['token']!=$tokenAPI ) {
|
||||
$this->response(array(
|
||||
'status'=>'1',
|
||||
'message'=>'Invalid API token.'
|
||||
));
|
||||
}
|
||||
|
||||
// AUTHENTICATION TOKEN
|
||||
// ------------------------------------------------------------
|
||||
$writePermissions = false;
|
||||
if( !empty($inputs['authentication']) ) {
|
||||
// Get the user with the authentication token
|
||||
$username = $dbUsers->getByAuthToken($inputs['authentication']);
|
||||
if( $username!==false ) {
|
||||
// Enable write permissions
|
||||
$writePermissions = true;
|
||||
}
|
||||
}
|
||||
|
||||
// REQUESTS
|
||||
// ------------------------------------------------------------
|
||||
|
||||
// (GET) /api/pages
|
||||
if( ($method==='GET') && ($parameters[0]==='pages') && empty($parameters[1]) ) {
|
||||
$data = $this->getPages();
|
||||
}
|
||||
// (GET) /api/pages/<key>
|
||||
elseif( ($method==='GET') && ($parameters[0]==='pages') && !empty($parameters[1]) ) {
|
||||
$data = $this->getPage($parameters[1]);
|
||||
}
|
||||
// (POST) /api/pages
|
||||
elseif( ($method==='POST') && ($parameters[0]==='pages') && empty($parameters[1]) && $writePermissions ) {
|
||||
$data = $this->newPage($inputs);
|
||||
}
|
||||
else {
|
||||
$data = array(
|
||||
'status'=>'1',
|
||||
'message'=>'Error: URI not found or Access denied.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->response($data);
|
||||
}
|
||||
|
||||
// PRIVATE METHODS
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
private function getMethod()
|
||||
{
|
||||
// METHODS
|
||||
// ------------------------------------------------------------
|
||||
// GET
|
||||
@ -77,38 +146,14 @@ class pluginAPI extends Plugin {
|
||||
// PUT
|
||||
// DELETE
|
||||
|
||||
$method = $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
// INPUTS
|
||||
// ------------------------------------------------------------
|
||||
// token | authentication token
|
||||
|
||||
$inputs = json_decode(file_get_contents('php://input'),true);
|
||||
|
||||
if( empty($inputs) ) {
|
||||
// Default variables for $input
|
||||
$inputs = array(
|
||||
'token'=>''
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Sanitize inputs
|
||||
foreach( $inputs as $key=>$value ) {
|
||||
if(empty($value)) {
|
||||
$this->response(array(
|
||||
'status'=>'1',
|
||||
'message'=>'Invalid input.'
|
||||
));
|
||||
} else {
|
||||
$inputs[$key] = Sanitize::html($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->method = $_SERVER['REQUEST_METHOD'];
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
private function getParameters($URI)
|
||||
{
|
||||
// PARAMETERS
|
||||
// ------------------------------------------------------------
|
||||
// /api/posts | GET | returns all posts
|
||||
// /api/posts/{key} | GET | returns the post with the {key}
|
||||
// /api/pages | GET | returns all pages
|
||||
// /api/pages/{key} | GET | returns the page with the {key}
|
||||
// /api/cli/regenerate | POST | check for new posts and pages
|
||||
@ -116,150 +161,58 @@ class pluginAPI extends Plugin {
|
||||
$parameters = explode('/', $URI);
|
||||
|
||||
// Sanitize parameters
|
||||
foreach( $parameters as $key=>$value ) {
|
||||
if(empty($value)) {
|
||||
$this->response(array(
|
||||
'status'=>'1',
|
||||
'message'=>'Invalid parameter.'
|
||||
));
|
||||
} else {
|
||||
$parameters[$key] = Sanitize::html($value);
|
||||
}
|
||||
foreach($parameters as $key=>$value) {
|
||||
$parameters[$key] = Sanitize::html($value);
|
||||
}
|
||||
|
||||
// Check authentication
|
||||
if( $this->getDbField('authentication')==1 ) {
|
||||
if( $inputs['token']!=$this->getDbField('token') ) {
|
||||
$this->response(array(
|
||||
'status'=>'1',
|
||||
'message'=>'Invalid token.'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// /api/posts
|
||||
if( ($method==='GET') && ($parameters[0]==='posts') && empty($parameters[1]) ) {
|
||||
$data = $this->getAllPosts();
|
||||
$this->response($data);
|
||||
}
|
||||
// /api/pages
|
||||
elseif( ($method==='GET') && ($parameters[0]==='pages') && empty($parameters[1]) ) {
|
||||
$data = $this->getAllPages();
|
||||
$this->response($data);
|
||||
}
|
||||
// /api/posts/{key}
|
||||
elseif( ($method==='GET') && ($parameters[0]==='posts') && !empty($parameters[1]) ) {
|
||||
$data = $this->getPost($parameters[1]);
|
||||
$this->response($data);
|
||||
}
|
||||
// /api/pages/{key}
|
||||
elseif( ($method==='GET') && ($parameters[0]==='pages') && !empty($parameters[1]) ) {
|
||||
$data = $this->getPage($parameters[1]);
|
||||
$this->response($data);
|
||||
}
|
||||
// /api/cli/regenerate
|
||||
elseif( ($method==='POST') && ($parameters[0]==='cli') && ($parameters[1]==='regenerate') ) {
|
||||
|
||||
// Regenerate posts
|
||||
if( $dbPosts->cliMode() ) {
|
||||
reIndexTagsPosts();
|
||||
}
|
||||
|
||||
// Regenerate pages
|
||||
$dbPages->cliMode();
|
||||
|
||||
$this->response(array(
|
||||
'status'=>'0',
|
||||
'message'=>'Pages and post regenerated.'
|
||||
));
|
||||
}
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
// FUNCTIONS
|
||||
// ----------------------------------------------------------------------------
|
||||
private function getInputs()
|
||||
{
|
||||
switch($this->method) {
|
||||
case "POST":
|
||||
$inputs = $_POST;
|
||||
break;
|
||||
case "GET":
|
||||
case "DELETE":
|
||||
$inputs = $_GET;
|
||||
break;
|
||||
case "PUT":
|
||||
$inputs = file_get_contents("php://input");
|
||||
break;
|
||||
default:
|
||||
$inputs = json_encode(array());
|
||||
break;
|
||||
}
|
||||
|
||||
return $this->cleanInputs($inputs);
|
||||
}
|
||||
|
||||
private function cleanInputs($inputs)
|
||||
{
|
||||
$tmp = array();
|
||||
if( is_array($inputs) ) {
|
||||
foreach($inputs as $key=>$value) {
|
||||
$tmp[$key] = Sanitize::html($value);
|
||||
}
|
||||
}
|
||||
elseif( is_string($inputs) ) {
|
||||
$tmp = json_decode($inputs, true);
|
||||
if(json_last_error()===0) {
|
||||
$tmp = array();
|
||||
}
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
private function response($data=array())
|
||||
{
|
||||
$json = json_encode($data);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
exit($json);
|
||||
}
|
||||
|
||||
private function ping()
|
||||
{
|
||||
if($this->getDbField('ping')) {
|
||||
|
||||
// Get the authentication key
|
||||
$token = $this->getDbField('token');
|
||||
|
||||
$url = 'https://api.bludit.com/ping?token='.$token.'&url='.DOMAIN_BASE;
|
||||
|
||||
// Check if curl is installed
|
||||
if( function_exists('curl_version') ) {
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
$out = curl_exec($ch);
|
||||
|
||||
if($out === false) {
|
||||
Log::set('Plugin API : '.'Curl error: '.curl_error($ch));
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
}
|
||||
else {
|
||||
$options = array(
|
||||
"ssl"=>array(
|
||||
"verify_peer"=>false,
|
||||
"verify_peer_name"=>false
|
||||
)
|
||||
);
|
||||
|
||||
$stream = stream_context_create($options);
|
||||
$out = file_get_contents($url, false, $stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPost($key)
|
||||
{
|
||||
// Generate the object Post
|
||||
$Post = buildPost($key);
|
||||
|
||||
if(!$Post) {
|
||||
return array(
|
||||
'status'=>'1',
|
||||
'message'=>'Post not found.'
|
||||
);
|
||||
}
|
||||
|
||||
$data['status'] = '0';
|
||||
$data['message'] = '';
|
||||
$data['data'] = $Post->json( $returnsArray=true );
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getAllPosts()
|
||||
{
|
||||
$posts = buildPostsForPage(0, $this->getDbField('showAllAmount'), true, false);
|
||||
|
||||
$tmp = array(
|
||||
'status'=>'0',
|
||||
'message'=>'',
|
||||
'data'=>array()
|
||||
);
|
||||
|
||||
foreach($posts as $Post) {
|
||||
array_push($tmp['data'], $Post->json( $returnsArray=true ));
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
private function getPage($key)
|
||||
{
|
||||
// Generate the object Page
|
||||
@ -272,30 +225,44 @@ class pluginAPI extends Plugin {
|
||||
);
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['status'] = '0';
|
||||
$data['message'] = '';
|
||||
$data['message'] = 'Page filtered by key: '.$key;
|
||||
$data['data'] = $Page->json( $returnsArray=true );
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getAllPages()
|
||||
private function getPages()
|
||||
{
|
||||
$pages = buildAllPages();
|
||||
global $dbPages;
|
||||
|
||||
$onlyPublished = true;
|
||||
$amountOfItems = $this->getValue('amountOfItems');
|
||||
$pageNumber = 1;
|
||||
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
|
||||
$tmp = array(
|
||||
'status'=>'0',
|
||||
'message'=>'',
|
||||
'message'=>'List of pages, amount of items: '.$amountOfItems,
|
||||
'data'=>array()
|
||||
);
|
||||
|
||||
foreach($pages as $Page) {
|
||||
if($Page->published()) {
|
||||
array_push($tmp['data'], $Page->json( $returnsArray=true ));
|
||||
}
|
||||
// Get keys of pages
|
||||
$keys = array_keys($list);
|
||||
foreach($keys as $pageKey) {
|
||||
// Create the page object from the page key
|
||||
$page = buildPage($pageKey);
|
||||
array_push($tmp['data'], $page->json( $returnsArray=true ));
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
private function createPage($args)
|
||||
{
|
||||
// This function is defined on functions.php
|
||||
return createPage($args);
|
||||
}
|
||||
|
||||
}
|
7
bl-plugins/categories/languages/en_US.json
Normal file
7
bl-plugins/categories/languages/en_US.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Categories",
|
||||
"description": "Shows all categories."
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
"author": "Bludit",
|
||||
"email": "",
|
||||
"website": "https://plugins.bludit.com",
|
||||
"version": "1.5.2",
|
||||
"releaseDate": "2016-05-28",
|
||||
"version": "2.0",
|
||||
"releaseDate": "2017-05-26",
|
||||
"license": "MIT",
|
||||
"compatible": "1.5.2",
|
||||
"compatible": "2.0",
|
||||
"notes": ""
|
||||
}
|
||||
}
|
68
bl-plugins/categories/plugin.php
Normal file
68
bl-plugins/categories/plugin.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
class pluginCategories extends Plugin {
|
||||
|
||||
public function init()
|
||||
{
|
||||
// Fields and default values for the database of this plugin
|
||||
$this->dbFields = array(
|
||||
'label'=>'Categories',
|
||||
'showCero'=>false
|
||||
);
|
||||
}
|
||||
|
||||
// Method called on the settings of the plugin on the admin area
|
||||
public function form()
|
||||
{
|
||||
global $Language;
|
||||
|
||||
$html = '<div>';
|
||||
$html .= '<label>'.$Language->get('Label').'</label>';
|
||||
$html .= '<input name="label" type="text" value="'.$this->getValue('label').'">';
|
||||
$html .= '<span class="tip">'.$Language->get('Title of the plugin for the sidebar').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$Language->get('Categories without content').'</label>';
|
||||
$html .= '<select name="showCero">';
|
||||
$html .= '<option value="true" '.($this->getValue('showCero')===true?'selected':'').'>Enabled</option>';
|
||||
$html .= '<option value="false" '.($this->getValue('showCero')===false?'selected':'').'>Disabled</option>';
|
||||
$html .= '</select>';
|
||||
$html .= '<span class="tip">'.$Language->get('Show the categories without content').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
// Method called on the sidebar of the website
|
||||
public function siteSidebar()
|
||||
{
|
||||
global $Language;
|
||||
global $dbCategories;
|
||||
|
||||
// HTML for sidebar
|
||||
$html = '<div class="plugin plugin-categories">';
|
||||
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
|
||||
$html .= '<div class="plugin-content">';
|
||||
$html .= '<ul>';
|
||||
|
||||
// By default the database of categories are alphanumeric sorted
|
||||
foreach( $dbCategories->db as $key=>$fields ) {
|
||||
$count = count($fields['list']);
|
||||
if($this->getValue('showCero') || $count>0) {
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="'.DOMAIN_CATEGORIES.$key.'">';
|
||||
$html .= $fields['name'];
|
||||
$html .= ' ('.count($fields['list']).')';
|
||||
$html .= '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
"author": "Bludit",
|
||||
"email": "",
|
||||
"website": "https://plugins.bludit.com",
|
||||
"version": "1.5.2",
|
||||
"releaseDate": "2016-05-28",
|
||||
"version": "2.0",
|
||||
"releaseDate": "2017-05-26",
|
||||
"license": "MIT",
|
||||
"compatible": "1.5.2",
|
||||
"compatible": "2.0",
|
||||
"notes": ""
|
||||
}
|
||||
}
|
@ -2,121 +2,51 @@
|
||||
|
||||
class pluginDisqus extends Plugin {
|
||||
|
||||
private $enable;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->dbFields = array(
|
||||
'shortname'=>'',
|
||||
'enablePages'=>0,
|
||||
'enablePosts'=>0,
|
||||
'enableDefaultHomePage'=>1
|
||||
'shortname'=>''
|
||||
);
|
||||
}
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
global $Url;
|
||||
|
||||
$this->enable = false;
|
||||
|
||||
if( $this->getDbField('enablePosts') && ($Url->whereAmI()=='post') ) {
|
||||
$this->enable = true;
|
||||
}
|
||||
elseif( $this->getDbField('enablePages') && ($Url->whereAmI()=='page') ) {
|
||||
$this->enable = true;
|
||||
}
|
||||
elseif( $this->getDbField('enableDefaultHomePage') && ($Url->whereAmI()=='home') )
|
||||
{
|
||||
$this->enable = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
global $Language;
|
||||
|
||||
$html = '<div>';
|
||||
$html .= '<label>'.$Language->get('Disqus shortname').'</label>';
|
||||
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getDbField('shortname').'">';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<input type="hidden" name="enablePages" value="0">';
|
||||
$html .= '<input name="enablePages" id="jsenablePages" type="checkbox" value="1" '.($this->getDbField('enablePages')?'checked':'').'>';
|
||||
$html .= '<label class="forCheckbox" for="jsenablePages">'.$Language->get('Enable Disqus on pages').'</label>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<input type="hidden" name="enablePosts" value="0">';
|
||||
$html .= '<input name="enablePosts" id="jsenablePosts" type="checkbox" value="1" '.($this->getDbField('enablePosts')?'checked':'').'>';
|
||||
$html .= '<label class="forCheckbox" for="jsenablePosts">'.$Language->get('Enable Disqus on posts').'</label>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<input type="hidden" name="enableDefaultHomePage" value="0">';
|
||||
$html .= '<input name="enableDefaultHomePage" id="jsenableDefaultHomePage" type="checkbox" value="1" '.($this->getDbField('enableDefaultHomePage')?'checked':'').'>';
|
||||
$html .= '<label class="forCheckbox" for="jsenableDefaultHomePage">'.$Language->get('Enable Disqus on default home page').'</label>';
|
||||
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getValue('shortname').'">';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function postEnd()
|
||||
{
|
||||
if( $this->enable ) {
|
||||
return '<div id="disqus_thread"></div>';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function pageEnd()
|
||||
{
|
||||
global $Url;
|
||||
global $page;
|
||||
|
||||
// Bludit check not-found page after the plugin method construct.
|
||||
// It's necesary check here the page not-found.
|
||||
if( ($page->key()!='error') && ($page->allowComments()) ) {
|
||||
$html = '<div id="disqus_thread"></div>';
|
||||
$html .= '<script type="text/javascript">
|
||||
var disqus_config = function () {
|
||||
this.page.url = "'.$page->permalink().'";
|
||||
this.page.identifier = "'.$page->uuid().'";
|
||||
};
|
||||
|
||||
if( $this->enable && !$Url->notFound()) {
|
||||
return '<div id="disqus_thread"></div>';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function siteHead()
|
||||
{
|
||||
if( $this->enable ) {
|
||||
return '<style>#disqus_thread { margin: 20px 0 }</style>';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function siteBodyEnd()
|
||||
{
|
||||
if( $this->enable ) {
|
||||
|
||||
$html = '
|
||||
<script type="text/javascript">
|
||||
|
||||
var disqus_shortname = "'.$this->getDbField('shortname').'";
|
||||
|
||||
(function() {
|
||||
var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
|
||||
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
|
||||
(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
|
||||
})();
|
||||
|
||||
</script>
|
||||
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>';
|
||||
(function() {
|
||||
var d = document, s = d.createElement("script");
|
||||
s.src = "https://'.$this->getValue('shortname').'.disqus.com/embed.js";
|
||||
s.setAttribute("data-timestamp", +new Date());
|
||||
(d.head || d.body).appendChild(s);
|
||||
})();
|
||||
</script>
|
||||
|
||||
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
||||
';
|
||||
return $html;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
11
bl-plugins/fixedPages/languages/en_US.json
Normal file
11
bl-plugins/fixedPages/languages/en_US.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Fixed pages",
|
||||
"description": "Shows a list of pages, you can define the amount of items and the order depends of settings."
|
||||
},
|
||||
|
||||
"home-page": "Home page",
|
||||
"show-home-link": "Show home link",
|
||||
"amount-of-items": "Amount of items"
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
"author": "Bludit",
|
||||
"email": "",
|
||||
"website": "https://plugins.bludit.com",
|
||||
"version": "1.5.2",
|
||||
"releaseDate": "2016-05-28",
|
||||
"version": "2.0",
|
||||
"releaseDate": "2017-05-26",
|
||||
"license": "MIT",
|
||||
"compatible": "1.5.2",
|
||||
"compatible": "2.0",
|
||||
"notes": ""
|
||||
}
|
||||
}
|
80
bl-plugins/fixedPages/plugin.php
Normal file
80
bl-plugins/fixedPages/plugin.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
class pluginFixedPages extends Plugin {
|
||||
|
||||
public function init()
|
||||
{
|
||||
// Fields and default values for the database of this plugin
|
||||
$this->dbFields = array(
|
||||
'label'=>'Fixed Pages',
|
||||
'homeLink'=>true
|
||||
);
|
||||
}
|
||||
|
||||
// Method called on the settings of the plugin on the admin area
|
||||
public function form()
|
||||
{
|
||||
global $Language;
|
||||
|
||||
$html = '<div>';
|
||||
$html .= '<label>'.$Language->get('Label').'</label>';
|
||||
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
|
||||
$html .= '<span class="tip">'.$Language->get('Title of the plugin for the sidebar').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$Language->get('Home link').'</label>';
|
||||
$html .= '<select name="homeLink">';
|
||||
$html .= '<option value="true" '.($this->getValue('showCero')?'checked':'').'>Enabled</option>';
|
||||
$html .= '<option value="false" '.($this->getValue('showCero')?'checked':'').'>Disabled</option>';
|
||||
$html .= '</select>';
|
||||
$html .= '<span class="tip">'.$Language->get('Show the home link on the sidebar').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
// Method called on the sidebar of the website
|
||||
public function siteSidebar()
|
||||
{
|
||||
global $Language;
|
||||
global $Url;
|
||||
global $Site;
|
||||
global $dbPages;
|
||||
|
||||
$pages = $dbPages->getFixedDB();
|
||||
|
||||
// HTML for sidebar
|
||||
$html = '<div class="plugin plugin-pages">';
|
||||
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
|
||||
$html .= '<div class="plugin-content">';
|
||||
$html .= '<ul>';
|
||||
|
||||
// Show Home page link
|
||||
if( $this->getValue('homeLink') ) {
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="'.$Site->url().'">';
|
||||
$html .= $Language->get('Home page');
|
||||
$html .= '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
// Get keys of pages
|
||||
$keys = array_keys($pages);
|
||||
foreach($keys as $pageKey) {
|
||||
// Create the page object from the page key
|
||||
$page = buildPage($pageKey);
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="'.$page->permalink().'">';
|
||||
$html .= $page->title();
|
||||
$html .= '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Google Tools",
|
||||
"name": "Google",
|
||||
"description": "This plugin generate the meta tag to validate your site with Google Webmasters Tools and the JavaScript code to track your site with Google Analytics."
|
||||
},
|
||||
|
10
bl-plugins/google/metadata.json
Normal file
10
bl-plugins/google/metadata.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"author": "Bludit",
|
||||
"email": "",
|
||||
"website": "https://plugins.bludit.com",
|
||||
"version": "2.0",
|
||||
"releaseDate": "2017-05-26",
|
||||
"license": "MIT",
|
||||
"compatible": "2.0",
|
||||
"notes": ""
|
||||
}
|
100
bl-plugins/google/plugin.php
Normal file
100
bl-plugins/google/plugin.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
class pluginGoogle extends Plugin {
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->dbFields = array(
|
||||
'google-analytics-tracking-id'=>'',
|
||||
'google-site-verification'=>'',
|
||||
'google-tag-manager'=>''
|
||||
);
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
global $Language;
|
||||
|
||||
$html = '<div>';
|
||||
$html .= '<label for="jsgoogle-site-verification">'.$Language->get('Google Webmasters tools').'</label>';
|
||||
$html .= '<input id="jsgoogle-site-verification" type="text" name="google-site-verification" value="'.$this->getDbField('google-site-verification').'">';
|
||||
$html .= '<span class="tip">'.$Language->get('complete-this-field-with-the-google-site-verification').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label for="jstracking-id">'.$Language->get('Google Analytics Tracking ID').'</label>';
|
||||
$html .= '<input id="jsgoogle-analytics-tracking-id" type="text" name="google-analytics-tracking-id" value="'.$this->getDbField('google-analytics-tracking-id').'">';
|
||||
$html .= '<span class="tip">'.$Language->get('complete-this-field-with-the-tracking-id').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label for="jsgoogle-tag-manager">'.$Language->get('Google Tag Manager').'</label>';
|
||||
$html .= '<input id="jsgoogle-tag-manager" type="text" name="google-tag-manager" value="'.$this->getDbField('google-tag-manager').'">';
|
||||
$html .= '<span class="tip">'.$Language->get('complete-this-field-with-the-tracking-id-google-tag').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function siteHead()
|
||||
{
|
||||
global $Url;
|
||||
global $WHERE_AM_I;
|
||||
|
||||
$html = '';
|
||||
|
||||
// Google HTML tag
|
||||
if( $this->getValue('google-site-verification') && ($WHERE_AM_I=='home') ) {
|
||||
$html .= PHP_EOL.'<!-- Google HTML tag -->'.PHP_EOL;
|
||||
$html .= '<meta name="google-site-verification" content="'.$this->getDbField('google-site-verification').'" />'.PHP_EOL;
|
||||
}
|
||||
|
||||
// Google Tag Manager
|
||||
if( $this->getValue('google-tag-manager') ) {
|
||||
$html .= PHP_EOL."<!-- Google Tag Manager -->".PHP_EOL;
|
||||
$html .= "<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':".PHP_EOL;
|
||||
$html .= "new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],".PHP_EOL;
|
||||
$html .= "j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=".PHP_EOL;
|
||||
$html .= "'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);".PHP_EOL;
|
||||
$html .= "})(window,document,'script','dataLayer','".$this->getValue('google-tag-manager')."');</script>".PHP_EOL;
|
||||
$html .= "<!-- End Google Tag Manager -->".PHP_EOL;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function siteBodyBegin()
|
||||
{
|
||||
$html = '';
|
||||
|
||||
// Google Tag Manager
|
||||
if( $this->getValue('google-tag-manager') ) {
|
||||
$html .= '<!-- Google Tag Manager (noscript) -->'.PHP_EOL;
|
||||
$html .= '<noscript><iframe src="https://www.googletagmanager.com/ns.html?id='.$this->getValue('google-tag-manager').'" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>'.PHP_EOL;
|
||||
$html .= '<!-- End Google Tag Manager (noscript) -->'.PHP_EOL;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function siteBodyEnd()
|
||||
{
|
||||
$html = '';
|
||||
|
||||
// Google Analytics
|
||||
if( $this->getValue('google-analytics-tracking-id') ) {
|
||||
$html .= PHP_EOL.'<!-- Google Analytics -->'.PHP_EOL;
|
||||
$html .= "<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', '".$this->getValue('google-analytics-tracking-id')."', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>".PHP_EOL;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
class pluginGoogleTools extends Plugin {
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->dbFields = array(
|
||||
'tracking-id'=>'',
|
||||
'google-site-verification'=>'',
|
||||
'google-tag-manager'=>''
|
||||
);
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
global $Language;
|
||||
|
||||
$html = '<div>';
|
||||
$html .= '<label for="jsgoogle-site-verification">'.$Language->get('Google Webmasters tools').'</label>';
|
||||
$html .= '<input id="jsgoogle-site-verification" type="text" name="google-site-verification" value="'.$this->getDbField('google-site-verification').'">';
|
||||
$html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-google-site-verification').'</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label for="jstracking-id">'.$Language->get('Google Analytics Tracking ID').'</label>';
|
||||
$html .= '<input id="jstracking-id" type="text" name="tracking-id" value="'.$this->getDbField('tracking-id').'">';
|
||||
$html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-tracking-id').'</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label for="jsgoogle-tag-manager">'.$Language->get('Google Tag Manager').'</label>';
|
||||
$html .= '<input id="jsgoogle-tag-manager" type="text" name="google-tag-manager" value="'.$this->getDbField('google-tag-manager').'">';
|
||||
$html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-tracking-id-google-tag').'</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function siteHead()
|
||||
{
|
||||
global $Url;
|
||||
|
||||
$html = '';
|
||||
|
||||
if((!Text::isEmpty($this->getDbField('google-site-verification'))) && ($Url->whereAmI()=='home')) {
|
||||
$html .= PHP_EOL.'<!-- Google Webmasters Tools -->'.PHP_EOL;
|
||||
$html .= '<meta name="google-site-verification" content="'.$this->getDbField('google-site-verification').'">'.PHP_EOL;
|
||||
}
|
||||
|
||||
if(!(Text::isEmpty($this->getDbField('google-tag-manager')))) {
|
||||
$html .= PHP_EOL."<!-- Google Tag Manager -->".PHP_EOL;
|
||||
$html .= "<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':".PHP_EOL;
|
||||
$html .= "new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],".PHP_EOL;
|
||||
$html .= "j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=".PHP_EOL;
|
||||
$html .= "'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);".PHP_EOL;
|
||||
$html .= "})(window,document,'script','dataLayer','".$this->getDbField('google-tag-manager')."');</script>".PHP_EOL;
|
||||
$html .= "<!-- End Google Tag Manager -->".PHP_EOL;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function siteBodyBegin()
|
||||
{
|
||||
if((Text::isEmpty($this->getDbField('google-tag-manager')))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$html = '<!-- Google Tag Manager (noscript) -->'.PHP_EOL;
|
||||
$html .= '<noscript><iframe src="https://www.googletagmanager.com/ns.html?id='.$this->getDbField('google-tag-manager').'" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>'.PHP_EOL;
|
||||
$html .= '<!-- End Google Tag Manager (noscript) -->'.PHP_EOL;
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function siteBodyEnd()
|
||||
{
|
||||
$html = PHP_EOL.'<!-- Google Analytics -->'.PHP_EOL;
|
||||
$html .= "<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', '".$this->getDbField('tracking-id')."', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>".PHP_EOL;
|
||||
|
||||
if(Text::isEmpty($this->getDbField('tracking-id'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Последни публикации",
|
||||
"description": "Показва най-новите публикации."
|
||||
},
|
||||
|
||||
"amount-of-posts": "Брой последни публикации",
|
||||
"show-home-link": "Покажи връзка за начало"
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Neueste Beiträge",
|
||||
"description": "Anzeige der neuesten Beiträge."
|
||||
},
|
||||
|
||||
"amount-of-posts": "Anzahl der Beiträge"
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user