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

View File

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

View File

@ -72,5 +72,6 @@ elseif( $Url->whereAmI()==='admin' ) {
// Set page 404 not found
if( $Url->notFound() ) {
$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;
}
// Returns a database with drafts pages
public function getScheduledDB()
{
$tmp = $this->db;
foreach($tmp as $key=>$fields) {
if($fields['status']!='scheduled') {
unset($tmp[$key]);
}
}
return $tmp;
}
// Return an array with the database for a page, FALSE otherwise.
public function getPageDB($key)
{

View File

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

View File

@ -2,6 +2,8 @@
class pluginAPI extends Plugin {
private $method;
public function init()
{
// Generate the API Token
@ -15,9 +17,11 @@ class pluginAPI extends Plugin {
public function form()
{
global $Language;
$html = '<div>';
$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 .= '</div>';
@ -53,6 +57,10 @@ class pluginAPI extends Plugin {
// Remove the first part of the URI
$URI = mb_substr($URI, $length);
// METHOD
// ------------------------------------------------------------
$method = $this->getMethod();
// INPUTS
// ------------------------------------------------------------
$inputs = $this->getInputs();
@ -121,6 +129,19 @@ class pluginAPI extends Plugin {
// PRIVATE METHODS
// ----------------------------------------------------------------------------
private function getMethod()
{
// METHODS
// ------------------------------------------------------------
// GET
// POST
// PUT
// DELETE
$this->method = $_SERVER['REQUEST_METHOD'];
return $this->method;
}
private function getParameters($URI)
{
// PARAMETERS
@ -141,16 +162,7 @@ class pluginAPI extends Plugin {
private function getInputs()
{
// METHODS
// ------------------------------------------------------------
// GET
// POST
// PUT
// DELETE
$method = $_SERVER['REQUEST_METHOD'];
switch($method) {
switch($this->method) {
case "POST":
$inputs = $_POST;
break;
@ -224,7 +236,7 @@ class pluginAPI extends Plugin {
foreach($keys as $pageKey) {
// Create the page object from the page key
$page = buildPage($pageKey);
array_push($tmp['data'], $Page->json( $returnsArray=true ));
array_push($tmp['data'], $page->json( $returnsArray=true ));
}
return $tmp;

View File

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