Author: kn Date: Tue Feb 5 16:31:15 2008 New Revision: 7295 Log: - Refactored converter class stubs # Class stub refactoring done now.
Modified: experimental/Document/src/converters/xslt/ezp3_ezp4.php experimental/Document/src/converters/xslt/xhtml_docbook.php experimental/Document/src/interfaces/converter.php Modified: experimental/Document/src/converters/xslt/ezp3_ezp4.php ============================================================================== --- experimental/Document/src/converters/xslt/ezp3_ezp4.php [iso-8859-1] (original) +++ experimental/Document/src/converters/xslt/ezp3_ezp4.php [iso-8859-1] Tue Feb 5 16:31:15 2008 @@ -1,52 +1,40 @@ <?php /** - * File containing the ezcDocumentEzp3ToEzp4 class + * File containing the ezcDocumentEzp3ToEzp4Converter class * * @package Document * @version //autogen// - * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved. * @license http://ez.no/licenses/new_bsd New BSD License - * */ - -class ezcDocumentEzp3ToEzp4 implements ezcDocumentConverter +/** + * Converter for eZ Publish 3 document to eZ Publish 4 documents. + * + * @package Document + * @version //autogen// + * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +class ezcDocumentEzp3ToEzp4Converter extends ezcDocumentXsltConverter { /** - * XSLT stylesheet + * Construct converter * - * @var DOMDocument + * @return void */ - static private $xslt = null; + public function __construct() + { + // Define the conversion file to use. + parent::__construct( dirname( __FILE__ ) . '/ezp3_ezp4.xsl' ); + } - /** - * XSLT processor + /*** + * Old implementation, maybe possible to reuse some parts later. Since we + * got no tests yet, leave it commented out. * - * @var XSLTProcessor - */ - static private $proc = null; - /** - * Various conversion parameters - * - * @var mixed - */ - private $parameters = array(); - - /** - * XPath sting to select all inline custom tags by 'name' attribute - * Used in XSLT. - * - * @var string - */ - static private $inlineCustomTags = ''; - - /** - * Constructs new converter - * - * @param $parameters - */ public function __construct( $parameters = array() ) { $this->parameters = $parameters; @@ -54,9 +42,9 @@ if ( isset( $this->parameters['inline_custom_tags'] ) ) foreach( $this->parameters['inline_custom_tags'] as $key=>$tagname ) { - ezcDocumentEzp3ToEzp4::$inlineCustomTags .= "@name = '$tagname'"; + self::$inlineCustomTags .= "@name = '$tagname'"; if ( $key != count( $parameters['inline_custom_tags'] ) - 1 ) - ezcDocumentEzp3ToEzp4::$inlineCustomTags .= ' or '; + self::$inlineCustomTags .= ' or '; } } @@ -64,23 +52,23 @@ * Returns converted document * * @return ezcDocumentXML - */ + * / static public function convert( ezcDocument $doc, $parameters = array() ) { - if ( !ezcDocumentEzp3ToEzp4::$proc ) + if ( !self::$proc ) { - if ( !ezcDocumentEzp3ToEzp4::$xslt ) + if ( !self::$xslt ) { - ezcDocumentEzp3ToEzp4::$xslt = new DOMDocument; - ezcDocumentEzp3ToEzp4::$xslt->load( dirname( __FILE__ ) . '/../converters/ezp3_ezp4.xsl' ); + self::$xslt = new DOMDocument; + self::$xslt->load( dirname( __FILE__ ) . '/../converters/ezp3_ezp4.xsl' ); } - ezcDocumentEzp3ToEzp4::$proc = new XSLTProcessor; - ezcDocumentEzp3ToEzp4::$proc->importStyleSheet( ezcDocumentEzp3ToEzp4::$xslt ); - ezcDocumentEzp3ToEzp4::$proc->registerPHPFunctions(); + self::$proc = new XSLTProcessor; + self::$proc->importStyleSheet( self::$xslt ); + self::$proc->registerPHPFunctions(); } // XSLT transformation - $resultDOM = ezcDocumentEzp3ToEzp4::$proc->transformToDoc( $doc->getDOM() ); + $resultDOM = self::$proc->transformToDoc( $doc->getDOM() ); $resultDoc = new ezcDocumentXML( 'ezp4', $resultDOM); return $resultDoc; @@ -88,9 +76,9 @@ static public function getInlineCustomTags() { - return ezcDocumentEzp3ToEzp4::$inlineCustomTags; + return self::$inlineCustomTags; } - + // */ } ?> Modified: experimental/Document/src/converters/xslt/xhtml_docbook.php ============================================================================== --- experimental/Document/src/converters/xslt/xhtml_docbook.php [iso-8859-1] (original) +++ experimental/Document/src/converters/xslt/xhtml_docbook.php [iso-8859-1] Tue Feb 5 16:31:15 2008 @@ -1,42 +1,39 @@ <?php - /** - * File containing the ezcDocumentXhtmlToDocbook class + * File containing the ezcDocumentEzp3ToEzp4Converter class * * @package Document * @version //autogen// - * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved. * @license http://ez.no/licenses/new_bsd New BSD License - * */ - -class ezcDocumentXhtmlToDocbook implements ezcDocumentConverter +/** + * Converter for eZ Publish 3 document to eZ Publish 4 documents. + * + * @package Document + * @version //autogen// + * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +class ezcDocumentXhtmlToDocbookConverter extends ezcDocumentXsltConverter { /** - * XSLT stylesheet + * Construct converter * - * @var DOMDocument + * @return void */ - static private $xslt = null; + public function __construct() + { + // Define the conversion file to use. + parent::__construct( dirname( __FILE__ ) . '/xhtml_docbook.xsl' ); + } - /** - * XSLT processor + /*** + * Old implementation, maybe possible to reuse some parts later. Since we + * got no tests yet, leave it commented out. * - * @var XSLTProcessor - */ - static private $proc = null; - /** - * Various conversion parameters - * - * @var mixed - */ - private $parameters = array(); - - /** - * Constructs new converter - */ public function __construct( $parameters = array() ) { $this->parameters = $parameters; @@ -46,27 +43,27 @@ * Returns converted document * * @return ezcDocumentXML - */ + * / static public function convert( ezcDocument $doc, $parameters = array() ) { - if ( !ezcDocumentXhtmlToDocbook::$proc ) + if ( !self::$proc ) { - if ( !ezcDocumentXhtmlToDocbook::$xslt ) + if ( !self::$xslt ) { - ezcDocumentXhtmlToDocbook::$xslt = new DOMDocument; - ezcDocumentXhtmlToDocbook::$xslt->load( dirname( __FILE__ ) . '/../converters/xhtml_docbook.xsl' ); + self::$xslt = new DOMDocument; + self::$xslt->load( dirname( __FILE__ ) . '/../converters/xhtml_docbook.xsl' ); } - ezcDocumentXhtmlToDocbook::$proc = new XSLTProcessor; - ezcDocumentXhtmlToDocbook::$proc->importStyleSheet( ezcDocumentXhtmlToDocbook::$xslt ); + self::$proc = new XSLTProcessor; + self::$proc->importStyleSheet( self::$xslt ); } // XSLT transformation - $resultDOM = ezcDocumentXhtmlToDocbook::$proc->transformToDoc( $doc->getDOM() ); + $resultDOM = self::$proc->transformToDoc( $doc->getDOM() ); $resultDoc = new ezcDocumentXML( 'docbook', $resultDOM); return $resultDoc; } - + // */ } ?> Modified: experimental/Document/src/interfaces/converter.php ============================================================================== --- experimental/Document/src/interfaces/converter.php [iso-8859-1] (original) +++ experimental/Document/src/interfaces/converter.php [iso-8859-1] Tue Feb 5 16:31:15 2008 @@ -27,7 +27,7 @@ * @param ezcDocument $doc * @return ezcDocument */ - public function convert( ezcDocument $doc ); + abstract public function convert( ezcDocument $doc ); } ?> -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components