DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:condition

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:condition [2014-09-23 11:06] – [PHP Errors after saving a changed page with conditions] Add new error information cinllocplugin:condition [2022-10-02 17:47] (current) – [condition Plugin] thalueng
Line 1: Line 1:
-====== condition plugin ======+====== condition Plugin ======
  
 ---- plugin ---- ---- plugin ----
-description: render a block if a condition is fulfilled, user custom tests can be easily added+description: Render a block if a condition is fulfilled, user custom tests can be easily added
 author     : Etienne Meleard author     : Etienne Meleard
 email      : etienne.meleard@free.fr email      : etienne.meleard@free.fr
 type       : Syntax type       : Syntax
-lastupdate : 2014-01-22+lastupdate : 2017-11-30
 compatible :  compatible : 
 depends    :  depends    : 
 conflicts  conflicts 
-similar    : ifauth, nodisp+similar    : ifauth, showif, isauth, nodisp, ifauthex
 tags       : condition if syntax tags       : condition if syntax
 securitywarning: partlyhidden securitywarning: partlyhidden
  
-downloadurl: https://github.com/gamma/dokuwiki-plugin-condition/archive/master.zip +downloadurl: https://github.com/gamma/dokuwiki-plugin-condition/zipball/master
 bugtracker : https://github.com/gamma/dokuwiki-plugin-condition/issues bugtracker : https://github.com/gamma/dokuwiki-plugin-condition/issues
 sourcerepo : https://github.com/gamma/dokuwiki-plugin-condition sourcerepo : https://github.com/gamma/dokuwiki-plugin-condition
 donationurl:  donationurl: 
 ---- ----
 +
 +:!: Replace curly brackets string indices with square brackets in line 84 and 149 of ''plugins/condition/syntax.php'' if you run your webserver with PHP 8.
 +
 ===== Description ===== ===== Description =====
  
-The Syntax [[plugins|Plugin]] allows to parse a content only if a specific condition (or multiple condition) is fulfilled. Some basic tests are provided and users can add new tests just by implementing a file in the template directory.+The Syntax Plugin allows to parse a content only if a specific condition (or multiple condition) is fulfilled. Some basic tests are provided and users can add new tests just by implementing a file in the template directory.
  
 ===== Syntax ===== ===== Syntax =====
Line 31: Line 34:
 </code> </code>
  
-''[condition_list]'' is a set of ''[condition]'' records separated by logical operators ''(&&, and, ||, or, ^, xor for now)'', use of parenthesis is allowed, negation is achieved by using heading ''!'' ''(ex !foo=bar or !(a=b || c<d) )''+''[condition_list]'' is a set of ''[condition]'' records separated by logical operators ''%%(&&, and, ||, or, ^, xor for now)%%'', use of parenthesis is allowed, negation is achieved by using heading ''!'' ''%%(ex !foo=bar or !(a=b || c<d) )%%''
  
 ''[condition]'' is formed from a ''[key]'', followed by an ''[operator]'' (optional) and then a ''[value]'' (optional) ''[condition]'' is formed from a ''[key]'', followed by an ''[operator]'' (optional) and then a ''[value]'' (optional)
Line 43: Line 46:
   - ''IP'': refers to the client's IP address   - ''IP'': refers to the client's IP address
  
-''[operator]'' signification is ''[key]'' dependent, for example : +''[operator]'' signification is ''[key]'' dependent, for example: 
-  * ''= or =='': equality, membership, read/edit ability on ... +  * ''%%=%%'' or ''%%==%%'': equality, membership, read/edit ability on... 
-  * ''!='': non-equality, non-member, no read/edit ability on ...+  * ''!='': non-equality, non-member, no read/edit ability on...
   * ...   * ...
  (browse base_tester.php for test_* methods for more information)  (browse base_tester.php for test_* methods for more information)
  
-''[value]'' can be a string (whitespace, ) and > free) or a " delimited string (whitespaces, ) and > are then allowed)+''[value]'' can be a string (whitespace, ) and > free) or a %%"%% delimited string (whitespaces, ) and > are then allowed)
  
-DokuWiki code can contain DokuWiki syntax but be careful with high-level syntax (containers, table ...) as there may be priority issue, +DokuWiki code can contain DokuWiki syntax but be careful with high-level syntax (containers, table ...) as there may be priority issue, bug reports are welcome...
-bug reports are welcome ...+
  
