Wikipedista:DaBlerBot/src: Porovnání verzí

Smazaný obsah Přidaný obsah
m aktualizace
m aktualizace
Řádek 5:
WikiBot for PHP
 
VERSION: 2010-10-0608
 
AUTHOR: [[cs:User:DaBler]]
Řádek 20:
* z "; term" odstranit tučné a italiku
* nahradit [http://cs.wikipedia.org/wiki/...] interními odkazy
* nahradit <i> a <b>
*/
 
Řádek 30 ⟶ 31:
private $token;
private $user_agent;
private $name;
 
private static $dict = array();
 
const COOKIEFILE = 'cookies.txt';
const SLEEP = 54;
 
public function __construct($base='http://cs.wikipedia.org/w/index.php', $user='DaBlerBot', $pass='heslo')
Řádek 89 ⟶ 91:
echo "Processing...\n";
$this->name = $name;
$new = self::process($page['text']);
$page['attr']['wpSummary'] = $new['summary'];
Řádek 110 ⟶ 113:
echo "Done.\n";
}
 
private function getToken()
{
Řádek 140 ⟶ 142:
 
$this->token = $matches[1];
// echo "New token: {$this->token}\n";
 
return TRUE;
Řádek 561 ⟶ 562:
'Ghz' => 'GHz',
);
 
//jednorázově
$replace += array( 'aktualní verze' => 'aktuální verze' );
 
self::$dict = $replace;
Řádek 573 ⟶ 571:
 
$sep = '[ ,\.;*#\-–—…&\(\)\/\[\]|\'{}=:<>?!"„“\n]';
//"
 
$replace = self::$dict;
Řádek 588 ⟶ 585:
}
 
private static function processfix_links_ex_cb($strm)
{
$link = $m[1];
$delim = $m[2];
$fragment = $m[3];
 
// TODO: link do čitelné podoby
$link = preg_replace("/_/m", " ", $link);
 
// TODO: fragment do čitelné podoby
$fragment = preg_replace("/_/m", " ", $fragment);
 
return "${link}${delim}${fragment}";
}
 
private function fix_links_cb($m)
{
$link = $m[1];
$delim = $m[2];
$desc = $m[3];
 
if($link === $desc)
$desc = $delim = '';
 
$link = preg_replace_callback('/^([^#]*)(#?)(.*)/', "WikiBot::fix_links_ex_cb", $link);
 
if($link === $this->name)
{
if($desc == '')
return "'''${link}'''";
else
return "'''${desc}'''";
}
else
return "[[${link}${delim}${desc}]]";
}
 
 
private function fix_links(&$str)
{
$old = $str;
 
$str = preg_replace_callback("/\\[\\[([^\\|\\]]+)(\\|?)([^\\]]+)?\\]\\]/", array($this, "fix_links_cb"), $str);
 
return !($old == $str);
}
 
 
private function process($str)
{
$summary = "[[WP:WCW]]:";
Řádek 609 ⟶ 654:
if(self::fix_orthography($str))
$summary .= " opravy pravopisu, ";
 
if(self::fix_links($str))
$summary .= " opravy odkazů, ";
 
if($str == '')