1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
<?php
/**
* TEXY! SUPPORT FOR FLASH
*/
// include Texy!
require_once dirname(__FILE__) . 'Texy.php';
/**
* User handler for images
*
* @param TexyHandlerInvocation handler invocation
* @param TexyImage
* @param TexyLink
* @return TexyHtml|string|FALSE
*/
function imageHandler($invocation, $image, $link)
{
$parts = explode(':', $image->URL);
if (count($parts) !== 2) return $invocation->proceed();
switch ($parts[0]) {
case 'youtube':
$video = htmlSpecialChars($parts[1]);
$dimensions = 'width="'.($image->width ? $image->width : 425).'" height="'.($image->height ? $image->height : 350).'"';
$code = '<div><object '.$dimensions.'>'
. '<param name="movie" value="http://www.youtube.com/v/'.$video.'" /><param name="wmode" value="transparent" />'
. '<embed src="http://www.youtube.com/v/'.$video.'" type="application/x-shockwave-flash" wmode="transparent" '.$dimensions.' /></object></div>';
$texy = $invocation->getTexy();
return $texy->protect($code, Texy::CONTENT_BLOCK);
}
return $invocation->proceed();
}
$texy = new Texy();
$texy->addHandler('image', 'imageHandler');
// processing
$text = file_get_contents('sample.texy');
$html = $texy->process($text); // that's all folks!
// echo formated output
header('Content-type: text/html; charset=utf-8');
echo $html;
// echo generated HTML code
echo '<hr />';
echo '<pre>';
echo htmlSpecialChars($html);
echo '</pre>';
|