mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
Update Extension.php
This commit is contained in:
@ -46,23 +46,18 @@ class Extension {
|
|||||||
public static function onMultiContentSave( RenderedRevision $renderedRevision, User $user, CommentStoreComment $summary, $flags, Status $hookStatus ) {
|
public static function onMultiContentSave( RenderedRevision $renderedRevision, User $user, CommentStoreComment $summary, $flags, Status $hookStatus ) {
|
||||||
$config = new Config();
|
$config = new Config();
|
||||||
if ( !$config->parseOnEdit ) return true;
|
if ( !$config->parseOnEdit ) return true;
|
||||||
$title = $renderedRevision->getRevision()->getPageAsLinkTarget();
|
|
||||||
$slots = $renderedRevision->getRevision()->getSlots();
|
$revision = $renderedRevision->getRevision();
|
||||||
$content = $renderedRevision->getRevision()->getSlots()->getContent( SlotRecord::MAIN );
|
$slots = $revision->getSlots();
|
||||||
$articleID = $renderedRevision->getRevision()->getPageId();
|
$content = $slots->getContent( SlotRecord::MAIN );
|
||||||
$wikiPage = WikiPage::newFromID( $articleID );
|
|
||||||
if ( $wikiPage == null ) {
|
$wikiPage = WikiPage::factory( $title );
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$source = Source::createFromPageandContent( $wikiPage, $content, $config );
|
$source = Source::createFromPageandContent( $wikiPage, $content, $config );
|
||||||
$linker = new Linker( $config );
|
$linker = new Linker( $config );
|
||||||
$result = $linker->linkContent( $source );
|
$result = $linker->linkContent( $source );
|
||||||
if ( $result ) {
|
if ( $result ) {
|
||||||
$source->setText( $result );
|
$content = $source->setText( $result );
|
||||||
|
$slots->setContent( 'main', $content );
|
||||||
$text = $source->getText($result);
|
|
||||||
$slots = $renderedRevision->getRevision()->getSlots();
|
|
||||||
$slots->setContent( 'main', ContentHandler::makeContent( $text, $title ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user