View Source

<ac:macro ac:name="note"><ac:parameter ac:name="title">Under Construction</ac:parameter><ac:rich-text-body>
<p>This proposal is under construction and is not ready for review.</p></ac:rich-text-body></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_File_Convert
{zone-data}

{zone-data:proposer-list}
[Jonathan Bond-Caron|mailto:jbondc@gmail.com]
{zone-data}

{zone-data:revision}
1.1 - 1 August 2006: Updated from community comments.
{zone-data}

{zone-data:overview}
Zend_File_Convert is a library that aims to make conversion between file formats simple and efficient. As an example, the initial focus of this proposal will be on an ambitious conversion of XHTML 1.0 (http://www.w3.org/TR/xhtml1/) documents to PDF.
{zone-data}

{zone-data:references}
* [DomPDF|http://www.digitaljunkies.ca/dompdf/]
{zone-data}

{zone-data:requirements}
The first step will consist of creating a factory class that tries to convert file A to file B. Following are list of requirements:

*will* include a factory method.
*will not* allow subclassing.
*will* allow adding file converters
*will* be able to do automatic detection of the file mime-type
*will* throw an exception if no valid file converter is found
*will not* use a cache, this is job of each Zend_File_Converter
{zone-data}

{zone-data:dependencies}
* Zend_Exception
* Zend_File ?
{zone-data}

{zone-data:operation}
The Zend file converter will try to find the appropriate converter (Zend_File_Converter) to make the conversion between two files. If will then call the appropriate converter to make the appropriate file conversion. If no valid converter is found, the class will throw an error.
{zone-data}

{zone-data:milestones}
* Milestone 1: Publish proposal.
* Milestone 2: Revise proposal, approve for Incubator development.
* Milestone 3: Commit working prototype to Incubator.
* Milestone 4: Commit working unit tests.
* Milestone 5: Write up a simple Zend_File_Converter implementation to use as an example.
* Milestone 6: Write end-user documentation.
* Milestone 7: Revise implementation, tests, and documentation based on feedback.
* Milestone 8: Merge changes from Incubator to Core.
{zone-data}

{zone-data:class-list}
* Zend_File_Convert (factory class)
* Zend_File_Converter (abstract class)
* Zend_File_Convert_Exception
{zone-data}

{zone-data:use-cases}
||UC-01||

... (see good use cases book)
{zone-data}

{zone-data:skeletons}
{code}
class Zend_File_Convert{

private $_file = array();
private $_converters = array();

public __construct($filePath) {
// Automatic detection of file mime-type ...
};

// Can specify directly which file converter to use
public convertUsing($converter Zend_File_Converter) {
}

// Can specify which file converter to use
public convert($method, $outputFile = NULL) {
// Loop through converters and pick who can do the conversion
}

// Adds a converter
public add($converter Zend_File_Converter) {
}
}

abstract class Zend_File_Converter {
// Supported file conversions (i.e. XHTMLtoPDF)
abstract public getSupportedMethods(){};
abstract public isSupportedMethod($file, $method){};
abstract public convert($file, $outputFile, $method) {};
}

class Zend_File_Convert_Exception extends Zend_Exception {}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>