Wikidot drives its parser and renderer through the Wikidot\Utils\WikiTransformation
class, which has a large number of fields and methods, making it difficult to determine exactly what the contract of the class is intended to be.
Here we will document all the present usages of WikiTransformation
to see what expectations and usecases it has, to be able to design the interface of WikitextBackend
.
FeedModule.php
, FrontForumModule.php
:
$wt = new WikiTransformation(); $wt->setMode("feed"); $template = $wt->processSource($format);
ForumPreviewPostModule.php
, ForumAction.php
:
$wt = new WikiTransformation(); $wt->setMode('post'); $body = $wt->processSource($source);
ForumPostRevisionModule.php
:
$source = $revision->getText(); $wt = new WikiTransformation(); $body = $wt->processSource($source);
PMAction.php
, PMPreviewModule.php
:
$wt = new WikiTransformation(); $wt->setMode('pm'); $body = $wt->processSource($source);
PMDraftsMessageModule.php
:
$wt = new WikiTransformation(); $wt->setMode('pm'); $message->setBody($wt->processSource($message->getBody()));
PagePreviewModule.php
:
$wt = new WikiTransformation(); $wt->setPageUnixName($pl->getParameterValue("page_unix_name")); /* snip */ if ($templatePage) { $source = $wt->assemblyTemplate($source, $templatePage->getSource()); } $result = $wt->processSource($source);
PageVersionModule.php
:
$tr = new WikiTransformation(); $content = $tr->processSource($source);
Outdater.php
:
$wt = new WikiTransformation(); $wt->setPage($page); $result = $wt->processSource($source);
private function assemblySource($source, $templateSource, $page = null) { $t = new WikiTransformation(false); return $t->assemblyTemplate($source, $templateSource, $page); }
ListPagesModule.php
:
if ($separation) { $wt = new WikiTransformation(); $wt->setMode("list"); $wt->setPage($page); $b = $wt->processSource($b); $b = "<div class=\"list-pages-item\">\n" . $b . "</div>"; //$b = "[[div class=\"list-pages-item\"]]\n".$b."\n[[/div]]"; }
if (!$separation) { $prependLine = $this->_readParameter('prependLine'); $appendLine = $this->_readParameter('appendLine'); $wt = new WikiTransformation(); $wt->setMode("list"); $glue = "\n"; $itemsContent = $wt->processSource(($prependLine ? ($prependLine . "\n") : ''). implode($glue, $items) . ($appendLine ? ("\n". $appendLine) : '')); } else { $itemsContent = implode("\n", $items); }
SocialBookmarksModule.php
:
// purify??? $wt = new WikiTransformation(); $out = $wt->purifyHtml($out); return $out;
PagesFeed.php
:
$wt = new WikiTransformation(); $wt->setMode("list"); $wt->setPage($page); $content = $wt->processSource($b); $d = utf8_encode("\xFE"); $content = preg_replace("/" . $d . "module \"([a-zA-Z0-9\/_]+?)\"(.+?)?" . $d . "/", '', $content); $content = preg_replace(';(<.*?)(src|href)="/([^"]+)"([^>]*>);si', '\\1\\2="'.GlobalProperties::$HTTP_SCHEMA . "://" . $site->getDomain().'/\\3"\\4', $content); $content = preg_replace(';<script\s+[^>]+>.*?</script>;is', '', $content); $content = preg_replace(';(<[^>]*\s+)on[a-z]+="[^"]+"([^>]*>);si', '\\1 \\2', $content);
WDEditUtils.php
:
$wt = new WikiTransformation(); // strip the Wiki processing $wt->wiki->rules = array( 'Include', 'Prefilter', 'Delimiter', // 'Moduledelimiter', 'Code', 'Raw', 'Modulepre', 'Module', 'Module654', 'Comment', 'Math', // 'Freelink', // 'Equationreference', //'Footnote', //'Footnoteitem', //'Footnoteblock', //'Bibitem', //'Bibliography', //'Bibcite', //'Divprefilter', //'Anchor', //'User', 'Heading'); $compiled = $wt->processSource($source);
Overall, I would group this in a few categories:
Generating RSS feeds
Compiling forum posts
Compiling private messages
Compiling page text
Includes the
Outdater
, which has a bit of notable logic around page invalidation.
ListPages
Miscellaneous
Social bookmarks, only for “purifying”
WDEditUtils
, which does page sectioning