function delete() { $nome_categoria = Params::get("nome_categoria"); $nome_modulo = Params::get("nome_modulo"); if ($nome_categoria !== ModuleUtils::FRAMEWORK_CATEGORY_NAME && $nome_modulo !== ModuleUtils::FRAMEWORK_MODULE_NAME) { $path = AvailableModules::get_available_module_path($nome_categoria, $nome_modulo); $d = new Dir($path); $d->delete(true); Flash::ok("Modulo " . $nome_categoria . "/" . $nome_modulo . " eliminato con successo!!"); return Redirect::success(); } else { Flash::error("Impossibile eliminare il modulo " . $nome_categoria . "/" . $nome_modulo); return Redirect::failure(); } }
static function validate_module($nome_categoria, $nome_modulo) { $module_file = new File(AvailableModules::get_available_module_path($nome_categoria, $nome_modulo) . AvailableModules::MODULE_DEFINITION_FILE); $schema_url = "http://www.mbcraft.it/schemas/2011/module.rnc"; $validator_url = "http://validator.nu?level=error&out=xml&schema=" . urlencode($schema_url); $ch = curl_init($validator_url); $headers = array("Content-Type: application/xml", "Referer: MBCRAFT - Italy - info@mbcraft.it"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $module_file->getContent()); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); $xml_result = new SimpleXMLElement($result); foreach ($xml_result->error as $error) { //$attribs = $error->attributes(); var_dump($error); //echo $attribs->line_number." : ".$error->message."<br />"; } return count($xml_result->children()) == 0; }
static function get_installed_module_definition($nome_categoria, $nome_modulo) { if (!InstalledModules::is_installed($nome_categoria, $nome_modulo)) { throw new InvalidParametersException(); } $mod_def_file = new File(AvailableModules::get_available_module_path($nome_categoria, $nome_modulo) . AvailableModules::MODULE_DEFINITION_FILE); $data = new SimpleXMLElement($mod_def_file->getContent()); return new ModuleDefinition($nome_categoria, $nome_modulo, $data); }
function testGetAvailableModulePath() { ModuleUtils::set_modules_path(FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/"); $path = AvailableModules::get_available_module_path("ecommerce", "cart"); $this->assertEqual("/" . FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/ecommerce/cart/", $path, "Il percorso del modulo non corrisponde!! : " . $path); }
static function is_module_available($nome_categoria, $nome_modulo) { $d = new Dir(DS . AvailableModules::get_available_module_path($nome_categoria, $nome_modulo)); $module_data = new File($d->getPath() . "/" . self::MODULE_DEFINITION_FILE); if ($d->exists()) { return true; } else { return false; } }