-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5175ceb
commit abceaa9
Showing
2 changed files
with
37 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,44 @@ | ||
<?php | ||
|
||
function countRFAs( $wikicode ) { | ||
preg_match_all( '/\{\{Wikipedia:Requests for adminship\/[^\}]+\}\}/i', $wikicode, $matches ); | ||
class RFACount { | ||
public function doRFA( $wapi, $rfaPageWikitext ) { | ||
$count = $this->countRFAs( $rfaPageWikitext ); | ||
|
||
// don't count {{Wikipedia:Requests for adminship/Header}} and {{Wikipedia:Requests for adminship/bureaucratship}} | ||
$count = count( $matches[0] ) - 2; | ||
$wikicodeToWrite = | ||
"$count<noinclude> | ||
{{Documentation}} | ||
</noinclude>"; | ||
$editSummary = "set RFA count to $count (NovemBot Task 7)"; | ||
$wapi->edit( 'User:Amalthea/RfX/RfA count', $wikicodeToWrite, $editSummary ); | ||
} | ||
|
||
public function doRFB( $wapi, $rfaPageWikitext ) { | ||
$count = $this->countRFBs( $rfaPageWikitext ); | ||
|
||
// if we get an impossible count, just return zero | ||
if ( $count < 0 ) { | ||
$count = 0; | ||
$wikicodeToWrite = $count; | ||
$editSummary = "set RFB count to $count (NovemBot Task 7)"; | ||
$wapi->edit( 'User:Amalthea/RfX/RfB count', $wikicodeToWrite, $editSummary ); | ||
} | ||
|
||
return $count; | ||
} | ||
private function countRFAs( $wikicode ) { | ||
preg_match_all( '/\{\{Wikipedia:Requests for adminship\/[^\}]+\}\}/i', $wikicode, $matches ); | ||
|
||
// don't count {{Wikipedia:Requests for adminship/Header}} and {{Wikipedia:Requests for adminship/bureaucratship}} | ||
$count = count( $matches[0] ) - 2; | ||
|
||
function countRFBs( $wikicode ) { | ||
preg_match_all( '/\{\{Wikipedia:Requests for bureaucratship\/[^\}]+\}\}/i', $wikicode, $matches ); | ||
// if we get an impossible count, just return zero | ||
if ( $count < 0 ) { | ||
$count = 0; | ||
} | ||
|
||
$count = count( $matches[0] ); | ||
return $count; | ||
} | ||
|
||
private function countRFBs( $wikicode ) { | ||
preg_match_all( '/\{\{Wikipedia:Requests for bureaucratship\/[^\}]+\}\}/i', $wikicode, $matches ); | ||
|
||
return $count; | ||
$count = count( $matches[0] ); | ||
|
||
return $count; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters