Skip to content

Commit

Permalink
Add support for alignment in image links
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.php.net/repository/pear/packages/Text_Wiki/trunk@231924 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Justin Patrin committed Mar 15, 2007
1 parent acd8836 commit 2021562
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Text/Wiki/Parse/Doku/Image.php
Expand Up @@ -42,7 +42,7 @@ class Text_Wiki_Parse_Image extends Text_Wiki_Parse {
*
*/

var $regex = '/({{)(wiki:|https?:\/\/|ftp:\/\/)(.+?)(}})/i';
var $regex = '/({{)(\s*)(wiki:|https?:\/\/|ftp:\/\/)(.+?)(\s*)(}})/i';


/**
Expand All @@ -64,18 +64,18 @@ class Text_Wiki_Parse_Image extends Text_Wiki_Parse {

function process(&$matches)
{
if ($matches[2] != 'wiki:') {
$matches[3] = $matches[2].$matches[3];
if ($matches[3] != 'wiki:') {
$matches[4] = $matches[3].$matches[4];
}

$pos = strpos($matches[3], '?');
$pos = strpos($matches[4], '?');
if ($pos === false) {
$options = array(
'src' => $matches[3],
'src' => $matches[4],
'attr' => array());
} else {
$options = array('src' => substr($matches[3], 0, $pos));
$attr = substr($matches[3], $pos + 1);
$options = array('src' => substr($matches[4], 0, $pos));
$attr = substr($matches[4], $pos + 1);
$parts = explode('x', $attr);
if (isset($parts[0]) && $parts[0] != '') {
$options['attr']['width'] = $parts[0];
Expand All @@ -84,6 +84,14 @@ function process(&$matches)
$options['attr']['height'] = $parts[1];
}
}

if (strlen($matches[2]) && strlen($matches[5])) {
$options['attr']['align'] = 'center';
} elseif (strlen($matches[2])) {
$options['attr']['align'] = 'right';
} elseif (strlen($matches[5])) {
$options['attr']['align'] = 'left';
}

return $this->wiki->addToken($this->rule, $options);
}
Expand Down

0 comments on commit 2021562

Please sign in to comment.