Session in admin area, improves in creation content

This commit is contained in:
Diego Najar 2018-07-12 20:03:31 +02:00
parent f0df4eb0ab
commit be8cf51393
8 changed files with 173 additions and 71 deletions

View File

@ -257,12 +257,14 @@ EOF;
$type = $args['type']; $type = $args['type'];
} }
$checked = $args['checked']?'checked':'';
return <<<EOF return <<<EOF
<div class="$class"> <div class="$class">
<label for="$id" class="col-sm-2">$label</label> <label for="$id" class="col-sm-2">$label</label>
<div class="col-sm-10"> <div class="col-sm-10">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="checkbox" id="$id"> <input name="$name" class="form-check-input" type="checkbox" id="$id" $checked>
<label class="form-check-label" for="$id">$labelForCheckbox</label> <label class="form-check-label" for="$id">$labelForCheckbox</label>
<small class="form-text text-muted">$tip</small> <small class="form-text text-muted">$tip</small>
</div> </div>

View File

@ -1,3 +1,5 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
<!-- TABS --> <!-- TABS -->
<ul class="nav nav-tabs" id="dynamicTab" role="tablist"> <ul class="nav nav-tabs" id="dynamicTab" role="tablist">
<li class="nav-item"> <li class="nav-item">
@ -107,9 +109,7 @@
<?php <?php
echo Bootstrap::formTitle(array('title'=>'External Cover image')); echo Bootstrap::formTitle(array('title'=>'External Cover image'));
?>
<?php
echo Bootstrap::formInputTextBlock(array( echo Bootstrap::formInputTextBlock(array(
'name'=>'externalCoverImage', 'name'=>'externalCoverImage',
'placeholder'=>'https://', 'placeholder'=>'https://',
@ -123,67 +123,106 @@
<!-- TABS OPTIONS --> <!-- TABS OPTIONS -->
<div class="tab-pane" id="options" role="tabpanel" aria-labelledby="options-tab"> <div class="tab-pane" id="options" role="tabpanel" aria-labelledby="options-tab">
<?php <?php
echo Bootstrap::formTitle(array('title'=>'Advanced'));
// Tags echo Bootstrap::formTitle(array('title'=>'Advanced'));
echo Bootstrap::formInputText(array(
'name'=>'tags',
'label'=>'Tags',
'value'=>$page->tags(),
'placeholder'=>'Tags separeted by comma'
));
// Date // Date
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'date', 'name'=>'date',
'label'=>'Date', 'label'=>'Date',
'placeholder'=>'YYYY-MM-DD hh:mm:ss', 'placeholder'=>'',
'value'=>$page->dateRaw() 'value'=>$page->date(),
'tip'=>'Date format: <code>YYYY-MM-DD Hours:Minutes:Seconds</code>'
)); ));
// Type // Type
echo Bootstrap::formSelect(array( echo Bootstrap::formSelect(array(
'name'=>'type', 'name'=>'type',
'label'=>'Type', 'label'=>'Type',
'selected'=>$page->status(), 'selected'=>$page->type(),
'options'=>array( 'options'=>array(
''=>'- Default -', ''=>'- Default -',
'sticky'=>'Sticky', 'sticky'=>'Sticky',
'static'=>'Static' 'static'=>'Static'
) ),
'tip'=>'???'
)); ));
// Parent // Parent
$parentTMP = buildPage($page->parent());
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'parentTMP', 'name'=>'parentTMP',
'label'=>'Parent', 'label'=>$L->g('Parent'),
'placeholder'=>'Start writing the title of the page parent', 'placeholder'=>'',
'value'=>($page->parent()?$page->parentMethod('title'):'') 'tip'=>'Start typing a page title to see a list of suggestions.',
'value'=>($parentTMP?$parentTMP->title():'')
)); ));
// Position // Position
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'position', 'name'=>'position',
'label'=>'Position', 'label'=>$L->g('Position'),
'placeholder'=>'', 'tip'=>'Field used when ordering content by position',
'value'=>$page->position() 'value'=>$page->position()
)); ));
// Friendly URL
echo Bootstrap::formInputText(array(
'name'=>'slug',
'label'=>'Friendly URL',
'value'=>$page->slug(),
'placeholder'=>'Leave empty for automaticly complete'
));
// Template // Template
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'template', 'name'=>'template',
'label'=>'Template', 'label'=>'Template',
'placeholder'=>'', 'placeholder'=>'',
'value'=>$page->template() 'value'=>$page->template(),
'tip'=>'Write a template name to filter the page in the theme and change the style of the page.'
)); ));
echo Bootstrap::formTitle(array('title'=>'SEO'));
// Tags
echo Bootstrap::formInputText(array(
'name'=>'tags',
'label'=>'Tags',
'placeholder'=>'',
'value'=>$page->tags(),
'tip'=>'Write the tags separeted by comma'
));
// Friendly URL
echo Bootstrap::formInputText(array(
'name'=>'slug',
'tip'=>$L->g('URL associated with the content'),
'label'=>$L->g('Friendly URL'),
'placeholder'=>'Leave empty for autocomplete by Bludit.',
'value'=>$page->slug()
));
echo Bootstrap::formCheckbox(array(
'name'=>'noindex',
'label'=>'Robots',
'labelForCheckbox'=>'Apply <code>noindex</code> to this page',
'placeholder'=>'',
'class'=>'mt-4',
'checked'=>$page->noindex(),
'tip'=>'This tells search engines not to show this page in their search results.'
));
echo Bootstrap::formCheckbox(array(
'name'=>'nofollow',
'label'=>'',
'labelForCheckbox'=>'Apply <code>nofollow</code> to this page',
'placeholder'=>'',
'checked'=>$page->nofollow(),
'tip'=>'This tells search engines not to follow links on this page.'
));
echo Bootstrap::formCheckbox(array(
'name'=>'noarchive',
'label'=>'',
'labelForCheckbox'=>'Apply <code>noarchive</code> to this page',
'placeholder'=>'',
'checked'=>$page->noarchive(),
'tip'=>'This tells search engines not to save a cached copy of this page.'
));
?> ?>
</div> </div>
@ -289,6 +328,9 @@
<script> <script>
$(document).ready(function() { $(document).ready(function() {
// Datepicker
$("#jsdate").datetimepicker({format:DB_DATE_FORMAT});
// Button Save // Button Save
$("#jsbuttonSave").on("click", function() { $("#jsbuttonSave").on("click", function() {
$("#jsstatus").val("published"); $("#jsstatus").val("published");
@ -322,6 +364,7 @@ $(document).ready(function() {
}); });
// Autosave interval // Autosave interval
// Autosave works when the content of the page is bigger than 100 characters
setInterval(function() { setInterval(function() {
var uuid = $("#jsuuid").val(); var uuid = $("#jsuuid").val();
var title = $("#jstitle").val(); var title = $("#jstitle").val();
@ -348,10 +391,11 @@ $(document).ready(function() {
var parentsXHR; var parentsXHR;
var parentsList; // Keep the parent list returned to get the key by the title page var parentsList; // Keep the parent list returned to get the key by the title page
$("#jsparentTMP").autoComplete({ $("#jsparentTMP").autoComplete({
minChars: 1,
source: function(term, response) { source: function(term, response) {
// Prevent call inmediatly another ajax request // Prevent call inmediatly another ajax request
try { parentsXHR.abort(); } catch(e){} try { parentsXHR.abort(); } catch(e){}
parentsXHR = $.getJSON("<?php echo HTML_PATH_ADMIN_ROOT ?>ajax/get-parents", {query: term}, parentsXHR = $.getJSON(HTML_PATH_ADMIN_ROOT+"ajax/get-parents", {query: term},
function(data) { function(data) {
parentsList = data; parentsList = data;
term = term.toLowerCase(); term = term.toLowerCase();
@ -364,6 +408,7 @@ $(document).ready(function() {
}); });
}, },
onSelect: function(e, term, item) { onSelect: function(e, term, item) {
// parentsList = array( pageTitle => pageKey )
var parentKey = parentsList[term]; var parentKey = parentsList[term];
$("#jsparent").attr("value", parentKey); $("#jsparent").attr("value", parentKey);
} }

View File

@ -44,6 +44,26 @@ echo Bootstrap::formOpen(array());
'tip'=>'' 'tip'=>''
)); ));
echo Bootstrap::formTitle(array('title'=>$L->g('Profile')));
echo Bootstrap::formInputText(array(
'name'=>'firstName',
'label'=>$L->g('First Name'),
'value'=>$user->firstName(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'lastName',
'label'=>$L->g('Last Name'),
'value'=>$user->lastName(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formTitle(array('title'=>$L->g('Password'))); echo Bootstrap::formTitle(array('title'=>$L->g('Password')));
echo ' echo '

View File

@ -1,3 +1,5 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
<!-- TABS --> <!-- TABS -->
<ul class="nav nav-tabs" id="dynamicTab" role="tablist"> <ul class="nav nav-tabs" id="dynamicTab" role="tablist">
<li class="nav-item"> <li class="nav-item">
@ -132,8 +134,9 @@
echo Bootstrap::formInputText(array( echo Bootstrap::formInputText(array(
'name'=>'parentTMP', 'name'=>'parentTMP',
'label'=>$L->g('Parent'), 'label'=>$L->g('Parent'),
'placeholder'=>'Start typing a page title to see a list of suggestions.', 'placeholder'=>'',
'tip'=>'Select a page to arrange your content in hierarchies.' 'tip'=>'Start typing a page title to see a list of suggestions.',
'value'=>''
)); ));
// Position // Position
@ -149,6 +152,7 @@
'name'=>'template', 'name'=>'template',
'label'=>'Template', 'label'=>'Template',
'placeholder'=>'', 'placeholder'=>'',
'value'=>'',
'tip'=>'Write a template name to filter the page in the theme and change the style of the page.' 'tip'=>'Write a template name to filter the page in the theme and change the style of the page.'
)); ));
@ -176,6 +180,7 @@
'labelForCheckbox'=>'Apply <code>noindex</code> to this page', 'labelForCheckbox'=>'Apply <code>noindex</code> to this page',
'placeholder'=>'', 'placeholder'=>'',
'class'=>'mt-4', 'class'=>'mt-4',
'checked'=>false,
'tip'=>'This tells search engines not to show this page in their search results.' 'tip'=>'This tells search engines not to show this page in their search results.'
)); ));
@ -184,6 +189,7 @@
'label'=>'', 'label'=>'',
'labelForCheckbox'=>'Apply <code>nofollow</code> to this page', 'labelForCheckbox'=>'Apply <code>nofollow</code> to this page',
'placeholder'=>'', 'placeholder'=>'',
'checked'=>false,
'tip'=>'This tells search engines not to follow links on this page.' 'tip'=>'This tells search engines not to follow links on this page.'
)); ));
@ -192,11 +198,11 @@
'label'=>'', 'label'=>'',
'labelForCheckbox'=>'Apply <code>noarchive</code> to this page', 'labelForCheckbox'=>'Apply <code>noarchive</code> to this page',
'placeholder'=>'', 'placeholder'=>'',
'checked'=>false,
'tip'=>'This tells search engines not to save a cached copy of this page.' 'tip'=>'This tells search engines not to save a cached copy of this page.'
)); ));
?> ?>
</div> </div>
<!-- Modal for Categories --> <!-- Modal for Categories -->

View File

@ -1,5 +1,11 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
// Session
Session::start();
if (Session::started()===false) {
exit('Bludit CMS. Session initialization failure.');
}
$layout = array( $layout = array(
'controller'=>null, 'controller'=>null,
'view'=>null, 'view'=>null,

View File

@ -120,10 +120,10 @@ if (file_exists(PATH_KERNEL.'bludit.pro.php')) {
} }
// Session // Session
Session::start(); // Session::start();
if (Session::started()===false) { // if (Session::started()===false) {
exit('Bludit CMS. Session initialization failure.'); // exit('Bludit CMS. Session initialization failure.');
} // }
// Objects // Objects
$dbPages = new dbPages(); $dbPages = new dbPages();

View File

@ -408,6 +408,12 @@ class Page {
return $this->getValue('status'); return $this->getValue('status');
} }
// (string) Returns type of the page
public function type()
{
return $this->status();
}
// Returns the title field // Returns the title field
public function title() public function title()
{ {
@ -426,6 +432,24 @@ class Page {
return $this->getValue('position'); return $this->getValue('position');
} }
// Returns the page noindex
public function noindex()
{
return $this->getValue('noindex');
}
// Returns the page nofollow
public function nofollow()
{
return $this->getValue('nofollow');
}
// Returns the page noarchive
public function noarchive()
{
return $this->getValue('noarchive');
}
// Returns the page slug // Returns the page slug
public function slug() public function slug()
{ {

View File

@ -21,9 +21,8 @@ Things to do:
- Fix Tinymce plugin - Fix Tinymce plugin
- New / Edit content - Edit content
-- Option without category -- If the parent is set, the
-- Delete content
- add to settings - add to settings
-- time for autosave -- time for autosave