TBS plugin for PmWiki

4 views
Skip to first unread message

TomH

unread,
Aug 3, 2008, 11:24:58 AM8/3/08
to TinyButStrong next version
Skrol29,

I am trying to make the plugin easier to use by users -- but NOT have
to give them access to editing the pmwiki config.php file.

As it stands now, for a user to add a tbs script she must be able to
edit the config.php to add the needed line...
$TbsScriptToCall['basename'] = 'filename';

So I try making a little sub-script to parse the
$TbsScriptToCall['path'] directory and dynamically build the
$TbsScriptToCall[] array.

The sub script "tbs_scripttocall_array.php" looks like..
----------------------------------------------------------------------------------
$tbs_dir = "/my_tbs_apps"; // $tbs_dir = $TbsScriptToCall['path'];

$tbs_prefix = "pm_"; // $tbs_prefix = $TbsScriptToCall['prefix'];

if ($handle = opendir($tbs_dir)) {
while (false !== ($file = readdir($handle))) {
if( !is_dir($file) ){
$path_parts = pathinfo($file);
if( $path_parts['extension']=="php" && strncmp($tbs_prefix,
$path_parts['filename'],2)==0 ){
$TbsScriptToCall[ $path_parts['filename'] ] =
$path_parts['basename']; }
}
}

// echo "<br><hr>TbsScriptToCall:<br>". $out =
print_r($TbsScriptToCall,true)."<hr>"; // debugging

closedir($handle);
}
-----------------------------------------------------------------------------------

Then I would add to the pmWiki config.php file
-----------------------------------------------------------------------------------
$TbsScriptToCall['path'] = 'my_tbs_apps/'; // relative to the PmWiki
root
$TbsScriptToCall['prefix'] = 'pm_';

// add a subscript here that will read the dir at
TbsScriptToCall['path']
// and instantiate the TbsScriptToCall['filename']=basenamename.".php"

include("/tbs_scripttocall_array.php");
-----------------------------------------------------------------------------------

So I have two questions for you to entertain:

(1) This approach is not working - i am getting the error
"(TBS for pmWiki) Error : parameter 'pm_ltw_cal_reminders2' is not
allowed. " I am inferring that this means that I am NOT getting the
array built -or- I have scripts in the improper directory but I cannot
seem to be able to debug this as it is wrapper inside of pmWiki (( the
"tbs_scripttocall_array.php" script works perfectly when run outside
of pmWiki so I feel the basic coding is okay))
Do you see the/any flaws in my approach?

(2) is this worth the effort to add to tbs_pmwiki plugin

Thanks for any help you can give, and thanks for TBS every day
TomH

TomH

unread,
Aug 3, 2008, 11:37:17 AM8/3/08
to TinyButStrong next version
Okay, it works now, it was thew directory structure,

* I now place "tbs_scripttocal_array.php" in the pmwiki/local/
directory
* then change pmwiki config.php as follows
------------------------
$TbsScriptToCall['path'] = 'my_tbs_apps/'; // relative to the PmWiki
root
$TbsScriptToCall['prefix'] = 'pm_';

include("tbs_scripttocall_array.php");
------------------------

So only asking now question (2) is this something worth making change
to the TBS_PmWiki plugin ??

Thanks a lot,
TomH

Skrol29

unread,
Aug 4, 2008, 5:59:21 PM8/4/08
to tbs-...@googlegroups.com
Hi TomH,

This is a good idea for a new feature.
But it seems to me that you don't need to build the array. You just need to check if the script is in the array, or if the script matches with the prefix.

I can implement that if you want.
---------------------
Skrol29
www.skrol29.com
www.tinybutstrong.com
---------------------


TomH a écrit :

TomH

unread,
Aug 4, 2008, 6:29:41 PM8/4/08
to tbs-...@googlegroups.com
Hi Skrol29

See below

Skrol29 wrote:
> Hi TomH,
>
> This is a good idea for a new feature.
> But it seems to me that you don't need to build the array.

The $TbsScriptToCall['scriptbasename'] array must be used
for something I guessed ;) maybe not?

> You just need
> to check if the script is in the array,

Not understanding which array you mean that would be checked
-- did you mean to say 'check if it is in the directory'?


> or if the script matches with
> the prefix.

???

Thanks,
TomH
Reply all
Reply to author
Forward
0 new messages