From 88354833d0ae973d835828f667779492727ac05e Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Sun, 26 Apr 2015 16:32:47 +0100 Subject: Replace Zend_Tag_Cloud --- app/Module/TopSurnamesModule.php | 4 +- famlist.php | 4 +- includes/functions/functions_print_lists.php | 68 +++++++++++++--------------- indilist.php | 4 +- 4 files changed, 37 insertions(+), 43 deletions(-) diff --git a/app/Module/TopSurnamesModule.php b/app/Module/TopSurnamesModule.php index d0ddd39e03..2b284c49fc 100644 --- a/app/Module/TopSurnamesModule.php +++ b/app/Module/TopSurnamesModule.php @@ -90,7 +90,7 @@ class TopSurnamesModule extends AbstractModule implements ModuleBlockInterface { switch ($infoStyle) { case 'tagcloud': uksort($all_surnames, __NAMESPACE__ . '\I18N::strcasecmp'); - $content = format_surname_tagcloud($all_surnames, 'indilist.php', true); + $content = format_surname_tagcloud($all_surnames, 'indilist.php', true, $WT_TREE); break; case 'list': uasort($all_surnames, __NAMESPACE__ . '\\TopSurnamesModule::surnameCountSort'); @@ -103,7 +103,7 @@ class TopSurnamesModule extends AbstractModule implements ModuleBlockInterface { case 'table': default: uasort($all_surnames, __NAMESPACE__ . '\\TopSurnamesModule::surnameCountSort'); - $content = format_surname_table($all_surnames, 'indilist.php'); + $content = format_surname_table($all_surnames, 'indilist.php', $WT_TREE); break; } diff --git a/famlist.php b/famlist.php index 65aaf2a7f9..7aee193266 100644 --- a/famlist.php +++ b/famlist.php @@ -192,11 +192,11 @@ if ($show === 'indi' || $show === 'surn') { echo format_surname_list($surns, 3, true, WT_SCRIPT_NAME, $WT_TREE); break; case 'style3': - echo format_surname_tagcloud($surns, WT_SCRIPT_NAME, true); + echo format_surname_tagcloud($surns, WT_SCRIPT_NAME, true, $WT_TREE); break; case 'style2': default: - echo format_surname_table($surns, WT_SCRIPT_NAME); + echo format_surname_table($surns, WT_SCRIPT_NAME, $WT_TREE); break; } } else { diff --git a/includes/functions/functions_print_lists.php b/includes/functions/functions_print_lists.php index 723c72568a..d97f196ba1 100644 --- a/includes/functions/functions_print_lists.php +++ b/includes/functions/functions_print_lists.php @@ -1493,11 +1493,12 @@ function format_media_table($media_objects) { * * @param string[][] $surnames array (of SURN, of array of SPFX_SURN, of array of PID) * @param string $script "indilist.php" (counts of individuals) or "famlist.php" (counts of spouses) + * @param Tree $tree generate links for this tree * * @return string */ -function format_surname_table($surnames, $script) { - global $controller, $WT_TREE; +function format_surname_table($surnames, $script, Tree $tree) { + global $controller; $html = ''; $controller @@ -1538,9 +1539,9 @@ function format_surname_table($surnames, $script) { foreach ($surnames as $surn => $surns) { // Each surname links back to the indi/fam surname list if ($surn) { - $url = $script . '?surname=' . rawurlencode($surn) . '&ged=' . $WT_TREE->getNameUrl(); + $url = $script . '?surname=' . rawurlencode($surn) . '&ged=' . $tree->getNameUrl(); } else { - $url = $script . '?alpha=,&ged=' . $WT_TREE->getNameUrl(); + $url = $script . '?alpha=,&ged=' . $tree->getNameUrl(); } // Row counter $html .= ''; @@ -1584,49 +1585,42 @@ function format_surname_table($surnames, $script) { * @param string[][] $surnames array (of SURN, of array of SPFX_SURN, of array of PID) * @param string $script indilist or famlist * @param boolean $totals show totals after each name + * @param Tree $tree generate links to this tree * * @return string */ -function format_surname_tagcloud($surnames, $script, $totals) { +function format_surname_tagcloud($surnames, $script, $totals, Tree $tree) { global $WT_TREE; - $cloud = new Zend_Tag_Cloud( - array( - 'tagDecorator' => array( - 'decorator' => 'HtmlTag', - 'options' => array( - 'htmlTags' => array(), - 'fontSizeUnit' => '%', - 'minFontSize' => 80, - 'maxFontSize' => 250 - ) - ), - 'cloudDecorator' => array( - 'decorator' => 'HtmlCloud', - 'options' => array( - 'htmlTags' => array( - 'div' => array( - 'class' => 'tag_cloud' - ) - ) - ) - ) - ) - ); + $minimum = PHP_INT_MAX; + $maximum = 1; + foreach ($surnames as $surn => $surns) { + foreach ($surns as $spfxsurn => $indis) { + $maximum = max($maximum, count($indis)); + $minimum = min($minimum, count($indis)); + } + } + + $html = ''; foreach ($surnames as $surn => $surns) { foreach ($surns as $spfxsurn => $indis) { - $cloud->appendTag(array( - 'title' => $totals ? I18N::translate('%1$s (%2$s)', '' . $spfxsurn . '', I18N::number(count($indis))) : $spfxsurn, - 'weight' => count($indis), - 'params' => array( - 'url' => $surn ? - $script . '?surname=' . urlencode($surn) . '&ged=' . $WT_TREE->getNameUrl() : $script . '?alpha=,&ged=' . $WT_TREE->getNameUrl() - ) - )); + $size = 75.0 + 125.0 * (count($indis) - $minimum) / ($maximum - $minimum); + $html .= '' . $spfxsurn . '', I18N::number(count($indis))); + } else { + $html .= $spfxsurn; + } + $html .= ' '; } } - return (string) $cloud; + return '
' . $html . '
'; } /** diff --git a/indilist.php b/indilist.php index 426902d48b..089fd4cef3 100644 --- a/indilist.php +++ b/indilist.php @@ -192,11 +192,11 @@ if ($show === 'indi' || $show === 'surn') { echo format_surname_list($surns, 3, true, WT_SCRIPT_NAME, $WT_TREE); break; case 'style3': - echo format_surname_tagcloud($surns, WT_SCRIPT_NAME, true); + echo format_surname_tagcloud($surns, WT_SCRIPT_NAME, true, $WT_TREE); break; case 'style2': default: - echo format_surname_table($surns, WT_SCRIPT_NAME); + echo format_surname_table($surns, WT_SCRIPT_NAME, $WT_TREE); break; } } else { -- cgit v1.3