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().'">'
|
||||||
|
@ -61,6 +62,7 @@ function table($status, $icon='arrow-circle-o-down') {
|
||||||
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Url->pageNumber()==1) {
|
if ($Url->pageNumber()==1) {
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -387,7 +386,7 @@ function editPage($args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// External Cover Image
|
// External Cover Image
|
||||||
if ( !empty($args['externalCoverImage']) ) {
|
if (!empty($args['externalCoverImage'])) {
|
||||||
$args['coverImage'] = $args['externalCoverImage'];
|
$args['coverImage'] = $args['externalCoverImage'];
|
||||||
unset($args['externalCoverImage']);
|
unset($args['externalCoverImage']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -399,7 +399,7 @@ class Page {
|
||||||
$explode = explode('/', $this->getValue('key'));
|
$explode = explode('/', $this->getValue('key'));
|
||||||
|
|
||||||
// Check if the page have a parent.
|
// Check if the page have a parent.
|
||||||
if(!empty($explode[1])) {
|
if (!empty($explode[1])) {
|
||||||
return $explode[1];
|
return $explode[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ class Page {
|
||||||
public function parentKey()
|
public function parentKey()
|
||||||
{
|
{
|
||||||
$explode = explode('/', $this->getValue('key'));
|
$explode = explode('/', $this->getValue('key'));
|
||||||
if(isset($explode[1])) {
|
if (isset($explode[1])) {
|
||||||
return $explode[0];
|
return $explode[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ class Page {
|
||||||
public function parentMethod($method)
|
public function parentMethod($method)
|
||||||
{
|
{
|
||||||
$parentKey = $this->parentKey();
|
$parentKey = $this->parentKey();
|
||||||
if( $parentKey ) {
|
if ($parentKey) {
|
||||||
$page = buildPage($parentKey);
|
$page = buildPage($parentKey);
|
||||||
return $page->{$method}();
|
return $page->{$method}();
|
||||||
}
|
}
|
||||||
|
@ -434,7 +434,7 @@ class Page {
|
||||||
{
|
{
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
$paths = Filesystem::listDirectories(PATH_PAGES.$this->getValue('key').DS);
|
$paths = Filesystem::listDirectories(PATH_PAGES.$this->getValue('key').DS);
|
||||||
foreach($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
array_push($tmp, basename($path));
|
array_push($tmp, basename($path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue