Enables NoWhereMan's statistics panel

Fixes #241 and enables NoWhereMan's statistics panel
This commit is contained in:
Fraenkiman 2023-05-07 15:23:40 +02:00
parent e779dcd348
commit af5c77e166
13 changed files with 348 additions and 195 deletions

View File

@ -24,7 +24,7 @@
'commedit' => false,
'delete' => false,
'cats' => true,
'stats' => false
'stats' => true
);
var $defaultaction = 'list';

View File

@ -16,7 +16,7 @@
class admin_entry_stats extends AdminPanelAction {
function format_number($num, $sep) {
$ss = $sep*$sep;
$ss = $sep * $sep;
$i = 0;
while ( $num > $ss ) {
$num = (float) $num / $sep;
@ -29,8 +29,8 @@
function setup() {
global $lang;
$lang['admin']['entry']['stats'] = array();
$this->smarty->assign('warnings', '[Dev Notice] Panel lang strings are currently hardcoded.');
$lang ['admin'] ['entry'] ['stats'] = array();
// $this->smarty->assign('warnings', '[Dev Notice] Panel lang strings are currently hardcoded.');
}
function main() {
@ -53,7 +53,7 @@
'topten' => array()
);
$entries['comments'] = 0;
$entries ['comments'] = 0;
$toplist = array();
@ -61,27 +61,25 @@
list($id, $e) = $q->getEntry();
$entries['count']++;
$entries['words'] += str_word_count($e['subject']) +
str_word_count($e['content']);
$entries ['count'] ++;
$entries ['words'] += str_word_count($e ['subject']) + str_word_count($e ['content']);
$entries['chars'] += strlen($e['subject']) +
strlen($e['content']);
$entries ['chars'] += strlen($e ['subject']) + strlen($e ['content']);
$entries['size'] += filesize(entry_exists($id));
$entries ['size'] += filesize(entry_exists($id));
$cc = $q->hasComments();
$entries['comments'] += $cc;
$toplist[$id] = $cc;
$toplistsubj[$id] = $e['subject'];
$entries ['comments'] += $cc;
$toplist [$id] = $cc;
$toplistsubj [$id] = $e ['subject'];
$comments['count']+= $cc;
$comments ['count'] += $cc;
while ($q->comments->hasMore()) {
list($cid, $c) = $q->comments->getComment();
$comments['words'] += str_word_count($c['content']);
$comments['chars'] += strlen($c['content']);
$comments['size'] += filesize(comment_exists($id, $cid));
$comments ['words'] += str_word_count($c ['content']);
$comments ['chars'] += strlen($c ['content']);
$comments ['size'] += filesize(comment_exists($id, $cid));
}
}
@ -89,12 +87,12 @@
arsort($toplist);
$i = 0;
foreach($toplist as $k=>$v) {
if ($i>=10 || $v < 1)
foreach($toplist as $k => $v) {
if ($i >= 10 || $v < 1)
break;
$entries['topten'][$k] = array(
'subject' => $toplistsubj[$k],
$entries ['topten'] [$k] = array(
'subject' => $toplistsubj [$k],
'comments' => $v
);
$i++;
@ -104,37 +102,37 @@
$binunit = array('Bytes', 'KiloBytes', 'MegaBytes', 'GigaBytes', 'TeraBytes', 'Many', 'ManyBytes');
list($count, $approx) = $this->format_number($entries['count'], 1000);
$entries['count'] = $count .' '. $decunit[$approx];
list($count, $approx) = $this->format_number($entries ['count'], 1000);
$entries ['count'] = $count . ' ' . $decunit [$approx];
list($count, $approx) = $this->format_number($entries['words'], 1000);
$entries['words'] = $count .' '. $decunit[$approx];
list($count, $approx) = $this->format_number($entries ['words'], 1000);
$entries ['words'] = $count . ' ' . $decunit [$approx];
list($count, $approx) = $this->format_number($entries['chars'], 1000);
$entries['chars'] = $count .' '. $decunit[$approx];
list($count, $approx) = $this->format_number($entries ['chars'], 1000);
$entries ['chars'] = $count . ' ' . $decunit [$approx];
list($count, $approx) = $this->format_number($entries['comments'], 1000);
$entries['comments'] = $count .' '. $decunit[$approx];
list($count, $approx) = $this->format_number($entries ['comments'], 1000);
$entries ['comments'] = $count . ' ' . $decunit [$approx];
list($count, $approx) = $this->format_number($entries['size'], 1024);
$entries['size'] = $count .' '. $binunit[$approx];
list($count, $approx) = $this->format_number($entries ['size'], 1024);
$entries ['size'] = $count . ' ' . $binunit [$approx];
$this->smarty->assign('entries', $entries);
list($count, $approx) = $this->format_number($comments['count'], 1000);
$comments['count'] = $count .' '. $decunit[$approx];
list($count, $approx) = $this->format_number($comments ['count'], 1000);
$comments ['count'] = $count . ' ' . $decunit [$approx];
list($count, $approx) = $this->format_number($comments['words'], 1000);
$comments['words'] = $count .' '. $decunit[$approx];
list($count, $approx) = $this->format_number($comments ['words'], 1000);
$comments ['words'] = $count . ' ' . $decunit [$approx];
list($count, $approx) = $this->format_number($comments['chars'], 1000);
$comments['chars'] = $count .' '. $decunit[$approx];
list($count, $approx) = $this->format_number($comments ['chars'], 1000);
$comments ['chars'] = $count . ' ' . $decunit [$approx];
list($count, $approx) = $this->format_number($comments['size'], 1024);
$comments['size'] = $count .' '. $binunit[$approx];
list($count, $approx) = $this->format_number($comments ['size'], 1024);
$comments ['size'] = $count . ' ' . $binunit [$approx];
$this->smarty->assign('comments', $comments);

View File

@ -1,29 +1,25 @@
<h2>{"Statistics"}</h2>
<h2>{$panelstrings.head}</h2>
{include file='shared:errorlist.tpl'}
{include file="shared:errorlist.tpl"}
<h3>{"Entries"}</h3>
{"<p>You have <strong>%s</strong>
entries using <strong>%s</strong> characters
in <strong>%s</strong> words.</p>
<p>Total disk space is
<strong>%s</strong>.</p>"|sprintf:$entries.count:$entries.chars:$entries.words:$entries.size}
<h3>{$panelstrings.entries}</h3>
<p>{$panelstrings.you_have} <strong>{"%s"|sprintf:$entries.count}</strong>
{$panelstrings.entries_using} <strong>{"%s"|sprintf:$entries.chars}</strong> {$panelstrings.characters_in} <strong>{"%s"|sprintf:$entries.words}</strong> {$panelstrings.words}.</p>
<p>{$panelstrings.total_disk_space_is} <strong>{"%s"|sprintf:$entries.size}</strong>.</p>
<h3>{"Comments"}</h3>
{"<p>You have <strong>%s</strong>
comments using <strong>%s</strong> characters
in <strong>%s</strong> words.</p>
<p>Total disk space is
<strong>%s</strong>.</p>"|sprintf:$comments.count:$comments.chars:$comments.words:$comments.size}
<h3>{$panelstrings.comments}</h3>
<p>{$panelstrings.you_have} <strong>{"%s"|sprintf:$comments.count}</strong>
{$panelstrings.comments_using} <strong>{"%s"|sprintf:$comments.chars}</strong> {$panelstrings.characters_in} <strong>{"%s"|sprintf:$comments.words}</strong> {$panelstrings.words}.</p>
<p>{$panelstrings.total_disk_space_is} <strong>{"%s"|sprintf:$comments.size}</strong>.</p>
{if $entries.topten}
<h3> {$entries.topten|@count} {"most commented entries"} </h3>
<h3>{$panelstrings.the} {$entries.topten|@count} {$panelstrings.most_commented_entries} </h3>
<ol>
{foreach from=$entries.topten key=id item=this_entry}
<li><a href="{$id|link:post_link}">{$this_entry.subject}</a> ({$this_entry.comments})</li>
<li><a href="{$panel_url|action_link:commentlist}&amp;entry={$id}">{$this_entry.subject}</a> ({$this_entry.comments})</li>
{/foreach}
</ol>

View File

@ -1,13 +1,14 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = array(
<?php
$lang ['admin'] ['entry'] ['submenu'] = array(
'list' => 'Spravovat příspěvky',
'write' => 'Přidat nový příspěvek',
'cats' => 'Spravovat kategorie'
);
'cats' => 'Manage Categories',
'stats' => 'Statistiky'
);
/* default action */
/* default action */
$lang ['admin'] ['entry'] ['list'] = array(
$lang ['admin'] ['entry'] ['list'] = array(
'head' => 'Správa příspěvků',
'descr' => 'Prosím vyberte příspěvek, který chcete upravit nebo <a href="admin.php?p=entry&amp;action=write">přidejte nový</a>' . '<br /><a href="admin.php?p=entry&amp;action=cats">Upravit kategorie</a>',
'filter' => 'Filtr: ',
@ -23,10 +24,10 @@
'act_del' => 'Smazat',
'act_view' => 'Zobrazit',
'act_edit' => 'Upravit'
);
);
/* write action */
$lang ['admin'] ['entry'] ['write'] = array(
/* write action */
$lang ['admin'] ['entry'] ['write'] = array(
'head' => 'Napsat příspěvek',
'descr' => 'Upravit formulář k napsání příspěvku',
'uploader' => 'Nahrát soubor(y)',
@ -45,32 +46,32 @@
'commmsg' => 'Správa komentářů tohoto příspěvku',
'delmsg' => 'Smazat tento příspěvek'
// 'back' => 'Back discarding changes',
);
);
$lang ['admin'] ['entry'] ['list'] ['msgs'] = array(
$lang ['admin'] ['entry'] ['list'] ['msgs'] = array(
1 => 'Příspěvek byl úspěšně uložený',
-1 => 'Při pokusu uložit příspěvek nastala chyba',
2 => 'Příspěvek byl úspěšně odstraněný',
-2 => 'Při pokusu smazat příspěvek nastala chyba'
);
);
$lang ['admin'] ['entry'] ['write'] ['error'] = array(
$lang ['admin'] ['entry'] ['write'] ['error'] = array(
'subject' => 'Memůžete odeslat pokud je předmět prázdný',
'content' => 'Memůžete odeslat prázdný příspěvek'
);
);
$lang ['admin'] ['entry'] ['write'] ['msgs'] = array(
$lang ['admin'] ['entry'] ['write'] ['msgs'] = array(
1 => 'Příspěvek byl úspěšně uložený',
-1 => 'Při pokuse uložit příspěvek nastala chyba',
-2 => 'Vyskytla se chyba: příspěvek nebyl uložený; index může být poškozen',
-3 => 'Vyskytla se chyba: příspěvek byl uložený jako návrh',
-4 => 'Vyskytla se chyba: příspěvek byl uložený jako návrh; index může být poškozen',
'draft' => 'Upravujete <strong>návrh</strong> příspěvku'
);
);
/* comments */
/* comments */
$lang ['admin'] ['entry'] ['commentlist'] = array(
$lang ['admin'] ['entry'] ['commentlist'] = array(
'head' => "Komentáře k přispěvkům ",
'descr' => 'Vybrat komentář na vymazání',
'sel' => 'Sel',
@ -84,14 +85,14 @@
'act_del' => 'Smazat',
'act_del_confirm' => 'Opravdu chceš smazat tento komentář?',
'nocomments' => 'Tento příspěvek ještě nebyl okomentovaný.'
);
);
$lang ['admin'] ['entry'] ['commentlist'] ['msgs'] = array(
$lang ['admin'] ['entry'] ['commentlist'] ['msgs'] = array(
1 => 'Komentář byl úspěšně odstraněný',
-1 => 'Při pokusu smazat příspěvek nastala chyba'
);
);
$lang ['admin'] ['entry'] ['commedit'] = array(
$lang ['admin'] ['entry'] ['commedit'] = array(
'head' => "Uprav komentář příspěvku",
'content' => 'Obsah',
'date' => 'Datum',
@ -101,16 +102,16 @@
'ip' => 'IP',
'loggedin' => 'Registrovaný užívatel',
'submit' => 'Ulož'
);
);
$lang ['admin'] ['entry'] ['commedit'] ['msgs'] = array(
$lang ['admin'] ['entry'] ['commedit'] ['msgs'] = array(
1 => 'Komentář byl upravený',
-1 => 'Nastala chyba při úpravě příspěvku'
);
);
/* delete action */
/* delete action */
$lang ['admin'] ['entry'] ['delete'] = array(
$lang ['admin'] ['entry'] ['delete'] = array(
'head' => 'Smazat příspěvek',
'descr' => 'Chystáte sa smazat tyto příspěvky:',
'preview' => 'Zobrazit',
@ -119,11 +120,11 @@
'ok' => 'Ano, smazat tento příspěvek',
'cancel' => 'Ne, zpět do Správy příspěvků',
'err' => 'Uvedená stránka neexistuje'
);
);
/* category mgmt */
/* category mgmt */
$lang ['admin'] ['entry'] ['cats'] = array(
$lang ['admin'] ['entry'] ['cats'] = array(
'head' => 'Upravit kategorie',
'descr' => '<p>Použijte formulář (dole) pro úpravu kategorií. </p><p>Každá kategorie by měla být v tomto formátu - "jméno kategorie: <em>id_number</em>". Položky odsazené pomlčkami tvoří hierarchii.</p>
@ -141,15 +142,29 @@ Různé :5
'fset1' => 'Úprava',
'fset2' => 'Použít změny',
'submit' => 'Uložit'
);
);
$lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
$lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
1 => 'Kategorie byli úspěšně uložené',
-1 => 'Při pokusu uložit kategorie nastala chyba',
2 => 'Kategorie byly smazané',
-2 => 'Při pokusu smazat kategorie nastala chyba.',
-3 => 'ID kategorií musí být KLADNÉ!!'
);
);
?>
/* stats */
$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistiky',
'entries' => 'Záznamy',
'you_have' => 'Máte',
'entries_using' => 'záznamů s',
'characters_in' => 'znaky v',
'words' => 'slovech',
'total_disk_space_is' => 'Celkový prostor v paměti je',
'comments' => 'Komentáře',
'comments_using' => 'komentářů s',
'the' => '',
'most_commented_entries' => 'nejkomentovanější příspěvky'
);
?>

View File

@ -2,7 +2,8 @@
$lang ['admin'] ['entry'] ['submenu'] = array(
'list' => 'Beiträge verwalten',
'write' => 'Beitrag schreiben',
'cats' => 'Kategorien verwalten'
'cats' => 'Kategorien verwalten',
'stats' => 'Statiskiken'
);
/* default action */
@ -152,4 +153,19 @@ $lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
-3 => 'Die Kategorie ID <strong>muss größer als 0 sein</strong>. Der Wert <strong>0</strong> ist nicht erlaubt.'
);
/* stats */
$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistiken',
'entries' => 'Beiträge',
'you_have' => 'Du hast',
'entries_using' => 'Beiträge mit',
'characters_in' => 'Zeichen in',
'words' => 'Wörtern',
'total_disk_space_is' => 'Der gesamte Speicherplatz beträgt',
'comments' => 'Kommentare',
'comments_using' => 'Kommentare mit',
'the' => 'Die',
'most_commented_entries' => 'meist kommentierten Beiträge'
);
?>

View File

@ -2,7 +2,8 @@
$lang ['admin'] ['entry'] ['submenu'] = array(
'list' => 'Διαχείριση καταχωρήσεων',
'write' => 'Δημιουργία καταχώρησης',
'cats' => 'Διαχείριση κατηγοριών'
'cats' => 'Διαχείριση κατηγοριών',
'stats' => 'Στατιστική'
);
/* default action */
@ -155,4 +156,19 @@ $lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
-3 => 'Τα IDs των κατηγοριών πρέπει να είναι οπωσδήποτε θετικά (το 0 δεν επιτρέπεται)'
);
/* stats */
$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Στατιστική',
'entries' => 'Ενδείξεις',
'you_have' => 'Έχετε',
'entries_using' => 'καταχωρήσεις με',
'characters_in' => 'χαρακτήρες',
'words' => 'λέξεις',
'total_disk_space_is' => 'Ο συνολικός χώρος αποθήκευσης είναι',
'comments' => 'Σχόλια',
'comments_using' => 'σχόλια με',
'the' => 'Οι',
'most_commented_entries' => 'πιο σχολιασμένες αναρτήσεις'
);
?>

