From c02d9576af30631e93950bbc8980d08ca988203d Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Wed, 22 Nov 2017 15:08:10 +0000 Subject: [PATCH] Fix #1508, #1497 - non-ajax blocks need global data too --- app/Controller/HomePageController.php | 14 +++++++++++++- app/Module/HtmlBlockModule.php | 6 +++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/Controller/HomePageController.php b/app/Controller/HomePageController.php index a7c42c85167..d594a86c54b 100644 --- a/app/Controller/HomePageController.php +++ b/app/Controller/HomePageController.php @@ -51,6 +51,12 @@ public function treePage(Request $request): Response { $side_blocks = $this->getBlocksForTreePage($tree_id, $access_level, 'side'); $title = Html::escape($tree->getTitle()); + // @TODO - ModuleBlockInterface::getBlock() currently relies on these globals + global $WT_TREE, $ctype, $controller; + $WT_TREE = $tree; + $ctype = 'gedcom'; + $controller = $this; + return $this->viewResponse('tree-page', [ 'main_blocks' => $main_blocks, 'side_blocks' => $side_blocks, @@ -214,6 +220,12 @@ public function userPage(Request $request) { $side_blocks = $this->getBlocksForUserPage($tree_id, $user_id, $access_level, 'side'); $title = I18N::translate('My page'); + // @TODO - ModuleBlockInterface::getBlock() currently relies on these globals + global $WT_TREE, $ctype, $controller; + $WT_TREE = $tree; + $ctype = 'user'; + $controller = $this; + return $this->viewResponse('user-page', [ 'main_blocks' => $main_blocks, 'side_blocks' => $side_blocks, @@ -254,7 +266,7 @@ public function userPageBlock(Request $request): Response { // @TODO - ModuleBlockInterface::getBlock() relies on these globals :-( global $WT_TREE, $ctype, $controller; $WT_TREE = $tree; - $ctype = 'gedcom'; + $ctype = 'user'; $controller = $this; $html = $module->getBlock($block_id, true); diff --git a/app/Module/HtmlBlockModule.php b/app/Module/HtmlBlockModule.php index ade04049b68..4c97114f12c 100644 --- a/app/Module/HtmlBlockModule.php +++ b/app/Module/HtmlBlockModule.php @@ -55,8 +55,8 @@ public function getDescription() { public function getBlock($block_id, $template = true, $cfg = []) { global $ctype, $WT_TREE; - $title = $this->getBlockSetting($block_id, 'title'); - $content = $this->getBlockSetting($block_id, 'html'); + $title = $this->getBlockSetting($block_id, 'title', ''); + $content = $this->getBlockSetting($block_id, 'html', ''); $gedcom = $this->getBlockSetting($block_id, 'gedcom'); $show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0'); $languages = $this->getBlockSetting($block_id, 'languages'); @@ -97,7 +97,7 @@ public function getBlock($block_id, $template = true, $cfg = []) { $title = $stats->embedTags($title); $content = $stats->embedTags($content); - if ($show_timestamp) { + if ($show_timestamp === '1') { $content .= '
' . FunctionsDate::formatTimestamp($this->getBlockSetting($block_id, 'timestamp', WT_TIMESTAMP) + WT_TIMESTAMP_OFFSET); }