当前位置: 首页>>代码示例>>PHP>>正文


PHP Dir::getPath方法代码示例

本文整理汇总了PHP中Dir::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Dir::getPath方法的具体用法?PHP Dir::getPath怎么用?PHP Dir::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dir的用法示例。


在下文中一共展示了Dir::getPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:29,代码来源:ImmaginiController.class.php

示例2: 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"));
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:25,代码来源:DocumentiController.class.php

示例3: 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);
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:16,代码来源:AbstractKeyedFolderEntityController.class.php

示例4: array

 function get_rotator()
 {
     $result = array();
     $result["rotator_name"] = Params::get("name");
     $result["image_list"] = array();
     $d = new Dir(self::ROTATOR_GALLERIES_ROOT_PATH . $result["rotator_name"] . "/");
     if ($d->exists()) {
         $files = $d->listFiles();
         foreach ($files as $f) {
             if ($f->isFile()) {
                 $img = array();
                 $img["path"] = $f->getPath();
                 $img["title"] = str_replace("_", " ", $f->getName());
                 $result["image_list"][] = $img;
             }
         }
     } else {
         echo "Rotator gallery directory not found! : " . $d->getPath();
     }
     return $result;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:21,代码来源:RotatorController.class.php

示例5: Dir

 function get_parent_folder()
 {
     $current_folder = new Dir($this->get_current_folder());
     $root_dir = new Dir($this->get_user_root());
     if ($root_dir->isParentOf($current_folder)) {
         return $current_folder->getParent()->getPath();
     } else {
         return $root_dir->getPath();
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:10,代码来源:GalleryController.class.php

示例6: extract

 static function extract($f, $dir)
 {
     if ($f instanceof File) {
         $source_file = $f;
     } else {
         $source_file = new File($f);
     }
     if ($dir instanceof Dir) {
         $target_dir = $dir;
     } else {
         $target_dir = new Dir($dir);
     }
     $reader = $source_file->openReader();
     $binarydata = $reader->read(3);
     $data = unpack("a3", $binarydata);
     if ($data[1] !== self::FF_ARCHIVE_HEADER) {
         throw new InvalidDataException("Intestazione del file non valida : " . $data[1]);
     }
     $binarydata = $reader->read(2 + 2 + 2);
     $data = unpack("v3", $binarydata);
     if ($data[1] !== self::CURRENT_MAJOR || $data[2] !== self::CURRENT_MINOR || $data[3] !== self::CURRENT_REV) {
         throw new InvalidDataException("Versione del file non supportata!! : " . $data[1] . "-" . $data[2] . "-" . $data[3]);
     }
     //properties
     $binarydata = $reader->read(2);
     $data = unpack("v", $binarydata);
     $properties_length = $data[1];
     if ($properties_length > 0) {
         $binarydata = $reader->read($properties_length);
         $data = unpack("a*", $binarydata);
         $properties = PropertiesUtils::readFromString($data[1], false);
     } else {
         $properties = array();
     }
     //num entries
     $binarydata = $reader->read(2);
     $data = unpack("v", $binarydata);
     $num_entries = $data[1];
     $i = 0;
     while ($i < $num_entries) {
         //entry type
         $binarydata = $reader->read(2);
         $data = unpack("v", $binarydata);
         $entry_type = $data[1];
         //path length
         $binarydata = $reader->read(2);
         $data = unpack("v", $binarydata);
         $path_length = $data[1];
         //path
         $binarydata = $reader->read($path_length);
         $data = unpack("a*", $binarydata);
         $path = $data[1];
         if ($entry_type === self::ENTRY_TYPE_DIR) {
             $d = $target_dir->newSubdir($path);
             $d->touch();
         }
         if ($entry_type === self::ENTRY_TYPE_FILE) {
             //compressed size
             $binarydata = $reader->read(4);
             $data = unpack("V", $binarydata);
             $num_bytes = $data[1];
             //compressed data
             $compressed_file_data = $reader->read($num_bytes);
             $uncompressed_file_data = gzuncompress($compressed_file_data);
             $f = new File($target_dir->getPath() . $path);
             $writer = $f->openWriter();
             $writer->write($uncompressed_file_data);
             $writer->close();
             //sha1 sum
             $sha1_checksum = $reader->read(20);
             if (strcmp($sha1_checksum, sha1_file($f->getFullPath(), true)) !== 0) {
                 throw new InvalidDataException("La somma sha1 non corrisponde per il file : " . $f->getPath());
             }
         }
         $i++;
     }
     $reader->close();
     return true;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:79,代码来源:FFArchive.class.php

示例7: testGetPathRelative

 function testGetPathRelative()
 {
     $my_included_file = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/include_teiop/");
     $rel_path = $my_included_file->getPath(new Dir("/" . FRAMEWORK_CORE_PATH . "tests"));
     $this->assertEqual("/io/include_teiop/", $rel_path, "Il percorso relativo non viene elaborato correttamente!! : " . $rel_path);
     $rel_path = $my_included_file->getPath(new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/"));
     $this->assertEqual("/include_teiop/", $rel_path, "Il percorso relativo non viene elaborato correttamente!! : " . $rel_path);
     $this->expectException("InvalidDataException");
     $this->assertEqual("/include_teiop/", $my_included_file->getPath(new Dir("/pluto/tests/io/include_test")), "Il percorso relativo non viene elaborato correttamente!!");
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:10,代码来源:plain_dir_test.php

示例8: testExecute

 function testExecute()
 {
     ModuleUtils::set_modules_path(FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/");
     $ciccia_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/modules/module_plug_root/ciccia/");
     $db_desc = DB::newDatabaseDescription();
     $this->assertFalse($db_desc->hasTable("my_entity"), "La tabella my_entity e' gia' presente nel database!!");
     $this->assertFalse($ciccia_dir->exists(), "La directory 'ciccia' esiste gia'!!");
     //dove innesto i moduli
     $module_plug_test_root = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/modules/module_plug_root/");
     ModulePlug::setRootDir($module_plug_test_root->getPath());
     $plug = new ModulePlug(new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/ecommerce/cart/"));
     $def = AvailableModules::get_available_module_definition("ecommerce", "cart");
     $install_data = $def->get_action_data("install");
     $plug->execute($install_data);
     $db_desc = DB::newDatabaseDescription();
     $this->assertTrue($db_desc->hasTable("my_entity"), "La tabella my_entity non e' stata creata!!");
     $sel = DB::newSelect("my_entity");
     $sel->count("*", "num_entries");
     $result = $sel->exec_fetch_assoc();
     $this->assertEqual($result["num_entries"], 2, "Il numero di righe nella tabella non corrisponde!!");
     $table_desc = DB::newTableFieldsDescription("my_entity");
     $this->assertTrue($table_desc->hasField("new_field"), "Il campo new_field non e' stato aggiunto!!");
     $this->assertTrue($table_desc->hasField("int_field"), "Il campo int_field non e' stato aggiunto!!");
     $ciccia_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/modules/module_plug_root/ciccia/");
     $this->assertTrue($ciccia_dir->exists(), "La directory 'ciccia' non e' stata creata!!");
     $uninstall_data = $def->get_action_data("uninstall");
     $plug->execute($uninstall_data[0]);
     $this->assertFalse($ciccia_dir->exists(), "La directory ciccia non e' stata eliminata!!");
     ModulePlug::setRootDir("/");
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:30,代码来源:module_plug_test.php

示例9: Dir

 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;
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:10,代码来源:AvailableModules.class.php

示例10: isParentOf

 function isParentOf($folder)
 {
     if ($folder instanceof Dir) {
         $d = $folder;
     } else {
         $d = new Dir($folder);
     }
     $path_a = $this->getPath();
     $path_b = $d->getPath();
     return StringUtils::starts_with($path_b, $path_a);
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:11,代码来源:Dir.class.php


注:本文中的Dir::getPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。