Skip to content

Commit

Permalink
Merge pull request #272 from robiso/333
Browse files Browse the repository at this point in the history
Publishing 3.3.3 馃殌  Thank you @slavenstancic
  • Loading branch information
robiso committed Jul 25, 2022
2 parents 11498ec + ae47a7a commit bbfbf5c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions index.php
Expand Up @@ -7,7 +7,7 @@
*/

session_start();
define('VERSION', '3.3.2');
define('VERSION', '3.3.3');
mb_internal_encoding('UTF-8');

if (defined('PHPUNIT_TESTING') === false) {
Expand Down Expand Up @@ -952,7 +952,7 @@ public function deletePageAction(): void
$this->deletePageFromDb($slugTree);

$allMenuItems = $selectedMenuItem = clone $this->get(self::DB_CONFIG, self::DB_MENU_ITEMS);
if (count(get_object_vars($allMenuItems)) === 1) {
if (count(get_object_vars($allMenuItems)) === 1 && count($slugTree) === 1) {
$this->alert('danger', 'Last page cannot be deleted - at least one page must exist.');
$this->redirect();
}
Expand Down Expand Up @@ -1056,7 +1056,7 @@ public function get()
$object = $this->db;

foreach ($args as $key => $arg) {
$object = $object->{$arg} ?? $this->set(...array_merge($args, [null]));
$object = $object->{$arg} ?? $this->set(...array_merge($args, [new stdClass]));
}

return $object;
Expand Down Expand Up @@ -1858,7 +1858,7 @@ public function orderMenuItem(int $content, string $menu): void
if (!in_array($content, [1, -1], true)) {
return;
}
$menuTree = $menu ? explode('-', $menu) : null;
$menuTree = explode('-', $menu);
$mainParentMenu = $selectedMenuKey = array_shift($menuTree);
$menuItems = $menuSelectionObject = clone $this->get(self::DB_CONFIG, self::DB_MENU_ITEMS);

Expand Down Expand Up @@ -2085,19 +2085,19 @@ public function saveAction(): void
if (isset($_POST['fieldname'], $_POST['content'], $_POST['target'], $_POST['token'])
&& $this->hashVerify($_POST['token'])) {
[$fieldname, $content, $target, $menu, $visibility] = $this->hook('save', $_POST['fieldname'],
$_POST['content'], $_POST['target'], $_POST['menu'], ($_POST['visibility'] ?? 'hide'));
if ($target === 'menuItemUpdate') {
$_POST['content'], $_POST['target'], $_POST['menu'] ?? null, ($_POST['visibility'] ?? 'hide'));
if ($target === 'menuItemUpdate' && $menu !== null) {
$this->updateMenuItem($content, $menu, $visibility);
$_SESSION['redirect_to_name'] = $content;
$_SESSION['redirect_to'] = $this->slugify($content);
}
if ($target === 'menuItemCreate') {
if ($target === 'menuItemCreate' && $menu !== null) {
$this->createMenuItem($content, $menu, $visibility, true);
}
if ($target === 'menuItemVsbl') {
if ($target === 'menuItemVsbl' && $menu !== null) {
$this->updateMenuItemVisibility($visibility, $menu);
}
if ($target === 'menuItemOrder') {
if ($target === 'menuItemOrder' && $menu !== null) {
$this->orderMenuItem($content, $menu);
}
if ($fieldname === 'defaultPage' && $this->getPageData($content) === null) {
Expand Down Expand Up @@ -2687,6 +2687,7 @@ public function uploadFileAction(): void
'htm',
'html',
'ico',
'jpeg',
'jpg',
'kdbx',
'm4a',
Expand Down Expand Up @@ -2782,9 +2783,10 @@ public static function url(string $location = ''): string
$showHttps = $securityCache['forceHttps'] ?? false;
}

$serverPort = ((($_SERVER['SERVER_PORT'] == '80') || ($_SERVER['SERVER_PORT'] == '443')) ? '' : ':' . $_SERVER['SERVER_PORT']);
return ($showHttps ? 'https' : 'http')
. '://' . ($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'])
. ((($_SERVER['SERVER_PORT'] == '80') || ($_SERVER['SERVER_PORT'] == '443')) ? '' : ':' . $_SERVER['SERVER_PORT'])
. ($_SERVER['HTTP_HOST'] ? '' : $serverPort)
. ((dirname($_SERVER['SCRIPT_NAME']) === '/') ? '' : dirname($_SERVER['SCRIPT_NAME']))
. '/' . $location;
}
Expand Down
2 changes: 1 addition & 1 deletion version
@@ -1 +1 @@
3.3.2
3.3.3

0 comments on commit bbfbf5c

Please sign in to comment.