00001 /* 00002 00003 Page Template class - template.hpp 00004 00005 This class represents 00006 an abstraction of a web page template. 00007 00008 */ 00009 00010 // sentry 00011 #ifndef Web_Page_Template_Hpp 00012 #define Web_Page_Template_Hpp 00013 00014 // includes 00015 #include "cgiTemplates.h" 00016 #include "read_base.hpp" 00017 00018 class page_template: public cgiTemplates, protected read_base 00019 { 00020 string getIdSql( long long Id ) 00021 { 00022 // load page from lookup url 00023 ocString sql = "select id, " 00024 "site_id, " 00025 "name, " 00026 "path " 00027 "from metasite.templates " 00028 "where id = "; 00029 sql.append(Id); 00030 return sql; 00031 } 00032 void propset( void ) 00033 { 00034 m_id = atoll(rs.getField(0).format().c_str()); 00035 m_site_id = atoll(rs.getField(1).format().c_str()); 00036 m_name = rs.getField(2).format(); 00037 m_path = rs.getField(3).format(); 00038 } 00039 protected: 00040 // Properties 00041 long long m_id; 00042 long long m_site_id; // link to site 00043 string m_name; // name (for menu item) 00044 string m_path; // path to file 00045 00046 public: 00047 page_template( void ) 00048 :cgiTemplates(),read_base(),m_id(0),m_site_id(0) 00049 { 00050 ; 00051 } 00052 virtual ~page_template() 00053 { 00054 ; 00055 } 00056 bool load( long long id ) 00057 { 00058 bool breturn=false; 00059 00060 // load the template info by id from the db. 00061 if( rs.open(getIdSql(id)) ) 00062 { 00063 propset(); 00064 // concatenate 'Templates/' and path info to lookup url 00065 string lookup = "Templates/" + path(); 00066 00067 // have the base class load the template file 00068 breturn = cgiTemplates::load ( lookup.c_str() ); 00069 00070 } 00071 00072 // return result of load 00073 return breturn; 00074 } 00075 00076 // Property Access Methods 00077 // gets 00078 long long id(void){ return m_id;} 00079 long long site_id(void){ return m_site_id;} 00080 string name(void){ return m_name;} 00081 string path(void){ return m_path;} 00082 // sets 00083 void id( long long in ) {m_id=in;} 00084 void site_id( long long in ) {m_site_id=in;} 00085 void name( string in ) {m_name=in;} 00086 void path( string in ) {m_path=in;} 00087 }; 00088 00089 #endif
1.5.5