View File

@ -2,7 +2,8 @@
$lang ['admin'] ['entry'] ['submenu'] = array(
'list' => 'Manage Entries',
'write' => 'Write Entry',
'cats' => 'Manage Categories'
'cats' => 'Manage Categories',
'stats' => 'Stats'
);
/* default action */
@ -155,4 +156,19 @@ $lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
-3 => 'Category IDs must be strictly positive (0 is not allowed)'
);
/* stats */
$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Stats',
'entries' => 'Entries',
'you_have' => 'You have',
'entries_using' => 'entries using',
'characters_in' => 'characters in',
'words' => 'words',
'total_disk_space_is' => 'Total disk space is',
'comments' => 'Comments',
'comments_using' => 'comments using',
'the' => 'The',
'most_commented_entries' => 'most commented entries'
);
?>

View File

@ -2,7 +2,8 @@
$lang ['admin'] ['entry'] ['submenu'] = array(
'list' => 'Administrar entradas',
'write' => 'Escribir entrada',
'cats' => 'Administrar Categorías'
'cats' => 'Administrar Categorías',
'stats' => 'Estadísticas'
);
/* default action */
@ -155,4 +156,19 @@ $lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
-3 => 'Los ID de categoría deben ser estrictamente positivos (0 is not allowed)'
);
/* stats */
$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Estadísticas',
'entries' => 'Entradas',
'you_have' => 'Tiene',
'entries_using' => 'entradas con',
'characters_in' => 'caracteres en',
'words' => 'palabras',
'total_disk_space_is' => 'El espacio de almacenamiento total es de',
'comments' => 'Comentarios',
'comments_using' => 'comentarios con',
'the' => 'Las',
'most_commented_entries' => 'entradas más comentadas'
);
?>

