aboutsummaryrefslogtreecommitdiff
path: root/wikilib.d/PmWiki.OtherVariables
blob: 4556e4853a34edbea249d57d07a0bac39cbc194f (plain)
1
2
3
4
5
6
7
8
9
version=pmwiki-2.3.36 ordered=1 urlencoded=1
author=Petko
charset=UTF-8
csum= $EnableUrlApprove, $EnablePmForm, $EnableCreole, $EnableRefCount, $EnableFeeds (+369)
name=PmWiki.OtherVariables
rev=95
targets=PmWiki.UrlApprovals,PmWiki.OtherVariables,Cookbook.PmForm,Cookbook.Creole,PmWiki.RefCount,PmWiki.WebFeeds,PmWiki.FmtPageName,PmWiki.SecurityVariables,PmWiki.PageVariables,PmWiki.Functions,Cookbook.HttpVariables,Cookbook.MoreCustomPageVariables,PmWiki.PageTextVariables,PmWiki.PagelistVariables,PmWiki.Forms,Cookbook.MarkupDirectiveFunctions
text=(:Summary:Variables not yet classified:)%0a%0a:$EnableUrlApprove: When set to 1, enables [[UrlApprovals]].%0a%0a:$EnablePmForm: When set to 1, enables Cookbook:PmForm.%0a%0a:$EnableCreole: When set to 1, enables Cookbook:Creole.%0a%0a:$EnableRefCount: When set to 1, enables [[RefCount]].%0a%0a:$EnableFeeds: An array enabling RSS and other web feeds, see [[WebFeeds]].\\%0a%25hlt php%25@@$EnableFeeds['rss'] = 1; # enable RSS feeds@@%0a%0a:$FmtV: %0a: :This variable is an array that is used for string substitutions at the end of a call to %25hlt php%25@@[[FmtPageName]]()@@. For each element in the array, the "key" (interpreted as a string) will be replaced by the corresponding "value".  The variable is intended to be a place to store substitution variables that have frequently changing values (thus avoiding a rebuild of the variable cache making @@[[FmtPageName]]()@@ faster). Also see $FmtP. %0a: :%25green%25''Values of $FmtV are set by the internal functions @@FormatTableRow@@, @@LinkIMap@@, @@HandleBrowse@@, PreviewPage, @@HandleEdit@@, @@PmWikiAuth@@, and @@PasswdVar@@, apparently to set values for system generated string substitutions like @@PageText@@.''%25%25%0a%0a:$FmtP:%0a: :This variable is an array that is used for pattern substitutions near the beginning of a call to %25hlt php%25[@FmtPageName()@]. For each element in the array, the "key" (interpreted as a pattern) will be replaced by the corresponding value evaluated for the name of the current page. This is for instance used to handle $-substitutions that depend on the pagename passed to [@FmtPageName()@].  Also see $FmtV. %0a: :%25green%25From @@robots.php@@: ''If $EnableRobotCloakActions is set, then a pattern is added to $FmtP to hide any "?action=" url parameters in page urls generated by PmWiki for actions that robots aren't allowed to access.  This can greatly reduce the load on the server by not providing the robot with links to pages that it will be forbidden to index anyway.''%0a%0a%0a:$FmtPV:%0a: :This variable is an array that is used for defining [[Page Variables]]. New variables can be defined with %25hlt php%25[@$FmtPV['$VarName'] = 'variable definition';@] which can be used in markup with %25pmhlt%25[@{$VarName}@]. Please note that the contents of %25hlt php%25[@$FmtPV['$VarName']@] are [@eval()@]ed to produce the final text for %25pmhlt%25[@$VarName@], so the contents must be a PHP expression which is valid at the time of substitution. In particular, %25red%25this does not work:%25%25%0a%0a:: :%25red%25@@#This doesn't work@@%25%25%0a:: :%25hlt php%25@@$FmtPV['$MyText'] = "This is my text."; # WARNING: Doesn't work!@@%0a%0a: :The problem is that the text %25blue%25[@This is my text.@]%25%25 is not a valid PHP expression. To work it would need to be placed in quotes, so that what actually gets stored in %25hlt php%25[@$FmtPV['$MyText']@] is %25blue%25[@"This is my text."@]%25%25 which '''is''' a valid PHP expression for a text string. Thus the correct way to do this would be with an extra set of quotes:%0a%0a:: :%25green%25@@#This will work@@%25%25%0a:: :%25hlt php%25@@$FmtPV['$MyText'] = '"This is my text."';@@%0a%0a: :This also has implications for how internal PHP or PmWiki variables are accessed. To have the page variable %25hlt php%25[@$MyVar@] produce the contents of the internal variable [@$myvar@], many folks try the following %25red%25which does not work:%25%25%0a%0a:: :%25red%25@@#This doesn't work either!@@%0a:: :%25hlt php%25@@$myvar = SomeComplexFunction();@@%0a:: :%25hlt php%25@@$FmtPV['$MyVar'] = $myvar; # WARNING: Doesn't work!@@%0a%0a: :There are several correct ways to do this, depending on whether you need the value of the %25hlt php%25[@$myvar@] variable as it was at the time the [@$FmtPV@] entry was created, or at the time that a particular instance of [@$MyVar@] is being rendered on a page. For most simple page variables that don't change during the processing of a page its more efficient to set the value when the entry is created:%0a%0a:: :%25hlt php%25@@$myvar = SomeComplexFunction();@@%0a:: :%25hlt php%25@@$FmtPV['$MyVar'] = "'" . $myvar . "'"; #capture contents of $myvar@@%0a%0a: :NOTE: If %25hlt php%25[@$myvar@] should contain single quotes, the above won't work as is, and you'll need to process the variable to escape any internal quotes.%0a%0a: :For more complex cases where an internal variable may have different values at different places in the page (possibly due to the effects of other markup), then you need to make the %25hlt php%25[@$FmtPV@] entry make an explicit reference to the global value of the variable (and the variable had better be global) like this:%0a%0a:: :%25hlt php%25@@global $myvar;@@%0a:: :%25hlt php%25@@$FmtPV['$MyVar'] = '$GLOBALS["myvar"]';@@%0a%0a: :Finally, there's nothing to stop you from simply having the evaluation of the %25hlt php%25[@$FmtPV@] entry execute a function to determine the replacement text:%0a%0a:: :%25hlt php%25@@# add page variable [={$Today}=], formats today's date as yyyy-mm-dd@@%0a:: :%25hlt php%25@@$FmtPV['$Today'] = '[[PmWiki/Functions#PSFT|PSFT]]([="%25Y-%25m-%25d"=], time() )';@@%0a%0a>>frame%3c%3c%0a: : Once again, please note that the values of the elements of $FmtPV are @@eval()@@ed so always sanitize any user input. The following is very insecure[=:=]%0a%0a:: : %25hlt php%25@@$FmtPV['$Var'] = $_REQUEST['Var'];@@ %25red%25@@# critically insecure, allows PHP code injection@@%0a:: : %25hlt php%25@@$FmtPV['$Var'] = '"'. addslashes($_REQUEST['Var']).'"';@@ %25red%25@@# critically insecure, allows PHP code injection@@%0a%0a: : See the recipe Cookbook:HttpVariables for a better way to use these variables.%0a>>%3c%3c%0a%0a: :See [[Cookbook:MoreCustomPageVariables]] for more examples of how to use [@$FmtPV@].%0a%0a:$MaxPageTextVars: This variable prevents endless loops in accidental recursive [[PageTextVariables]] which could lock down a server. Default is 500 which means that each PageTextVariable from one page can be displayed up to 500 times in one wiki page. If you need to display it more than 500 times, set in @@config.php@@ something like%0a-->%25hlt php%25@@$MaxPageTextVars = 10000;@@ # ten thousand times%0a%0a:$DefaultUnsetPageTextVars: An array setting default values to page text variables which are not defined in the page, or when the user doesn't have read permissions for the page. See [[PageTextVariables#default]].%0a%0a:$DefaultEmptyPageTextVars: An array setting default values to page text variables which are defined in the page but empty. See [[PageTextVariables#default]].%0a%0a:$PageCacheDir: Enables the cache of most of the HTML for pages with no conditionals. The variable contains the name of a writable directory where PmWiki can cache the HTML output to speed up subsequent displays of the same page. Default is empty, which disables the cache. See also $PageListCacheDir.%0a-->%25hlt php%25[@# Enable HTML caching in work.d/.pagecache%0a$PageCacheDir = 'work.d/.pagecache'; @]%0a%0a:$MarkupMarkupLevel: This global variable is a positive integer when the markup processing engine is inside a %25pmhlt%25[@(:markup:)@] block; it is 0 (zero) or null otherwise.%0a%0a:$EnableInputDataAttr: This variable controls whether [[forms|input form elements]] should accept custom @@data-*@@ attributes. By default they do.%0a-->%25hlt php%25[@# Disable data-* attributes in forms%0a$EnableInputDataAttr = 0; @]%0a%0a:$MarkupDirectiveFunctions: This is an array that allows recipe authors to easily configure custom directives. See Cookbook:MarkupDirectiveFunctions.%0a
time=1724044378