/**
  * Load all needed modules
  */
 private function initializeModules()
 {
     $list = array();
     $module_dir = AgaviToolKit::literalize("%core.module_dir%");
     $files = scandir($module_dir);
     AppKitAgaviUtil::initializeModule('AppKit');
     foreach ($files as $file) {
         if ($file == '.' || $file == '..') {
             continue;
         }
         if (!is_dir($module_dir . "/" . $file) || !is_readable($module_dir . "/" . $file)) {
             continue;
         }
         $list[] = $file;
     }
     $available_modules = array();
     foreach ($list as $mod_name) {
         try {
             if (in_array($mod_name, self::$excludeModules) === false) {
                 AppKitAgaviUtil::initializeModule($mod_name);
                 $available_modules[$mod_name] = $module_dir . "/" . $mod_name;
             }
         } catch (AgaviDisabledModuleException $e) {
         }
     }
     AgaviConfig::set("org.icinga.modules", $available_modules);
     AppKitAgaviUtil::initializeModule('Config');
 }
 /**
  * Fetches the Validation xml for the action/module combination and returns it as
  * an DOMDocument
  *
  * @param    string  The module name
  * @param    string  The action to get the validation xml for
  * @return   AgaviXmlConfigDomDocument
  *
  * @author   Jannis Moßhammer<*****@*****.**>
  * @throws   AgaviConfigurationException     when module or action does not exist
  */
 protected function getValidatorXMLForAction($module, $action)
 {
     // get Module path
     $path = AgaviToolkit::literalize('%core.module_dir%') . "/" . $module;
     if (!file_exists(AgaviToolkit::normalizePath($path))) {
         throw new AgaviConfigurationException("Couldn't find module " . $module);
     }
     // get Validation file
     $actionPath = str_replace(".", "/", $action);
     $xml = $path . "/validate/" . $actionPath . ".xml";
     if (!file_exists(AgaviToolkit::normalizePath($path))) {
         throw new AgaviConfigurationException("Couldn't find validation file for " . $action);
     }
     $dom = new AgaviXmlConfigDomDocument();
     $dom->load(AgaviToolKit::normalizePath($xml));
     //TODO: Validate xml
     return $dom;
 }
 protected function checkModuleFilesystemConsistency()
 {
     $dir = AgaviToolKit::literalize("%core.module_dir/" . $this->modulename);
     if (!is_dir($dir)) {
         throw new ModuleFolderDoesNotExistException("Module folder for {$modulename} couldn't be found at " . $dir);
     }
     if (!is_dir($dir . "/config")) {
         throw new ModuleFolderDoesNotExistException("Config folder for {$modulename} couldn't be found at " . $dir);
     }
     if (!is_readable($dir . "/config/module.xml") && !is_readable($dir . "/config/module.xml.in")) {
         throw new ModuleFolderPermissionException("Couldn't read module.xml (or module.xml.in)");
     }
     $this->dir = $dir;
     // get properties of this module
     if (is_readable($dir . "/config/menu.xml")) {
         $this->hasMenuXML = true;
     }
     if (is_readable($dir . "/config/access.xml")) {
         $this->hasAccessXML = true;
     }
     if (is_readable($dir . "/config/databases.xml")) {
         $this->hasDatabasesXML = true;
     }
 }
 private function getAvailableModules()
 {
     $modules = array('AppKit');
     $module_dir = AgaviToolKit::literalize("%core.module_dir%");
     $files = scandir($module_dir);
     foreach ($files as $file) {
         if ($file == '.' || $file == '..' || $file == 'AppKit' || $file == 'Config') {
             continue;
         }
         if (!is_dir($module_dir . "/" . $file) || !is_readable($module_dir . "/" . $file)) {
             continue;
         }
         $modules[] = $file;
     }
     $modules[] = 'Config';
     return $modules;
 }
 /**
  * Checks wether $attribute is an attribute of the DOMElement $element or any of it's parents
  * Returns the attribute value or null if it doesn't exist
  *
  * @param    AgaviXmlDomElement  DomElement to start hangling up
  * @param    string              Attribute to search for
  *
  * @author   Jannis Moßhammer <*****@*****.**>
  */
 public static function getInheritedAttribute(DomElement $element, $attribute)
 {
     $parent = $element;
     do {
         if ($parent->hasAttribute($attribute)) {
             return AgaviToolKit::literalize($parent->getAttribute($attribute));
         }
         $element = $parent;
         $parent = $element->parentNode;
     } while ($parent instanceof DomElement);
     return null;
 }