Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outsourcing of the fixed statistics panel in a plugin #373

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.cs-cz.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Statistiky';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Statistiky';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistiky',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.da-dk.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Statistik';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Statistik';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistik',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.de-de.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Statistiken';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Statistiken';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistiken',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.el-gr.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Στατιστική';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Στατιστική';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Στατιστική',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.en-us.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Stats';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Stats';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Stats',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.es-es.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Estadísticas';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Estadísticas';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Estadísticas',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.fr-fr.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Statistiques';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Statistiques';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistiques',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.it-it.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Statistiche';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Statistiche';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistiche',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.ja-jp.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = '統計情報';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = '統計情報';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => '統計情報',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.nl-nl.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Statistieken';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Statistieken';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistieken',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.pt-br.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Estatísticas';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Estatísticas';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Estatísticas',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.ru-ru.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Статистика';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Статистика';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Статистика',
Expand Down
2 changes: 1 addition & 1 deletion fp-plugins/stats/lang/lang.sl-si.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$lang ['admin'] ['entry'] ['submenu'] = 'Statistika';
$lang ['admin'] ['entry'] ['submenu'] ['stats'] = 'Statistika';

$lang ['admin'] ['entry'] ['stats'] = array(
'head' => 'Statistika',
Expand Down
23 changes: 9 additions & 14 deletions fp-plugins/stats/plugin.stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@
* Author: FlatPress
* Author URI: https://flatpress.org
*/
require_once ABS_PATH . 'defaults.php';
require_once INCLUDES_DIR . 'includes.php';

if (class_exists('AdminPanelAction')) {


class admin_entry_stats extends AdminPanelAction {

var $lang = 'plugin:stats';


function format_number($num, $sep) {
$ss = $sep * $sep;
$i = 0;
Expand All @@ -34,22 +30,21 @@ function setup() {
global $lang;

$lang = lang_load('plugin:stats');
$lang ['admin'] ['entry'] ['stats'] = array();
$this->smarty->assign('admin_resource', 'plugin:stats/admin.plugin.stats');
}

function main() {

global $fpdb;
global $fpdb, $lang;
$lang = lang_load('plugin:stats');

$fpdb->query(array(
'count' => -1, // show all
'fullparse' => true
));

$q = $fpdb->getQuery();

$comments =
$entries = array(
'count' => 0,
Expand All @@ -58,15 +53,15 @@ function main() {
'size' => 0,
'topten' => array()
);

$entries ['comments'] = 0;

$toplist = array();

while ($q->hasMore()) {

list($id, $e) = $q->getEntry();

$entries ['count'] ++;
$entries ['words'] += str_word_count($e ['subject']) + str_word_count($e ['content']);

Expand Down