You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
misc/pmwiki_recipes/groupstats.php

52 lines
1.8 KiB

<?php
# give a visual representation of pages and group
#
# action for the whole wiki (equivalent to group="") done through AllPages fake group
# add the GroupKeyPages function as a parameter
$RecipeInfo['GroupStats']['Version'] = '2011-08-06';
SDV($HandleActions['GroupStats'], 'GroupStats');
# if url contains action=myaction call HandleMyAction timely
$HandleAuth['GroupStats'] = 'read'; # authorization level $auth for HandleMyAction
function GroupStats($pagename, $auth){
list($group,$page) = explode(".",$pagename);
$distmax = 15;
if ($group == "AllPages"){
// equivalent to getting ALL pages
$group = "";
$distmax = 50;
}
$dist= GroupDegreeDistribution($group);
for($i=1;$i<$distmax;$i++){
if (isset($dist[$i]))
$distribution .= $dist[$i].",";
else
$distribution .= "0,";
}
$max = max($dist);
$upperbound = $dist[($distmax/5)];
$img = "http://sparklines.bitworking.info/spark.cgi?type=impulse"
."&d=$distribution&height=100"
."&limits=0,$max"
."&upper=$upperbound&above-color=red&below-color=gray&width=15&.png";
$selectingalgo = "NetworkDegree";
# can also be NetworkOutgoingIncoming or NetworkLeverageCentrality or NetworkDegree
# threshold are set later on
$keypages = var_export(GroupKeyPages($group, $selectingalgo),true);
$coeditions = var_export(Coeditions($group),true);
# could be improvied by coloring
# link to self
# links that do not exist explicitely
print "<h1>Group statistics for $group</h1>"
."<hr/><h2>Degree distribution</h2>(from d(1) to d(max), d()=0 excluded, max(d())=2, avg(d())~=4):</br>"
.$distribution."<br><img src=\"$img\" /><br>"
."<hr/><h2><a name=\"Key pages\"></a>Keypages using $selectingalgo</h2><pre>".$keypages."</pre>"
."<hr/><h2><a name=\"Coeditions\"></a>Coedition</h2><pre>".$coeditions."</pre>";
}
?>