/** * Interface to import/export. * * @return tempcode The interface. */ function ui() { $title = get_page_title('XML_DATA_MANAGEMENT'); require_code('form_templates'); $import_url = build_url(array('page' => '_SELF', 'type' => '_import'), '_SELF'); $import_fields = new ocp_tempcode(); $import_fields->attach(form_input_huge(do_lang_tempcode('XML_DATA'), '', 'xml', '', true)); $import_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'URL' => $import_url, 'HIDDEN' => '', 'TEXT' => do_lang_tempcode('XML_IMPORT_TEXT'), 'FIELDS' => $import_fields, 'SUBMIT_NAME' => do_lang_tempcode('IMPORT'))); $all_tables = find_all_xml_tables(); $export_url = build_url(array('page' => '_SELF', 'type' => '_export'), '_SELF'); $export_fields = new ocp_tempcode(); $nice_tables = new ocp_tempcode(); foreach ($all_tables as $table) { $nice_tables->attach(form_input_list_entry($table)); } $export_fields->attach(form_input_multi_list(do_lang_tempcode('TABLES'), do_lang_tempcode('DESCRIPTION_TABLES'), 'tables', $nice_tables, NULL, 15)); $export_fields->attach(form_input_tick(do_lang_tempcode('EXPORT_WITH_COMCODE_XML'), do_lang_tempcode('DESCRIPTION_EXPORT_WITH_COMCODE_XML'), 'comcode_xml', false)); $export_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'URL' => $export_url, 'HIDDEN' => '', 'TEXT' => do_lang_tempcode('XML_EXPORT_TEXT'), 'FIELDS' => $export_fields, 'SUBMIT_NAME' => do_lang_tempcode('EXPORT'))); return do_template('XML_STORAGE_SCREEN', array('TITLE' => $title, 'IMPORT_FORM' => $import_form, 'EXPORT_FORM' => $export_form)); }
/** * Export ocPortal database tables to an equivalent XML format, automatically. * * @param ?array List of tables to export (NULL: all tables except those skippable) * @param boolean Whether to export Comcode as Comcode XML * @return string Exported data in XML format */ function export_to_xml($tables = NULL, $comcode_xml = true) { if ($comcode_xml) { require_code('comcode_conversion'); } $GLOBALS['NO_QUERY_LIMIT'] = true; $GLOBALS['NO_DB_SCOPE_CHECK'] = true; if (is_null($tables)) { $tables = find_all_xml_tables(); } // Build up data $xml_data = ''; $xml_data .= '<!-- Exported on ' . xmlentities(date('Y-m-d h:i:s')) . ' by ' . xmlentities($GLOBALS['FORUM_DRIVER']->get_username(get_member())) . ' -->' . chr(10); $xml_data .= '<ocportal origin="' . xmlentities(get_base_url()) . '" version="' . xmlentities(float_format(ocp_version_number())) . '">' . chr(10); foreach ($tables as $table) { $table_xml = _export_table_to_xml($table, $comcode_xml); if ($table_xml != '') { $xml_data .= _tab($table_xml) . chr(10); } } $xml_data = rtrim($xml_data) . chr(10); $xml_data .= '</ocportal>' . chr(10); return $xml_data; }