View File

@ -2,7 +2,8 @@
$lang ['admin'] ['entry'] ['submenu'] = array(
'list' => 'G&eacute;rer les billets',
'write' => '&Eacute;crire un billet',
'cats' => 'G&eacute;rer les cat&eacute;gories'
'cats' => 'G&eacute;rer les cat&eacute;gories',
'stats' => 'Statistiques'
);
/* action par défaut */
@ -152,4 +153,19 @@ $lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
-3 => 'Le num&eacute;ro de cat&eacute;gorie doit &ecirc;tre positif (0 pas permis)'
);
/* stats */
$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistiques',
'entries' => 'Entrées',
'you_have' => 'Tu as',
'entries_using' => 'entrées avec',
'characters_in' => 'caractères dans',
'words' => 'mots',
'total_disk_space_is' => 'L\'espace mémoire total est de',
'comments' => 'Commentaires',
'comments_using' => 'commentaires avec',
'the' => 'Les',
'most_commented_entries' => 'entrées les plus commentées'
);
?>

View File

@ -2,7 +2,8 @@
$lang ['admin'] ['entry'] ['submenu'] = array(
'list' => 'Gestione Articoli',
'write' => 'Scrivi Articolo',
'cats' => 'Gestione Categorie'
'cats' => 'Gestione Categorie',
'stats' => 'Statistica'
);
/* default action */
@ -155,4 +156,19 @@ $lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
-3 => 'Gli ID delle categorie devono essere assolutamente positivi (lo 0 non è consentito)'
);
/* stats */
$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistica',
'entries' => 'Entrate',
'you_have' => 'Hai',
'entries_using' => 'voci con',
'characters_in' => 'caratteri in',
'words' => 'parole',
'total_disk_space_is' => 'Lo spazio di archiviazione totale è di',
'comments' => 'Commenti',
'comments_using' => 'commenti con',
'the' => 'Le',
'most_commented_entries' => 'voci più commentate'
);
?>

