Exemplo n.º 1
0
$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()
{
    return "\nuse args\n\n--box=box_uid for an individual box\n--userid=user_id for userid\n--user=username\n\nother options coming maybe someday \n\t\n\n";
Exemplo n.º 2
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);
}