Autosave tab, and autosave type for pages
This commit is contained in:
parent
c3cccaf42d
commit
68407ad75e
|
@ -40,6 +40,7 @@ $drafts = $pages->getDraftDB(true);
|
||||||
$scheduled = $pages->getScheduledDB(true);
|
$scheduled = $pages->getScheduledDB(true);
|
||||||
$static = $pages->getStaticDB(true);
|
$static = $pages->getStaticDB(true);
|
||||||
$sticky = $pages->getStickyDB(true);
|
$sticky = $pages->getStickyDB(true);
|
||||||
|
$autosave = $pages->getAutosaveDB(true);
|
||||||
|
|
||||||
// If the user is an Author filter the content he/she can edit
|
// If the user is an Author filter the content he/she can edit
|
||||||
if (checkRole(array('author'), false)) {
|
if (checkRole(array('author'), false)) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($args['icon'])) {
|
if (isset($args['icon'])) {
|
||||||
return '<a '.$options.'><span class="fa fa-'.$args['icon'].'" style="font-size: 0.7em;"></span> '.$args['title'].'</a>';
|
return '<a '.$options.'><span class="fa fa-'.$args['icon'].'"></span>'.$args['title'].'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<a '.$options.'>'.$args['title'].'</a>';
|
return '<a '.$options.'>'.$args['title'].'</a>';
|
||||||
|
|
|
@ -10,6 +10,7 @@ function table($type) {
|
||||||
global $scheduled;
|
global $scheduled;
|
||||||
global $static;
|
global $static;
|
||||||
global $sticky;
|
global $sticky;
|
||||||
|
global $autosave;
|
||||||
|
|
||||||
if ($type=='published') {
|
if ($type=='published') {
|
||||||
$list = $published;
|
$list = $published;
|
||||||
|
@ -51,6 +52,8 @@ function table($type) {
|
||||||
echo '</p>';
|
echo '</p>';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} elseif ($type=='autosave') {
|
||||||
|
$list = $autosave;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
@ -180,8 +183,13 @@ function table($type) {
|
||||||
<a class="nav-link" id="scheduled-tab" data-toggle="tab" href="#scheduled" role="tab"><?php $L->p('Scheduled') ?> <?php if (count($scheduled)>0) { echo '<span class="badge badge-danger">'.count($scheduled).'</span>'; } ?></a>
|
<a class="nav-link" id="scheduled-tab" data-toggle="tab" href="#scheduled" role="tab"><?php $L->p('Scheduled') ?> <?php if (count($scheduled)>0) { echo '<span class="badge badge-danger">'.count($scheduled).'</span>'; } ?></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" id="draft-tab" data-toggle="tab" href="#draft" role="tab"><?php $L->p('Draft') ?> <?php if (count($drafts)>0) { echo '<span class="badge badge-danger">'.count($drafts).'</span>'; } ?></a>
|
<a class="nav-link" id="draft-tab" data-toggle="tab" href="#draft" role="tab"><?php $L->p('Draft') ?></a>
|
||||||
</li>
|
</li>
|
||||||
|
<?php if (!empty($autosave)): ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" id="autosave-tab" data-toggle="tab" href="#autosave" role="tab"><?php $L->p('Autosave') ?></a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<!-- TABS PAGES -->
|
<!-- TABS PAGES -->
|
||||||
|
@ -222,12 +230,11 @@ function table($type) {
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var searchXHR;
|
var searchXHR;
|
||||||
var searchList;
|
var searchArray;
|
||||||
$("#search").autoComplete({
|
$("#search").autoComplete({
|
||||||
minChars: 3,
|
minChars: 3,
|
||||||
source: function(term, response) {
|
source: function(term, response) {
|
||||||
try { searchXHR.abort(); } catch(e){}
|
searchXHR = $.getJSON(HTML_PATH_ADMIN_ROOT+"ajax/content-get-list",
|
||||||
searchXHR = $.getJSON(HTML_PATH_ADMIN_ROOT+"ajax/content-list",
|
|
||||||
{
|
{
|
||||||
published: true,
|
published: true,
|
||||||
static: true,
|
static: true,
|
||||||
|
@ -237,19 +244,19 @@ function table($type) {
|
||||||
query: term
|
query: term
|
||||||
},
|
},
|
||||||
function(data) {
|
function(data) {
|
||||||
searchList = data;
|
searchArray = data;
|
||||||
var matches = [];
|
var matches = [];
|
||||||
for (var title in data) {
|
for (var key in data) {
|
||||||
matches.push(title);
|
matches.push(key);
|
||||||
}
|
}
|
||||||
response(matches);
|
response(matches);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
renderItem: function (item, search) {
|
renderItem: function (item, search) {
|
||||||
var key = searchList[item];
|
var title = searchArray[item]['title'];
|
||||||
html = '<div class="search-suggestion">';
|
html = '<div class="search-suggestion">';
|
||||||
html += '<div class="search-suggestion-item">'+item+'</div>';
|
html += '<div class="search-suggestion-item">'+title+'</div>';
|
||||||
html += '<div class="search-suggestion-options"><a href="<?php echo DOMAIN_ADMIN ?>edit-content/'+key+'">Edit</a> <a target="_blank" class="ml-2" href="<?php echo DOMAIN_PAGES ?>'+key+'"">Visit</a></div>';
|
html += '<div class="search-suggestion-options"><a href="<?php echo DOMAIN_ADMIN ?>edit-content/'+item+'">Edit</a> <a target="_blank" class="ml-2" href="<?php echo DOMAIN_PAGES ?>'+item+'"">Visit</a></div>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
@ -276,6 +283,13 @@ function table($type) {
|
||||||
<div class="tab-pane" id="draft" role="tabpanel">
|
<div class="tab-pane" id="draft" role="tabpanel">
|
||||||
<?php table('draft'); ?>
|
<?php table('draft'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- TABS AUTOSAVE -->
|
||||||
|
<?php if (!empty($autosave)): ?>
|
||||||
|
<div class="tab-pane" id="autosave" role="tabpanel">
|
||||||
|
<?php table('autosave'); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modal for delete page -->
|
<!-- Modal for delete page -->
|
||||||
|
|
|
@ -1,6 +1,19 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
/*
|
||||||
|
| Search for pages that have in the title the string $query and returns the array of pages
|
||||||
|
|
|
||||||
|
| @_GET['published'] boolean True to search in published database
|
||||||
|
| @_GET['static'] boolean True to search in static database
|
||||||
|
| @_GET['sticky'] boolean True to search in sticky database
|
||||||
|
| @_GET['scheduled'] boolean True to search in scheduled database
|
||||||
|
| @_GET['draft'] boolean True to search in draft database
|
||||||
|
| @_GET['query'] string Text to search in the title
|
||||||
|
|
|
||||||
|
| @return array
|
||||||
|
*/
|
||||||
|
|
||||||
// $_GET
|
// $_GET
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
$published = empty($_GET['published']) ? false:true;
|
$published = empty($_GET['published']) ? false:true;
|
||||||
|
@ -24,7 +37,7 @@ foreach ($pagesKey as $pageKey) {
|
||||||
$page = new Page($pageKey);
|
$page = new Page($pageKey);
|
||||||
$lowerTitle = Text::lowercase($page->title());
|
$lowerTitle = Text::lowercase($page->title());
|
||||||
if (Text::stringContains($lowerTitle, $query)) {
|
if (Text::stringContains($lowerTitle, $query)) {
|
||||||
$tmp[$page->title()] = $page->key();
|
$tmp[$page->key()] = $page->json(true);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// continue
|
// continue
|
|
@ -8,6 +8,7 @@ header('Content-Type: application/json');
|
||||||
| @_POST['title'] string Page title
|
| @_POST['title'] string Page title
|
||||||
| @_POST['content'] string Page content
|
| @_POST['content'] string Page content
|
||||||
| @_POST['uuid'] string Page uuid
|
| @_POST['uuid'] string Page uuid
|
||||||
|
| @_POST['uuid'] string Page type, by default is draft
|
||||||
|
|
|
|
||||||
| @return array
|
| @return array
|
||||||
*/
|
*/
|
||||||
|
@ -17,6 +18,7 @@ header('Content-Type: application/json');
|
||||||
$title = isset($_POST['title']) ? $_POST['title'] : false;
|
$title = isset($_POST['title']) ? $_POST['title'] : false;
|
||||||
$content = isset($_POST['content']) ? $_POST['content'] : false;
|
$content = isset($_POST['content']) ? $_POST['content'] : false;
|
||||||
$uuid = isset($_POST['uuid']) ? $_POST['uuid'] : false;
|
$uuid = isset($_POST['uuid']) ? $_POST['uuid'] : false;
|
||||||
|
$type = isset($_POST['type']) ? $_POST['type'] : 'draft';
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Check UUID
|
// Check UUID
|
||||||
|
@ -30,7 +32,7 @@ $page = array(
|
||||||
'slug'=>$uuid,
|
'slug'=>$uuid,
|
||||||
'title'=>$title,
|
'title'=>$title,
|
||||||
'content'=>$content,
|
'content'=>$content,
|
||||||
'type'=>'draft'
|
'type'=>$type
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get the page key by the UUID
|
// Get the page key by the UUID
|
||||||
|
|
|
@ -13,7 +13,8 @@ class bluditAjax {
|
||||||
'tokenCSRF': tokenCSRF,
|
'tokenCSRF': tokenCSRF,
|
||||||
'uuid': "autosave-" + uuid,
|
'uuid': "autosave-" + uuid,
|
||||||
'title': title,
|
'title': title,
|
||||||
'content': content
|
'content': content,
|
||||||
|
'type': 'autosave'
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Pages extends dbJSON {
|
||||||
'description'=>'',
|
'description'=>'',
|
||||||
'username'=>'',
|
'username'=>'',
|
||||||
'tags'=>array(),
|
'tags'=>array(),
|
||||||
'type'=>'published', // published, static, draft, sticky, scheduled
|
'type'=>'published', // published, static, draft, sticky, scheduled, autosave
|
||||||
'date'=>'',
|
'date'=>'',
|
||||||
'dateModified'=>'',
|
'dateModified'=>'',
|
||||||
'position'=>0,
|
'position'=>0,
|
||||||
|
@ -411,6 +411,21 @@ class Pages extends dbJSON {
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns an array with a list of keys/database of autosave pages
|
||||||
|
public function getAutosaveDB($onlyKeys=true)
|
||||||
|
{
|
||||||
|
$tmp = $this->db;
|
||||||
|
foreach ($tmp as $key=>$fields) {
|
||||||
|
if($fields['type']!='autosave') {
|
||||||
|
unset($tmp[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($onlyKeys) {
|
||||||
|
return array_keys($tmp);
|
||||||
|
}
|
||||||
|
return $tmp;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns an array with a list of keys/database of scheduled pages
|
// Returns an array with a list of keys/database of scheduled pages
|
||||||
public function getScheduledDB($onlyKeys=true)
|
public function getScheduledDB($onlyKeys=true)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue