bug fixes

This commit is contained in:
Diego Najar 2017-06-25 22:54:59 +02:00
parent 304a57beca
commit 9d865eb6ce
7 changed files with 79 additions and 37 deletions

View File

@ -681,15 +681,13 @@ div.plugin-links > span.separator {
width: 100%; width: 100%;
} }
#jsformplugin > div > label, #jsformplugin ul {
#jsformplugin > div > input[type=text], padding: 0;
#jsformplugin > div > input[type=checkbox], list-style: none;
#jsformplugin > div > textarea, margin-bottom: 10px;
#jsformplugin > div > select {
display: table-cell;
} }
#jsformplugin > div > button[type=submit] { #jsformplugin button[type=submit] {
margin-left: 200px; margin-left: 200px;
border-radius: 2px; border-radius: 2px;
padding: 1px 20px; padding: 1px 20px;
@ -702,11 +700,19 @@ div.plugin-links > span.separator {
cursor: pointer; cursor: pointer;
} }
#jsformplugin > div > button[type=submit].blue { #jsformplugin button[type=submit].blue {
background: #007add !important; background: #007add !important;
color: #fff; color: #fff;
} }
#jsformplugin > div > label,
#jsformplugin > div > input[type=text],
#jsformplugin > div > input[type=checkbox],
#jsformplugin > div > textarea,
#jsformplugin > div > select {
display: table-cell;
}
#jsformplugin > div > span.tip { #jsformplugin > div > span.tip {
color: #999; color: #999;
margin-top: 5px; margin-top: 5px;

View File

@ -92,12 +92,15 @@
<h4 class="panel-title"><?php $L->p('Scheduled pages') ?></h4> <h4 class="panel-title"><?php $L->p('Scheduled pages') ?></h4>
<ul class="uk-list"> <ul class="uk-list">
<?php <?php
if( empty($_scheduledPosts) ) { $scheduledPages = $dbPages->getScheduledDB();
if( empty($scheduledPages) ) {
echo '<li>'.$Language->g('There are no scheduled pages').'</li>'; echo '<li>'.$Language->g('There are no scheduled pages').'</li>';
} }
else { else {
foreach($_scheduledPosts as $Post) { $keys = array_keys($scheduledPages);
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>'; foreach($keys as $key) {
$page = buildPage($key);
echo '<li><span class="label-time">'.$page->dateRaw(SCHEDULED_DATE_FORMAT).'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
} }
} }
?> ?>
@ -128,12 +131,15 @@
<h4 class="panel-title"><?php $L->p('Drafts') ?></h4> <h4 class="panel-title"><?php $L->p('Drafts') ?></h4>
<ul class="uk-list"> <ul class="uk-list">
<?php <?php
if( empty($_draftPages) ) { $draftPages = $dbPages->getDraftDB();
if( empty($draftPages) ) {
echo '<li>'.$Language->g('There are no draft pages').'</li>'; echo '<li>'.$Language->g('There are no draft pages').'</li>';
} }
else { else {
foreach($_draftPages as $Page) { $keys = array_keys($scheduledPages);
echo '<li><span class="label-draft">'.$Language->g('Page').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->title()?$Page->title():'['.$Language->g('Empty title').'] ').'</a></li>'; foreach($keys as $key) {
$page = buildPage($key);
echo '<li><span class="label-draft">'.$Language->g('Page').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
} }
} }
?> ?>

View File

