Hi, I am trying to include another extension in my own extension. I need to parse the other extension as wikitext, but it doesn't work.
I am extending http://www.mediawiki.org/wiki/Extension:SelectCategoryTagCloud to include not only a tag cloud, but also a hierarchical view on categories. Instead of writing the code from scratch, I would like to reuse http://www.mediawiki.org/wiki/Extension:CategoryTree. I am trying to include the <categorytree> tags in the area where the tag cloud is. Users would then be able to select categories from the categorytree and assign them to the article.
I have used the following code, but I get an error.
$outputtext = $wgParser->recursiveTagParse("<categorytree depth="2" onlyroot="on" mode="all" style="float:none; margin-left:1ex; border:1px solid gray; padding:0.7ex; background-color:white;">My Category</categorytree>");
The error is: Fatal error: Call to a member function getUseTeX() on a non-object in D:\Apache2.2\htdocs\mike2\includes\Parser.php on line 551
Just to clarify, I have a hook extension where I need to make sure that the wikitext is parsed before I include it in the output of the extension.
How can I get rid of the error? Or does anyone have other suggestions?
Thanks, Andi
On Mon, Sep 10, 2007 at 02:42:11PM +0100, Andreas Rindler wrote:
Hi, I am trying to include another extension in my own extension. I need to parse the other extension as wikitext, but it doesn't work.
I am extending http://www.mediawiki.org/wiki/Extension:SelectCategoryTagCloud to include not only a tag cloud, but also a hierarchical view on categories. Instead of writing the code from scratch, I would like to reuse http://www.mediawiki.org/wiki/Extension:CategoryTree. I am trying to include the <categorytree> tags in the area where the tag cloud is. Users would then be able to select categories from the categorytree and assign them to the article.
I have used the following code, but I get an error.
You might want to try using the setTransparentTagHook() function instead of the setHook() function to register your tag. Transparent tags are evaluated at the very end of the parsing, so that they don't get wikitext as input, but parsed wikitext ("HTML").
jens
On 10/09/2007, Jens Frank jf@mormo.org wrote:
On Mon, Sep 10, 2007 at 02:42:11PM +0100, Andreas Rindler wrote:
Hi, I am trying to include another extension in my own extension. I need to parse the other extension as wikitext, but it doesn't work.
I am extending http://www.mediawiki.org/wiki/Extension:SelectCategoryTagCloud to include not only a tag cloud, but also a hierarchical view on categories. Instead of writing the code from scratch, I would like to reuse http://www.mediawiki.org/wiki/Extension:CategoryTree. I am trying to include the <categorytree> tags in the area where the tag cloud is. Users would then be able to select categories from the categorytree and assign them to the article.
I have used the following code, but I get an error.
You might want to try using the setTransparentTagHook() function instead of the setHook() function to register your tag. Transparent tags are evaluated at the very end of the parsing, so that they don't get wikitext as input, but parsed wikitext ("HTML").
I am using an extension A inside an extension B and I am having troubles to parse A so that I don't have to manually rewrite in HTML what extension A and the parser should do on their own. How would I apply your suggestion to extensions A or B?
Thanks, Andi
On Tue, Sep 11, 2007 at 04:10:25PM +0100, Andreas Rindler wrote:
On 10/09/2007, Jens Frank jf@mormo.org wrote:
On Mon, Sep 10, 2007 at 02:42:11PM +0100, Andreas Rindler wrote:
Hi, I am trying to include another extension in my own extension. I need to parse the other extension as wikitext, but it doesn't work.
I am extending http://www.mediawiki.org/wiki/Extension:SelectCategoryTagCloud to include not only a tag cloud, but also a hierarchical view on categories. Instead of writing the code from scratch, I would like to reuse http://www.mediawiki.org/wiki/Extension:CategoryTree. I am trying to include the <categorytree> tags in the area where the tag cloud is. Users would then be able to select categories from the categorytree and assign them to the article.
I have used the following code, but I get an error.
You might want to try using the setTransparentTagHook() function instead of the setHook() function to register your tag. Transparent tags are evaluated at the very end of the parsing, so that they don't get wikitext as input, but parsed wikitext ("HTML").
I am using an extension A inside an extension B and I am having troubles to parse A so that I don't have to manually rewrite in HTML what extension A and the parser should do on their own. How would I apply your suggestion to extensions A or B?
Change extension B to use setTransparentTagHook().
I think you might have something like e.g.
<b-tag> draw chart values <a-tag>select x,y from values where...</a-tag> color red </b-tag>
If a-tag is registered using setHook(), a-tag would get expanded first, and then b-tag would be expanded, getting a-tag's output as input to the values parameter.
Regards,
jens
$wgParser is a global that has to be both created before you use it, and declared as a global. Did you forget either of those? You can also create a new parser inside your extension.
JH
On Sep 10, 2007, at 9:42 AM, Andreas Rindler wrote:
Hi, I am trying to include another extension in my own extension. I need to parse the other extension as wikitext, but it doesn't work.
I am extending http://www.mediawiki.org/wiki/ Extension:SelectCategoryTagCloud to include not only a tag cloud, but also a hierarchical view on categories. Instead of writing the code from scratch, I would like to reuse http://www.mediawiki.org/wiki/Extension:CategoryTree. I am trying to include the <categorytree> tags in the area where the tag cloud is. Users would then be able to select categories from the categorytree and assign them to the article.
I have used the following code, but I get an error.
$outputtext = $wgParser->recursiveTagParse("<categorytree depth="2" onlyroot="on" mode="all" style="float:none; margin-left:1ex; border:1px solid gray; padding:0.7ex; background-color:white;">My Category</categorytree>");
The error is: Fatal error: Call to a member function getUseTeX() on a non-object in D:\Apache2.2\htdocs\mike2\includes\Parser.php on line 551
Just to clarify, I have a hook extension where I need to make sure that the wikitext is parsed before I include it in the output of the extension.
How can I get rid of the error? Or does anyone have other suggestions?
Thanks, Andi
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
On 10/09/2007, Jim Hu jimhu@tamu.edu wrote:
$wgParser is a global that has to be both created before you use it, and declared as a global. Did you forget either of those? You can also create a new parser inside your extension.
I ceclared global $wgParser; at the beginning of the function but I am not sure how to 'create' one?!
You know, I thought this was more straightforward at first, but looking at my own code I use the global parser.
$wgParser seems to be created in Setup.php
$wgParser = new StubObject( 'wgParser', 'Parser' );
So, it seems like it shouldn't be a "non-object" when you call it. Try an is_object on it and print the result just to be sure??
Jim On Sep 10, 2007, at 12:02 PM, Andreas Rindler wrote:
On 10/09/2007, Jim Hu jimhu@tamu.edu wrote:
$wgParser is a global that has to be both created before you use it, and declared as a global. Did you forget either of those? You can also create a new parser inside your extension.
I ceclared global $wgParser; at the beginning of the function but I am not sure how to 'create' one?!
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
On 10/09/2007, Jim Hu jimhu@tamu.edu wrote:
You know, I thought this was more straightforward at first, but looking at my own code I use the global parser.
$wgParser seems to be created in Setup.php
$wgParser = new StubObject( 'wgParser', 'Parser' );
So, it seems like it shouldn't be a "non-object" when you call it. Try an is_object on it and print the result just to be sure??
I checked is_object($wgParser) and it comes back ok. But it's in parser.php where the error is thrown by the call $this->mOptions->getUseTeX(). And I tested it with plain text and it still throws the same error: $wgParser->recursiveTagParse("hello world");
On Mon, 10 Sep 2007 14:42:11 +0100, Andreas Rindler wrote:
$outputtext = $wgParser->recursiveTagParse("<categorytree depth="2" onlyroot="on" mode="all" style="float:none; margin-left:1ex; border:1px solid gray; padding:0.7ex; background-color:white;">My Category</categorytree>");
I don't know if you can parse a constant string, so I wouldn't be surprised if the parser complains somewhere that it's not an object. I'd do something like:
$outputtext = "<categorytree depth="2" onlyroot="on" mode="all" style="float:none; margin-left:1ex; border:1px solid gray; padding:0.7ex; background-color:white;">My Category</categorytree>")
$outputtext = $parser->recursiveTagParse($outputtext);
Assuming that the third arg to your hook is called $parser; probably neater to use the one that's passed in. But keeping your text in a variable and then replacing it is more consistent with most of what I've seen.
On 11/09/2007, Steve Sanbeg ssanbeg@ask.com wrote:
I don't know if you can parse a constant string, so I wouldn't be surprised if the parser complains somewhere that it's not an object. I'd do something like:
$outputtext = "<categorytree depth="2" onlyroot="on" mode="all" style="float:none; margin-left:1ex; border:1px solid gray; padding:0.7ex; background-color:white;">My Category</categorytree>")
$outputtext = $parser->recursiveTagParse($outputtext);
I tried that, but no difference.
Assuming that the third arg to your hook is called $parser; probably neater to use the one that's passed in. But keeping your text in a variable and then replacing it is more consistent with most of what I've seen.
I am using a hook extension (http://www.mediawiki.org/wiki/Manual:Hooks), so I don't have a parser passed in as an argument.
I don't know if you can parse a constant string, so I wouldn't be surprised if the parser complains somewhere that it's not an object. I'd do something like:
I can't see why that would make any difference. A string isn't an object, as far as I know, so it's passed by value, not reference.
wikitech-l@lists.wikimedia.org