Logo ZenEngine Logo SourceForge.net ZenEngine
the lightweight CMS framework

ZenFSComposedDocMaker

package : ZenFS
Author : Bruno Desthuilliers
Version : 0.0.5

public class ZenFSComposedDocMaker

An FS DocMaker that build composed document from multiple text/XML/whatever source.
Walk the directory that hosts the parts (usually XML source files, but it should work with any docType defined in your conf and having a proper docMaker). For each of theses which type's in the conf file, ask the contentManager for the appropriate docMaker, create the doc, then compiles alls the docs in a single one. NB : The 'head' part of the doc is the one of the first doc created The conf file for ZenFSComposedDocMaker's docs has the following structure: [docType] priority=[int, with lower values having higher priority] sort_order=[SORT_ASC|SORT_DESC] sort_type=[SORT_STRING|SORT_NUMERIC|SORT_REGULAR|SORT_NATURAL] before_part=[html string to be inserted before every 'part' of that docType] after_part=[html string, to be inserted after every 'part' of that docType] stylesheet=[path/to/specific_stylesheet.css, inserted in the document's head section] ;

Functions

public void ZenFSComposedDocMaker

Keep reference to the contentManager, and parse the conf file
reference to the contentManager is needed here so we can call backon the contentManager to get the right docMakers for the parts of the document.

Parameters :
object [unknown] $contentManager : Reference to the ContentManager
string $docMakerConf : Path to the config.file for the docMaker

Return : (void)

public string getErrorMsg

Return an error message if something went wrong.

Return : (string)

public mixed makeDocument

Create a document from a bunch of source files

Parameters :
mixed $docQueryData : for ZenFS : hash with 'path' = path to the XML file to parse and 'docType' = the docType

Return : (mixed) The created document, or null if failed

private array _listParts

Generate a properly sorted list of docType/docQueryData for files that are parts of the composed document.

Parameters :
string $dirpath : the path to the composed document directory

Return : (array) an (ordered) list of [docType, docQueryData]

private array _sortFiles

sort a list of filenames according to the sort_type and sort_order settings in the composed document conf

Parameters :
array $files : list of files to sort
array $typeInfo : (settings) for the docType of the files

Return : (array) the file list, sorted according to typeInfo

private void _parseConfig

Parse the conf file, order parts docTypes by priority and check for correct sort order.

Parameters :
string $docMakerConf : Path to the config.file for the docMaker

Return : (void)

variables

private array $_docTypes

The config for the docMaker, as an associative array

private string $_errorMsg

Error message

private string $_contentManager

A reference to the parent ZenContentManager.
We need this to ask the contentManager for the docMakersto build the parts of the composed document