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 // List of published pages
$onlyPublished = true; $onlyPublished = false;
$amountOfItems = ITEMS_PER_PAGE_ADMIN; $amountOfItems = ITEMS_PER_PAGE_ADMIN;
$pageNumber = $Url->pageNumber(); $pageNumber = $Url->pageNumber();
$published = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); $published = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);

View File

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

View File

@ -20,6 +20,8 @@ echo '
<tbody> <tbody>
'; ';
function table($status, $icon='arrow-circle-o-down') { function table($status, $icon='arrow-circle-o-down') {
global $Url; global $Url;
global $Language; global $Language;
@ -40,27 +42,64 @@ function table($status, $icon='arrow-circle-o-down') {
if (!empty($list)) { if (!empty($list)) {
echo '<tr> 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>
<td></td> <td></td>
</tr>'; </tr>';
} }
foreach($list as $pageKey) { if (ORDER_BY=='position') {
$page = buildPage($pageKey); foreach ($list as $pageKey) {
if ($page) { $page = buildPage($pageKey);
echo '<tr>'; if ($page) {
echo '<td> if ($page->isParent()) {
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'">' echo '<tr>
.($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ') <td>
.'</a> <a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'"><i class="fa fa-'.$icon.'"></i> '
</td>'; .($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ')
.'</a>
</td>
<td class="uk-text-center">'.$page->position().'</td>';
echo '<td class="uk-text-center">'.( (ORDER_BY=='date') ? $page->dateRaw(ADMIN_PANEL_DATE_FORMAT) : $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>';
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$page->key() : '/'.$Url->filters('page').'/'.$page->key(); foreach ($page->children() as $childKey) {
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>'; $child = buildPage($childKey);
echo '</tr>'; 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().'"><i class="fa fa-'.$icon.'"></i> '
.($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ')
.'</a>
</td>';
echo '<td class="uk-text-center">'.( (ORDER_BY=='date') ? $page->dateRaw(ADMIN_PANEL_DATE_FORMAT) : $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>';
}
} }
} }
} }
@ -70,7 +109,7 @@ if ($Url->pageNumber()==1) {
table('scheduled', 'clock-o'); table('scheduled', 'clock-o');
table('static', 'thumb-tack'); table('static', 'thumb-tack');
} }
table('published', 'check'); table('published', 'circle-o');
echo ' echo '
</tbody> </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> </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> </script>

View File

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

View File

@ -426,6 +426,8 @@ class dbPages extends dbJSON
return false; return false;
} }
// Returns the amount of pages // Returns the amount of pages
// (boolean) $total, TRUE returns the total of pages // (boolean) $total, TRUE returns the total of pages
// (boolean) $total, FALSE returns the total of published pages (without draft and scheduled) // (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); 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() public function getParents()
{ {
$db = $this->getPublishedDB(); $db = $this->getPublishedDB();
@ -452,6 +454,18 @@ class dbPages extends dbJSON
return $db; 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 // Return TRUE if the page exists, FALSE otherwise
public function exists($key) public function exists($key)
{ {

View File

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

View File

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