Improves on pages
This commit is contained in:
parent
3c2ecccb74
commit
a77e22d93b
@ -140,6 +140,11 @@ legend.first-child {
|
||||
padding: 15px 10px;
|
||||
}
|
||||
|
||||
.uk-table td.children {
|
||||
padding: 15px 10px 15px 25px;
|
||||
}
|
||||
|
||||
|
||||
.uk-badge {
|
||||
margin-right: 5px !important;
|
||||
font-size: 0.9em;
|
||||
|
@ -7,7 +7,6 @@ echo '
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.$L->g('Title').'</th>
|
||||
<th>'.$L->g('Parent').'</th>
|
||||
<th class="uk-text-center">'.$L->g('Position').'</th>
|
||||
<th>'.$L->g('Friendly URL').'</th>
|
||||
</tr>
|
||||
@ -15,26 +14,33 @@ echo '
|
||||
<tbody>
|
||||
';
|
||||
|
||||
unset($pagesParents[NO_PARENT_CHAR]);
|
||||
|
||||
foreach($pagesParents as $parentKey=>$pageList)
|
||||
{
|
||||
// Parent page
|
||||
$Page = $pages[$parentKey];
|
||||
|
||||
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$Page->key() : '/'.$Url->filters('page').'/'.$Page->key();
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>';
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->published()?'':'<span class="label-draft">'.$Language->g('Draft').'</span> ').($Page->title()?$Page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a>';
|
||||
echo '</td>';
|
||||
echo '<td class="uk-text-center">'.$Page->position().'</td>';
|
||||
echo '<td><a target="_blank" href="'.$Page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// Children
|
||||
foreach($pageList as $Page)
|
||||
{
|
||||
if($parentKey!==NO_PARENT_CHAR) {
|
||||
$parentTitle = $pages[$Page->parentKey()]->title();
|
||||
}
|
||||
else {
|
||||
$parentTitle = '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>'.($Page->parentKey()?'- ':'').'<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->published()?'':'<span class="label-draft">'.$Language->g('Draft').'</span> ').($Page->title()?$Page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a></td>';
|
||||
echo '<td>'.$parentTitle.'</td>';
|
||||
echo '<td class="uk-text-center">'.$Page->position().'</td>';
|
||||
|
||||
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$Page->key() : '/'.$Url->filters('page').'/'.$Page->key();
|
||||
|
||||
echo '<tr class="children">';
|
||||
echo '<td class="children">';
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->published()?'':'<span class="label-draft">'.$Language->g('Draft').'</span> ').($Page->title()?$Page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a>';
|
||||
echo '</td>';
|
||||
echo '<td class="uk-text-center">'.$Page->position().'</td>';
|
||||
echo '<td><a target="_blank" href="'.$Page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
@ -7,14 +7,18 @@
|
||||
// Array with all pages.
|
||||
$pages = array();
|
||||
|
||||
$pagesPublished = array();
|
||||
|
||||
// Array with all pages, order by parent.
|
||||
$pagesParents = array(NO_PARENT_CHAR=>array());
|
||||
|
||||
$pagesParentsPublished = array();
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function sortPages($a, $b)
|
||||
function sortPages2($a, $b)
|
||||
{
|
||||
if ($a->position() == $b->position()) {
|
||||
return 0;
|
||||
@ -23,6 +27,15 @@ function sortPages($a, $b)
|
||||
return ($a->position() < $b->position()) ? -1 : 1;
|
||||
}
|
||||
|
||||
function sortPages($a, $b)
|
||||
{
|
||||
if ($a['position'] == $b['position']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($a['position'] < $b['position']) ? -1 : 1;
|
||||
}
|
||||
|
||||
function buildPage($key)
|
||||
{
|
||||
global $dbPages;
|
||||
@ -81,63 +94,62 @@ function buildPage($key)
|
||||
function buildAllPages()
|
||||
{
|
||||
global $pagesParents;
|
||||
global $pagesParentsPublished;
|
||||
global $pagesPublished;
|
||||
global $dbPages;
|
||||
|
||||
// Get the page list
|
||||
$list = $dbPages->getDB();
|
||||
|
||||
// Clean pages array.
|
||||
$pages = array();
|
||||
|
||||
// Remove the error page
|
||||
unset($list['error']);
|
||||
|
||||
// Sorte pages
|
||||
uasort($list, 'sortPages');
|
||||
|
||||
foreach($list as $key=>$db)
|
||||
{
|
||||
$Page = buildPage($key);
|
||||
|
||||
if($Page!==false)
|
||||
{
|
||||
// --- Order pages by parents ---
|
||||
// Filter pages, with and without parent
|
||||
|
||||
// Generate all posible parents.
|
||||
if( $Page->parentKey()===false )
|
||||
{
|
||||
// If the page doesn't have a father, it's a parent page :P
|
||||
if( $Page->parentKey()===false ) {
|
||||
// Add the parent key in the dbPages
|
||||
$dbPages->addParentKey($Page->key());
|
||||
|
||||
// Add the page as a parent page in the array
|
||||
$pagesParents[NO_PARENT_CHAR][$Page->key()] = $Page;
|
||||
|
||||
// If the page is published
|
||||
if($Page->published()) {
|
||||
$pagesParentsPublished[NO_PARENT_CHAR][$Page->key()] = $Page;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$pagesParents[$Page->parentKey()][$Page->key()] = $Page;
|
||||
|
||||
// If the page is published
|
||||
if($Page->published()) {
|
||||
$pagesParentsPublished[$Page->parentKey()][$Page->key()] = $Page;
|
||||
}
|
||||
}
|
||||
|
||||
// --- All pages in 1 array ---
|
||||
// All pages in one array
|
||||
$pages[$Page->key()] = $Page;
|
||||
|
||||
// If the page is published
|
||||
if($Page->published()) {
|
||||
$pagesPublished[$Page->parentKey()][$Page->key()] = $Page;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- SORT PAGES ---
|
||||
|
||||
// Sort parents.
|
||||
$parents = $pagesParents[NO_PARENT_CHAR];
|
||||
uasort($parents, 'sortPages');
|
||||
|
||||
// Sort children.
|
||||
unset($pagesParents[NO_PARENT_CHAR]);
|
||||
$children = $pagesParents;
|
||||
$tmpPageWithParent = array();
|
||||
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;
|
||||
uasort($tmpPageWithParent[$parentKey], 'sortPages');
|
||||
}
|
||||
}
|
||||
|
||||
$pagesParents = array(NO_PARENT_CHAR=>$parents) + $tmpPageWithParent;
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
@ -193,3 +205,4 @@ if($Url->notFound())
|
||||
|
||||
// Build all pages
|
||||
$pages = buildAllPages();
|
||||
|
||||
|
@ -16,6 +16,30 @@ h1, h2, h3, h4, h5, h6 {
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.4em;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
#header {
|
||||
background-color: #f7f7f7;
|
||||
border-bottom: 0;
|
||||
|
@ -13,7 +13,7 @@
|
||||
<nav class="links">
|
||||
<ul>
|
||||
<?php
|
||||
$parents = $pagesParents[NO_PARENT_CHAR];
|
||||
$parents = $pagesParentsPublished[NO_PARENT_CHAR];
|
||||
foreach($parents as $Parent) {
|
||||
echo '<li><a href="'.$Parent->permalink().'">'.$Parent->title().'</a></li>';
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
<header>
|
||||
<div class="title">
|
||||
<h1><a href="<?php echo $Post->permalink() ?>"><?php echo $Post->title() ?></a></h1>
|
||||
<p><?php echo $Post->description() ?></p>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<?php
|
||||
|
Loading…
Reference in New Issue
Block a user