Well, this is my way of doing plugings - I write them like a standalone app - with their templates, classes etc.
I have a config file in which is described which plugin go to what page. (About - article, gallery - using gallery plugin).
And I just make a plugin.php file that is loaded to the CMS, and it is using all the global vars.
Example.
CMS calling the plugin.php -
PHP Code:
<?php
// Loading the plugin "controller"
include_once( 'lib/pluginFrontController.php');
$action = $engine->url->action;
$fc = new x3PluginFrontController( $module, $action );
include_once( 'tmpl/index.php');
?>
And the pluginFrontController.php -
PHP Code:
<?php
include_once '__pluginPrototype.php';
class x3PluginFrontController extends __pluginPrototype {
protected $module;
public function __construct ( $action, $module ) {
parent::__contruct();
switch ( $action ) {
case 'view':
include_once 'x3PluginView.php';
x3PluginView::__construct( $module );
break;
default:
include_once 'x3PluginMain.php';
x3PluginMain::__construct( $module );
break;
}
}
}
?>
And at last - pluginPrototype :
PHP Code:
<?php
class __pluginPrototype {
protected $article = "table_article";
protected $comment = "table_comments";
protected $user = "table_users";
public function __construct() {}
protected function __doSomeAction() {}
}
?>
In plugin prototype I've added database table names as protected and some function that will be use trough all the classes - eg. check data, or check user..
All "actions"- view, comment etc are seperate classes in which you define what is going to happen in that action - view - loads the selected article etc.
I used to write all this in one big class - and it become ove bloated - one class had ~1200 lines. So this seems like a good thing - for now.
If anybody has any suggestions - please suggest :)
Critcism is always welcome.
This could be modified to use the real MVC platform - like ZendFramework/Cake/Kohana ...