/usr/share/horde/wicked/lib/Text_Wiki/Parse/Mediawiki/Wikilink2.php is in php-horde-wicked 2.0.7-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 | <?php
require_once 'Text/Wiki/Parse/Mediawiki/Wikilink.php';
/**
* Placeholder class as a complement to the Wikilink2 renderer.
*
* We are overwriting the image() function because we want it to pass on to add
* an Image2 token instead.
*
* @package Wicked
*/
class Text_Wiki_Parse_Wikilink2 extends Text_Wiki_Parse_Wikilink
{
/**
* Generates an image token. Token options are:
* - 'src' => the name of the image file
* - 'attr' => an array of attributes for the image:
* | - 'alt' => the optional alternate image text
* | - 'align' => 'left', 'center' or 'right'
* | - 'width' => 'NNNpx'
* | - 'height' => 'NNNpx'
*
* @access public
* @param array &$matches The array of matches from parse().
* @return string token to be used as replacement
*/
public function image($name, $text, $interlang, $colon)
{
$attr = array('alt' => '');
$splits = explode('|', $text);
$sep = '';
foreach ($splits as $split) {
switch (strtolower($split)) {
case 'left': case 'center': case 'right':
$attr['align'] = strtolower($split);
break;
default:
// this regex is imho not restrictive enough but should
// keep false positives to a minimum
if (preg_match('/\dpx\s*$/i', $split)) {
$split = preg_replace("/\s/", "", $split);
$split = preg_replace("/px$/i", "", $split);
list($width,$height) = explode("x", $split);
$attr['width'] = $width;
if ($height) {
$attr['height'] = $height;
}
}
else {
$attr['alt'] .= $sep . $split;
$sep = '|';
}
}
}
$options = array(
'src' => ($interlang ? $interlang . ':' : '') . $name,
'attr' => $attr);
// create and return the replacement token
return $this->wiki->addToken('Image2', $options);
}
}
|