00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011 #include <iomanip>
00012 #include "cgiTemplates.h"
00013 #include "paragraph.hpp"
00014 #include "forms.h"
00015 #include "richForm.hpp"
00016 #include "list_base.hpp"
00017 #include "cgiTemplates.h"
00018 #include "openLogin.h"
00019 #include "../../webconsole/metasite_source/site.hpp"
00020 using namespace std;
00021 openLogin oLogin;
00022
00023
00024
00025 class paragraph_form: public paragraph, public richForm
00026 {
00027 string templateFromId( string template_id )
00028 {
00029 string ret;
00030 quickQuery qqry;
00031 string getSql = "select path from metasite.templates where id = ";
00032 getSql += template_id;
00033 openRS & rs = qqry.getData(getSql);
00034 if( qqry.opened )
00035 {
00036 ret = rs.getField(0).format();
00037 rs.close();
00038 }
00039 return ret;
00040 }
00041 string templateFromPageId( string page_id )
00042 {
00043 string ret;
00044 quickQuery qqry;
00045 string getSql = "select template_id from metasite.pages where id = ";
00046 getSql += page_id;
00047 openRS & rs = qqry.getData(getSql);
00048 if( qqry.opened )
00049 {
00050 string template_id = rs.getField(0).format();
00051 rs.close();
00052 ret = templateFromId( template_id );
00053 }
00054 return ret;
00055 }
00056 public:
00057 paragraph_form(cgiScript & script):paragraph(),richForm(script){setKey(*this);}
00058 virtual ~paragraph_form(){;}
00059
00060 void form_id_transfer( void )
00061 {
00062 llongFXfer( "id", id );
00063 }
00064
00065 void form_data_transfer( void )
00066 {
00067
00068 llongFXfer( "site_id", site_id );
00069 llongFXfer( "page_id", page_id );
00070 intFXfer( "place_order", place_order );
00071 stringFXfer( "template_tag", template_tag);
00072 stringFXfer( "replace_tag", replace_tag);
00073 stringFXfer( "name", name);
00074 stringFXfer( "content", content );
00075
00076
00077 stringFXfer( "section", section );
00078 }
00079
00080 bool dbf_action( string mode, changeMap & changes )
00081 {
00082 return db_action( mode, changes );
00083 }
00084
00085
00086 bool form_display( void )
00087 {
00088 bool breturn = true;
00089 ocString str_page_id;
00090 str_page_id.append(page_id);
00091 string templateFile = templateFromPageId(str_page_id.c_str());
00092
00093 script << makeTop("paragraph_ui.cgi", "Paragraph Content");
00094
00095 script << formTemplate.getParagraph("advanced_begin")
00096 << makeHiddenBox( "section", section )
00097 << makeStaticBox( "Page Id", "page_id", page_id, "10" )
00098 << makeStaticBox("Id", "id", id, "10")
00099 << makeStaticBox("Site Id", "site_id", site_id , "10");
00100 script << "<br class='clearall'>" << endl;
00101 script << makeTextBox("Place Order","place_order",place_order,"8");
00102 script << "<br class='clearall'>" << endl
00103 << makeMetaBox("Template Tag","template_tag",template_tag,"50",
00104 templateFile,"content items" )
00105 << "<br class='clearall'>" << endl
00106 << makeTextBox("Replacement Tag","replace_tag",replace_tag,"50")
00107 << "<br class='clearall'>" << endl;
00108 script << formTemplate.getParagraph("advanced_end");
00109 script << makeTextBox("Name","name",name,"64")
00110 << "<br class='clearall'>" << endl
00111 << makeRichEntry( "Content","content", content );
00112 if( key() )
00113 {
00114 script << "<input type='button' onclick='doUpdate()' name='action' class='action' value=' OK '>";
00115 }
00116 else
00117 {
00118 script << "<input type='button' onclick='doInsert()' name='action' class='action' value=' OK '>";
00119 }
00120
00121 script << makeBottom( m_result ) << endl;
00122 return breturn;
00123 }
00124
00125 bool ivalidate( void )
00126 {
00127 if(paragraph::ivalidate())
00128 {
00129 content =htmlDecode( content );
00130 return true;
00131 }
00132 return false;
00133 }
00134 bool uvalidate( changeMap & changes )
00135 {
00136 if(paragraph::uvalidate(changes))
00137 {
00138 content =htmlDecode( content );
00139 return true;
00140 }
00141 return false;
00142 }
00143
00144 bool ssupplemental( void )
00145 {
00146 bool bret = paragraph::ssupplemental();
00147 content = htmlFixup( content );
00148 return bret;
00149 }
00150 };
00151
00152 int main( int argcount, char ** args )
00153 {
00154 cgiScript script( "text/html", false );
00155 paragraph_form myFrm(script);
00156
00157
00158 if( oLogin.testLoginStatus() )
00159 {
00160 script.closeHeader();
00161 cgiInput & args = script.ClientArguments();
00162 myFrm.template_tag = args["template_tag"].c_str();
00163 cgiTemplates pgTemplate;
00164 pgTemplate.load("Templates/editorPane.htmp");
00165
00166 script << ocString(pgTemplate.getParagraph("top"))
00167 .replaceAll("$heading$","SITES");
00168
00169 myFrm.loadControlTemplates("Templates/childdivform.htmp");
00170 myFrm.form_action();
00171 myFrm.form_display();
00172
00173
00174 string relativePath = "relativePath=\"";
00175 if( myFrm.site_id > 0 )
00176 {
00177 siteObject site;
00178 site.key( myFrm.site_id );
00179 if( site.get_data() )
00180 {
00181 relativePath += site.url;
00182 relativePath += "\";";
00183 }
00184 else
00185 {
00186 relativePath += "/\";";
00187 }
00188 }
00189 ocString bottom = pgTemplate.getParagraph("bottom");
00190 script << bottom.replace("/*_extra_js_*/",relativePath);
00191
00192 }
00193 else
00194 {
00195 script.Redirect("signIn.html");
00196 }
00197 }
00198
00199
00200 #include "read_write_base.cpp"
00201 #include "forms_base.cpp"