<commit_before><?php
/**
 * Created on 2007-09-26
 * 
 *  
 * SVN INFORMATION:::
 * ------------------
 * SVN Signature::::::: $Id$
 * Last Author::::::::: $Author$ 
 * Current Revision:::: $Revision$ 
 * Repository Location: $HeadURL$ 
 * Last Updated:::::::: $Date$
 * 
 * 
 * Originally from a snippet (just the function) on PHPFreaks.com: http://www.phpfreaks.com/quickcode/BBCode/712.php
 * The original code had parse errors, so it had to be fixed... While it was posted as just a basic function, 
 * the code within (such as the reference to "$this->bbCodeData" indicated it was from a class... so it has 
 * been converted.
 */

require_once(dirname(__FILE__) .'/cs_versionAbstract.class.php');

class cs_bbCodeParser extends cs_versionAbstract {
	
	/** Array containing all the codes & how to parse them. */
	private $bbCodeData = NULL;
	
	//=========================================================================
	/**
	 * Setup internal structures.
	 */
	function __construct() {
		# Which BBCode is accepted here
		$this->bbCodeData = array(
			'bold' => array(
				'start'	=> array('[b]', '\[b\](.*)', '<b>\\1'),
				'end'	=> array('[/b]', '\[\/b\]', '</b>'),
			),
			
			'underline' => array(
				'start'	=> array('[u]', '\[u\](.*)', '<u>\\1'),
				'end'	=> array('[/u]', '\[\/u\]', '</u>'),
			),
			
			'italic' => array(
				'start'	=> array('[i]', '\[i\](.*)', '<i>\\1'),
				'end'	=> array('[/i]', '\[\/i\]', '</i>'),
			),
			
			'image' => array(
				'start'	=> array('[img]', '\[img\](http:\/\/|ftp:\/\/|\/)(.*)(.jpg|.jpeg|.bmp|.gif|.png)', '<img src=\'\\1\\2\\3\' />'),
				'end'	=> array('[/img]', '\[\/img\]', ''), 
			),
			
			#  [url]http://x.com[/url]
			'url1' => array(
				'start'	=> array('[url]', '\[url\](http:\/\/|ftp:\/\/)(.*)', '<a target="_blank" href=\'\\1\\2\'>\\1\\2'),
				'end'	=> array('[/url]', '\[\/url\]', '</a>'),
			),
			
			# [url=http://x.com]stuff[/url]
			'url2' => array(
				'start'	=> array('[url]', '\[url=(http:\/\/|ftp:\/\/)(.*)\](.*)', '<a target="_blank" href=\'\\1\\2\'>\\3'), 
				'end'	=> array('[/url]', '\[\/url\]', '</a>'),
			),
			
			'code' => array(
				'start'	=> array('[code]', '\[code\](.*)', '<br /><br /><b>CODE</b>:<div class="code">\\1'),
				'end'	=> array('[/code]', '\[\/code\]', '</div><br />'),
			),
		);
	}//end __construct()
	//=========================================================================
	
	
	
	//=========================================================================
	/**
	 * Ensure the object is initialized properly, throw exception if not.
	 */
	private function isInitialized() {
		if(!is_array($this->bbCodeData) || !count($this->bbCodeData)) {
			throw new exception(__METHOD__ .": BBCode array not initialized");
		}
	}//end isInitialized()<commit_msg>Support "https://<commit_after><?php
/**
 * Created on 2007-09-26
 * 
 *  
 * SVN INFORMATION:::
 * ------------------
 * SVN Signature::::::: $Id$
 * Last Author::::::::: $Author$ 
 * Current Revision:::: $Revision$ 
 * Repository Location: $HeadURL$ 
 * Last Updated:::::::: $Date$
 * 
 * 
 * Originally from a snippet (just the function) on PHPFreaks.com: http://www.phpfreaks.com/quickcode/BBCode/712.php
 * The original code had parse errors, so it had to be fixed... While it was posted as just a basic function, 
 * the code within (such as the reference to "$this->bbCodeData" indicated it was from a class... so it has 
 * been converted.
 */

require_once(dirname(__FILE__) .'/cs_versionAbstract.class.php');

class cs_bbCodeParser extends cs_versionAbstract {
	
	/** Array containing all the codes & how to parse them. */
	private $bbCodeData = NULL;
	
	//=========================================================================
	/**
	 * Setup internal structures.
	 */
	function __construct() {
		# Which BBCode is accepted here
		$this->bbCodeData = array(
			'bold' => array(
				'start'	=> array('[b]', '\[b\](.*)', '<b>\\1'),
				'end'	=> array('[/b]', '\[\/b\]', '</b>'),
			),
			
			'underline' => array(
				'start'	=> array('[u]', '\[u\](.*)', '<u>\\1'),
				'end'	=> array('[/u]', '\[\/u\]', '</u>'),
			),
			
			'italic' => array(
				'start'	=> array('[i]', '\[i\](.*)', '<i>\\1'),
				'end'	=> array('[/i]', '\[\/i\]', '</i>'),
			),
			
			'image' => array(
				'start'	=> array('[img]', '\[img\](http:\/\/|https:\/\/|ftp:\/\/|\/)(.*)(.jpg|.jpeg|.bmp|.gif|.png)', '<img src=\'\\1\\2\\3\' />'),
				'end'	=> array('[/img]', '\[\/img\]', ''), 
			),
			
			#  [url]http://x.com[/url]
			'url1' => array(
				'start'	=> array('[url]', '\[url\](http:\/\/|https:\/\/|ftp:\/\/)(.*)', '<a target="_blank" href=\'\\1\\2\'>\\1\\2'),
				'end'	=> array('[/url]', '\[\/url\]', '</a>'),
			),
			
			# [url=http://x.com]stuff[/url]
			'url2' => array(
				'start'	=> array('[url]', '\[url=(http:\/\/|https:\/\/|ftp:\/\/)(.*)\](.*)', '<a target="_blank" href=\'\\1\\2\'>\\3'), 
				'end'	=> array('[/url]', '\[\/url\]', '</a>'),
			),
			
			'code' => array(
				'start'	=> array('[code]', '\[code\](.*)', '<br /><br /><b>CODE</b>:<div class="code">\\1'),
				'end'	=> array('[/code]', '\[\/code\]', '</div><br />'),
			),
		);
	}//end __construct()
	//=========================================================================
	
	
	
	//=========================================================================
	/**
	 * Ensure the object is initialized properly, throw exception if not.
	 */
	private function isInitialized() {
		if(!is_array($this->bbCodeData) || !count($this->bbCodeData)) {
			throw new exception(__METHOD__ .": BBCode array not initialized");
		}
	}//end isInitialized()
{'fraction_non_alphanumeric': 0.36210299659070516, 'fraction_numerical': 0.009689574735331061, 'mean_word_length': 2.992836676217765, 'pattern_counts': {'":': 2, '<': 41, '<?xml version=': 0, '>': 89, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4716461', 'n_tokens_mistral': 2277, 'n_tokens_neox': 1944, 'n_words': 414}