Fisharebest\Webtrees\Functions\FunctionsPrintLists::surnameTagCloud PHP Метод

surnameTagCloud() публичный статический Метод

Print a tagcloud of surnames.
public static surnameTagCloud ( string[][] $surnames, string $script, boolean $totals, Fisharebest\Webtrees\Tree $tree ) : string
$surnames string[][] array (of SURN, of array of SPFX_SURN, of array of PID)
$script string indilist or famlist
$totals boolean show totals after each name
$tree Fisharebest\Webtrees\Tree generate links to this tree
Результат string
    public static function surnameTagCloud($surnames, $script, $totals, Tree $tree)
    {
        $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) {
                if ($maximum === $minimum) {
                    // All surnames occur the same number of times
                    $size = 150.0;
                } else {
                    $size = 75.0 + 125.0 * (count($indis) - $minimum) / ($maximum - $minimum);
                }
                $html .= '<a style="font-size:' . $size . '%" href="' . $script . '?surname=' . Filter::escapeUrl($surn) . '&amp;ged=' . $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 '<div class="tag_cloud">' . $html . '</div>';
    }

Usage Example

Пример #1
0
 /**
  * {@inhericDoc}
  * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
  */
 protected function renderContent()
 {
     /** @var \Fisharebest\Webtrees\Tree $tree */
     $tree = $this->data->get('tree');
     echo '<h2 class="center">', $this->data->get('title'), '</h2>';
     echo '<p class="center alpha_index">', implode(' | ', $this->getInitialLettersList()), '</p>';
     if ($this->data->get('issurnames', false)) {
         $surns = $this->data->get('surnameslist', array());
         $extra_params = array('mod' => Constants::MODULE_MAJ_PATROLIN_NAME, 'mod_action' => 'Lineage');
         // Show the surname list
         switch ($tree->getPreference('SURNAME_LIST_STYLE')) {
             case 'style1':
                 echo FunctionsPrintLists::surnameList($surns, 3, true, WT_SCRIPT_NAME, $tree, $extra_params);
                 break;
             case 'style3':
                 echo FunctionsPrintLists::surnameTagCloud($surns, WT_SCRIPT_NAME, true, $tree, $extra_params);
                 break;
             case 'style2':
             default:
                 echo FunctionsPrintLists::surnameTable($surns, WT_SCRIPT_NAME, $tree, $extra_params);
                 break;
         }
     } else {
         if ($this->data->get('islineages', false)) {
             //Link to indilist
             echo '<p class="center"><strong>' . '<a href="indilist.php?ged=' . $tree->getNameUrl() . '&surname=' . rawurlencode($this->data->get('surname')) . '">' . I18N::translate('Go to the list of individuals with surname %s', $this->data->get('legend')) . '</a></strong></p>';
             $lineages = $this->data->get('lineages', null);
             $nb_lineages = count($lineages);
             if (is_null($lineages) || $nb_lineages == 0) {
                 echo '<p class="center"><span class="warning">', I18N::translate('No individuals with surname %s has been found. Please try another name.', '<span dir="auto">' . $this->data->get('legend') . '</span>'), '</span></p>';
             } else {
                 echo '<div id="patronymiclineages">' . '<div class="list_label">', $this->data->get('table_title'), '</div>';
                 echo '<div class="list_value_wrap">';
                 foreach ($lineages as $i => $lineage) {
                     $this->printRootLineage($lineage);
                     if ($i < $nb_lineages - 1) {
                         echo '<hr />';
                     }
                 }
                 echo '</div>';
                 echo '<div class="list_label">', I18N::translate('%s lineages found', $nb_lineages), '</div>' . '</div>';
             }
         }
     }
 }
All Usage Examples Of Fisharebest\Webtrees\Functions\FunctionsPrintLists::surnameTagCloud