<commit_before><?php

namespace SBBCodeParser;

class Node_Container_Document extends Node_Container
{
	/**
	 * Current Tag
	 * @var Node_Container
	 */
	protected $current_tag = null;

	/**
	 * Assoc array of all the BBCodes for this document
	 * @var array
	 */
	protected $bbcodes = array();

	/**
	 * Base URI to be used for links, images, ect.
	 * @var string
	 */
	protected $base_uri = null;

	/**
	 * Assoc array of emoticons in smiley_code => smiley_url format
	 * @var array
	 */
	protected $emoticons = array();

	/*
	 * If to throw errors when encountering bad BBCode or
	 * to silently try and fix
	 * @var bool
	 */
	protected $throw_errors = false;


	public function __construct($load_defaults=true, $throw_errors=true)
	{
		$this->throw_errors = $throw_errors;

		// Load default BBCodes
		if($load_defaults)
			$this->add_bbcodes($this->default_bbcodes());
	}

	/**
	 * Gets an array of the default BBCodes
	 * @return array
	 */
	public static function default_bbcodes()
	{
		return array(
			new BBCode('b', '<strong>%content%</strong>'),
			new BBCode('i', '<em>%content%</em>'),
			new BBCode('strong', '<strong>%content%</strong>'),
			new BBCode('em', '<em>%content%</em>'),
			new BBCode('u', '<span style="text-decoration: underline">%content%</span>'),
			new BBCode('s', '<span style="text-decoration: line-through">%content%</span>'),
			new BBCode('blink', '<span style="text-decoration: blink">%content%</span>'),
			new BBCode('sub', '<sub>%content%</sub>'),
			new BBCode('sup', '<sup>%content%</sup>'),
			new BBCode('ins', '<ins>%content%</ins>'),
			new BBCode('del', '<del>%content%</del>'),

			new BBCode('right', '<div style="text-align: right">%content%</div>', BBCode::BLOCK_TAG),
			new BBCode('left', '<div style="text-align: left">%content%</div>', BBCode::BLOCK_TAG),
			new BBCode('center', '<div style="text-align: center">%content%</div>', BBCode::BLOCK_TAG),
			new BBCode('justify', '<div style="text-align: justify">%content%</div>', BBCode::BLOCK_TAG),

			// notes only show in editing so ignore it
			new BBCode('note', ''),
			new BBCode('hidden', ''),

			new BBCode('abbr', function($content, $attribs)
			{
				return '<abbr title="' . $attribs['default'] . '">' . $content . '</abbr>';
			}),
			new BBCode('acronym', function($content, $attribs)
			{
				return '<acronym title="' . $attribs['default'] . '">' . $content . '</acronym>';
			}),

			new BBCode('icq', '<a href="http://www.icq.com/people/about_me.php?uin=%content%">
				<img  src="http://status.icq.com/online.gif?icq=%content%&amp;img=5"> %content%</a>',
				BBCode::INLINE_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('skype', '<a href="skype:jovisa737590?call">
				<img src="http://mystatus.skype.com/bigclassic/%content%" style="border: none;" width="182"
				height="44" alt="My status" /></a>',
				BBCode::INLINE_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),

			new BBCode('bing', '<a href="http://www.bing.com/search?q=%content%">%content%</a>',
				BBCode::INLINE_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('google', '<a href="http://www.google.com/search?q=%content%">%content%</a>',
				BBCode::INLINE_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('wikipedia', '<a href="http://www.wikipedia.org/wiki/%content%">%content%</a>',
				BBCode::INLINE_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('youtube', function($content, $attribs)
			{
				if(substr($content, 0, 23) === 'http://www.youtube.com/')
					$uri = $content;
				else
					$uri = 'http://www.youtube.com/v/' . $content;

				return '<iframe width="480" height="390" src="' . $uri . '" frameborder="0"></iframe>';
			}, BBCode::BLOCK_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('vimeo', function($content, $attribs)
			{
				if(substr($content, 0, 24) === 'http://player.vimeo.com/')
					$uri = $content;
				else if(substr($content, 0, 17) === 'http://vimeo.com/'
					|| substr($content, 0, 21) === 'http://www.vimeo.com/'
					&& preg_match("/http:\/\/(?:www\.)?vimeo\.com\/([0-9]{4,10})/", $content, $matches))
				{
					preg_match("/http:\/\/(?:www\.)?vimeo\.com\/([0-9]{4,10})/", $content, $matches);
					$uri = 'http://player.vimeo.com/video/' . $matches[1] . '?title=0&amp;byline=0&amp;portrait=0';
				}
				else
					$uri = 'http://player.vimeo.com/video/' . $content . '?title=0&amp;byline=0&amp;portrait=0';

				return '<iframe src="' . $uri . '" width="400" height="225" frameborder="0"></iframe>';
			}, BBCode::BLOCK_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('flash', function($content, $attribs)<commit_msg>Update konfigurasi BBcodeParser untuk embed youtube video<commit_after><?php

namespace SBBCodeParser;

class Node_Container_Document extends Node_Container
{
	/**
	 * Current Tag
	 * @var Node_Container
	 */
	protected $current_tag = null;

	/**
	 * Assoc array of all the BBCodes for this document
	 * @var array
	 */
	protected $bbcodes = array();

	/**
	 * Base URI to be used for links, images, ect.
	 * @var string
	 */
	protected $base_uri = null;

	/**
	 * Assoc array of emoticons in smiley_code => smiley_url format
	 * @var array
	 */
	protected $emoticons = array();

	/*
	 * If to throw errors when encountering bad BBCode or
	 * to silently try and fix
	 * @var bool
	 */
	protected $throw_errors = false;


	public function __construct($load_defaults=true, $throw_errors=true)
	{
		$this->throw_errors = $throw_errors;

		// Load default BBCodes
		if($load_defaults)
			$this->add_bbcodes($this->default_bbcodes());
	}

	/**
	 * Gets an array of the default BBCodes
	 * @return array
	 */
	public static function default_bbcodes()
	{
		return array(
			new BBCode('b', '<strong>%content%</strong>'),
			new BBCode('i', '<em>%content%</em>'),
			new BBCode('strong', '<strong>%content%</strong>'),
			new BBCode('em', '<em>%content%</em>'),
			new BBCode('u', '<span style="text-decoration: underline">%content%</span>'),
			new BBCode('s', '<span style="text-decoration: line-through">%content%</span>'),
			new BBCode('blink', '<span style="text-decoration: blink">%content%</span>'),
			new BBCode('sub', '<sub>%content%</sub>'),
			new BBCode('sup', '<sup>%content%</sup>'),
			new BBCode('ins', '<ins>%content%</ins>'),
			new BBCode('del', '<del>%content%</del>'),

			new BBCode('right', '<div style="text-align: right">%content%</div>', BBCode::BLOCK_TAG),
			new BBCode('left', '<div style="text-align: left">%content%</div>', BBCode::BLOCK_TAG),
			new BBCode('center', '<div style="text-align: center">%content%</div>', BBCode::BLOCK_TAG),
			new BBCode('justify', '<div style="text-align: justify">%content%</div>', BBCode::BLOCK_TAG),

			// notes only show in editing so ignore it
			new BBCode('note', ''),
			new BBCode('hidden', ''),

			new BBCode('abbr', function($content, $attribs)
			{
				return '<abbr title="' . $attribs['default'] . '">' . $content . '</abbr>';
			}),
			new BBCode('acronym', function($content, $attribs)
			{
				return '<acronym title="' . $attribs['default'] . '">' . $content . '</acronym>';
			}),

			new BBCode('icq', '<a href="http://www.icq.com/people/about_me.php?uin=%content%">
				<img  src="http://status.icq.com/online.gif?icq=%content%&amp;img=5"> %content%</a>',
				BBCode::INLINE_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('skype', '<a href="skype:jovisa737590?call">
				<img src="http://mystatus.skype.com/bigclassic/%content%" style="border: none;" width="182"
				height="44" alt="My status" /></a>',
				BBCode::INLINE_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),

			new BBCode('bing', '<a href="http://www.bing.com/search?q=%content%">%content%</a>',
				BBCode::INLINE_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('google', '<a href="http://www.google.com/search?q=%content%">%content%</a>',
				BBCode::INLINE_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('wikipedia', '<a href="http://www.wikipedia.org/wiki/%content%">%content%</a>',
				BBCode::INLINE_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('youtube', function($content, $attribs)
			{
				if(substr($content, 0, 23) === 'http://www.youtube.com/')
					$uri = $content;
				else
					$uri = 'http://www.youtube.com/embed/' . $content;

				return '<iframe width="480" height="390" src="' . $uri . '" frameborder="0"></iframe>';
			}, BBCode::BLOCK_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('vimeo', function($content, $attribs)
			{
				if(substr($content, 0, 24) === 'http://player.vimeo.com/')
					$uri = $content;
				else if(substr($content, 0, 17) === 'http://vimeo.com/'
					|| substr($content, 0, 21) === 'http://www.vimeo.com/'
					&& preg_match("/http:\/\/(?:www\.)?vimeo\.com\/([0-9]{4,10})/", $content, $matches))
				{
					preg_match("/http:\/\/(?:www\.)?vimeo\.com\/([0-9]{4,10})/", $content, $matches);
					$uri = 'http://player.vimeo.com/video/' . $matches[1] . '?title=0&amp;byline=0&amp;portrait=0';
				}
				else
					$uri = 'http://player.vimeo.com/video/' . $content . '?title=0&amp;byline=0&amp;portrait=0';

				return '<iframe src="' . $uri . '" width="400" height="225" frameborder="0"></iframe>';
			}, BBCode::BLOCK_TAG, false, array(), array('text_node'), BBCode::AUTO_DETECT_EXCLUDE_ALL),
			new BBCode('flash', function($content, $attribs)
{'fraction_non_alphanumeric': 0.22025159826768406, 'fraction_numerical': 0.011342544854609197, 'mean_word_length': 4.464225352112676, 'pattern_counts': {'":': 0, '<': 105, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 18, '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': '4232980', 'n_tokens_mistral': 3901, 'n_tokens_neox': 3421, 'n_words': 661}