A replacement for the InfoHandler


This is a drop-in replacement for the InfoHandler.

The Code


First things first, go to the BarGraph action and follow the installation instructions.

When the BarGraph action is running without a hitch, save the following code as actions/pagestats.php --

<?php

require_once('3rdparty/plugins/bar_graph.php');

if ($this->HasAccess('read'))
{
    $prefix = $this->config['table_prefix'];

    $sql = "(SELECT 'total_referrers', count(*) FROM {$prefix}referrers) UNION
    (SELECT 'page_referrers', count(*) FROM {$prefix}referrers WHERE page_tag = '$this->tag') UNION
    (SELECT 'total_comments', count(*) FROM {$prefix}comments) UNION
    (SELECT 'page_comments', count(*) FROM {$prefix}comments WHERE page_tag = '$this->tag') UNION
    (SELECT 'total_backlinks', count(*) FROM {$prefix}links) UNION
    (SELECT 'page_backlinks', count(*) FROM {$prefix}links WHERE to_tag = '$this->tag') UNION
    (SELECT 'total_revisions', count(*) FROM {$prefix}pages) UNION
    (SELECT 'page_revisions', count(*) FROM {$prefix}pages WHERE tag = '$this->tag')"
;

    $results = mysql_query($sql);
    if (mysql_num_rows($results))
    {
        while ($row = mysql_fetch_row($results)) $stats[$row[0]] = $row[1];
    }

    $authors = $this->LoadAll("SELECT user, COUNT(*) AS edits FROM {$prefix}pages WHERE tag = '$this->tag' GROUP  BY user ORDER BY edits DESC, user ASC");
    if ($authors)
    {
        $graph =& new bar_graph('Revisions by Author');
        $graph->total = $stats['page_revisions'];
        foreach($authors as $author) $graph->add($author['user'], $author['edits']);
        $graph->show();
    }

    echo '<p>&nbsp;</p>';

    $graph =& new bar_graph('Global Statistics');
    foreach (array('revisions', 'comments', 'backlinks', 'referrers') as $index)
    {
        if (isset($stats["page_$index"]) && isset($stats["total_$index"]))
        {
            $graph->add(ucwords($index), $stats["page_$index"] . '/' . $stats["total_$index"]);
        }
    }
    $graph->show();
}

?>


The Example


{{pagestats}}


The Screenshot


 (image: http://bytebrite.com/img/psss.gif)

Authors


DennyShimkoski


CategoryUserContributions
There are 2 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki