00001
00002
00003
00004
00005
00006
00007
00008 #include <iostream>
00009 #include <iomanip>
00010 #include "cgiTemplates.h"
00011 #include "connectstring"
00012 #include "forms.h"
00013 #include "ocTypes.h"
00014 #include "ocString.h"
00015 #include "richForm.hpp"
00016 #include "list_base.hpp"
00017 #include "cgiTemplates.h"
00018 #include "openLogin.h"
00019 #include "read_write_base.hpp"
00020
00021 using namespace std;
00022 openLogin oLogin;
00023
00024 class global_content: public read_write_base
00025 {
00026 public:
00027 identifier id;
00028 long long site_id;
00029 string name;
00030 string content;
00031
00032 global_content():read_write_base(),id(0LL),name("top")
00033 {
00034
00035 data_name("metasite.global_content");
00036
00037 addDXMap( new llongXfer("id", &id ));
00038 addDXMap( new llongXfer("site_id", &site_id ));
00039 addDXMap( new stringXfer("name", &name ));
00040 addDXMap( new stringXfer("content", &content ));
00041 }
00042 };
00043
00044 class global_content_form: public global_content, public richForm
00045 {
00046 public:
00047 global_content_form(cgiScript & script):global_content(),richForm(script){setKey(*this);}
00048 virtual ~global_content_form(){;}
00049
00050 void form_id_transfer( void )
00051 {
00052 llongFXfer( "id", id );
00053 }
00054
00055 void form_data_transfer( void )
00056 {
00057
00058 llongFXfer( "site_id", site_id );
00059 stringFXfer( "name", name);
00060 stringFXfer( "content", content );
00061 }
00062
00063 bool dbf_action( string mode, changeMap & changes )
00064 {
00065 return db_action( mode, changes );
00066 }
00067
00068
00069 bool form_display( void )
00070 {
00071 bool breturn = true;
00072 ocString ssql = "select id, name from metasite.sites ";
00073 if(site_id)
00074 {
00075 ssql += "where id =";
00076 ssql.append(site_id);
00077 }
00078 script << makeTop("global_content_ui.cgi", "Global Content")
00079 << makeStaticBox("id", "id", id, "12")
00080 << makeComboBox("Site", "site_id", site_id, ssql )
00081 << makeTextBox( "Enter '<b>top</b>', '<b>end</b>', or spacer came", "name", name, "25" ) << "(Use the template name of the spacer.)"
00082 << makeTextArea( "Content","content", content, "6","80" )
00083 << makeButtons( key() );
00084 script << makeBottom( m_result ) << endl;
00085 return breturn;
00086 }
00087
00088 bool ivalidate( void )
00089 {
00090 name = ocString(name).remove("|");
00091 content = htmlDecode( content );
00092 return true;
00093 }
00094 bool uvalidate( changeMap & changes )
00095 {
00096 name = ocString(name).remove("|");
00097 content = htmlDecode( content );
00098 return true;
00099 }
00100
00101 bool ssupplemental( void )
00102 {
00103 name = ocString(name).remove("|");
00104 content = htmlFixup( content );
00105 return true;
00106 }
00107 };
00108
00109 int main( int argcount, char ** args )
00110 {
00111 cgiScript script( "text/html", false );
00112 global_content_form myFrm(script);
00113
00114 if( oLogin.testLoginStatus() )
00115 {
00116 script.closeHeader();
00117 cgiTemplates pgTemplate;
00118 pgTemplate.load("Templates/editorPane.htmp");
00119
00120 script << ocString(pgTemplate.getParagraph("top"))
00121 .replaceAll("$heading$","SITES");
00122
00123 myFrm.loadControlTemplates("Templates/child_form.htmp");
00124 myFrm.form_action();
00125 myFrm.form_display();
00126
00127 script << pgTemplate.getParagraph("bottom");
00128 }
00129 else
00130 {
00131 script.Redirect("signIn.html");
00132 }
00133 }
00134
00135
00136 #include "read_write_base.cpp"
00137 #include "forms_base.cpp"