00001
00002 #include <fstream>
00003 #include <sstream>
00004 #include <iostream>
00005 #include <iomanip>
00006
00007 #include "ocString.h"
00008 #include "ocFileSys.h"
00009 #include "connectstring"
00010 #include "openDB.hpp"
00011
00012 #define DO_OPEN_LOGGING
00013 #include "openLogger.h"
00014 #include "ocImportParser.h"
00015 #include "read_write_base.hpp"
00016 #include "SysImportFixup.h"
00017 #include "../../webconsole/metasite_source/global_content.hpp"
00018 #include "../../webconsole/metasite_source/templates.hpp"
00019 #define SUPPRESS_LINK_CREATION
00020 #include "../../webconsole/metasite_source/page.hpp"
00021 #include "link.hpp"
00022 #include "../../webconsole/metasite_source/menu.hpp"
00023 #include "../../webconsole/metasite_source/menu_item.hpp"
00024 #include "page_menus.hpp"
00025 #include "../../webconsole/metasite_source/paragraph.hpp"
00026 using namespace std;
00027
00028 string condition( ocString input )
00029 {
00030 return input.replaceAll("\"","\"\"");
00031 }
00032
00033 void exportGlobalContent( long long site_id )
00034 {
00035 global_content bobj;
00036 ocString whereClause = " site_id = ";
00037 whereClause.append(site_id);
00038 cout << " global_content get with " << whereClause << endl;
00039 if( bobj.get_data(whereClause))
00040 {
00041 cout << "opening Global.csv" << endl;
00042
00043 ofstream outFile( "Global.csv" );
00044 do
00045 { cout << ".";
00046 outFile << bobj.id << ",\""
00047 << condition(bobj.name) << "\",\""
00048 << condition(bobj.content) << "\"" << endl;
00049 }while(bobj.next()) ;
00050 outFile.close();
00051 cout << "done" << endl;
00052 }
00053 else
00054 {
00055 cout << bobj.last_result();
00056 }
00057 }
00058 void exportTemplates( long long site_id )
00059 {
00060 Template bobj;
00061 ocString whereClause = " site_id = ";
00062 whereClause.append(site_id);
00063 cout << " templates get with " << whereClause << endl;
00064 if( bobj.get_data(whereClause))
00065 {
00066 cout << "opening Templates.csv" << endl;
00067
00068 ofstream outFile( "Templates.csv" );
00069 do
00070 { cout << ".";
00071 outFile << bobj.id << ",\""
00072 << condition(bobj.name) << "\",\""
00073 << condition(bobj.path) << "\"" << endl;
00074 }while(bobj.next()) ;
00075 outFile.close();
00076 cout << "done" << endl;
00077 }
00078 else
00079 {
00080 cout << bobj.last_result();
00081 }
00082 }
00083 void exportPages( long long site_id )
00084 {
00085 page bobj;
00086 ocString whereClause = " site_id = ";
00087 whereClause.append(site_id);
00088 cout << " page get with " << whereClause << endl;
00089 if( bobj.get_data(whereClause))
00090 {
00091 cout << "opening Page.csv" << endl;
00092
00093 ofstream outFile( "Page.csv" );
00094 do
00095 { cout << ".";
00096
00097
00098
00099
00100
00101
00102
00103
00104 outFile << bobj.id << ","
00105 << bobj.template_id << ",\""
00106 << condition(bobj.name) << "\",\""
00107 << condition(bobj.url) << "\",\""
00108 << condition(bobj.meta_description) << "\"" << endl;
00109 }while(bobj.next()) ;
00110 outFile.close();
00111 cout << "done" << endl;
00112 }
00113 else
00114 {
00115 cout << bobj.last_result();
00116 }
00117 }
00118
00119 void exportLinks( long long site_id )
00120 {
00121 links_Obj bobj;
00122 ocString whereClause = " site_id = ";
00123 whereClause.append(site_id);
00124 cout << " link get with " << whereClause << endl;
00125 if( bobj.get_data(whereClause))
00126 {
00127 cout << "opening Link.csv" << endl;
00128
00129 ofstream outFile( "Link.csv" );
00130 do
00131 { cout << ".";
00132 outFile << bobj.id << ",\""
00133 << condition(bobj.name) << "\",\""
00134 << condition(bobj.url) << "\",\""
00135 << condition(bobj.target) << "\"" << endl;
00136 }while(bobj.next()) ;
00137 outFile.close();
00138 cout << "done" << endl;
00139 }
00140 else
00141 {
00142 cout << bobj.last_result();
00143 }
00144 }
00145 void exportMenus( long long site_id )
00146 {
00147 menu bobj;
00148 ocString whereClause = " site_id = ";
00149 whereClause.append(site_id);
00150 cout << " menu get with " << whereClause << endl;
00151 if( bobj.get_data(whereClause))
00152 {
00153 cout << "opening Menu.csv" << endl;
00154
00155 ofstream outFile( "Menu.csv" );
00156 do
00157 { cout << ".";
00158 outFile << bobj.id << ",\""
00159 << condition(bobj.name) << "\""
00160 << endl;
00161 }while(bobj.next()) ;
00162 outFile.close();
00163 cout << "done" << endl;
00164 }
00165 else
00166 {
00167 cout << bobj.last_result();
00168 }
00169 }
00170 void exportMenuItems( long long site_id )
00171 {
00172 menu_item bobj;
00173 ocString whereClause = " site_id = ";
00174 whereClause.append(site_id);
00175 cout << " menu_item get with " << whereClause << endl;
00176 if( bobj.get_data(whereClause))
00177 {
00178 cout << "opening MenuItem.csv" << endl;
00179
00180 ofstream outFile( "MenuItem.csv" );
00181 do
00182 { cout << ".";
00183 outFile << bobj.id << ","
00184 << bobj.menu_id << ","
00185 << bobj.link_id << ",\""
00186 << condition(bobj.template_tag) << "\",\""
00187 << condition(bobj.locate_tag) << "\",\""
00188 << condition(bobj.target_tag) << "\",\""
00189 << condition(bobj.label_tag) << "\","
00190 << bobj.place_order << ","
00191 << bobj.place_level << endl;
00192 }while(bobj.next()) ;
00193 outFile.close();
00194 cout << "done" << endl;
00195 }
00196 else
00197 {
00198 cout << bobj.last_result();
00199 }
00200 }
00201 void exportPageMenus( long long site_id )
00202 {
00203 page_menus_Obj bobj;
00204 ocString whereClause = " site_id = ";
00205 whereClause.append(site_id);
00206 cout << " page_menu get with " << whereClause << endl;
00207 if( bobj.get_data(whereClause))
00208 {
00209 cout << "opening PageMenu.csv" << endl;
00210
00211 ofstream outFile( "PageMenu.csv" );
00212 do
00213 { cout << ".";
00214 outFile << bobj.id << ","
00215 << bobj.menu_id << ","
00216 << bobj.page_id << ","
00217 << bobj.place_order << ","
00218 << bobj.collapsible << endl;
00219 }while(bobj.next()) ;
00220 outFile.close();
00221 cout << "done" << endl;
00222 }
00223 else
00224 {
00225 cout << bobj.last_result();
00226 }
00227 }
00228
00229 void exportParagraphs( long long site_id )
00230 {
00231 paragraph bobj;
00232 ocString whereClause = " site_id = ";
00233 whereClause.append(site_id);
00234 cout << " paragraph get with " << whereClause << endl;
00235 if( bobj.get_data(whereClause))
00236 {
00237 cout << "opening Paragraph.csv" << endl;
00238
00239 ofstream outFile( "Paragraph.csv" );
00240 do
00241 { cout << ".";
00242
00243 outFile << bobj.id << ","
00244 << bobj.page_id << ","
00245 << bobj.place_order << ",\""
00246 << condition(bobj.template_tag) << "\",\""
00247 << condition(bobj.replace_tag) << "\",\""
00248 << condition(bobj.name) << "\",\""
00249 << condition(bobj.content) << "\"" << endl;
00250 }while(bobj.next()) ;
00251 outFile.close();
00252 cout << "done" << endl;
00253 }
00254 else
00255 {
00256 cout << bobj.last_result();
00257 }
00258 }
00259
00260 int main( int argc, char** argv )
00261 {
00262
00263
00264
00265
00266
00267 if( argc > 1 )
00268 {
00269
00270 long long site_id = atoll(argv[1]);
00271
00272 exportGlobalContent( site_id );
00273
00274 exportTemplates( site_id );
00275
00276 exportPages( site_id );
00277
00278 exportLinks( site_id );
00279
00280 exportMenus( site_id );
00281
00282 exportMenuItems( site_id );
00283
00284 exportPageMenus( site_id );
00285
00286 exportParagraphs( site_id );
00287 }
00288
00289
00290
00291 return 0;
00292 }
00293
00294 #include "read_write_base.cpp"