I'm trying to make minicms a plugin, and I'm obviously missing something.
I wanted to keep all the files self contained down in the plugin folder.
There are two pages that were built to administer the cms system, I moved them from the root of the gallery to the plugin dir.
/gallery/plugins/minicms/cms_admin.php
/gallery/plugins/minicms/cms_edit.php
However I can't include init.inc.php even if I use the right relative path.
require('../../include/init.inc.php');
Warning: main(include/debugger.inc.php): failed to open stream: No such file or directory in c:\inetpub\wwwroot\develcms\include\init.inc.php on line 26
Fatal error: main(): Failed opening required 'include/debugger.inc.php' (include_path='.;c:\php4\pear') in c:\inetpub\wwwroot\develcms\include\init.inc.php on line 26
I can see why this is happening, but other than moving those files to /gallery I'm not seeing a way around it.
I don't see how I can use filters to prevent the rest of a regular coppermine page shown, and insert my own. (or even if that would be an acceptable way if I could).
I'm thinking perhaps I could put a placeholder .php file out at the root of the gallery and do something like this:
plugin.php:
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
// if no plugin is specified then abort, don't let plugin writers get sloppy
// Plugins use the 'plugin_full_page' filter and examine the passed variable
// to see if its for them.
if (isset($_GET['plugin']))
$plugin = (int)$_GET['plugin'];
elseif (isset($_POST['plugin']))
$plugin = $_POST['plugin'];
else
cpg_die(CRITICAL_ERROR, 'No Plugin Specified', __FILE__, __LINE__);
$data=CPGPluginAPI::filter('plugin_full_page',$plugin);
// If no $data was returned then no point in proceeding any further, something is wrong.
if (!$data) cpg_die(CRITICAL_ERROR, 'No data returned from plugin!', __FILE__, __LINE__);
pageheader($data['title']);
echo $data['content'];
pagefooter();
ob_end_flush();
?>
At that point your plugin could act on all the superglobals, do its work, and then return an array with the output. And it's generic enough it could work for any plugin who needed to do something similar.
Thoughts?