-
Notifications
You must be signed in to change notification settings - Fork 0
Add Special:PersistentPageIdentifierResolver page #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
650570e
26f4f49
d0d79a6
61481e2
dfc6776
892d3e5
74d0210
fb3647f
97b39bf
b504e07
b805080
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?php | ||
| $specialPageAliases = []; | ||
|
|
||
| /** English (English) */ | ||
| $specialPageAliases['en'] = [ | ||
| 'PURIResolver' => [ 'PURIResolver' ], | ||
| ]; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?php | ||
|
|
||
| declare( strict_types = 1 ); | ||
|
|
||
| namespace ProfessionalWiki\PersistentPageIdentifiers\EntryPoints; | ||
|
|
||
| use FormSpecialPage; | ||
| use ProfessionalWiki\PersistentPageIdentifiers\PersistentPageIdentifiersExtension; | ||
| use Status; | ||
| use Title; | ||
|
|
||
| class SpecialPURIResolver extends FormSpecialPage { | ||
|
|
||
| public function __construct() { | ||
| parent::__construct( 'PURIResolver' ); | ||
| } | ||
|
|
||
| public function execute( $subPage ): void { | ||
| parent::execute( $subPage ); | ||
|
|
||
| if ( !$subPage ) { | ||
| return; | ||
| } | ||
|
|
||
| $title = $this->getTitleFromPersistentId( $subPage ); | ||
|
|
||
| if ( !$title ) { | ||
JeroenDeDauw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return; | ||
| } | ||
|
|
||
| $this->getOutput()->redirect( $title->getFullURL() ); | ||
| } | ||
|
|
||
| protected function getFormFields() { | ||
|
Check failure on line 34 in src/EntryPoints/SpecialPURIResolver.php
|
||
| return [ | ||
| 'puri' => [ | ||
| 'type' => 'text', | ||
| 'label-message' => 'puriresolver-puri', | ||
| 'required' => true, | ||
| ] | ||
| ]; | ||
| } | ||
|
|
||
| public function onSubmit( array $data ) { | ||
|
Check failure on line 44 in src/EntryPoints/SpecialPURIResolver.php
|
||
| $title = $this->getTitleFromPersistentId( $data['puri'] ); | ||
|
|
||
| if ( !$title ) { | ||
| // Message: puri-not-exists | ||
| return Status::newFatal( $this->getMessagePrefix() . '-not-exists' ); | ||
| } | ||
|
|
||
| $this->getOutput()->redirect( $title->getFullURL() ); | ||
|
Check failure on line 52 in src/EntryPoints/SpecialPURIResolver.php
|
||
| } | ||
alistair3149 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| protected function getDisplayFormat() { | ||
| return 'ooui'; | ||
| } | ||
|
|
||
| public function getGroupName(): string { | ||
| return 'redirects'; | ||
| } | ||
|
|
||
| private function getTitleFromPersistentId( string $persistentId ): ?Title { | ||
| $pageId = $this->getPageIdFromPersistentId( $persistentId ); | ||
|
|
||
| if ( $pageId ) { | ||
| return Title::newFromID( $pageId ); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| private function getPageIdFromPersistentId( string $persistentId ): ?int { | ||
| return PersistentPageIdentifiersExtension::getInstance()->getPageIdsRepo()->getPageIdFromPersistentId( $persistentId ); | ||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.