@@ -519,46 +519,46 @@ public function getItemCount($tag_id, $modid = 0, $catid = 0)
519519 * @param int $font_min
520520 * @return array tag data values for display
521521 */
522- // public function getTagData($tags_array, $font_max = 0, $font_min = 0)
523- // {
524- // $tags_data_array = [];
525- // if (\is_array($tags_array) && !empty($tags_array)) {
526- // // set min and max tag count
527- // $count_array = \array_column($tags_array, 'count', 'id');
528- // $count_min = \count($count_array) > 0 ? \min($count_array) : 0;
529- // $count_min = $count_min > 0 ? $count_min : 0;
530- // $count_max = \count($count_array) > 0 ? \max($count_array) : 0;
531- // $count_max = $count_max > 0 ? $count_max : 0;
532- // if ($count_max > 0) {
533- // $term_array = \array_column($tags_array, 'term', 'id');
534- // $tags_term_array = \array_map('\mb_strtolower', $term_array);
535- // \array_multisort($tags_term_array, \SORT_ASC, $tags_array);
536- // $count_interval = $count_max - $count_min;
537- // $level_limit = 5;
538- //
539- // $font_ratio = $count_interval ? ($font_max - $font_min) / $count_interval : 1;
540- //
541- // foreach ($tags_array as $tag) {
542- // /*
543- // * Font-size = ((tag.count - count.min) * (font.max - font.min) / (count.max - count.min) ) * 100%
544- // */
545- // $font_sz = \floor(($tag['count'] - $count_min) * $font_ratio) + $font_min;
546- // $level_sz = \floor(($tag['count'] - $count_min) * $level_limit / $count_max);
547- // $tags_data_array[] = [
548- // 'id' => $tag['id'],
549- // 'font' => empty($count_interval) ? 100 : (int)$font_sz,
550- // 'level' => empty($count_max) ? 0 : (int)$level_sz,
551- // 'term' => \urlencode($tag['term']),
552- // 'title' => \htmlspecialchars($tag['term'], \ENT_QUOTES | \ENT_HTML5),
553- // 'count' => $tag['count'],
554- // ];
555- // }
556- // }
557- // }
558- //
559- //
560- // return $tags_data_array;
561- // }
522+ public function getTagData ($ tags_array , $ font_max = 0 , $ font_min = 0 )
523+ {
524+ $ tags_data_array = [];
525+ if (\is_array ($ tags_array ) && !empty ($ tags_array )) {
526+ // set min and max tag count
527+ $ count_array = \array_column ($ tags_array , 'count ' , 'id ' );
528+ $ count_min = \count ($ count_array ) > 0 ? \min ($ count_array ) : 0 ;
529+ $ count_min = $ count_min > 0 ? $ count_min : 0 ;
530+ $ count_max = \count ($ count_array ) > 0 ? \max ($ count_array ) : 0 ;
531+ $ count_max = $ count_max > 0 ? $ count_max : 0 ;
532+ if ($ count_max > 0 ) {
533+ $ term_array = \array_column ($ tags_array , 'term ' , 'id ' );
534+ $ tags_term_array = \array_map ('\mb_strtolower ' , $ term_array );
535+ \array_multisort ($ tags_term_array , \SORT_ASC , $ tags_array );
536+ $ count_interval = $ count_max - $ count_min ;
537+ $ level_limit = 5 ;
538+
539+ $ font_ratio = $ count_interval ? ($ font_max - $ font_min ) / $ count_interval : 1 ;
540+
541+ foreach ($ tags_array as $ tag ) {
542+ /*
543+ * Font-size = ((tag.count - count.min) * (font.max - font.min) / (count.max - count.min) ) * 100%
544+ */
545+ $ font_sz = \floor (($ tag ['count ' ] - $ count_min ) * $ font_ratio ) + $ font_min ;
546+ $ level_sz = \floor (($ tag ['count ' ] - $ count_min ) * $ level_limit / $ count_max );
547+ $ tags_data_array [] = [
548+ 'id ' => $ tag ['id ' ],
549+ 'font ' => empty ($ count_interval ) ? 100 : (int )$ font_sz ,
550+ 'level ' => empty ($ count_max ) ? 0 : (int )$ level_sz ,
551+ 'term ' => \urlencode ($ tag ['term ' ]),
552+ 'title ' => \htmlspecialchars ($ tag ['term ' ], \ENT_QUOTES | \ENT_HTML5 ),
553+ 'count ' => $ tag ['count ' ],
554+ ];
555+ }
556+ }
557+ }
558+
559+
560+ return $ tags_data_array ;
561+ }
562562
563563 /**
564564 * Delete an object as well as links relying on it
0 commit comments