version=pmwiki-2.0.beta55 ordered=1 urlencoded=1 agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6 author=Pm host=24.1.26.255 name=PmWiki.Functions rev=33 targets=PmWiki.PmWiki,PmWiki.Variables,PmWiki.Internationalizations,PmWiki.FmtPageName,PmWiki.CustomMarkup text=This 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. You might also want to look at the [[latest CVS version of pmwiki.php -> http://cvs.sourceforge.net/viewcvs.py/pmwiki/pmwiki/pmwiki.php?view=markup]].%0a%0a%25green%25Put PmWiki standard functions here with brief explanations (per Pm email). Overly-documented functions get their own page (where possible). `BenWilson August 02, 2005, at 02:15 PM%0a%0a!![[#FmtPageName]] [@FmtPageName@]($fmt, $pagename)%0a%0a-> \%0a[[#FmtPageName-desc]]Returns [@$fmt@], with $variable and $[internationalisation] substitutions performed, under the assumption that the current page is [@pagename@]. See [[PmWiki.Variables]] for an (incomplete) list of available variables, [[PmWiki.Internationalizations]] for internationalisation.%0a%0aThis is one of the major functions in PmWiki, see [[PmWiki.FmtPageName]] for%0alots of details.%0a%0a%0a!![[#Markup]] [@Markup@]($name, $when, $pattern, $replace)%0a%0a-> \%0a[[#Markup-desc]]Adds a new markup to the conversion table. Described in greater detail at PmWiki.CustomMarkup.%0a%0aThis function is used to insert translation rules into the PmWiki's%0atranslation engine. The arguments to [@Markup()@] are all strings, where:%0a%0a:[@$name@]: The string names the rule that is inserted. It must be \%0a unique (?? and is used partially controls the order in which the \%0a rules are applied).%0a-> %25red%25What happens if the name isn't unique??%25%25%0a:[@$when@]: This string is used to primarily control ''when'' \%0a a rule is to be applied. See ??? for more details on the order of rules.%0a:[@$pattern@]: This string is a [[regular expression \%0a -> http://www.php.net/preg_replace]] that is used by the translation \%0a engine to look for occurences of this rule in the markup source.%0a:[@$replace@]: This string will replace the matched text when a match \%0a occurs.%0a%0aAlso see: [[PmWiki.CustomMarkup]] and [[Cookbook:Functions#Markup]]%0a%0a!![[#MarkupToHTML]] [@MarkupToHTML@]($pagename, $str)%0a%0a-> \%0a[[#MarkupToHTML-desc]] Converts the string [@$str@] containing PmWiki markup into the corresponding HTML code, assuming the current page is [@$pagename@].%0a%0aAlso see: [[Cookbook:Functions#MarkupToHTML]]%0a%0a!![[#mkdirp]] [@mkdirp@]($dir)%0a%0aThe function [@mkdirp@]($dir) creates a directory, [@$dir@], if it doesn't%0aalready exist, including any parent directories that might be needed. For%0aeach directory created, it checks that the permissions on the directory are%0asufficient to allow PmWiki scripts to read and write files in that%0adirectory. This includes checking for restrictions imposed by PHP's%0asafe_mode setting. If [@mkdirp@]() is unable to successfully create a%0aread/write directory, [@mkdirp@]() aborts with an error message telling the%0aadministrator the steps to take to either create $dir manually or give%0aPmWiki sufficient permissions to be able to do it.%0a%0aCode of [@mkdirp@]() taken from version pmwiki-2.0.beta55 (current is {$Version}):%0a%0a-> [@%0a## mkdirp creates a directory and its parents as needed, and sets%0a## permissions accordingly.%0afunction mkdirp($dir) {%0a global $ScriptUrl;%0a if (file_exists($dir)) return;%0a if (!file_exists(dirname($dir))) mkdirp(dirname($dir));%0a if (mkdir($dir, 0777)) {%0a fixperms($dir);%0a if (@touch("$dir/xxx")) { unlink("$dir/xxx"); return; }%0a rmdir($dir);%0a }%0a $parent = realpath(dirname($dir));%0a $perms = decoct(fileperms($parent) & 03777);%0a $msg = "PmWiki needs to have a writable %3ctt>$dir/%3c/tt> directory%0a before it can continue. You can create the directory manually%0a by executing the following commands on your server:%0a %3cpre> mkdir $parent/$dir\n chmod 777 $parent/$dir%3c/pre>%0a Then, %3ca href='$ScriptUrl'>reload this page%3c/a>.";%0a $safemode = ini_get('safe_mode');%0a if (!$safemode) $msg .= "%3cbr />%3cbr />Or, for a slightly more%0a secure installation, try executing %3cpre> chmod 2777 $parent%3c/pre>%0a on your server and following %3ca target='_blank' href='$ScriptUrl'>%0a this link%3c/a>. Afterwards you can restore the permissions to%0a their current setting by executing %3cpre> chmod $perms $parent%3c/pre>.";%0a Abort($msg);%0a}%0a@] time=1125544917