예제 #1
0
 function testSplitPath()
 {
     $strings = array('/foo/bar' => array('/foo', 'bar'), '/foo/bar/' => array('/foo', 'bar'), 'foo/bar/' => array('foo', 'bar'), 'foo/bar' => array('foo', 'bar'), 'foo/bar/baz' => array('foo/bar', 'baz'), 'foo/bar/baz/' => array('foo/bar', 'baz'), 'foo' => array('', 'foo'), 'foo/' => array('', 'foo'), '/foo/' => array('', 'foo'), '/foo' => array('', 'foo'), '' => array(null, null), "/àfoó/bar" => array("/àfoó", 'bar'), "/àfoo/bür/" => array("/àfoo", "bür"), "foo/àür" => array("foo", "àür"));
     foreach ($strings as $input => $expected) {
         $output = URLUtil::splitPath($input);
         $this->assertEquals($expected, $output, 'The expected output for \'' . $input . '\' was incorrect');
     }
 }
예제 #2
0
 function testSplitPath()
 {
     $strings = ['/foo/bar' => ['/foo', 'bar'], '/foo/bar/' => ['/foo', 'bar'], 'foo/bar/' => ['foo', 'bar'], 'foo/bar' => ['foo', 'bar'], 'foo/bar/baz' => ['foo/bar', 'baz'], 'foo/bar/baz/' => ['foo/bar', 'baz'], 'foo' => ['', 'foo'], 'foo/' => ['', 'foo'], '/foo/' => ['', 'foo'], '/foo' => ['', 'foo'], '' => [null, null], "/àfoó/bar" => ["/àfoó", 'bar'], "/àfoo/bür/" => ["/àfoo", "bür"], "foo/àür" => ["foo", "àür"]];
     foreach ($strings as $input => $expected) {
         $output = URLUtil::splitPath($input);
         $this->assertEquals($expected, $output, 'The expected output for \'' . $input . '\' was incorrect');
     }
 }
예제 #3
0
 /**
  * This function allows you to check if a node exists.
  *
  * @param string $path
  * @return bool
  */
 public function nodeExists($path)
 {
     try {
         // The root always exists
         if ($path === '') {
             return true;
         }
         list($parent, $base) = URLUtil::splitPath($path);
         $parentNode = $this->getNodeForPath($parent);
         if (!$parentNode instanceof ICollection) {
             return false;
         }
         return $parentNode->childExists($base);
     } catch (Exception\NotFound $e) {
         return false;
     }
 }
예제 #4
0
 /**
  * Renames the node
  *
  * @param string $name The new name
  * @return void
  */
 function setName($name)
 {
     list($parentLocalPath, ) = URLUtil::splitPath($this->localPath);
     list($parentPath, ) = URLUtil::splitPath($this->path);
     list(, $newName) = URLUtil::splitPath($name);
     $newPath = $parentLocalPath . '/' . $newName . '/';
     $path = trim($parentPath, 'files') . '/' . $newName . '/';
     $hash = sha1($path);
     $log = print_r([$this->exData->pdo, $name, $newPath, $hash, date('Y-m-d H:i:s'), $this->dirid], true);
     file_put_contents('cache/logs/xxebug.log', ' --- ' . date('Y-m-d H:i:s') . ' --- RequestInterface --- ' . PHP_EOL . $log, FILE_APPEND);
     $stmt = $this->exData->pdo->prepare('UPDATE vtiger_files_dir SET name=?, path = ?, hash=?, mtime=? WHERE id=?;');
     $stmt->execute([$name, $newPath, $hash, date('Y-m-d H:i:s'), $this->dirid]);
     rename($this->exData->localStorageDir . $this->localPath, $this->exData->localStorageDir . $newPath);
     $this->path = $newPath;
 }
 /**
  * This method will check if the url matches the temporary file pattern
  * if it does, it will return an path based on $this->dataDir for the
  * temporary file storage.
  *
  * @param string $path
  * @return boolean|string
  */
 protected function isTempFile($path)
 {
     // We're only interested in the basename.
     list(, $tempPath) = URLUtil::splitPath($path);
     foreach ($this->temporaryFilePatterns as $tempFile) {
         if (preg_match($tempFile, $tempPath)) {
             return $this->getDataDir() . '/sabredav_' . md5($path) . '.tempfile';
         }
     }
     return false;
 }
예제 #6
0
 /**
  * Deletes a node from the tree
  *
  * @param string $path
  * @return void
  */
 public function delete($path)
 {
     $node = $this->getNodeForPath($path);
     $node->delete();
     list($parent) = URLUtil::splitPath($path);
     $this->markDirty($parent);
 }