@ -72,5 +72,6 @@ elseif( $Url->whereAmI()==='admin' ) {
// Set page 404 not found // Set page 404 not found
if( $Url->notFound() ) { if( $Url->notFound() ) {
$Url->setWhereAmI('page'); $Url->setWhereAmI('page');
$page = new Page('error'); $page = buildPage('error');
$pages[0] = $page;
} }

View File

@ -292,6 +292,18 @@ class dbPages extends dbJSON
return $tmp; return $tmp;
} }
// Returns a database with drafts pages
public function getScheduledDB()
{
$tmp = $this->db;
foreach($tmp as $key=>$fields) {
if($fields['status']!='scheduled') {
unset($tmp[$key]);
}
}
return $tmp;
}
// Return an array with the database for a page, FALSE otherwise. // Return an array with the database for a page, FALSE otherwise.
public function getPageDB($key) public function getPageDB($key)
{ {

View File

@ -18,6 +18,7 @@ class Page {
{ {
$filePath = PATH_PAGES.$key.DS.FILENAME; $filePath = PATH_PAGES.$key.DS.FILENAME;
// Check if the file exists
if( !Sanitize::pathFile($filePath) ) { if( !Sanitize::pathFile($filePath) ) {
return false; return false;
} }
@ -25,26 +26,32 @@ class Page {
$tmp = 0; $tmp = 0;
$lines = file($filePath); $lines = file($filePath);
foreach($lines as $lineNumber=>$line) { foreach($lines as $lineNumber=>$line) {
$parts = array_map('trim', explode(':', $line, 2)); // Split the line in 2 parts, limiter by :
$parts = explode(':', $line, 2);
// Lowercase variable // Remove all characters except letters and dash -
$parts[0] = preg_replace('/[^A-Za-z\-]/', '', $parts[0]);
// Lowercase
$parts[0] = Text::lowercase($parts[0]); $parts[0] = Text::lowercase($parts[0]);
// If variables is content then break the foreach and process the content after. // Check if the current line start the content of the page
if($parts[0]==='content') { // We have two breakers, the word content or 3 dash ---
if( ($parts[0]==='content') || ($parts[0]==='---') ) {
$tmp = $lineNumber; $tmp = $lineNumber;
break; break;
} }
if( !empty($parts[0]) && !empty($parts[1]) ) { if( !empty($parts[0]) && !empty($parts[1]) ) {
// Sanitize all fields, except Content. $parts[1] = trim($parts[1]);
// Sanitize all fields, except the content
$this->vars[$parts[0]] = Sanitize::html($parts[1]); $this->vars[$parts[0]] = Sanitize::html($parts[1]);
} }
} }
// Process the content // Process the content
if($tmp!==0) { if($tmp!==0) {
// Next line after "Content:" variable // Next line after "Content:" or "---"
$tmp++; $tmp++;
// Remove lines after Content // Remove lines after Content

View File

@ -2,6 +2,8 @@
class pluginAPI extends Plugin { class pluginAPI extends Plugin {
private $method;
public function init() public function init()
{ {
// Generate the API Token // Generate the API Token
@ -15,9 +17,11 @@ class pluginAPI extends Plugin {
public function form() public function form()
{ {
global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label>'.$Language->get('API Token').'</label>'; $html .= '<label>'.$Language->get('API Token').'</label>';
$html .= '<input type="text" value="'.$this->getValue('token').'" disabled>'; $html .= '<input name="token" type="text" value="'.$this->getValue('token').'">';
$html .= '<span class="tip">'.$Language->get('This token is for read only and is regenerated every time you install the plugin').'</span>'; $html .= '<span class="tip">'.$Language->get('This token is for read only and is regenerated every time you install the plugin').'</span>';
$html .= '</div>'; $html .= '</div>';
@ -53,6 +57,10 @@ class pluginAPI extends Plugin {
// Remove the first part of the URI // Remove the first part of the URI
$URI = mb_substr($URI, $length); $URI = mb_substr($URI, $length);
// METHOD
// ------------------------------------------------------------
$method = $this->getMethod();
// INPUTS // INPUTS
// ------------------------------------------------------------ // ------------------------------------------------------------
$inputs = $this->getInputs(); $inputs = $this->getInputs();
@ -121,6 +129,19 @@ class pluginAPI extends Plugin {
// PRIVATE METHODS // PRIVATE METHODS
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
private function getMethod()
{
// METHODS
// ------------------------------------------------------------
// GET
// POST
// PUT
// DELETE
$this->method = $_SERVER['REQUEST_METHOD'];
return $this->method;
}
private function getParameters($URI) private function getParameters($URI)
{ {
// PARAMETERS // PARAMETERS
@ -141,16 +162,7 @@ class pluginAPI extends Plugin {
private function getInputs() private function getInputs()
{ {
// METHODS switch($this->method) {
// ------------------------------------------------------------
// GET
// POST
// PUT
// DELETE
$method = $_SERVER['REQUEST_METHOD'];
switch($method) {
case "POST": case "POST":
$inputs = $_POST; $inputs = $_POST;
break; break;
@ -224,7 +236,7 @@ class pluginAPI extends Plugin {
foreach($keys as $pageKey) { foreach($keys as $pageKey) {
// Create the page object from the page key // Create the page object from the page key
$page = buildPage($pageKey); $page = buildPage($pageKey);
array_push($tmp['data'], $Page->json( $returnsArray=true )); array_push($tmp['data'], $page->json( $returnsArray=true ));
} }
return $tmp; return $tmp;

View File

@ -13,5 +13,3 @@
<!-- Plugins with the hook pageEnd --> <!-- Plugins with the hook pageEnd -->
<?php Theme::plugins('pageEnd') ?> <?php Theme::plugins('pageEnd') ?>
</section> </section>
<?php var_dump($page); ?>