Updates
This commit is contained in:
parent
f3ba92527b
commit
708514fc81
Binary file not shown.
After Width: | Height: | Size: 1005 B |
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
<title><?php echo $layout['title'] ?></title>
|
<title><?php echo $layout['title'] ?></title>
|
||||||
|
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="./css/favicon.png">
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="./css/kube.min.css?version=<?php echo BLUDIT_VERSION ?>">
|
<link rel="stylesheet" type="text/css" href="./css/kube.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/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.datetimepicker.css?version=<?php echo BLUDIT_VERSION ?>">
|
||||||
|
|
|
@ -30,26 +30,21 @@ function build_page($key)
|
||||||
global $dbUsers;
|
global $dbUsers;
|
||||||
global $Parsedown;
|
global $Parsedown;
|
||||||
|
|
||||||
// Page object.
|
// Page object, content from FILE.
|
||||||
$Page = new Page($key);
|
$Page = new Page($key);
|
||||||
if( !$Page->isValid() ) {
|
if( !$Page->isValid() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page database.
|
// Page database, content from DATABASE JSON.
|
||||||
$db = $dbPages->getDb($key);
|
$db = $dbPages->getDb($key);
|
||||||
if( !$db ) {
|
if( !$db ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Foreach field from database.
|
// Foreach field from DATABASE.
|
||||||
foreach($db as $field=>$value)
|
foreach($db as $field=>$value) {
|
||||||
{
|
$Page->setField($field, $value);
|
||||||
// Not overwrite the value from file.
|
|
||||||
$Page->setField($field, $value, false);
|
|
||||||
|
|
||||||
// Overwrite the value on the db.
|
|
||||||
//$dbPages->setDb($key, $field, $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Content in raw format
|
// Content in raw format
|
||||||
|
|
|
@ -34,25 +34,23 @@ function buildPost($key)
|
||||||
global $Parsedown;
|
global $Parsedown;
|
||||||
global $Site;
|
global $Site;
|
||||||
|
|
||||||
// Post object, this get the content from the file.
|
// Post object, content from FILE.
|
||||||
$Post = new Post($key);
|
$Post = new Post($key);
|
||||||
if( !$Post->isValid() ) {
|
if( !$Post->isValid() ) {
|
||||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the post from file with key: '.$key);
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the post from file with key: '.$key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page database, this get the contente from the database json.
|
// Post database, content from DATABASE JSON.
|
||||||
$db = $dbPosts->getDb($key);
|
$db = $dbPosts->getDb($key);
|
||||||
if( !$db ) {
|
if( !$db ) {
|
||||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the post from database with key: '.$key);
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the post from database with key: '.$key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Foreach field from database.
|
// Foreach field from DATABASE.
|
||||||
foreach($db as $field=>$value)
|
foreach($db as $field=>$value) {
|
||||||
{
|
$Post->setField($field, $value);
|
||||||
// Not overwrite the value from file.
|
|
||||||
$Post->setField($field, $value, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Content in raw format
|
// Content in raw format
|
||||||
|
@ -119,7 +117,9 @@ function buildPostsForPage($pageNumber=0, $amount=POSTS_PER_PAGE_ADMIN, $removeU
|
||||||
|
|
||||||
// Search for changes on posts by the user.
|
// Search for changes on posts by the user.
|
||||||
if( $Site->cliMode() ) {
|
if( $Site->cliMode() ) {
|
||||||
$dbPosts->regenerateCli();
|
if($dbPosts->regenerateCli()) {
|
||||||
|
reIndexTagsPosts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the scheduler.
|
// Execute the scheduler.
|
||||||
|
|
|
@ -372,13 +372,27 @@ class dbPages extends dbJSON
|
||||||
// Update all fields from FILE to DATABASE.
|
// Update all fields from FILE to DATABASE.
|
||||||
foreach($fields as $f=>$v)
|
foreach($fields as $f=>$v)
|
||||||
{
|
{
|
||||||
if($Page->getField($f)) {
|
// If the field exists on the FILE, update it.
|
||||||
// DEBUG: Validar/Sanitizar valores, ej: validar formato fecha
|
if($Page->getField($f))
|
||||||
$this->db[$key][$f] = $Page->getField($f);
|
{
|
||||||
|
$valueFromFile = $Page->getField($f);
|
||||||
|
|
||||||
|
if($f=='tags') {
|
||||||
|
// Generate tags array.
|
||||||
|
$this->db[$key]['tags'] = $this->generateTags($valueFromFile);
|
||||||
|
}
|
||||||
|
elseif($f=='date') {
|
||||||
|
// Validate Date from file
|
||||||
|
if(Valid::date($valueFromFile, DB_DATE_FORMAT)) {
|
||||||
|
$this->db[$key]['date'] = $valueFromFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Sanitize the values from file.
|
||||||
|
$this->db[$key][$f] = Sanitize::html($valueFromFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG: Update tags
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove old pages from db
|
// Remove old pages from db
|
||||||
|
|
|
@ -378,13 +378,15 @@ class dbPosts extends dbJSON
|
||||||
return $a['date']<$b['date'];
|
return $a['date']<$b['date'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return TRUE if there are new posts, FALSE otherwise.
|
||||||
public function regenerateCli()
|
public function regenerateCli()
|
||||||
{
|
{
|
||||||
$db = $this->db;
|
$db = $this->db;
|
||||||
$newPaths = array();
|
$allPosts = array();
|
||||||
$fields = array();
|
$fields = array();
|
||||||
|
$currentDate = Date::current(DB_DATE_FORMAT);
|
||||||
|
|
||||||
// Default fields and value
|
// Generate default fields and values.
|
||||||
foreach($this->dbFields as $field=>$options) {
|
foreach($this->dbFields as $field=>$options) {
|
||||||
if(!$options['inFile']) {
|
if(!$options['inFile']) {
|
||||||
$fields[$field] = $options['value'];
|
$fields[$field] = $options['value'];
|
||||||
|
@ -392,55 +394,62 @@ class dbPosts extends dbJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields['status'] = CLI_STATUS;
|
$fields['status'] = CLI_STATUS;
|
||||||
$fields['date'] = Date::current(DB_DATE_FORMAT);
|
$fields['date'] = $currentDate;
|
||||||
|
|
||||||
// Recovery pages from the first level of directories
|
// Recovery posts from the first level of directories
|
||||||
//$tmpPaths = glob(PATH_POSTS.'*', GLOB_ONLYDIR);
|
|
||||||
$tmpPaths = Filesystem::listDirectories(PATH_POSTS);
|
$tmpPaths = Filesystem::listDirectories(PATH_POSTS);
|
||||||
foreach($tmpPaths as $directory)
|
foreach($tmpPaths as $directory)
|
||||||
{
|
{
|
||||||
$key = basename($directory);
|
if(file_exists($directory.DS.'index.txt'))
|
||||||
|
|
||||||
if(file_exists($directory.DS.'index.txt')) {
|
|
||||||
// The key is the directory name
|
|
||||||
$newPaths[$key] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($newPaths as $key=>$value)
|
|
||||||
{
|
|
||||||
if(!isset($this->db[$key])) {
|
|
||||||
$this->db[$key] = $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
$Post = new Post($key);
|
|
||||||
|
|
||||||
// Update all fields from FILE to DATABASE.
|
|
||||||
foreach($fields as $f=>$v)
|
|
||||||
{
|
{
|
||||||
if($Post->getField($f)) {
|
// The key is the directory name.
|
||||||
|
$key = basename($directory);
|
||||||
|
|
||||||
$valueFromFile = $Post->getField($f);
|
// All keys posts
|
||||||
|
$allPosts[$key] = true;
|
||||||
|
|
||||||
// Validate values from file.
|
// Create the new entry if not exists on DATABASE.
|
||||||
if($f=='tags') {
|
if(!isset($this->db[$key])) {
|
||||||
$valueFromFile = array_map('trim', explode(',', $valueFromFile));
|
// New entry on database
|
||||||
$valueFromFile = implode(',', $valueFromFile);
|
$this->db[$key] = $fields;
|
||||||
}
|
}
|
||||||
elseif($f=='date') {
|
|
||||||
if(!Valid::date($valueFromFile,DB_DATE_FORMAT)) {
|
// Create the post from FILE.
|
||||||
$valueFromFile = Date::current(DB_DATE_FORMAT);
|
$Post = new Post($key);
|
||||||
|
|
||||||
|
// Update all fields from FILE to DATABASE.
|
||||||
|
foreach($fields as $f=>$v)
|
||||||
|
{
|
||||||
|
// If the field exists on the FILE, update it.
|
||||||
|
if($Post->getField($f))
|
||||||
|
{
|
||||||
|
$valueFromFile = $Post->getField($f);
|
||||||
|
|
||||||
|
if($f=='tags') {
|
||||||
|
// Generate tags array.
|
||||||
|
$this->db[$key]['tags'] = $this->generateTags($valueFromFile);
|
||||||
|
}
|
||||||
|
elseif($f=='date') {
|
||||||
|
// Validate Date from file
|
||||||
|
if(Valid::date($valueFromFile, DB_DATE_FORMAT)) {
|
||||||
|
$this->db[$key]['date'] = $valueFromFile;
|
||||||
|
|
||||||
|
if( $valueFromFile>$currentDate ) {
|
||||||
|
$this->db[$key]['status'] = 'scheduled';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Sanitize the values from file.
|
||||||
|
$this->db[$key][$f] = Sanitize::html($valueFromFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanitize the values from file.
|
|
||||||
$this->db[$key][$f] = Sanitize::html($valueFromFile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove old posts from db
|
// Remove orphan posts from db, the orphan posts are posts deleted by hand (directory deleted).
|
||||||
foreach( array_diff_key($db, $newPaths) as $key=>$data ) {
|
foreach( array_diff_key($db, $allPosts) as $key=>$data ) {
|
||||||
unset($this->db[$key]);
|
unset($this->db[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
class Filesystem {
|
class Filesystem {
|
||||||
|
|
||||||
// NEW
|
// NEW
|
||||||
|
|
||||||
|
// Returns an array with the absolutes directories.
|
||||||
public static function listDirectories($path, $regex='*')
|
public static function listDirectories($path, $regex='*')
|
||||||
{
|
{
|
||||||
$directories = glob($path.$regex, GLOB_ONLYDIR);
|
$directories = glob($path.$regex, GLOB_ONLYDIR);
|
||||||
|
|
|
@ -32,49 +32,46 @@ class pluginPages extends Plugin {
|
||||||
global $Language;
|
global $Language;
|
||||||
global $pagesParents;
|
global $pagesParents;
|
||||||
global $Site, $Url;
|
global $Site, $Url;
|
||||||
$home = $Url->whereAmI()==='home';
|
|
||||||
|
|
||||||
$html = '<div class="plugin plugin-pages">';
|
$html = '<div class="plugin plugin-pages">';
|
||||||
|
|
||||||
// Print the label if it not empty.
|
// Print the label if not empty.
|
||||||
$label = $this->getDbField('label');
|
$label = $this->getDbField('label');
|
||||||
if( !empty($label) ) {
|
if( !empty($label) ) {
|
||||||
$html .= '<h2>'.$label.'</h2>';
|
$html .= '<h2>'.$label.'</h2>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= '<div class="plugin-content">';
|
$html .= '<div class="plugin-content">';
|
||||||
|
|
||||||
$parents = $pagesParents[NO_PARENT_CHAR];
|
|
||||||
|
|
||||||
$html .= '<ul>';
|
$html .= '<ul>';
|
||||||
|
|
||||||
|
// Show home link ?
|
||||||
if($this->getDbField('homeLink')) {
|
if($this->getDbField('homeLink')) {
|
||||||
$current = ($Site->homeLink()==$home) ? ' class="active"' : '';
|
$html .= '<li>';
|
||||||
$html .= '<li' .$current. '><a class="parent" href="'.$Site->homeLink().'">'.$Language->get('Home').'</a></li>';
|
$html .= '<a class="parent'.( ($Url->whereAmI()=='home')?' active':'').'" href="'.$Site->homeLink().'">'.$Language->get('Home').'</a>';
|
||||||
|
$html .= '</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$parents = $pagesParents[NO_PARENT_CHAR];
|
||||||
foreach($parents as $parent)
|
foreach($parents as $parent)
|
||||||
{
|
{
|
||||||
//if($Site->homepage()!==$parent->key())
|
// Print the parent
|
||||||
|
$html .= '<li>';
|
||||||
|
$html .= '<a class="parent '.( ($parent->key()==$Url->slug())?' active':'').'" href="'.$parent->permalink().'">'.$parent->title().'</a>';
|
||||||
|
|
||||||
|
// Check if the parent has children
|
||||||
|
if(isset($pagesParents[$parent->key()]))
|
||||||
{
|
{
|
||||||
$current_parent = ($parent->slug()==$Url->slug()) ? ' class="active"' : '';
|
$children = $pagesParents[$parent->key()];
|
||||||
// Print the parent
|
|
||||||
$html .= '<li' .$current_parent. '><a class="parent" href="'.$parent->permalink().'">'.$parent->title().'</a>';
|
|
||||||
|
|
||||||
// Check if the parent has children
|
// Print children
|
||||||
if(isset($pagesParents[$parent->key()]))
|
$html .= '<ul>';
|
||||||
|
foreach($children as $child)
|
||||||
{
|
{
|
||||||
$children = $pagesParents[$parent->key()];
|
$html .= '<li>';
|
||||||
|
$html .= '<a class="children '.( ($child->key()==$Url->slug())?' active':'').'" href="'.$child->permalink().'">'.$child->title().'</a>';
|
||||||
// Print the children
|
$html .= '</li>';
|
||||||
$html .= '<ul>';
|
|
||||||
foreach($children as $child)
|
|
||||||
{
|
|
||||||
$current_child = ($child->slug()==$Url->slug()) ? ' class="active"' : '';
|
|
||||||
$html .= '<li' .$current_child. '><a class="children" href="'.$child->permalink().'">'.$child->title().'</a></li>';
|
|
||||||
}
|
|
||||||
$html .= '</ul>';
|
|
||||||
}
|
}
|
||||||
|
$html .= '</ul>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,4 +81,4 @@ class pluginPages extends Plugin {
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -268,9 +268,6 @@ div.plugin-content li {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.plugin-content ul li.active a {
|
|
||||||
color: #2672ec;
|
|
||||||
}
|
|
||||||
div.plugin-content ul {
|
div.plugin-content ul {
|
||||||
display: block;
|
display: block;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
|
@ -292,6 +289,11 @@ div.plugin-content ul > li > ul > li > a {
|
||||||
color: #777;
|
color: #777;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.plugin-content a.active {
|
||||||
|
color: #2672ec !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------
|
/* ------------------------
|
||||||
Responsive
|
Responsive
|
||||||
------------------------ */
|
------------------------ */
|
||||||
|
|
Loading…
Reference in New Issue