CVS update: /cowiki/includes/cowiki/class/render/
[email protected] 29 May 2005 15:41:22 -0000
| Newsgroups | gmane.comp.php.cowiki.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: cmarble Date: 2005/05/29 08:41:22 Modified: cowiki/includes/cowiki/class/render/class.FrontHtmlTransformer.php cowiki/includes/cowiki/class/render/class.XmlPrettyHtmlPrinter.php Log: Issue number: 196 Submitted by: cmarble Modified justification code. XmlPretty now uses SAX parser, much neater. File Changes: Directory: /cowiki/includes/cowiki/class/render/ ================================================ File [changed]: class.FrontHtmlTransformer.php Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/render/class.FrontHtmlTransformer.php?r1=1.43&r2=1.44 Delta lines: +26 -5 -------------------- --- class.FrontHtmlTransformer.php 9 Apr 2005 23:35:00 -0000 1.43 +++ class.FrontHtmlTransformer.php 29 May 2005 15:41:20 -0000 1.44 @@ -2,7 +2,7 @@ /** * - * $Id: class.FrontHtmlTransformer.php,v 1.43 2005/04/09 23:35:00 dgorski Exp $ + * $Id: class.FrontHtmlTransformer.php,v 1.44 2005/05/29 15:41:20 cmarble Exp $ * * This file is part of coWiki. coWiki is free software under the terms of * the GNU General Public License (GPL). Read the LICENSE file. If you did @@ -17,7 +17,7 @@ * @author Daniel T. Gorski, <[email protected]> * @copyright (C) Daniel T. Gorski, {@link http://www.develnet.org} * @license http://www.gnu.org/licenses/gpl.html - * @version $Revision: 1.43 $ + * @version $Revision: 1.44 $ * */ @@ -172,21 +172,21 @@ // Transform missing document (link) $sStr = preg_replace_callback( - '=<link strref\="([^"]*)">(.*)</link>=Usi', + '=<link origin\="[^"]*" strref\="([^"]*)">(.*)</link>=Usi', array($this, '_transformMissingDocument'), $sStr ); // Transform exisisting document (link) $sStr = preg_replace_callback( - '=<link idref\="([^"]*)">(.*)</link>=Usi', + '=<link origin\="[^"]*" idref\="([^"]*)">(.*)</link>=Usi', array($this, '_transformExistingDocument'), $sStr ); // Transform link with URI $sStr = preg_replace_callback( - '=<link href\="([^"]*)">(.*)</link>=Usi', + '=<link origin\="[^"]*" href\="([^"]*)">(.*)</link>=Usi', array($this, '_transformUri'), $sStr ); @@ -227,6 +227,12 @@ $sStr ); + $sStr = preg_replace_callback( + '=<(left|center|right)>(.*)</\1>=Usi', + array($this, '_transformJustification'), + $sStr + ); + // Get rid of remaining XML elements $aArr = array( '<toc>', '</toc>', @@ -319,7 +325,8 @@ // "Deleted document" if (!is_object($Node)) { $this->bChangedRef = true; - $sStr = '['.__('I18N_DOC_DELETED_DOCUMENT').']'; + $sStr = '['.'('.$sRef.')('.$sAlias.')'. + __('I18N_DOC_DELETED_DOCUMENT').']'; } } @@ -720,6 +727,20 @@ $sStr .= $aMatches[1]; $sStr .= '</blockquote>'; + return $sStr; + } + + // -------------------------------------------------------------------- + + protected function &_transformJustification(&$aMatches) { + $sStr = '<div width="100%" style="text-align:'.$aMatches[1].'">'; + $sStr .= $aMatches[2]; + $sStr .= '</div>'; + /* + $sStr = '<p width="100%" style="text-align:'.$aMatches[1].'">'; + $sStr .= $aMatches[2]; + $sStr .= '</p>'; + */ return $sStr; } File [changed]: class.XmlPrettyHtmlPrinter.php Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/render/class.XmlPrettyHtmlPrinter.php?r1=1.7&r2=1.8 Delta lines: +102 -3 --------------------- --- class.XmlPrettyHtmlPrinter.php 16 Jan 2005 23:26:51 -0000 1.7 +++ class.XmlPrettyHtmlPrinter.php 29 May 2005 15:41:20 -0000 1.8 @@ -2,7 +2,7 @@ /** * - * $Id: class.XmlPrettyHtmlPrinter.php,v 1.7 2005/01/16 23:26:51 dgorski Exp $ + * $Id: class.XmlPrettyHtmlPrinter.php,v 1.8 2005/05/29 15:41:20 cmarble Exp $ * * This file is part of coWiki. coWiki is free software under the terms of * the GNU General Public License (GPL). Read the LICENSE file. If you did @@ -17,7 +17,7 @@ * @author Daniel T. Gorski, <[email protected]> * @copyright (C) Daniel T. Gorski, {@link http://www.develnet.org} * @license http://www.gnu.org/licenses/gpl.html - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * */ @@ -41,6 +41,7 @@ $rParser = null, $nIndent = null, $sCDataColor = '#000000', + $sRet = null, $sWordWrap = null; /** @@ -113,11 +114,109 @@ * * @author Daniel T. Gorski, <[email protected]> * @since coWiki 0.3.0 + * @author Archie Campbell, <[email protected]> + * @since coWiki 0.4.0 + * + */ + public function getPretty($sStr, $nWordWrap = 60) { + + // Check if init() was successful + if (!$this->rParser) { + return false; + } + + $this->sCDataColor = RuntimeContext::getInstance()-> + getRegistry()->get('COLOR_CODE_HTML'); + $this->nWordWrap = $nWordWrap; + + xml_set_default_handler( $this->rParser, + array(&$this,'xml_default_handler') ); + xml_set_element_handler( $this->rParser, + array(&$this,'xml_start_handler'), + array(&$this,'xml_end_handler') ); + xml_set_character_data_handler( $this->rParser, + array(&$this,'xml_cdata_handler') ); + + $this->sRet = ''; + + if(!xml_parse( $this->rParser, $sStr )){ + echo xml_error_string(xml_get_error_code($this->rParser)); + } + + return $this->sRet; + } + + /** + * xml element default handler + * + * @access protected + * + * @author Archie Campbell <[email protected]> + * @since coWiki 0.4.0 + * + */ + protected function xml_default_handler( &$parser, $sData ) { + $this->sRet .= html_entity_decode($sData); + } + /** + * xml cdata handler + * + * @access protected + * + * @author Archie Campbell <[email protected]> + * @since coWiki 0.4.0 + * + */ + protected function xml_cdata_handler( &$parser, $sData ) { + $this->sRet .= $this->_formatCData($sData) ."\n"; + } + /** + * xml element start handler + * + * @access protected + * + * @author Archie Campbell <[email protected]> + * @since coWiki 0.4.0 + * + */ + protected function xml_start_handler( &$parser, $sName, $aAttrib ){ + $this->nIndent++; + $this->sRet .= $this->_getIndent(); + $this->sRet .= '<'.$sName; + foreach($aAttrib as $attr => $value) { + $this->sRet .= ' '.$attr.'="'.$value.'"'; + } + $this->sRet .= '>'."\n"; + } + /** + * xml element end handler + * + * @access protected + * + * @author Archie Campbell <[email protected]> + * @since coWiki 0.4.0 + * + */ + protected function xml_end_handler( &$parser, $sName ) { + $this->sRet .= $this->_getIndent(); + $this->nIndent--; + $this->sRet .= '</'.$sName.'>'."\n"; + } + /** + * Get pretty + * + * @access public + * @param string + * @param integer + * @return mixed + * + * @author Daniel T. Gorski, <[email protected]> + * @since coWiki 0.3.0 * * @todo [D11N] Check description * @todo [D11N] Check the parameter type of "$nWordWrap" */ - public function getPretty($sStr, $nWordWrap = 60) { + private function _old_getPretty($sStr, $nWordWrap = 60) { // Check if init() was successful if (!$this->rParser) {