Index: trunk/extensions/ArchiveLinks/ArchiveLinks.i18n.php |
— | — | @@ -0,0 +1,11 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalization File for Archive Links |
| 5 | + */ |
| 6 | + |
| 7 | +$messages = array(); |
| 8 | + |
| 9 | +//English |
| 10 | +$messages['en'] = array ( |
| 11 | + 'archive-links-cache-title' => '[cache]', |
| 12 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/ArchiveLinks/ArchiveLinks.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 13 | + native |
Index: trunk/extensions/ArchiveLinks/ArchiveLinks.php |
— | — | @@ -46,12 +46,15 @@ |
47 | 47 | //$wgHooks['LinkerMakeExternalLink'][] = 'getExternalLinks'; |
48 | 48 | //$wgHooks['EditPage::attemptSave'][] = 'getExternalLinks'; |
49 | 49 | |
| 50 | +$wgExtensionMessagesFiles['ArchiveLinks'] = dirname( __FILE__ ) . '/ArchiveLinks.i18n.php'; |
| 51 | + |
50 | 52 | $wgHooks['ArticleSaveComplete'][] = 'ArchiveLinks::queueExternalLinks'; |
51 | 53 | $wgHooks['LinkerMakeExternalLink'][] = 'ArchiveLinks::rewriteLinks'; |
52 | 54 | |
53 | | -$wgArchiveService = 'wikiwix'; |
54 | | -$wgUseMultipleArchives = false; |
55 | | -$wgWhatToCallArchive = '[cache]'; |
| 55 | +$wgArchiveLinksConfig = array ( |
| 56 | + 'archive_service' => 'wikiwix', |
| 57 | + 'use_multiple_archives' => false, |
| 58 | +); |
56 | 59 | |
57 | 60 | class ArchiveLinks { |
58 | 61 | public static function queueExternalLinks ( &$article ) { |
— | — | @@ -70,9 +73,7 @@ |
71 | 74 | foreach ( $external_links as $link => $unused_value ) { |
72 | 75 | //$db_result['resource'] = $db_slave->select( 'el_archive_resource', '*', '`el_archive_resource`.`resource_url` = "' . $db_slave->strencode( $link ) . '"'); |
73 | 76 | $db_result['blacklist'] = $db_slave->select( 'el_archive_blacklist', '*', '`el_archive_blacklist`.`bl_url` = "' . $db_slave->strencode( $link ) . '"'); |
74 | | - |
75 | | - //we need to know if the URL is already in the queue to prevent a page from being archived twice, so we will query the master |
76 | | - $db_result['queue'] = $db_master->select( 'el_archive_queue', '*', '`el_archive_queue`.`url` = "' . $db_slave->strencode( $link ) . '"' ); |
| 77 | + $db_result['queue'] = $db_slave->select( 'el_archive_queue', '*', '`el_archive_queue`.`url` = "' . $db_slave->strencode( $link ) . '"' ); |
77 | 78 | |
78 | 79 | if ( $db_result['blacklist']->numRows() === 0 ) { |
79 | 80 | if ( $db_result['queue']->numRows() === 0 ) { |
— | — | @@ -107,31 +108,30 @@ |
108 | 109 | |
109 | 110 | public static function rewriteLinks ( &$url, &$text, &$link, &$attributes ) { |
110 | 111 | if ( array_key_exists('rel', $attributes) && $attributes['rel'] === 'nofollow' ) { |
111 | | - global $wgArchiveService; |
112 | | - global $wgUseMultipleArchives; |
113 | | - global $wgWhatToCallArchive; |
114 | | - if ( $wgUseMultipleArchives ) { |
115 | | - //add support for more than one archival service at once |
116 | | - // (a page where you can select more than one) |
| 112 | + global $wgArchiveLinksConfig; |
| 113 | + if ( $wgArchiveLinksConfig['use_multiple_archives'] ) { |
| 114 | + //need to add support for more than one archival service at once |
| 115 | + // (a page where you can select one from a list of choices) |
117 | 116 | } else { |
118 | | - switch ( $wgArchiveService ) { |
| 117 | + switch ( $wgArchiveLinksConfig['archive_service'] ) { |
119 | 118 | case 'local': |
120 | 119 | //We need to have something to figure out where the filestore is... |
121 | 120 | $link_to_archive = urlencode( substr_replace( $url, '', 0, 7 ) ); |
122 | 121 | break; |
123 | 122 | case 'wikiwix': |
124 | | - $link_to_archive = 'http://archive.wikiwix.org/cache/?url=' . $link; |
| 123 | + $link_to_archive = 'http://archive.wikiwix.com/cache/?url=' . $url; |
125 | 124 | break; |
126 | 125 | case 'internet_archive': |
127 | | - $link_to_archive = 'http://wayback.archive.org/web/*/' . $link; |
| 126 | + $link_to_archive = 'http://wayback.archive.org/web/*/' . $url; |
128 | 127 | break; |
129 | 128 | case 'webcitation': |
130 | | - $link_to_archive = 'http://webcitation.org/query?url=' . $link; |
| 129 | + $link_to_archive = 'http://webcitation.org/query?url=' . $url; |
131 | 130 | break; |
132 | 131 | } |
133 | 132 | } |
134 | | - $link = "<a rel=\"nofollow\" class=\"{$attributes['class']}\" href=\"{$url}\">{$text}</a> <sup><small><a href=\"" |
135 | | - . $link_to_archive . "\">{$wgWhatToCallArchive}</a></small></sup> "; |
| 133 | + //Note to self: need to fix this to use Html.php instead of direct html |
| 134 | + $link = "<a rel=\"nofollow\" class=\"{$attributes['class']}\" href=\"{$url}\">{$text}</a> <sup><small><a href=\"" |
| 135 | + . "{$link_to_archive}\">" . wfMsg( 'archive-links-cache-title' ) . '</a></small></sup> '; |
136 | 136 | return false; |
137 | 137 | } else { |
138 | 138 | return true; |
— | — | @@ -160,7 +160,7 @@ |
161 | 161 | |
162 | 162 | //$db_slave = wfGetDB( DB_SLAVE ); |
163 | 163 | |
164 | | - /*$db_result = $db_slave->select( 'el_archive_blacklist', '*', |
| 164 | + /*db_result = $db_slave->select( 'el_archive_blacklist', '*', |
165 | 165 | '`el_archive_blacklist`.`bl_url` = "' . $db_slave->strencode( 'http://example.com' ) . '"'); |
166 | 166 | */ |
167 | 167 | //$db_result['queue'] = $db_slave->select( 'el_archive_queue', '*', '`el_archive_queue`.`url` = "' . $db_slave->strencode( 'http://example.com' ) . '"' ); |