2015-10-19 00:45:58 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Check role
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
if($Login->role()!=='admin') {
|
|
|
|
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
|
|
|
Redirect::page('admin', 'dashboard');
|
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Functions
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
function setSettings($args)
|
|
|
|
{
|
|
|
|
global $Site;
|
|
|
|
global $Language;
|
2017-05-21 22:01:44 +02:00
|
|
|
global $Syslog;
|
|
|
|
global $dbPages;
|
2015-10-19 00:45:58 +02:00
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
// Add slash at the begin and end
|
2015-10-19 00:45:58 +02:00
|
|
|
$args['uriPage'] = Text::addSlashes($args['uriPage']);
|
|
|
|
$args['uriTag'] = Text::addSlashes($args['uriTag']);
|
2017-05-16 00:46:20 +02:00
|
|
|
$args['uriCategory'] = Text::addSlashes($args['uriCategory']);
|
2015-10-19 00:45:58 +02:00
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
if( ($args['uriPage']==$args['uriTag']) ||
|
|
|
|
($args['uriPage']==$args['uriCategory']) ||
|
|
|
|
($args['uriTag']==$args['uriCategory'])
|
|
|
|
) {
|
2015-10-19 00:45:58 +02:00
|
|
|
$args = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $Site->set($args) ) {
|
2017-05-21 22:01:44 +02:00
|
|
|
// Add to syslog
|
|
|
|
$Syslog->add(array(
|
|
|
|
'dictionaryKey'=>'changes-on-settings',
|
|
|
|
'notes'=>''
|
|
|
|
));
|
|
|
|
|
|
|
|
// Check actual order by, if different than the new settings sort pages
|
|
|
|
if( $Site->orderBy()!=ORDER_BY ) {
|
|
|
|
if( $Site->orderBy()=='date' ) {
|
|
|
|
$dbPages->sortByDate();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$dbPages->sortByPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save database state
|
|
|
|
$dbPages->save();
|
|
|
|
|
|
|
|
// Re-index categories
|
|
|
|
reindexCategories();
|
|
|
|
|
|
|
|
// Re-index tags
|
|
|
|
reindextags();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create an alert
|
|
|
|
Alert::set( $Language->g('The changes have been saved') );
|
2015-10-19 00:45:58 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
// Redirect
|
|
|
|
Redirect::page('settings-advanced');
|
2015-10-19 00:45:58 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main after POST
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|
|
|
{
|
|
|
|
setSettings($_POST);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main after POST
|
|
|
|
// ============================================================================
|
2017-07-15 15:47:37 +02:00
|
|
|
$allPublishedPages = buildAllpages(true);
|
2015-10-19 00:45:58 +02:00
|
|
|
|
2017-07-11 23:53:53 +02:00
|
|
|
// Homepage select options
|
|
|
|
$homepageOptions = array();
|
|
|
|
foreach($allPublishedPages as $key=>$page) {
|
2017-07-23 17:02:06 +02:00
|
|
|
$parentKey = $page->parentKey();
|
|
|
|
if ($parentKey) {
|
|
|
|
$homepageOptions[$key] = $pagesByParentByKey[PARENT][$parentKey]->title() .'->'. $page->title();
|
|
|
|
} else {
|
|
|
|
$homepageOptions[$key] = $page->title();
|
|
|
|
}
|
2017-09-04 19:09:37 +02:00
|
|
|
|
|
|
|
ksort($homepageOptions);
|
2017-07-11 23:53:53 +02:00
|
|
|
}
|