Modules
For creating a new Modul, at least the following Folder and File structure is required:
--- /consumer/cid{CID}/modul/
|
+--- /modulName/
|
+-------- modul.php
Read more about the path /consumer/cid{CID}/. Assume Community ID 1, you place your module in /consumer/cid1/modul/.
If you added the folder correctly, you should be able to use this module for menu pages.
If your module uses extended features like translations, then you should create the following structure:
--- /consumer/cid{CID}/modul/
|
+--- /modulName/
|
+-------- modul.php
+-------- modul.ini
|
+-------- /translation/
| |
| +-------- /en/
| | |
| | +-------- modulName.properties
| |
| +-------- /../
| |
| +-------- modulName.properties
Follow the naming syntax and case, otherwise your module will likely not work.
Read the section ”Translations” for knowledge about how BIGACE handles translations.
modul.php
This is the main Modul File that holds the full Modules logic. Simply script your PHP code as you always do.
modul.ini
This is the Modul Configuration File, that could look like this:
; ; Example INI File for the Developer Manual ; ; possible settings are TRUE and FALSE translate = FALSE ; a comma separated list of functional right names frights = ; following is optional and only required if your modul uses Modul Configurations ; it is a comma separated list of property name (avoid special character) properties = "property_foo,property_bar" [property_foo] ; shown in the modul config dialog as title name = "Foo will be used?" ; the type. available: "Boolean", "String", "Integer", "Text", "Category" type = "Boolean" ; whether this value must be set for proper modul work - the value is currently NOT tested by the application! ; you should avoid setting to "false" unless you cannot apply default values (like email address) optional = true ; the default value, if the configuration is not set default = false [property_bar] name = "An example value" type = "Text" optional = true default = "A default values, which will be used as long as the user did not set on"
If you switch “translate” to “TRUE”, the optional Translation File “translation.lang.php - translation.properties” will be loaded into the global Translation Namespace.
modul.lang.php - modul.properties
This File holds the description and name for the Modul and looks like this (in case of an INI File):
; a comment name = the modules name title = the modules title description = a short description of this module world = out there
The “Name” is shown in the Menu Administration, the “Title” and “Description” will be shown in the Module Admin Plugin.
These translations are not accessible within the Global Namespace, but only by calling the Moduls Class Methods.
translation.properties
If your module uses translations, you put them into this ResourceBundle. The translations will be auto-loaded if you switch the INI setting “translate” to “TRUE”.
Show Admin link and fetch configurations
import('classes.modul.ModulService');
import('classes.modul.Modul');
// default values, must not be set, will overwrite ini "default" setting
$config = array('property_bar' => 'I am an dynamic default value: ' . date());
$modulService = new ModulService();
$modul = new Modul($MENU->getModulID());
$config = $modulService->getModulProperties($MENU, $modul, $config); // config is optional
// if the current user is able to configure the modul, display the config link
if ($modul->isModulAdmin())
{
import('classes.util.links.ModulAdminLink');
import('classes.util.LinkHelper');
$mdl = new ModulAdminLink();
$mdl->setItemID($MENU->getID());
$mdl->setLanguageID($MENU->getLanguageID());
?>
<script type="text/javascript">
<!--
function openAdmin()
{
fenster = open("<?php echo LinkHelper::getUrlFromCMSLink($mdl); ?>","ModulAdmin","menubar=no,toolbar=no,statusbar=no,directories=no,location=no,scrollbars=yes,resizable=no,height=350,width=400,screenX=0,screenY=0");
bBreite=screen.width;
bHoehe=screen.height;
fenster.moveTo((bBreite-400)/2,(bHoehe-350)/2);
}
// -->
</script>
<?php
echo '<div class="modulAdminLink" align="left"><a onClick="openAdmin(); return false;" href="'.LinkHelper::getUrlFromCMSLink($mdl).'"><img src="'.$GLOBALS['_BIGACE']['DIR']['public'].'system/images/preferences.gif" border="0" align="top"> Module Admin</a></div>';
}
foreach($config AS $confKey => $confValue) {
echo '<br>Key <u>'.$confKey.'</u> has value: <b>'.$confValue.'</b>';
}
