Improves on Manage pages and minor fixes
This commit is contained in:
parent
caa96d4fa4
commit
9798bbcd9b
@ -16,8 +16,7 @@
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if( isset($_POST['delete-page']) ) {
|
||||
if( deletePage($_POST['key']) ) {
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
@ -38,13 +37,12 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
// ============================================================================
|
||||
// Main after POST
|
||||
// ============================================================================
|
||||
|
||||
if( !$dbPages->exists($layout['parameters']) ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$layout['parameters']);
|
||||
$pageKey = $layout['parameters'];
|
||||
$page = buildPage($pageKey);
|
||||
if ($page===false) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$pageKey);
|
||||
Redirect::page('pages');
|
||||
}
|
||||
|
||||
$page = $pagesByKey[$layout['parameters']];
|
||||
|
||||
// Title of the page
|
||||
$layout['title'] .= ' - '.$Language->g('Edit Content').' - '.$page->title();
|
@ -16,11 +16,8 @@
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
|
||||
if (createPage($_POST)!==false) {
|
||||
Alert::set( $Language->g('Page added successfully') );
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
createPage($_POST);
|
||||
Redirect::page('pages');
|
||||
}
|
||||
|
||||
|
@ -20,5 +20,23 @@
|
||||
// Main after POST
|
||||
// ============================================================================
|
||||
|
||||
// List of published pages
|
||||
$onlyPublished = true;
|
||||
$amountOfItems = ITEMS_PER_PAGE_ADMIN;
|
||||
$pageNumber = $Url->pageNumber();
|
||||
$published = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
|
||||
// Check if out of range the pageNumber
|
||||
if (empty($published)) {
|
||||
Redirect::page('pages');
|
||||
}
|
||||
|
||||
// List of drafts pages
|
||||
$drafts = $dbPages->getDraftDB();
|
||||
|
||||
$scheduled = $dbPages->getScheduledDB();
|
||||
|
||||
$fixed = $dbPages->getFixedDB();
|
||||
|
||||
// Title of the page
|
||||
$layout['title'] .= ' - '.$Language->g('Manage Content');
|
@ -22,42 +22,53 @@ echo '
|
||||
';
|
||||
|
||||
function table($status, $icon='arrow-circle-o-down') {
|
||||
global $pages;
|
||||
global $Url;
|
||||
global $Language;
|
||||
global $published;
|
||||
global $drafts;
|
||||
global $scheduled;
|
||||
global $fixed;
|
||||
|
||||
$showLegend = true;
|
||||
foreach ($pages as $key=>$page) {
|
||||
if ($page->status()==$status) {
|
||||
if ($showLegend) {
|
||||
$showLegend = false;
|
||||
echo '<tr>
|
||||
<td style="color: #aaa; font-size: 0.9em; text-transform: uppercase;"><i class="fa fa-'.$icon.'" aria-hidden="true"></i> '.$status.'</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
unset($pages[$key]);
|
||||
echo '<tr>';
|
||||
echo '<td>
|
||||
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'
|
||||
.($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ')
|
||||
.'</a>
|
||||
</td>';
|
||||
if ($status=='published') {
|
||||
$list = $published;
|
||||
} elseif ($status=='draft') {
|
||||
$list = $drafts;
|
||||
} elseif ($status=='scheduled') {
|
||||
$list = $scheduled;
|
||||
} elseif ($status=='fixed') {
|
||||
$list = $fixed;
|
||||
}
|
||||
|
||||
echo '<td class="uk-text-center">'.( (ORDER_BY=='date') ? $page->dateRaw() : $page->position() ).'</td>';
|
||||
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> '.$status.'</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
$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($list as $pageKey=>$fields) {
|
||||
$page = buildPage($pageKey);
|
||||
echo '<tr>';
|
||||
echo '<td>
|
||||
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'
|
||||
.($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() : $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>';
|
||||
}
|
||||
}
|
||||
|
||||
table('draft', 'spinner');
|
||||
table('scheduled', 'clock-o');
|
||||
table('fixed', 'thumb-tack');
|
||||
table('sticky', 'sticky-note-o');
|
||||
if ($Url->pageNumber()==1) {
|
||||
table('draft', 'spinner');
|
||||
table('scheduled', 'clock-o');
|
||||
table('fixed', 'thumb-tack');
|
||||
}
|
||||
table('published', 'check');
|
||||
|
||||
echo '
|
||||
|
@ -88,5 +88,4 @@ else
|
||||
|
||||
// Load plugins after the admin area is loaded.
|
||||
Theme::plugins('afterAdminLoad');
|
||||
|
||||
}
|
@ -16,18 +16,6 @@
|
||||
*/
|
||||
$pages = array();
|
||||
|
||||
// Array with pages, each page is a Page Object
|
||||
// Filtered by pagenumber and amount of items per page
|
||||
/*
|
||||
array(
|
||||
"pageKey1" => Page Object,
|
||||
"pageKey2" => Page Object,
|
||||
...
|
||||
"pageKeyN" => Page Object,
|
||||
)
|
||||
*/
|
||||
$pagesByKey = array();
|
||||
|
||||
// Page filtered by the user, is a Page Object
|
||||
$page = $Page = false;
|
||||
|
||||
@ -127,10 +115,6 @@ elseif ($Url->whereAmI()==='category') {
|
||||
elseif ($Url->whereAmI()==='home') {
|
||||
buildPagesForHome();
|
||||
}
|
||||
// Build pages for the admin area
|
||||
elseif ($Url->whereAmI()==='admin') {
|
||||
buildPagesForAdmin();
|
||||
}
|
||||
|
||||
// Set page 404 not found
|
||||
if ($Url->notFound()) {
|
||||
|
@ -100,10 +100,6 @@ function buildThePage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function buildPagesForAdmin() {
|
||||
return buildPagesFor('admin');
|
||||
}
|
||||
|
||||
function buildPagesForHome() {
|
||||
return buildPagesFor('home');
|
||||
}
|
||||
@ -128,27 +124,21 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
|
||||
global $dbTags;
|
||||
global $Site;
|
||||
global $Url;
|
||||
global $pagesByKey;
|
||||
global $pages;
|
||||
|
||||
// Get the page number from URL
|
||||
$pageNumber = $Url->pageNumber();
|
||||
|
||||
if($for=='admin') {
|
||||
$onlyPublished = false;
|
||||
$amountOfItems = ITEMS_PER_PAGE_ADMIN;
|
||||
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
}
|
||||
elseif($for=='home') {
|
||||
if ($for=='home') {
|
||||
$onlyPublished = true;
|
||||
$amountOfItems = $Site->itemsPerPage();
|
||||
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
}
|
||||
elseif($for=='category') {
|
||||
elseif ($for=='category') {
|
||||
$amountOfItems = $Site->itemsPerPage();
|
||||
$list = $dbCategories->getList($categoryKey, $pageNumber, $amountOfItems);
|
||||
}
|
||||
elseif($for=='tag') {
|
||||
elseif ($for=='tag') {
|
||||
$amountOfItems = $Site->itemsPerPage();
|
||||
$list = $dbTags->getList($tagKey, $pageNumber, $amountOfItems);
|
||||
}
|
||||
@ -160,14 +150,9 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
|
||||
}
|
||||
|
||||
$pages = array(); // global variable
|
||||
$pagesByKey = array(); // global variable
|
||||
foreach($list as $pageKey=>$fields) {
|
||||
$page = buildPage($pageKey);
|
||||
if($page!==false) {
|
||||
// $pagesByKey
|
||||
$pagesByKey[$pageKey] = $page;
|
||||
|
||||
// $pages
|
||||
array_push($pages, $page);
|
||||
}
|
||||
}
|
||||
@ -309,6 +294,7 @@ function printDebug($array) {
|
||||
function createPage($args) {
|
||||
global $dbPages;
|
||||
global $Syslog;
|
||||
global $Language;
|
||||
|
||||
// The user is always the one loggued
|
||||
$args['username'] = Session::get('username');
|
||||
@ -339,6 +325,8 @@ function createPage($args) {
|
||||
'notes'=>$args['title']
|
||||
));
|
||||
|
||||
Alert::set( $Language->g('new-page-created') );
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
@ -550,6 +538,7 @@ function editSettings($args) {
|
||||
global $Site;
|
||||
global $Syslog;
|
||||
global $Language;
|
||||
global $dbPages;
|
||||
|
||||
if (isset($args['language'])) {
|
||||
if ($args['language']!=$Site->language()) {
|
||||
|
@ -199,5 +199,7 @@
|
||||
"this-title-is-almost-always-used-in-the-sidebar-of-the-site": "This title is almost always used in the sidebar of the site.",
|
||||
"password-must-be-at-least-6-characters-long": "Password must be at least 6 characters long",
|
||||
"ip-address-has-been-blocked": "IP address has been blocked",
|
||||
"try-again-in-a-few-minutes": "Try again in a few minutes"
|
||||
"try-again-in-a-few-minutes": "Try again in a few minutes",
|
||||
"page-published-from-scheduler": "Page published from scheduler",
|
||||
"installer-page-about-content": "The about page is an important and powerful for potential clients and partners. For those who wonder who is behind the website, your About page is the first source of information."
|
||||
}
|
Loading…
Reference in New Issue
Block a user