/usr/share/doc/php-texy/examples/images/demo.php is in php-texy 2.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 60 61 62 63 64 65 66 67 68 69 70 | <?php
/**
* This demo shows how Texy! control images (useful for CMS)
* - programmable images controlling
* - onMouseOver state
* - support for preloading
*/
// 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)
{
if ($image->URL == 'user') // accepts only [* user *]
{
$image->URL = 'image.gif'; // image URL
$image->overURL = 'image-over.gif'; // onmouseover image
$image->modifier->title = 'Texy! logo';
if ($link) $link->URL = 'big.gif'; // linked image
}
return $invocation->proceed($image, $link);
}
$texy = new Texy();
$texy->addHandler('image', 'imageHandler');
$texy->imageModule->root = 'imagesdir/'; // "in-line" images root
$texy->imageModule->linkedRoot = 'imagesdir/big/'; // "linked" images root
$texy->imageModule->leftClass = 'my-left-class'; // left-floated image modifier
$texy->imageModule->rightClass = 'my-right-class'; // right-floated image modifier
$texy->imageModule->defaultAlt = 'default alt. text';// default image alternative text
// 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>';
// echo all used images
echo '<hr />';
echo '<pre>';
echo 'used images:';
print_r($texy->summary['images']);
echo 'onmouseover images:';
print_r($texy->summary['preload']);
echo '</pre>';
|