Extension talk:CreateArticle/sourcecode
[edit] Mediawiki 1.8.2 and 1.9.3 issue
I had to add a "trim()" to the expression "$value=htmlspecialchars($matches[1]);" i.e. trim($value=htmlspecialchars($matches[1])); in order to make this extension work. It would always declare "type not specified".
It may be due to a change in how the function htmlspecialchars is defined in MW 1.6.9, where this extension was tested.
/* Parses tag input arguments */
function getCreateBoxOption(&$value,&$input,$name,$isNumber=false) {
if(preg_match("/^\s*$name\s*=\s*(.*)/mi",$input,$matches)) {
if($isNumber) {
$value=intval($matches[1]);
} else {
$value=htmlspecialchars($matches[1]);
}
}
}
class Createbox {
var $type,$prefix, $subpage, $width;
var $preload,$editintro, $bgcolor;
var $defaulttext,$buttonlabel;
var $align, $br, $hidden;
function CreateBox( &$parser ) {
$this->parser =& $parser;
}
function render() {
if($this->type=='createarticle'){
return $this->getCreateForm();
} else {
return false;
}
}
Hope this helps, Jean-Lou Dupont 18:35, 17 March 2007 (UTC)
Thanks Jean-Lou -- I had not gotten around to updating this for versions 1.8.x and 1.9.x yet. I appreciate your contribution. --Hoggwild5 19:20, 20 March 2007 (UTC)
FATAL ERROR 1
Fatal error: Call to a member function getNamespace() on a non-object in /www/htdocs/ Skin.php on line 427
FATAL ERROR 2
1.To get this code working under PHP 5.3.3 & MediaWiki 1.16.0, I had to change the definition of the function renderCreatebox in line 84 from Um diesen Code arbeiten unter PHP 5.3.3 & MediaWiki 1.16.0, musste ich die Definition der Funktion renderCreatebox in Zeile 84 Wechsel von function renderCreatebox($input, $params, &$parser) { to zu function renderCreatebox($input, $params, $parser) {
FATAL ERROR 3
2.With MediaWiki 1.16.0, a fatal error occurs when you try to create an article that already exists ("Fatal error: Call to a member function getNamespace() on a non-object in /www/wiki/includes/Skin.php on line 376"). Mit MediaWiki 1.16.0, tritt ein schwerwiegender Fehler, wenn Sie einen Artikel, der bereits vorhanden ist ("Fatal error zu erstellen: Rufen Sie auf eine Elementfunktion GetNamespace () auf einem non-object in / www / wiki / includes / Skin.php auf Linie 376 "). This can be fixed by changing line 216 from Dies kann durch Ändern Linie 216 aus behoben werden $wgTitle = Title::newFromText( wfMsgForContent( 'createarticle' ) ); to zu $wgTitle = Title::newFromText( wfMsgForContent( 'error' ) );
FATAL ERROR 4