Commit d969a215 authored by ~rs's avatar ~rs

added subcategories

parents 75e2f749 d0de7448
......@@ -3,7 +3,11 @@
include './Core/BotCore.php';
/** SortCat.php
<<<<<<< HEAD
* Sortiere die Subkategorien einer Kategorie.
=======
* Sortiere eine Kategorie.
>>>>>>> d0de74489803ea53c008a3a5cdce95ec54178750
* Nach MoveIt.php von Freddy2001 <freddy2001@wikipedia.de>
* @Author KPFC
* @Version 0.1
......@@ -14,6 +18,7 @@ class SortCat extends Core {
$this->initcurl($Account, $Job, $pUseHTTPS = true);
// Bitte hier die Kategorie, die sortiert werden soll angeben
<<<<<<< HEAD
$cat = "Two-colored roses";
$target = "Category:" . $cat;
echo "---SortCat---\nDurchlauf: " . date('l jS F Y H:i:s') . "\nTarget: " . $target . "---\n";
......@@ -78,6 +83,64 @@ class SortCat extends Core {
}
if ($ds==='q'||$cont==='q') {
break;
=======
$cat = "Pink roses";
// Bitte hier die neue Kategorie angeben
$target = "Category:" . $cat;
echo "---SortCat---\nDurchlauf: " . date('l jS F Y H:i:s') . "\nTarget: " . $target . "---\n";
$pages = $this->getCatMembers($target, true, true);
print_r($pages);
for($i = 0; count($pages) > $i; $i++) {
$page = $pages[$i];
$pagecontent = $this->readPage($page);
$oldpagecontent = $pagecontent;
echo "\n" . $page . "\n";
$page = str_replace("Category:", "", $page);
//things to be trimmed
$page = str_replace("Rosa", "", $page);
$page = trim($page);
$page = trim($page, '\'');
$page = str_replace('\' (', " ", $page);
$page = str_replace("(","", $page);
$page = str_replace(")", "", $page);
/* $page = str_replace("ä", "a", $page);
$page = str_replace("ö", "o", $page);
$page = str_replace("ü", "u", $page); */
$page = trim($page);
//either sort one category by another or use defaultsort
//if the category is already sorted it skips; if not, it will use DEFAULTSORT; if this is already with another sorting, it will use a |-sorting
if (!(strstr($pagecontent, "Category:" . $cat . "|" . $page)||strstr($pagecontent, "{{DEFAULTSORT:$page"))&&strstr($pages[$i], "Rosa")) {
if (strstr($pagecontent, "{{DEFAULTSORT:")) {
preg_match("~({{DEFAULTSORT:.*}})~", $pagecontent, $dfs);
echo "-: " . $dfs[1] . "\n";
echo "+: {{DEFAULTSORT:" . $page . "}}\n";
$ds = $this->askOperator("Use new defaultsort? [y/N/a/q]");
if ($ds==='y') {
$pagecontent = str_replace($dfs[1] . "\n", "", $pagecontent);
$pagecontent = "{{DEFAULTSORT:" . $page . "}}\n" . $pagecontent;
} else if ($ds==='q') {
break;
} else if ($ds!=='a') {
$pagecontent = str_replace ("[[Category:" . $cat . "]]", "[[Category:" . $cat . "|" . $page . "]]", $pagecontent);
}
} else {
$pagecontent = "{{DEFAULTSORT:" . $page . "}}\n" . $pagecontent;
}
}
if ($pagecontent!==$oldpagecontent) {
$summary = "Sort";
echo "\n---\n";
print_r($oldpagecontent);
echo "\n+++\n";
print_r($pagecontent);
$cont = $this->askOperator("\nsave? [y/N/q]");
if ($cont==='q') {
break;
} else if ($cont==='y') {
$this->editPageMinor($pages[$i], $pagecontent, $summary);
sleep(0);
}
>>>>>>> d0de74489803ea53c008a3a5cdce95ec54178750
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment