|
Profiles /
ThomasPcontact: pmwiki ATT sigproc DDOT de Contact me directly by mail - I have no notifications running. Pmwiki usage:
Pmwiki devel interests:
Contributions/files
Personal feature wishlist / todo list
Firefox extensions useful in connection with wiki development/production
Some code fragmentsThese are some code fragments that I found useful. Feel free to copy them around in the wiki, or add some new features etc. (Leave me a notice of what you did.) DebuggingI use the following code (could evolve to
<?php if (!defined('PmWiki')) exit();
SDV($EnableDebug, false);
$dbgAlreadyCalled = false;
$repetitionLock = false;
function debugMsg($label, $text) {
global $debugfile;
global $debugEvents;
global $debugLastMsg;
global $dbgAlreadyCalled;
global $repetitionLock;
global $EnableDebug;
if (!$EnableDebug) return;
if (strlen($text) == 0) return;
if (in_array($label, $debugEvents)) {
if (!$dbgAlreadyCalled) {
$debugfile = @fopen("cookbook/debugout.txt", "a");
fwrite($debugfile, str_pad('', 80, '-') . "\n");
$dbgAlreadyCalled = true;
}
if ("$label$text" == $debugLastMsg) {
if ($repetitionLock) return;
$text = 'Last message repeated at least once.';
$repetitionLock = true;
} else {
$debugLastMsg = "$label$text";
$repetitionLock = false;
}
$labelLength = 4;
$label = str_pad(substr($label, 0, $labelLength), $labelLength, ' ');
$textArr = explode("\n", trim($text));
$outtext = '';
foreach($textArr as $textLine) {
$outtext .= strftime("%Y-%m-%d %H:%M:%S %Z") . " $label $textLine\n";
}
fwrite($debugfile, $outtext);
}
}
To install, place $debugEvents = array( # add further event labels here: 'LOGN', # login 'LOGT', # logout #'LTEX', # linuxtex.php #'NOTY', # notification #'UPLD', # upload '' # dummy ); also there. (You can customize the "label table" to your needs.) Further, set
debugMsg('xxxx', "myfile.php: My text.\n");
in the code, where Special features:
Pmwiki references
Roadmap for the WikiEdit API
Stuff
{$ClientIP}
(:visitorslist:) limit days author actions
Cookbook/SysDiff.php
Old stuffReasoning for solving certain pmwiki internaNaming scheme for paths to uploaded files This has been more or less realized in the "Uploads:" markup, see UploadsMarkup. ThomasP December 17, 2007, at 05:09 AM
Concerns every module that has interaction with local (uploaded) files, e.g. (:attachlist:), ..., upload functions, etc. I propose to let path names be meant as absolute starting from below the upload
directory, i.e. (:includefile file.txt:) Actually there is no reason against having just two config variables, one for specifying where files go by default, and one from where they are read by default (like the $UploadPrefixPathFmt variable proposed by Dominique). This could leave the current $UploadPrefixFmt variable intact.
Assume in a wiki The following syntax would - using this strategy - be well defined: (:newattachlist /:) (:newattachlist /Home:) (:newattachlist /Home/MyPage:) (:newattachlist:) meaning that the engine should show the list of files
Note that this leads to a common file structure for everyone using pmwiki, but still retains the possibility of storing the files grouped wherever you want. When uploading files for example (especially when using the "upload" button), one should be allowed to specify where the file is put. (The field "Save as" should take also path names to this end, that are meant (consequently) as absolute starting below the upload root dir.) Usually one would only allow path specification using slashes. Considering the current way of addressing attachments in directories different from the current one (using Some extra implementation would be necessary besides changing every single module: currently permission checking is done using the current page (where the markup is placed) as reference. With the new strategy, that page should only do the job of handling the action, while permission checking is done using the path specified. (E.g. when uploading a file with Attach:/OtherGroup/file.txt or displaying files with (:newattachlist /OtherGroup:) (where we assume that this markup is placed in group Home, = different from OtherGroup), the group OtherGroup should be taken as reference for the "upload" permission check.) This means that these checks also have to be possible for groups or the root dir, and this is a really new thing that needs to be implemented then (though it would be not much work, as I estimate from the UserAuth module). |