From de293999872346271cdfb5dbecbad7f77362b83b Mon Sep 17 00:00:00 2001 From: faketruth Date: Fri, 27 Jan 2012 23:47:32 +0000 Subject: Converted entire Core plugin including WebAdmin interface to new plugin method/system/thingy and sexyfied it. Made some changes to WebAdmin to make the new plugins work Old plugins still work like they're supposed to Not all hooks have been programmed for the new plugins yet, this still needs to be done git-svn-id: http://mc-server.googlecode.com/svn/trunk@182 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cWebAdmin.cpp | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'source/cWebAdmin.cpp') diff --git a/source/cWebAdmin.cpp b/source/cWebAdmin.cpp index 86dbf5990..ec4894aef 100644 --- a/source/cWebAdmin.cpp +++ b/source/cWebAdmin.cpp @@ -3,6 +3,7 @@ #include "cStringMap.h" #include "cWebPlugin.h" +#include "cWebPlugin_Lua.h" #include "cPluginManager.h" #include "cPlugin.h" @@ -96,6 +97,16 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) std::string UserPassword = WebAdmin->m_IniFile->GetValue( "User:"+r->username_, "Password", ""); if (UserPassword != "" && r->password_ == UserPassword) { + std::string BaseURL = "./"; + if( Split.size() > 1 ) + { + for( unsigned int i = 0; i < Split.size(); i++) + { + BaseURL += "../"; + } + BaseURL += "webadmin/"; + } + std::string Menu; std::string Content; std::string Template = WebAdmin->GetTemplate(); @@ -103,7 +114,20 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) for( PluginList::iterator itr = WebAdmin->m_Plugins.begin(); itr != WebAdmin->m_Plugins.end(); ++itr ) { - Menu += "
  • " + (*itr)->GetName() + "
  • "; + cWebPlugin* WebPlugin = *itr; + cWebPlugin_Lua* LuaPlugin = dynamic_cast< cWebPlugin_Lua* >( WebPlugin ); + if( LuaPlugin ) + { + std::list< std::string > NameList = LuaPlugin->GetTabNames(); + for( std::list< std::string >::iterator Name = NameList.begin(); Name != NameList.end(); ++Name ) + { + Menu += "
  • " + (*Name) + "
  • "; + } + } + else + { + Menu += "
  • " + WebPlugin->GetName() + "
  • "; + } } HTTPRequest Request; @@ -112,17 +136,20 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) Request.Params = new cStringMap(r->params_); Request.Path = r->path_; - - if( Split.size() > 1 ) { - for( PluginList::iterator itr = WebAdmin->m_Plugins.begin(); itr != WebAdmin->m_Plugins.end(); ++itr ) { if( (*itr)->GetName() == Split[1] ) { Content = (*itr)->HandleRequest( &Request ); - FoundPlugin = (*itr)->GetName(); + cWebPlugin* WebPlugin = *itr; + FoundPlugin = WebPlugin->GetName(); + cWebPlugin_Lua* LuaPlugin = dynamic_cast< cWebPlugin_Lua* >( WebPlugin ); + if( LuaPlugin ) + { + FoundPlugin += " - " + LuaPlugin->GetTabNameForRequest( &Request ); + } break; } } @@ -144,7 +171,10 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) const cPluginManager::PluginList & List = PM->GetAllPlugins(); for( cPluginManager::PluginList::const_iterator itr = List.begin(); itr != List.end(); ++itr ) { - Content += std::string("
  • ") + std::string( (*itr)->GetName() ) + "
  • "; + char c_VersionNum[32]; // 32 digits should be enough? XD + sprintf_s( c_VersionNum, 32, "%i", (*itr)->GetVersion() ); + Content += std::string("
  • ") + std::string( (*itr)->GetName() ) + " V. " + std::string( c_VersionNum ) + "
  • "; + } } Content += ""; @@ -163,13 +193,7 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) if( Split.size() > 1 ) { - Content += "\n

    Go back

    "; + Content += "\n

    Go back

    "; } // mem usage -- cgit v1.2.3