The MindTouch API submits with each extension function invocation an implict environment, such as the user's name, the page the function is being invoked on, and so forth. This makes it possible for a function to customize its output based on the context of the invocation.
The implicit environment is automatically handled by native extensions written in .NET, but for PHP, they require a bit of custom code (created by stevel):
function deki_env($key) {
$headers = getallheaders();
$dekivars = $headers["X-DekiScript-Env"];
$arr = preg_split('/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/', $dekivars);
$result = array();
foreach ($arr as $token) {
if (preg_match('/^\s*([a-zA-Z\.]+)="(.*)"$/', $token, $matches)) {
$result[$matches[1]] = $matches[2];
}
}
return $result[$key];
}
TODO: this capability should be added to the PHP Extension harness!
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by