Improves on Manage Content view

This commit is contained in:
Diego Najar 2018-01-21 23:23:22 +01:00
parent 203e120d17
commit 809cd261b2
9 changed files with 103 additions and 28 deletions

View File

@ -21,7 +21,7 @@
// ============================================================================
// List of published pages
$onlyPublished = true;
$onlyPublished = false;
$amountOfItems = ITEMS_PER_PAGE_ADMIN;
$pageNumber = $Url->pageNumber();
$published = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);

View File

@ -302,6 +302,10 @@ button.aslink:hover {
padding: 14px 8px !important;
}
.uk-table td.child-title {
padding-left: 20px !important;
}
/* RESPONSIVE
---------------------------------------------------------------- */

View File

@ -20,6 +20,8 @@ echo '
<tbody>
';
function table($status, $icon='arrow-circle-o-down') {
global $Url;
global $Language;
@ -40,18 +42,54 @@ function table($status, $icon='arrow-circle-o-down') {
if (!empty($list)) {
echo '<tr>
<td style="color: #aaa; font-size: 0.9em; text-transform: uppercase;"><i class="fa fa-'.$icon.'" aria-hidden="true"></i> '.$Language->g($status).'</td>
<td style="color: #aaa; font-size: 0.9em; text-transform: uppercase;">'.$Language->g($status).'</td>
<td></td>
<td></td>
</tr>';
}
foreach($list as $pageKey) {
if (ORDER_BY=='position') {
foreach ($list as $pageKey) {
$page = buildPage($pageKey);
if ($page) {
if ($page->isParent()) {
echo '<tr>
<td>
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'"><i class="fa fa-'.$icon.'"></i> '
.($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ')
.'</a>
</td>
<td class="uk-text-center">'.$page->position().'</td>';
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$page->key() : '/'.$Url->filters('page').'/'.$page->key();
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
echo '</tr>';
foreach ($page->children() as $childKey) {
$child = buildPage($childKey);
echo '<tr>
<td class="child-title">
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$child->key().'"><i class="fa fa-circle-thin"></i> '
.($child->title()?$child->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ')
.'</a>
</td>
<td class="uk-text-center">'.$child->position().'</td>';
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$child->key() : '/'.$Url->filters('page').'/'.$child->key();
echo '<td><a target="_blank" href="'.$child->permalink().'">'.$friendlyURL.'</a></td>';
echo '</tr>';
}
}
}
}
} else {
foreach ($list as $pageKey) {
$page = buildPage($pageKey);
if ($page) {
echo '<tr>';
echo '<td>
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'">'
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'"><i class="fa fa-'.$icon.'"></i> '
.($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ')
.'</a>
</td>';
@ -63,6 +101,7 @@ function table($status, $icon='arrow-circle-o-down') {
echo '</tr>';
}
}
}
}
if ($Url->pageNumber()==1) {
@ -70,7 +109,7 @@ if ($Url->pageNumber()==1) {
table('scheduled', 'clock-o');
table('static', 'thumb-tack');
}
table('published', 'check');
table('published', 'circle-o');
echo '
</tbody>

View File

@ -285,6 +285,15 @@ $(document).ready(function()
}
});
$("#jsstatus").change(function() {
if ($(this).val()=='static') {
$("#jsparent").val(' ');
$("#jsparent").attr('disabled','disabled');
} else {
$("#jsparent").removeAttr('disabled');
}
});
});
</script>

View File

@ -253,6 +253,15 @@ $(document).ready(function()
}
});
$("#jsstatus").change(function() {
if ($(this).val()=='static') {
$("#jsparent").val(' ');
$("#jsparent").attr('disabled','disabled');
} else {
$("#jsparent").removeAttr('disabled');
}
});
});
</script>

View File

@ -43,7 +43,7 @@ define('PAGE_BREAK', '<!-- pagebreak -->');
define('PARENT', 'BLUDIT3849abb4cb7abd24c2d8dac17b216f17');
// Items per page for admin area
define('ITEMS_PER_PAGE_ADMIN', 10);
define('ITEMS_PER_PAGE_ADMIN', 20);
// Cli mode, status for new pages
define('CLI_STATUS', 'published');

View File

@ -426,6 +426,8 @@ class dbPages extends dbJSON
return false;
}
// Returns the amount of pages
// (boolean) $total, TRUE returns the total of pages
// (boolean) $total, FALSE returns the total of published pages (without draft and scheduled)
@ -439,7 +441,7 @@ class dbPages extends dbJSON
return count($this->db);
}
// Returns an array with all parents pages key, a parent page is not a child
// Returns an array with all parents pages key. A parent page is not a child
public function getParents()
{
$db = $this->getPublishedDB();
@ -452,6 +454,18 @@ class dbPages extends dbJSON
return $db;
}
public function getChildren($parentKey)
{
$tmp = $this->db;
$list = array();
foreach ($tmp as $key=>$fields) {
if (Text::startsWith($key, $parentKey.'/')) {
array_push($list, $key);
}
}
return $list;
}
// Return TRUE if the page exists, FALSE otherwise
public function exists($key)
{

View File

@ -58,6 +58,9 @@ function buildPage($key) {
$categoryKey = $page->categoryKey();
$page->setField('categoryMap', $dbCategories->getMap($categoryKey));
// Get the keys of the child
$page->setField('children', $dbPages->getChildren($key));
return $page;
}
@ -189,9 +192,6 @@ function buildPagesByParent($publishedPages=true, $staticPages=true) {
if ($publishedPages) {
$keys = array_merge($keys, $dbPages->getPublishedDB($onlyKeys));
}
if ($staticPages) {
$keys = array_merge($keys, $dbPages->getStaticDB($onlyKeys));
}
foreach ($keys as $pageKey) {
$page = buildPage($pageKey);

View File

@ -438,14 +438,9 @@ class Page {
// Returns an array with all children's key
public function children()
{
$tmp = array();
$paths = Filesystem::listDirectories(PATH_PAGES.$this->getValue('key').DS);
foreach ($paths as $path) {
array_push($tmp, basename($path));
return $this->getValue('children');
}
return $tmp;
}
public function subpages()
{
return $this->children();
@ -458,6 +453,11 @@ class Page {
return !empty($subpages);
}
public function isParent()
{
return $this->hasSubpages();
}
// Returns relative time (e.g. "1 minute ago")
// Based on http://stackoverflow.com/a/18602474