Index: trunk/extensions/Special404/Special404.alias.php |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Aliases for Special:404 |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$specialPageAliases = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Daniel Friesen |
| 14 | + */ |
| 15 | +$specialPageAliases['en'] = array( |
| 16 | + 'Error404' => array( 'Error404', '404' ), |
| 17 | +); |
| 18 | + |
Property changes on: trunk/extensions/Special404/Special404.alias.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 19 | + native |
Index: trunk/extensions/Special404/Special404_body.php |
— | — | @@ -0,0 +1,23 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + echo "Special404 extension\n"; |
| 6 | + exit( 1 ); |
| 7 | +} |
| 8 | + |
| 9 | +class Special404 extends UnlistedSpecialPage { |
| 10 | + |
| 11 | + public function __construct() { |
| 12 | + parent::__construct('Error404'); |
| 13 | + } |
| 14 | + |
| 15 | + public function execute( $par ) { |
| 16 | + global $wgOut, $wgRequest; |
| 17 | + |
| 18 | + $this->setHeaders(); |
| 19 | + $wgOut->setStatusCode( 404 ); |
| 20 | + $wgOut->addWikiMsg( 'special404-body', trim($wgRequest->getRequestURL(), '/\\') ); |
| 21 | + |
| 22 | + } |
| 23 | + |
| 24 | +} |
Property changes on: trunk/extensions/Special404/Special404_body.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 25 | + native |
Index: trunk/extensions/Special404/Special404.i18n.php |
— | — | @@ -0,0 +1,28 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation file for Special404 extension. |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Daniel Friesen |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'special404-desc' => "Provides a 404 special page destination for 404 Not Found errors.", |
| 17 | + 'error404' => "404 Not Found", |
| 18 | + 'special404-body' => <<<MSG |
| 19 | +The URL you requested was not found. |
| 20 | + |
| 21 | +Did you mean to type [{{fullurl:$1}} {{fullurl:$1}}]? |
| 22 | + |
| 23 | +Maybe you would like to look at: |
| 24 | +* [[{{int:mainpage}}|The main page]] |
| 25 | + |
| 26 | +MSG |
| 27 | + , |
| 28 | +); |
| 29 | + |
Property changes on: trunk/extensions/Special404/Special404.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 30 | + native |
Index: trunk/extensions/Special404/README |
— | — | @@ -0,0 +1,21 @@ |
| 2 | +Special404 can be installed by installing the extension and adding some webserver |
| 3 | +config to make the special page handle 404s. |
| 4 | + |
| 5 | +For apache there are issues getting a ErrorDocument to work, a RewriteRule is |
| 6 | +one known way to make this work. You can place something like this inside of your |
| 7 | +.htaccess file: |
| 8 | + |
| 9 | +RewriteCond %{REQUEST_FILENAME} !-f |
| 10 | +RewriteCond %{REQUEST_FILENAME} !-d |
| 11 | +RewriteRule ^/?.*$ /index.php?title=Special:Error404 |
| 12 | + |
| 13 | +Be sure to tweak it to match the local location of your index.php and include any |
| 14 | +other RewriteRules BEFORE this rule, this should be the very last RewriteRule you have. |
| 15 | + |
| 16 | +Note that it's important that you use /index.php?title=Special:Error404 instead |
| 17 | +of something that includes the path and you do not use something like /wiki/Special:Error404 |
| 18 | +because this destination using index.php and an explicit title is the only one |
| 19 | +that will get MediaWiki to display the 404 special page. It also retains the |
| 20 | +request path which the extension will then pass to the 404 body. |
| 21 | + |
| 22 | +Note that you can customize the 404 page's body by using [[MediaWiki:Special404-body]]. |
Index: trunk/extensions/Special404/Special404.php |
— | — | @@ -0,0 +1,31 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Special404 - provides a special page based 404 destination. |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * @author Daniel Friesen |
| 9 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 10 | + * @link http://www.mediawiki.org/wiki/Extension:Special404 Documentation |
| 11 | + */ |
| 12 | + |
| 13 | +# Not a valid entry point, skip unless MEDIAWIKI is defined |
| 14 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 15 | + echo "Special404 extension"; |
| 16 | + exit( 1 ); |
| 17 | +} |
| 18 | + |
| 19 | +$wgExtensionCredits['specialpage'][] = array( |
| 20 | + 'path' => __FILE__, |
| 21 | + 'author' => 'Daniel Friesen', |
| 22 | + 'name' => 'Special404', |
| 23 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:Special404', |
| 24 | + 'descriptionmsg' => 'special404-desc', |
| 25 | +); |
| 26 | + |
| 27 | +$wgExtensionMessagesFiles['Special404'] = dirname( __FILE__ ) . '/Special404.i18n.php'; |
| 28 | +$wgExtensionAliasesFiles['Special404'] = dirname( __FILE__ ) . '/Special404.alias.php'; |
| 29 | + |
| 30 | +$wgSpecialPages['Error404'] = array( 'Special404' ); |
| 31 | +$wgAutoloadClasses['Special404'] = dirname( __FILE__ ) . '/Special404_body.php'; |
| 32 | + |
Property changes on: trunk/extensions/Special404/Special404.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 33 | + native |