Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
Box\Spout\Writer\ODS\Helper\FileSystemHelper Class Reference
Inheritance diagram for Box\Spout\Writer\ODS\Helper\FileSystemHelper:
Box\Spout\Common\Helper\FileSystemHelper Box\Spout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface Box\Spout\Common\Helper\FileSystemHelperInterface Box\Spout\Common\Helper\FileSystemHelperInterface

Public Member Functions

 __construct ($baseFolderPath, $zipHelper)
 
 createBaseFilesAndFolders ()
 Creates all the folders needed to create a ODS file, as well as the files that won't change.
 
 createContentFile ($worksheetManager, $styleManager, $worksheets)
 Creates the "content.xml" file under the root folder.
 
 createFileWithContents ($parentFolderPath, $fileName, $fileContents)
 Creates a file with the given name and content in the given folder.
 
 createFolder ($parentFolderPath, $folderName)
 Creates an empty folder with the given name under the given parent folder.
 
 createStylesFile ($styleManager, $numWorksheets)
 Creates the "styles.xml" file under the root folder.
 
 deleteFile ($filePath)
 Delete the file at the given path.
 
 deleteFolderRecursively ($folderPath)
 Delete the folder at the given path as well as all its contents.
 
 deleteWorksheetTempFolder ()
 Deletes the temporary folder where sheets content was stored.
 
 getRootFolder ()
 
 getSheetsContentTempFolder ()
 
 zipRootFolderAndCopyToStream ($streamPointer)
 Zips the root folder and streams the contents of the zip into the given stream.
 

Public Attributes

const APP_NAME = 'Spout'
 
const CONTENT_XML_FILE_NAME = 'content.xml'
 
const MANIFEST_XML_FILE_NAME = 'manifest.xml'
 
const META_INF_FOLDER_NAME = 'META-INF'
 
const META_XML_FILE_NAME = 'meta.xml'
 
const MIMETYPE = 'application/vnd.oasis.opendocument.spreadsheet'
 
const MIMETYPE_FILE_NAME = 'mimetype'
 
const SHEETS_CONTENT_TEMP_FOLDER_NAME = 'worksheets-temp'
 
const STYLES_XML_FILE_NAME = 'styles.xml'
 

Protected Member Functions

 copyFileContentsToTarget ($sourceFilePath, $targetResource)
 Streams the content of the file at the given path into the target resource.
 
 createManifestFile ()
 Creates the "manifest.xml" file under the "META-INF" folder (under root)
 
 createMetaFile ()
 Creates the "meta.xml" file under the root folder.
 
 createMetaInfoFolderAndFile ()
 Creates the "META-INF" folder under the root folder as well as the "manifest.xml" file in it.
 
 createMimetypeFile ()
 Creates the "mimetype" file under the root folder.
 
 createRootFolder ()
 Creates the folder that will be used as root.
 
 createSheetsContentTempFolder ()
 Creates the temp folder where specific sheets content will be written to.
 
 throwIfOperationNotInBaseFolder (string $operationFolderPath)
 All I/O operations must occur inside the base folder, for security reasons.
 

Protected Attributes

string $baseFolderRealPath
 Real path of the base folder where all the I/O can occur.
 
string $metaInfFolder
 Path to the "META-INF" folder inside the root folder.
 
string $rootFolder
 Path to the root folder inside the temp folder where the files to create the ODS will be stored.
 
string $sheetsContentTempFolder
 Path to the temp folder, inside the root folder, where specific sheets content will be written to.
 

Constructor & Destructor Documentation

◆ __construct()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::__construct ( $baseFolderPath,
$zipHelper )
Parameters
string$baseFolderPathThe path of the base folder where all the I/O can occur
ZipHelper$zipHelperHelper to perform tasks with Zip archive

Member Function Documentation

◆ copyFileContentsToTarget()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::copyFileContentsToTarget ( $sourceFilePath,
$targetResource )
protected

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.

Parameters
string$sourceFilePathPath of the file whose content will be copied
resource$targetResourceTarget resource that will receive the content
Return values
void

◆ createBaseFilesAndFolders()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::createBaseFilesAndFolders ( )

Creates all the folders needed to create a ODS file, as well as the files that won't change.

Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create at least one of the base folders
Return values
void

Implements Box\Spout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface.

◆ createContentFile()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::createContentFile ( $worksheetManager,
$styleManager,
$worksheets )

Creates the "content.xml" file under the root folder.

Parameters
WorksheetManager$worksheetManager
StyleManager$styleManager
Worksheet[]$worksheets
Return values
FileSystemHelper

