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