19 $this->lines = explode(
"\n", $text );
20 $this->numLines = count( $this->lines );
29 while ( $this->pos < $this->numLines ) {
37 case 'transparenthooks':
41 if ( $this->pos < $this->numLines - 1 ) {
48 foreach ( $this->deletions as $deletion => $unused ) {
49 $this->
warning(
"Could not find test \"$deletion\" to delete it" );
51 foreach ( $this->changes as $test => $sectionChanges ) {
52 foreach ( $sectionChanges as
$section => $change ) {
53 $this->
warning(
"Could not find section \"$section\" in test \"$test\" " .
54 "to {$change['op']} it" );
67 if ( preg_match(
'/^!!\s*(\S+)/',
$line, $m ) ) {
76 $line = $this->lines[$this->pos++];
80 'headingLine' =>
$line,
84 while ( $this->pos < $this->numLines ) {
85 $line = $this->lines[$this->pos++];
87 if ( $nextHeading ===
'end' ) {
92 for ( $i = 0; $i < $this->numLines - $this->pos - 1; $i++ ) {
93 if ( $this->lines[$this->pos + $i] ===
'' ) {
99 $this->pos += strlen( $trail );
103 'headingLine' =>
$line,
108 } elseif ( $nextHeading !==
false ) {
110 $heading = $nextHeading;
113 'headingLine' =>
$line,
121 throw new Exception(
'Unexpected end of file' );
125 $line = $this->lines[$this->pos++];
127 $expectedEnd =
'end' . $heading;
128 $contents =
"$line\n";
131 $line = $this->lines[$this->pos++];
133 $contents .=
"$line\n";
134 }
while ( $this->pos < $this->numLines && $nextHeading !== $expectedEnd );
136 if ( $nextHeading !== $expectedEnd ) {
137 throw new Exception(
'Unexpected end of file' );
143 $this->result .= $contents;
149 if (
$section[
'name'] ===
'test' ) {
150 $testName = rtrim(
$section[
'contents'],
"\n" );
153 if ( isset( $this->deletions[$testName] ) ) {
155 unset( $this->deletions[$testName] );
158 if ( isset( $this->changes[$testName] ) ) {
159 $changes =& $this->changes[$testName];
160 foreach ( $test as $i =>
$section ) {
162 if ( isset(
$changes[$sectionName] ) ) {
164 switch ( $change[
'op'] ) {
166 $test[$i][
'name'] = $change[
'value'];
167 $test[$i][
'headingLine'] =
"!! {$change['value']}";
170 $test[$i][
'contents'] = $change[
'value'];
173 $test[$i][
'deleted'] =
true;
176 throw new Exception(
"Unknown op: ${change['op']}" );
185 if ( isset(
$section[
'deleted'] ) ) {
188 $this->result .=
$section[
'headingLine'] .
"\n";
189 $this->result .=
$section[
'contents'];
194 $this->result .= $contents;
__construct( $text, array $deletions, array $changes, $warningCallback)
static edit( $text, array $deletions, array $changes, $warningCallback=null)
emitHooks( $heading, $contents)
passed in as a query string parameter to the various URLs constructed here(i.e. $prevlink) $ldel you ll need to handle error etc yourself modifying $error and returning true will cause the contents of $error to be echoed at the top of the edit form as wikitext Return true without altering $error to allow the edit to proceed & $editor
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))