Esempio n. 1
0
function baseEditPageAnswerSave(&$session)
{
    $session->trace(TC_Gui1, 'baseEditPageAnswerSave');
    $message2 = null;
    $message = null;
    $content = $_POST['edit_content'];
    $len = strlen($content);
    $content = textAreaToWiki($session, $content);
    $session->trace(TC_Gui1, 'baseEditPageAnswerSave: ' . $content);
    if (!isset($_POST['edit_pageid']) || $_POST['edit_pageid'] <= 0) {
        $session->trace(TC_Gui1, 'baseEditPageAnswerSave-2: ' . $_POST['edit_pagename']);
        $_POST['edit_pagename'] = normalizeWikiName($session, $_POST['edit_pagename']);
        $content = extractHtmlBody($content);
        if (empty($_POST['edit_pagename'])) {
            $message = '+++ kein Seitenname angegeben';
        } elseif (dbSingleValue($session, 'select count(*) from ' . dbTable($session, T_Page) . ' where name=' . dbSqlString($session, $_POST['edit_pagename'])) > 0) {
            $message = '+++ Seite existiert schon: ' . $_POST['edit_pagename'];
        } else {
            $read_group = 0;
            $write_group = 0;
            if (empty($_POST['edit_mimetype'])) {
                $_POST['edit_mimetype'] = M_Wiki;
            }
            $page = dbInsert($session, T_Page, 'name,type,createdat,changedat,readgroup,writegroup', dbSqlString($session, $_POST['edit_pagename']) . ',' . dbSqlString($session, $_POST['edit_mimetype']) . ',now(),now(),' . $read_group . ',' . $write_group);
            $_POST['edit_pageid'] = $page;
            $_POST['edit_textid'] = dbInsert($session, T_Text, 'page,type,text,createdby,createdat,changedat', $page + 0 . "," . dbSqlString($session, mimeToTextType($_POST['edit_mimetype'])) . ',' . dbSqlString($session, $content) . ',' . dbSqlString($session, $session->fUserName) . ',now(),now()');
            $session->trace(TC_Gui1, 'baseEditPageAnswerSave-3: ' . $page . '/' . $_POST['edit_textid']);
        }
        $message2 = $len == strlen($content) ? '' : 'Es wurde der Rumpf (body) extrahiert.';
    } else {
        $pageid = $_POST['edit_pageid'];
        $new_textid = dbGetLastText($session, $pageid);
        if ($new_textid > $_POST['edit_textidpred'] && (!isset($_POST['edit_textid']) || $new_textid > $_POST['edit_textid'])) {
            $message = "+++ Warnung: Seite wurde inzwischen geändert! " . "Bitte Differenz ermitteln und erneut eintragen! " . $new_textid . " /  " . $_POST['edit_textidpred'];
        }
        $date = dbSqlDateTime($session, time());
        if (empty($_POST['edit_textid'])) {
            $_POST['edit_textid'] = dbInsert($session, T_Text, 'page,type,createdat,changedat,createdby,text', $_POST['edit_pageid'] . ',' . dbSqlString($session, mimeToTextType($_POST['edit_mimetype'])) . ",{$date},{$date}," . dbSqlString($session, $session->fUserName) . ',' . dbSqlString($session, $content));
            dbUpdate($session, T_Text, $new_textid, 'replacedby=' . $_POST['edit_textid'] . ',');
        } else {
            dbUpdate($session, T_Text, $_POST['edit_textid'], "text=" . dbSqlString($session, $content) . ",");
        }
    }
    if (isset($_POST['edit_save']) && $message == null) {
        guiShowPageById($session, $_POST['edit_pageid'], 0);
    } else {
        baseEditPage($session, C_Auto, $message, $message2);
    }
}
Esempio n. 2
0
function baseAlterPageAnswerChangePage(&$session)
{
    global $alterpage_name, $alterpage_content, $textarea_width, $textarea_height, $alterpage_content, $alterpage_mime, $alterpage_changepage, $alterpage_changecontent, $alterpage_previe;
    $session->trace(TC_Gui1, 'baseAlterPageAnswerChangePage');
    $alterpage_name = makePageName($alterpage_name);
    $len = strlen($alterpage_content);
    $alterpage_content = extractHtmlBody($alterpage_content);
    $message = $message2 = null;
    if (empty($alterpage_name)) {
        $message = '+++ kein Seitenname angegeben';
    }
    if (($page_id = dbPageId($session, $alterpage_name)) <= 0) {
        $message = '+++ Seite nicht gefunden: ' . $alterpage_name;
    } else {
        $readgroup = $writegroup = 0;
        dbUpdate($session, T_Page, $page_id, "changedat=now(),readgroup={$readgroup},writegroup={$writegroup},");
        dbInsert($session, T_Text, 'page,type,text,createdby', $page_id . "," . dbSqlString($session, $alterpage_mime) . ',' . dbSqlString($session, $alterpage_content) . ',' . dbSqlString($session, $session->fUserName));
        $message = 'Seite ' . $alterpage_name . ' wurde geändert';
    }
    if ($len != strlen($alterpage_content)) {
        $message2 = 'Es wurde der Rumpf (body) extrahiert.';
    }
    if ($message != null) {
        baseAlterPage($session, C_Change, $message, $message2);
    } else {
        $session->SetLocation($alterpage_name);
        guiShowPage($session, $alterpage_name);
    }
}