';
}
}
}
// Render rows for a list, applying the parent/child nesting rules used by the
// Static tab and by the Pages/Sticky lists when ORDER_BY is "position".
function tableRows($list, $type, $isSticky = false) {
$nestChildren = ($type === 'static') || (ORDER_BY === 'position');
foreach ($list as $pageKey) {
try {
$page = new Page($pageKey);
} catch (Exception $e) {
continue;
}
if ($nestChildren) {
if ($page->isChild()) {
continue;
}
tableRow($pageKey, $type, $isSticky, true);
} else {
tableRow($pageKey, $type, $isSticky, false);
}
}
}
// Render a full table for a single tab (Static, Scheduled, Draft, Autosave).
function table($type) {
global $L;
global $drafts;
global $scheduled;
global $static;
global $autosave;
if ($type === 'draft') {
$list = $drafts;
$emptyMessage = $L->g('There are no draft pages at this moment.');
} elseif ($type === 'scheduled') {
$list = $scheduled;
$emptyMessage = $L->g('There are no scheduled pages at this moment.');
} elseif ($type === 'static') {
$list = $static;
$emptyMessage = $L->g('There are no static pages at this moment.');
} elseif ($type === 'autosave') {
$list = $autosave;
$emptyMessage = '';
} else {
return;
}
if (empty($list) && $type !== 'autosave') {
echo '
'.$emptyMessage.'
';
return;
}
echo '
';
echo '
'.$L->g('Title').'
';
if ($type === 'static') {
echo '
'.$L->g('URL').'
';
}
echo '
'.$L->g('Actions').'
';
echo '
';
tableRows($list, $type);
echo '
';
}
// Render the Pages tab: sticky rows first, then the paginated published list,
// in a single table.
function tablePages() {
global $L;
global $published;
global $sticky;
global $url;
$isFirstPage = ($url->pageNumber() <= 1);
if (empty($published) && (empty($sticky) || !$isFirstPage)) {
echo '
'.$L->g('There are no pages at this moment.').'
';
return;
}
echo '
';
echo '
'.$L->g('Title').'
';
echo '
'.$L->g('URL').'
';
echo '
'.$L->g('Actions').'
';
echo '
';
if (!empty($sticky) && $isFirstPage) {
tableRows($sticky, 'sticky', true);
}
if (!empty($published)) {
tableRows($published, 'published', false);
}
echo '
$L->g('Delete'),
'buttonPrimaryClass'=>'btn-danger deletePageModalAcceptButton',
'buttonSecondary'=>$L->g('Cancel'),
'buttonSecondaryClass'=>'btn-link',
'modalTitle'=>$L->g('Delete content'),
'modalText'=>$L->g('Are you sure you want to delete this page'),
'modalId'=>'jsdeletePageModal'
));
?>