Jump to content

User:Sambot/Code/Baseball

From Wikipedia, the free encyclopedia
<?php

include('pillar/class.pillar.php');

$pillar = Pillar::ini_launch('baseball.ini');

LoopThrough::embedded('Template:Baseball-reference','baseballstats','registry.txt');

function baseballstats($title) {
    try {
        $page = new Page ($title);
    } catch (PillarException $e) {
        return false;
    }
    
    $template = new Template($page->get_text(),'baseball-reference');
    
    $template->rename('baseballstats');
    
    $template->renamefield('id','br');
    
    $text = $template->wholePage();
    
    try {
        $page->put($text,'BOT: Migrating {{baseball-reference}} to {{baseballstats}}',true);
    } catch (PillarActionCancelled $e) {
        return true;
    } catch (PillarException $e) {
        return false;
    }
}