Beispiel #1
0
function admExportPagesAnswer(&$session)
{
    global $export_pattern, $export_exists, $export_type, $export_export, $export_preview;
    $session->trace(TC_Gui1, 'admExportPagesAnswer');
    $message = null;
    if (isset($export_export)) {
        if (empty($export_pattern)) {
            $message = '+++ kein Suchmuster angegeben';
        } else {
            $page_list = dbIdList($session, T_Page, admBuildCondition($session, $export_pattern));
            if (!($file = fopen(FN_PageExport, 'w'))) {
                $message = 'kann Datei nicht öffnen: ' . FN_PageExport;
            } else {
                $prefix = $session->fDbTablePrefix;
                fputs($file, '/* Export ' . "\n" . 'am: ' . strftime("%Y.%m.%d %H:%M:%S") . "\n" . 'von: ' . $session->fUserName . "\n" . 'Modus: ' . $export_type . "\n" . 'Prefix: ' . $prefix . "\n" . 'Seiten: ' . implode(', ', $page_list) . "\n" . "*/\n");
                foreach ($page_list as $ii => $page_id) {
                    $page = dbGetRecordById($session, T_Page, $page_id, 'name,type,readgroup,writegroup');
                    $text_id = dbSingleValue($session, 'select max(id) from ' . dbTable($session, T_Text) . ' where page=' . (0 + $page_id));
                    $text = dbGetRecordById($session, T_Text, $text_id, 'type,createdby,createdat,text');
                    if ($export_type == 'insert') {
                        fputs($file, 'insert into ' . $prefix . 'page(id,name,type,readgroup,writegroup) values (' . (0 + $page_id) . ',' . dbSqlString($session, $page[0]) . ',' . dbSqlString($session, $page[1]) . ',' . (0 + $page[2]) . ',' . (0 + $page[3]) . ');' . "\n");
                        fputs($file, 'insert into ' . $prefix . 'text(page,type,createdby,createdat,text) values (' . (0 + $page_id) . ',' . dbSqlString($session, $text[0]) . ',' . dbSqlString($session, $text[1]) . ',' . dbSqlString($session, $text[2]) . ',' . dbSqlString($session, $text[3]) . ');' . "\n");
                    } else {
                        fputs($file, '/* Seite ' . $page[0] . "*/\n");
                        fputs($file, '/* delete from ' . $prefix . dbTable($session, T_Text) . ' where page=' . $page_id . ';' . "\n*/\n");
                        fputs($file, 'update ' . $prefix . 'page set type=' . dbSqlString($session, $page[1]) . ' where name=' . dbSqlString($session, $page[0]) . ';' . "\n");
                        fputs($file, 'insert into ' . $prefix . 'text(page,createdby,createdat,text) values (' . (0 + $page_id) . ',' . dbSqlString($session, $text[0]) . ',' . dbSqlString($session, $text[1]) . ',' . dbSqlString($session, $text[2]) . ',' . dbSqlString($session, $text[3]) . ');' . "\n");
                    }
                }
                fclose($file);
                $export_exists = FN_PageExport;
                $message = 'Datei ' . FN_PageExport . ' wurde exportiert';
            }
        }
    }
    admExportPages($session, $message);
}
Beispiel #2
0
function admExportPagesAnswer(&$session)
{
    $session->trace(TC_Gui1, 'admExportPagesAnswer');
    $message = null;
    if (isset($_POST['export_export'])) {
        if (empty($_POST['export_pattern'])) {
            $message = '+++ kein Suchmuster angegeben';
        } else {
            $page_list = dbIdList($session, T_Page, admBuildCondition($session, $_POST['export_pattern']));
            $fn = $session->fullPath("import", true) . FN_PageExport;
            if (!($file = fopen($fn, 'w'))) {
                $message = 'kann Datei nicht öffnen: ' . $fn;
            } else {
                $prefix = $session->fDbTablePrefix;
                fputs($file, '# Export ' . "\n" . '# am: ' . strftime("%Y.%m.%d %H:%M:%S") . "\n" . '# von: ' . $session->fUserName . "\n" . '# Modus: ' . $_POST['export_type'] . "\n" . '# Prefix: ' . $prefix . "\n" . '# Muster: ' . $_POST['export_pattern'] . "\n" . '# Seiten: ' . implode(', ', $page_list) . "\n" . "\n");
                $count = 0;
                foreach ($page_list as $ii => $page_id) {
                    $count++;
                    $page = dbGetRecordById($session, T_Page, $page_id, 'name,type');
                    $text_id = dbSingleValue($session, 'select max(id) from ' . dbTable($session, T_Text) . ' where page=' . (0 + $page_id));
                    $text = dbGetRecordById($session, T_Text, $text_id, 'type,createdby,createdat,text');
                    if ($_POST['export_type'] == 'wiki') {
                        fputs($file, "\n#name=" . $page[0] . "\tlines=" . (1 + substr_count($text[3], "\n")) . "\ttype=" . $text[0] . "\tpage=" . $page_id . "\ttext=" . $text_id . "\tby=" . $text[1] . "\tat=" . $text[2] . "\n");
                        fputs($file, $text[3]);
                    }
                }
                fclose($file);
                $_POST['export_exists'] = $fn;
                $message = 'Datei ' . $fn . ' wurde exportiert: ' . ($count + 0) . " Seite(n)";
            }
        }
    }
    admExportPages($session, $message);
}