====== Progress Bar Plugin ====== ---- plugin ---- description: This plugin lets you put a progress bar on any wiki page. author : Mischa The Evil email : mischa_the_evil@hotmail.com type : syntax lastupdate : 2009-03-09 compatible : depends : conflicts : similar : progrecss tags : diagram, chart, progressbar downloadurl : https://trello.com/1/cards/659c9dfecba2e595a5c4e9c0/attachments/659c9ef29b6dabf7c2c98910/download/progressbar-1.0.0_20090309.zip bugtracker : sourcerepo : donationurl : screenshot_img : ---- ===== Introduction ===== The original author of this plugin was [[mmiikkee13@gmail.com|Mike Smith]]. Looking at the comments up to today (2009-03-10) it seems that he has stopped maintaining this plugin. I have taken-over maintaining this plugin to prevent it from being lost... ===== Syntax ===== Simply put '''' in any page, where ''[size]'' is a number from 0 to 100 without the % sign. Only multiples of 10 are supported, so you can only use 0%, 10%, 20%, etc. ==== Examples ==== will make an empty progress bar. will make a 70% full one. ===== Installation ===== Download and extract the following archive to ../lib/plugins/: * [[http://www.mediafire.com/file/o1nmllyrywi/progressbar-1.0.0_20090309.zip|.zip-archive]] ===== Source ===== Here's the source code, but you'll still need the images from the above archive.\\ ==== syntax.php ==== 'Mischa The Evil', 'email' => 'mischa_the_evil@hotmail.com', 'date' => '2009-03-09', 'name' => 'Progressbar', 'desc' => 'Makes progress bars on wiki pages.', 'url' => 'http://www.dokuwiki.org/plugin:progressbar', ); } /** * What kind of syntax are we? */ function getType() { return 'substition'; } /** * Where to sort in? */ function getSort() { return 999; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('', $mode, 'plugin_progressbar'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler) { substr($match, 10, -1); return array(substr($match, 10, -1)); } /** * Create output */ function render($mode, &$renderer, $data) { $renderer->doc .= '' . $data[0] . '% completed'; return true; } } ===== Customization ===== You can change the default images in ../lib/plugins/progressbar/images. Mike Smith tried to make them fit-in well with the default DokuWiki style (they are using a green/blue color-scheme), but they probably look horrible with any other style :-) ==== Gray ==== I personally use images which are using a gray color-scheme and wanted to share them also. Therefore I'll make the set public as a separate imagepack. To install simply backup the directory ../lib/plugins/progressbar/images and then extract the following archive into it overwriting the available default images: * [[http://www.mediafire.com/file/dwnwvyumvzm/imagepack-gray.zip|Gray Imagepack]] ===== History ===== ==== 2009-03-09 (1.0.0) ==== * Added - Link-elements to the progress-images for tooltips in **all** browsers * Changed - Rebrand the plugin after take-over * Fixed - Image-error when used inside a namespace since this wasn't fixed correctly in 2007-11-13 * Fixed - Incorrect date ==== 2007-11-13 (0.0.0) ==== * Fixed - 0%-state bug * Fixed - Added width- and height-elements to the img tag * Fixed - Image-error when used inside a namespace ==== 2006-12-03 ==== * Initial version by Mike Smith ===== Modifications ===== In the time this plugin exists several other users have modified the plugin to fit their own specific requirements. These changes are sometimes shared across the community. Below follows a listing of several of these shared modifications. * The main difference between the different modifications are the used display elements, '''' is inline, ''
'' and '''' are block-level elements (''display: block;'') * The other main difference is that the modifications are all using CSS-only to render the progress-bar instead of using fixed images for this purpose as the "official" source does. ==== Image Free Version ==== If you don't want the images to be extremely different you could simply use the variable ''$data[0]'' to indicate an image width and use the same image for every percentage. However, 0% wouldn't be very useful, nor would it indicate the progress percent/value without viewing the alt text. Why deal with images? The following code will replace the ''$renderer->doc ....'' line in syntax.php. It produces just about the same results as the images. $renderer->doc .= '
'.($data[0]<=0 ? '' : '') . ($data[0]>=100 ? '' : '') .'
  
'; Want to throw some text in there? Use this ugly solution((zero width percentage is an issue. set to 1 in that instance)): $renderer->doc .= '
'.$data[0].'% completed
   
';
Furthermore, if you opt to not use the images anymore then you shouldn't really limit yourself to only 11 different percentages. The following function replaces function connectTo($mode) inside of syntax.php. The regular expression means accept one or two characters from 0-9 or 100 /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('', $mode, 'plugin_progressbar'); } Code supplied by Anonymous. ==== Inline Version ==== This version creates a progress bar without the images. It will also be inserted inline into your text if you want one that does not wrap to a new line. It's also thinner. **Features:** * No extra images needed. (uses one transparent image that already exists in the Wiki image directory). * 100 pixels wide. * Renders inline with your text. * Thinner. * Supports any integer percent from 0-100. * Shows the percent value on mouse-over. ** How To Use:** * Update the ''connectTo'' function inside syntax.php as per below to make it support any number from 0-100. /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('', $mode, 'plugin_progressbar'); } * Replace the render function in your syntax.php file for this plugin, with this: function render($mode, &$renderer, $data) { if($data[0]<0){$data[0]=0;} if($data[0]>100){$data[0]=100;} $sizeLeft = 100-$data[0]; $renderer->doc .= ''.($data[0]<=0 ? '' : ''.$data[0].'%') . ($data[0]>=100 ? '' : ''.$data[0].'%') .''; return true; } Code supplied by Sherri W. (start.ofitall.com). ==== Image Free Div Float Version ==== // Replace connectTo for use 0-100% instead of 10%/20% .. // like inline Version & Image Free Version function connectTo($mode) { $this->Lexer->addSpecialPattern('', $mode, 'plugin_progressbar'); } // Code supplied by M. Wolff // float first div Tag change the float behaviour "left" or "right"; without float div std display:block => newline // width independed just change width:155px on all tags // background-color of incomplete first div tag // background-color of complete second div tag // font-size third div tag depend on margin-top and height:15px(all tags) have to also change // text-align third div tag // color of the text third div tag // Edited by J. Monin for basic ODT export support, and localization (write only % symbol) // Replace render function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ $renderer->doc.='
'.$data[0].'%
'; } elseif ($mode == 'odt'){ $renderer->doc .= ''.$data[0].'%'; } return true; }
Code supplied by M. Wolff, enhanced by J. Monin ===== Discussion ===== ==== Completed ==== * The 0 state (0%, empty progress bar) doesn't work in the plugin (even on your demo site). I changed the regexp in syntax.php (''connectTo()'' function) from this ''""'' to this ''""'' (added the ''?'' after ''[1-9]'' to make it optional) and now it works. --- //GJH 2007-01-15// * Hi, just stumbled over your cute little plugin - STRONGLY Suggest to add the width and height tag to the img tag to allow the browser to display the wiki pages without the need to wait for loading the progress bar image --- //eth at gmx punkt at 2007-02-14// * This plugin does not work in namespaces if you have DokuWiki configured to use ''/'' -- syntax.php line 84 needs modified to provide an absolute web path to the images, because relative path wont work if your in /somenamespace/somepage. ''dirname($_SERVER['PHP_SELF'])'' seems to work for me. --- //Anonymous 2007-??-??// >> All three above-mentioned bugs have been corrected in [[http://lukas.zapletalovi.com/blog:progressbar_pro_dokuwiki|this version]] (actually this is version ''2007-11-13''). Please include it in the mainstream and notify me. Thanks. --- //Lukas 2007-11-13// >>> An updated zip-archive is available now (version 2009-03-09 [1.0.0]). --- //[[mischa_the_evil@hotmail.com|Mischa The Evil]] 2009/03/10 01:20// * The .tar.gz link won't install in the plugin manager. --- //dinolinux [at] gmail [dot] com 2007-05-18// * I've made a tar.bz2 version and stuck it on the server where the demo was running. Updated the link above. However I'm not developing this anymore, therefore the other enhancements here weren't added to it. --- //Mike Smith 2007-??-??// >> An updated zip-archive is available now (version 2009-03-09 [1.0.0]). Don't know if that works with the plugin manager though... --- //[[mischa_the_evil@hotmail.com|Mischa The Evil]] 2009/03/10 01:20// ==== Open ==== * ...