Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Dipchikov 2016-01-22 09:16:34 +02:00
commit 08104ed3c4
333 changed files with 14334 additions and 2577 deletions

10
.gitignore vendored
View File

@ -1,7 +1,5 @@
.DS_Store
!themes/pure
themes/*
content/databases
content/pages
content/posts
content/uploads
bl-content/databases
bl-content/pages
bl-content/posts
bl-content/uploads

View File

@ -1,8 +1,8 @@
[Bludit](http://www.bludit.com/) — Flat file CMS
================================================
Create your own Blog in seconds.
[Bludit](http://www.bludit.com/)
================================
**Fast**, **simple**, **extensible** and **flat file** CMS.
Fast, simple, extensible and Flat file CMS.
Bludit is a simple web application to make your own **blog** or **site** in seconds, it's completly **free and open source**. Bludit uses flat-files (text files in JSON format) to store the posts and pages, you don't need to install or configure a database.
- [Documentation](http://docs.bludit.com)
- [Help and Support](http://forum.bludit.com)
@ -10,13 +10,13 @@ Fast, simple, extensible and Flat file CMS.
- [Themes](https://github.com/dignajar/bludit-themes)
- [More plugins and themes](http://forum.bludit.com/viewforum.php?f=14)
Social
------
Social networks
---------------
- [Twitter](https://twitter.com/bludit)
- [Facebook](https://www.facebook.com/bluditcms)
- [Google+](https://plus.google.com/+Bluditcms)
- [Freenode IRC](https://webchat.freenode.net) channel #bludit
- [Freenode IRC](https://webchat.freenode.net) channel **#bludit**
[![Join the chat at https://gitter.im/dignajar/bludit](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dignajar/bludit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

View File

@ -1,13 +1,90 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
class Post extends fileContent
{
function __construct($key)
{
// Database Key
$this->setField('key', $key);
class Content {
public $vars;
function __construct($path)
{
if($this->build($path)===false) {
$this->vars = false;
}
}
// Return true if valid
public function isValid()
{
return($this->vars!==false);
}
public function getField($field)
{
if(isset($this->vars[$field])) {
return $this->vars[$field];
}
return false;
}
// $notoverwrite true if you don't want to replace the value if are set previusly
public function setField($field, $value, $overwrite=true)
{
if($overwrite || empty($this->vars[$field])) {
$this->vars[$field] = $value;
}
return true;
}
private function build($path)
{
if( !Sanitize::pathFile($path, 'index.txt') ) {
return false;
}
$tmp = 0;
$lines = file($path.'index.txt');
foreach($lines as $lineNumber=>$line)
{
$parts = array_map('trim', explode(':', $line, 2));
// Lowercase variable
$parts[0] = Text::lowercase($parts[0]);
// If variables is content then break the foreach and process the content after.
if($parts[0]==='content')
{
$tmp = $lineNumber;
break;
}
if( !empty($parts[0]) && !empty($parts[1]) ) {
// Sanitize all fields, except Content.
$this->vars[$parts[0]] = Sanitize::html($parts[1]);
}
}
// Process the content.
if($tmp!==0)
{
// Next line after "Content:" variable
$tmp++;
// Remove lines after Content
$output = array_slice($lines, $tmp);
if(!empty($parts[1])) {
array_unshift($output, "\n");
array_unshift($output, $parts[1]);
}
$implode = implode($output);
$this->vars['content'] = $implode;
// Sanitize content.
//$this->vars['content'] = Sanitize::html($implode);
}
parent::__construct(PATH_POSTS.$key.DS);
}
// Returns the post title.
@ -78,9 +155,19 @@ class Post extends fileContent
return ($this->getField('status')=='draft');
}
public function username()
public function coverImage($absolute=true)
{
return $this->getField('username');
$fileName = $this->getField('coverImage');
if(empty($fileName)) {
return false;
}
if($absolute) {
return HTML_PATH_UPLOADS.$fileName;
}
return $fileName;
}
public function profilePicture()
@ -88,14 +175,22 @@ class Post extends fileContent
return HTML_PATH_UPLOADS_PROFILES.$this->username().'.jpg';
}
public function authorFirstName()
// Returns the user object if $field is false, otherwise returns the field's value.
public function user($field=false)
{
return $this->getField('authorFirstName');
// Get the user object.
$User = $this->getField('user');
if($field) {
return $User->getField($field);
}
return $User;
}
public function authorLastName()
public function username()
{
return $this->getField('authorLastName');
return $this->getField('username');
}
public function description()
@ -104,7 +199,7 @@ class Post extends fileContent
}
// Returns the post date according to locale settings and format settings.
public function date($format=false)
public function date()
{
return $this->getField('date');
}
@ -145,19 +240,16 @@ class Post extends fileContent
}
}
public function slug()
{
return $this->getField('key');
}
public function permalink($absolute=false)
{
global $Url;
global $Site;
$url = trim($Site->url(),'/');
$filterType = $this->getField('filterType');
$url = trim(DOMAIN_BASE,'/');
$key = $this->key();
$filter = trim($Url->filters('post'), '/');
$filter = trim($Url->filters($filterType), '/');
$htmlPath = trim(HTML_PATH_ROOT,'/');
if(empty($filter)) {
@ -178,4 +270,5 @@ class Post extends fileContent
return '/'.$htmlPath.'/'.$tmp;
}
}

View File

@ -40,10 +40,6 @@ class dbJSON
$this->dbBackup = $array;
}
}
else
{
Log::set(__METHOD__.LOG_SEP.'File '.$file.' does not exists');
}
}
public function restoreDB()
@ -58,6 +54,7 @@ class dbJSON
return count($this->db);
}
// Returns the value from the field.
public function getField($field)
{
if(isset($this->db[$field])) {
@ -86,24 +83,24 @@ class dbJSON
return file_put_contents($this->file, $data, LOCK_EX);
}
// Returns a JSON encoded string on success or FALSE on failure.
private function serialize($data)
{
// DEBUG: La idea es siempre serializar en json, habria que ver si siempre esta cargado json_enconde y decode
if(JSON) {
return json_encode($data, JSON_PRETTY_PRINT);
}
return serialize($data);
return json_encode($data, JSON_PRETTY_PRINT);
}
// Returns the value encoded in json in appropriate PHP type.
private function unserialize($data)
{
// DEBUG: La idea es siempre serializar en json, habria que ver si siempre esta cargado json_enconde y decode
if(JSON) {
return json_decode($data, true);
// NULL is returned if the json cannot be decoded.
$decode = json_decode($data, true);
// If NULL returns false.
if(empty($decode)) {
return false;
}
return unserialize($data);
return $decode;
}
}

View File

@ -8,6 +8,8 @@ class Plugin {
// (string) Database path and filename
public $filenameDb;
public $filenameMetadata;
// (array) Database unserialized
public $db;
@ -18,20 +20,10 @@ class Plugin {
public $className;
// (array) Plugin's information.
public $data;
public $metadata;
function __construct()
{
$this->data = array(
'name'=>'',
'description'=>'',
'author'=>'',
'email'=>'',
'website'=>'',
'version'=>'',
'releaseDate'=>''
);
$this->dbFields = array();
$reflector = new ReflectionClass(get_class($this));
@ -50,7 +42,12 @@ class Plugin {
$this->filenameDb = PATH_PLUGINS_DATABASES.$this->directoryName.DS.'db.php';
// If the plugin installed then get the database.
// --- Metadata ---
$this->filenameMetadata = PATH_PLUGINS.$this->directoryName().DS.'metadata.json';
$metadataString = file_get_contents($this->filenameMetadata);
$this->metadata = json_decode($metadataString, true);
// If the plugin is installed then get the database.
if($this->installed())
{
$Tmp = new dbJSON($this->filenameDb);
@ -63,19 +60,30 @@ class Plugin {
return HTML_PATH_PLUGINS.$this->directoryName.'/';
}
// Returns the item from plugin-data.
public function getData($key)
public function phpPath()
{
if(isset($this->data[$key])) {
return $this->data[$key];
return PATH_PLUGINS.$this->directoryName.DS;
}
public function phpPathDB()
{
return PATH_PLUGINS_DATABASES.$this->directoryName.DS;
}
// Returns the item from plugin-data.
public function getMetadata($key)
{
if(isset($this->metadata[$key])) {
return $this->metadata[$key];
}
return '';
}
public function setData($array)
public function setMetadata($key, $value)
{
$this->data = $array;
$this->metadata[$key] = $value;
return true;
}
public function getDbField($key, $html=true)
@ -114,37 +122,37 @@ class Plugin {
public function name()
{
return $this->getData('name');
return $this->getMetadata('name');
}
public function description()
{
return $this->getData('description');
return $this->getMetadata('description');
}
public function author()
{
return $this->getData('author');
return $this->getMetadata('author');
}
public function email()
{
return $this->getData('email');
return $this->getMetadata('email');
}
public function website()
{
return $this->getData('website');
return $this->getMetadata('website');
}
public function version()
{
return $this->getData('version');
return $this->getMetadata('version');
}
public function releaseDate()
{
return $this->getData('releaseDate');
return $this->getMetadata('releaseDate');
}
public function className()
@ -176,7 +184,13 @@ class Plugin {
public function uninstall()
{
unlink($this->filenameDb);
// Delete all files.
$files = Filesystem::listFiles( $this->phpPathDB() );
foreach($files as $file) {
unlink($file);
}
// Delete the directory.
rmdir(PATH_PLUGINS_DATABASES.$this->directoryName);
}
@ -191,4 +205,4 @@ class Plugin {
// The user can define your own dbFields.
}
}
}

View File

@ -23,4 +23,4 @@ if($Login->role()!=='admin') {
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================

View File

@ -6,11 +6,31 @@
function updateBludit()
{
global $Site;
global $dbPosts;
// Check if Bludit need to be update.
if($Site->currentBuild() < BLUDIT_BUILD)
if( ($Site->currentBuild() < BLUDIT_BUILD) || isset($_GET['update']) )
{
$directories = array(PATH_POSTS, PATH_PAGES, PATH_PLUGINS_DATABASES, PATH_UPLOADS_PROFILES);
// --- Update dates ---
foreach($dbPosts->db as $key=>$post)
{
$date = Date::format($post['date'], 'Y-m-d H:i', DB_DATE_FORMAT);
if($date !== false) {
$dbPosts->setPostDb($key,'date',$date);
}
}
$dbPosts->save();
// --- Update directories ---
$directories = array(
PATH_POSTS,
PATH_PAGES,
PATH_PLUGINS_DATABASES,
PATH_UPLOADS_PROFILES,
PATH_UPLOADS_THUMBNAILS,
PATH_TMP
);
foreach($directories as $dir)
{
@ -23,6 +43,8 @@ function updateBludit()
// Set and save the database.
$Site->set(array('currentBuild'=>BLUDIT_BUILD));
Log::set('updateBludit'.LOG_SEP.'System updated');
}
}

View File

@ -1,5 +1,9 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
@ -13,11 +17,17 @@ function editPage($args)
$args['parent'] = NO_PARENT_CHAR;
}
// Edit the page.
if( $dbPages->edit($args) )
// Add the page, if the $key is FALSE the creation of the post failure.
$key = $dbPages->edit($args);
if($key)
{
$dbPages->regenerateCli();
// 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']);
}
@ -34,6 +44,9 @@ function deletePage($key)
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');
}

View File

@ -13,12 +13,18 @@ function editPost($args)
global $dbPosts;
global $Language;
// Edit the post.
if( $dbPosts->edit($args) )
// 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();
// 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']);
}
@ -40,6 +46,9 @@ function deletePost($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');
}
@ -79,4 +88,4 @@ if(!$dbPosts->postExists($layout['parameters']))
$_Post = buildPost($layout['parameters']);
$layout['title'] .= ' - '.$Language->g('Edit post').' - '.$_Post->title();
$layout['title'] .= ' - '.$Language->g('Edit post').' - '.$_Post->title();

View File

@ -85,11 +85,9 @@ if($Login->role()!=='admin') {
$layout['parameters'] = $Login->username();
}
$_user = $dbUsers->getDb($layout['parameters']);
$_User = $dbUsers->getUser($layout['parameters']);
// If the user doesn't exist, redirect to the users list.
if($_user===false) {
if($_User===false) {
Redirect::page('admin', 'users');
}
$_user['username'] = $layout['parameters'];

View File

@ -33,4 +33,4 @@ foreach($plugins['all'] as $P)
}
}
Redirect::page('admin', 'plugins');
Redirect::page('admin', 'plugins');

View File

@ -36,4 +36,4 @@ else
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to install the theme: '.$themeDirname);
}
Redirect::page('admin', 'themes');
Redirect::page('admin', 'themes');

View File

@ -83,7 +83,7 @@ function checkGet($args)
if( $Login->verifyUserByToken($args['username'], $args['tokenEmail']) )
{
// Renew the tokenCRFS. This token will be the same inside the session for multiple forms.
$Security->generateToken();
$Security->generateTokenCSRF();
Redirect::page('admin', 'dashboard');
return true;
@ -119,4 +119,4 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================

View File

@ -23,7 +23,7 @@ function checkPost($args)
if( $Login->verifyUser($_POST['username'], $_POST['password']) )
{
// Renew the token. This token will be the same inside the session for multiple forms.
$Security->generateToken();
$Security->generateTokenCSRF();
Redirect::page('admin', 'dashboard');
return true;
@ -51,4 +51,4 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================

View File

@ -23,4 +23,4 @@
if( $Login->logout())
{
Redirect::home();
}
}

View File

@ -0,0 +1,21 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// ============================================================================

View File

@ -0,0 +1,21 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// ============================================================================

View File

@ -13,9 +13,15 @@ function addPage($args)
global $dbPages;
global $Language;
// Add the page.
if( $dbPages->add($args) )
// Add the page, if the $key is FALSE the creation of the post failure.
$key = $dbPages->add($args);
if($key)
{
// Call the plugins after page created.
Theme::plugins('afterPageCreate');
// Alert the user
Alert::set($Language->g('Page added successfully'));
Redirect::page('admin', 'manage-pages');
}
@ -40,4 +46,4 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================

View File

@ -13,12 +13,18 @@ function addPost($args)
global $dbPosts;
global $Language;
// Add the page.
if( $dbPosts->add($args) )
// Add the page, if the $key is FALSE the creation of the post failure.
$key = $dbPosts->add($args);
if($key)
{
// Reindex tags, this function is in 70.posts.php
reIndexTagsPosts();
// Call the plugins after post created.
Theme::plugins('afterPostCreate');
// Alert for the user
Alert::set($Language->g('Post added successfully'));
Redirect::page('admin', 'manage-posts');
}
@ -45,4 +51,4 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================

View File

@ -23,4 +23,4 @@ if($Login->role()!=='admin') {
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================

View File

@ -0,0 +1,24 @@
<?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');
}
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// ============================================================================
$themes = buildThemes();

View File

@ -29,4 +29,4 @@ $pluginClassName = $layout['parameters'];
$Plugin = new $pluginClassName;
$Plugin->uninstall();
Redirect::page('admin', 'plugins');
Redirect::page('admin', 'plugins');

View File

@ -26,8 +26,13 @@
background: #1F5FC4;
}
.uk-form legend {
legend {
width: 70% !important;
margin-top: 40px !important;
}
legend.first-child {
margin-top: 0px !important;
}
.uk-navbar-nav > li > a {
@ -36,7 +41,8 @@
padding: 15px;
}
.uk-nav-navbar > li > a:hover {
.uk-nav-navbar > li > a:hover,
.uk-nav-navbar > li > a:focus {
background: #2672ec;
}
@ -82,6 +88,34 @@ li.bludit-logo {
background: #F9F9F9 !important;
}
.uk-container {
max-width: 1280px !important;
}
.uk-width-large-4-5,
.uk-width-large-8-10 {
width: 75% !important;
}
.uk-width-large-1-5,
.uk-width-large-2-10 {
width: 25% !important;
}
.uk-thumbnail {
margin: 2px 3px !important;
max-width: 30% !important;
padding: 0 !important;
}
.uk-progress-bar {
background: #2672ec !important;
}
.uk-placeholder {
margin-bottom: 0 !important;
}
/* ----------- BLUDIT ----------- */
#logo {
@ -90,7 +124,7 @@ li.bludit-logo {
}
h2.title {
margin: 20px 0;
margin: 0 0 20px 0;
}
button.delete-button {
@ -111,16 +145,22 @@ button.delete-button:hover {
height: 400px;
}
.bl-view {
margin-top: 25px;
margin-bottom: 25px;
}
/* ----------- ALERT ----------- */
#alert {
display: none;
bottom: 20px;
color: #ffffff;
display: none;
padding: 24px;
position: fixed;
right: 20px;
text-align: center;
width: 100%;
width: 350px;
z-index: 100;
}
@ -132,6 +172,152 @@ button.delete-button:hover {
background: rgba(187, 48, 48, 0.91);
}
/* ----------- FORM ----------- */
.sidebar .uk-form-label {
font-size: 0.9em;
text-transform: uppercase;
}
#jstagList {
margin-top: 5px;
}
#jstagList span {
background: #f1f1f1;
border-radius: 3px;
color: #2672ec;
margin-right: 5px;
padding: 3px 10px;
cursor: pointer;
}
/* ----------- BLUDIT IMAGES V8 ----------- */
#bludit-images-v8 {
}
#bludit-images-v8 .bludit-thumbnail {
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
display: inline-block;
height: auto;
margin: 2px;
padding: 0;
width: 15% !important;
}
#bludit-images-v8-upload {
width: 100%;
padding: 0;
margin-bottom: 15px !important;
}
#bludit-images-v8-drag-drop {
padding: 20px;
}
#bludit-images-v8-progressbar {
display: none;
margin: 20px;
}
#bludit-images-v8-thumbnails {
max-height: 350px;
overflow: auto;
font-size: 0;
}
/* ----------- BLUDIT QUICK IMAGES ----------- */
#bludit-quick-images {
}
#bludit-quick-images a.moreImages {
margin: 15px 0 0;
width: 100%;
background: #F5F5F5 !important;
color: #555;
}
#bludit-quick-images h4.label {
background: #f8f8f8;
color: #aaa;
padding: 2px 5px;
font-size: 0.9em;
}
#bludit-quick-images-thumbnails {
font-size: 0;
}
#bludit-quick-images .bludit-thumbnail {
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
display: inline-block;
height: auto;
margin: 2px;
padding: 0;
width: 31% !important;
}
/* ----------- BLUDIT COVER IMAGE ----------- */
#bludit-cover-image {
}
#cover-image-thumbnail {
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
color: #666;
height: 130px;
padding: 0;
width: 100%;
}
#cover-image-upload {
color: #999;
position: relative;
top: 35%;
}
#cover-image-delete {
background: rgba(255, 255, 255, 0.7);
bottom: 0;
color: #000;
display: none;
font-size: 2.2em;
padding: 4px 10px;
position: absolute;
right: 0;
cursor: pointer;
}
#cover-image-progressbar {
display: none;
left: 5%;
position: relative;
top: 33%;
width: 90%;
}
/* ----------- BLUDIT PROFILE PICTURE ----------- */
#bludit-profile-picture-drag-drop {
width: 100%;
padding: 15px 0;
}
#bludit-profile-picture-progressbar {
display: none;
margin: 15px 0 0;
width: 100%;
}
/* ----------- LOGIN FORM ----------- */
div.login-box > h1 {
@ -149,7 +335,7 @@ div.login-form {
/* ----------- DASHBOARD ----------- */
div.dashboard-links {
margin: 20px 0;
margin: 0 0 25px 0;
}
div.dashboard-links h4 {
@ -160,8 +346,18 @@ div.dashboard-links a {
color: #555;
}
/* NEW POST */
h3.titleOptions {
font-size: 1em;
}
/* ----------- PLUGIN LIST / THEME LIST ----------- */
tr.plugin-installed,
tr.theme-installed {
background: #F2F7FF !important;
}
div.plugin-links > a {
display: inline-block;
margin-top: 5px;

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
.autocomplete-suggestions {
text-align: left; cursor: default; border: 1px solid #ccc; border-top: 0; background: #fff; box-shadow: -1px 1px 3px rgba(0,0,0,.1);
/* core styles should not be changed */
position: absolute; display: none; z-index: 9999; max-height: 254px; overflow: hidden; overflow-y: auto; box-sizing: border-box;
}
.autocomplete-suggestion { position: relative; padding: 0 .6em; line-height: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02em; color: #333; }
.autocomplete-suggestion b { font-weight: normal; color: #1f8dd6; }
.autocomplete-suggestion.selected { background: #f0f0f0; }

View File

@ -18,6 +18,11 @@ input[type="password"] {
/* ----------- BLUDIT ----------- */
div.login-box {
width: 400px;
max-width: calc(100% - 40px);
}
div.login-box > h1 {
font-weight: lighter;
letter-spacing: 4px;
@ -26,7 +31,6 @@ div.login-box > h1 {
}
div.login-form {
width: 400px;
text-align: left;
}

View File

@ -1,2 +1,2 @@
/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/*! UIkit 2.24.3 | 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}

View File

@ -1,2 +1,2 @@
/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/*! UIkit 2.24.3 | 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}

View File

@ -0,0 +1,2 @@
/*! UIkit 2.24.3 | 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}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
/*! UIkit 2.24.3 | 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.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1005 B

After

Width:  |  Height:  |  Size: 1005 B

View File

@ -0,0 +1,171 @@
<!DOCTYPE HTML>
<html>
<head>
<base href="<?php echo HTML_PATH_ADMIN_THEME ?>">
<meta charset="<?php echo CHARSET ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noindex,nofollow">
<title><?php echo $layout['title'] ?></title>
<!-- Favicon -->
<link rel="shortcut icon" type="image/x-icon" href="./img/favicon.png">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="./css/uikit/uikit.almost-flat.min.css?version=<?php echo BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="./css/uikit/upload.almost-flat.min.css?version=<?php echo BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="./css/uikit/form-file.almost-flat.min.css?version=<?php echo BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="./css/uikit/placeholder.almost-flat.min.css?version=<?php echo BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="./css/uikit/progress.almost-flat.min.css?version=<?php echo BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="./css/default.css?version=<?php echo BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="./css/jquery.datetimepicker.css?version=<?php echo BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="./css/jquery.auto-complete.css?version=<?php echo BLUDIT_VERSION ?>">
<!-- Javascript -->
<script charset="utf-8" src="./js/jquery.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<script charset="utf-8" src="./js/uikit/uikit.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<script charset="utf-8" src="./js/uikit/upload.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<script charset="utf-8" src="./js/jquery.datetimepicker.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<script charset="utf-8" src="./js/jquery.auto-complete.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<!-- Plugins -->
<?php Theme::plugins('adminHead') ?>
</head>
<body>
<!-- Plugins -->
<?php Theme::plugins('adminBodyBegin') ?>
<!-- Alert -->
<script>
$(document).ready(function() {
<?php
if( Alert::defined() ) {
echo '$("#alert").slideDown().delay(3500).slideUp();';
}
?>
$("#alert").click(function() {
$(this).hide();
});
});
</script>
<div id="alert" class="<?php echo (Alert::status()==ALERT_STATUS_OK)?'alert-ok':'alert-fail'; ?>">
<?php Alert::p() ?>
</div>
<!-- Navbar -->
<nav class="uk-navbar">
<!-- Navbar for Desktop -->
<div class="uk-container uk-container-center uk-hidden-small">
<ul class="uk-navbar-nav">
<li class="bludit-logo">BLUDIT</li>
<li <?php echo ($layout['view']=='dashboard')?'class="uk-active"':'' ?> ><a href="<?php echo HTML_PATH_ADMIN_ROOT.'dashboard' ?>"><i class="uk-icon-object-ungroup"></i> <?php $L->p('Dashboard') ?></a></li>
<li <?php echo ($layout['view']=='new-post')?'class="uk-active"':'' ?>><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-post' ?>"><i class="uk-icon-pencil"></i> <?php $L->p('New post') ?></a></li>
<li <?php echo ($layout['view']=='new-page')?'class="uk-active"':'' ?>><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><i class="uk-icon-file-text-o"></i> <?php $L->p('New page') ?></a></li>
<li class="uk-parent" data-uk-dropdown>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-posts' ?>"><i class="uk-icon-clone"></i> <?php $L->p('Manage') ?> ▾</a>
<div class="uk-dropdown uk-dropdown-navbar">
<ul class="uk-nav uk-nav-navbar">
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-posts' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Posts') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Pages') ?></a></li>
<?php if($Login->role() == 'admin') { ?>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>"><i class="uk-icon-users"></i> <?php $L->p('Users') ?></a></li>
<?php } ?>
</ul>
</div>
</li>
<?php if($Login->role() == 'admin') { ?>
<li class="uk-parent" data-uk-dropdown>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-general' ?>"><i class="uk-icon-cog"></i> <?php $L->p('Settings') ?> ▾</a>
<div class="uk-dropdown uk-dropdown-navbar">
<ul class="uk-nav uk-nav-navbar">
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-general' ?>"><i class="uk-icon-th-large"></i> <?php $L->p('General') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-advanced' ?>"><i class="uk-icon-th"></i> <?php $L->p('Advanced') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-regional' ?>"><i class="uk-icon-globe"></i> <?php $L->p('Language and timezone') ?></a></li>
<li class="uk-nav-divider"></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins' ?>"><i class="uk-icon-puzzle-piece"></i> <?php $L->p('Plugins') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'themes' ?>"><i class="uk-icon-paint-brush"></i> <?php $L->p('Themes') ?></a></li>
<li class="uk-nav-divider"></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'about' ?>"><?php $L->p('About') ?></a></li>
</ul>
</div>
</li>
<?php } ?>
</ul>
<div class="uk-navbar-flip">
<ul class="uk-navbar-nav">
<li class="uk-parent" data-uk-dropdown>
<?php
$profilePictureSrc = HTML_PATH_ADMIN_THEME_IMG.'default.png';
if(file_exists(PATH_UPLOADS_PROFILES.$Login->username().'.png')) {
$profilePictureSrc = HTML_PATH_UPLOADS_PROFILES.$Login->username().'.png';
}
?>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>">
<img class="uk-border-circle" width="28px" src="<?php echo $profilePictureSrc ?>" alt=""> <?php echo $Login->username() ?>
</a>
<div class="uk-dropdown uk-dropdown-navbar">
<ul class="uk-nav uk-nav-navbar">
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>"><?php $L->p('Profile') ?></a></li>
<li class="uk-nav-divider"></li>
<li><a target="_blank" href="<?php echo HTML_PATH_ROOT ?>"><?php $L->p('Website') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'logout' ?>"><?php $L->p('Logout') ?></a></li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<!-- Navbar for Mobile -->
<a href="#offcanvas" class="uk-navbar-toggle uk-visible-small" data-uk-offcanvas></a>
<div class="uk-navbar-brand uk-navbar-center uk-visible-small">BLUDIT</div>
</nav>
<!-- Offcanvas for Mobile -->
<div id="offcanvas" class="uk-offcanvas">
<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>
<?php if($Login->role() == 'admin') { ?>
<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.'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.'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>
<?php } ?>
</ul>
</div>
</div>
<!-- View -->
<div class="uk-container uk-container-center bl-view">
<?php
if( Sanitize::pathFile(PATH_ADMIN_VIEWS, $layout['view'].'.php') ) {
include(PATH_ADMIN_VIEWS.$layout['view'].'.php');
}
?>
</div>
<!-- Javascript -->
<?php include(PATH_JS.'functions.php') ?>
<!-- Plugins -->
<?php Theme::plugins('adminBodyEnd') ?>
</body>
</html>

View File

@ -0,0 +1,608 @@
<?php
class HTML {
public static function title($args)
{
$html = '<h2 class="title"><i class="uk-icon-'.$args['icon'].'"></i> '.$args['title'].'</h2>';
echo $html;
}
public static function formOpen($args)
{
$class = empty($args['class']) ? '' : ' '.$args['class'];
$id = empty($args['id']) ? '' : 'id="'.$args['id'].'"';
$html = '<form class="uk-form'.$class.'" '.$id.' method="post" action="" autocomplete="off">';
echo $html;
}
public static function formClose()
{
$html = '</form>';
$script = '<script>
$(document).ready(function() {
// Prevent the form submit when press enter key.
$("form").keypress(function(e) {
if (e.which == 13) {
return false;
}
});
});
</script>';
echo $html.$script;
}
// label, name, value, tip
public static function formInputText($args)
{
$id = 'js'.$args['name'];
$type = isset($args['type']) ? $args['type'] : 'text';
$class = empty($args['class']) ? '' : 'class="'.$args['class'].'"';
$placeholder = empty($args['placeholder']) ? '' : 'placeholder="'.$args['placeholder'].'"';
$disabled = empty($args['disabled']) ? '' : 'disabled';
$html = '<div class="uk-form-row">';
if(!empty($args['label'])) {
$html .= '<label for="'.$id.'" class="uk-form-label">'.$args['label'].'</label>';
}
$html .= '<div class="uk-form-controls">';
$html .= '<input id="'.$id.'" name="'.$args['name'].'" type="'.$type.'" '.$class.' '.$placeholder.' autocomplete="off" '.$disabled.' value="'.$args['value'].'">';
if(!empty($args['tip'])) {
$html .= '<p class="uk-form-help-block">'.$args['tip'].'</p>';
}
$html .= '</div>';
$html .= '</div>';
echo $html;
}
public static function tagsAutocomplete($args)
{
// Tag array for Javascript
$tagArray = 'var tagArray = [];';
if(!empty($args['value'])) {
$tagArray = 'var tagArray = ["'.implode('","', $args['value']).'"]';
}
$args['value'] = '';
// Text input
self::formInputText($args);
echo '<div id="jstagList"></div>';
$script = '<script>
'.$tagArray.'
function insertTag(tag)
{
// Clean the input text
$("#jstags").val("");
if(tag.trim()=="") {
return true;
}
// Check if the tag is already inserted.
var found = $.inArray(tag, tagArray);
if(found == -1) {
tagArray.push(tag);
renderTagList();
}
}
function removeTag(tag)
{
var found = $.inArray(tag, tagArray);
if(found => 0) {
tagArray.splice(found, 1);
renderTagList();
}
}
function renderTagList()
{
if(tagArray.length == 0) {
$("#jstagList").html("");
}
else {
$("#jstagList").html("<span>"+tagArray.join("</span><span>")+"</span>");
}
}
$("#jstags").autoComplete({
minChars: 1,
source: function(term, suggest){
term = term.toLowerCase();
var choices = ['.$args['words'].'];
var matches = [];
for (i=0; i<choices.length; i++)
if (~choices[i].toLowerCase().indexOf(term)) matches.push(choices[i]);
suggest(matches);
},
onSelect: function(e, value, item) {
// Insert the tag when select whit the mouse click.
insertTag(value);
}
});
$(document).ready(function() {
// When the page is loaded render the tags
renderTagList();
// Remove the tag when click on it.
$("body").on("click", "#jstagList > span", function() {
value = $(this).html();
removeTag(value);
});
// Insert tag when press enter key.
$("#jstags").keypress(function(e) {
if (e.which == 13) {
var value = $(this).val();
insertTag(value);
}
});
// When form submit.
$("form").submit(function(e) {
var list = tagArray.join(",");
$("#jstags").val(list);
});
});
</script>';
echo $script;
}
public static function formInputPassword($args)
{
$args['type'] = 'password';
self::formInputText($args);
}
public static function formTextarea($args)
{
$id = 'js'.$args['name'];
$type = isset($args['type']) ? $args['type'] : 'text';
$class = empty($args['class']) ? '' : 'class="'.$args['class'].'"';
$placeholder = empty($args['placeholder']) ? '' : 'placeholder="'.$args['placeholder'].'"';
$rows = empty($args['rows']) ? '' : 'rows="'.$args['rows'].'"';
$html = '<div class="uk-form-row">';
if(!empty($args['label'])) {
$html .= '<label for="'.$id.'" class="uk-form-label">'.$args['label'].'</label>';
}
$html .= '<div class="uk-form-controls">';
$html .= '<textarea id="'.$id.'" name="'.$args['name'].'" '.$class.' '.$placeholder.' '.$rows.'>'.$args['value'].'</textarea>';
if(!empty($args['tip'])) {
$html .= '<p class="uk-form-help-block">'.$args['tip'].'</p>';
}
$html .= '</div>';
$html .= '</div>';
echo $html;
}
public static function formSelect($args)
{
$id = 'js'.$args['name'];
$type = isset($args['type']) ? $args['type'] : 'text';
$class = empty($args['class']) ? '' : 'class="'.$args['class'].'"';
$html = '<div class="uk-form-row">';
$html .= '<label for="'.$id.'" class="uk-form-label">'.$args['label'].'</label>';
$html .= '<div class="uk-form-controls">';
$html .= '<select id="'.$id.'" name="'.$args['name'].'" '.$class.'>';
foreach($args['options'] as $key=>$value) {
$html .= '<option value="'.$key.'"'.( ($args['selected']==$key)?' selected="selected"':'').'>'.$value.'</option>';
}
$html .= '</select>';
$html .= '<p class="uk-form-help-block">'.$args['tip'].'</p>';
$html .= '</div>';
$html .= '</div>';
echo $html;
}
public static function formInputHidden($args)
{
$id = 'js'.$args['name'];
$html = '<input type="hidden" id="'.$id.'" name="'.$args['name'].'" value="'.$args['value'].'">';
echo $html;
}
public static function legend($args)
{
$class = empty($args['class']) ? '' : 'class="'.$args['class'].'"';
$html = '<legend '.$class.'>'.$args['value'].'</legend>';
echo $html;
}
public static function formButtonSubmit($args)
{
$html = '';
}
public static function bluditQuickImages()
{
global $L;
$html = '<!-- BLUDIT QUICK IMAGES -->';
$html .= '
<div id="bludit-quick-images">
<div id="bludit-quick-images-thumbnails" onmousedown="return false">
';
$thumbnailList = Filesystem::listFiles(PATH_UPLOADS_THUMBNAILS,'*','*',true);
array_splice($thumbnailList, THUMBNAILS_AMOUNT);
foreach($thumbnailList as $file) {
$filename = basename($file);
$html .= '<img class="bludit-thumbnail" data-filename="'.$filename.'" src="'.HTML_PATH_UPLOADS_THUMBNAILS.$filename.'" alt="Thumbnail">';
}
$html .= '
</div>
';
if(empty($thumbnailList)) {
$html .= '<div class="empty-images uk-block uk-text-center uk-block-muted">'.$L->g('There are no images').'</div>';
}
$html .= '
<a data-uk-modal href="#bludit-images-v8" class="moreImages uk-button">'.$L->g('More images').'</a>
</div>
';
$script = '
<script>
// Add thumbnail to Quick Images
function addQuickImages(filename)
{
var imageSrc = HTML_PATH_UPLOADS_THUMBNAILS + filename;
// Remove element if there are more than 6 thumbnails
if ($("#bludit-quick-images-thumbnails > img").length > 5) {
$("img:last-child", "#bludit-quick-images-thumbnails").remove();
}
// Add the new thumbnail to Quick images
$("#bludit-quick-images-thumbnails").prepend("<img class=\"bludit-thumbnail\" data-filename=\""+filename+"\" src=\""+imageSrc+"\" alt=\"Thumbnail\">");
}
</script>
';
echo $html.$script;
}
public static function bluditCoverImage($coverImage="")
{
global $L;
$style = '';
if(!empty($coverImage)) {
$style = 'background-image: url('.HTML_PATH_UPLOADS_THUMBNAILS.$coverImage.')';
}
$html = '<!-- BLUDIT COVER IMAGE -->';
$html .= '
<div id="bludit-cover-image">
<div id="cover-image-thumbnail" class="uk-form-file uk-placeholder uk-text-center" style="'.$style.'">
<input type="hidden" name="coverImage" id="cover-image-upload-filename" value="'.$coverImage.'">
<div id="cover-image-upload" '.( empty($coverImage)?'':'style="display: none;"' ).'>
<div><i class="uk-icon-picture-o"></i> '.$L->g('Cover image').'</div>
<div style="font-size:0.8em;">'.$L->g('Drag and drop or click here').'<input id="cover-image-file-select" type="file"></div>
</div>
<div id="cover-image-delete" '.( empty($coverImage)?'':'style="display: block;"' ).'>
<div><i class="uk-icon-trash-o"></i></div>
</div>
<div id="cover-image-progressbar" class="uk-progress">
<div class="uk-progress-bar" style="width: 0%;">0%</div>
</div>
</div>
</div>
';
$script = '
<script>
function addCoverImage(filename)
{
var imageSrc = HTML_PATH_UPLOADS_THUMBNAILS + filename;
// Cover image background
$("#cover-image-thumbnail").attr("style","background-image: url("+imageSrc+")");
// Form attribute
$("#cover-image-upload-filename").attr("value", filename);
}
$(document).ready(function() {
$("#cover-image-delete").on("click", function() {
$("#cover-image-thumbnail").attr("style","");
$("#cover-image-upload-filename").attr("value","");
$("#cover-image-delete").hide();
$("#cover-image-upload").show();
});
var settings =
{
type: "json",
action: HTML_PATH_ADMIN_ROOT+"ajax/uploader",
allow : "*.(jpg|jpeg|gif|png)",
params: {"type":"cover-image"},
loadstart: function() {
$("#cover-image-progressbar").find(".uk-progress-bar").css("width", "0%").text("0%");
$("#cover-image-progressbar").show();
$("#cover-image-delete").hide();
$("#cover-image-upload").hide();
},
progress: function(percent) {
percent = Math.ceil(percent);
$("#cover-image-progressbar").find(".uk-progress-bar").css("width", percent+"%").text(percent+"%");
},
allcomplete: function(response) {
$("#cover-image-progressbar").find(".uk-progress-bar").css("width", "100%").text("100%");
$("#cover-image-progressbar").hide();
$("#cover-image-delete").show();
$(".empty-images").hide();
// Add Cover Image
addCoverImage(response.filename);
// Add thumbnail to Quick Images
addQuickImages(response.filename);
// Add thumbnail to Bludit Images V8
addBluditImagev8(response.filename);
},
notallowed: function(file, settings) {
alert("'.$L->g('Supported image file types').' "+settings.allow);
}
};
UIkit.uploadSelect($("#cover-image-file-select"), settings);
UIkit.uploadDrop($("#cover-image-thumbnail"), settings);
});
</script>
';
echo $html.$script;
}
public static function bluditImagesV8()
{
global $L;
$html = '<!-- BLUDIT IMAGES V8 -->';
$html .= '
<div id="bludit-images-v8" class="uk-modal">
<div class="uk-modal-dialog">
<div id="bludit-images-v8-upload" class="uk-form-file uk-placeholder uk-text-center">
<div id="bludit-images-v8-drag-drop">
<div><i class="uk-icon-picture-o"></i> '.$L->g('Upload image').'</div>
<div style="font-size:0.8em;">'.$L->g('Drag and drop or click here').'<input id="bludit-images-v8-file-select" type="file"></div>
</div>
<div id="bludit-images-v8-progressbar" class="uk-progress">
<div class="uk-progress-bar" style="width: 0%;">0%</div>
</div>
</div>
<div id="bludit-images-v8-thumbnails">
';
$thumbnailList = Filesystem::listFiles(PATH_UPLOADS_THUMBNAILS,'*','*',true);
foreach($thumbnailList as $file) {
$filename = basename($file);
$html .= '<img class="bludit-thumbnail" src="'.HTML_PATH_UPLOADS_THUMBNAILS.$filename.'" data-filename="'.$filename.'" alt="Thumbnail">';
}
$html .= '
</div>
';
if(empty($thumbnailList)) {
$html .= '<div class="empty-images uk-block uk-text-center uk-block-muted">'.$L->g('There are no images').'</div>';
}
$html .= '
<div class="uk-modal-footer">
'.$L->g('Double click on the image to add it').' <a href="" class="uk-modal-close">'.$L->g('Click here to cancel').'</a>
</div>
</div>
</div>
';
$script = '
<script>
// Add thumbnail to Bludit Images v8
function addBluditImagev8(filename)
{
var imageSrc = HTML_PATH_UPLOADS_THUMBNAILS + filename;
// Add the new thumbnail to Bludit Images v8
$("#bludit-images-v8-thumbnails").prepend("<img class=\"bludit-thumbnail\" data-filename=\""+filename+"\" src=\""+imageSrc+"\" alt=\"Thumbnail\">");
}
$(document).ready(function() {
// Add border when select an thumbnail
$("body").on("click", "img.bludit-thumbnail", function() {
$(".bludit-thumbnail").css("border", "1px solid #ddd");
$(this).css("border", "solid 3px orange");
});
// Hide the modal when double click on thumbnail.
$("body").on("dblclick", "img.bludit-thumbnail", function() {
var modal = UIkit.modal("#bludit-images-v8");
if ( modal.isActive() ) {
modal.hide();
}
});
// Event for double click for insert the image is in each editor plugin
// ..
var settings =
{
type: "json",
action: HTML_PATH_ADMIN_ROOT+"ajax/uploader",
allow : "*.(jpg|jpeg|gif|png)",
params: {"type":"bludit-images-v8"},
loadstart: function() {
$("#bludit-images-v8-progressbar").find(".uk-progress-bar").css("width", "0%").text("0%");
$("#bludit-images-v8-drag-drop").hide();
$("#bludit-images-v8-progressbar").show();
},
progress: function(percent) {
percent = Math.ceil(percent);
$("#bludit-images-v8-progressbar").find(".uk-progress-bar").css("width", percent+"%").text(percent+"%");
},
allcomplete: function(response) {
$("#bludit-images-v8-progressbar").find(".uk-progress-bar").css("width", "100%").text("100%");
$("#bludit-images-v8-progressbar").hide();
$("#bludit-images-v8-drag-drop").show();
$(".empty-images").hide();
// Add thumbnail to Bludit Images V8
addBluditImagev8(response.filename);
// Add thumbnail to Quick Images
addQuickImages(response.filename);
},
notallowed: function(file, settings) {
alert("'.$L->g('Supported image file types').' "+settings.allow);
}
};
UIkit.uploadSelect($("#bludit-images-v8-file-select"), settings);
UIkit.uploadDrop($("#bludit-images-v8-upload"), settings);
});
</script>
';
echo $html.$script;
}
public static function profileUploader($username)
{
global $L;
$html = '<!-- BLUDIT PROFILE UPLOADER -->';
$html .= '
<div id="bludit-profile-picture">
<div id="bludit-profile-picture-image">';
if(file_exists(PATH_UPLOADS_PROFILES.$username.'.png')) {
$html .= '<img class="uk-border-rounded" src="'.HTML_PATH_UPLOADS_PROFILES.$username.'.png" alt="Profile picture">';
}
else {
$html .= '<div class="uk-block uk-border-rounded uk-block-muted uk-block-large">'.$L->g('Profile picture').'</div>';
}
$html .= '
</div>
<div id="bludit-profile-picture-progressbar" class="uk-progress">
<div class="uk-progress-bar" style="width: 0%;">0%</div>
</div>
<div id="bludit-profile-picture-drag-drop" class="uk-form-file uk-placeholder uk-text-center">
<div>'.$L->g('Upload image').'</div>
<div style="font-size:0.8em;">'.$L->g('Drag and drop or click here').'<input id="bludit-profile-picture-file-select" type="file"></div>
</div>
</div>
';
$script = '
<script>
$(document).ready(function() {
var settings =
{
type: "json",
action: HTML_PATH_ADMIN_ROOT+"ajax/uploader",
allow : "*.(jpg|jpeg|gif|png)",
params: {"type":"profilePicture", "username":"'.$username.'"},
loadstart: function() {
$("#bludit-profile-picture-progressbar").find(".uk-progress-bar").css("width", "0%").text("0%");
$("#bludit-profile-picture-progressbar").show();
},
progress: function(percent) {
percent = Math.ceil(percent);
$("#bludit-profile-picture-progressbar").find(".uk-progress-bar").css("width", percent+"%").text(percent+"%");
},
allcomplete: function(response) {
$("#bludit-profile-picture-progressbar").find(".uk-progress-bar").css("width", "100%").text("100%");
$("#bludit-profile-picture-progressbar").hide();
$("#bludit-profile-picture-image").html("<img class=\"uk-border-rounded\" src=\"'.HTML_PATH_UPLOADS_PROFILES.$username.'.png?time='.time().'\">");
},
notallowed: function(file, settings) {
alert("'.$L->g('Supported image file types').' "+settings.allow);
}
};
UIkit.uploadSelect($("#bludit-profile-picture-file-select"), settings);
UIkit.uploadDrop($("#bludit-profile-picture-drag-drop"), settings);
});
</script>
';
echo $html.$script;
}
}

View File

@ -0,0 +1,3 @@
// jQuery autoComplete v1.0.7
// https://github.com/Pixabay/jQuery-autoComplete
!function(e){e.fn.autoComplete=function(t){var o=e.extend({},e.fn.autoComplete.defaults,t);return"string"==typeof t?(this.each(function(){var o=e(this);"destroy"==t&&(e(window).off("resize.autocomplete",o.updateSC),o.off("blur.autocomplete focus.autocomplete keydown.autocomplete keyup.autocomplete"),o.data("autocomplete")?o.attr("autocomplete",o.data("autocomplete")):o.removeAttr("autocomplete"),e(o.data("sc")).remove(),o.removeData("sc").removeData("autocomplete"))}),this):this.each(function(){function t(e){var t=s.val();if(s.cache[t]=e,e.length&&t.length>=o.minChars){for(var a="",c=0;c<e.length;c++)a+=o.renderItem(e[c],t);s.sc.html(a),s.updateSC(0)}else s.sc.hide()}var s=e(this);s.sc=e('<div class="autocomplete-suggestions '+o.menuClass+'"></div>'),s.data("sc",s.sc).data("autocomplete",s.attr("autocomplete")),s.attr("autocomplete","off"),s.cache={},s.last_val="",s.updateSC=function(t,o){if(s.sc.css({top:s.offset().top+s.outerHeight(),left:s.offset().left,width:s.outerWidth()}),!t&&(s.sc.show(),s.sc.maxHeight||(s.sc.maxHeight=parseInt(s.sc.css("max-height"))),s.sc.suggestionHeight||(s.sc.suggestionHeight=e(".autocomplete-suggestion",s.sc).first().outerHeight()),s.sc.suggestionHeight))if(o){var a=s.sc.scrollTop(),c=o.offset().top-s.sc.offset().top;c+s.sc.suggestionHeight-s.sc.maxHeight>0?s.sc.scrollTop(c+s.sc.suggestionHeight+a-s.sc.maxHeight):0>c&&s.sc.scrollTop(c+a)}else s.sc.scrollTop(0)},e(window).on("resize.autocomplete",s.updateSC),s.sc.appendTo("body"),s.sc.on("mouseleave",".autocomplete-suggestion",function(){e(".autocomplete-suggestion.selected").removeClass("selected")}),s.sc.on("mouseenter",".autocomplete-suggestion",function(){e(".autocomplete-suggestion.selected").removeClass("selected"),e(this).addClass("selected")}),s.sc.on("mousedown",".autocomplete-suggestion",function(t){var a=e(this),c=a.data("val");return(c||a.hasClass("autocomplete-suggestion"))&&(s.val(c),o.onSelect(t,c,a),s.sc.hide()),!1}),s.on("blur.autocomplete",function(){try{over_sb=e(".autocomplete-suggestions:hover").length}catch(t){over_sb=0}over_sb?s.is(":focus")||setTimeout(function(){s.focus()},20):(s.last_val=s.val(),s.sc.hide(),setTimeout(function(){s.sc.hide()},350))}),o.minChars||s.on("focus.autocomplete",function(){s.last_val="\n",s.trigger("keyup.autocomplete")}),s.on("keydown.autocomplete",function(t){if((40==t.which||38==t.which)&&s.sc.html()){var a,c=e(".autocomplete-suggestion.selected",s.sc);return c.length?(a=40==t.which?c.next(".autocomplete-suggestion"):c.prev(".autocomplete-suggestion"),a.length?(c.removeClass("selected"),s.val(a.addClass("selected").data("val"))):(c.removeClass("selected"),s.val(s.last_val),a=0)):(a=40==t.which?e(".autocomplete-suggestion",s.sc).first():e(".autocomplete-suggestion",s.sc).last(),s.val(a.addClass("selected").data("val"))),s.updateSC(0,a),!1}if(27==t.which)s.val(s.last_val).sc.hide();else if(13==t.which||9==t.which){var c=e(".autocomplete-suggestion.selected",s.sc);c.length&&s.sc.is(":visible")&&(o.onSelect(t,c.data("val"),c),setTimeout(function(){s.sc.hide()},20))}}),s.on("keyup.autocomplete",function(a){if(!~e.inArray(a.which,[13,27,35,36,37,38,39,40])){var c=s.val();if(c.length>=o.minChars){if(c!=s.last_val){if(s.last_val=c,clearTimeout(s.timer),o.cache){if(c in s.cache)return void t(s.cache[c]);for(var l=1;l<c.length-o.minChars;l++){var i=c.slice(0,c.length-l);if(i in s.cache&&!s.cache[i].length)return void t([])}}s.timer=setTimeout(function(){o.source(c,t)},o.delay)}}else s.last_val=c,s.sc.hide()}})})},e.fn.autoComplete.defaults={source:0,minChars:3,delay:150,cache:1,menuClass:"",renderItem:function(e,t){t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");var o=new RegExp("("+t.split(" ").join("|")+")","gi");return'<div class="autocomplete-suggestion" data-val="'+e+'">'+e.replace(o,"<b>$1</b>")+"</div>"},onSelect:function(e,t,o){}}}(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/*! UIkit 2.24.3 | 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 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.dataTransfer&&n.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.dataTransfer.files]),t(n.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()}(),e.support.ajaxupload&&e.$.event.props.push("dataTransfer"),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});

View File

@ -1,7 +1,6 @@
<!DOCTYPE HTML>
<html class="uk-height-1-1 uk-notouch">
<head>
<base href="<?php echo HTML_PATH_ADMIN_THEME ?>">
<meta charset="<?php echo CHARSET ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noindex,nofollow">
@ -9,15 +8,15 @@
<title>Bludit</title>
<!-- Favicon -->
<link rel="shortcut icon" type="image/x-icon" href="./img/favicon.png">
<link rel="shortcut icon" type="image/x-icon" href="<?php echo HTML_PATH_ADMIN_THEME.'img/favicon.png' ?>">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="./css/uikit.almost-flat.min.css?version=<?php echo BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="./css/login.css?version=<?php echo BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="<?php echo HTML_PATH_ADMIN_THEME.'css/uikit/uikit.almost-flat.min.css?version='.BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="<?php echo HTML_PATH_ADMIN_THEME.'css/login.css?version='.BLUDIT_VERSION ?>">
<!-- Javascript -->
<script charset="utf-8" src="./js/jquery.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<script charset="utf-8" src="./js/uikit.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<script charset="utf-8" src="<?php echo HTML_PATH_ADMIN_THEME.'js/jquery.min.js?version='.BLUDIT_VERSION ?>"></script>
<script charset="utf-8" src="<?php echo HTML_PATH_ADMIN_THEME.'js/uikit/uikit.min.js?version='.BLUDIT_VERSION ?>"></script>
<!-- Plugins -->
<?php Theme::plugins('loginHead') ?>
@ -46,4 +45,4 @@
<?php Theme::plugins('loginBodyEnd') ?>
</body>
</html>
</html>

View File

@ -31,4 +31,4 @@ echo '
echo '
</tbody>
</table>
';
';

View File

@ -7,7 +7,7 @@ HTML::formOpen(array('id'=>'add-user-form', 'class'=>'uk-form-horizontal'));
// Security token
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
HTML::formInputText(array(
@ -57,4 +57,4 @@ HTML::formOpen(array('id'=>'add-user-form', 'class'=>'uk-form-horizontal'));
</div>
</div>';
HTML::formClose();
HTML::formClose();

View File

@ -7,7 +7,7 @@ HTML::formOpen(array('id'=>'jsformplugin'));
// Security token
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
// Print the plugin form
@ -19,4 +19,4 @@ HTML::formOpen(array('id'=>'jsformplugin'));
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'plugins">'.$L->g('Cancel').'</a>
</div>';
HTML::formClose();
HTML::formClose();

View File

@ -119,7 +119,7 @@
}
else {
foreach($_scheduledPosts as $Post) {
echo '<li><span class="label-time">'.$Post->date(SCHEDULED_DATE_FORMAT).'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->title()?$Post->title():'['.$Language->g('Empty title').'] ').'</a></li>';
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>';
}
}
?>
@ -128,4 +128,4 @@
</div>
</div>
</div>

View File

@ -7,7 +7,7 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
// Security token
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
// Key input
@ -18,7 +18,7 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
// ---- LEFT SIDE ----
echo '<div class="uk-grid">';
echo '<div class="uk-width-large-7-10">';
echo '<div class="uk-width-large-8-10">';
// Title input
HTML::formInputText(array(
@ -52,7 +52,7 @@ if(count($_Page->children())===0)
echo '</div>';
// ---- RIGHT SIDE ----
echo '<div class="uk-width-large-3-10">';
echo '<div class="sidebar uk-width-large-2-10">';
// Tabs, general and advanced mode
echo '<ul class="uk-tab" data-uk-tab="{connect:\'#tab-options\'}">';
@ -71,18 +71,19 @@ echo '<div class="uk-width-large-3-10">';
'name'=>'description',
'label'=>$L->g('description'),
'value'=>$_Page->description(),
'rows'=>'7',
'rows'=>'4',
'class'=>'uk-width-1-1 uk-form-medium',
'tip'=>$L->g('this-field-can-help-describe-the-content')
));
// Tags input
HTML::formInputText(array(
HTML::tagsAutocomplete(array(
'name'=>'tags',
'value'=>$_Page->tags(),
'value'=>$_Page->tags(true),
'tip'=>$L->g('Type the tag and press enter'),
'class'=>'uk-width-1-1 uk-form-large',
'tip'=>$L->g('Write the tags separated by commas'),
'label'=>$L->g('Tags')
'label'=>$L->g('Tags'),
'words'=>'"'.implode('", "', $dbTags->getAll()).'"'
));
echo '</li>';
@ -90,13 +91,32 @@ echo '<div class="uk-width-large-3-10">';
// ---- IMAGES TAB ----
echo '<li>';
HTML::uploader();
// --- BLUDIT COVER IMAGE ---
echo '<hr>';
HTML::bluditCoverImage($_Page->coverImage(false));
echo '<hr>';
// --- BLUDIT QUICK IMAGES ---
HTML::bluditQuickImages();
// --- BLUDIT IMAGES V8 ---
HTML::bluditImagesV8();
echo '</li>';
// ---- ADVANCED TAB ----
echo '<li>';
// Status input
HTML::formSelect(array(
'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'),
'tip'=>''
));
// If the page is parent then doesn't can have a parent.
if(count($_Page->children())===0)
{
@ -116,16 +136,6 @@ if(count($_Page->children())===0)
));
}
// Status input
HTML::formSelect(array(
'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'),
'tip'=>''
));
// Position input
HTML::formInputText(array(
'name'=>'position',
@ -195,4 +205,4 @@ $(document).ready(function()
});
</script>
</script>

View File

@ -7,7 +7,7 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
// Security token
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
// Key input
@ -18,7 +18,7 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
// ---- LEFT SIDE ----
echo '<div class="uk-grid">';
echo '<div class="uk-width-large-7-10">';
echo '<div class="uk-width-large-8-10">';
// Title input
HTML::formInputText(array(
@ -46,7 +46,7 @@ echo '<div class="uk-width-large-7-10">';
echo '</div>';
// ---- RIGHT SIDE ----
echo '<div class="uk-width-large-3-10">';
echo '<div class="sidebar uk-width-large-2-10">';
// Tabs, general and advanced mode
echo '<ul class="uk-tab" data-uk-tab="{connect:\'#tab-options\'}">';
@ -65,18 +65,19 @@ echo '<div class="uk-width-large-3-10">';
'name'=>'description',
'label'=>$L->g('description'),
'value'=>$_Post->description(),
'rows'=>'7',
'rows'=>'4',
'class'=>'uk-width-1-1 uk-form-medium',
'tip'=>$L->g('this-field-can-help-describe-the-content')
));
// Tags input
HTML::formInputText(array(
HTML::tagsAutocomplete(array(
'name'=>'tags',
'value'=>$_Post->tags(),
'value'=>$_Post->tags(true),
'tip'=>$L->g('Type the tag and press enter'),
'class'=>'uk-width-1-1 uk-form-large',
'tip'=>$L->g('Write the tags separated by commas'),
'label'=>$L->g('Tags')
'label'=>$L->g('Tags'),
'words'=>'"'.implode('", "', $dbTags->getAll()).'"'
));
echo '</li>';
@ -84,22 +85,22 @@ echo '<div class="uk-width-large-3-10">';
// ---- IMAGES TAB ----
echo '<li>';
HTML::uploader();
// --- BLUDIT COVER IMAGE ---
echo '<hr>';
HTML::bluditCoverImage($_Post->coverImage(false));
echo '<hr>';
// --- BLUDIT QUICK IMAGES ---
HTML::bluditQuickImages();
// --- BLUDIT IMAGES V8 ---
HTML::bluditImagesV8();
echo '</li>';
// ---- ADVANCED TAB ----
echo '<li>';
// Date input
HTML::formInputText(array(
'name'=>'date',
'value'=>$_Post->date(),
'class'=>'uk-width-1-1 uk-form-large',
'tip'=>$L->g('To schedule the post just select the date and time'),
'label'=>$L->g('Date')
));
// Status input
HTML::formSelect(array(
'name'=>'status',
@ -110,6 +111,15 @@ echo '<div class="uk-width-large-3-10">';
'tip'=>''
));
// Date input
HTML::formInputText(array(
'name'=>'date',
'value'=>$_Post->dateRaw(),
'class'=>'uk-width-1-1 uk-form-large',
'tip'=>$L->g('To schedule the post just select the date and time'),
'label'=>$L->g('Date')
));
// Slug input
HTML::formInputText(array(
'name'=>'slug',
@ -155,4 +165,4 @@ $(document).ready(function() {
});
</script>
</script>

View File

@ -10,21 +10,21 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
// Security token
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
// Security token
HTML::formInputHidden(array(
'name'=>'username',
'value'=>$_user['username']
'value'=>$_User->username()
));
HTML::legend(array('value'=>$L->g('Profile')));
HTML::legend(array('value'=>$L->g('Profile'), 'class'=>'first-child'));
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">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,20 +59,53 @@ 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'=>''
));
}
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')
));
HTML::legend(array('value'=>'Social networks'));
HTML::formInputText(array(
'name'=>'twitterUsername',
'label'=>'Twitter username',
'value'=>$_User->twitterUsername(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
HTML::formInputText(array(
'name'=>'facebookUsername',
'label'=>'Facebook username',
'value'=>$_User->facebookUsername(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
HTML::formInputText(array(
'name'=>'googleUsername',
'label'=>'Google username',
'value'=>$_User->googleUsername(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
HTML::formInputText(array(
'name'=>'instagramUsername',
'label'=>'Instagram username',
'value'=>$_User->instagramUsername(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
echo '<div class="uk-form-row">
<div class="uk-form-controls">
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
@ -80,7 +113,7 @@ if($Login->role()==='admin') {
</div>
</div>';
if( ($Login->role()==='admin') && ($_user['username']!='admin') ) {
if( ($Login->role()==='admin') && ($_User->username()!='admin') ) {
HTML::legend(array('value'=>$L->g('Delete')));
@ -96,9 +129,11 @@ if( ($Login->role()==='admin') && ($_user['username']!='admin') ) {
HTML::formClose();
echo '</div>';
echo '<div class="uk-width-3-10" style="margin-top: 50px; text-align: center;">';
echo '<img id="jsprofilePicture" class="uk-border-rounded" src="'.HTML_PATH_UPLOADS_PROFILES.$_user['username'].'.jpg" alt="'.$L->g('Profile picture').'">';
HTML::profileUploader($_user['username']);
HTML::profileUploader($_User->username());
echo '</div>';
echo '</div>';

View File

@ -2,7 +2,7 @@
<form method="post" action="" class="uk-form" autocomplete="off">
<input type="hidden" id="jstoken" name="tokenCSRF" value="<?php $Security->printToken() ?>">
<input type="hidden" id="jstoken" name="tokenCSRF" value="<?php $Security->printTokenCSRF() ?>">
<div class="uk-form-row">
<input name="email" class="uk-width-1-1 uk-form-large" placeholder="<?php $L->p('Email') ?>" type="text">
@ -16,4 +16,4 @@
</div>
<a class="login-email" href="<?php echo HTML_PATH_ADMIN_ROOT.'login' ?>"><i class="uk-icon-chevron-left"></i> <?php $L->p('Back to login form') ?></a>
<a class="login-email" href="<?php echo HTML_PATH_ADMIN_ROOT.'login' ?>"><i class="uk-icon-chevron-left"></i> <?php $L->p('Back to login form') ?></a>

View File

@ -2,7 +2,7 @@
<form method="post" action="" class="uk-form" autocomplete="off">
<input type="hidden" id="jstoken" name="tokenCSRF" value="<?php $Security->printToken() ?>">
<input type="hidden" id="jstoken" name="tokenCSRF" value="<?php $Security->printTokenCSRF() ?>">
<div class="uk-form-row">
<input name="username" class="uk-width-1-1 uk-form-large" placeholder="<?php $L->p('Username') ?>" type="text">
@ -20,4 +20,4 @@
</div>
<a class="login-email" href="<?php echo HTML_PATH_ADMIN_ROOT.'login-email' ?>"><i class="uk-icon-envelope-o"></i> <?php $L->p('Send me a login access code') ?></a>
<a class="login-email" href="<?php echo HTML_PATH_ADMIN_ROOT.'login-email' ?>"><i class="uk-icon-envelope-o"></i> <?php $L->p('Send me a login access code') ?></a>

View File

@ -38,4 +38,4 @@ echo '
echo '
</tbody>
</table>
';
';

View File

@ -52,4 +52,4 @@ echo '
}
?>
</ul>
</div>
</div>

View File

@ -7,12 +7,12 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
// Security token
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
// ---- LEFT SIDE ----
echo '<div class="uk-grid">';
echo '<div class="uk-width-large-7-10">';
echo '<div class="uk-width-large-8-10">';
// Title input
HTML::formInputText(array(
@ -39,7 +39,7 @@ echo '<div class="uk-width-large-7-10">';
echo '</div>';
// ---- RIGHT SIDE ----
echo '<div class="uk-width-large-3-10">';
echo '<div class="sidebar uk-width-large-2-10">';
// Tabs, general and advanced mode
echo '<ul class="uk-tab" data-uk-tab="{connect:\'#tab-options\'}">';
@ -58,18 +58,19 @@ echo '<div class="uk-width-large-3-10">';
'name'=>'description',
'label'=>$L->g('description'),
'value'=>'',
'rows'=>'7',
'rows'=>'4',
'class'=>'uk-width-1-1 uk-form-medium',
'tip'=>$L->g('this-field-can-help-describe-the-content')
));
// Tags input
HTML::formInputText(array(
HTML::tagsAutocomplete(array(
'name'=>'tags',
'value'=>'',
'tip'=>$L->g('Type the tag and press enter'),
'class'=>'uk-width-1-1 uk-form-large',
'tip'=>$L->g('Write the tags separated by commas'),
'label'=>$L->g('Tags')
'label'=>$L->g('Tags'),
'words'=>'"'.implode('", "', $dbTags->getAll()).'"'
));
echo '</li>';
@ -77,13 +78,32 @@ echo '<div class="uk-width-large-3-10">';
// ---- IMAGES TAB ----
echo '<li>';
HTML::uploader();
// --- BLUDIT COVER IMAGE ---
echo '<hr>';
HTML::bluditCoverImage();
echo '<hr>';
// --- BLUDIT QUICK IMAGES ---
HTML::bluditQuickImages();
// --- BLUDIT IMAGES V8 ---
HTML::bluditImagesV8();
echo '</li>';
// ---- ADVANCED TAB ----
echo '<li>';
// Status input
HTML::formSelect(array(
'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'=>'published',
'tip'=>''
));
// Parent input
$options = array();
$options[NO_PARENT_CHAR] = '('.$Language->g('No parent').')';
@ -98,16 +118,6 @@ echo '<div class="uk-width-large-3-10">';
'tip'=>''
));
// Status input
HTML::formSelect(array(
'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'=>'published',
'tip'=>''
));
// Position input
HTML::formInputText(array(
'name'=>'position',
@ -170,4 +180,4 @@ $(document).ready(function()
});
</script>
</script>

View File

@ -7,12 +7,12 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
// Security token
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
// ---- LEFT SIDE ----
echo '<div class="uk-grid">';
echo '<div class="uk-width-large-7-10">';
echo '<div class="uk-width-large-8-10">';
// Title input
HTML::formInputText(array(
@ -39,7 +39,7 @@ echo '<div class="uk-width-large-7-10">';
echo '</div>';
// ---- RIGHT SIDE ----
echo '<div class="uk-width-large-3-10">';
echo '<div class="sidebar uk-width-large-2-10">';
// Tabs, general and advanced mode
echo '<ul class="uk-tab" data-uk-tab="{connect:\'#tab-options\'}">';
@ -58,18 +58,19 @@ echo '<div class="uk-width-large-3-10">';
'name'=>'description',
'label'=>$L->g('description'),
'value'=>'',
'rows'=>'7',
'rows'=>'4',
'class'=>'uk-width-1-1 uk-form-medium',
'tip'=>$L->g('this-field-can-help-describe-the-content')
));
// Tags input
HTML::formInputText(array(
HTML::tagsAutocomplete(array(
'name'=>'tags',
'value'=>'',
'tip'=>$L->g('Type the tag and press enter'),
'class'=>'uk-width-1-1 uk-form-large',
'tip'=>$L->g('Write the tags separated by commas'),
'label'=>$L->g('Tags')
'label'=>$L->g('Tags'),
'words'=>'"'.implode('", "', $dbTags->getAll()).'"'
));
echo '</li>';
@ -77,22 +78,22 @@ echo '<div class="uk-width-large-3-10">';
// ---- IMAGES TAB ----
echo '<li>';
HTML::uploader();
// --- BLUDIT COVER IMAGE ---
echo '<hr>';
HTML::bluditCoverImage();
echo '<hr>';
// --- BLUDIT QUICK IMAGES ---
HTML::bluditQuickImages();
// --- BLUDIT IMAGES V8 ---
HTML::bluditImagesV8();
echo '</li>';
// ---- ADVANCED TAB ----
echo '<li>';
// Date input
HTML::formInputText(array(
'name'=>'date',
'value'=>Date::current(DB_DATE_FORMAT),
'class'=>'uk-width-1-1 uk-form-large',
'tip'=>$L->g('To schedule the post just select the date and time'),
'label'=>$L->g('Date')
));
// Status input
HTML::formSelect(array(
'name'=>'status',
@ -103,6 +104,15 @@ echo '<div class="uk-width-large-3-10">';
'tip'=>''
));
// Date input
HTML::formInputText(array(
'name'=>'date',
'value'=>Date::current(DB_DATE_FORMAT),
'class'=>'uk-width-1-1 uk-form-large',
'tip'=>$L->g('To schedule the post just select the date and time'),
'label'=>$L->g('Date')
));
// Slug input
HTML::formInputText(array(
'name'=>'slug',
@ -140,4 +150,4 @@ $(document).ready(function() {
});
</script>
</script>

View File

@ -0,0 +1,52 @@
<?php
HTML::title(array('title'=>$L->g('Plugins'), 'icon'=>'puzzle-piece'));
echo '
<table class="uk-table">
<thead>
<tr>
<th class="uk-width-1-5">'.$L->g('Name').'</th>
<th class="uk-width-3-5">'.$L->g('Description').'</th>
<th class="uk-text-center">'.$L->g('Version').'</th>
<th class="uk-text-center">'.$L->g('Author').'</th>
</tr>
</thead>
<tbody>
';
foreach($plugins['all'] as $Plugin)
{
echo '
<tr '.($Plugin->installed()?'class="plugin-installed"':'class="plugin-notInstalled"').'>
<td>
<div class="plugin-name">'.$Plugin->name().'</div>
<div class="plugin-links">
';
if($Plugin->installed()) {
if(method_exists($Plugin, 'form')) {
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().'">'.$L->g('Activate').'</a>';
}
echo '
</div>
</td>
<td>'.$Plugin->description().'</td>
<td class="uk-text-center">'.$Plugin->version().'</td>
<td class="uk-text-center"><a targe="_blank" href="'.$Plugin->website().'">'.$Plugin->author().'</a></td>
';
echo '</tr>';
}
echo '
</tbody>
</table>
';

View File

@ -6,9 +6,11 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child'));
HTML::formSelect(array(
'name'=>'postsperpage',
'label'=>$L->g('Posts per page'),
@ -82,6 +84,14 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'tip'=>''
));
HTML::formInputText(array(
'name'=>'uriBlog',
'label'=>$L->g('Blog'),
'value'=>$Site->uriFilters('blog'),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>''
));
echo '<div class="uk-form-row">
<div class="uk-form-controls">
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>

View File

@ -7,9 +7,11 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
// Security token
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
HTML::legend(array('value'=>$L->g('Site information'), 'class'=>'first-child'));
HTML::formInputText(array(
'name'=>'title',
'label'=>$L->g('Site title'),
@ -48,4 +50,4 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
</div>
</div>';
HTML::formClose();
HTML::formClose();

View File

@ -6,9 +6,11 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child'));
HTML::formSelect(array(
'name'=>'language',
'label'=>$L->g('Language'),
@ -35,6 +37,8 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'tip'=>$L->g('you-can-use-this-field-to-define-a-set-off')
));
HTML::legend(array('value'=>$L->g('Date and time formats')));
HTML::formInputText(array(
'name'=>'dateFormat',
'label'=>$L->g('Date format'),
@ -63,4 +67,4 @@ $(document).ready(function() {
});
</script>
</script>

View File

@ -0,0 +1,45 @@
<?php
HTML::title(array('title'=>$L->g('Themes'), 'icon'=>'paint-brush'));
echo '
<table class="uk-table">
<thead>
<tr>
<th class="uk-width-1-5">'.$L->g('Name').'</th>
<th class="uk-width-3-5">'.$L->g('Description').'</th>
<th class="uk-text-center">'.$L->g('Version').'</th>
<th class="uk-text-center">'.$L->g('Author').'</th>
</tr>
</thead>
<tbody>
';
foreach($themes as $theme)
{
echo '
<tr '.($theme['dirname']==$Site->theme()?'class="theme-installed"':'class="theme-notInstalled"').'>
<td>
<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'].'">'.$L->g('Activate').'</a>';
}
echo '
</div>
</td>
<td>'.$theme['description'].'</td>
<td class="uk-text-center">'.$theme['version'].'</td>
<td class="uk-text-center"><a targe="_blank" href="'.$theme['website'].'">'.$theme['author'].'</a></td>
';
echo '</tr>';
}
echo '
</tbody>
</table>
';

View File

@ -7,7 +7,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
// Security token
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getToken()
'value'=>$Security->getTokenCSRF()
));
// Hidden field username
@ -52,4 +52,4 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
HTML::formClose();
?>
?>

View File

@ -35,4 +35,4 @@ foreach($users as $username=>$field)
echo '
</tbody>
</table>
';
';

View File

@ -0,0 +1,67 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
header('Content-Type: application/json');
// Type
$type = 'other';
if(!empty($_POST['type'])) {
$type = Sanitize::html($_POST['type']);
}
// Source.
$source = $_FILES['files']['tmp_name'][0];
// Filename and extension.
$filename = Text::lowercase($_FILES['files']['name'][0]);
$fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
$filename = pathinfo($filename, PATHINFO_FILENAME);
$filename = Text::replace(' ', '', $filename);
$filename = Text::replace('_', '', $filename);
// Generate the next filename if the filename already exist.
$tmpName = $filename.'.'.$fileExtension;
if( file_exists(PATH_UPLOADS.$tmpName) )
{
$number = 0;
$tmpName = $filename.'_'.$number.'.'.$fileExtension;
while(file_exists(PATH_UPLOADS.$tmpName)) {
$number++;
$tmpName = $filename.'_'.$number.'.'.$fileExtension;
}
}
// Move from temporary PHP folder to temporary Bludit folder.
move_uploaded_file($source, PATH_TMP.'original'.'.'.$fileExtension);
// --- PROFILE PICTURE ---
if($type=='profilePicture')
{
// Resize and crop profile image.
$username = Sanitize::html($_POST['username']);
$tmpName = $username.'.png';
$Image = new Image();
$Image->setImage(PATH_TMP.'original'.'.'.$fileExtension, '400', '400', 'crop');
$Image->saveImage(PATH_UPLOADS_PROFILES.$tmpName, 100, false, true);
}
// --- OTHERS ---
else {
// Generate the thumbnail
$Image = new Image();
$Image->setImage(PATH_TMP.'original'.'.'.$fileExtension, THUMBNAILS_WIDTH, THUMBNAILS_HEIGHT, 'crop');
$Image->saveImage(PATH_UPLOADS_THUMBNAILS.$tmpName, 100, true);
// Move the original to the upload folder.
rename(PATH_TMP.'original'.'.'.$fileExtension, PATH_UPLOADS.$tmpName);
}
// Remove the Bludit temporary file.
if(file_exists(PATH_TMP.'original'.'.'.$fileExtension)) {
unlink(PATH_TMP.'original'.'.'.$fileExtension);
}
exit(json_encode(array(
'status'=>0,
'filename'=>$tmpName
)));
?>

View File

@ -15,7 +15,7 @@ $layout['controller'] = $layout['view'] = $layout['slug'] = $explodeSlug[0];
unset($explodeSlug[0]);
$layout['parameters'] = implode('/', $explodeSlug);
// Disable Magic Quotes
// Disable Magic Quotes.
// Thanks, http://stackoverflow.com/questions/517008/how-to-turn-off-magic-quotes-on-shared-hosting
if ( in_array( strtolower( ini_get( 'magic_quotes_gpc' ) ), array( '1', 'on' ) ) )
{
@ -24,29 +24,34 @@ if ( in_array( strtolower( ini_get( 'magic_quotes_gpc' ) ), array( '1', 'on' ) )
$_COOKIE = array_map('stripslashes', $_COOKIE);
}
// AJAX
// --- AJAX ---
if( $layout['slug']==='ajax' )
{
// Check if the user is loggued.
if($Login->isLogged())
{
// Load AJAX file
// Load the ajax file.
if( Sanitize::pathFile(PATH_AJAX, $layout['parameters'].'.php') ) {
include(PATH_AJAX.$layout['parameters'].'.php');
}
}
}
// ADMIN AREA
// --- ADMIN AREA ---
else
{
// Boot rules
include(PATH_RULES.'60.plugins.php');
include(PATH_RULES.'70.posts.php');
include(PATH_RULES.'70.pages.php');
include(PATH_RULES.'80.plugins.php');
include(PATH_RULES.'71.pages.php');
include(PATH_RULES.'99.header.php');
include(PATH_RULES.'99.paginator.php');
include(PATH_RULES.'99.themes.php');
include(PATH_RULES.'99.security.php');
// Page not found.
// User not logged.
// Slug is login.
// Slug is login-email.
if($Url->notFound() || !$Login->isLogged() || ($Url->slug()==='login') || ($Url->slug()==='login-email') )
{
$layout['controller'] = 'login';
@ -59,28 +64,29 @@ else
$layout['view'] = 'login-email';
}
// Generate the token for the user not logged, when the user is loggued the token will be change.
$Security->generateToken();
// Generate the tokenCSRF for the user not logged, when the user log-in the token will be change.
$Security->generateTokenCSRF();
}
// Plugins before admin area loaded
// Load plugins before the admin area will be load.
Theme::plugins('beforeAdminLoad');
// Admin theme init.php
// Load init.php if the theme has one.
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().DS.'init.php') ) {
include(PATH_ADMIN_THEMES.$Site->adminTheme().DS.'init.php');
}
// Load controller
// Load controller.
if( Sanitize::pathFile(PATH_ADMIN_CONTROLLERS, $layout['controller'].'.php') ) {
include(PATH_ADMIN_CONTROLLERS.$layout['controller'].'.php');
}
// Load view and theme
// Load view and theme.
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().DS.$layout['template']) ) {
include(PATH_ADMIN_THEMES.$Site->adminTheme().DS.$layout['template']);
}
// Plugins after admin area loaded
// Load plugins after the admin area is loaded.
Theme::plugins('afterAdminLoad');
}
}

View File

@ -4,7 +4,7 @@
define('BLUDIT_VERSION', 'githubVersion');
define('BLUDIT_CODENAME', '');
define('BLUDIT_RELEASE_DATE', '');
define('BLUDIT_BUILD', '20151119');
define('BLUDIT_BUILD', '20160121');
// Debug mode
define('DEBUG_MODE', TRUE);
@ -21,22 +21,28 @@ if(DEBUG_MODE)
// PHP paths
// PATH_ROOT and PATH_BOOT are defined in index.php
define('PATH_LANGUAGES', PATH_ROOT.'languages'.DS);
define('PATH_THEMES', PATH_ROOT.'themes'.DS);
define('PATH_PLUGINS', PATH_ROOT.'plugins'.DS);
define('PATH_KERNEL', PATH_ROOT.'kernel'.DS);
define('PATH_LANGUAGES', PATH_ROOT.'bl-languages'.DS);
define('PATH_THEMES', PATH_ROOT.'bl-themes'.DS);
define('PATH_PLUGINS', PATH_ROOT.'bl-plugins'.DS);
define('PATH_KERNEL', PATH_ROOT.'bl-kernel'.DS);
define('PATH_CONTENT', PATH_ROOT.'bl-content'.DS);
define('PATH_ABSTRACT', PATH_KERNEL.'abstract'.DS);
define('PATH_RULES', PATH_KERNEL.'boot'.DS.'rules'.DS);
define('PATH_HELPERS', PATH_KERNEL.'helpers'.DS);
define('PATH_AJAX', PATH_KERNEL.'ajax'.DS);
define('PATH_JS', PATH_KERNEL.'js'.DS);
define('PATH_CONTENT', PATH_ROOT.'content'.DS);
define('PATH_POSTS', PATH_CONTENT.'posts'.DS);
define('PATH_PAGES', PATH_CONTENT.'pages'.DS);
define('PATH_DATABASES', PATH_CONTENT.'databases'.DS);
define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases'.DS.'plugins'.DS);
define('PATH_TMP', PATH_CONTENT.'tmp'.DS);
define('PATH_UPLOADS', PATH_CONTENT.'uploads'.DS);
define('PATH_UPLOADS_PROFILES', PATH_UPLOADS.'profiles'.DS);
define('PATH_UPLOADS_THUMBNAILS', PATH_UPLOADS.'thumbnails'.DS);
define('PATH_ADMIN', PATH_KERNEL.'admin'.DS);
define('PATH_ADMIN_THEMES', PATH_ADMIN.'themes'.DS);
define('PATH_ADMIN_CONTROLLERS', PATH_ADMIN.'controllers'.DS);
@ -56,6 +62,11 @@ define('ALERT_STATUS_OK', 0);
// Alert status fail
define('ALERT_STATUS_FAIL', 1);
// Salt length
define('THUMBNAILS_WIDTH', 400);
define('THUMBNAILS_HEIGHT', 400);
define('THUMBNAILS_AMOUNT', 6);
// Salt length
define('SALT_LENGTH', 8);
@ -69,13 +80,16 @@ define('NO_PARENT_CHAR', '3849abb4cb7abd24c2d8dac17b216f17');
define('POSTS_PER_PAGE_ADMIN', 10);
// Check if JSON encode and decode are enabled.
define('JSON', function_exists('json_encode'));
// define('JSON', function_exists('json_encode'));
// TRUE if new posts hand-made set published, or FALSE for draft.
define('CLI_STATUS', 'published');
// Database format date
define('DB_DATE_FORMAT', 'Y-m-d H:i');
// Database date format
define('DB_DATE_FORMAT', 'Y-m-d H:i:s');
// Sitemap date format
define('SITEMAP_DATE_FORMAT', 'Y-m-d');
// Date format for Dashboard schedule posts
define('SCHEDULED_DATE_FORMAT', 'd M - h:i a');
@ -87,7 +101,7 @@ define('TOKEN_EMAIL_TTL', '+15 minutes');
define('CHARSET', 'UTF-8');
// Directory permissions
define('DIR_PERMISSIONS', '0755');
define('DIR_PERMISSIONS', 0755);
// Multibyte string extension loaded.
define('MB_STRING', extension_loaded('mbstring'));
@ -103,7 +117,7 @@ if(MB_STRING)
// Inclde Abstract Classes
include(PATH_ABSTRACT.'dbjson.class.php');
include(PATH_ABSTRACT.'filecontent.class.php');
include(PATH_ABSTRACT.'content.class.php');
include(PATH_ABSTRACT.'plugin.class.php');
// Inclde Classes
@ -115,6 +129,7 @@ include(PATH_KERNEL.'dblanguage.class.php');
include(PATH_KERNEL.'dbsite.class.php');
include(PATH_KERNEL.'post.class.php');
include(PATH_KERNEL.'page.class.php');
include(PATH_KERNEL.'user.class.php');
include(PATH_KERNEL.'url.class.php');
include(PATH_KERNEL.'login.class.php');
include(PATH_KERNEL.'parsedown.class.php');
@ -140,7 +155,7 @@ include(PATH_HELPERS.'image.class.php');
Session::start();
if(Session::started()===false) {
Log::set('init.php'.LOG_SEP.'Error occurred when trying to start the session.');
exit('Bludit CMS. Failed to start session.');
exit('Bludit. Failed to start session.');
}
// Objects
@ -153,52 +168,76 @@ $Url = new Url();
$Parsedown = new ParsedownExtra();
$Security = new Security();
// HTML PATHs
$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$base = dirname($base);
// --- Relative paths ---
// This paths are relative for the user / web browsing.
// Base URL
// The user can define the base URL.
// Left empty if you want to Bludit try to detect the base URL.
$base = '';
if( !empty($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['SCRIPT_NAME']) && empty($base) ) {
$base = str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_NAME']);
$base = dirname($base);
}
elseif( empty($base) ) {
$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$base = dirname($base);
}
if($base!=DS) {
$base = $base.'/';
$base = trim($base, '/');
$base = '/'.$base.'/';
}
else {
// Workaround for Windows Web Servers
$base = '/';
}
define('HTML_PATH_ROOT', $base);
// Paths for themes
define('HTML_PATH_THEMES', HTML_PATH_ROOT.'themes/');
define('HTML_PATH_THEME', HTML_PATH_ROOT.'themes/'.$Site->theme().'/');
define('HTML_PATH_ROOT', $base);
define('HTML_PATH_THEMES', HTML_PATH_ROOT.'bl-themes/');
define('HTML_PATH_THEME', HTML_PATH_THEMES.$Site->theme().'/');
define('HTML_PATH_THEME_CSS', HTML_PATH_THEME.'css/');
define('HTML_PATH_THEME_JS', HTML_PATH_THEME.'js/');
define('HTML_PATH_THEME_IMG', HTML_PATH_THEME.'img/');
define('HTML_PATH_ADMIN_ROOT', HTML_PATH_ROOT.'admin/');
define('HTML_PATH_ADMIN_THEME', HTML_PATH_ROOT.'kernel/admin/themes/'.$Site->adminTheme().'/');
define('HTML_PATH_ADMIN_THEME', HTML_PATH_ROOT.'bl-kernel/admin/themes/'.$Site->adminTheme().'/');
define('HTML_PATH_ADMIN_THEME_JS', HTML_PATH_ADMIN_THEME.'js/');
define('HTML_PATH_ADMIN_THEME_CSS', HTML_PATH_ADMIN_THEME.'css/');
define('HTML_PATH_ADMIN_THEME_IMG', HTML_PATH_ADMIN_THEME.'img/');
define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'content/uploads/');
define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'bl-content/uploads/');
define('HTML_PATH_UPLOADS_PROFILES', HTML_PATH_UPLOADS.'profiles/');
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'plugins/');
define('HTML_PATH_UPLOADS_THUMBNAILS', HTML_PATH_UPLOADS.'thumbnails/');
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/');
define('JQUERY', HTML_PATH_ADMIN_THEME_JS.'jquery.min.js');
// PHP paths with dependency
define('PATH_THEME', PATH_ROOT.'themes'.DS.$Site->theme().DS);
// --- PHP paths with dependency ---
// This paths are absolutes for the OS.
define('PATH_THEME', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS);
define('PATH_THEME_PHP', PATH_THEME.'php'.DS);
define('PATH_THEME_CSS', PATH_THEME.'css'.DS);
define('PATH_THEME_JS', PATH_THEME.'js'.DS);
define('PATH_THEME_IMG', PATH_THEME.'img'.DS);
define('PATH_THEME_LANG', PATH_THEME.'languages'.DS);
// Objects with dependency
// --- Absolute paths with domain ---
// This paths are absolutes for the user / web browsing.
define('DOMAIN', $Site->domain());
define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT);
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);
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
// --- Objects shortcuts ---
$L = $Language;

View File

@ -24,6 +24,15 @@ $plugins = array(
'beforeAdminLoad'=>array(),
'afterAdminLoad'=>array(),
'beforeRulesLoad'=>array(),
'afterPostCreate'=>array(),
'afterPostModify'=>array(),
'afterPostDelete'=>array(),
'afterPageCreate'=>array(),
'afterPageModify'=>array(),
'afterPageDelete'=>array(),
'loginHead'=>array(),
'loginBodyBegin'=>array(),
'loginBodyEnd'=>array(),
@ -38,7 +47,7 @@ unset($pluginsEvents['all']);
// Functions
// ============================================================================
function build_plugins()
function buildPlugins()
{
global $plugins;
global $pluginsEvents;
@ -63,26 +72,24 @@ function build_plugins()
{
$Plugin = new $pluginClass;
// Default language and meta data for the plugin
$tmpMetaData = array();
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.'en_US.json';
$database = new dbJSON($languageFilename, false);
$tmpMetaData = $database->db['plugin-data'];
// Check if the plugin is translated.
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json';
if( Sanitize::pathFile($languageFilename) )
{
$database = new dbJSON($languageFilename, false);
$tmpMetaData = array_merge($tmpMetaData, $database->db['plugin-data']);
if( !Sanitize::pathFile($languageFilename) ) {
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.'en_US.json';
}
// Set plugin meta data
$Plugin->setData($tmpMetaData);
$database = file_get_contents($languageFilename);
$database = json_decode($database, true);
// Add words to language dictionary.
unset($database->db['plugin-data']);
$Language->add($database->db);
// Set name and description from the language file.
$Plugin->setMetadata('name',$database['plugin-data']['name']);
$Plugin->setMetadata('description',$database['plugin-data']['description']);
// Remove name and description, and add new words if there are.
unset($database['plugin-data']);
if(!empty($database)) {
$Language->add($database);
}
// Push Plugin to array all plugins installed and not installed.
$plugins['all'][$pluginClass] = $Plugin;
@ -104,4 +111,4 @@ function build_plugins()
// Main
// ============================================================================
build_plugins();
buildPlugins();

View File

@ -4,6 +4,8 @@
// Variables
// ============================================================================
// Array with all posts specified by a filter.
// Filter by page number, by tag, etc.
$posts = array();
// ============================================================================
@ -42,7 +44,7 @@ function buildPost($key)
}
// Post database, content from DATABASE JSON.
$db = $dbPosts->getDb($key);
$db = $dbPosts->getPostDB($key);
if( !$db ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the post from database with key: '.$key);
return false;
@ -75,14 +77,9 @@ function buildPost($key)
$postDateFormated = $Post->dateRaw( $Site->dateFormat() );
$Post->setField('date', $postDateFormated, true);
// Parse username for the post.
if( $dbUsers->userExists( $Post->username() ) )
{
$user = $dbUsers->getDb( $Post->username() );
$Post->setField('authorFirstName', $user['firstName'], false);
$Post->setField('authorLastName', $user['lastName'], false);
}
// User object
$username = $Post->username();
$Post->setField('user', $dbUsers->getUser($username));
return $Post;
}
@ -91,9 +88,10 @@ function buildPostsForPage($pageNumber=0, $amount=POSTS_PER_PAGE_ADMIN, $removeU
{
global $dbPosts;
global $dbTags;
global $posts;
global $Url;
$posts = array();
if($tagKey) {
// Get the keys list from tags database, this database is optimized for this case.
$list = $dbTags->getList($pageNumber, $amount, $tagKey);
@ -116,6 +114,8 @@ function buildPostsForPage($pageNumber=0, $amount=POSTS_PER_PAGE_ADMIN, $removeU
array_push($posts, $Post);
}
}
return $posts;
}
// ============================================================================
@ -140,11 +140,13 @@ if( ($Url->whereAmI()==='post') && ($Url->notFound()===false) )
{
$Post = buildPost( $Url->slug() );
// The post doesn't exist.
if($Post===false)
{
$Url->setNotFound(true);
unset($Post);
}
// The post is not published yet.
elseif( !$Post->published() )
{
$Url->setNotFound(true);
@ -159,17 +161,17 @@ if( ($Url->whereAmI()==='post') && ($Url->notFound()===false) )
// Build posts by specific tag.
elseif( ($Url->whereAmI()==='tag') && ($Url->notFound()===false) )
{
buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true, $Url->slug());
$posts = buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true, $Url->slug());
}
// Build posts for homepage or admin area.
else
{
// Posts for admin area.
if($Url->whereAmI()==='admin') {
buildPostsForPage($Url->pageNumber(), POSTS_PER_PAGE_ADMIN, false);
$posts = buildPostsForPage($Url->pageNumber(), POSTS_PER_PAGE_ADMIN, false);
}
// Posts for homepage
else {
buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true);
// Posts for home and blog filter.
elseif( ( ($Url->whereAmI()==='home') || ($Url->whereAmI()==='blog') ) && ($Url->notFound()===false) ) {
$posts = buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true);
}
}
}

View File

@ -23,11 +23,12 @@ function sortPages($a, $b)
return ($a->position() < $b->position()) ? -1 : 1;
}
function build_page($key)
function buildPage($key)
{
global $dbPages;
global $dbUsers;
global $Parsedown;
global $Site;
// Page object, content from FILE.
$Page = new Page($key);
@ -37,7 +38,7 @@ function build_page($key)
}
// Page database, content from DATABASE JSON.
$db = $dbPages->getDb($key);
$db = $dbPages->getPageDB($key);
if( !$db ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the page from database with key: '.$key);
return false;
@ -58,31 +59,40 @@ function build_page($key)
$content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS); // Parse img src relative to absolute.
$Page->setField('content', $content, true);
// Parse username for the page.
if( $dbUsers->userExists( $Page->username() ) )
{
$user = $dbUsers->getDb( $Page->username() );
// Pagebrake
$explode = explode(PAGE_BREAK, $content);
$Page->setField('breakContent', $explode[0], true);
$Page->setField('readMore', !empty($explode[1]), true);
$Page->setField('authorFirstName', $user['firstName'], false);
$Page->setField('authorLastName', $user['lastName'], false);
}
// Date format
$pageDate = $Page->date();
$Page->setField('dateRaw', $pageDate, true);
$pageDateFormated = $Page->dateRaw( $Site->dateFormat() );
$Page->setField('date', $pageDateFormated, true);
// User object
$username = $Page->username();
$Page->setField('user', $dbUsers->getUser($username));
return $Page;
}
function build_all_pages()
function buildAllPages()
{
global $pages;
global $pagesParents;
global $dbPages;
$list = $dbPages->getAll();
$list = $dbPages->getDB();
// Clean pages array.
$pages = array();
unset($list['error']);
foreach($list as $key=>$db)
{
$Page = build_page($key);
$Page = buildPage($key);
if($Page!==false)
{
@ -127,6 +137,8 @@ function build_all_pages()
}
$pagesParents = array(NO_PARENT_CHAR=>$parents) + $tmpPageWithParent;
return $pages;
}
// ============================================================================
@ -138,16 +150,18 @@ if( $Site->cliMode() ) {
$dbPages->regenerateCli();
}
// Filter by page, then build it
// Build specific page.
if( ($Url->whereAmI()==='page') && ($Url->notFound()===false) )
{
$Page = build_page( $Url->slug() );
$Page = buildPage( $Url->slug() );
// The page doesn't exist.
if($Page===false)
{
$Url->setNotFound(true);
unset($Page);
}
// The page is not published yet.
elseif( !$Page->published() )
{
$Url->setNotFound(true);
@ -155,14 +169,15 @@ if( ($Url->whereAmI()==='page') && ($Url->notFound()===false) )
}
}
// Default homepage
if($Url->notFound()===false)
// Homepage
if( ($Url->whereAmI()==='home') && ($Url->notFound()===false) )
{
if( Text::isNotEmpty($Site->homepage()) && ($Url->whereAmI()==='home') )
// The user defined as homepage a particular page.
if( Text::isNotEmpty( $Site->homepage() ) )
{
$Url->setWhereAmI('page');
$Page = build_page( $Site->homepage() );
$Page = buildPage( $Site->homepage() );
if($Page===false) {
$Url->setWhereAmI('home');
@ -177,4 +192,4 @@ if($Url->notFound())
}
// Build all pages
build_all_pages();
$pages = buildAllPages();

View File

@ -9,6 +9,11 @@ if($Url->whereAmI()=='admin') {
$postPerPage = POSTS_PER_PAGE_ADMIN;
$numberOfPosts = $dbPosts->numberPost(true); // published and drafts
}
elseif($Url->whereAmI()=='tag') {
$postPerPage = $Site->postsPerPage();
$tagKey = $Url->slug();
$numberOfPosts = $dbTags->countPostsByTag($tagKey);
}
else {
$postPerPage = $Site->postsPerPage();
$numberOfPosts = $dbPosts->numberPost(false); // published

View File

@ -20,9 +20,9 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
$token = isset($_POST['tokenCSRF']) ? Sanitize::html($_POST['tokenCSRF']) : false;
if( !$Security->validateToken($token) )
if( !$Security->validateTokenCSRF($token) )
{
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying validate the tokenCSRF. Token CSRF ID: '.$token);
Log::set(__FILE__.LOG_SEP.'Error occurred when trying to validate the tokenCSRF. Token CSRF ID: '.$token);
// Destroy the session.
Session::destroy();
@ -38,4 +38,4 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================

View File

@ -0,0 +1,84 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Variables
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
function buildThemes()
{
global $Site;
$themes = array();
$themesPaths = Filesystem::listDirectories(PATH_THEMES);
foreach($themesPaths as $themePath)
{
// Check if the theme is translated.
$languageFilename = $themePath.DS.'languages'.DS.$Site->locale().'.json';
if( !Sanitize::pathFile($languageFilename) ) {
$languageFilename = $themePath.DS.'languages'.DS.'en_US.json';
}
if( Sanitize::pathFile($languageFilename) )
{
$database = file_get_contents($languageFilename);
$database = json_decode($database, true);
if(empty($database)) {
Log::set('99.themes.php'.LOG_SEP.'JSON Error on theme '.$themePath);
break;
}
$database = $database['theme-data'];
$database['dirname'] = basename($themePath);
// --- Metadata ---
$filenameMetadata = $themePath.DS.'metadata.json';
if( Sanitize::pathFile($filenameMetadata) )
{
$metadataString = file_get_contents($filenameMetadata);
$metadata = json_decode($metadataString, true);
if(empty($metadata)) {
Log::set('99.themes.php'.LOG_SEP.'JSON Error on theme '.$themePath);
break;
}
$database = $database + $metadata;
// Theme data
array_push($themes, $database);
}
}
}
return $themes;
}
// ============================================================================
// Main
// ============================================================================
// Load the language file
$languageFilename = PATH_THEME.DS.'languages'.DS.$Site->locale().'.json';
if( !Sanitize::pathFile($languageFilename) ) {
$languageFilename = PATH_THEME.DS.'languages'.DS.'en_US.json';
}
if( Sanitize::pathFile($languageFilename) )
{
$database = file_get_contents($languageFilename);
$database = json_decode($database, true);
// Remote the name and description.
unset($database['theme-data']);
// Load words from the theme language
if(!empty($database)) {
$Language->add($database);
}
}

View File

@ -1,9 +1,14 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// Boot rules
// Load plugins rules
include(PATH_RULES.'60.plugins.php');
// Plugins before rules loaded, except plugins rules
Theme::plugins('beforeRulesLoad');
// Load rules
include(PATH_RULES.'70.posts.php');
include(PATH_RULES.'70.pages.php');
include(PATH_RULES.'80.plugins.php');
include(PATH_RULES.'71.pages.php');
include(PATH_RULES.'99.header.php');
include(PATH_RULES.'99.paginator.php');
include(PATH_RULES.'99.themes.php');
@ -25,4 +30,4 @@ else {
}
// Plugins after site loaded
Theme::plugins('afterSiteLoad');
Theme::plugins('afterSiteLoad');

View File

@ -106,4 +106,4 @@ class dbLanguage extends dbJSON
return $tmp;
}
}
}

View File

@ -12,7 +12,9 @@ class dbPages extends dbJSON
'tags'=> array('inFile'=>false, 'value'=>array()),
'status'=> array('inFile'=>false, 'value'=>'draft'),
'date'=> array('inFile'=>false, 'value'=>''),
'position'=> array('inFile'=>false, 'value'=>0)
'position'=> array('inFile'=>false, 'value'=>0),
'coverImage'=> array('inFile'=>false, 'value'=>''),
'checksum'=> array('inFile'=>false, 'value'=>'')
);
function __construct()
@ -74,6 +76,10 @@ class dbPages extends dbJSON
}
}
// Create Hash
$serialize = serialize($dataForDb+$dataForFile);
$dataForDb['checksum'] = sha1($serialize);
// Make the directory. Recursive.
if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_PAGES.$key);
@ -94,7 +100,7 @@ class dbPages extends dbJSON
return false;
}
return true;
return $key;
}
public function edit($args)
@ -156,6 +162,10 @@ class dbPages extends dbJSON
}
}
// Create Hash
$serialize = serialize($dataForDb+$dataForFile);
$dataForDb['checksum'] = sha1($serialize);
// Move the directory from old key to new key.
if($newKey!==$args['key'])
{
@ -182,7 +192,7 @@ class dbPages extends dbJSON
return false;
}
return true;
return $newKey;
}
public function delete($key)
@ -214,7 +224,7 @@ class dbPages extends dbJSON
}
// Return an array with the database for a page, FALSE otherwise.
public function getDb($key)
public function getPageDB($key)
{
if($this->pageExists($key)) {
return $this->db[$key];
@ -287,8 +297,8 @@ class dbPages extends dbJSON
return $newKey;
}
// Return an array with all databases.
public function getAll()
// Returns the database
public function getDB()
{
return $this->db;
}
@ -418,4 +428,4 @@ class dbPages extends dbJSON
return $this->db!=$db;
}
}
}

View File

@ -10,7 +10,9 @@ class dbPosts extends dbJSON
'status'=> array('inFile'=>false, 'value'=>'draft'), // published, draft, scheduled
'tags'=> array('inFile'=>false, 'value'=>array()),
'allowComments'=> array('inFile'=>false, 'value'=>false),
'date'=> array('inFile'=>false, 'value'=>'')
'date'=> array('inFile'=>false, 'value'=>''),
'coverImage'=> array('inFile'=>false, 'value'=>''),
'checksum'=> array('inFile'=>false, 'value'=>'')
);
private $numberPosts = array(
@ -34,8 +36,14 @@ class dbPosts extends dbJSON
return $this->numberPosts['published'];
}
// Returns the database
public function getDB()
{
return $this->db;
}
// Return an array with the post's database, FALSE otherwise.
public function getDb($key)
public function getPostDB($key)
{
if($this->postExists($key)) {
return $this->db[$key];
@ -44,7 +52,7 @@ class dbPosts extends dbJSON
return false;
}
public function setDb($key, $field, $value)
public function setPostDb($key, $field, $value)
{
if($this->postExists($key)) {
$this->db[$key][$field] = $value;
@ -102,12 +110,12 @@ class dbPosts extends dbJSON
return false;
}
// Date
// If the date not valid, then set the current date.
if(!Valid::date($args['date'], DB_DATE_FORMAT)) {
$args['date'] = $currentDate;
}
// Schedule post?
// Schedule post ?
if( ($args['date']>$currentDate) && ($args['status']=='published') ) {
$args['status'] = 'scheduled';
}
@ -151,6 +159,10 @@ class dbPosts extends dbJSON
}
}
// Create Hash
$serialize = serialize($dataForDb+$dataForFile);
$dataForDb['checksum'] = sha1($serialize);
// Make the directory.
if( Filesystem::mkdir(PATH_POSTS.$key) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_POSTS.$key);
@ -175,7 +187,7 @@ class dbPosts extends dbJSON
return false;
}
return true;
return $key;
}
public function edit($args)
@ -302,7 +314,7 @@ class dbPosts extends dbJSON
$saveDatabase = false;
// Check scheduled posts and publish.
// Check scheduled posts
foreach($this->db as $postKey=>$values)
{
if($values['status']=='scheduled')
@ -318,7 +330,7 @@ class dbPosts extends dbJSON
}
}
// Save the database.
// Save the database ?
if($saveDatabase)
{
if( $this->save() === false ) {
@ -409,7 +421,7 @@ class dbPosts extends dbJSON
// All keys posts
$allPosts[$key] = true;
// Create the new entry if not exists on DATABASE.
// Create the new entry if not exist on DATABASE.
if(!isset($this->db[$key])) {
// New entry on database
$this->db[$key] = $fields;
@ -435,7 +447,7 @@ class dbPosts extends dbJSON
if(Valid::date($valueFromFile, DB_DATE_FORMAT)) {
$this->db[$key]['date'] = $valueFromFile;
if( $valueFromFile>$currentDate ) {
if( $valueFromFile > $currentDate ) {
$this->db[$key]['status'] = 'scheduled';
}
}
@ -466,4 +478,4 @@ class dbPosts extends dbJSON
return $this->db!=$db;
}
}
}

View File

@ -17,6 +17,7 @@ class dbSite extends dbJSON
'uriPage'=> array('inFile'=>false, 'value'=>'/'),
'uriPost'=> array('inFile'=>false, 'value'=>'/post/'),
'uriTag'=> array('inFile'=>false, 'value'=>'/tag/'),
'uriBlog'=> array('inFile'=>false, 'value'=>'/blog/'),
'url'=> array('inFile'=>false, 'value'=>''),
'cliMode'=> array('inFile'=>false, 'value'=>true),
'emailFrom'=> array('inFile'=>false, 'value'=>''),
@ -67,6 +68,7 @@ class dbSite extends dbJSON
$filters['post'] = $this->getField('uriPost');
$filters['page'] = $this->getField('uriPage');
$filters['tag'] = $this->getField('uriTag');
$filters['blog'] = $this->getField('uriBlog');
if(empty($filter)) {
return $filters;
@ -93,6 +95,12 @@ class dbSite extends dbJSON
return $this->url().ltrim($filter, '/');
}
public function urlBlog()
{
$filter = $this->getField('uriBlog');
return $this->url().ltrim($filter, '/');
}
// Returns the site title.
public function title()
{
@ -144,12 +152,40 @@ class dbSite extends dbJSON
return $this->getField('footer');
}
// Returns the url site.
// Returns the full domain and base url.
// For example, http://www.domain.com/bludit/
public function url()
{
return $this->getField('url');
}
// Returns the protocol and the domain, without the base url.
// For example, http://www.domain.com
public function domain()
{
// If the URL field is not set, try detect the domain.
if(Text::isEmpty( $this->url() ))
{
if(!empty($_SERVER['HTTPS'])) {
$protocol = 'https://';
}
else {
$protocol = 'http://';
}
$domain = trim($_SERVER['HTTP_HOST'], '/');
return $protocol.$domain;
}
// Parse the domain from the field URL.
$parse = parse_url($this->url());
$domain = trim($parse['host'], '/');
return $parse['scheme'].'://'.$domain;
}
// Returns TRUE if the cli mode is enabled, otherwise FALSE.
public function cliMode()
{

View File

@ -18,6 +18,16 @@ class dbTags extends dbJSON
parent::__construct(PATH_DATABASES.'tags.php');
}
// Returns an array with all tags names
public function getAll()
{
$tmp = array();
foreach($this->db['postsIndex'] as $tagSlug=>$tagInfo) {
$tmp[$tagSlug] = $tagInfo['name'];
}
return $tmp;
}
// Returns an array with a list of posts keys, filtered by a page number and a tag key.
public function getList($pageNumber, $postPerPage, $tagKey)
{
@ -84,4 +94,4 @@ class dbTags extends dbJSON
return true;
}
}
}

View File

@ -12,7 +12,11 @@ class dbUsers extends dbJSON
'email'=> array('inFile'=>false, 'value'=>''),
'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')
'tokenEmailTTL'=> array('inFile'=>false, 'value'=>'2009-03-15 14:00'),
'twitterUsername'=> array('inFile'=>false, 'value'=>''),
'facebookUsername'=> array('inFile'=>false, 'value'=>''),
'googleUsername'=> array('inFile'=>false, 'value'=>''),
'instagramUsername'=> array('inFile'=>false, 'value'=>'')
);
function __construct()
@ -20,6 +24,24 @@ class dbUsers extends dbJSON
parent::__construct(PATH_DATABASES.'users.php');
}
public function getUser($username)
{
$User = new User();
if($this->userExists($username))
{
$User->setField('username', $username);
foreach($this->db[$username] as $key=>$value) {
$User->setField($key, $value);
}
return $User;
}
return false;
}
public function getAll()
{
return $this->db;
@ -188,4 +210,4 @@ class dbUsers extends dbJSON
return true;
}
}
}

View File

@ -31,4 +31,4 @@ class Alert {
return Session::get('defined');
}
}
}

View File

@ -25,9 +25,14 @@ class Date {
// Format a local time/date according to locale settings.
public static function format($date, $currentFormat, $outputFormat)
{
// Returns a new DateTime instance or FALSE on failure.
$Date = DateTime::createFromFormat($currentFormat, $date);
return $Date->format($outputFormat);
if($Date!==false) {
return $Date->format($outputFormat);
}
return false;
}
public static function timeago($time)

Some files were not shown because too many files have changed in this diff Show More