[Pmwiki-users] Request for a callback once stdconfig.php has been included

Christian Ridderström chr
Fri Feb 13 06:44:55 CST 2004


Hi

In the beta version, if $PageHeaderFmt is set to a default value in 
stdlayout.php, which is included *after* local.php is executed. 
Furthermore, it is only set if it didn't exist before stdlayout.php is 
included.

The problem here is that I only wish to append something to $PageHeaderFmt
(or modify it)  --- I like the default value and don't want to have to
manually copy the default value from stdalyout.php.

With the current structure that's not possible, so I would like to be able 
to define a callback function that's invoked *after* stdconfig.php has 
been included.

The code in pmwiki.php looks like this right now:

	if (file_exists('local.php')) { include('local.php'); $LocalConf=1; }
	elseif (file_exists('local/local.php'))
	  { include('local/local.php'); $LocalConf=1; }

	SDV($DefaultPage,"$DefaultGroup/$DefaultTitle");
	if ($pagename=='') $pagename=$DefaultPage;

	if ($EnableStdConfig && file_exists('scripts/stdconfig.php'))
		include_once('scripts/stdconfig.php');

But I'd like to change this into:

	// Look for configuration file
	if (file_exists('local.php'))	
	  $ConfigFile='local.php';
	elseif (file_exists('local/local.php'))
	  $ConfigFile='local/local.php';
	elseif (file_exists('local/config.php'))
	  $ConfigFile='local/config.php';
	else
	  $ConfigFile='';
	
	// Include any configuration file that was found
	if (''!=$ConfigFile)	
	  include($ConfigFile);

	SDV($DefaultPage,"$DefaultGroup/$DefaultTitle");
	if ($pagename=='') $pagename=$DefaultPage;

	if ($EnableStdConfig && file_exists('scripts/stdconfig.php'))
	  include_once('scripts/stdconfig.php');

	// Execute callback function if it exists
	if (function_exists('ConfigCallback'))
	  ConfigCallback();

where I

* Sneaked in code allowing you name the configuration file 'config.php'
* Replaced $LocalConf with $ConfigFile, different name and semantics
* Added a callback to ConfigCallback() if that function exists

What do you think?

/Christian

-- 
Christian Ridderstr?m                           http://www.md.kth.se/~chr





More information about the pmwiki-users mailing list