=====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== ""

Page statistics for HomePage




Page revisions (author/page totals):
User Edits % Percentage
JsnX 124/183 67.76%
DarTar 53/183 28.96%
JavaWoman 5/183 2.73%
WakkaInstaller 1/183 0.55%

 

Global statistics (page/site totals):
Statistics Count % Percentage
Hits1/1100%
Revisions183/101931.8%
Comments96/20514.68%
Backlinks50/55490.9%
Referrers34294/6797850.45%
"" ---- === Current version === (2005-08-07) Latest available version: ##**0.3**## === Change log === ==0.3== ~- bugfix: preventing divide by zero errors; ---- === The code === **Dependencies:** The ##info## handler uses: ~-the **##[[FormatUserMethod | FormatUser()]]##** method, that must be added to ##wikka.php##, at the end of the user-related functions, right after ##""function UserWantsComments()""##; ~-the **##[[WikkaCountingRecords | getCount()]]##** method, that must be added to ##wikka.php## right after the ##""LoadAll()""## method. Copy the following code as: ##handlers/page/info.php## %%(php;1)
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\n\n\n\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\n". "\n". "\n". "\n". "\n"; } $output .= "
".TABLE_AUTHORS_HEADING_USER."".TABLE_AUTHORS_HEADING_EDITS."".TABLE_AUTHORS_HEADING_PERCENTAGE."".TABLE_AUTHORS_HEADING_PERCENTAGE_BAR."
".$this->FormatUser($author['user'], OPTION_LINK, OPTION_HOSTNAME_LENGTH)."".$author['edits']."/".$totaledits."".$rounded_percentage."".$bar."
\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\n\n\n\n\n\n\n". ''."\n". ''."\n". ''."\n". ''."\n". ''."\n". '
".TABLE_STATS_HEADING_STATISTICS."".TABLE_STATS_HEADING_COUNT."".TABLE_STATS_HEADING_PERCENTAGE."".TABLE_STATS_HEADING_PERCENTAGE_BAR."
Hits'.$hitspage.'/'.$totalhn.''.$hnpercentage.''.$hnbar.'
Revisions'.$revpage.'/'.$totalrv.''.$rvpercentage.''.$rvbar.'
Comments'.$commentspage.'/'.$totalcn.''.$cnpercentage.''.$cnbar.'
Backlinks'.$backlinkpage.'/'.$totalbn.''.$bnpercentage.''.$bnbar.'
Referrers'.$refpage.'/'.$totalrn.''.$rnpercentage.''.$rnbar.'
'."\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