plugin:replace
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revision | |||
— | plugin:replace [2018-06-05 22:56] (current) – [Download and Installation] Klap-in | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== replace Plugin ====== | ||
+ | ---- plugin ---- | ||
+ | description: | ||
+ | author | ||
+ | email : letssurf@gmail.com | ||
+ | type : syntax | ||
+ | lastupdate : 2009-04-13 | ||
+ | compatible : 2009-02-14 | ||
+ | similar | ||
+ | tags : search, replace | ||
+ | |||
+ | downloadurl: | ||
+ | bugtracker : | ||
+ | sourcerepo : | ||
+ | donationurl: | ||
+ | |||
+ | screenshot_img: | ||
+ | ---- | ||
+ | |||
+ | This is my first plugin so please forgive any errors. | ||
+ | |||
+ | Comments welcome. | ||
+ | |||
+ | ===== Download and Installation ===== | ||
+ | |||
+ | Search and install the plugin using the [[plugin: | ||
+ | |||
+ | * [[https:// | ||
+ | |||
+ | ===== Version History ===== | ||
+ | |||
+ | ==== 2009-04-13 ==== | ||
+ | |||
+ | * Fixed compatibility issue with DokuWiki 2009-02-14. | ||
+ | |||
+ | ==== 2008-01-31 ==== | ||
+ | |||
+ | * First release. | ||
+ | |||
+ | ===== Source Code ===== | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | /** | ||
+ | * Plugin Replace: Replaces words with DokuWiki snippets | ||
+ | * | ||
+ | * Create replace.conf file and populate with words and snippets like in acronyms | ||
+ | * e.g. | ||
+ | * | ||
+ | * HelloWorld **Hello World** | ||
+ | * This example would replace HelloWorld with bold Hello World | ||
+ | * | ||
+ | * HTTPS [[wp> | ||
+ | * | ||
+ | * This example would replace words HTTPS with a Wikipedia link to HTTPS | ||
+ | * | ||
+ | * @url http:// | ||
+ | * @license | ||
+ | * @author | ||
+ | */ | ||
+ | |||
+ | if(!defined(' | ||
+ | if(!defined(' | ||
+ | require_once(DOKU_PLUGIN.' | ||
+ | |||
+ | class Syntax_Plugin_Replace extends DokuWiki_Syntax_Plugin { | ||
+ | |||
+ | function getInfo(){ | ||
+ | return array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | function getType(){ return ' | ||
+ | function getAllowedTypes() { | ||
+ | return array(' | ||
+ | } | ||
+ | |||
+ | function getSort() { | ||
+ | return 999; | ||
+ | } | ||
+ | |||
+ | function Syntax_Plugin_Replace() { | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | function preConnect() { | ||
+ | if(!count($this-> | ||
+ | $replacers = array_map(' | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | function connectTo($mode) { | ||
+ | if(!count($this-> | ||
+ | if(strlen($this-> | ||
+ | $this-> | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function handle($match, | ||
+ | switch($state) { | ||
+ | case DOKU_LEXER_SPECIAL : | ||
+ | $this-> | ||
+ | break; | ||
+ | } | ||
+ | return array(); | ||
+ | } | ||
+ | |||
+ | function render($mode, | ||
+ | return true; | ||
+ | } | ||
+ | } | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | ===== Comments ===== | ||
+ | |||
+ | Thank you very much for this plugin. For me it has been extremely helpful. (For beginners: Copy the PHP code into dokuwiki/ | ||
+ | |||
+ | ==== Integration with confmanager-plugin ==== | ||
+ | |||
+ | To modify replace.conf via admin-menu install [[confmanager|confmanager-plugin]] and modify following lines: | ||
+ | |||
+ | admn.php (line 9): add " | ||
+ | <code php> | ||
+ | var $cnffiles = array(' | ||
+ | </ | ||
+ | |||
+ | lang.php (for german) | ||
+ | <code css> | ||
+ | $lang[' | ||
+ | $lang[' | ||
+ | $lang[' | ||
+ | </ | ||
+ | |||
+ | ==== Feature suggestions ==== | ||
+ | |||
+ | * Please add **mutiple words** support - I would like to hack it but I don't get it *arg* -- //Christian 2009/12/10 13:05// | ||
+ | * Any way to do the replace within a source line? I would like to do the substitution for copy-pasting into multiple conf files. I guess I'm looking to also include the ' | ||
+ | |||
+ | |||
+ | ==== Replacement text is not shown ==== | ||
+ | |||
+ | > In Version DokuWiki-2008-05-05 this tag don´t work for me. | ||
+ | > The keywords (from conf/ | ||
+ | > | ||
+ | > E.g. - | ||
+ | > replace.conf: | ||
+ | > < | ||
+ | little big | ||
+ | red green | ||
+ | </ | ||
+ | My little car is red. | ||
+ | My replace result: | ||
+ | My car is . | ||
+ | The right replace result: | ||
+ | My big car is green. | ||
+ | |||
+ | > I don´t know the trick to get it work. | ||
+ | > | ||
+ | > Knut | ||
+ | |||
+ | ---- | ||
+ | |||
+ | I second this statement, I cannot figure out why it does not work. Using same version of DokuWiki... | ||
+ | | ||
+ | Too bad :-( | ||
+ | |||
+ | ---- | ||
+ | The Same here - no function as in the big green car example :( Using Debian 5.0.1, DokuWiki 0.0.20080505-4, | ||
+ | |||
+ | ---- | ||
+ | |||
+ | Fixed in version 2009-04-13. No extensive testing, I was just looking for a similar feature for another plugin and got curious if it's possible to make this one to work. Seems so. --- // | ||
+ | |||
+ | ---- | ||
+ | |||
+ | Working 2011-01-23. replace.conf needs double % before and after replacement text. (sry example replace.conf breaks page formatting). | ||
+ | original | ||
+ | < | ||
+ | start brc Brc bRc brC end \\ | ||
+ | start haccp ifs ifs6 brc5 end | ||
+ | </ | ||
+ | replaced | ||
+ | < | ||
+ | start BRC BRC bRc brC end | ||
+ | start HACCP IFS IFS6 BRC5 end | ||
+ | </ | ||
+ | |||
+ | ==== Plugin (2009-04-13) fails at line 74 ==== | ||
+ | |||
+ | I get the following message upon detection of a word from replace.conf: | ||
+ | |||
+ | '' | ||
+ | |||
+ | Is this a problem with the PHP version? (My host uses PHP 4.4.7.) --- // | ||
+ | |||
+ | ---- | ||
+ | |||
+ | Yep. Passing objects around in PHP 4 is a real pain --- forget one reference operator and now you have to deal with a clone. Unfortunately it cannot be fixed within plugin. If you feel adventurous you can fix it in '' | ||
+ | |||
+ | <code php> | ||
+ | < ' | ||
+ | --- | ||
+ | > ' | ||
+ | </ | ||
+ | |||
+ | It did the trick at my place, but I have no idea if it will break something else. | ||
+ | |||
+ | Or better yet, send [[http:// | ||
+ | |||
+ | > It also worked for me, thanks Mykola! (Maybe '' | ||
+ | >< | ||
+ | if (version_compare(PHP_VERSION, | ||
+ | $modes[] = array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } else { | ||
+ | $modes[] = array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Bugfix for special chars (2012/ | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | function preConnect() { | ||
+ | if(!count($this-> | ||
+ | $replacers = array_map(' | ||
+ | // removed ' | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | [[robert.jaeckel@verwaltung.uni-halle.de|Robert Jäckel]] |
plugin/replace.txt · Last modified: 2018-06-05 22:56 by Klap-in