Example #1
0
 public function load($printQuery = false, $logQuery = false)
 {
     // Skip if already loaded
     if ($this->isLoaded()) {
         return $this;
     }
     if (empty($this->_items)) {
         // Get the config
         $config = Mage::getConfig();
         // Loop through the modules
         foreach ($config->getNode('modules')->children() as $module) {
             // Create an object
             $item = new Varien_Object();
             // Module name
             $item->setName($module->getName());
             // Module Active
             $item->setFileEnable((string) $module->active);
             // Module Code Pool
             $item->setCodePool((string) $module->codePool);
             // Module Version
             $version = Mage::getConfig()->getModuleConfig($module->getName())->version ? Mage::getConfig()->getModuleConfig($module->getName())->version : "undefined";
             $item->setVersion($version);
             // Folder Path
             $dir = $config->getOptions()->getCodeDir() . DS . $module->codePool . DS . uc_words($module->getName(), DS);
             $item->setFolderPath($dir);
             // Folder Exists
             $pathExists = file_exists($dir) ? "true" : "false";
             $item->setFolderPathExists($pathExists);
             // Config File Exists
             $file = $config->getModuleDir('etc', $module->getName()) . DS . "config.xml";
             $item->setConfigFilePath($file);
             $exists = file_exists($file);
             if ($exists) {
                 // Get the config.xml file
                 $configXml = simplexml_load_string(file_get_contents($file), 'Varien_Simplexml_Element');
                 // Get the resources tag
                 if ($nodes = $configXml->global->resources) {
                     // Reset the pointer to the beginning of the array
                     reset($nodes);
                     // Get the resource name (first key in the array)
                     $resourceName = key($nodes);
                 } else {
                     $resourceName = '';
                 }
                 $item->setDataEntry($resourceName);
                 if (!$resourceName) {
                     $dataVersion = '';
                 } else {
                     // Get the data version based on the resource name
                     $dataVersion = Mage::getResourceSingleton('core/resource')->getDataVersion($resourceName);
                 }
                 $item->setDataVersion($dataVersion);
                 // Please note that the 0 value means Enabled and 1 means Disabled
                 $disableOutput = Mage::getStoreConfig('advanced/modules_disable_output/' . $module->getName()) ? 'false' : 'true';
                 $item->setOutputEnable($disableOutput);
             } else {
                 $item->setDataEntry('');
                 $item->setDataVersion('');
                 $item->setOutputEnable('');
             }
             $exists = $exists ? 'true' : 'false';
             $item->setConfigFileExists($exists);
             $this->addItem($item);
         }
     }
     $this->_setIsLoaded();
     $this->_renderFilters()->_renderOrders()->_renderLimit();
     return $this;
 }