Skip to content

Commit

Permalink
finished "perfecting" CSS and linking in the Image rule
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.php.net/repository/pear/packages/Text_Wiki/trunk@168817 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Paul M Jones committed Sep 19, 2004
1 parent f64c515 commit 57ed333
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
27 changes: 20 additions & 7 deletions Text/Wiki/Render/Xhtml/Image.php
Expand Up @@ -4,7 +4,7 @@ class Text_Wiki_Render_Xhtml_Image extends Text_Wiki_Render {
var $conf = array(
'base' => '/',
'css' => null,
'css_href' => null
'css_link' => null
);


Expand Down Expand Up @@ -43,9 +43,10 @@ function token($options)
$href = $options['attr']['link'];
} else {
// it's a WikiPage; assume it exists.
/** @todo This needs to honor the sprintf convention (pmjones) */
$href =
$this->wiki->getRenderConf('xhtml', 'wikilink', 'view_url') .
/** @todo This needs to honor sprintf wikilinks (pmjones) */
/** @todo This needs to honor interwiki (pmjones) */
/** @todo This needs to honor freelinks (pmjones) */
$href = $this->wiki->getRenderConf('xhtml', 'wikilink', 'view_url') .
$options['attr']['link'];
}
} else {
Expand Down Expand Up @@ -104,13 +105,24 @@ function token($options)
// start the HTML output
$output = '<img src="' . htmlspecialchars($src) . '"';

// get the CSS class but don't add it yet
$css = $this->formatConf(' class="%s"', 'css');

// add the attributes to the output, and be sure to
// track whether or not we find an "alt" attribute
$alt = false;
foreach ($options['attr'] as $key => $val) {

// track the 'alt' attribute
if (strtolower($key) == 'alt') {
$alt = true;
}

// the 'class' attribute overrides the CSS class conf
if (strtolower($key) == 'class') {
$css = null;
}

$key = htmlspecialchars($key);
$val = htmlspecialchars($val);
$output .= " $key=\"$val\"";
Expand All @@ -122,14 +134,15 @@ function token($options)
$output .= " alt=\"$alt\"";
}

// end the image tag
$output .= ' />';
// end the image tag with the automatic CSS class (if any)
$output .= "$css />";

// was the image clickable?
if ($href) {
// yes, add the href and return
$href = htmlspecialchars($href);
$output = "<a href=\"$href\">$output</a>";
$css = $this->formatConf(' class="%s"', 'css_link');
$output = "<a$css href=\"$href\">$output</a>";
}

return $output;
Expand Down
9 changes: 5 additions & 4 deletions package.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
<!-- $Id: package.xml,v 1.26 2004-09-19 02:56:27 pmjones Exp $ -->
<!-- $Id: package.xml,v 1.27 2004-09-19 21:41:26 pmjones Exp $ -->
<package version="1.0">
<name>Text_Wiki</name>
<summary>Abstracts parsing and rendering rules for Wiki markup in structured plain text.</summary>
Expand All @@ -15,16 +15,17 @@
</maintainers>
<release>
<version>0.22.0</version>
<date>????</date>
<date>2004-09-19</date>
<license>LGPL</license>
<state>beta</state>
<state>alpha</state>
<notes>
* Render rules for Url and Interwiki use XHTML compliant "target"s now, per suggestion from Aaron Kalin and JS code from youngpup.net
* Parse rule for Heading now adds an ID attribute to the token, will be used when generating table of contents (based on ideas from Stephane Le Solliec)
* Render rule for Image now guesses width and height, and adds a pseudo-center alignment option (thanks Stephane Solliec)
* Render rule for Image now guesses width and height, and adds a pseudo-center alignment option, and works better with non-local images (thanks Stephane Solliec)
* Base Render class now has formatConf() method to wrap a config value in an sprintf() format
* Added CSS class configuration keys for all appropriate rules (*big* thanks to Bob Glamm, glamm at a-s-i dot com, who did a ton of work on this)
* Render rules for Wikilink and Freelink are much more configurable: put new-link text before or after the page name, or use CSS only to control the look of new-links
* fixed bug 2316: swapped processing order to Center and Newline
</notes>
<filelist>

Expand Down

0 comments on commit 57ed333

Please sign in to comment.