====== Modified Boxes Plugin ======
---- plugin ----
description: Just an example to prove the point
author : Robert Meerman
email : robert.meerman@gmail.com
type : syntax
lastupdate : 2005-10-25
compatible :
depends :
conflicts : boxes
similar : note, boxes
tags : boxes
----
//This page is a child of [[:plugin:boxes]], and outlines a modified version of it. Please consult the original version for more detailed documentation//
===== Changes =====
- Syntax changed: **%%<<<%%** width classes | title ::: //content// ::: caption **%%>>>%%**
- Markup allows in captions
- Title and Caption may be multiple lines now (i.e. multiple paragraphs)
- Width may be specified in %, px, em or ex
Why might you want this? If you can specify the width in px, you can use boxes to caption images seamlessly (by making the box the same width as the image) regardless of the browser width. Being able to place markup in the caption is nice for when you want to draw attention to a note about, say, an alternative version of some software — it looks really nice having the download link in the caption.
===== syntax.php =====
syntax.php
>>
* width width of the box, must include unit (one of "%", "px", "em" or "ex")
* styles one or more classes used to style the box, several predefined styles included in style.css
* title (optional) all text between '|' and ':::' will be rendered above the main code text with a
* different style.
* caption (optional) all text between ':::' and '>>>' will be rendered above the main code text with a
* different style.
*
* NB: To omit the title, drop it and it's preceeding '|'
* To omit the caption, drop it and it's preceeding ':::'
* To omit styles, drop the first ':::' and all preceeding it
* You can have an empty style section and title: <<< | title ::: content >>>
* EG1: <<< contents >>>
* EG2: <<< round red ::: contents >>>
* EG3: <<< {media_link} ::: From left to right: Person 1, Person 2, Person 3 >>>
*
* Acknowledgements:
* Rounded corners based on snazzy borders by Stu Nicholls (http://www.cssplay.co.uk/boxes/snazzy)
* which is in turn based on nifty corners by Alessandro Fulciniti (http://pro.html.it/esempio/nifty/)
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Christopher Smith
"; break; case 'box_open' : if ($this->title_mode) { $this->title_mode = false; $renderer->doc .= "
"; } else { $renderer->doc .= "
\n".$this->_xhtml_boxopen($data).""; } break; case 'data' : $renderer->doc .= $renderer->_xmlEntities($data); break; case 'caption_open' : $this->caption_mode = true; $renderer->doc .= "
"; // Then open caption break; case 'box_close' : if($this->caption_mode){ // Close caption div $renderer->doc .= "
"; break; } return true; } return false; } function _boxstyle($str) { if (!strlen($str)) return array(); $styles = array(); $tokens = preg_split('/\s+/', $str, 9); // limit is defensive foreach ($tokens as $token) { if (preg_match('/^\d+(%|px|em|ex)$/', $token)) { $styles['width'] = $token; continue; } $styles['class'] = (isset($styles['class']) ? $styles['class'].' ' : '').$token; } return $styles; } function _xhtml_boxopen($style) { $class = "class='box" . (isset($style['class']) ? ' '.$style['class'] : '') . "'"; $style = isset($style['width']) ? " style='width: {$style['width']};'" : ''; $html = "
div.box div.box_title > p, div.box div.box_caption > p{
margin: 0;
padding: 0;
}
==== Complete stylesheet ====
Should you wish to download the complete stylesheet, here it is.
/* plugin:box */
div.box {
width: 50%;
margin: 1em auto;
border: 1px solid;
padding: 4px;
}
/* rounded corners styles from Stu Nicholls snazzy borders, http://www.cssplay.co.uk/boxes/snazzy.html */
.xtop, .xbottom {background:transparent; font-size:0; line-height: 1px;}
.xb1, .xb2, .xb3, .xb4 {display:block; overflow:hidden; border-style: solid;}
.xb2, .xb3 {height:1px;}
.xb2, .xb3, .xb4 {border-width:0 1px;}
.xb1 {height: 0; margin:0 5px; border-width:1px 0 0 0;}
.xb2 {margin:0 3px; border-width:0 2px;}
.xb3 {margin:0 2px;}
.xb4 {height:2px; margin:0 1px;}
div.box .xtop, div.box .xbottom {display: none;}
div.box.round .xtop, div.box.round .xbottom {display: block;}
div.box.round { border: none; padding: 0;}
div.box.round .xbox {display:block; border-width:0 1px; border-style: solid; padding: 0 4px; }
div.box div.box_title, div.box div.box_caption {
font-size: 90%;
margin: 0;
padding: 2px 6px;
line-height: 1.2em;
}
div.box div.box_title > p, div.box div.box_caption > p{
margin: 0;
padding: 0;
}
div.box div.box_title { margin-bottom: 4px;}
div.box div.box_caption { margin-top: 4px;}
div.box .box_content {
margin: 0;
padding: 0 6px;
border-width: 1px;
border-style: dashed;
line-height: 1.2em;
}
/* floating alignment */
div.box.left {
float: left;
margin-right: 1em;
}
div.box.right {
float: right;
margin-left: 1em;
}
/* colours */
/* default */
div.box, div.box .box_content, div.box .xbox, div.box .xb1, div.box .xb2, div.box .xb3, div.box .xb4 {
border-color: #8cacbb;
}
div.box, div.box .xbox, div.box .xb1, div.box .xb2, div.box .xb3, div.box .xb4 {
background: #ecf1f4;
}
div.box div.box_title, div.box div.box_caption { background: #dee7ec;}
div.box .box_content { background: #f7fafb;}
/* blue */
div.box.blue, div.box.blue .box_content, div.box.blue .xbox,
div.box.blue .xb1, div.box.blue .xb2, div.box.blue .xb3, div.box.blue .xb4 {
border-color: #bbbbdd;
}
div.box.blue, div.box.blue .xbox,
div.box.blue .xb1, div.box.blue .xb2, div.box.blue .xb3, div.box.blue .xb4 {
background: #e4ecf8;
}
div.box.blue div.box_title, div.box.blue div.box_caption {background: #cad0ee;}
div.box.blue .box_content {background: #f4f8fd;}
/* red */
div.box.red, div.box.red .box_content, div.box.red .xbox,
div.box.red .xb1, div.box.red .xb2, div.box.red .xb3, div.box.red .xb4 {
border-color: #ddbbbb;
}
div.box.red, div.box.red .xbox,
div.box.red .xb1, div.box.red .xb2, div.box.red .xb3, div.box.red .xb4 {
background: #f8ece4;
}
div.box.red div.box_title, div.box.red div.box_caption {background: #eed0ca;}
div.box.red .box_content {background: #fdf4ec;}
/* green */
div.box.green, div.box.green .box_content, div.box.green .xbox,
div.box.green .xb1, div.box.green .xb2, div.box.green .xb3, div.box.green .xb4 {
border-color: #bbddbb;
}
div.box.green, div.box.green .xbox,
div.box.green .xb1, div.box.green .xb2, div.box.green .xb3, div.box.green .xb4 {
background: #e4f8f2;
}
div.box.green div.box_title, div.box.green div.box_caption {background: #c4e4d4;}
div.box.green .box_content {background: #ecfaf6;}
/* orange */
div.box.orange, div.box.orange .box_content, div.box.orange .xbox,
div.box.orange .xb1, div.box.orange .xb2, div.box.orange .xb3, div.box.orange .xb4 {
border-color: #da3;
}
div.box.orange, div.box.orange .xbox,
div.box.orange .xb1, div.box.orange .xb2, div.box.orange .xb3, div.box.orange .xb4 {
background: #f4e8ca;
}
div.box.orange div.box_title, div.box.orange div.box_caption {background: #f0d499;}
div.box.orange .box_content {background: #f8f0da;}
/* must come last to override coloured background when using rounded corners */
div.box.round {
background: transparent !important;
}
/* end plugin:box */