protected function _clearDir($type = null, $timeNow = null) {
		switch (mb_strtolower($type)) {
			case 'export':
				$clearPath = $this->_getExportDir();
				$storageTime = $this->_getStorageTimeExport();
				break;
			case 'preview':
				$clearPath = $this->_getPreviewDir();
				$storageTime = $this->_getStorageTimePreview();
				break;
			default:
				return false;
		}

		$result = true;
		$oFolder = new Folder($clearPath, true);
		$exportFiles = $oFolder->find('.*', false);
		if (empty($exportFiles)) {
			return $result;
		}

		if (!empty($timeNow)) {
			$timeNow = (int)$timeNow;
		} else {
			$timeNow = time();
		}

		$exportFilesPath = $oFolder->pwd();
		foreach ($exportFiles as $exportFile) {
			$oFile = new File($exportFilesPath . DS . $exportFile);
			$lastChangeTime = $oFile->lastChange();
			if ($lastChangeTime === false) {
				continue;
			}

			if (($timeNow - $lastChangeTime) > $storageTime) {
				if (!$oFile->delete()) {
					$result = false;
				}
			}
		}

		return true;
	}
protected function _clearDir($type = null, $timeNow = null) {
		switch (mb_strtolower($type)) {
			case 'export':
				$clearPath = $this->_getExportDir();
				$storageTime = $this->_getStorageTimeExport();
				break;
			case 'preview':
				$clearPath = $this->_getPreviewDir();
				$storageTime = $this->_getStorageTimePreview();
				break;
			default:
				return false;
		}

		$result = true;
		$oFolder = new Folder($clearPath, true);
		$exportFiles = $oFolder->find('.*', false);
		if (empty($exportFiles)) {
			return $result;
		}

		if (!empty($timeNow)) {
			$timeNow = (int)$timeNow;
		} else {
			$timeNow = time();
		}

		$exportFilesPath = $oFolder->pwd();
		foreach ($exportFiles as $exportFile) {
			$oFile = new File($exportFilesPath . DS . $exportFile);
			$lastChangeTime = $oFile->lastChange();
			if ($lastChangeTime === false) {
				continue;
			}

			if (($timeNow - $lastChangeTime) > $storageTime) {
				if (!$oFile->delete()) {
					$result = false;
				}
			}
		}

		return true;
	}
protected function _clearDir ( $ type = null , $ timeNow = null ) { switch ( mb_strtolower ( $ type ) ) { case 'export' : $ clearPath = $ this -> _getExportDir ( ) ; $ storageTime = $ this -> _getStorageTimeExport ( ) ; break ; case 'preview' : $ clearPath = $ this -> _getPreviewDir ( ) ; $ storageTime = $ this -> _getStorageTimePreview ( ) ; break ; default : return false ; } $ result = true ; $ oFolder = new Folder ( $ clearPath , true ) ; $ exportFiles = $ oFolder -> find ( '.*' , false ) ; if ( empty ( $ exportFiles ) ) { return $ result ; } if ( ! empty ( $ timeNow ) ) { $ timeNow = ( int ) $ timeNow ; } else { $ timeNow = time ( ) ; } $ exportFilesPath = $ oFolder -> pwd ( ) ; foreach ( $ exportFiles as $ exportFile ) { $ oFile = new File ( $ exportFilesPath . DS . $ exportFile ) ; $ lastChangeTime = $ oFile -> lastChange ( ) ; if ( $ lastChangeTime === false ) { continue ; } if ( ( $ timeNow - $ lastChangeTime ) > $ storageTime ) { if ( ! $ oFile -> delete ( ) ) { $ result = false ; } } } return true ; }
Cleanup the export directory from old files

@param string $type Type of target directory. One of:
- `export`;
- `preview`;
@param int $timeNow Timestamp of current date and time.
@return bool Success
Cleanup the export directory from old files