<?php
/**
 * Adodis Blog package
 * @author J-Extension <contact@jextn.com>
 * @link http://www.jextn.com
 * @copyright (C) 2012 - 2013 J-Extension
 * @license GNU/GPL, see LICENSE.php for full license.
**/


defined('_JEXEC') or die('Restricted access');

class AdodisBlogVideosHelper
{

	public function processVideos( $content )
	{
		$pattern 	= '/http:\/\/www\.youtube\.com\/watch\?(.*)v=([a-zA-Z0-9_\-]+)(\S*)/i';
		$replace 	= '<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/$2&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$2&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>';
		$content 	= preg_replace($pattern, $replace, $content);
		return  $content;
	}

	public function removeVideos( $content )
	{
		$pattern 	= '/http:\/\/www\.youtube\.com\/watch\?(.*)v=([a-zA-Z0-9_\-]+)(\S*)/i';
		$replace 	= '{Video}';
		//$replace 	= ' ';
		$content 	= preg_replace($pattern, $replace, $content);
		return  $content;
	}

	public function processReplaceImages( $HTMLContent)
	{
    	$content 	= preg_replace("/<img[^>]+\>/i", "{image}", $HTMLContent);
    	return $content;
	}
}