function elimina_immagine() { $image_name = Params::get("image_name"); $id_prodotto_servizio = Params::get("id_prodotto_servizio"); $product_image_dir = new Dir(self::PRODUCT_IMAGE_DIR . "/" . $id_prodotto_servizio); $product_image_file = $product_image_dir->newFile($image_name); ImagePicker::delete_image_thumbnails($product_image_file); //elimino la riga associata all'immagine $peer = new ImmagineProdottoServizioPeer(); $peer->id_prodotto_servizio__EQUALS($id_prodotto_servizio); $peer->nome_immagine__EQUALS($image_name); $elenco_immagini_prodotto_servizio = $peer->find(); foreach ($elenco_immagini_prodotto_servizio as $img) { $peer->delete($img); } $product_image_file->delete(); if ($product_image_dir->isEmpty()) { $product_image_dir->delete(); } return Redirect::success(); }
function execute() { $attributes = $this->attributes; $name = $attributes->name; $location = $attributes->location; $do_file_name = $name . "DO.class.php"; $peer_file_name = $name . "Peer.class.php"; $d = new Dir($location); $do_file = $d->newFile($do_file_name); $do_file->delete(); $peer_file = $d->newFile($peer_file_name); $peer_file->delete(); $d->delete(); }
function testGetAvailableArchives() { $d = new Dir(ModuleArchiver::MODULES_ARCHIVE_DIR); $a1 = $d->newFile("test__category-1_2_3.ffa"); $a1->touch(); $a2 = $d->newFile("test__product-4_3_1.ffa"); $a2->touch(); $f3 = $d->newFile("element__list-1_0_0.ffa"); $f3->touch(); $available_module_archives = ModuleArchiver::get_available_module_archives(); $this->assertTrue(count($available_module_archives) == 3, "Il numero di archivi disponibili non corrisponde!! : " . count($available_module_archives)); $a1->delete(); $a2->delete(); $f3->delete(); }
function execute() { $attributes = $this->attributes; $name = $attributes->name; $location = $attributes->location; $table_name = $attributes->table_name; $do_file_name = $name . "DO.class.php"; $peer_file_name = $name . "Peer.class.php"; $d = new Dir($location); $d->touch(); $do_file = $d->newFile($do_file_name); $do_file->setContent("<?\n class " . $name . "DO extends AbstractDO\n {\n static function __getMyTable()\n {\n return \"" . $table_name . "\";\n }\n }\n?>"); $peer_file = $d->newFile($peer_file_name); $peer_file->setContent("<?\n class " . $name . "Peer extends AbstractPeer {}\n?>"); }
public static function get_image_by_height($path, $height = "original") { if ($path instanceof File) { $image_file = $path; } else { $image_file = new File($path); } $image_dir = $image_file->getDirectory(); $full_cache_dir = new Dir(self::THUMBNAILS_DIR . $image_dir->getPath()); $full_cache_dir->touch(); $data = ImageUtils::get_image_data($image_file); if ($height == "original") { $thumb_folder = "original"; } else { if ($data["height"] > $height) { $thumb_folder = "__x" . $height; } else { $thumb_folder = "original"; } } if ($thumb_folder == "original") { return $image_file->getPath(); } $final_image_folder = new Dir(self::THUMBNAILS_DIR . $image_dir->getPath() . $thumb_folder); //copio l'immagine nella cache $final_image_folder->touch(); $thumbnail_image_file = $final_image_folder->newFile($image_file->getFilename()); if (!$thumbnail_image_file->exists()) { ImageUtils::resize_by_height($image_file, $thumbnail_image_file, $height); } return $thumbnail_image_file->getPath(); }
static function extract_from_archive($filename) { $modules_archive_dir = new Dir(self::MODULES_ARCHIVE_DIR); $modules_archive_dir->touch(); $module_archive = $modules_archive_dir->newFile($filename); $properties = FFArchive::getArchiveProperties($module_archive); $module_dir = new Dir(ModuleUtils::get_modules_path() . "/" . $properties["category_name"] . "/" . $properties["module_name"]); return FFArchive::extract($module_archive, $module_dir); }
function delete_gallery() { $gallery_name = Params::get("gallery_name"); $dir = new Dir($this->get_current_folder() . "/" . $gallery_name); $gallery_ini = $dir->newFile("_gallery.ini"); if ($gallery_ini->exists()) { $dir->delete(true); if (is_html()) { return Redirect::success(); } else { return Result::ok(); } } else { if (is_html()) { return Redirect::failure(); } else { return Result::error("Impossibile eliminare la gallery"); } } }
static function saveTo($form_field_name, $dir, $filename = null) { if ($dir instanceof Dir) { $final_dir = $dir; } else { $final_dir = new Dir($dir); } $tmp_path = self::getUploadedTmpPath($form_field_name); if ($filename == null) { $real_filename = self::getRealFilename($form_field_name); } else { $real_filename = $filename; } $final_file = $final_dir->newFile($real_filename); $result = move_uploaded_file($tmp_path, $final_file->getFullPath()); if ($result == true) { return $final_file; } else { return null; } }
function testRenameDirs() { $d = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/dir/"); $d->touch(); $this->assertTrue($d->exists(), "La directory non e' stata creata!!"); $f1 = $d->newFile("my_file.txt"); $f1->setContent("Ciao!!"); $this->assertTrue($f1->exists(), "Il file non e' stato creato nella cartella!!"); $d2 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/target/"); $d2->delete(true); $this->assertFalse($d2->exists(), "La directory esiste gia'!!"); $this->assertTrue($d->rename("target")); $this->assertFalse($d->exists(), "La directory non e' stata rinominata con successo!!"); $this->assertTrue($d2->exists(), "La directory non e' stata rinominata con successo!!"); $f2 = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/target/my_file.txt"); $this->assertTrue($f2->exists(), "Il file non e' stato spostato insieme alla directory!!"); $d3 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/existing_dir/"); $this->assertFalse($d2->rename("existing_dir"), "Il rename e' stato effettuato su una directory che gia' esiste!!"); $this->assertFalse($d2->isEmpty(), "La directory non spostata non contiene piu' il suo file!!"); $this->assertTrue($d3->isEmpty(), "La directory gia' esistente e' stata riempita con pattume!!"); $this->expectException("InvalidParameterException"); $d4 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/another_target/buh/"); $this->assertFalse($d2->rename("another_target/buh"), "Rename con spostamento andato a buon fine!!"); $d2->delete(true); }
function drop_do($attributes) { $name = $attributes->name; $location = $attributes->location; $do_file_name = $name . "DO.class.php"; $peer_file_name = $name . "Peer.class.php"; $d = new Dir($location); $do_file = $d->newFile($do_file_name); $do_file->delete(); $peer_file = $d->newFile($peer_file_name); $peer_file->delete(); $d->delete(); }