function testFolderOrDocument()
 {
     $oFolder =& KTFolderUtil::add($this->oFolder, 'testFolderOrDocument', $this->oUser);
     $this->assertNotError($oFolder);
     if (PEAR::isError($oFolder)) {
         return;
     }
     $oDocument =& KTDocumentUtil::add($oFolder, 'testFolderOrDocument.txt', $this->oUser, array());
     $this->assertNotError($oDocument);
     if (PEAR::isError($oDocument)) {
         return;
     }
     $sPath = "/Root Folder/" . $this->oFolder->getName() . "/testFolderOrDocument/";
     $aReturn =& KTBrowseUtil::folderOrDocument($sPath . 'testFolderOrDocument.txt');
     $this->assertEqual($aReturn[0], $oFolder->getID());
     $this->assertEqual($aReturn[1], $oDocument->getID());
     $this->assertEqual($aReturn[2], NULL);
     $bReturn =& KTBrowseUtil::folderOrDocument($sPath . 'testFolderOrDocument.txt/ktcore.delete');
     $this->assertEqual($bReturn, false);
     $aReturn =& KTBrowseUtil::folderOrDocument($sPath . 'testFolderOrDocument.txt/ktcore.delete', true);
     $this->assertEqual($aReturn[0], $oFolder->getID());
     $this->assertEqual($aReturn[1], $oDocument->getID());
     $this->assertEqual($aReturn[2], 'ktcore.delete');
     $aReturn =& KTBrowseUtil::folderOrDocument($sPath);
     $this->assertEqual($aReturn[0], $oFolder->getID());
     $this->assertEqual($aReturn[1], NULL);
     $this->assertEqual($aReturn[2], NULL);
     $bReturn =& KTBrowseUtil::folderOrDocument($sPath . 'ktcore.delete');
     $this->assertEqual($bReturn, false);
     $aReturn =& KTBrowseUtil::folderOrDocument($sPath . 'ktcore.delete', true);
     $this->assertEqual($aReturn[0], $oFolder->getID());
     $this->assertEqual($aReturn[1], NULL);
     $this->assertEqual($aReturn[2], 'ktcore.delete');
 }
<?php

require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . '/browse/browseutil.inc.php';
error_reporting(E_ALL);
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/test.sxw"));
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/test.sxw/ktcore.delete"));
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/test.sxw/ktcore.delete", true));
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/Default Unit"));
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/Default Unit/ktcore.delete"));
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/Default Unit/ktcore.delete", true));
Exemple #3
0
function checkDirectory($path)
{
    global $fsPath, $aIgnore;
    $fullpath = sprintf('%s/%s', $fsPath, $path);
    if (!is_dir($fullpath)) {
        print "Not a directory: {$fullpath}\n";
    }
    if ($path === '/Deleted') {
        // Deleted files handled separately.
        return;
    }
    if (!empty($path)) {
        $fod = KTBrowseUtil::folderOrDocument($path);
        if ($fod === false) {
            $GLOBALS['aFoldersToRemove'][] = $path;
            return;
        }
    }
    $dh = @opendir($fullpath);
    if ($dh === false) {
        print "Could not open directory: {$fullpath}\n";
    }
    while (($filename = readdir($dh)) !== false) {
        if (in_array($filename, $aIgnore)) {
            continue;
        }
        $subrelpath = sprintf('%s/%s', $path, $filename);
        $subfullpath = sprintf('%s/%s', $fsPath, $subrelpath);
        if (is_dir($subfullpath)) {
            checkDirectory($subrelpath);
        }
        if (is_file($subfullpath)) {
            checkFile($subrelpath);
        }
    }
}