diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-04-26 16:32:47 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-04-26 16:32:47 +0100 |
| commit | 88354833d0ae973d835828f667779492727ac05e (patch) | |
| tree | 67725b2bc4e8c7d89df8327b10b09c83804d73ea | |
| parent | 0b1cb8210b4f7bf37a2c36b0026d12b66e79a6e3 (diff) | |
| download | webtrees-88354833d0ae973d835828f667779492727ac05e.tar.gz webtrees-88354833d0ae973d835828f667779492727ac05e.tar.bz2 webtrees-88354833d0ae973d835828f667779492727ac05e.zip | |
Replace Zend_Tag_Cloud
| -rw-r--r-- | app/Module/TopSurnamesModule.php | 4 | ||||
| -rw-r--r-- | famlist.php | 4 | ||||
| -rw-r--r-- | includes/functions/functions_print_lists.php | 68 | ||||
| -rw-r--r-- | 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 .= '<tr>'; @@ -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)', '<span dir="auto">' . $spfxsurn . '</span>', 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 .= '<a style="font-size:' . $size . '%" href="' . $script . '?'; + if ($surn) { + $html .= 'surname=' . urlencode($surn) . '&ged=' . $tree->getNameUrl(); + } else { + $html .= '?alpha=,&ged=' . $WT_TREE->getNameUrl(); + } + if ($totals) { + $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $spfxsurn . '</span>', I18N::number(count($indis))); + } else { + $html .= $spfxsurn; + } + $html .= '</a> '; } } - return (string) $cloud; + return '<div class="tag_cloud">' . $html . '</div>'; } /** 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 { |
