mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-12-03 11:51:26 +00:00
first commit
This commit is contained in:
commit
c715e2a604
5325 files changed
+329700
No files matched your search
@@ -0,0 +1,9 @@
|
||||
version=pmwiki-2.2.74 ordered=1 urlencoded=1
|
||||
author=Petko
|
||||
charset=UTF-8
|
||||
csum=pmcrypt
|
||||
name=PmWiki.Functions
|
||||
rev=107
|
||||
targets=Cookbook.Functions,PmWiki.CustomMarkup,PmWiki.CustomActions,PmWiki.Variables,PmWiki.Internationalizations,PmWiki.FmtPageName,PmWiki.MakeLink,PmWiki.ConditionalMarkup,PmWiki.Drafts,PmWiki.UpdatePage,Cookbook.MarkupExpressionSamples,Category.PmWikiDeveloper
|
||||
text=(:Summary: How some of the functions in pmwiki.php work:)%0a(:Audience: admins (advanced) :)%0a%0aThis page describes some of the internal workings of PmWiki by explaining how some of the functions in pmwiki.php work. For a more brief list/overview on functions useful to for instance cookbook writers, see Cookbook:Functions. %0a%0aTo use this functions you have to make sure that all relevant internal variables have been initialized correctly. See [[Custom Markup]] and [[(PmWiki:)Custom Actions]] for more information on how these functions are typically called via [@Markup()@] or [@$HandleActions[]@].%0a%0a!! [[#pmcrypt]] [@pmcrypt($password, $salt = null)@]%0aThe pmcrypt() function is intended to be a safe replacement for the [[http://php.net/crypt|PHP 5.6+ crypt() function]] without providing a $salt, which would raise a notice. If a salt is provided, crypt() is called to check an existing password. If a salt is not provided, [[http://php.net/password_hash|password_hash()]] will be called to create a cryptographically strong password hash.%0a%0a!![[#PCCF]] [@PCCF($php_code, $callback_template='default', $callback_arguments = '$m')@]%0aThe PCCF() function (''PmWiki Create Callback Function'') can be used to create callback functions used with [[(http://php.net/)preg_replace_callback]]. It is required for PHP 5.5, but will also work with earlier PHP versions.%0a%0aThe first argument is the PHP code to be evaluated. %0a%0aThe second argument (optional) is the callback template, a key from the global $CallbackFnTemplates array. There are two templates that can be used by recipe authors: %0a* 'default' will pass $php_code as a function code%0a* 'return' will wrap $php_code like "return $php_code;" (since PmWiki 2.2.62)%0a%0aThe third argument (optional) is the argument of the callback function. Note that PmWiki uses the '$m' argument to pass the matches of a regular expression search, but your function can use other argument(s).%0a%0aPCCF() will create an anonymous (lambda) callback function containing the supplied code, and will cache it. On subsequent calls with the same $php_code, PCCF() will return the cached function name.%0a%0aSee http://php.net/create_function.%0a%0a!![[#PPRA]] [@PPRA($array_search_replace, $string)@]%0aThe PPRA() function (''PmWiki preg_replace array'') can be used to perform a regular expression replacement with or without evaluation, for PHP 5.5 compatibility. %0a%0aSince PmWiki 2.2.56, PmWiki uses this function to process the following arrays: $MakePageNamePatterns, $FmtP, $QualifyPatterns, $ROEPatterns, $ROSPatterns, $SaveAttrPatterns, $MakeUploadNamePatterns. Any custom settings should continue to work for PHP 5.4 and earlier, but wikis running on PHP 5.5 may need to make a few changes.%0a%0aThe first argument contains the 'search'=>'replace' pairs, the second is the "haystack" string to be manipulated.%0a%0aThe 'replace' parts of the array can be strings or function names. If the 'replace' part is a callable function name, it will be called with the array of matches as a first argument via preg_replace_callback(). If not a callable function, a simple preg_replace() will be performed.%0a%0aPreviously, PmWiki used such constructs:%0a $fmt = preg_replace(array_keys($FmtP), array_values($FmtP), $fmt);%0a%0aIt is now possible to use simply this:%0a $fmt = PPRA($FmtP, $fmt);%0a%0aNote that since PHP 5.5, the search patterns cannot have an /e evaluation flag. When creating the $array_search_replace array, before PHP 5.5 we could use something like (eg. for $MakePageNamePatterns):%0a '/(?%3c=^| )([a-z])/e' => "strtoupper('$1')",%0a%0aSince PHP 5.5, we should use this (will also work in PHP 5.4 and earlier):%0a '/(?%3c=^| )([a-z])/' => PCCF("return strtoupper(\$m[1]);"),%0a%0aNote that the /e flag should be now omitted, instead of '$0', '$1', '$2', we should use $m[0], $m[1], $m[2], etc. in the replacement code, and there is no need to call PSS() in the replacement code, as backslashes are not automatically added.%0a%0a!![[#PPRE]] [@PPRE($search_pattern, $replacement_code, $string)@]%0aThe PPRE() function (''PmWiki preg_replace evaluate'') can be used to perform a regular expression replacement with evaluation.%0a%0aSince PHP 5.5, the preg_replace() function has deprecated the /e evaluation flag, and displays warnings when the flag is used. The PPRE() function automatically creates a callback function with the replacement code and calls it.%0a%0aBefore PHP 5.5, it was possible to use such calls:%0a $fmt = preg_replace('/\\$([A-Z]\\w*Fmt)\\b/e','$GLOBALS["$1"]',$fmt);%0a%0aSince PHP 5.5, it is possible to replace the previous snippet with the following (also works before PHP 5.5):%0a $fmt = PPRE('/\\$([A-Z]\\w*Fmt)\\b/','$GLOBALS[$m[1]]',$fmt);%0a%0aNote that the /e flag should be now omitted, instead of '$0', '$1', '$2', we should use $m[0], $m[1], $m[2], etc. in the replacement code, and there is no need to call PSS() in the replacement code, as backslashes are not automaticLine truncated
|
||||
time=1430064613
|
||||
Reference in new issue
Block a user