Bug fixed - Page position
This commit is contained in:
parent
e970b71d13
commit
3b6aac5ec2
|
@ -14,7 +14,7 @@ $pagesParents = array(NO_PARENT_CHAR=>array());
|
||||||
// Functions
|
// Functions
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
function orderChildren($a, $b)
|
function sortPages($a, $b)
|
||||||
{
|
{
|
||||||
if ($a->position() == $b->position()) {
|
if ($a->position() == $b->position()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -23,10 +23,6 @@ function orderChildren($a, $b)
|
||||||
return ($a->position() < $b->position()) ? -1 : 1;
|
return ($a->position() < $b->position()) ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function orderParent($array, $values, $offset) {
|
|
||||||
return ( array_slice($array, 0, $offset, true) + $values + array_slice($array, $offset, NULL, true) );
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_page($key)
|
function build_page($key)
|
||||||
{
|
{
|
||||||
global $dbPages;
|
global $dbPages;
|
||||||
|
@ -110,31 +106,27 @@ function build_all_pages()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======== Sort pages ========
|
// --- SORT PAGES ---
|
||||||
|
|
||||||
$tmpNoParents = $pagesParents[NO_PARENT_CHAR];
|
// Sort parents.
|
||||||
|
$parents = $pagesParents[NO_PARENT_CHAR];
|
||||||
|
uasort($parents, 'sortPages');
|
||||||
|
|
||||||
|
// Sort children.
|
||||||
unset($pagesParents[NO_PARENT_CHAR]);
|
unset($pagesParents[NO_PARENT_CHAR]);
|
||||||
|
$children = $pagesParents;
|
||||||
// Sort children
|
|
||||||
$tmpPageWithParent = array();
|
$tmpPageWithParent = array();
|
||||||
foreach($pagesParents as $parentKey=>$childrenPages)
|
foreach($children as $parentKey=>$childrenPages)
|
||||||
|
{
|
||||||
|
// If the child doesn't have a valid parent, then doesn't included them.
|
||||||
|
if(isset($pages[$parentKey]))
|
||||||
{
|
{
|
||||||
$tmpPageWithParent[$parentKey] = $childrenPages;
|
$tmpPageWithParent[$parentKey] = $childrenPages;
|
||||||
uasort($tmpPageWithParent[$parentKey], 'orderChildren');
|
uasort($tmpPageWithParent[$parentKey], 'sortPages');
|
||||||
}
|
|
||||||
|
|
||||||
// Sort parents
|
|
||||||
$tmp = array();
|
|
||||||
foreach($tmpNoParents as $parentKey=>$childrenPages)
|
|
||||||
{
|
|
||||||
// DEBUG: Workaround, Esto es un bug, cuando se usa el Cli mode
|
|
||||||
// DEBUG: Se genera un padre sin index.txt y adentro hay un hijo
|
|
||||||
if(isset($pages[$parentKey])) {
|
|
||||||
$tmp = orderParent($tmp, array($parentKey=>$childrenPages), $pages[$parentKey]->position());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pagesParents = array(NO_PARENT_CHAR=>$tmp) + $tmpPageWithParent;
|
$pagesParents = array(NO_PARENT_CHAR=>$parents) + $tmpPageWithParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
Loading…
Reference in New Issue