bug fix #542
This commit is contained in:
parent
c88bb01323
commit
ff1abc1e36
@ -48,6 +48,7 @@ function table($status, $icon='arrow-circle-o-down') {
|
|||||||
|
|
||||||
foreach($list as $pageKey=>$fields) {
|
foreach($list as $pageKey=>$fields) {
|
||||||
$page = buildPage($pageKey);
|
$page = buildPage($pageKey);
|
||||||
|
if ($page) {
|
||||||
echo '<tr>';
|
echo '<tr>';
|
||||||
echo '<td>
|
echo '<td>
|
||||||
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'">'
|
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'">'
|
||||||
@ -62,6 +63,7 @@ function table($status, $icon='arrow-circle-o-down') {
|
|||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($Url->pageNumber()==1) {
|
if ($Url->pageNumber()==1) {
|
||||||
table('draft', 'spinner');
|
table('draft', 'spinner');
|
||||||
|
@ -19,9 +19,7 @@ class dbPages extends dbJSON
|
|||||||
'category'=> array('inFile'=>false, 'value'=>''),
|
'category'=> array('inFile'=>false, 'value'=>''),
|
||||||
'md5file'=> array('inFile'=>false, 'value'=>''),
|
'md5file'=> array('inFile'=>false, 'value'=>''),
|
||||||
'uuid'=> array('inFile'=>false, 'value'=>''),
|
'uuid'=> array('inFile'=>false, 'value'=>''),
|
||||||
'allowComments'=> array('inFile'=>false, 'value'=>true),
|
'allowComments'=> array('inFile'=>false, 'value'=>true)
|
||||||
'parent'=> array('inFile'=>false, 'value'=>''),
|
|
||||||
'slug'=> array('inFile'=>false, 'value'=>'')
|
|
||||||
);
|
);
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
@ -61,6 +59,11 @@ class dbPages extends dbJSON
|
|||||||
$args['slug'] = Text::truncate($tmpslug, 60, '');
|
$args['slug'] = Text::truncate($tmpslug, 60, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parent
|
||||||
|
if (!isset($args['parent'])) {
|
||||||
|
$args['parent'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
// Generate key
|
// Generate key
|
||||||
$key = $this->generateKey($args['slug'], $args['parent']);
|
$key = $this->generateKey($args['slug'], $args['parent']);
|
||||||
|
|
||||||
@ -156,6 +159,11 @@ class dbPages extends dbJSON
|
|||||||
$args[$field] = $value;
|
$args[$field] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parent
|
||||||
|
if (!isset($args['parent'])) {
|
||||||
|
$args['parent'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
$newKey = $this->generateKey($args['slug'], $args['parent'], false, $args['key']);
|
$newKey = $this->generateKey($args['slug'], $args['parent'], false, $args['key']);
|
||||||
|
|
||||||
// If the page is draft then the created time is the current
|
// If the page is draft then the created time is the current
|
||||||
@ -213,6 +221,9 @@ class dbPages extends dbJSON
|
|||||||
// Remove the old key
|
// Remove the old key
|
||||||
unset( $this->db[$args['key']] );
|
unset( $this->db[$args['key']] );
|
||||||
|
|
||||||
|
// Reindex Orphan Children
|
||||||
|
$this->reindexChildren($args['key'], $newKey);
|
||||||
|
|
||||||
// Checksum MD5
|
// Checksum MD5
|
||||||
$dataForDb['md5file'] = md5_file(PATH_PAGES.$newKey.DS.FILENAME);
|
$dataForDb['md5file'] = md5_file(PATH_PAGES.$newKey.DS.FILENAME);
|
||||||
|
|
||||||
@ -228,6 +239,19 @@ class dbPages extends dbJSON
|
|||||||
return $newKey;
|
return $newKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function reindex the orphan children with the new parent key
|
||||||
|
// If a page has subpages and the page change his key is necesarry check the children key
|
||||||
|
public function reindexChildren($oldParentKey, $newParentKey) {
|
||||||
|
$tmp = $this->db;
|
||||||
|
foreach ($tmp as $key=>$fields) {
|
||||||
|
if (Text::startsWith($key, $oldParentKey.'/')) {
|
||||||
|
$newKey = Text::replace($oldParentKey.'/', $newParentKey.'/', $key);
|
||||||
|
$this->db[$newKey] = $this->db[$key];
|
||||||
|
unset($this->db[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function delete($key)
|
public function delete($key)
|
||||||
{
|
{
|
||||||
// This is need it, because if the key is empty the Filesystem::deleteRecursive is going to delete PATH_PAGES
|
// This is need it, because if the key is empty the Filesystem::deleteRecursive is going to delete PATH_PAGES
|
||||||
|
@ -167,7 +167,6 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate the global variable $pagesByParent, defined on 69.pages.php
|
// Generate the global variable $pagesByParent, defined on 69.pages.php
|
||||||
// (boolean) $allPages, TRUE include all status, FALSE only include published status
|
|
||||||
function buildPagesByParent($publishedPages=true, $staticPages=true) {
|
function buildPagesByParent($publishedPages=true, $staticPages=true) {
|
||||||
global $dbPages;
|
global $dbPages;
|
||||||
global $pagesByParent;
|
global $pagesByParent;
|
||||||
|
@ -151,6 +151,7 @@ class Text {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Replace all occurrences of the search string with the replacement string.
|
// Replace all occurrences of the search string with the replacement string.
|
||||||
|
// replace("%body%", "black", "<body text='%body%'>");
|
||||||
public static function replace($search, $replace, $string)
|
public static function replace($search, $replace, $string)
|
||||||
{
|
{
|
||||||
return str_replace($search,$replace,$string);
|
return str_replace($search,$replace,$string);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user