View File

@ -2,7 +2,8 @@
$lang ['admin'] ['entry'] ['submenu'] = array(
'list' => '記事の管理',
'write' => '記事の作成',
'cats' => '記事カテゴリの管理'
'cats' => '記事カテゴリの管理',
'stats' => '統計情報'
);
/* default action */
@ -152,4 +153,19 @@ $lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
-3 => 'Category IDs must be strictly positive (0 is not allowed)'
);
/* stats */
$lang ['admin'] ['entry'] ['stats'] = array(
'head' => '統計情報',
'entries' => 'エントリー',
'you_have' => '',
'entries_using' => '件、',
'characters_in' => '文字、',
'words' => '語。',
'total_disk_space_is' => '総収納容量は',
'comments' => 'コメント',
'comments_using' => '件',
'the' => 'コメント数が多かった',
'most_commented_entries' => '作品'
);
?>

View File

@ -2,7 +2,8 @@
$lang ['admin'] ['entry'] ['submenu'] = array(
'list' => 'Vermeldingen beheren',
'write' => 'Schrijf vermelding',
'cats' => 'Categorie beheren'
'cats' => 'Categorie beheren',
'stats' => 'Statistieken'
);
/* default action */
@ -155,4 +156,19 @@ $lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
-3 => 'Categorie ID moeten strikt positief zijn (0 is niet toegestaan)'
);
/* stats */
$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistieken',
'entries' => 'Vermeldingen',
'you_have' => 'Je hebt',
'entries_using' => 'berichten met',
'characters_in' => 'tekens in',
'words' => 'woorden',
'total_disk_space_is' => 'De totale opslagruimte is',
'comments' => 'Reacties',
'comments_using' => 'reacties met',
'the' => 'De',
'most_commented_entries' => 'meest becommentarieerde inzendingen'
);
?>

View File

@ -3,7 +3,8 @@
$lang ['admin'] ['entry'] ['submenu'] = array(
'list' => 'Lista de posts',
'write' => 'Criar um post',
'cats' => 'Administrar as categorias'
'cats' => 'Administrar as categorias',
'stats' => 'Estatísticas'
);
/* default action */
@ -153,4 +154,19 @@ $lang ['admin'] ['entry'] ['cats'] ['msgs'] = array(
-3 => 'Os IDs da categoria devem ser apenas positivos. (0 não é permitido.)'
);
/* stats */
$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Estatísticas',
'entries' => 'Entradas',
'you_have' => 'Você tem',
'entries_using' => 'entradas com',
'characters_in' => 'caracteres em',
'words' => 'palavras',
'total_disk_space_is' => 'O espaço total de armazenamento é de',
'comments' => 'Comentários',
'comments_using' => 'comentários com',
'the' => 'As',
'most_commented_entries' => 'entradas mais comentadas'
);
?>