PHP Class ODTTemplateManager

Show file Open project: openeyes/openeyes Class Usage Examples

Public Methods

Method Description
__construct ( $filename, $templateDir, $outputDir, $outputName )
changeImageFromGDObject ( $imageName, $image ) * Change an existing image in document by GD object
exchangeAllStringValuesByStyleName ( $texts )
exchangeGeneratedTablesWithTextNodes ( $data )
exchangeStringValueByStyleName ( $styleName, $value ) * Change variables in odt xml by style-name property
exchangeStringValues ( $data ) * Change ${} variables in odt xml to the param value
fillTableByName ( $name, $data, $type = 'name' ) * Find table in xml and fill it with data values
generatePDF ( ) * Generate pdf file from odt and delete temporary folder
generatePDFPageN ( $pageNumber = 1 ) * Convert the generated pdf N page
generateXmlTables ( $dataTables ) private
getPDF ( ) * Get generated pdf
imgReplaceByName ( $imageName, $newImageUrl ) * Change an existing image in document by new image url
saveContentXML ( ) * Save xml file content after edit
storePDF ( ) : ProtectedFile Store the PDF as a ProtectedFile in the system

Protected Methods

Method Description
cleanUp ( ) deletes all the files generated in the process of generating the final output
getImageHrefFromImageNode ( $imageName ) * Get image path from the xml document

Private Methods

Method Description
addStyleToHeader ( $tableName, $style ) * Add a new style to the office:automatic-styles node
createDirs ( $path ) * Create directoy by path
createNode ( $xml, $tag, $attribs, $value = '' ) * Create new element,set attributes and append to xml node
createSingleOrMultilineTextNode ( $node, $string, $existingStyleName = null )
deleteDir ( $path ) * Delete temporary files by path
getTableColsCount ( $firstRow ) * Count table columns
getTableVariableNode ( $nodeValue, $text ) * Find and change ${} varibale in table
openContentXML ( ) * Open xml file
replaceTableNode ( $templateVariableName, $tableXml )
unZip ( $createZipNameDir = true, $overwrite = true ) * Unzip odt file into the temporary directory
zipOdtFile ( ) * Zip xml files

Method Details

__construct() public method

public __construct ( $filename, $templateDir, $outputDir, $outputName )
$filename
$templateDir
$outputDir
$outputName

changeImageFromGDObject() public method

* Change an existing image in document by GD object
public changeImageFromGDObject ( $imageName, $image )
$imageName
$image

cleanUp() protected method

deletes all the files generated in the process of generating the final output
protected cleanUp ( )

exchangeAllStringValuesByStyleName() public method

exchangeGeneratedTablesWithTextNodes() public method

exchangeStringValueByStyleName() public method

* Change variables in odt xml by style-name property
public exchangeStringValueByStyleName ( $styleName, $value )
$styleName
$value

exchangeStringValues() public method

* Change ${} variables in odt xml to the param value
public exchangeStringValues ( $data )
$data

fillTableByName() public method

* Find table in xml and fill it with data values
public fillTableByName ( $name, $data, $type = 'name' )
$name
$data

generatePDF() public method

* Generate pdf file from odt and delete temporary folder
public generatePDF ( )

generatePDFPageN() public method

* Convert the generated pdf N page
public generatePDFPageN ( $pageNumber = 1 )
$pageNumber

generateXmlTables() public method

private
public generateXmlTables ( $dataTables )

getImageHrefFromImageNode() protected method

* Get image path from the xml document
protected getImageHrefFromImageNode ( $imageName )
$imageName

getPDF() public method

* Get generated pdf
public getPDF ( )

imgReplaceByName() public method

* Change an existing image in document by new image url
public imgReplaceByName ( $imageName, $newImageUrl )
$imageName
$newImageUrl

saveContentXML() public method

* Save xml file content after edit
public saveContentXML ( )

storePDF() public method

Store the PDF as a ProtectedFile in the system
public storePDF ( ) : ProtectedFile
return ProtectedFile