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 "read_write_base.hpp"
00016 #include "forms_base.hpp"
00017 #include "list_base.hpp"
00018 #include "menu.hpp"
00019 #include "openLogin.h"
00020 #include "siteLimit.h"
00021 #include "ocFileSys.h"
00022
00023 using namespace std;
00024 openLogin oLogin;
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class menu_item_List: public list_base
00039 {
00040 public:
00041 long long menu_id;
00042 string id, place_order;
00043 long place_level;
00044 cgiTemplates movemap;
00045
00046
00047 menu_item_List(cgiScript&sc, long long id):list_base(sc),menu_id(id)
00048 {
00049 movemap.load("Templates/map.htm");
00050 }
00051 ~menu_item_List(){;}
00052
00053 bool list_display( void )
00054 {
00055 bool breturn = true;
00056 editLink = listTemplate.getParagraph("hotcolumn");
00057 editLink = editLink.replace("$prog$","menu_item_ui.cgi");
00058 hotCol=3;
00059 ocString sql = "select mi.id, mi.place_order, mi.place_level, l.name "
00060 "from metasite.menu_items mi "
00061 "inner join metasite.links l on l.id = mi.link_id "
00062 "where mi.menu_id = ";
00063 sql.append(menu_id);
00064 sql += " order by mi.place_order";
00065
00066 getData(sql);
00067 emitData();
00068 emitEnd();
00069 return breturn;
00070 }
00071 void derived_complete_event( void )
00072 {
00073 ocString loco = "menu_item_ui.cgi";
00074 if(menu_id)
00075 {
00076 loco += "?menu_id=";
00077 loco.append(menu_id);
00078 }
00079 ocString adder = listTemplate.getParagraph("list_new");
00080 webIO << adder.replace("$location",loco.c_str())
00081 .replace("$item","Menu Item");
00082 }
00083
00084 virtual void sendField( int iField, ocString & td )
00085 {
00086
00087 if(iField==0)
00088 {
00089 id=rs.getField(iField).format();
00090 }
00091 if(iField==1)
00092 {
00093 place_order=rs.getField(iField).format();
00094 }
00095 if(iField==2)
00096 {
00097 place_level=atol(rs.getField(iField).format().c_str());
00098 }
00099 }
00100
00101
00102 virtual void sendHotField( int iField, ocString & td )
00103 {
00104 ocString linkId = id;
00105 ocString moveMap = movemap.getParagraph("movemap");
00106 ocString level;
00107 ocString FieldName = rs.getField(iField).format();
00108 FieldName += " ( ";
00109 FieldName.append(place_order);
00110 FieldName += " )";
00111 level.append(place_level*30);
00112 if(menu_id)
00113 {
00114 linkId += "&menu_id=";
00115 linkId.append(menu_id);
00116 }
00117 webIO << moveMap.replaceAll("miid",id.c_str())
00118 .replace( "$LEVEL$", level.c_str() )
00119 << td.replace( "$data$",
00120 editLink.replaceAll( "$key$", linkId.c_str() )
00121 .replaceAll( "$col$", FieldName.c_str() ).c_str() );
00122 }
00123 };
00124
00125
00126 class menu_form: public menu, public forms_base
00127 {
00128 public:
00129 menu_form(cgiScript & script):menu(),forms_base(script)
00130 {
00131 setKey(*this);
00132 site_id = atoll(currentSite(script.ClientArguments()).c_str());
00133 }
00134 virtual ~menu_form(){;}
00135
00136 void form_id_transfer( void )
00137 {
00138 llongFXfer( "id", id );
00139 }
00140 void form_data_transfer( void )
00141 {
00142
00143 llongFXfer( "site_id", site_id );
00144 stringFXfer( "name", name);
00145 stringFXfer( "reference_template", reference_template);
00146 stringFXfer( "template_open_tag", template_open_tag);
00147 stringFXfer( "template_close_tag", template_close_tag);
00148 }
00149
00150 bool dbf_action( string mode, changeMap & changes )
00151 {
00152 return db_action( mode, changes );
00153 }
00154
00155
00156 bool form_display( void )
00157 {
00158 bool breturn = true;
00159 string siteLimitation = siteFocus(oLogin);
00160 string sql = "select id, name from metasite.sites";
00161 if( siteLimitation.length() != 0 )
00162 {
00163 sql += " where id ";
00164 sql += siteLimitation;
00165 }
00166
00167
00168 script << makeTop("", "Menu Manager")
00169 << formTemplate.getParagraph("advanced_begin")
00170 << makeStaticBox("id", "id", id, "12")
00171 << makeComboBox( "Site", "site_id", site_id,
00172 sql );
00173 sql = "select path, path from metasite.templates ";
00174 if( siteLimitation.length() != 0 )
00175 {
00176 sql += " where site_id ";
00177 sql += siteLimitation;
00178 }
00179
00180
00181 script << "<br class='clearall'>" << endl;
00182 script << makeComboBox("reference_template", "reference_template", reference_template ,sql,"Choose");
00183 script << "<br class='clearall'>" << endl;
00184 script << makeMetaBox("template_open_tag", "template_open_tag", template_open_tag ,"35",reference_template, "open");
00185 script << "<br class='clearall'>" << endl;
00186 script << makeMetaBox("template_close_tag", "template_close_tag", template_close_tag ,"35",reference_template, "close");
00187 script << "<br class='clearall'>" << endl;
00188
00189 script << "<br class='clearall'>" << endl
00190 << formTemplate.getParagraph("advanced_end")
00191 << makeTextBox("name","name",name,"50")
00192 << "<br class='clearall'>" << endl
00193 << makeButtons( key() );
00194 if ( id != 0 )
00195 {
00196 script << "<tr><td colspan='2'>";
00197 script << "<b>Menu Items:</b><br>";
00198 menu_item_List list(script,id);
00199 list.loadListTemplates("Templates/divlist.htmp");
00200 list.list_display();
00201 script << "</td></tr>";
00202 }
00203 script << makeBottom( m_result ) << endl;
00204 return breturn;
00205 }
00206 };
00207
00208
00209 int main( int argcount, char ** args )
00210 {
00211 cgiScript script( "text/html", false );
00212 menu_form myFrm(script);
00213
00214 if( oLogin.testLoginStatus() )
00215 {
00216 script.closeHeader();
00217 cgiTemplates pgoo;
00218 pgoo.load("Templates/adminPane.htmp");
00219
00220 script << ocString(pgoo.getParagraph("top"))
00221 .replace( "// More Functions?",
00222 "</SCRIPT><SCRIPT type=\"text/javascript\" src=\"menumanip.js\"></SCRIPT>" );
00223
00224 myFrm.loadControlTemplates("Templates/divform.htmp");
00225 myFrm.form_action();
00226 myFrm.form_display();
00227
00228 ocString end = pgoo.getParagraph("bottom");
00229 if( myFrm.getMode() != "s" )
00230 {
00231 script << end.replace("/*_extra_js_*/"," remenu();");
00232 }
00233 else
00234 {
00235 script << end;
00236 }
00237 }
00238 else
00239 {
00240 script.closeHeader();
00241 script << oLogin.getLastError() << endl;
00242
00243 }
00244 }
00245
00246 #include "read_write_base.cpp"
00247 #include "forms_base.cpp"