Not logged in. · Lost password · Register
Forum: General Help and Support Plugins RSS
[SOLVED] how to trigger some (or all) (syntax)-plugins on a string
Avatar
Falkor #1
Member since Apr 2007 · 32 posts
Group memberships: Members
Show profile · Link to this post
Subject: [SOLVED] how to trigger some (or all) (syntax)-plugins on a string
Hi all,

I'm in need of a way to trigger either some or all plugins on a string (page) before I send it as email to some
subscribers (this is not the normal subscription, but a crude group-based subscription plugin I've made).

The reason is that I use the numbered_headings plugin, and it would make the some of the documents a lot easier to
read in pure text form.

Hope somebody can help,


//Falkor
This post was edited on 2007-09-27, 12:51 by Falkor.
chi #2
Member since Jun 2006 · 1851 posts · Location: Munich Germany
Group memberships: Members, Super Mods, Wiki Managers
Show profile · Link to this post
Hi,

you have to turn your string into a list of instructions first and then parse them. Here`s an example:

  1. $info = array();
  2. $str  = "The text to be parsed including syntax plugins code etc. etc."
  3. $ins  = p_get_instructions($str);
  4. $out  = p_render('xhtml', $ins, &$info); // $info holds information returned by the renderer

The p_cached_instructions() function may be also of interest for you (inc/parserutils.php).
Please add [SOLVED] to the initial thread subject if you feel your question has been answered.
If my answer doesn't make sense maybe your question didn't either - just visit http://facepalm.org.
Avatar
Falkor #3
Member since Apr 2007 · 32 posts
Group memberships: Members
Show profile · Link to this post
Thanks for quick reply.

This is basicly what I'm looking for, but I'd like to avoid the whole xhtml if possible.
I guess the quickest and dirties way is to strip all html-tags afterwards?

If I were to remove some of the instructions, would that cause significant problems for p_render?
It's very important that the email sent is plain text, although it does contain a link to the page if one wish to read it in a
nicer format.

I'd really like to hear your thoughts on this, before I put [solved] in the subject.

Cheers,

//Falkor
chi #4
Member since Jun 2006 · 1851 posts · Location: Munich Germany
Group memberships: Members, Super Mods, Wiki Managers
Show profile · Link to this post
Quote by Falkor:
This is basicly what I'm looking for, but I'd like to avoid the whole xhtml if possible.
I guess the quickest and dirties way is to strip all html-tags afterwards?

I guess so, you mentioned that you need to parse the syntax of plugins too, that however is only possible in xhtml mode.

Quote by Falkor:
If I were to remove some of the instructions, would that cause significant problems for p_render?

I think "removing" instructions won`t work in all cases, you would rather have to replace them, for example replace headline instructions with instructions for <p> blocks (I guess the sectioning instructions could be removed though).

And just another idea: If I understand you correctly, you`re about to implement a subscription system which sends the whole page as plain text via mail after a change. If that`s the case you don`t need to parse the thing again, you could also use the latest cached revision and strip all HTML tags from it.
Please add [SOLVED] to the initial thread subject if you feel your question has been answered.
If my answer doesn't make sense maybe your question didn't either - just visit http://facepalm.org.
Avatar
Falkor #5
Member since Apr 2007 · 32 posts
Group memberships: Members
Show profile · Link to this post
Quote by chi:
And just another idea: If I understand you correctly, you`re about to implement a subscription system which sends the whole page as plain text via mail after a change. If that`s the case you don`t need to parse the thing again, you could also use the latest cached revision and strip all HTML tags from it.

That's a good idea. When is a revision is cached? I'm using a the IO_WIKIPAGE_WRITE event to trigger it and use the data that is in the event. As you might imagine it is imperative that it is the latest version that is included in the mail.

//Falkor
chi #6
Member since Jun 2006 · 1851 posts · Location: Munich Germany
Group memberships: Members, Super Mods, Wiki Managers
Show profile · Link to this post
Quote by Falkor:
That's a good idea. When is a revision is cached?

The revision is written on IO_WIKIPAGE_WRITE too, when $data[3] contains a revision number. I think if you hook in AFTER this event you should be able to retrieve the latest revision with something along these lines:

  1. $cache = p_cached_xhtml(wikiFN($ID));
Please add [SOLVED] to the initial thread subject if you feel your question has been answered.
If my answer doesn't make sense maybe your question didn't either - just visit http://facepalm.org.
Avatar
Falkor #7
Member since Apr 2007 · 32 posts
Group memberships: Members
Show profile · Link to this post
Thanks a lot! This has been enlightening :-)

//Falkor
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-08-21, 18:00:26 (UTC +02:00)