Skip to content

Commit

Permalink
Merge commit 'origin/ipye' into luca
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca de Alfaro committed Aug 23, 2008
2 parents 94902ad + 20052bd commit 50fbd46
Showing 1 changed file with 17 additions and 29 deletions.
46 changes: 17 additions & 29 deletions online/mediawiki/extensions/Trust/Trust.php
Expand Up @@ -35,7 +35,13 @@ class TextTrust extends ExtensionClass
const TRUST_MULTIPLIER = 10;

## Token to split trust and origin values on
const TRUST_SPLIT_TOKEN = ",";
const TRUST_SPLIT_TOKEN = ',';

## Token to be replaed with <
const TRUST_OPEN_TOKEN = "QQampo:";

## Token to be replaed with >
const TRUST_CLOSE_TOKEN = ":ampc:";

## Median Value of Trust
var $median = 0.0;
Expand Down Expand Up @@ -340,30 +346,11 @@ function ucscColorTrust_Magic( &$magicWords, $langCode ) {
return true;
}

/* Blame Map */
/** Not used currently.
function ucscOrigin_Render( &$parser, $origin = 0 ) {
$output = "QQampo:span onclick='showOrigin($origin)'>";
$output = "<span class=BLAME_MAP:$origin:>";
$output = "BLAME_MAP:$origin:";
if ($this->first_origin){
$this->first_origin = false;
} else {
$output = "QQampo:/span:ampc:" . $output;
}
return array( $output, "noparse" => false, "isHTML" => false );
}
*/

/* Turn the finished trust info into a span tag. Also handle closing tags. */
function ucscOrigin_Finalize(&$parser, &$text) {
$count = 0;
// $text = preg_replace('/class=\"BLAME_MAP:(\d+):\"/', "onclick='showOrigin($1)'", $text, -1, $count);
// $text = preg_replace('/BLAME_MAP:(\d+):/', "<span onclick='showOrigin($1)'>", $text, -1, $count);
$text = preg_replace('/QQampo:/', "<", $text, -1, $count);
$text = preg_replace('/:ampc:/', ">", $text, -1, $count);
$text = preg_replace('/' . self::TRUST_OPEN_TOKEN . '/', "<", $text, -1, $count);
$text = preg_replace('/' . self::TRUST_CLOSE_TOKEN .'/', ">", $text, -1, $count);
$text = preg_replace('/<\/p>/', "</span></p>", $text, -1, $count);
$text = preg_replace('/<p><\/span>/', "<p>", $text, -1, $count);
$text = preg_replace('/<li><\/span>/', "<li>", $text, -1, $count);
Expand All @@ -374,18 +361,19 @@ function ucscOrigin_Finalize(&$parser, &$text) {
function ucscColorTrust_Render( &$parser, $combinedValue = "0,0" ) {

// Split the value into trust and origin information.
$splitVals = split(TRUST_SPLIT_TOKEN, $combinedValue);
$trustVal = $splitVals[0];
$originVal = $splitVals[1];

$class = $this->computeColorFromFloat($trustVal);
$output = "QQampo:span class=$class:ampc:";
// 0 = trust
// 1 = origin
$splitVals = explode(self::TRUST_SPLIT_TOKEN, $combinedValue);

$class = $this->computeColorFromFloat($splitVals[0]);
$output = self::TRUST_OPEN_TOKEN . "span class=\"$class\" onclick=\"showOrigin("
. $splitVals[1] . ")\"" . self::TRUST_CLOSE_TOKEN;

$this->current_trust = $class;
if ($this->first_span){
$this->first_span = false;
} else {
$output = "QQampo:/span:ampc:" . $output;
$output = self::TRUST_OPEN_TOKEN . "/span" . self::TRUST_CLOSE_TOKEN . $output;
}

return array ( $output, "noparse" => false, "isHTML" => false );
Expand Down

0 comments on commit 50fbd46

Please sign in to comment.