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


PHP Folder::deleteFolder方法代码示例

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


在下文中一共展示了Folder::deleteFolder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteFolder

 /**
  * Delete this folder, all subsections and files
  * @return boolean to determine if delete was succesfull
  */
 function deleteFolder()
 {
     if (!empty($this->id)) {
         global $dbi;
         /* Delete files in folder */
         $result = $dbi->query("SELECT id FROM " . fileTableName . " WHERE folderId=" . $this->id);
         for ($i = 0; list($id) = $result->fetchrow_array(); $i++) {
             $file = new File($id);
             $file->deleteFile();
         }
         /* Delete subfolders */
         $result = $dbi->query("SELECT id FROM " . folderTableName . " WHERE parentId=" . $this->id);
         for ($i = 0; list($id) = $result->fetchrow_array(); $i++) {
             $folder = new Folder($id);
             $folder->deleteFolder();
         }
         /* Delete logged information in database */
         $dbi->query("DELETE FROM " . logTableName . " WHERE type='folder' AND typeId=" . $this->id);
         /* Delete this folder */
         $dbi->query("DELETE FROM " . folderTableName . " WHERE id=" . $this->id);
         /* Folder was deleted */
         return true;
     }
     /* Folder was not deleted */
     return false;
 }
开发者ID:gkathir15,项目名称:catmis,代码行数:30,代码来源:Folder.class.php

示例2: getPostValue

if (!$login->isAdmin()) {
    $login->printLoginForm();
    exit;
}
// Delete files
$delete = getPostValue("delete");
if ($delete) {
    // Check if data is submitted from the form
    checkSubmitter();
    // Delete folders
    $folders = getPostValue("folders");
    if (!empty($folders)) {
        for ($i = 0; $i < sizeof($folders); $i++) {
            if (!empty($folders[$i])) {
                $tmpFolder = new Folder($folders[$i]);
                $tmpFolder->deleteFolder();
            }
        }
    }
    // Delete files
    $files = getPostValue("files");
    if (!empty($files)) {
        for ($i = 0; $i < sizeof($files); $i++) {
            if (!empty($files[$i])) {
                $tmpFile = new File($files[$i]);
                $tmpFile->deleteFile();
            }
        }
    }
    // Redirect
    redirect(scriptUrl . "/" . folderFilesAdmin . "/" . fileFilesIndex . (!empty($folder->id) ? "?folderId=" . $folder->id : ""));
开发者ID:gkathir15,项目名称:catmis,代码行数:31,代码来源:index.php

示例3: syncFolders

 public static function syncFolders($folderToSync)
 {
     $debug = self::$debug;
     $mode = self::$mode;
     import('dao.Folder');
     $folder = new Folder();
     import('dao.File');
     $file = new File();
     $folderFullName = $folderToSync['path'];
     $folderId = $folderToSync['fd_id'];
     // If folder is locked, ignore. Unless set mode greater than 0.
     if ($folderToSync['locked'] && $mode == 0) {
         if ($debug) {
             ZDebug::my_echo('Ignore locked folder: ' . $folderFullName . '(' . $folderId . ')');
         }
         return TRUE;
     }
     // Step 1: If folder is not physically exist, set to deleted in DB.
     if (!is_dir($folderFullName)) {
         $folder->deleteFolder($folderId);
         if ($debug) {
             ZDebug::my_echo('Delete folder in DB: ' . $folderFullName . '(' . $folderId . ')');
         }
         return TRUE;
     }
     // Step 2: Get the result set of files under this folder
     $filesInFolder = $folder->getFilesInFolder($folderId);
     $fileNameArr = array();
     foreach ($filesInFolder as $theFile) {
         // Step 3: If a file is not physically exist, delete it in table files.
         if (!file_exists($theFile['path'])) {
             $file->deleteFile($theFile['fid']);
             if ($debug) {
                 ZDebug::my_echo('Delete file in DB: ' . $theFile['path'] . '(' . $theFile['fid'] . ')');
             }
         } elseif ($theFile['last_modified'] != my_filemtime($theFile['path'])) {
             $theFile['last_modified'] = my_filemtime($theFile['path']);
             $file->saveFile($theFile);
             if ($debug) {
                 ZDebug::my_echo('Update file in DB: ' . $theFile['path'] . '(' . $theFile['fid'] . ')');
             }
         } elseif ($mode > 1) {
             $file->saveFile($theFile);
             if ($debug) {
                 ZDebug::my_echo('Update file in DB: ' . $theFile['path'] . '(' . $theFile['fid'] . ')');
             }
         } else {
         }
         $fileNameArr[] = $theFile['name'];
     }
     // Step 5: Get result set of sub-folders under this folder
     $subFoldera = $folder->getSubFolder($folderId);
     $folderNameArr = array();
     foreach ($subFoldera as $theFolder) {
         // Step 6: If a folder is not physically exist, set deleted flag in table folders.
         if (!file_exists($theFolder['path'])) {
             $folder->deleteFolder($theFolder['fd_id']);
             if ($debug) {
                 ZDebug::my_echo('Delete folder in DB: ' . $theFolder['path'] . '(' . $theFolder['fd_id'] . ')');
             }
         } elseif ($theFolder['last_modified'] != my_filemtime($theFolder['path'])) {
             $theFolder['last_modified'] = my_filemtime($theFolder['path']);
             $folder->saveFolder($theFolder);
             if ($debug) {
                 ZDebug::my_echo('Update folder in DB: ' . $theFolder['path'] . '(' . $theFolder['fd_id'] . ')');
             }
             self::syncFolders($theFolder);
         } else {
             self::syncFolders($theFolder);
         }
         $folderNameArr[] = $theFolder['name'];
     }
     $hdl = opendir($folderFullName);
     while ($item = readdir($hdl)) {
         $itemFullName = $folderFullName . DIRECTORY_SEPARATOR . $item;
         // Step 8: If physical file is not in DB file result set, then add a file
         if ($item != "." && $item != ".." && is_file($itemFullName) && !in_array($item, $fileNameArr)) {
             $file->saveFile(array('path' => $itemFullName, 'fd_id' => $folderId));
             if ($debug > 1) {
                 ZDebug::my_echo('Adding new file in DB: ' . $itemFullName);
             }
         }
         // Step 9: if physical folder is not in DB folder result set, then add a folder
         if ($item != "." && $item != ".." && is_dir($itemFullName) && !in_array($item, $folderNameArr)) {
             self::addFolder($itemFullName, $folderId);
         }
     }
     closedir($hdl);
 }
开发者ID:elevenfox,项目名称:VTree,代码行数:89,代码来源:SyncFiles.class.php


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