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 "siteLimit.h"
00020 #include "site.hpp"
00021
00022 using namespace std;
00023 openLogin oLogin;
00024
00025
00026
00027 class paragraph_form: public paragraph, public richForm
00028 {
00029 public:
00030 paragraph_form(cgiScript & script):paragraph(),richForm(script){setKey(*this);}
00031 virtual ~paragraph_form(){;}
00032
00033 void form_id_transfer( void )
00034 {
00035 llongFXfer( "id", id );
00036 }
00037
00038 void form_data_transfer( void )
00039 {
00040
00041 llongFXfer( "site_id", site_id );
00042 llongFXfer( "page_id", page_id );
00043 intFXfer( "place_order", place_order );
00044 stringFXfer( "template_tag", template_tag);
00045 stringFXfer( "replace_tag", replace_tag);
00046 stringFXfer( "name", name);
00047 stringFXfer( "content", content );
00048
00049
00050 stringFXfer( "section", section );
00051 }
00052
00053 bool dbf_action( string mode, changeMap & changes )
00054 {
00055 return db_action( mode, changes );
00056 }
00057
00058
00059 bool form_display( void )
00060 {
00061 bool breturn = true;
00062 ocString str_page_id;
00063 str_page_id.append(page_id);
00064 string templateFile = templateFromPageId(str_page_id.c_str());
00065 ocString sql = "select id, name from metasite.sites ";
00066 sql += "where id ";
00067 sql += siteFocus(oLogin);
00068
00069 script << makeTop("paragraph_ui.cgi", "Paragraph Content");
00070
00071 script << formTemplate.getParagraph("advanced_begin")
00072 << makeHiddenBox( "section", section )
00073 << makeStaticBox("Id", "id", id, "12")
00074 << makeComboBox("Site", "site_id", site_id, sql.c_str() );
00075 script << "<br class='clearall'>" << endl;
00076
00077
00078 sql = "select id, name from metasite.pages where site_id " + siteFocus(oLogin);
00079 script << makeComboBox("Page", "page_id", page_id, sql.c_str() );
00080 script << makeTextBox("Place Order","place_order",place_order,"8");
00081 script << "<br class='clearall'>" << endl
00082 << makeMetaBox("Template Tag","template_tag",template_tag,"50",
00083 templateFile,"content items" )
00084 << "<br class='clearall'>" << endl
00085 << makeTextBox("Replacement Tag","replace_tag",replace_tag,"50")
00086 << "<br class='clearall'>" << endl;
00087 script << formTemplate.getParagraph("advanced_end");
00088 script << makeTextBox("Name","name",name,"64")
00089 << "<br class='clearall'>" << endl
00090 << makeRichEntry( "Content","content", content )
00091 << makeButtons( key() );
00092
00093 script << makeBottom( m_result ) << endl;
00094 return breturn;
00095 }
00096
00097 bool ivalidate( void )
00098 {
00099 if(paragraph::ivalidate())
00100 {
00101 content =htmlDecode( content );
00102 return true;
00103 }
00104 return false;
00105 }
00106 bool uvalidate( changeMap & changes )
00107 {
00108 if(paragraph::uvalidate(changes))
00109 {
00110 content =htmlDecode( content );
00111 return true;
00112 }
00113 return false;
00114 }
00115
00116 bool ssupplemental( void )
00117 {
00118 bool bret = paragraph::ssupplemental();
00119 content = htmlFixup( content );
00120 return bret;
00121 }
00122 };
00123
00124 int main( int argcount, char ** args )
00125 {
00126 cgiScript script( "text/html", false );
00127 paragraph_form myFrm(script);
00128
00129
00130 if( oLogin.testLoginStatus() )
00131 {
00132 script.closeHeader();
00133 cgiInput & args = script.ClientArguments();
00134 myFrm.template_tag = args["template_tag"].c_str();
00135 cgiTemplates pgTemplate;
00136 pgTemplate.load("Templates/editorPane.htmp");
00137
00138 script << ocString(pgTemplate.getParagraph("top"))
00139 .replaceAll("$heading$","SITES");
00140
00141 myFrm.loadControlTemplates("Templates/childdivform.htmp");
00142 myFrm.form_action();
00143 myFrm.form_display();
00144
00145
00146 string relativePath;
00147 if( myFrm.site_id > 0 )
00148 {
00149 siteObject site;
00150 site.key( myFrm.site_id );
00151 if( site.get_data() )
00152 {
00153 relativePath = "relativePath=\"";
00154 relativePath += site.url;
00155 relativePath += "\";";
00156 }
00157 }
00158 ocString bottom = pgTemplate.getParagraph("bottom");
00159 script << bottom.replace("/*_extra_js_*/",relativePath);
00160 }
00161 else
00162 {
00163 script.Redirect("signIn.html");
00164 }
00165 }
00166
00167
00168 #include "read_write_base.cpp"
00169 #include "forms_base.cpp"