Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SpecialReadingLists | |
0.00% |
0 / 29 |
|
0.00% |
0 / 3 |
90 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| execute | |
0.00% |
0 / 27 |
|
0.00% |
0 / 1 |
56 | |||
| getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\ReadingLists; |
| 4 | |
| 5 | use MediaWiki\Exception\UserNotLoggedIn; |
| 6 | use MediaWiki\Html\Html; |
| 7 | use MediaWiki\SpecialPage\UnlistedSpecialPage; |
| 8 | |
| 9 | class SpecialReadingLists extends UnlistedSpecialPage { |
| 10 | /** |
| 11 | * Construct function |
| 12 | */ |
| 13 | public function __construct() { |
| 14 | parent::__construct( 'ReadingLists' ); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Render SpecialPage:ReadingLists |
| 19 | * |
| 20 | * @param string $subPage Parameter submitted as subpage |
| 21 | * @throws UserNotLoggedIn |
| 22 | */ |
| 23 | public function execute( $subPage ) { |
| 24 | $this->setHeaders(); |
| 25 | $this->outputHeader(); |
| 26 | |
| 27 | $req = $this->getRequest(); |
| 28 | $exportFeature = $req->getText( 'limport' ) !== '' || $req->getText( 'lexport' ) !== ''; |
| 29 | |
| 30 | if ( !$this->getUser()->isNamed() ) { |
| 31 | $this->requireNamedUser(); |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | $output = $this->getOutput(); |
| 36 | $config = $this->getConfig(); |
| 37 | |
| 38 | $anonymizedPreviews = $config->get( 'ReadingListsAnonymizedPreviews' ); |
| 39 | |
| 40 | if ( $exportFeature && $anonymizedPreviews ) { |
| 41 | $output->addHtmlClasses( 'reading-lists-anonymized-previews' ); |
| 42 | } |
| 43 | |
| 44 | // Special:ReadingLists/ExampleUser/1 is a subpage, with a specific reading list |
| 45 | // Special:ReadingLists/ExampleUser (or Special:ReadingLists) |
| 46 | // is the overview page "Reading lists" for the user. |
| 47 | $parts = $subPage ? explode( '/', $subPage ) : []; |
| 48 | if ( count( $parts ) >= 2 ) { |
| 49 | $output->setPageTitleMsg( $this->msg( 'readinglists-special-subpage-title' ) ); |
| 50 | } else { |
| 51 | $output->setPageTitleMsg( $this->msg( 'readinglists-title' ) ); |
| 52 | } |
| 53 | |
| 54 | $output->addHTML( Html::errorBox( |
| 55 | $this->msg( 'readinglists-error' )->parse(), |
| 56 | '', |
| 57 | 'reading-lists__errorbox' |
| 58 | ) ); |
| 59 | |
| 60 | $container = Html::element( 'div', [ |
| 61 | 'class' => 'reading-lists-container' |
| 62 | ] ); |
| 63 | |
| 64 | $output->addHTML( $container ); |
| 65 | $output->addModuleStyles( [ 'ext.readingLists.special.styles' ] ); |
| 66 | $output->addModules( [ 'ext.readingLists.special' ] ); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * @return string |
| 71 | */ |
| 72 | protected function getGroupName() { |
| 73 | return 'pages'; |
| 74 | } |
| 75 | } |