◆ createFileWithContents()

Box\Spout\Common\Helper\FileSystemHelper::createFileWithContents ( $parentFolderPath,
$fileName,
$fileContents )
inherited

Creates a file with the given name and content in the given folder.

The parent folder must exist.

Parameters
string$parentFolderPathThe parent folder path where the file is going to be created
string$fileNameThe name of the file to create
string$fileContentsThe contents of the file to create
Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create the file or if the file path is not inside of the base folder
Return values
stringPath of the created file

Implements Box\Spout\Common\Helper\FileSystemHelperInterface.

◆ createFolder()

Box\Spout\Common\Helper\FileSystemHelper::createFolder ( $parentFolderPath,
$folderName )
inherited

Creates an empty folder with the given name under the given parent folder.

Parameters
string$parentFolderPathThe parent folder path under which the folder is going to be created
string$folderNameThe name of the folder to create
Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create the folder or if the folder path is not inside of the base folder
Return values
stringPath of the created folder

Implements Box\Spout\Common\Helper\FileSystemHelperInterface.

◆ createManifestFile()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::createManifestFile ( )
protected

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

Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create the file
Return values
FileSystemHelper

◆ createMetaFile()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::createMetaFile ( )
protected

Creates the "meta.xml" file under the root folder.

Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create the file
Return values
FileSystemHelper

◆ createMetaInfoFolderAndFile()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::createMetaInfoFolderAndFile ( )
protected

Creates the "META-INF" folder under the root folder as well as the "manifest.xml" file in it.

Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create the folder or the "manifest.xml" file
Return values
FileSystemHelper

◆ createMimetypeFile()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::createMimetypeFile ( )
protected

Creates the "mimetype" file under the root folder.

Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create the file
Return values
FileSystemHelper

◆ createRootFolder()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::createRootFolder ( )
protected

Creates the folder that will be used as root.

Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create the folder
Return values
FileSystemHelper

◆ createSheetsContentTempFolder()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::createSheetsContentTempFolder ( )
protected

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.

Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create the folder
Return values
FileSystemHelper

◆ createStylesFile()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::createStylesFile ( $styleManager,
$numWorksheets )

Creates the "styles.xml" file under the root folder.

Parameters
StyleManager$styleManager
int$numWorksheetsNumber of created worksheets
Return values
FileSystemHelper

◆ deleteFile()

Box\Spout\Common\Helper\FileSystemHelper::deleteFile ( $filePath)
inherited

Delete the file at the given path.

Parameters
string$filePathPath of the file to delete
Exceptions
Box\Spout\Common\Exception\IOExceptionIf the file path is not inside of the base folder
Return values
void

Implements Box\Spout\Common\Helper\FileSystemHelperInterface.

◆ deleteFolderRecursively()

Box\Spout\Common\Helper\FileSystemHelper::deleteFolderRecursively ( $folderPath)
inherited

Delete the folder at the given path as well as all its contents.

Parameters
string$folderPathPath of the folder to delete
Exceptions
Box\Spout\Common\Exception\IOExceptionIf the folder path is not inside of the base folder
Return values
void

Implements Box\Spout\Common\Helper\FileSystemHelperInterface.

◆ deleteWorksheetTempFolder()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::deleteWorksheetTempFolder ( )

Deletes the temporary folder where sheets content was stored.

Return values
FileSystemHelper

◆ getRootFolder()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::getRootFolder ( )

◆ getSheetsContentTempFolder()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::getSheetsContentTempFolder ( )
Return values
string

◆ throwIfOperationNotInBaseFolder()

Box\Spout\Common\Helper\FileSystemHelper::throwIfOperationNotInBaseFolder ( string $operationFolderPath)
protectedinherited

All I/O operations must occur inside the base folder, for security reasons.

This function will throw an exception if the folder where the I/O operation should occur is not inside the base folder.

Parameters
string$operationFolderPathThe path of the folder where the I/O operation should occur
Exceptions
Box\Spout\Common\Exception\IOExceptionIf the folder where the I/O operation should occur is not inside the base folder or the base folder does not exist
Return values
void

◆ zipRootFolderAndCopyToStream()

Box\Spout\Writer\ODS\Helper\FileSystemHelper::zipRootFolderAndCopyToStream ( $streamPointer)

Zips the root folder and streams the contents of the zip into the given stream.

Parameters
resource$streamPointerPointer to the stream to copy the zip
Return values
void

The documentation for this class was generated from the following file: