00001
00002
00003
00004
00005
00006 #include <iostream>
00007 #include <iomanip>
00008 #include "cgiTemplates.h"
00009 #include "connectstring"
00010 #include "forms.h"
00011 #include "ocTypes.h"
00012 #include "ocString.h"
00013 #include "read_write_base.hpp"
00014 #include "forms_base.hpp"
00015 #include "list_base.hpp"
00016 #include "cgiTemplates.h"
00017 #include "openLogin.h"
00018 #include "site.hpp"
00019
00020 using namespace std;
00021 openLogin oLogin;
00022
00023 class global_content_List: public list_base
00024 {
00025 public:
00026 long long site_id;
00027
00028
00029 global_content_List(cgiScript&sc, long long id):list_base(sc),site_id(id)
00030 {
00031 ;
00032 }
00033 ~global_content_List(){;}
00034
00035 bool list_display( void )
00036 {
00037 bool breturn = true;
00038 editLink = listTemplate.getParagraph("hotcolumn");
00039 editLink = editLink.replace("$prog$","global_content_ui.cgi");
00040 hotCol=-2;
00041 ocString sql= "select id, name, content "
00042 "from metasite.global_content "
00043 "where site_id = ";
00044 sql.append(site_id);
00045 emitHeadings("Id|Name|Content");
00046 getData(sql);
00047 emitData();
00048 emitEnd();
00049 return breturn;
00050 }
00051 void derived_complete_event( void )
00052 {
00053 ocString loco = "global_content_ui.cgi";
00054 if( site_id)
00055 {
00056 loco += "?site_id=";
00057 loco.append(site_id);
00058 }
00059 ocString adder = listTemplate.getParagraph("list_new");
00060 webIO << adder.replace("$cols","2")
00061 .replace("$location",loco.c_str())
00062 .replace("$item","Item");
00063 }
00064
00065
00066 virtual void sendHotField( int iField, ocString & td )
00067 {
00068 ocString linkId = rs.getField(0).format();
00069 if( site_id)
00070 {
00071 linkId += "&site_id=";
00072 linkId.append(site_id);
00073 }
00074 webIO << td.replace( "$data$",
00075 editLink.replaceAll( "$key$", linkId.c_str() )
00076 .replaceAll( "$col$", rs.getField(iField).format().c_str() ).c_str());
00077 }
00078 };
00079
00080
00081
00082 class site_form: public siteObject, public forms_base
00083 {
00084 public:
00085 site_form(cgiScript & script):siteObject(),forms_base(script){setKey(*this);}
00086 virtual ~site_form(){;}
00087
00088 void form_id_transfer( void )
00089 {
00090 llongFXfer( "id", id );
00091 }
00092 void form_data_transfer( void )
00093 {
00094
00095 stringFXfer( "name", name);
00096 stringFXfer( "domain", domain );
00097 stringFXfer( "url", url );
00098 stringFXfer( "path",path );
00099 }
00100
00101 bool dbf_action( string mode, changeMap & changes )
00102 {
00103 return db_action( mode, changes );
00104 }
00105
00106
00107 bool form_display( void )
00108 {
00109 bool breturn = true;
00110 script << makeTop("site_ui.cgi", "SITES")
00111 << makeStaticBox("id", "id", id, "12")
00112 << makeTextBox("name","name",name,"64")
00113 << makeTextBox("domain","domain",domain,"64")
00114 << makeTextBox("url","url",url,"64")
00115 << makeTextBox("path","path",path,"64")
00116 << makeButtons( key() );
00117 if ( id != 0 )
00118 {
00119 script << "<tr><td colspan='2'>";
00120 script << "<b>Site Global Content:</b><br>";
00121 global_content_List list(script,id);
00122 list.loadListTemplates("Templates/poplist.htmp");
00123 list.list_display();
00124 script << "</td></tr>";
00125 }
00126 script << makeBottom( m_result ) << endl;
00127 return breturn;
00128 }
00129 };
00130
00131
00132 int main( int argcount, char ** args )
00133 {
00134 cgiScript script( "text/html", false );
00135 site_form myFrm(script);
00136
00137 if( oLogin.testLoginStatus() )
00138 {
00139 script.closeHeader();
00140 cgiTemplates pgTemplate;
00141 pgTemplate.load("Templates/adminPane.htmp");
00142
00143 script << ocString(pgTemplate.getParagraph("top"))
00144 .replaceAll("$heading$","SITES");
00145
00146 myFrm.loadControlTemplates("Templates/form.htmp");
00147 myFrm.form_action();
00148 myFrm.form_display();
00149 ocString end = pgTemplate.getParagraph("bottom");
00150 if( myFrm.getMode() != "s" )
00151 {
00152 script << end.replace("/*_extra_js_*/"," remenu();");
00153 }
00154 else
00155 {
00156 script << end;
00157 }
00158 }
00159 else
00160 {
00161 script.Redirect("signIn.html");
00162 }
00163 }
00164
00165
00166 #include "read_write_base.cpp"
00167 #include "forms_base.cpp"