Bug fix when select the type of the page
This commit is contained in:
parent
0a7d63c512
commit
bf061d6fff
|
@ -85,7 +85,7 @@ function table($type) {
|
||||||
$friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$page->key() : '/'.$url->filters('page').'/'.$page->key();
|
$friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$page->key() : '/'.$url->filters('page').'/'.$page->key();
|
||||||
echo '<td class="d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
echo '<td class="d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||||
|
|
||||||
echo '<td id="jscontentTools" class="pt-3 text-center d-none d-sm-table-cell w-25">'.PHP_EOL;
|
echo '<td class="contentTools pt-3 text-center d-sm-table-cell w-25">'.PHP_EOL;
|
||||||
echo '<a class="btn btn-outline-secondary btn-sm mb-1" href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'"><span class="oi oi-pencil"></span> '.$L->g('Edit').'</a>'.PHP_EOL;
|
echo '<a class="btn btn-outline-secondary btn-sm mb-1" href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'"><span class="oi oi-pencil"></span> '.$L->g('Edit').'</a>'.PHP_EOL;
|
||||||
if (count($page->children())==0) {
|
if (count($page->children())==0) {
|
||||||
echo '<button type="button" class="btn btn-outline-danger btn-sm deletePageButton mb-1" data-toggle="modal" data-target="#jsdeletePageModal" data-key="'.$page->key().'"><span class="oi oi-trash"></span> '.$L->g('Delete').'</button>'.PHP_EOL;
|
echo '<button type="button" class="btn btn-outline-danger btn-sm deletePageButton mb-1" data-toggle="modal" data-target="#jsdeletePageModal" data-key="'.$page->key().'"><span class="oi oi-trash"></span> '.$L->g('Delete').'</button>'.PHP_EOL;
|
||||||
|
@ -111,7 +111,7 @@ function table($type) {
|
||||||
$friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$child->key() : '/'.$url->filters('page').'/'.$child->key();
|
$friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$child->key() : '/'.$url->filters('page').'/'.$child->key();
|
||||||
echo '<td><a target="_blank" href="'.$child->permalink().'">'.$friendlyURL.'</a></td>';
|
echo '<td><a target="_blank" href="'.$child->permalink().'">'.$friendlyURL.'</a></td>';
|
||||||
|
|
||||||
echo '<td class="pt-3 text-center d-none d-sm-table-cell w-25">'.PHP_EOL;
|
echo '<td class="contentTools pt-3 text-center d-sm-table-cell w-25">'.PHP_EOL;
|
||||||
echo '<a class="btn btn-outline-secondary btn-sm mb-1" href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$child->key().'"><span class="oi oi-pencil"></span> '.$L->g('Edit').'</a>'.PHP_EOL;
|
echo '<a class="btn btn-outline-secondary btn-sm mb-1" href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$child->key().'"><span class="oi oi-pencil"></span> '.$L->g('Edit').'</a>'.PHP_EOL;
|
||||||
echo '<button type="button" class="btn btn-outline-danger btn-sm deletePageButton mb-1" data-toggle="modal" data-target="#jsdeletePageModal" data-key="'.$child->key().'"><span class="oi oi-trash"></span> '.$L->g('Delete').'</button>'.PHP_EOL;
|
echo '<button type="button" class="btn btn-outline-danger btn-sm deletePageButton mb-1" data-toggle="modal" data-target="#jsdeletePageModal" data-key="'.$child->key().'"><span class="oi oi-trash"></span> '.$L->g('Delete').'</button>'.PHP_EOL;
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
|
@ -143,7 +143,7 @@ function table($type) {
|
||||||
$friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$page->key() : '/'.$url->filters('page').'/'.$page->key();
|
$friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$page->key() : '/'.$url->filters('page').'/'.$page->key();
|
||||||
echo '<td class="pt-3 d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
echo '<td class="pt-3 d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||||
|
|
||||||
echo '<td id="jscontentTools" class="pt-3 text-center d-sm-table-cell w-25">'.PHP_EOL;
|
echo '<td class="contentTools pt-3 text-center d-sm-table-cell w-25">'.PHP_EOL;
|
||||||
echo '<a class="btn btn-outline-secondary btn-sm mb-1" href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'"><span class="oi oi-pencil"></span> '.$L->g('Edit').'</a>'.PHP_EOL;
|
echo '<a class="btn btn-outline-secondary btn-sm mb-1" href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'"><span class="oi oi-pencil"></span> '.$L->g('Edit').'</a>'.PHP_EOL;
|
||||||
if (count($page->children())==0) {
|
if (count($page->children())==0) {
|
||||||
echo '<button type="button" class="btn btn-outline-danger btn-sm deletePageButton mb-1" data-toggle="modal" data-target="#jsdeletePageModal" data-key="'.$page->key().'"><span class="oi oi-trash"></span> '.$L->g('Delete').'</button>'.PHP_EOL;
|
echo '<button type="button" class="btn btn-outline-danger btn-sm deletePageButton mb-1" data-toggle="modal" data-target="#jsdeletePageModal" data-key="'.$page->key().'"><span class="oi oi-trash"></span> '.$L->g('Delete').'</button>'.PHP_EOL;
|
||||||
|
|
|
@ -83,14 +83,6 @@ echo Bootstrap::formOpen(array(
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#jsPublishSwitch").on("click", function() {
|
|
||||||
$("#jstype").val("published");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsDraftSwitch").on("click", function() {
|
|
||||||
$("#jstype").val("draft");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsoptionsSidebar").on("click", function() {
|
$("#jsoptionsSidebar").on("click", function() {
|
||||||
$("#jseditorSidebar").toggle();
|
$("#jseditorSidebar").toggle();
|
||||||
$("#jsshadow").toggle();
|
$("#jsshadow").toggle();
|
||||||
|
@ -189,7 +181,7 @@ echo Bootstrap::formOpen(array(
|
||||||
'label'=>$L->g('Type'),
|
'label'=>$L->g('Type'),
|
||||||
'selected'=>$page->type(),
|
'selected'=>$page->type(),
|
||||||
'options'=>array(
|
'options'=>array(
|
||||||
'default'=>'- '.$L->g('Default').' -',
|
'published'=>'- '.$L->g('Default').' -',
|
||||||
'sticky'=>$L->g('Sticky'),
|
'sticky'=>$L->g('Sticky'),
|
||||||
'static'=>$L->g('Static')
|
'static'=>$L->g('Static')
|
||||||
),
|
),
|
||||||
|
@ -392,13 +384,12 @@ $(document).ready(function() {
|
||||||
|
|
||||||
// Button Save
|
// Button Save
|
||||||
$("#jsbuttonSave").on("click", function() {
|
$("#jsbuttonSave").on("click", function() {
|
||||||
// Get the type from the selector
|
// If the switch is setted to "published", get the value from the selector
|
||||||
var typeSelector = $("#jstypeSelector option:selected").val();
|
if ($("#jsPublishSwitch").is(':checked')) {
|
||||||
// Get the type from the switch
|
var value = $("#jstypeSelector option:selected").val();
|
||||||
var typeSwitch = $("#jstype").val();
|
$("#jstype").val(value);
|
||||||
// Set the type from the selector if the switch is publish
|
} else {
|
||||||
if ((typeSelector!='default') && (typeSwitch=='published')) {
|
$("#jstype").val("draft");
|
||||||
$("#jstype").val(typeSelector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the content
|
// Get the content
|
||||||
|
|
|
@ -69,14 +69,6 @@ echo Bootstrap::formOpen(array(
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#jsPublishSwitch").on("click", function() {
|
|
||||||
$("#jstype").val("published");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsDraftSwitch").on("click", function() {
|
|
||||||
$("#jstype").val("draft");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsoptionsSidebar").on("click", function() {
|
$("#jsoptionsSidebar").on("click", function() {
|
||||||
$("#jseditorSidebar").toggle();
|
$("#jseditorSidebar").toggle();
|
||||||
$("#jsshadow").toggle();
|
$("#jsshadow").toggle();
|
||||||
|
@ -167,7 +159,7 @@ echo Bootstrap::formOpen(array(
|
||||||
'label'=>$L->g('Type'),
|
'label'=>$L->g('Type'),
|
||||||
'selected'=>'',
|
'selected'=>'',
|
||||||
'options'=>array(
|
'options'=>array(
|
||||||
'default'=>'- '.$L->g('Default').' -',
|
'published'=>'- '.$L->g('Default').' -',
|
||||||
'sticky'=>$L->g('Sticky'),
|
'sticky'=>$L->g('Sticky'),
|
||||||
'static'=>$L->g('Static')
|
'static'=>$L->g('Static')
|
||||||
),
|
),
|
||||||
|
@ -338,13 +330,12 @@ $(document).ready(function() {
|
||||||
|
|
||||||
// Button Save
|
// Button Save
|
||||||
$("#jsbuttonSave").on("click", function() {
|
$("#jsbuttonSave").on("click", function() {
|
||||||
// Get the type from the selector
|
// If the switch is setted to "published", get the value from the selector
|
||||||
var typeSelector = $("#jstypeSelector option:selected").val();
|
if ($("#jsPublishSwitch").is(':checked')) {
|
||||||
// Get the type from the switch
|
var value = $("#jstypeSelector option:selected").val();
|
||||||
var typeSwitch = $("#jstype").val();
|
$("#jstype").val(value);
|
||||||
// Set the type from the selector if the switch is publish
|
} else {
|
||||||
if ((typeSelector!='default') && (typeSwitch=='published')) {
|
$("#jstype").val("draft");
|
||||||
$("#jstype").val(typeSelector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the content
|
// Get the content
|
||||||
|
|
|
@ -344,21 +344,6 @@ function editPage($args) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Title and content need to be here because from inside the dbPages is not visible
|
|
||||||
if (empty($args['title']) || empty($args['content'])) {
|
|
||||||
try {
|
|
||||||
$page = new Page($args['key']);
|
|
||||||
if (empty($args['title'])) {
|
|
||||||
$args['title'] = $page->title();
|
|
||||||
}
|
|
||||||
if (empty($args['content'])) {
|
|
||||||
$args['content'] = $page->contentRaw();
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
// continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$key = $pages->edit($args);
|
$key = $pages->edit($args);
|
||||||
if ($key) {
|
if ($key) {
|
||||||
// Call the plugins after page modified
|
// Call the plugins after page modified
|
||||||
|
|
|
@ -197,8 +197,8 @@ class Pages extends dbJSON {
|
||||||
// This variable is not belong to the database so is not defined in $row
|
// This variable is not belong to the database so is not defined in $row
|
||||||
$newKey = $this->generateKey($slug, $parent, false, $key);
|
$newKey = $this->generateKey($slug, $parent, false, $key);
|
||||||
|
|
||||||
// If the page is draft then the created time is the current
|
// If the page is draft then the created date is the current
|
||||||
if ($this->db[$key]['type']=='draft') {
|
if ($row['type']=='draft') {
|
||||||
$row['date'] = Date::current(DB_DATE_FORMAT);
|
$row['date'] = Date::current(DB_DATE_FORMAT);
|
||||||
} elseif (!Valid::date($row['date'], DB_DATE_FORMAT)) {
|
} elseif (!Valid::date($row['date'], DB_DATE_FORMAT)) {
|
||||||
$row['date'] = $this->db[$key]['date'];
|
$row['date'] = $this->db[$key]['date'];
|
||||||
|
|
Loading…
Reference in New Issue