# Path: RapacheCore/PluginBase.py
# class PluginBaseObject():
# 
#     def __init__(self, path):
#             
#         # The path to the plugin
#         self.path = path
#     
#         # module this plugin works with
#         self.module = ""
#         
#         # Define what additional config should be read from vhost file
#         self.vhosts_config = {  } # 0 value | 1 options
#         
#         # Number set when plugin UI is added to notebook
#         self._tab_number = -1
#     
#     def is_module_enabled(self):
#         if self.module:
#             module = ModuleModel(self.module)
#             module.load()
#             #print "STATUS : " + self.module + " - " + str( module.is_enabled())
#             return module.is_enabled()
#         return True
#         
#     def is_enabled(self):
#         enabled = self.is_module_enabled()
#         
#         #TODO: Method of activating / deactivating plugins
#         
#         return enabled
#         
#     # Add item to tools menu
#     def init_main_window(self, MainWindow):
#         return None
#         
#         
#     # Customise the module properties window
#     def load_module_properties(self, notebook, module):
#         return True
# 
#     # Perform action on module properties save
#     def save_module_properties(self, module):
#         return True
# 
# 
# 
# 
# 
# 
#     # Init the vhost propertis window
#     def init_vhost_properties(self, notebook):
#         return None, None, None
# 
#     # Tab recives focus load properties from vhost object
#     def load_vhost_properties(self,  vhost):
#         return True
#         
#     # Tab blurs update vhost object with changes
#     def update_vhost_properties(self, vhost):
#         return True, ""
#         
#     # Perform action on vhost properties save, return false if validation fails
#     def save_vhost_properties(self, vhost):
#         return True, ""


import os
import re
     import pygtk
    import gtk
    import gtk.glade
from RapacheCore.PluginBase import PluginBaseObject
from EditDocumentNameGui import EditDocumentNameWindow
        if not iter: return
        document = model.get_value(iter, 0)
        edw = EditDocumentNameWindow(self.path, document )
        result = edw.run()
        if result:
             self.treeview_default_document.get_model().set_value(iter, 0, edw.return_value)
             
    def on_toolbutton_document_delete_clicked(self, widget):
        model, iter = self.treeview_default_document.get_selection().get_selected()
        if not iter: return
        self.treeview_default_document.get_model().remove(iter)
        return


    # Customise the vhost properties window
    def load_vhost_properties(self, vhost):
        self.documents = []
        if vhost.config.ServerAdmin: self.entry_admin_email.set_text(vhost.config.ServerAdmin.value)
        if vhost.config.ErrorLog: self.entry_log_location.set_text(vhost.config.ErrorLog.value)
        if vhost.config.LogLevel:
            self.combobox_log_level.set_active( self.log_levels.index( vhost.config.LogLevel.value ) )
        if vhost.config.ServerSignature and vhost.config.ServerSignature.value.lower() != "off":
            self.checkbutton_server_signature.set_active(True)
        if vhost.config.DirectoryIndex:
            self.documents = list(vhost.config.DirectoryIndex.opts)
            
            
        ds = vhost.config.Directory.search(  [vhost.get_document_root()]  )
        if len( ds ) > 0:
            d = ds[0]

# Path: RapacheCore/PluginBase.py
# class PluginBaseObject():
# 
#     def __init__(self, path):
#             
#         # The path to the plugin
#         self.path = path
#     
#         # module this plugin works with
#         self.module = ""
#         
#         # Define what additional config should be read from vhost file
#         self.vhosts_config = {  } # 0 value | 1 options
#         
#         # Number set when plugin UI is added to notebook
#         self._tab_number = -1
#     
#     def is_module_enabled(self):
#         if self.module:
#             module = ModuleModel(self.module)
#             module.load()
#             #print "STATUS : " + self.module + " - " + str( module.is_enabled())
#             return module.is_enabled()
#         return True
#         
#     def is_enabled(self):
#         enabled = self.is_module_enabled()
#         
#         #TODO: Method of activating / deactivating plugins
#         
#         return enabled
#         
#     # Add item to tools menu
#     def init_main_window(self, MainWindow):
#         return None
#         
#         
#     # Customise the module properties window
#     def load_module_properties(self, notebook, module):
#         return True
# 
#     # Perform action on module properties save
#     def save_module_properties(self, module):
#         return True
# 
# 
# 
# 
# 
# 
#     # Init the vhost propertis window
#     def init_vhost_properties(self, notebook):
#         return None, None, None
# 
#     # Tab recives focus load properties from vhost object
#     def load_vhost_properties(self,  vhost):
#         return True
#         
#     # Tab blurs update vhost object with changes
#     def update_vhost_properties(self, vhost):
#         return True, ""
#         
#     # Perform action on vhost properties save, return false if validation fails
#     def save_vhost_properties(self, vhost):
#         return True, ""


# Path: plugins/advanced/plugin.py
import os
import re
     import pygtk
    import gtk
    import gtk.glade
from RapacheCore.PluginBase import PluginBaseObject
from EditDocumentNameGui import EditDocumentNameWindow

        if not iter: return
        document = model.get_value(iter, 0)
        edw = EditDocumentNameWindow(self.path, document )
        result = edw.run()
        if result:
             self.treeview_default_document.get_model().set_value(iter, 0, edw.return_value)
             
    def on_toolbutton_document_delete_clicked(self, widget):
        model, iter = self.treeview_default_document.get_selection().get_selected()
        if not iter: return
        self.treeview_default_document.get_model().remove(iter)
        return


    # Customise the vhost properties window
    def load_vhost_properties(self, vhost):
        self.documents = []
        if vhost.config.ServerAdmin: self.entry_admin_email.set_text(vhost.config.ServerAdmin.value)
        if vhost.config.ErrorLog: self.entry_log_location.set_text(vhost.config.ErrorLog.value)
        if vhost.config.LogLevel:
            self.combobox_log_level.set_active( self.log_levels.index( vhost.config.LogLevel.value ) )
        if vhost.config.ServerSignature and vhost.config.ServerSignature.value.lower() != "off":
            self.checkbutton_server_signature.set_active(True)
        if vhost.config.DirectoryIndex:
            self.documents = list(vhost.config.DirectoryIndex.opts)
            
            
        ds = vhost.config.Directory.search(  [vhost.get_document_root()]  )
        if len( ds ) > 0:
            d = ds[0]

            if d.Options: