cvs: pear /Text_Wiki/Text/Wiki/Parse/Mediawiki Wikilink.php

From: Date: Thu, 16 Apr 2009 15:10:51 +0000
Subject: cvs: pear /Text_Wiki/Text/Wiki/Parse/Mediawiki Wikilink.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-55942@lists.php.net to get a copy of this message
ritzmo Thu Apr 16 15:10:51 2009 UTC Modified files: /pear/Text_Wiki/Text/Wiki/Parse/Mediawiki Wikilink.php Log: implement fr#14348: allow width/height for images http://cvs.php.net/viewvc.cgi/pear/Text_Wiki/Text/Wiki/Parse/Mediawiki/Wikilink.php?r1=1.8&r2=1.9&diff_format=u Index: pear/Text_Wiki/Text/Wiki/Parse/Mediawiki/Wikilink.php diff -u pear/Text_Wiki/Text/Wiki/Parse/Mediawiki/Wikilink.php:1.8 pear/Text_Wiki/Text/Wiki/Parse/Mediawiki/Wikilink.php:1.9 --- pear/Text_Wiki/Text/Wiki/Parse/Mediawiki/Wikilink.php:1.8 Thu Apr 27 18:09:15 2006 +++ pear/Text_Wiki/Text/Wiki/Parse/Mediawiki/Wikilink.php Thu Apr 16 15:10:51 2009 @@ -18,7 +18,7 @@ * @author Paul M. Jones <pmjones@php.net> * @copyright 2005 bertrand Gugger * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 - * @version CVS: $Id: Wikilink.php,v 1.8 2006/04/27 18:09:15 ritzmo Exp $ + * @version CVS: $Id: Wikilink.php,v 1.9 2009/04/16 15:10:51 ritzmo Exp $ * @link http://pear.php.net/package/Text_Wiki */ @@ -236,7 +236,9 @@ * - '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' + * | - 'align' => 'left', 'center' or 'right' + * | - 'width' => 'NNNpx' + * | - 'height' => 'NNNpx' * * @access public * @param array &$matches The array of matches from parse(). @@ -245,22 +247,30 @@ function image($name, $text, $interlang, $colon) { $attr = array('alt' => ''); - // scan text for supplementary attibutes - if (strpos($text, '|') !== false) { - $splits = explode('|', $text); - $sep = ''; - foreach ($splits as $split) { - switch (strtolower($split)) { - case 'left': case 'center': case 'right': - $attr['align'] = strtolower($split); - break; - default: + $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 = '|'; - } + } } - } else { - $attr['alt'] = $text; } $options = array( 'src' => ($interlang ? $interlang . ':' : '') . $name,

« previous php.pear.cvs (#55942) next »