-
Notifications
You must be signed in to change notification settings - Fork 0
Adding Modules
Timothy Gibbons edited this page Apr 21, 2018
·
1 revision
In the recent version you can add your own pages and modules to the system.
If you need to install something to the database though an install file. You can append (using file
$GLOBALS['{MODULE_NAME}']['install'] = true;
to the inc/install.php file. You can use the following code
if(is_writable('inc/install.php'))
file_put_contents('inc/install.php', '<?php\n$CONFIG[\'{MODULE_NAME}\'][\'install\'] = true;\n?>', FILE_APPEND);
else
die('Config not writable');
To create a new module you can do the following
- Create a new folder with the module name
- Enter into the folder
- Create a new file with the following format
{Module Name}.module.php
* ** - Add in that file**
<?php
$core = Module::Register('{Module Name}'); // *
$core->description = "{Description}";
$core->author = "{Author Name}";
$core->version = "1.0.0";
?>
Those with * it have to be the same as the folder name Those with ** replace what's in {}
$core->addPage('/page', function(){
require 'pages/index.php';
return true; // Don't redirect to 404. turn to false to redirect to 404.
});
If there is a link that have a prameter you can use
$core->addPage('/page/(.*)/', function($p1){
$p1 = Output::clean($p1); // Clean $p1
require 'pages/index.php';
return true; // Don't redirect to 404. turn to false to redirect to 404.
});
you can add more just like:
$core->addPage('/page/(.*)/(.*)', function($p1, $p2){
$p1 = Output::clean($p1); // Clean $p1
$p2 = Output::clean($p2); //Clean $p2
require 'pages/index.php';
return true; // Don't redirect to 404. turn to false to redirect to 404.
});
To allow for GET
parameters:
$core->addPage('/page/(.*)/(.*)/(.*)', function($p1, $p2){
$p1 = Output::clean($p1); // Clean $p1
$p2 = Output::clean($p2); //Clean $p2
require 'pages/index.php';
return true; // Don't redirect to 404. turn to false to redirect to 404.
});
$core->classAutoload(function($class){
if (file_exists('modules/{Module Name}/{path to all the classes}/'.$class.'.class.php')){
require 'classes/'.$class.'.class.php';
return true;
}
return false;
});