Commit 069ca70f authored by Luke081515's avatar Luke081515

Allow to add a space per request

parent e5e8a04f
Pipeline #1817 failed with stages
in 1 minute and 42 seconds
......@@ -39,9 +39,6 @@ class Corrector extends Core {
}
$needle = $this->askOperator('What should be replaced? ');
$replace = $this->askOperator('What should be the replacement? ');
if ($this->askOperator('Add a space to the end of the replacement? [y/N] ') === 'y') {
$replace = $replace . " ";
}
$this->needle = $needle;
$this->replace = $replace;
}
......@@ -114,38 +111,45 @@ class Corrector extends Core {
$end = "\033[0m";
$htmlarr = explode("\n", $html);
while (true) {
for($i = 0; $i < count($htmlarr); $i++) {
for($i = 0; $i < count($htmlarr); $i++) {
$anzahl = substr_count($htmlarr[$i], $needle);
$anzahl = substr_count($htmlarr[$i], $needle);
if($anzahl > 0) {
// cut off long lines
if(stripos($htmlarr[$i], $needle) > 70) {
$htmlarr[$i] = substr($htmlarr[$i], stripos($htmlarr[$i], $needle) - 50);
}
if($anzahl > 0) {
// cut off long lines
if(stripos($htmlarr[$i], $needle) > 70) {
$htmlarr[$i] = substr($htmlarr[$i], stripos($htmlarr[$i], $needle) - 50);
}
if(strripos($htmlarr[$i], $needle) + strlen($needle) + 70 < strlen($htmlarr[$i])) {
$htmlarr[$i] = substr($htmlarr[$i], 0, strripos($htmlarr[$i], $needle) + strlen($needle) + 50);
}
if(strripos($htmlarr[$i], $needle) + strlen($needle) + 70 < strlen($htmlarr[$i])) {
$htmlarr[$i] = substr($htmlarr[$i], 0, strripos($htmlarr[$i], $needle) + strlen($needle) + 50);
}
$old = str_replace($needle, $red . $needle . $end, $htmlarr[$i]);
$old = str_replace($needle, $red . $needle . $end, $htmlarr[$i]);
$newstr = str_replace($needle, $new, $htmlarr[$i]);
$newstr = str_replace($new, $green . $new . $end, $newstr);
echo 'Zeile ' . ($i + 1) . ":\n– " . $old . "\n+ " . $newstr . "\n\n";
$newstr = str_replace($needle, $new, $htmlarr[$i]);
$newstr = str_replace($new, $green . $new . $end, $newstr);
echo 'Zeile ' . ($i + 1) . ":\n– " . $old . "\n+ " . $newstr . "\n\n";
}
}
}
$answer = strtoupper($this->askOperator('Replace all occurrences? [Y], [N] '));
if($this->validateAnswer($answer)) {
if($answer == 'Y') {
// Do replace
$newhtml = $this->replace($html, $needle, $new);
$this->editPage($seite, $newhtml, $this->summary);
} else {
// Leave it as it is
echo "\n" . 'Not replaced. Skipping…' . "\n";
$answer = strtoupper($this->askOperator('Replace all occurrences? [Y], [N] '));
if($this->validateAnswer($answer)) {
if($answer == 'Y') {
// Do replace
$newhtml = $this->replace($html, $needle, $new);
$this->editPage($seite, $newhtml, $this->summary);
break;
} else {
$answer = strtoupper($this->askOperator('Add a space? [Y], [N] '));
if($answer == 'Y') {
$new = $new . " ";
} else {
// Leave it as it is
echo "\n" . 'Not replaced. Skipping…' . "\n";
break;
}
}
}
}
}
......
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