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-06-22 19:00] Aleksandrplugin: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
  
-downloadurl: https://github.com/gamma/dokuwiki-plugin-condition/archive/master.zip  +downloadurl: https://github.com/gamma/dokuwiki-plugin-condition/zipball/master 
-bugtracker : +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: 
 ---- ----
-===== Description ===== 
  
-The Syntax [[plugins|Plugin]] allows to parse a content only if a specific condition (or multiple condition) is fulfilledSome basic tests are provided and users can add new tests just by implementing a file in the template directory.+:!: 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 =====
  
-__**Warning :**__ //This plugin must not be considered as a way to securely hide data from users since hit on the "show source" button will display the code. It is only a way to put a condition on some wiki text for visual effectIf you want to achieve higher level of data hiding you can try to remove the "show source" button but note that it is not the most secure thing ...//+The Syntax Plugin allows to parse content only if specific condition (or multiple condition) is fulfilledSome basic tests are provided and users can add new tests just by implementing file in the template directory.
  
 ===== Syntax ===== ===== Syntax =====
Line 32: 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 44: 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 69: 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 81: Line 81:
 ==== syntax.php ==== ==== syntax.php ====
  
-<code php>+<file php syntax.php>
 <?php <?php
 /** /**
Line 140: 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 278: 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 426: Line 426:
 } //class } //class
 ?> ?>
-</code>+</file>
  
 ==== base_tester.php ==== ==== base_tester.php ====
  
-<code php>+<file php base_tester.php>
 <?php <?php
  /*  /*
Line 723: 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 738: 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 759: 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 767: 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 777: 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 784: 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 822: Line 819:
 //2010-11-22 [[zefir-cs@ukr.net|Zefir]]// //2010-11-22 [[zefir-cs@ukr.net|Zefir]]//
  
-:!: I have the same error, but this code doesn´t solve the problem. If I use the condition-plugin some where in the page all headings get lost for the TOC up to the line where you use the condition plugin. The next heading is used as first heading. If no heading is left, filename is used. //2011-07-03//+:!: I have the same error, but this code doesn´t solve the problem. If I use the condition-plugin some where in the page all headings get lost for the TOC up to the line where you use the condition plugin. The next heading is used as first heading. If no heading is left, filename is used.  
 + 
 +//2011-07-03 anonymous// 
 + 
 +:!: The plugin **does not** work with my installation. I traced the [[https://github.com/gamma/dokuwiki-plugin-condition/issues/1|issue in github]]. 
  
 +//2014-09-23 11:01 [[user>cinlloc|cinlloc]] //
  
plugin/condition.1403456430.txt.gz · Last modified: 2014-06-22 19:00 by Aleksandr

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