本文整理汇总了PHP中Dir::touch方法的典型用法代码示例。如果您正苦于以下问题:PHP Dir::touch方法的具体用法?PHP Dir::touch怎么用?PHP Dir::touch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dir
的用法示例。
在下文中一共展示了Dir::touch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
function add()
{
if (Upload::isUploadSuccessful("my_file")) {
$peer = new ImmaginiPeer();
$do = $peer->new_do();
$peer->setupByParams($do);
$d = new Dir("/immagini/user/" . Session::get("/session/username") . Params::get("folder"));
if (!$d->exists()) {
$d->touch();
}
$do->save_folder = $d->getPath();
$do->real_name = Upload::getRealFilename("my_file");
$do->folder = Params::get("folder");
$tokens = explode(".", Upload::getRealFilename("my_file"));
$extension = $tokens[count($tokens) - 1];
$do->hash_name = md5(uniqid()) . "." . strtolower($extension);
Upload::saveTo("my_file", $do->save_folder, $do->hash_name);
$peer->save($do);
if (is_html()) {
Flash::ok("Immagine aggiunta con successo.");
return Redirect::success();
} else {
return ActiveRecordUtils::toArray($do);
}
} else {
Flash::error(Upload::getUploadError("my_file"));
return Redirect::failure();
}
}
示例2: execute
function execute()
{
$file_or_folder = $this->file_or_folder;
if (self::$dummy_mode) {
echo "Adding : " . $file_or_folder . "<br />";
return;
}
$root_dir_path = self::$root_dir->getPath();
$file_or_folder = str_replace("\\", "/", $file_or_folder);
$file_list = array();
//se finisce con lo slash è una directory
if (substr($file_or_folder, strlen($file_or_folder) - 1, 1) == "/") {
//creo la cartella
$target_dir = new Dir(DS . $root_dir_path . $file_or_folder);
$target_dir->touch();
$source_dir = new Dir($this->module_dir->getPath() . $file_or_folder);
foreach ($source_dir->listFiles() as $elem) {
if ($elem->isDir()) {
$file_list = array_merge($file_list, $this->add($file_or_folder . $elem->getName() . DS));
} else {
$file_list = array_merge($file_list, $this->add($file_or_folder . $elem->getFilename()));
}
}
} else {
$source_file = new File($this->module_dir->getPath() . $file_or_folder);
$target_file = new File($root_dir_path . $file_or_folder);
$target_dir = $target_file->getDirectory();
$target_dir->touch();
$source_file->copy($target_dir);
$file_list[] = $target_dir->newFile($source_file->getFilename())->getPath();
}
return $file_list;
}
示例3: add
function add()
{
ini_set('upload_max_filesize', 8388608 * 4);
if (Upload::isUploadSuccessful("my_file")) {
$peer = new DocumentiPeer();
$do = $peer->new_do();
$peer->setupByParams($do);
$d = new Dir("/documenti/user/" . Session::get("/session/username") . "/contenuti/");
if (!$d->exists()) {
$d->touch();
}
$do->save_folder = $d->getPath();
$do->real_name = Upload::getRealFilename("my_file");
$do->folder = Params::get("folder");
$tokens = explode(".", Upload::getRealFilename("my_file"));
$extension = $tokens[count($tokens) - 1];
$do->hash_name = md5(uniqid()) . "." . strtolower($extension);
Upload::saveTo("my_file", $do->save_folder, $do->hash_name);
$peer->save($do);
Flash::ok("Documento aggiunto con successo.");
return Redirect::success();
} else {
return Redirect::failure(Upload::getUploadError("my_file"));
}
}
示例4: Dir
function aggiungi_immagine()
{
$id_prodotto_servizio = Params::get("id_prodotto_servizio");
if (Params::is_set("file_field_name")) {
$file_field_name = Params::get("file_field_name");
} else {
$file_field_name = "file";
}
if (Upload::isUploadSuccessful($file_field_name)) {
$product_dir = new Dir(self::PRODUCT_IMAGE_DIR . "/" . $id_prodotto_servizio);
$product_dir->touch();
$uploaded_img = Upload::saveTo($file_field_name, $product_dir);
if (isset(Config::instance()->PRODUCT_IMAGE_RESIZE_BY_WIDTH)) {
image_w($uploaded_img->getPath(), Config::instance()->PRODUCT_IMAGE_RESIZE_BY_WIDTH);
} else {
if (isset(Config::instance()->PRODUCT_IMAGE_RESIZE_BY_HEIGHT)) {
image_h($uploaded_img->getPath(), Config::instance()->PRODUCT_IMAGE_RESIZE_BY_HEIGHT);
}
}
//creo una riga associata all'immagine
$immagine_prodotto_servizio_peer = new ImmagineProdottoServizioPeer();
$do = $immagine_prodotto_servizio_peer->new_do();
$do->id_prodotto_servizio = Params::get("id_prodotto_servizio");
$do->nome_immagine = $uploaded_img->getFilename();
$immagine_prodotto_servizio_peer->save($do);
return Redirect::success();
} else {
Flash::error(Upload::getUploadError($file_field_name));
return Redirect::failure();
}
}
示例5: testCompressUncompress
function testCompressUncompress()
{
$f = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/test.ffa");
$f->delete();
FFArchive::compress($f, new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/data/"));
$ext_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/");
$ext_dir->touch();
$f = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/test.ffa");
$this->assertTrue($f->exists(), "Il file da decomprimere non esiste!!");
FFArchive::extract($f, $ext_dir);
$f1 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/cartella.png");
$this->assertTrue($f1->exists(), "Il file cartella.png non e' stato estratto!!");
$this->assertEqual($f1->getSize(), 441, "La dimensione di cartella.png non corrisponde!!");
$f2 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/file1.txt");
$this->assertTrue($f2->exists(), "Il file file1.txt non e' stato estratto!!");
$f3 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/file2.dat");
$this->assertTrue($f3->exists(), "Il file file2.dat non e' stato estratto!!");
$d1 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/empty_folder");
$this->assertTrue($d1->exists(), "La cartella vuota non e' stata estratta!!");
$d2 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/folder");
$this->assertTrue($d2->exists(), "La cartella folder non e' stata estratta!!");
$f4 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/folder/sub/yep.txt");
$this->assertTrue($f4->exists(), "Il file yep.txt non e' stato estratto!!");
$this->assertEqual($f4->getSize(), 10, "La dimensione di yep.txt non corrisponde!!");
$this->assertTrue($ext_dir->delete(true), "La directory coi file estratti non e' stata elimintata!!");
$this->assertFalse($f1->exists(), "Il file cartella.png esiste ancora!!");
}
示例6: get_image_by_height
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();
}
示例7: Dir
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);
}
示例8: execute
function execute()
{
$dir = $this->dir;
if (self::$dummy_mode) {
echo "Mkdir : " . self::$root_dir->getPath() . $dir . "<br />";
return;
}
$d = new Dir(self::$root_dir->getPath() . $dir);
$d->touch();
}
示例9: Dir
function create_folder()
{
$folder_name = Params::get("folder_name");
$dir = new Dir($this->get_current_folder() . "/" . $folder_name);
$dir->touch();
if (is_html()) {
return Redirect::success();
} else {
return Result::ok();
}
}
示例10: testRmdir
function testRmdir()
{
$dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/module_plug_root/prova/");
$module_plug_test_root = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/module_plug_root/");
$target_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/module_plug_root/");
$plug = new DirBridge($target_dir, new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/ecommerce/cart/"));
$this->assertFalse($dir->exists(), "La directory c'e' gia'!!");
$dir->touch();
$this->assertTrue($dir->exists(), "La directory non e' stata creata!!");
$plug->rmdir("prova");
$this->assertFalse($dir->exists(), "La directory non e' stata eliminata!!");
}
示例11: GalleryCollectionPeer
function create_collection()
{
$peer = new GalleryCollectionPeer();
$do = $peer->new_do();
$peer->setupByParams($do);
$do->folder = Random::newHexString();
$d = new Dir(self::GALLERY_COLLECTION_ROOT_DIR . $do->folder);
$d->touch();
$peer->save($do);
if (is_html()) {
return Redirect::success();
} else {
return Result::ok();
}
}
示例12: execute
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?>");
}
示例13: Dir
function __saveAttachedFile($do)
{
if ($this->__uploadMaxFilesize() != null) {
ini_set('upload_max_filesize', $this->__uploadMaxFilesize());
}
$d = new Dir($this->__saveFolderPath());
if (!$d->exists()) {
$d->touch();
}
$do->save_folder = $d->getPath();
$do->real_name = Upload::getRealFilename("my_file");
$tokens = explode(".", Upload::getRealFilename("my_file"));
$extension = $tokens[count($tokens) - 1];
$do->hash_name = md5(uniqid()) . "." . strtolower($extension);
Upload::saveTo("my_file", $do->save_folder, $do->hash_name);
}
示例14: GalleryPeer
function create_gallery()
{
$peer = new GalleryPeer();
$gallery = $peer->new_do();
$peer->setupByParams($gallery);
$gallery->folder = Random::newHexString();
$peer_collection = new GalleryCollectionPeer();
$collection = $peer_collection->find_by_id($gallery->id_gallery_collection);
$d = new Dir(GalleryCollectionController::GALLERY_COLLECTION_ROOT_DIR . $collection->folder . "/" . $gallery->folder);
$d->touch();
$peer->save($gallery);
if (is_html()) {
return Redirect::success();
} else {
return Result::ok();
}
}
示例15: testDeleteRealEmpty
function testDeleteRealEmpty()
{
$d = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/delete_test_dir_empty/real_empty_dir/");
$this->assertFalse($d->exists(), "La cartella dal eliminare non esiste!!");
$d->touch();
$this->assertTrue($d->exists(), "La cartella da eliminare non è stata creata!!");
$d->delete();
$this->assertFalse($d->exists(), "La cartella da eliminare non è stata eliminata!!");
}