Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1377,6 +1377,15 @@ |
1378 | 1378 | 'special-categories-sort-count', |
1379 | 1379 | 'special-categories-sort-abc', |
1380 | 1380 | ), |
| 1381 | + 'linksearch' => array( |
| 1382 | + 'linksearch', |
| 1383 | + 'linksearch-pat', |
| 1384 | + 'linksearch-ns', |
| 1385 | + 'linksearch-ok', |
| 1386 | + 'linksearch-text', |
| 1387 | + 'linksearch-line', |
| 1388 | + 'linksearch-error', |
| 1389 | + ), |
1381 | 1390 | 'listusers' => array( |
1382 | 1391 | 'listusersfrom', |
1383 | 1392 | 'listusers-submit', |
— | — | @@ -2805,6 +2814,7 @@ |
2806 | 2815 | 'logpages' => 'Special:Log', |
2807 | 2816 | 'allpages' => 'Special:AllPages', |
2808 | 2817 | 'categories' => 'Special:Categories', |
| 2818 | + 'linksearch' => 'Special:LinkSearch', |
2809 | 2819 | 'listusers' => 'Special:ListUsers', |
2810 | 2820 | 'newuserlog' => 'Special:Log/newusers', |
2811 | 2821 | 'listgrouprights' => 'Special:ListGroupRights', |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | # Extension classes are specified with $wgAutoloadClasses |
10 | 10 | # This array is a global instead of a static member of AutoLoader to work around a bug in APC |
11 | 11 | global $wgAutoloadLocalClasses; |
12 | | -$wgAutoloadLocalClasses = array( |
| 12 | +$wgAutoloadLocalClasses = array( |
13 | 13 | # Includes |
14 | 14 | 'AjaxDispatcher' => 'includes/AjaxDispatcher.php', |
15 | 15 | 'AjaxResponse' => 'includes/AjaxResponse.php', |
— | — | @@ -356,7 +356,7 @@ |
357 | 357 | 'WhiteSpaceNode' => 'includes/diff/Nodes.php', |
358 | 358 | 'WikiDiff3' => 'includes/diff/Diff.php', |
359 | 359 | 'WordLevelDiff' => 'includes/diff/DifferenceEngine.php', |
360 | | - |
| 360 | + |
361 | 361 | # includes/filerepo |
362 | 362 | 'ArchivedFile' => 'includes/filerepo/ArchivedFile.php', |
363 | 363 | 'File' => 'includes/filerepo/File.php', |
— | — | @@ -446,6 +446,7 @@ |
447 | 447 | 'ImportReporter' => 'includes/specials/SpecialImport.php', |
448 | 448 | 'ImportStreamSource' => 'includes/specials/SpecialImport.php', |
449 | 449 | 'ImportStringSource' => 'includes/specials/SpecialImport.php', |
| 450 | + 'LinkSearchPage' => 'includes/specials/SpecialLinkSearch.php', |
450 | 451 | 'ListredirectsPage' => 'includes/specials/SpecialListredirects.php', |
451 | 452 | 'LoginForm' => 'includes/specials/SpecialUserlogin.php', |
452 | 453 | 'LonelyPagesPage' => 'includes/specials/SpecialLonelypages.php', |
— | — | @@ -517,11 +518,11 @@ |
518 | 519 | class AutoLoader { |
519 | 520 | /** |
520 | 521 | * autoload - take a class name and attempt to load it |
521 | | - * |
| 522 | + * |
522 | 523 | * @param string $className Name of class we're looking for. |
523 | 524 | * @return bool Returning false is important on failure as |
524 | 525 | * it allows Zend to try and look in other registered autoloaders |
525 | | - * as well. |
| 526 | + * as well. |
526 | 527 | */ |
527 | 528 | static function autoload( $className ) { |
528 | 529 | global $wgAutoloadClasses, $wgAutoloadLocalClasses; |
— | — | @@ -580,4 +581,3 @@ |
581 | 582 | AutoLoader::autoload( $class ); |
582 | 583 | } |
583 | 584 | } |
584 | | - |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2828,6 +2828,7 @@ |
2829 | 2829 | 'Mytalk' => 'redirects', |
2830 | 2830 | 'Mycontributions' => 'redirects', |
2831 | 2831 | 'Search' => 'redirects', |
| 2832 | + 'LinkSearch' => 'redirects', |
2832 | 2833 | |
2833 | 2834 | 'Movepage' => 'pagetools', |
2834 | 2835 | 'MergeHistory' => 'pagetools', |
Index: trunk/phase3/includes/specials/SpecialLinkSearch.php |
— | — | @@ -0,0 +1,182 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * @file |
| 5 | + * @ingroup SpecialPage |
| 6 | + * |
| 7 | + * @author Brion Vibber |
| 8 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * Special:LinkSearch to search the external-links table. |
| 13 | + * @ingroup SpecialPage |
| 14 | + */ |
| 15 | + |
| 16 | +function wfSpecialLinkSearch( $par ) { |
| 17 | + |
| 18 | + list( $limit, $offset ) = wfCheckLimits(); |
| 19 | + global $wgOut, $wgRequest, $wgUrlProtocols, $wgMiserMode; |
| 20 | + $target = $GLOBALS['wgRequest']->getVal( 'target', $par ); |
| 21 | + $namespace = $GLOBALS['wgRequest']->getIntorNull( 'namespace', null ); |
| 22 | + |
| 23 | + $protocols_list[] = ''; |
| 24 | + foreach( $wgUrlProtocols as $prot ) { |
| 25 | + $protocols_list[] = $prot; |
| 26 | + } |
| 27 | + |
| 28 | + $target2 = $target; |
| 29 | + $protocol = ''; |
| 30 | + $pr_sl = strpos($target2, '//' ); |
| 31 | + $pr_cl = strpos($target2, ':' ); |
| 32 | + if ( $pr_sl ) { |
| 33 | + // For protocols with '//' |
| 34 | + $protocol = substr( $target2, 0 , $pr_sl+2 ); |
| 35 | + $target2 = substr( $target2, $pr_sl+2 ); |
| 36 | + } elseif ( !$pr_sl && $pr_cl ) { |
| 37 | + // For protocols without '//' like 'mailto:' |
| 38 | + $protocol = substr( $target2, 0 , $pr_cl+1 ); |
| 39 | + $target2 = substr( $target2, $pr_cl+1 ); |
| 40 | + } elseif ( $protocol == '' && $target2 != '' ) { |
| 41 | + // default |
| 42 | + $protocol = 'http://'; |
| 43 | + } |
| 44 | + if ( !in_array( $protocol, $protocols_list ) ) { |
| 45 | + // unsupported protocol, show original search request |
| 46 | + $target2 = $target; |
| 47 | + $protocol = ''; |
| 48 | + } |
| 49 | + |
| 50 | + $self = Title::makeTitle( NS_SPECIAL, 'Linksearch' ); |
| 51 | + |
| 52 | + $wgOut->addWikiText( wfMsg( 'linksearch-text', '<nowiki>' . implode( ', ', $wgUrlProtocols) . '</nowiki>' ) ); |
| 53 | + $s = Xml::openElement( 'form', array( 'id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $GLOBALS['wgScript'] ) ) . |
| 54 | + Xml::hidden( 'title', $self->getPrefixedDbKey() ) . |
| 55 | + '<fieldset>' . |
| 56 | + Xml::element( 'legend', array(), wfMsg( 'linksearch' ) ) . |
| 57 | + Xml::inputLabel( wfMsg( 'linksearch-pat' ), 'target', 'target', 50, $target ) . ' '; |
| 58 | + if ( !$wgMiserMode ) { |
| 59 | + $s .= Xml::label( wfMsg( 'linksearch-ns' ), 'namespace' ) . ' ' . |
| 60 | + XML::namespaceSelector( $namespace, '' ); |
| 61 | + } |
| 62 | + $s .= Xml::submitButton( wfMsg( 'linksearch-ok' ) ) . |
| 63 | + '</fieldset>' . |
| 64 | + Xml::closeElement( 'form' ); |
| 65 | + $wgOut->addHtml( $s ); |
| 66 | + |
| 67 | + if( $target != '' ) { |
| 68 | + $searcher = new LinkSearchPage( $target2, $namespace, $protocol ); |
| 69 | + $searcher->doQuery( $offset, $limit ); |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +class LinkSearchPage extends QueryPage { |
| 74 | + |
| 75 | + function __construct( $query, $ns, $prot ) { |
| 76 | + $this->mQuery = $query; |
| 77 | + $this->mNs = $ns; |
| 78 | + $this->mProt = $prot; |
| 79 | + } |
| 80 | + |
| 81 | + function getName() { |
| 82 | + return 'LinkSearch'; |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Disable RSS/Atom feeds |
| 87 | + */ |
| 88 | + function isSyndicated() { |
| 89 | + return false; |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Return an appropriately formatted LIKE query and the clause |
| 94 | + */ |
| 95 | + static function mungeQuery( $query , $prot ) { |
| 96 | + $field = 'el_index'; |
| 97 | + $rv = LinkFilter::makeLike( $query , $prot ); |
| 98 | + if ($rv === false) { |
| 99 | + //makeLike doesn't handle wildcard in IP, so we'll have to munge here. |
| 100 | + if (preg_match('/^(:?[0-9]{1,3}\.)+\*\s*$|^(:?[0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]*\*\s*$/', $query)) { |
| 101 | + $rv = $prot . rtrim($query, " \t*") . '%'; |
| 102 | + $field = 'el_to'; |
| 103 | + } |
| 104 | + } |
| 105 | + return array( $rv, $field ); |
| 106 | + } |
| 107 | + |
| 108 | + function linkParameters() { |
| 109 | + global $wgMiserMode; |
| 110 | + $params = array(); |
| 111 | + $params['target'] = $this->mProt . $this->mQuery; |
| 112 | + if( isset( $this->mNs ) && !$wgMiserMode ) { |
| 113 | + $params['namespace'] = $this->mNs; |
| 114 | + } |
| 115 | + return $params; |
| 116 | + } |
| 117 | + |
| 118 | + function getSQL() { |
| 119 | + global $wgMiserMode; |
| 120 | + $dbr = wfGetDB( DB_SLAVE ); |
| 121 | + $page = $dbr->tableName( 'page' ); |
| 122 | + $externallinks = $dbr->tableName( 'externallinks' ); |
| 123 | + |
| 124 | + /* strip everything past first wildcard, so that index-based-only lookup would be done */ |
| 125 | + list( $munged, $clause ) = self::mungeQuery( $this->mQuery, $this->mProt ); |
| 126 | + $stripped = substr($munged,0,strpos($munged,'%')+1); |
| 127 | + $encSearch = $dbr->addQuotes( $stripped ); |
| 128 | + |
| 129 | + $encSQL = ''; |
| 130 | + if ( isset ($this->mNs) && !$wgMiserMode ) |
| 131 | + $encSQL = 'AND page_namespace=' . $dbr->addQuotes( $this->mNs ); |
| 132 | + |
| 133 | + $use_index = $dbr->useIndexClause( $clause ); |
| 134 | + return |
| 135 | + "SELECT |
| 136 | + page_namespace AS namespace, |
| 137 | + page_title AS title, |
| 138 | + el_index AS value, |
| 139 | + el_to AS url |
| 140 | + FROM |
| 141 | + $page, |
| 142 | + $externallinks $use_index |
| 143 | + WHERE |
| 144 | + page_id=el_from |
| 145 | + AND $clause LIKE $encSearch |
| 146 | + $encSQL"; |
| 147 | + } |
| 148 | + |
| 149 | + function formatResult( $skin, $result ) { |
| 150 | + $title = Title::makeTitle( $result->namespace, $result->title ); |
| 151 | + $url = $result->url; |
| 152 | + $pageLink = $skin->makeKnownLinkObj( $title ); |
| 153 | + $urlLink = $skin->makeExternalLink( $url, $url ); |
| 154 | + |
| 155 | + return wfMsgHtml( 'linksearch-line', $urlLink, $pageLink ); |
| 156 | + } |
| 157 | + |
| 158 | + /** |
| 159 | + * Override to check query validity. |
| 160 | + */ |
| 161 | + function doQuery( $offset, $limit, $shownavigation=true ) { |
| 162 | + global $wgOut; |
| 163 | + list( $this->mMungedQuery, $clause ) = LinkSearchPage::mungeQuery( $this->mQuery, $this->mProt ); |
| 164 | + if( $this->mMungedQuery === false ) { |
| 165 | + $wgOut->addWikiText( wfMsg( 'linksearch-error' ) ); |
| 166 | + } else { |
| 167 | + // For debugging |
| 168 | + // Generates invalid xhtml with patterns that contain -- |
| 169 | + //$wgOut->addHtml( "\n<!-- " . htmlspecialchars( $this->mMungedQuery ) . " -->\n" ); |
| 170 | + parent::doQuery( $offset, $limit, $shownavigation ); |
| 171 | + } |
| 172 | + } |
| 173 | + |
| 174 | + /** |
| 175 | + * Override to squash the ORDER BY. |
| 176 | + * We do a truncated index search, so the optimizer won't trust |
| 177 | + * it as good enough for optimizing sort. The implicit ordering |
| 178 | + * from the scan will usually do well enough for our needs. |
| 179 | + */ |
| 180 | + function getOrder() { |
| 181 | + return ''; |
| 182 | + } |
| 183 | +} |
Property changes on: trunk/phase3/includes/specials/SpecialLinkSearch.php |
___________________________________________________________________ |
Name: svn:mergeinfo |
1 | 184 | + |
Name: svn:eol-style |
2 | 185 | + native |
Index: trunk/phase3/includes/QueryPage.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | array( 'DeadendPagesPage', 'Deadendpages' ), |
23 | 23 | array( 'DisambiguationsPage', 'Disambiguations' ), |
24 | 24 | array( 'DoubleRedirectsPage', 'DoubleRedirects' ), |
| 25 | + array( 'LinkSearchPage', 'LinkSearch' ), |
25 | 26 | array( 'ListredirectsPage', 'Listredirects' ), |
26 | 27 | array( 'LonelyPagesPage', 'Lonelypages' ), |
27 | 28 | array( 'LongPagesPage', 'Longpages' ), |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -129,6 +129,7 @@ |
130 | 130 | 'Contributions' => array( 'SpecialPage', 'Contributions' ), |
131 | 131 | 'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ), |
132 | 132 | 'Whatlinkshere' => array( 'SpecialPage', 'Whatlinkshere' ), |
| 133 | + 'LinkSearch' => array( 'SpecialPage', 'LinkSearch' ), |
133 | 134 | 'Recentchangeslinked' => 'SpecialRecentchangeslinked', |
134 | 135 | 'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ), |
135 | 136 | 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ), |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2104,6 +2104,16 @@ |
2105 | 2105 | 'special-categories-sort-count' => 'sort by count', |
2106 | 2106 | 'special-categories-sort-abc' => 'sort alphabetically', |
2107 | 2107 | |
| 2108 | +# Special:LinkSearch |
| 2109 | +'linksearch' => 'Search web links', |
| 2110 | +'linksearch-pat' => 'Search pattern:', |
| 2111 | +'linksearch-ns' => 'Namespace:', |
| 2112 | +'linksearch-ok' => 'Search', |
| 2113 | +'linksearch-text' => 'Wildcards such as "*.wikipedia.org" may be used.<br /> |
| 2114 | +Supported protocols: <tt>$1</tt>', |
| 2115 | +'linksearch-line' => '$1 linked from $2', |
| 2116 | +'linksearch-error' => 'Wildcards may appear only at the start of the hostname.', |
| 2117 | + |
2108 | 2118 | # Special:ListUsers |
2109 | 2119 | 'listusersfrom' => 'Display users starting at:', |
2110 | 2120 | 'listusers-submit' => 'Show', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -126,6 +126,9 @@ |
127 | 127 | * Added Wantedfiles special pages, allowing users to find image links with no image. |
128 | 128 | * (bug 12650) It is now possible to set different expiration times for different |
129 | 129 | restriction types on the protection form. |
| 130 | +* Special:Log/newusers recording new users.was added (was extension Newuserlog) |
| 131 | +* Special:LinkSearch to search for external links was added (was extension |
| 132 | + LinkSearch) |
130 | 133 | |
131 | 134 | === Bug fixes in 1.14 === |
132 | 135 | |