|
@@ 4721-4733 (lines=13) @@
|
| 4718 |
|
* @throws MWException |
| 4719 |
|
* @return callable|null The old value of the mTagHooks array associated with the hook |
| 4720 |
|
*/ |
| 4721 |
|
public function setHook( $tag, $callback ) { |
| 4722 |
|
$tag = strtolower( $tag ); |
| 4723 |
|
if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) { |
| 4724 |
|
throw new MWException( "Invalid character {$m[0]} in setHook('$tag', ...) call" ); |
| 4725 |
|
} |
| 4726 |
|
$oldVal = isset( $this->mTagHooks[$tag] ) ? $this->mTagHooks[$tag] : null; |
| 4727 |
|
$this->mTagHooks[$tag] = $callback; |
| 4728 |
|
if ( !in_array( $tag, $this->mStripList ) ) { |
| 4729 |
|
$this->mStripList[] = $tag; |
| 4730 |
|
} |
| 4731 |
|
|
| 4732 |
|
return $oldVal; |
| 4733 |
|
} |
| 4734 |
|
|
| 4735 |
|
/** |
| 4736 |
|
* As setHook(), but letting the contents be parsed. |
|
@@ 4867-4881 (lines=15) @@
|
| 4864 |
|
* @throws MWException |
| 4865 |
|
* @return null |
| 4866 |
|
*/ |
| 4867 |
|
public function setFunctionTagHook( $tag, $callback, $flags ) { |
| 4868 |
|
$tag = strtolower( $tag ); |
| 4869 |
|
if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) { |
| 4870 |
|
throw new MWException( "Invalid character {$m[0]} in setFunctionTagHook('$tag', ...) call" ); |
| 4871 |
|
} |
| 4872 |
|
$old = isset( $this->mFunctionTagHooks[$tag] ) ? |
| 4873 |
|
$this->mFunctionTagHooks[$tag] : null; |
| 4874 |
|
$this->mFunctionTagHooks[$tag] = [ $callback, $flags ]; |
| 4875 |
|
|
| 4876 |
|
if ( !in_array( $tag, $this->mStripList ) ) { |
| 4877 |
|
$this->mStripList[] = $tag; |
| 4878 |
|
} |
| 4879 |
|
|
| 4880 |
|
return $old; |
| 4881 |
|
} |
| 4882 |
|
|
| 4883 |
|
/** |
| 4884 |
|
* Replace "<!--LINK-->" link placeholders with actual links, in the buffer |