From d7952a34bc82db471ebc960cb25a37234ddd3514 Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Mon, 4 Mar 2019 11:48:20 +0000 Subject: Unique stacks should be an opt-in feature --- app/View.php | 39 ++++++++++++++++++++-- resources/views/statistics/other/chart-setup.phtml | 4 +-- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/app/View.php b/app/View.php index 7dcc6554f0..58952708ec 100644 --- a/app/View.php +++ b/app/View.php @@ -18,8 +18,15 @@ declare(strict_types=1); namespace Fisharebest\Webtrees; use Exception; -use function ob_end_clean; use Throwable; +use function array_filter; +use function extract; +use function implode; +use function is_dir; +use function is_file; +use function ob_end_clean; +use function ob_start; +use function sha1; /** * Simple view/template class. @@ -94,6 +101,7 @@ class View public static function push(string $stack) { self::$stack = $stack; + ob_start(); } @@ -105,9 +113,34 @@ class View public static function endpush() { $content = ob_get_clean(); - $hash = sha1($content); - self::$stacks[self::$stack][$hash] = $content; + self::$stacks[self::$stack][] = $content; + } + + /** + * Variant of push that will only add one copy of each item. + * + * @param string $stack + * + * @return void + */ + public static function pushunique(string $stack) + { + self::$stack = $stack; + + ob_start(); + } + + /** + * Variant of push that will only add one copy of each item. + * + * @return void + */ + public static function endpushunique() + { + $content = ob_get_clean(); + + self::$stacks[self::$stack][sha1($content)] = $content; } /** diff --git a/resources/views/statistics/other/chart-setup.phtml b/resources/views/statistics/other/chart-setup.phtml index 694fc2da9e..10cc361b89 100644 --- a/resources/views/statistics/other/chart-setup.phtml +++ b/resources/views/statistics/other/chart-setup.phtml @@ -4,7 +4,7 @@ declare(strict_types=1); use Fisharebest\Webtrees\View; ?> - + - + -- cgit v1.3