00001
00002
00003
00004
00005
00006
00007 #include "openLogin.h"
00008 #include "cgiTemplates.h"
00009 #include "cgiExtend.h"
00010
00011
00012 extern "C"
00013 {
00014 int ordinal( void );
00015 string label( void );
00016 void presentation( ostream & client );
00017 }
00018 using namespace std;
00019
00020 int ordinal( void )
00021 {
00022 return 8;
00023 }
00024
00025 string label( void )
00026 {
00027 return "E-Commerce";
00028 }
00029
00030 void presentation( ostream & client )
00031 {
00032 cgiEnvironment envir;
00033 cgiTemplates tmplts;
00034 tmplts.load("./Templates/menu.htmp");
00035 openLogin login(false);
00036
00037 ocString expanded = tmplts.getParagraph("expanded");
00038 ocString collapsed = tmplts.getParagraph("collapsed");
00039 ocString subitem = tmplts.getParagraph("subitem");
00040 ocString listitem = tmplts.getParagraph("listitem");
00041
00042
00043 ocString thisOrdinal;
00044 string expandedOrdinal;
00045 string link="menu.cgi";
00046 thisOrdinal.append(ordinal());
00047
00048 cgiInput & clientSent = envir.ClientArguments();
00049 if( clientSent.count("module") )
00050 {
00051 expandedOrdinal = clientSent["module"].c_str();
00052 }
00053
00054 if( thisOrdinal == expandedOrdinal )
00055 {
00056
00057 client << expanded.replace( "$location", link.c_str() )
00058 .replace( "$label", label().c_str() ) << endl;
00059 if( login.testLoginStatus() &&
00060 login.fetchServices( " s.tree_depth >= 2 && s.xml_params like '<actor>ecommerce</actor>%'" ) )
00061 {
00062
00063 serviceMap & services = login.Services();
00064 serviceVector & names = login.ServiceNames();
00065 serviceMap::iterator pos;
00066 int st;
00067 for(st=0; st<names.size();++st )
00068 {
00069 pos = services.find(names[st]);
00070 if(pos!=services.end())
00071 {
00072
00073 openService & service = pos->second;
00074 ocString & tmpl = service.tree_depth=="2"?subitem:listitem;
00075 client << tmpl
00076 .replace("$location",service.uri.c_str())
00077 .replace("$label",service.menu_name.c_str()) << endl;
00078 }
00079 }
00080 }
00081 }
00082 else
00083 {
00084 link+="?module=";
00085 link+=thisOrdinal;
00086 client << collapsed.replace( "$location", link.c_str() )
00087 .replace( "$label", label().c_str() ) << endl;
00088 }
00089 }
00090
00091 #include "read_write_base.cpp"