Hi *,
just another quick update.
Attached you find my 'trying out different things' file, which shows you
the first sql for the table, and my tries to get some Hooks and Outputs
going.
One of the things that I am wondering at the moment is how to display
forms, links and other output on normal Article pages just using hooks.
The last thing I tried yesterday was the DiffViewHeader, which would
allow for managing the revisiontags (needs to be renamed). I could
output the results using BeforePageDisplay, and wgOut->addHtml, and some
css to move stuff to the top, but this does not seem to be that clean.
Now, to get help with questions like that, where do you recommend to
look for answers? This list, #wikipedia, another mailinglist?
Cheers,
Joerg
----------------
<?
/*
--
-- Table structure for table `revisiontags`
--
CREATE TABLE `revisiontags` (
`rt_id` int(10) NOT NULL auto_increment,
`rt_rev_id` int(10) NOT NULL,
`rt_dimension` varchar(255) NOT NULL,
`rt_tag` int(2) NOT NULL,
`rt_user` int(5) NOT NULL,
`rt_timestamp` char(14) NOT NULL,
`rt_comment` varchar(255) default NULL,
PRIMARY KEY (`rt_id`),
KEY `rt_rev_id` (`rt_rev_id`,`rt_dimension`,`rt_tag`,`rt_timestamp`)
) CHARSET=latin1 COMMENT='Revision Tags Extension' AUTO_INCREMENT=1 ;
Possible Hooks
--------------
'BeforePageDisplay': Called just before outputting a page (all kinds of,
articles, special, history, preview, diff, edit, ...)
Can be used to set custom CSS/JS
$out: OutputPage object
'OutputPageBeforeHTML': a page has been processed by the parser and
the resulting HTML is about to be displayed.
$parserOutput: the parserOutput (object) that corresponds to the page
$text: the text that will be displayed, in HTML (string)
*/
class RevisionTags {
var $dimensions = array('quality'=>array('tags'=>array(0=>'none',
1=>'unvandalised',
2=>'superb'),
'comments'=>True,
'default'=>0));
function writeTag($rev_id,$dimension,$tag,$user,$comment) {
}
function getTagsForRevision($rev_id) {
}
function writeStuff(&$out) {
global $mediaWiki;
if ($out->isArticle())
$text = 'Yeah, Article';
else
$text = 'Something else';
$out->addHTML("<blink>$text</blink>");
}
function addToDiff(&$diff,&$oldrev,&$newrev) {
global $wgOut;
$id = $newrev->getId();
$self = $_SERVER['PHP_SELF'];
$form = "
<form action='$self/Special:RevisionTags'>
Tag new revision $id:<br>";
foreach ($this->dimensions as $dimension=>$content) {
$form.="$dimension <select name='$dimension'>";
foreach ($content['tags'] as $idx=>$label) {
$form.="<option value='$idx'>$label</option>";
}
$form.="</select>";
}
$form.="<input type='submit' value='tag'></form>";
$wgOut->addHTML($form);
}
}
$revtags = new RevisionTags();
#$wgHooks['BeforePageDisplay'][] = array($revtags, 'writeStuff');
$wgHooks['DiffViewHeader'][] = array($revtags, 'addToDiff');
?>