Exemplo n.º 1
0
     if (!$title->exists()) {
         $article->doEdit('placeholder', 'Added by wikibot to create page id', EDIT_NEW | EDIT_FORCE_BOT);
     }
     # make the table
     $box_text = make_box($data['page_name'], $data['table_template'], $data);
     # this adds the data too.
     $new_page = str_replace("{{{" . strtoupper($data['table_template']) . "}}}", $box_text, $page_template_text);
     $article->doEdit($new_page, 'Added by wikibot', EDIT_UPDATE | EDIT_FORCE_BOT);
     $change_count++;
     echo "{$line_count} lines processed: " . $data['page_name'] . " is item {$change_count}\n";
 } else {
     # page already exists.  Find the desired box
     echo $data['page_name'] . " already exists\n";
     $box_id = get_wikibox_id($data['page_name'], $data['table_template']);
     $box_uid = get_wikibox_uid($box_id);
     $box = new wikiBox();
     $box->box_uid = $box_uid;
     $box->template = $data['table_template'];
     $box->set_from_DB();
     $rows = get_wikibox_rows($box, $uid, $data['metadata']);
     if (count($rows) == 0) {
         $row = $box->insert_row('', $uid);
         $rows[] = $row->row_index;
         echo "adding new row row_index = " . $row->row_index . "\n";
         $row->db_save_row();
     }
     #print_r($rows);
     # usually this should only happen once, but it comes as an array.
     foreach ($rows as $index => $row_index) {
         $box->rows[$row_index]->row_data = $data['row_data'];
         $box->rows[$row_index]->db_save_row();
Exemplo n.º 2
0
# need to configure with paths to maintenance scripts and TableEdit
$wikiPath = "/Library/WebServer/Documents/wiki";
set_include_path(get_include_path() . PATH_SEPARATOR . $wikiPath);
$tableEditPath = "/Library/WebServer/Documents/wiki/extensions/TableEdit";
require_once "{$wikiPath}/maintenance/commandline.inc";
require_once "{$tableEditPath}/class.wikiBox.php";
require_once "{$tableEditPath}/SpecialTableEdit.body.php";
#print_r($optionsWithArgs);
#print_r($args);
#print_r($options);
if (!isset($options) || isset($options['h'])) {
    echo help();
}
if (isset($options['box'])) {
    global $wgUser;
    $box = new wikiBox($options['box']);
    $tableEdit = new TableEdit();
    $box->set_from_db();
    $title = Title::newFromID($box->page_uid);
    if (isset($options['userid'])) {
        $wgUser->setID($options['userid']);
        $wgUser->loadFromId();
    }
    $tableEdit->save_to_page($title, $box);
    #	print_r($wgUser);
    #	print_r($tableEdit);
}
# end if box
#echo "done\n";
function help()
{
Exemplo n.º 3
0
Arquivo: wiki.php Projeto: GMOD/Chado
function make_box($page_name, $template = '', $data, $fill = 1)
{
    global $db;
    $uid = 0;
    if (isset($data['owner'])) {
        $uid = $data['owner'];
    }
    $metadata = '';
    if (isset($data['metadata'])) {
        $metadata = $data['metadata'];
    }
    # identify the  box
    $box_id = get_wikibox_id($page_name, $template);
    # echo "\nbox_id:$box_id\n";
    $box_uid = get_wikibox_uid($box_id);
    # echo "box_uid:$box_uid\n";
    $box = new wikiBox();
    $box->box_uid = $box_uid;
    $box->template = $template;
    $box->set_from_DB();
    # if fill != 1, then we aren't filling a new row.  We just want the box from the database, even if it's empty.
    if ($fill == 1) {
        $rows = get_wikibox_rows($box, $uid, $metadata);
        #       echo "found rows owned by $uid and matching $metadata\n"; print_r($rows);#print_r($box->rows);echo "\n";
        if (count($rows) == 0) {
            $row = $box->insert_row('', $uid);
            $rows[] = $row->row_index;
            #echo "adding new row row_index = ".$row->row_index."\n";
        }
        #       print_r($box);
        #       print_r($rows);
        foreach ($rows as $row_index) {
            $function = "do_" . $template;
            $row_data = $box->rows[$row_index]->row_data;
            if ($box->rows[$row_index]->owner_uid == $uid) {
                $row_data = $data['row_data'];
            }
            $box->rows[$row_index]->row_data = $row_data;
            if ($box->box_id > 0) {
                $box->rows[$row_index]->row_id = insert_wikibox_row($box->rows[$row_index]);
                insert_row_metadata($box->rows[$row_index], $metadata);
            }
        }
    }
    #       print_r($box->rows);
    $tableEdit = new TableEdit();
    $table = str_replace("\\'", "'", $tableEdit->make_wikibox($box));
    return str_replace('\\n', "\n", $table);
}