|
Cookbook /
Delta Bytes in Recent ChangesSummary: Display the number of bytes (characters) added or deleted to a page in RecentChanges.
Version: 24 February 2007
Prerequisites:
Status:
Maintainer: Petko
Discussion: DeltaBytesRecentChanges-Talk
Questions answered by this recipeHow can the RecentChanges pages display the amount of bytes (characters) added or deleted to a page? Like it is done in Wikipedia? DescriptionDisplay the number of bytes (characters) added or deleted to a page in RecentChanges. You can use such a function (add it in your (farm)config.php):
array_unshift($EditFunctions, "DeltaPageSize");
function DeltaPageSize($pagename,&$page,&$new)
{
global $EnablePost, $ChangeSummary, $Now;
if (!$EnablePost) return;
$delta = strlen($new['text']) - strlen($page['text']);
if($delta>0) $delta = "+$delta";
$new['csum'] .= " ($delta)";
$new["csum:$Now"] .= " ($delta)";
$ChangeSummary .= " ($delta)";
}
A sample output of this recipe would be:
Variant with colored delta numbersThis variant displays important deletions in red, important additions in green and in bold.
array_unshift($EditFunctions, "DeltaPageSize");
function DeltaPageSize($pagename,&$page,&$new)
{
global $EnablePost, $ChangeSummary, $Now;
if (!$EnablePost) return;
$delta = strlen($new['text']) - strlen($page['text']);
$span = $_span = $bold = '';
if(abs($delta) > 500 )$bold = "'''";
if($delta<-500) $span="purple";
elseif($delta<-100)$span="red";
elseif($delta==0) $span="gray";
elseif($delta>100)$span="green";
if($span){$span="=]%$span%"; $_span="%%[=";}
if($delta>0) $delta = "+$delta";
$new['csum'] .= " ($delta)";
$new["csum:$Now"] .= " ($delta)";
$ChangeSummary .= " ($span$bold$delta$bold$_span)";
}
Notes
Release Notes
Comments
See Also
ContributorsUser notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |