Skip to content

Commit

Permalink
Fix #1508, #1497 - non-ajax blocks need global data too
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed Nov 22, 2017
1 parent f45af9a commit c02d957
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 13 additions & 1 deletion app/Controller/HomePageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions app/Module/HtmlBlockModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 .= '<br>' . FunctionsDate::formatTimestamp($this->getBlockSetting($block_id, 'timestamp', WT_TIMESTAMP) + WT_TIMESTAMP_OFFSET);
}

Expand Down

0 comments on commit c02d957

Please sign in to comment.