https://bugzilla.wikimedia.org/show_bug.cgi?id=18856





--- Comment #2 from Juho Vepsäläinen <[email protected]>  2009-05-27 06:47:59 
UTC ---
Alright. I implemented a simple form extension for MediaWiki (I know there are
at least two other of those available but neither matched my demands :) ). This
means that when editing certain pages besides the traditional editing box the
user sees some additional fields. Pages having forms are defined using category
hierarchy and by matching templates to the category names. The templates define
the overall structure and outlook of the document. Furthermore it contains
markup (ie. {{{textbox:textbox name}}} ) to determine where to show fields. The
extension constructs the editing pages based on this information
(category/template matching + template markup -> form).

I stash the user provided information on wiki pages in the syntax using
comments and serializing (explains the removeCommentLines part on previous
example). Furthermore each property (ie. field but as a more generic concept)
can render itself in wiki syntax (renderProperties on previous example). I use
renderProperties also in following way:

$wgHooks['EditPage::attemptSave'][] = 'combineBeforeWikiParse';
$wgHooks['EditPageBeforePreviewText'][] = 'combineBeforeWikiParse';
function combineBeforeWikiParse( $editPage ) {
        if( pageIsEditable() ) {
                $editPage->textbox1 = renderProperties($editPage) .
$editPage->textbox1;
        }

        return true;
}

So you can think it as a template engine sitting on top of MediaWiki's template
engine. In fact you could easily replace MediaWiki's current syntax with
totally different one this way but that's another story and goes beyond the
point. Basically if you are doing this sort of things and want to have preview
working properly, you have to do little tricks such as this. It's possible I
have missed some obvious solution given that I'm new to MediaWiki extension
coding though. :)

I agree that the name of the hook may not be the best possible. Feel free to
suggest more fitting one. :)


-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to