=====Info Handler=====
This is the development page for the ##**info**## handler.
The ##info## handler displays information and statistics about the current page.
>>**See also:**
~-UnderDevelopment
~-WikkaBetaFeatures
~-PageAdminAction
~-PageStatsAction
**Note:** The ##info## handler is installed on this server as a beta feature.
>><<**Table of Contents:**
~-""Usage""
~-""Sample output""
~-""Current version""
~-""Change log""
~-""The code""
~-""Styling""<<
::c::
=== Usage ===
Append ##[[http://wikka.jsnx.com/HomePage/info | /info]]## to the URL of the page or click on "Stats" in the page footer.
----
==Sample output==
""
Format('=== '.sprintf(PAGE_TITLE,'[['.$this->tag.']]').' ===');
// 1. check source page existence
if (!$this->page)
{
// source page does not exist!
$box = ERROR_PAGE_NOT_EXISTING;
}
else
{
$tag = $this->page['tag'];
// 2. page exists - now check user's read-access to the source page
if (!$this->HasAccess('read'))
{
// user can't read source page!
$box = ERROR_NO_ACCESS;
} else
{
// page exists and user has read-access to the source - proceed
// --- Authors ---
$authors = $this->LoadAll('SELECT user, COUNT(*) AS edits FROM '.$this->config['table_prefix'].'pages WHERE `tag` = "'.$tag.'" GROUP BY user ORDER BY edits DESC, user ASC');
$totaledits = $this->getCount('pages', '`tag` = "'.$tag.'"');
$output .= $this->Format('=='.HEADING_AUTHORS.'==');
if ($authors)
{
$output .= "
\n\n\n".TABLE_AUTHORS_HEADING_USER." | \n".TABLE_AUTHORS_HEADING_EDITS." | \n".TABLE_AUTHORS_HEADING_PERCENTAGE." | \n".TABLE_AUTHORS_HEADING_PERCENTAGE_BAR." | \n
\n\n\n";
foreach($authors as $author)
{
$percentage = $author['edits'] / $totaledits * 100;
$bar_width = round((PERCENTAGE_BAR_WIDTH * $author['edits'] / $totaledits),PERCENTAGE_DECIMALS_ROUND).'px';
$rounded_percentage = round($percentage,PERCENTAGE_DECIMALS_ROUND).'%';
$bar = '';
$output .= "\n".$this->FormatUser($author['user'], OPTION_LINK, OPTION_HOSTNAME_LENGTH)." | \n".
"".$author['edits']."/".$totaledits." | \n".
"".$rounded_percentage." | \n".
"".$bar." | \n".
"
\n";
}
$output .= "
\n";
}
$output .= "
\n";
// --- Statistics ---
$whereTag = "`tag` = '".$tag."'";
$wherePageTag = "`page_tag` = '".$tag."'";
$whereToTag = "`to_tag` = '".$tag."'";
$hn = 1; #forthcoming
$rv = $this->getCount('pages',$whereTag);
$cn = $this->getCount('comments',$wherePageTag);
$bn = $this->getCount('links',$whereToTag);
$rn = $this->getCount('referrers',$wherePageTag);
$totalhn = 1; #forthcoming
$totalrv = $this->getCount('pages');
$totalcn = $this->getCount('comments');
$totalbn = $this->getCount('links');
$totalrn = $this->getCount('referrers');
// @@ note: the link generation below is redundant and should be optimized
// get page hits (forthcoming)
$hitspage = ($hn > 0) ? '
'.$hn.'' : '0';
if ($totalhn > 0)
{
$hnpercentage = round($hn / $totalhn * 100, PERCENTAGE_DECIMALS_ROUND).'%';
$hnwidth = round((PERCENTAGE_BAR_WIDTH * $hn / $totalhn), PERCENTAGE_DECIMALS_ROUND).'px';
} else
{
$hnpercentage = '0%';
$hnwidth = '0px';
}
$hnbar = '
';
// get page revisions and create revision link if needed
$revpage = ($rv > 0) ? '
'.$rv.'' : '0';
if ($totalrv > 0)
{
$rvpercentage = round($rv / $totalrv * 100, PERCENTAGE_DECIMALS_ROUND).'%';
$rvwidth = round((PERCENTAGE_BAR_WIDTH * $rv / $totalrv), PERCENTAGE_DECIMALS_ROUND).'px';
} else
{
$rvpercentage = '0%';
$rvwidth = '0px';
}
$rvbar = '
';
// get page comments and create comments link if needed
$commentspage = ($cn > 0) ? '
'.$cn.'' : '0';
if ($totalcn > 0)
{
$cnpercentage = round($cn / $totalcn * 100, PERCENTAGE_DECIMALS_ROUND).'%';
$cnwidth = round((PERCENTAGE_BAR_WIDTH * $cn / $totalcn), PERCENTAGE_DECIMALS_ROUND).'px';
} else
{
$cnpercentage = '0%';
$cnwidth = '0px';
}
$cnbar = '';
// get page backlinks and create backlinks link
$backlinkpage = ($bn > 0) ? '
'.$bn.'' : '0';
if ($totalbn > 0)
{
$bnpercentage = round($bn / $totalbn * 100, PERCENTAGE_DECIMALS_ROUND).'%';
$bnwidth = round((PERCENTAGE_BAR_WIDTH * $bn / $totalbn), PERCENTAGE_DECIMALS_ROUND).'px';
} else
{
$bnpercentage = '0%';
$bnwidth = '0px';
}
$bnbar = '
';
// get page referrers and create referrer link
$refpage = ($rn > 0) ? '
'.$rn.'' : '0';
if ($totalrn > 0)
{
$rnpercentage = round($rn / $totalrn * 100, PERCENTAGE_DECIMALS_ROUND).'%';
$rnwidth = round((PERCENTAGE_BAR_WIDTH * $rn / $totalrn), PERCENTAGE_DECIMALS_ROUND).'px';
} else
{
$rnpercentage = '0%';
$rnwidth = '0px';
}
$rnbar = '
';
$output .= $this->Format('=='.HEADING_STATS.'==');
$output .= "
\n\n\n".TABLE_STATS_HEADING_STATISTICS." | \n".TABLE_STATS_HEADING_COUNT." | \n".TABLE_STATS_HEADING_PERCENTAGE." | \n".TABLE_STATS_HEADING_PERCENTAGE_BAR." | \n
\n\n\n".
'Hits | '.$hitspage.'/'.$totalhn.' | '.$hnpercentage.' | '.$hnbar.' |
'."\n".
'Revisions | '.$revpage.'/'.$totalrv.' | '.$rvpercentage.' | '.$rvbar.' |
'."\n".
'Comments | '.$commentspage.'/'.$totalcn.' | '.$cnpercentage.' | '.$cnbar.' |
'."\n".
'Backlinks | '.$backlinkpage.'/'.$totalbn.' | '.$bnpercentage.' | '.$bnbar.' |
'."\n".
'Referrers | '.$refpage.'/'.$totalrn.' | '.$rnpercentage.' | '.$rnbar.' |
'."\n".
'
'."\n";
// --- actions --- (forthcoming)
}
}
// display messages
if (isset($box)) echo $this->Format(' --- '.$box.' --- --- ');
// print form
if (isset($output)) print $output;
?>
%%
=== Styling ===
The ##info## handler uses a bunch of [[ChartStyling | CSS classes]] for styling the percentage bars.
----
CategoryDevelopmentHandlers