Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401]

(no description)

File Size: 299 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: FileSystemHelper  - X-Ref

Class FileSystemHelper
This class provides helper functions to help with the file system operations
like files/folders creation & deletion for ODS files

__construct($baseFolderPath, $zipHelper)   X-Ref

param: string $baseFolderPath The path of the base folder where all the I/O can occur
param: ZipHelper $zipHelper Helper to perform tasks with Zip archive

getRootFolder()   X-Ref

return: string

getSheetsContentTempFolder()   X-Ref

return: string

createBaseFilesAndFolders()   X-Ref
Creates all the folders needed to create a ODS file, as well as the files that won't change.

return: void

createRootFolder()   X-Ref
Creates the folder that will be used as root

return: FileSystemHelper

createMetaInfoFolderAndFile()   X-Ref
Creates the "META-INF" folder under the root folder as well as the "manifest.xml" file in it

return: FileSystemHelper

createManifestFile()   X-Ref
Creates the "manifest.xml" file under the "META-INF" folder (under root)

return: FileSystemHelper

createSheetsContentTempFolder()   X-Ref
Creates the temp folder where specific sheets content will be written to.
This folder is not part of the final ODS file and is only used to be able to jump between sheets.

return: FileSystemHelper

createMetaFile()   X-Ref
Creates the "meta.xml" file under the root folder

return: FileSystemHelper

createMimetypeFile()   X-Ref
Creates the "mimetype" file under the root folder

return: FileSystemHelper

createContentFile($worksheetManager, $styleManager, $worksheets)   X-Ref
Creates the "content.xml" file under the root folder

param: WorksheetManager $worksheetManager
param: StyleManager $styleManager
param: Worksheet[] $worksheets
return: FileSystemHelper

copyFileContentsToTarget($sourceFilePath, $targetResource)   X-Ref
Streams the content of the file at the given path into the target resource.
Depending on which mode the target resource was created with, it will truncate then copy
or append the content to the target file.

param: string $sourceFilePath Path of the file whose content will be copied
param: resource $targetResource Target resource that will receive the content
return: void

deleteWorksheetTempFolder()   X-Ref
Deletes the temporary folder where sheets content was stored.

return: FileSystemHelper

createStylesFile($styleManager, $numWorksheets)   X-Ref
Creates the "styles.xml" file under the root folder

param: StyleManager $styleManager
param: int $numWorksheets Number of created worksheets
return: FileSystemHelper

zipRootFolderAndCopyToStream($streamPointer)   X-Ref
Zips the root folder and streams the contents of the zip into the given stream

param: resource $streamPointer Pointer to the stream to copy the zip
return: void