option to hide post counters (home)

This commit is contained in:
Luana
2023-06-26 00:36:30 -03:00
committed by Shish
parent 8f70075c45
commit 4e6ca4d184
2 changed files with 16 additions and 9 deletions

View File

@ -26,6 +26,8 @@ class Home extends Extension
public function onSetupBuilding(SetupBuildingEvent $event) public function onSetupBuilding(SetupBuildingEvent $event)
{ {
$counters = []; $counters = [];
$counters["None"] = "none";
$counters["Text-only"] = "text-only";
foreach (glob("ext/home/counters/*") as $counter_dirname) { foreach (glob("ext/home/counters/*") as $counter_dirname) {
$name = str_replace("ext/home/counters/", "", $counter_dirname); $name = str_replace("ext/home/counters/", "", $counter_dirname);
$counters[ucfirst($name)] = $name; $counters[ucfirst($name)] = $name;
@ -50,16 +52,21 @@ class Home extends Extension
} }
$counter_dir = $config->get_string('home_counter', 'default'); $counter_dir = $config->get_string('home_counter', 'default');
$num_comma = "";
$counter_text = "";
if ($counter_dir != 'none') {
$total = Image::count_images(); $total = Image::count_images();
$strtotal = "$total";
$num_comma = number_format($total); $num_comma = number_format($total);
$counter_text = ""; if ($counter_dir != 'text-only') {
$strtotal = "$total";
$length = strlen($strtotal); $length = strlen($strtotal);
for ($n=0; $n<$length; $n++) { for ($n=0; $n<$length; $n++) {
$cur = $strtotal[$n]; $cur = $strtotal[$n];
$counter_text .= "<img alt='$cur' src='$base_href/ext/home/counters/$counter_dir/$cur.gif' />"; $counter_text .= "<img alt='$cur' src='$base_href/ext/home/counters/$counter_dir/$cur.gif' />";
} }
}
}
// get the homelinks and process them // get the homelinks and process them
if (strlen($config->get_string('home_links', '')) > 0) { if (strlen($config->get_string('home_links', '')) > 0) {

View File

@ -53,7 +53,7 @@ EOD
$counter_html $counter_html
<div class='space' id='foot'> <div class='space' id='foot'>
<small><small> <small><small>
$contact_link Serving $num_comma posts &ndash; $contact_link" . (empty($num_comma) ? "" : " Serving $num_comma posts &ndash;") . "
Running <a href='https://code.shishnet.org/shimmie2/'>Shimmie2</a> Running <a href='https://code.shishnet.org/shimmie2/'>Shimmie2</a>
</small></small> </small></small>
</div> </div>