Commit af19efed authored by ~rs's avatar ~rs

Update EditInEditor.php

parent 70605007
Pipeline #1925 passed with stages
in 1 minute and 43 seconds
#!/usr/bin/php
<?php
require './Core/BotCore.php';
//require './Diff/src/DiffOpFactory.php';
# commented out: show diff before saving
# require './vendor/autoload.php';
/** EditInEditor.php
* Opens a page in a user-defined editor and saves the page after closing the editor
* @Author KPFC
......@@ -9,8 +10,8 @@ require './Core/BotCore.php';
* @Status Alpha
*/
class EditInEditor extends Core {
public function __construct ($Account, $Job, $pUseHTTPS = true, $botflag, $pagename, $minor = false, $fast = false) {
$this->initcurl($Account, $Job, $pUseHTTPS); //login
public function __construct ($Account, $Job, $pUseHTTPS = true, $botflag, $pagename, $minor = false, $fast = false) {
$this->initcurl($Account, $Job, $pUseHTTPS, "user"); //login
$editor = 'code'; //change this as you like
$pagecontent = $this->readPage($pagename);
//create temporary file to edit
......@@ -18,24 +19,23 @@ class EditInEditor extends Core {
fwrite(fopen($page_tmp, 'a+'), $pagecontent);
popen($editor . ' ' . $page_tmp, "w");
$this->askOperator('Done?');
$oldcontent = $pagecontent;
$oldcontent = $pagecontent;
$pagecontent = file_get_contents($page_tmp);
//delete temporary file
unlink($page_tmp);
//save page
$diff = new DiffOpFactory;
//$diffOp = array('type' => 'change', 'newvalue' => $pagecontent, 'oldvalue' => $oldcontent);
$diffOp['type'] = 'change';
$diffOp['newvalue'] = $pagecontent;
$diffOp['oldvalue'] = $oldcontent;
if (!$fast) {
echo $diff->newFromArray($diffOp);
if ($this->askOperator('Save? [Y/n]')==='n') {
return 0;
# $differ = new \Diff\Differ\MapDiffer();
# $diff = $differ->doDiff(str_split($oldcontent), str_split($pagecontent));
if (!$fast) {
# print_r( $diff );
if ($this->askOperator('Save? [Y/n]' === 'n')) {
$not = true;
}
}
$this->editPageD($pagename, $pagecontent, $Job, $botflag, $minor, 0, false);
if (!$not) {
$this->editPageD($pagename, $pagecontent, $Job, $botflag, $minor, 0, false);
}
}
}
$Bot = new EditInEditor ('KPFC@dewiki', 'Custom-Edit', true, false, 'test', false, false); // Aufrufen der definierten Passwortdaten in Password.php
?>
?>
\ No newline at end of file
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