* Invision Power Services * IP.Board v3.4.9 * Text Parsing: HTML * Last Updated: $Date: 2012-06-08 09:28:02 +0100 (Fri, 08 Jun 2012) $ * * * @author $Author: mmecham $ * @copyright (c) 2001 - 2009 Invision Power Services, Inc. * @license http://www.invisionpower.com/company/standards.php#license * @package IP.Board * @link http://www.invisionpower.com * @since 9th March 2005 11:03 * @version $Revision: 10894 $ * * Revised in 3.4 by Matt Mecham * Refactored into a text parsing module * */ if ( ! defined( 'IN_IPB' ) ) { print "
$match )
{
$txt = $matches[0][$id];
$txt = str_replace( '_prettyXprint', 'prettyprint', $txt );
$txt = str_replace( '_lang-' , 'lang-' , $txt );
$txt = str_replace( '_linenums' , 'linenums' , $txt );
$html = str_replace( $matches[0][$id], $txt, $html );
}
/* ensure emo dir is converted over (legacy posts) */
if ( strstr( $html, '<#EMO_DIR#>' ) )
{
$html = str_replace( '<#EMO_DIR#>', $this->registry->getClass('output')->skin['set_emo_dir'], $html );
}
/* Add lightbox rel tag. Emoticons should be code at this point */
if ( ! parent::$Perms['parseHtml'] )
{
$html = preg_replace( "/(?!)
]+?)>/i", "
", $html );
$html = preg_replace( "/
]+?)class='bbc_img'([^>]+?)>/i", "
", $html );
}
return $html;
}
/**
* Convert to BBCode
* @param string
* @return string
*/
public function toBBCode( $content )
{
/* Anything to parse? */
if ( ! $content )
{
return $content;
}
$ot = $content;
$content = str_replace( array( "\r\n", "\n" ), "\n", $content );
/* Tidy up first */
$content = str_replace( '', '', $content );
$content = preg_replace( '#(\s+?)?
(\s+?)?(
]+?)?>|)#is', '
', $content );
/* Before we content/strip newlines, lets make code safe */
$content = $this->_recurseAndParse( 'pre', $content, "_parsePreTag" );
$content = str_replace( ' ', "{'tab'}", $content );
$content = str_replace( "\t", "{'tab'}", $content );
$content = str_replace( ' ', ' ', $content );
/* looks to be non RTE content that has ended up there */
if ( ! strstr( $content, '
", $content );
}
else
{
$content = str_replace( "\n", "", $content );
}
/* Restore preserved newlines */
$content = str_replace( "", "\n", $content );
// -----------------------------------------
// Clean up already encoded HTML
// -----------------------------------------
$content = str_replace( '"', '"', $content );
$content = str_replace( ''', "'", $content );
// -----------------------------------------
// Fix up incorrectly nested urls / BBcode
// -----------------------------------------
// @link
// http://community.invisionpower.com/tracker/issue-24704-pasting-content-in-rte-with-image-first/
// Revert the fix for now as it causes more issues than the original one
$content = preg_replace( '#]+?)\[(.+?)[\'"](.+?)' . '>(.+?)\[\\2#is', '\\4[\\2', $content );
// $content = preg_replace(
// '#\'"]+?)[\'"](.*?)>(.+?)\[([^<]+?)#is', '\\3[\\4', $content );
// -----------------------------------------
// Make URLs safe (prevent tag stripping)
// -----------------------------------------
$content = preg_replace_callback( '#<(a href|img src)=([\'"])([^>]+?)(\\2)#is', array( $this, '_unhtmlUrl' ), $content );
// -----------------------------------------
// WYSI-Weirdness #1: BR tags to \n
// -----------------------------------------
$content = preg_replace( '#
]+?)>#', "
", $content );
$content = str_ireplace( array( "
", "
" ), "\n", $content );
$content = trim( $content );
// -----------------------------------------
// Before we can use strip_tags, we should
// clean out any javascript and CSS
// -----------------------------------------
$content = preg_replace( '/\