This repository has been archived by the owner on Jan 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Creating a Module
Jon Stockton edited this page Jun 30, 2014
·
26 revisions
moduleName.zip
includes
- moduleName.mod.php
- moduleName_component.mod.php
templates
- moduleName.template
- moduleName_component.template
- moduleName_component_CONSTANT.template
Code
class moduleName extends SimpleModule {/*code*/}
Rules
moduleName must be the same as the filename: (ex. class testModule in testModule.mod.php)
Arguments
Array $configs - The configuration array from config.inc.php (optional)
Return
Should return TRUE if the module has all the required pieces, FALSE otherwise.
Arguments
Array $configs - The configuration array from config.inc.php (optional)
Return
Should attempt to install missing pieces and return TRUE on success, FALSE otherwise.
Arguments
Array $configs -The configuration array from config.inc.php (optional)
Return
Should attempt to uninstall extra module pieces (templates, database tables,
etc. - not code) and return TRUE on success, FALSE otherwise.
Arguments
String $content - The current template (prior to being parsed)
Array $configs - The configuration array from config.inc.php (optional)
Return
Should return the parsed version of $content (creating/overriding any constants)
Arguments
Array $configs - The configuration array from config.inc.php (optional)
Return
Should return the name of the template to be used ("" for default)
Arguments
Array $configs - The configuration array from config.inc.php (optional)
Return
Should return whatever {CONTENT} should be replaced with.
SimpleUtils::installReqFiles()
<?php
if(SIMPLESITE!=1)
die("Can't access this file directly.");
class testModule extends SimpleDisplay implements simpleModule
{
public static $info=array( "author" => "Jon Stockton",
"name" => "Test Module",
"version" => "1.0",
"date" => "April 9, 2012"
);
public function choosePage()
{
return "";
}
public function sideparse($content)
{
return str_replace("{TEST}","Hello World!",$content);
}
public function isInstalled($configs=array())
{
return $this->checkReqFiles(
array(
$_SERVER['DOCUMENT_ROOT'].$configs['path']['root'].$configs['path']['mod_templates']."/testModule.template"
),
$configs
);
}
public function install($configs=array())
{
$this->installReqFiles(array("testModule.template" => "e1RFU1R9"),$configs);
return TRUE;
}
public function getContent($configs=array())`
{
return $this->readTemplate($_SERVER['DOCUMENT_ROOT'].$configs["path"]["root"].$configs["path"]["mod_templates"]."/testModule.template","testModule");
}
}
?>