-**It is now sure that using the plugin inside a table cell won't work, working on it now, any help is welcome ...**+**It is now sure that using the plugin inside a table cell won't work, working on it now, any help is welcome...**
  
-Example :+Example:
 <code> <code>
 <if user>You are **connected**<else>You must identify yourself to do something</if> <if user>You are **connected**<else>You must identify yourself to do something</if>
Line 68: Line 70:
 ===== Download and Installation ===== ===== Download and Installation =====
  
-Download and install the plugin using the [[plugin:plugin|Plugin Manager]] using the following URL. Refer to [[:Plugins]] on how to install plugins manually.+Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
   * Latest Version: [[https://github.com/gamma/dokuwiki-plugin-condition/archive/master.zip]] (GitHub)   * Latest Version: [[https://github.com/gamma/dokuwiki-plugin-condition/archive/master.zip]] (GitHub)
   * Old Version: [[http://dokuwiki.yent.eu/condition.zip]]   * Old Version: [[http://dokuwiki.yent.eu/condition.zip]]
- 
  
 ===== Sources ===== ===== Sources =====
Line 80: Line 81:
 ==== syntax.php ==== ==== syntax.php ====
  
-<code php>+<file php syntax.php>
 <?php <?php
 /** /**
Line 139: Line 140:
  
  // Handle the match  // Handle the match
- function handle($match, $state, $pos, &$handler) {+ function handle($match, $state, $pos, Doku_Handler $handler) {
  if($state != DOKU_LEXER_UNMATCHED) return false;  if($state != DOKU_LEXER_UNMATCHED) return false;
   
Line 277: Line 278:
  * Create output  * Create output
  */  */
- function render($mode, &$renderer, $data) {+ function render($mode, Doku_Renderer $renderer, $data) {
  global $INFO;  global $INFO;
  if(count($data) != 2) return false;  if(count($data) != 2) return false;
Line 425: Line 426:
 } //class } //class
 ?> ?>
-</code>+</file>
  
 ==== base_tester.php ==== ==== base_tester.php ====
  
-<code php>+<file php base_tester.php>
 <?php <?php
  /*  /*
Line 722: Line 723:
  }  }
 ?> ?>
-</code>+</file>
  
-==== How can I implement some other tests ? ====+==== How can I implement some other tests? ====
  
-You must create the //condition_plugin_custom_tester.php// in your template directory and start with this base :+You must create the //condition_plugin_custom_tester.php// in your template directory and start with this base:
  
 <code php> <code php>
Line 737: Line 738:
 </code> </code>
  
-To add the test with the key "foo" just add the test method :+To add the test with the key "foo" just add the test method:
  
 <code php> <code php>
Line 758: Line 759:
 </code> </code>
  
-So that test can be used as :+So that test can be used as:
 <code> <code>
 <if foo=bar>foo = bar<else>foo != bar</if> <if foo=bar>foo = bar<else>foo != bar</if>
Line 766: Line 767:
 </code> </code>
  
-If your test don't take a parameter you can define it as follows :+If your test don't take a parameter you can define it as follows:
  
 <code php> <code php>
Line 776: Line 777:
 </code> </code>
  
-This test is valid if "bar" is a parent namespace of the page :+This test is valid if "bar" is a parent namespace of the page:
 <code> <code>
 <if foo>Page is under "bar" namespace</if> <if foo>Page is under "bar" namespace</if>
Line 783: Line 784:
 ==== TODO ==== ==== TODO ====
  
-  * Allow multiple user custom test files (plugin style) ?+  * Allow multiple user custom test files (plugin style)?
   * Ensure this works well with top-level containers   * Ensure this works well with top-level containers
-  * clean-up and simplify code (mainly reduce calls to preg_replace/match) because it is a bit slow ... +  * clean-up and simplify code (mainly reduce calls to preg_replace/match) because it is a bit slow...
-===== Discussion ===== +
- +
-~~DISCUSSION~~+
  
 ==== While discussion isn't working ==== ==== While discussion isn't working ====
Line 828: Line 826:
  
 //2014-09-23 11:01 [[user>cinlloc|cinlloc]] // //2014-09-23 11:01 [[user>cinlloc|cinlloc]] //
- 
- 
- 
  
plugin/condition.1411463185.txt.gz · Last modified: 2014-09-23 11:06 by cinlloc

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki