* @license PHP License * @package WB * @subpackage vfs */ /** * Virtual File System * * Basics * * @version 0.2.0 * @package WB * @subpackage vfs */ class WBVFS extends WBStdClass { /** * file information table */ const TABLE_FILE = 'vfsfile'; /** * file upload chunks */ const TABLE_UPLOAD = 'vfsfileupload'; /** * user table */ const TABLE_USER = 'user'; const MIME_PLAIN = 'plain'; /** * constructor * * @param array $parameter */ public function __construct($parameter = array()) { } /** * Switch on/off translation feature * * @param bool|int $switch */ public function switchTranslation($switch = false) { $switch = intval($switch); if (0 < $switch) { $switch = true; } else { $switch = false; } $this->doSwitchTranslation($switch); } /** * Actually switch translation * * @param bool $switch */ protected function doSwitchTranslation($switch) { } /** * make name unique * * automatically change name like Windows(tm) explorer does * * @param string $name * @param array $siblings * @return string */ protected function makeUniqueName($name, $siblings) { // remove forward slashes from name $name = str_replace('/', '_', $name); $i = 1; $nameFormat = $name . ' (%d)'; // see whether name is already a numbered one if (preg_match('/(.+)\s\((\d+)\)$/', $name, $match)) { $i = intval($match[2]); $nameFormat = $match[1] . ' (%d)'; } while ($i < 1000) { $ok = true; foreach ($siblings as $s) { // check name of siblings if ($name == $s['name']) { $ok = false; break; } } if ($ok) { break; } ++$i; $name = sprintf($nameFormat, $i); } return $name; } } ?>