Revision as of 19:56, 26 March 2018 editWbm1058 (talk | contribs)Autopatrolled, Administrators264,845 edits v 1.42 – list other pages proposed to be merged which are blank or don't exist at the end of the run← Previous edit |
Latest revision as of 14:02, 29 November 2024 edit undoJLaTondre (talk | contribs)Administrators45,016 edits rv by restoring prior versionTag: Manual revert |
(39 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
|
<source lang=php> |
|
<syntaxhighlight lang=php> |
|
<?php |
|
<?php |
|
/** proposedmergers.php - To generate lists of proposed page mergers on Misplaced Pages |
|
/** proposedmergers.php - To generate lists of proposed page mergers on Misplaced Pages |
|
* Version 1.42 |
|
|
* |
|
* |
|
* (c) 2009 James Hare - http://en.wikipedia.org/User:Harej |
|
* (c) 2009 James Hare - http://en.wikipedia.org/User:Harej |
|
|
* (c) 2013-2022 Bill - http://en.wikipedia.org/User:wbm1058 |
|
* |
|
* |
|
* This program is free software; you can redistribute it and/or modify |
|
* This program is free software; you can redistribute it and/or modify |
Line 28: |
Line 28: |
|
require_once 'botclasses.php'; // Botclasses.php was written by User:Chris_G and is available under the GNU General Public License |
|
require_once 'botclasses.php'; // Botclasses.php was written by User:Chris_G and is available under the GNU General Public License |
|
include("logininfo.php"); |
|
include("logininfo.php"); |
|
|
|
|
|
const bot_version = "1.110"; |
|
|
const botuser = "Merge bot"; |
|
|
|
|
|
function templateprocess($processed) { |
|
function templateprocess($processed) { |
Line 43: |
Line 46: |
|
|
|
|
|
# {{Merging}} |
|
# {{Merging}} |
|
|
$processed = preg_replace("/^(Mergingsectionto|Merging|Merging to|Merging_to)(.*)\|\s*dir\s*\=\s*from/i", "mergefrom$2", $processed); |
|
$processed = preg_replace("/^(Mergingsectionto|Merging|Merging to|Merging_to)/i", "merge", $processed); |
|
$processed = preg_replace("/^(Mergingsectionto|Merging|Merging to|Merging_to)/i", "merge", $processed); |
|
|
|
|
Line 55: |
Line 59: |
|
$processed = preg_replace("/^(Merge to|Merge_to|Merge-to|Mergeinto|MergetoCat|Mergelist|Mergeto-disputed)/i", "mergeto", $processed); |
|
$processed = preg_replace("/^(Merge to|Merge_to|Merge-to|Mergeinto|MergetoCat|Mergelist|Mergeto-disputed)/i", "mergeto", $processed); |
|
$processed = preg_replace("/^(MergePartial|Merge-multiple-to|Merge to article|Merge_to_article)/i", "mergeto", $processed); |
|
$processed = preg_replace("/^(MergePartial|Merge-multiple-to|Merge to article|Merge_to_article)/i", "mergeto", $processed); |
|
$processed = preg_replace("/^(Mergeto-multiple|Multiplemergeto|Multiplemergeinto|Merge into|Merge_into|MergeTo|Mergeto|Merge2)/i", "mergeto", $processed); |
|
$processed = preg_replace("/^(Mergeto-multiple|Multiplemergeto|Multiplemergeinto|Merge into|Merge_into|Merge-into|MergeTo|Mergeto|Merge2)/i", "mergeto", $processed); |
|
$processed = preg_replace("/^(Merge school|Merge_school|Merge-school)/i", "mergeto", $processed); |
|
$processed = preg_replace("/^(Merge school|Merge_school|Merge-school)/i", "mergeto", $processed); |
|
|
|
|
Line 67: |
Line 71: |
|
} |
|
} |
|
|
|
|
|
|
echo "PHP version: " . PHP_VERSION . "\n"; |
|
|
#phpinfo(); |
|
|
echo "Bot version: " . bot_version . "\n"; |
|
|
|
|
|
$j = 0; |
|
|
$takeofflater = 0; |
|
|
$maxi = 0; |
|
|
$cachepage = ""; |
|
|
$discuss = array(); |
|
|
$target = array(); |
|
|
$section = array(); |
|
|
$multiplesections = array(); |
|
|
$reason = array(); |
|
$othernamespace = 0; |
|
$othernamespace = 0; |
|
$matchfailed = 0; |
|
$matchfailed = 0; |
|
$templatesplitfailed = 0; |
|
$templatesplitfailed = 0; |
|
$nopartner = 0; |
|
$nopartner = 0; |
|
|
$nopartners = array(); |
|
|
$no_direction = 0; |
|
|
$no_directions = array(); |
|
|
$conflict = 0; |
|
|
$conflicts = array(); |
|
$mismatched_date = 0; |
|
$mismatched_date = 0; |
|
$mismatched_dates = array(); |
|
$mismatched_dates = array(); |
Line 79: |
Line 101: |
|
$no_reciprocal = 0; |
|
$no_reciprocal = 0; |
|
$redirects = 0; |
|
$redirects = 0; |
|
|
$maybe = 0; |
|
|
$maybes = array(); |
|
|
$diffcase = 0; |
|
|
$diffcases = array(); |
|
|
$redir_no_reciprocal = 0; |
|
|
$redir_no_reciprocals = array(); |
|
|
$page_moved = 0; |
|
|
$pages_moved = array(); |
|
|
$other_redirect = 0; |
|
|
$other_redirects = array(); |
|
$selfmerge = 0; |
|
$selfmerge = 0; |
|
|
$targetself = 0; |
|
$noname = 0; |
|
$noname = 0; |
|
$wikt = 0; |
|
$wikt = 0; |
|
$mainsubmission = ""; |
|
$mainsubmission = ""; |
|
|
$skipped = 0; |
|
|
$counter = array(); |
|
|
$maxcounter = 0; |
|
|
$submission = array(); |
|
|
$nomatches = array(); |
|
|
$nosplits = array(); |
|
|
|
|
|
echo "Logging in...\n"; |
|
echo "Logging in...\n"; |
|
$objwiki = new wikipedia(); |
|
$objwiki = new wikipedia(); |
|
|
$objwiki->http->useragent = '] php wikibot classes'; |
|
$objwiki->login($mbuser, $mbpass); |
|
$objwiki->login($mbuser, $mbpass); |
|
echo "...done.\n"; |
|
echo "...done.\n"; |
Line 104: |
Line 144: |
|
} |
|
} |
|
|
|
|
|
for ($i = 0; $i < count($transcludes); $i++) { // for each page |
|
for ($i = 0; $i < count($transcludes); $i++) { // for each page in the category |
|
|
|
|
|
if ($i > $maxi) { |
|
if ($i > $maxi) { |
Line 110: |
Line 150: |
|
} |
|
} |
|
|
|
|
|
if (preg_match("/^((User|Misplaced Pages|File|MediaWiki|Template|Help|Category|Portal)(( |_)talk)?|Talk):/", $transcludes)) { |
|
if (preg_match("/^((User|Misplaced Pages|File|MediaWiki|Template|Help|Category|Portal|Draft)(( |_)talk)?|Talk):/", $transcludes)) { |
|
echo "\n\n?? Other namespace: " . $transcludes . "\n\n"; |
|
echo "\n\n?? Other namespace: " . $transcludes . "\n\n"; |
|
$others = $transcludes; |
|
$others = $transcludes; |
Line 119: |
Line 159: |
|
$getpagefailed = 0; |
|
$getpagefailed = 0; |
|
do { |
|
do { |
|
$contents = $objwiki->getpage($transcludes); |
|
if ($transcludes == $cachepage) { |
|
|
echo "getpage 1: $transcludes|from cache\n"; |
|
|
$contents = $cachecontents; |
|
|
} |
|
|
else { |
|
|
echo "getpage 1: $transcludes|"; |
|
|
$contents = $objwiki->getpage($transcludes); |
|
|
} |
|
if ($contents == FALSE) { |
|
if ($contents == FALSE) { |
|
echo "\n\n?? getpage failed: " . $transcludes . "\n\n"; |
|
echo "\n\n?? getpage failed: " . $transcludes . "\n\n"; |
Line 131: |
Line 178: |
|
} while ($contents == FALSE); |
|
} while ($contents == FALSE); |
|
|
|
|
|
if (preg_match_all("/\{{2}\s?(merge|afd-merge|merging|move section)*\}{2}/i", $contents, $raw) == 0) { |
|
if (preg_match_all("/\{{2}\s?(merge|proposed merge|afd-merge|merging|move section)*\}{2}/i", $contents, $raw1) == 0) { |
|
#echo "contents:\n"; |
|
#echo "contents:\n"; |
|
#echo "$contents"; |
|
#echo "$contents"; |
Line 142: |
Line 189: |
|
} |
|
} |
|
|
|
|
|
|
$mergetemplates = count($raw1); |
|
|
if ($mergetemplates > 1) { |
|
|
echo "$mergetemplates merge templates on $transcludes\n"; |
|
|
print_r($raw1); |
|
|
} |
|
$takeofflater = 0; |
|
$takeofflater = 0; |
|
|
|
|
for ($j = 0; $j < count($raw); $j++) { // for each utterance |
|
|
|
for ($j = 0; $j < $mergetemplates; $j++) { // for each merge template on the page |
|
$key = $a . "-" . $i . "-" . $j; |
|
$key = $a . "-" . $i . "-" . $j; |
|
|
|
|
|
$pagename = $transcludes; |
|
$pagename = $transcludes; |
|
echo $key . ">> " . $pagename; |
|
echo $key . ">> " . $pagename; |
|
$template = templateprocess($raw); |
|
$template = templateprocess($raw1); |
|
#echo "Count of raw: " . count($raw) . "\n"; |
|
#echo " § " . $template . " §"; |
|
|
|
|
|
$ptemplate = $raw1; |
|
|
if (isset($contents)) $pcontents = $contents; |
|
|
else $pcontents = ""; |
|
unset($contents); |
|
unset($contents); |
|
|
|
|
Line 172: |
Line 229: |
|
continue 2; |
|
continue 2; |
|
default: |
|
default: |
|
echo "*** templatesplitfailed: " . $templatesplit . "\n"; |
|
echo "*** templatesplitfailed: " . $template . "\n"; |
|
print_r($templatesplit); |
|
print_r($templatesplit); |
|
$nosplits = $transcludes; |
|
$nosplits = $transcludes; |
Line 188: |
Line 245: |
|
|
|
|
|
for ($para = 1; $para < count($templatesplit); $para++) { |
|
for ($para = 1; $para < count($templatesplit); $para++) { |
|
if (preg_match("/^date=/i", $templatesplit)) { |
|
#echo "\n" . $para . ") " . $templatesplit . "\n"; |
|
|
if (preg_match("/^date\s*=/i", $templatesplit)) { |
|
$date = str_replace("date=", "", $templatesplit); |
|
$date = str_replace("date=", "", $templatesplit); |
|
|
$date = str_replace("_", " ", $date); |
|
|
|
|
|
if ($date != $monthyear) { |
|
if ($date != $monthyear) { |
Line 210: |
Line 269: |
|
} |
|
} |
|
} |
|
} |
|
elseif (preg_match("/^(discuss|discussion)=/i", $templatesplit)) { |
|
elseif (preg_match("/^(discuss|discussion|talk)\s*=/i", $templatesplit)) { |
|
$discuss = str_replace("discuss=", "", $templatesplit); |
|
$discuss = str_replace("discuss=", "", $templatesplit); |
|
$discuss = str_replace("discussion=", "", $discuss); |
|
$discuss = str_replace("discussion=", "", $discuss); |
|
|
$discuss = str_replace("talk=", "", $discuss); |
|
} |
|
} |
|
elseif (preg_match("/^target=/i", $templatesplit)) { |
|
elseif (preg_match("/^target\s*=/i", $templatesplit)) { |
|
$target = str_replace("target=", "", $templatesplit); |
|
$target = str_replace("target=", "", $templatesplit); |
|
|
|
|
|
if ($target == $transcludes) { |
|
|
echo "\n** error ** Page " . $transcludes . " proposed merge target is itself\n"; |
|
|
$targetself += 1; |
|
|
} |
|
|
|
|
|
if (in_array($target, $pagename)) { |
|
if (in_array($target, $pagename)) { |
Line 231: |
Line 296: |
|
} |
|
} |
|
} |
|
} |
|
elseif (preg_match("/^section=/i", $templatesplit)) { |
|
elseif (preg_match("/^section\s*=/i", $templatesplit)) { |
|
$section = str_replace("section=", "", $templatesplit); |
|
$section = str_replace("section=", "", $templatesplit); |
|
} |
|
} |
|
elseif (preg_match("/^multiplesections=/i", $templatesplit)) { // Template:Mergefrom uses parameter multiplesections; Merge and Mergeto do not |
|
elseif (preg_match("/^multiplesections\s*=/i", $templatesplit)) { |
|
|
// Template:Mergefrom uses parameter multiplesections; Merge and Mergeto do not |
|
$multiplesections = str_replace("multiplesections=", "", $templatesplit); |
|
$multiplesections = str_replace("multiplesections=", "", $templatesplit); |
|
} |
|
} |
|
elseif (preg_match("/^reason=/i", $templatesplit)) { |
|
elseif (preg_match("/^dir\s*=/i", $templatesplit)) { // Template:Merging |
|
|
} |
|
|
elseif (preg_match("/^(reason|comment)\s*=/i", $templatesplit)) { |
|
$reason = str_replace("reason=", "", $templatesplit); |
|
$reason = str_replace("reason=", "", $templatesplit); |
|
$reasons = $pagename . " …… " . $reason; |
|
$reasons = $pagename . " …… " . $reason; |
Line 259: |
Line 327: |
|
if (preg_match("/^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20)=/i", $templatesplit)) { |
|
if (preg_match("/^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20)=/i", $templatesplit)) { |
|
echo "\nNumbered parameter(s):" . $templatesplit; |
|
echo "\nNumbered parameter(s):" . $templatesplit; |
|
$templatesplit = str_replace("1=", "", $templatesplit); |
|
$templatesplit = preg_replace("/(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20)=/", "", $templatesplit); |
|
} |
|
} |
|
$otherpage .= $templatesplit . "|"; |
|
$otherpage .= $templatesplit . "|"; |
Line 276: |
Line 344: |
|
$pagecontents = ""; |
|
$pagecontents = ""; |
|
|
|
|
|
if (strpos($otherpages,"#")) { |
|
if (str_replace ("_"," ",$otherpages) != $otherpages) { |
|
|
echo "\n$otherpages has underscores\n"; |
|
|
$pos = strpos($ptemplate, $otherpages); |
|
|
$otherpages = str_replace ("_"," ",$otherpages); |
|
|
if ($pos !== false) { |
|
|
$new_template = substr_replace($ptemplate, $otherpages, $pos, strlen($otherpages)); |
|
|
$pcontents = str_replace($ptemplate,$new_template,$pcontents); |
|
|
if ($pcontents == "") { |
|
|
echo "\n??Problem replacing underscores with spaces in merge template\n"; |
|
|
} |
|
|
else if ($objwiki->nobots($transcludes,botuser,$pcontents) == true) { |
|
|
echo "\nReplacing underscores with spaces in merge template\n"; |
|
|
$objwiki->edit($transcludes,$pcontents,"Replace underscores with spaces in merge template",true,true); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (strpos($otherpages,"#") !== false) { |
|
$len = strpos($otherpages,"#"); |
|
$len = strpos($otherpages,"#"); |
|
$mp = substr($otherpages,0,$len); // strip section links |
|
if ($len == 0) $mp = $pagename; |
|
|
else $mp = substr($otherpages,0,$len); // strip section links |
|
} |
|
} |
|
else $mp = $otherpages; |
|
else $mp = $otherpages; |
Line 287: |
Line 374: |
|
} |
|
} |
|
else if ($mp == "") { |
|
else if ($mp == "") { |
|
echo "\n**** Pagename not specified ****\n\n"; |
|
echo "\n**** Pagename not specified ****" . $ptemplate . "\n\n"; |
|
$noname += 1; |
|
$noname += 1; |
|
|
$new_template = str_replace ("||","|",$ptemplate); |
|
|
if ($new_template !== $ptemplate) { |
|
|
$pcontents = str_replace($ptemplate,$new_template,$pcontents); |
|
|
if ($pcontents == "") { |
|
|
echo "\n??Problem removing redundant pipe in merge template\n"; |
|
|
} |
|
|
else if ($objwiki->nobots($transcludes,botuser,$pcontents) == true) { |
|
|
echo "\nRemoving redundant pipe in merge template\n"; |
|
|
$objwiki->edit($transcludes,$pcontents,"Remove redundant pipe in merge template",true,true); |
|
|
} |
|
|
} |
|
} |
|
} |
|
else if (preg_match("/^(Wiktionary|Wikt):/i",$otherpages)) { |
|
else if (preg_match("/^(Wiktionary|Wikt):/i",$otherpages)) { |
Line 297: |
Line 395: |
|
else { |
|
else { |
|
while ($pagecontents == "") { |
|
while ($pagecontents == "") { |
|
if ($break == 5) { |
|
if ($break == 5) { |
|
echo "\n*** " . $pagename . ": PAGE " . $otherpages . " IS BLANK OR DOES NOT EXIST ***\n\n"; |
|
echo "\n*** " . $pagename . ": PAGE " . $otherpages . " IS BLANK OR DOES NOT EXIST ***\n\n"; |
|
$blanks = $pagename . ":: " . $otherpages; |
|
$blanks = $pagename . ":: " . $otherpages; |
|
unset($pagecontents); |
|
unset($pagecontents); |
|
$blank += 1; |
|
$blank += 1; |
|
break; |
|
break; |
|
} |
|
} |
|
else { |
|
else { |
|
|
if (preg_match("/^((User|Misplaced Pages|File|MediaWiki|Template|Help|Category|Portal|Draft)(( |_)talk)?|Talk):/", $otherpages) |
|
$pagecontents = $objwiki->getpage($otherpages); |
|
|
$break += 1; |
|
and $break == 0) { |
|
|
echo "\n\n? Other namespace: " . $otherpages . "\n\n"; |
|
} |
|
|
|
$others = $otherpages; |
|
|
$othernamespace += 1; |
|
|
} |
|
|
echo "getpage 2: $otherpages|"; |
|
|
$pagecontents = $objwiki->getpage($otherpages); |
|
|
if (preg_match_all("/\{{2}\s?(merge|afd-merge|merging|move section)*\}{2}/i", $pagecontents, $raw2) == 0 and $break == 0) { |
|
|
echo "*** Merge tag not found on " . $otherpages . " *2*\n"; |
|
|
$no_reciprocal += 1; |
|
|
} |
|
|
$cachepage = $otherpages; |
|
|
if (isset($pagecontents)) $cachecontents = $pagecontents; |
|
|
else $cachecontents = ""; |
|
|
$break += 1; |
|
|
} |
|
} |
|
} |
|
|
|
|
|
if (preg_match("/^\#REDIRECT(\s*|:)\{2}/i", $pagecontents, $redirect)) { |
|
if (isset($pagecontents) and preg_match("/^\#REDIRECT(\s*|:)\{2}/i", $pagecontents, $redirect)) { |
|
echo "\n*** " . $pagename. ": PAGE " . $otherpages . " IS A REDIRECT!! ***\n"; |
|
echo "\n*** " . $pagename. ": PAGE " . $otherpages . " IS A REDIRECT!! ***\n"; |
|
echo $pagecontents . "\n\n"; |
|
echo $pagecontents . "\n\n"; |
|
$redirects += 1; |
|
$redirects += 1; |
|
|
preg_match("/(?<=\{2}))/i", $redirect, $target); |
|
|
echo "Target: " . $target . "\n"; |
|
|
$target = ucfirst($target); |
|
|
$target = str_replace ("_"," ",$target); |
|
|
$target = trim($target); |
|
|
|
|
|
if (strpos($target,"#") !== false) { |
|
|
$len = strpos($target,"#"); |
|
|
if ($len == 0) $targetpage = $target; |
|
|
else $targetpage = substr($target,0,$len); // strip section links |
|
|
} |
|
|
else $targetpage = $target; |
|
|
|
|
|
if ($targetpage == $pagename) { |
|
|
echo $otherpages . " redirects to " . $target . " -- may have been merged\n\n"; |
|
|
$maybes = $pagename . ":: " . $otherpages; |
|
|
$maybe +=1; |
|
|
} |
|
|
else if (strtoupper($otherpages) == strtoupper($target)) { |
|
|
echo "Case difference\n"; |
|
|
$diffcases = $pagename . ":: " . $otherpages . " vs. " . $target; |
|
|
$diffcase += 1; |
|
|
$pos = strpos($ptemplate, $otherpages); |
|
|
if ($pos !== false) { |
|
|
$new_template = substr_replace($ptemplate, $target, $pos, strlen($otherpages)); |
|
|
$pcontents = str_replace($ptemplate,$new_template,$pcontents); |
|
|
if ($pcontents == "") { |
|
|
echo "\n??Problem bypassing redirect in merge template – DIFFCAPS\n"; |
|
|
} |
|
|
else if ($objwiki->nobots($transcludes,botuser,$pcontents) == true) { |
|
|
echo "\nBypassing redirect in merge template – DIFFCAPS\n"; |
|
|
$objwiki->edit($transcludes,$pcontents,"Bypass redirect in merge template – DIFFCAPS",true,true); |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
echo "getpage 4: $targetpage|"; |
|
|
$pagecontents = $objwiki->getpage($targetpage); |
|
|
if (preg_match_all("/\{{2}\s?(merge|afd-merge|merging|move section)*\}{2}/i", $pagecontents, $raw4) == 0) { |
|
|
echo "*** Merge tag not found on target page " . $targetpage. " *4*\n"; |
|
|
$redir_no_reciprocals = $pagename . ":: " . $otherpages; |
|
|
$redir_no_reciprocal += 1; |
|
|
} |
|
|
else { |
|
|
echo "*** Merge tag found on target page " . $targetpage. " *4* " . $raw4 . "\n"; |
|
|
$pos = stripos($raw4,$pagename); |
|
|
if ($pos === false) { |
|
|
echo " ** " . $pagename . " not found!\n"; |
|
|
$other_redirects = $pagename . ":: " . $otherpages; |
|
|
$other_redirect += 1; |
|
|
} |
|
|
else { |
|
|
echo " ** found " . $pagename . "\n"; |
|
|
$pages_moved = $pagename . ":: " . $otherpages; |
|
|
$page_moved += 1; |
|
|
$pos = strpos($ptemplate, $otherpages); |
|
|
if ($pos !== false) { |
|
|
$new_template = substr_replace($ptemplate, $target, $pos, strlen($otherpages)); |
|
|
$pcontents = str_replace($ptemplate,$new_template,$pcontents); |
|
|
echo "\n$pcontents\n"; |
|
|
if ($pcontents == "") { |
|
|
echo "\n??Problem bypassing redirect in merge template – apparently " . $otherpages . |
|
|
" moved to " . $target . "\n"; |
|
|
} |
|
|
else if ($objwiki->nobots($transcludes,botuser,$pcontents) == true) { |
|
|
echo "\nBypassing redirect in merge template – apparently " . $otherpages . " moved to " . $target . "\n"; |
|
|
$objwiki->edit($transcludes,$pcontents,"Bypass redirect in merge template – apparently " . |
|
|
$otherpages . " moved to " . $target,true,true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
} |
|
} |
|
} |
|
} |
Line 337: |
Line 522: |
|
} |
|
} |
|
else { |
|
else { |
|
$pagecontents = $objwiki->getpage($otherpages); |
|
if ($otherpages == $cachepage) { |
|
|
echo "getpage 3: $otherpages|from cache\n"; |
|
|
$pagecontents = $cachecontents; |
|
|
} |
|
|
else { |
|
|
echo "getpage 3: $otherpages|"; |
|
|
$pagecontents = $objwiki->getpage($otherpages); |
|
|
if (preg_match_all("/\{{2}\s?(merge|afd-merge|merging|move section)*\}{2}/i", $pagecontents, $raw3) == 0) { |
|
|
echo "*** Merge tag not found on " . $otherpages. " *3*\n"; |
|
|
$no_reciprocal += 1; |
|
|
} |
|
|
} |
|
$break += 1; |
|
$break += 1; |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
if (preg_match_all("/\{{2}\s?(merge|afd-merge|merging|move section)*\}{2}/i", $pagecontents, $raw) == 0) { |
|
if (isset($pagecontents) and preg_match_all("/\{{2}\s?(merge|afd-merge|merging|move section)*\}{2}/i", $pagecontents, $raw) !== 0) { |
|
|
$reciprocal = FALSE; |
|
echo "\n*** Merge tag not found on " . $otherpages. " ***\n"; |
|
|
|
for ($jraw = 0; $jraw < count($raw); $jraw++) { |
|
$no_reciprocal += 1; |
|
|
|
echo "(" . $jraw . ") " . $raw; |
|
} |
|
|
|
$pos = stripos($raw,$pagename); |
|
else { |
|
|
|
if ($pos === false) { |
|
echo "mergeto target: " . $otherpage . " ◆ " . $otherpages; |
|
|
echo " . "]\n"; |
|
echo " ** " . $pagename . " not found!"; |
|
unset($pagename); |
|
} |
|
unset($type); |
|
else { |
|
|
echo " ** found " . $pagename; |
|
$takeofflater += 1; |
|
|
|
$reciprocal_template = templateprocess($raw); |
|
continue; |
|
|
|
echo "\n§ " . $reciprocal_template . " § "; |
|
|
$reciprocal_templatesplit = array_map('trim',explode("|", $reciprocal_template)); |
|
|
echo $reciprocal_templatesplit; |
|
|
switch ($reciprocal_templatesplit) { |
|
|
case "merge": |
|
|
echo "\n% Reciprocal direction not specified\n"; |
|
|
$no_directions = $pagename . " ==> " . $otherpages; |
|
|
$no_direction += 1; |
|
|
case "mergefrom": |
|
|
case "false-positive": |
|
|
$reciprocal = TRUE; |
|
|
break; |
|
|
case "mergeto": |
|
|
echo "\n!! Conflicting tags !!\n"; |
|
|
$conflicts = $pagename . " <===> " . $otherpages; |
|
|
$conflict += 1; |
|
|
break; |
|
|
default: |
|
|
echo "\n!! Unexpected: " . $templatesplit; |
|
|
} |
|
|
} |
|
|
} |
|
|
if ($reciprocal == FALSE) { |
|
|
echo "\n*** Reciprocal merge tag not found on " . $otherpages. " ***\n"; |
|
|
$no_reciprocal += 1; |
|
|
} |
|
|
else { |
|
|
echo "\n"; |
|
|
echo "mergeto target: " . $otherpage . " ◆ " . $otherpages; |
|
|
echo " . "]\n"; |
|
|
unset($pagename); |
|
|
unset($type); |
|
|
$takeofflater += 1; |
|
|
continue; |
|
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
|
if (!array_key_exists($key, $discuss)) { // ($discuss == "") |
|
|
|
|
if ($discuss == "") { |
|
|
if (preg_match("/^(User|Misplaced Pages|Image|File|MediaWiki|Template|Help|Category|Portal):/i",$transcludes,$m)) { |
|
if (preg_match("/^(User|Misplaced Pages|Image|File|MediaWiki|Template|Help|Category|Portal):/i",$transcludes,$m)) { |
|
$discuss = str_replace($m,$m.' talk',$transcludes); |
|
$discuss = str_replace($m,$m.' talk',$transcludes); |
Line 392: |
Line 622: |
|
|
|
|
|
foreach ($pagename as $key => $title) { |
|
foreach ($pagename as $key => $title) { |
|
if ($counter] > $maxcounter) { |
|
if (array_key_exists($date, $counter) and $counter] > $maxcounter) { |
|
$maxcounter = $counter]; |
|
$maxcounter = $counter]; |
|
} |
|
} |
|
|
if (!array_key_exists($date, $submission)) $submission] = ""; |
|
|
if (!array_key_exists($key, $reason)) $reason = ""; |
|
|
|
|
|
switch ($type) { |
|
switch ($type) { |
|
case "with": // regular merge |
|
case "with": // regular merge |
|
if ($target != "") { |
|
if (array_key_exists($key, $target)) { // ($target != "") |
|
$submission] .= "{{merge log entry|1=]|2=$otherpage|3=]]|talk=$discuss|type=with}}\n"; |
|
$submission] .= |
|
|
"{{merge log entry|1=]|2=$otherpage|3=]]|talk=$discuss|type=with|reason=$reason}}\n"; |
|
} |
|
} |
|
else { |
|
else { |
|
$submission] .= "{{merge log entry|1=]|2=$otherpage|talk=$discuss|type=with}}\n"; |
|
$submission] .= "{{merge log entry|1=]|2=$otherpage|talk=$discuss|type=with|reason=$reason}}\n"; |
|
} |
|
} |
|
break; |
|
break; |
|
case "into": // merge-from |
|
case "into": // merge-from |
|
$submission] .= "{{merge log entry|1=$otherpage|2=]|talk=$discuss|type=into}}\n"; |
|
$submission] .= "{{merge log entry|1=$otherpage|2=]|talk=$discuss|type=into|reason=$reason}}\n"; |
|
break; |
|
break; |
|
case "to": // merge-to |
|
case "to": // merge-to |
|
$submission] .= "{{merge log entry|1=]|2=$otherpage|talk=$discuss|type=into}}\n"; |
|
$submission] .= "{{merge log entry|1=]|2=$otherpage|talk=$discuss|type=into|reason=$reason}}\n"; |
|
break; |
|
break; |
|
case "to ?": // no partner |
|
case "to ?": // no partner |
|
$submission] .= "{{merge log entry|1=]|2=?|talk=$discuss|type=into}}\n"; |
|
$submission] .= "{{merge log entry|1=]|2=?|talk=$discuss|type=into|reason=$reason}}\n"; |
|
break; |
|
break; |
|
default: |
|
default: |
|
echo "\n*error* " . $type . "\n"; |
|
echo "\n*error* " . $type . "\n"; |
|
|
break; // use "continue 2"? |
|
continue; |
|
|
} |
|
} |
|
|
|
|
|
|
|
$counter] += 1; |
|
if (array_key_exists($date, $counter)) $counter] += 1; |
|
|
else $counter] = 1; |
|
echo $date . " | " . $counter] . ") " . $key . " ++ " . $title. "\n"; |
|
echo $date . " | " . $counter] . ") " . $key . " ++ " . $title. "\n"; |
|
} |
|
} |
Line 426: |
Line 660: |
|
|
|
|
|
foreach ($submission as $log => $content) { |
|
foreach ($submission as $log => $content) { |
|
echo "Updating> " . $log. "\n"; |
|
if ($log != "") { |
|
|
echo "Updating> " . $log. "\n"; |
|
#echo $content . "\n"; |
|
#echo $content . "\n"; |
|
$objwiki->edit("Misplaced Pages:Proposed mergers/Log/" . $log,$content,"Updating list of proposed mergers",false,true); |
|
$objwiki->edit("Misplaced Pages:Proposed mergers/Log/" . $log,$content,"Updating list of proposed mergers",false,true); |
|
|
} |
|
|
else echo "\n? Error, null log specification: " . $content . "\n\n"; |
|
} |
|
} |
|
|
|
|
Line 445: |
Line 682: |
|
print_r($nosplits); |
|
print_r($nosplits); |
|
echo "\nNo partner: " . $nopartner . "\n"; |
|
echo "\nNo partner: " . $nopartner . "\n"; |
|
print_r($nopartners); |
|
if ($nopartner > 0) print_r($nopartners); |
|
|
echo "\nReciprocal direction not specified: " . $no_direction . "\n"; |
|
|
if ($no_direction > 0) print_r($no_directions); |
|
|
echo "\nConflicting tags: " . $conflict . "\n"; |
|
|
if ($conflict > 0) print_r($conflicts); |
|
echo "\nPages with multiple proposal dates: " . $mismatched_date . "\n"; |
|
echo "\nPages with multiple proposal dates: " . $mismatched_date . "\n"; |
|
print_r($mismatched_dates); |
|
if ($mismatched_date > 0) print_r($mismatched_dates); |
|
echo "\nPages where reasons are given in the template: " . $reason_count . "\n"; |
|
echo "\nPages where reasons are given in the template: " . $reason_count . "\n"; |
|
print_r($reasons); |
|
if ($reason_count > 0) print_r($reasons); |
|
echo "\nOther pages which are blank or don't exist: " . $blank . "\n"; |
|
echo "\nOther pages which are blank or don't exist: " . $blank . "\n"; |
|
print_r($blanks); |
|
if ($blank > 0) print_r($blanks); |
|
echo "\nOther pages which are redirects: " . $redirects . "\n"; |
|
echo "\nOther pages which are redirects: " . $redirects; |
|
|
echo "\n Maybe merged: " . $maybe . "\n"; |
|
|
if ($maybe > 0) print_r($maybes); |
|
|
echo "\n Cases differ: " . $diffcase . "\n"; |
|
|
if ($diffcase > 0) print_r($diffcases); |
|
|
echo "\n Pages moved: " . $page_moved . "\n"; |
|
|
if ($page_moved > 0) print_r($pages_moved); |
|
|
echo "\n Other redirects: " . $other_redirect . "\n"; |
|
|
if ($other_redirect > 0) print_r($other_redirects); |
|
|
echo "\n Redirect with no reciprocal tags: " . $redir_no_reciprocal . "\n"; |
|
|
print_r($redir_no_reciprocals); |
|
echo "\nMerge-to targets without reciprocal merge tags: " . $no_reciprocal . "\n"; |
|
echo "\nMerge-to targets without reciprocal merge tags: " . $no_reciprocal . "\n"; |
|
echo "\nSelf-merges: " . $selfmerge . "\n"; |
|
echo "\nSelf-merges: " . $selfmerge . "\n"; |
|
|
echo "\nSpecified |target is the page itself: " . $targetself . "\n"; |
|
echo "\nNo name specified: " . $noname . "\n"; |
|
echo "\nNo name specified: " . $noname . "\n"; |
|
echo "\nWiktionary merges: " . $wikt . "\n"; |
|
echo "\nWiktionary merges: " . $wikt . "\n"; |
Line 460: |
Line 712: |
|
|
|
|
|
?> |
|
?> |
|
|
</syntaxhighlight> |
|
</source> |
|