110 lines
4.1 KiB
HTML
110 lines
4.1 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Module HowTo - Basic concepts</title>
|
||
|
<link rel="stylesheet" type="text/css" href="style/layout.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<div style="text-align: center;">
|
||
|
<h1>Module HowTo - Basic concepts<br>
|
||
|
</h1>
|
||
|
<br>
|
||
|
<br>
|
||
|
<div style="text-align: left;"><br>
|
||
|
<h2>1. Licensing</h2>
|
||
|
LAM is licensed under the <a href="http://www.gnu.org/licenses/gpl.txt">GNU
|
||
|
General Public License</a>. This means your plugins need a compatible
|
||
|
license.<br>
|
||
|
LAM is distributed with a copy of the GPL license.<br>
|
||
|
<br>
|
||
|
<h2>2. Naming and position in directory structure</h2>
|
||
|
<br>
|
||
|
Module names are usually named after the object class they manage.
|
||
|
However, you can use any name you want, it should be short and
|
||
|
containing only a-z and 0-9. The module name is only shown in the
|
||
|
configuration dialog, on all other pages LAM will show a provided <span
|
||
|
style="font-style: italic;">alias</span> name.<br>
|
||
|
All account modules are stored in <span style="font-weight: bold;">lib/modules</span>.
|
||
|
The filename must end with <span style="font-weight: bold;">.inc</span>
|
||
|
and the file must have the same name as its inside class.<br>
|
||
|
<br>
|
||
|
<span style="font-weight: bold; text-decoration: underline;">Example:</span>
|
||
|
Our example module will provide the <span style="font-weight: bold;">class
|
||
|
ieee802Devic</span><span style="font-style: italic; font-weight: bold;">e</span>,
|
||
|
therefore the file will be called <span style="font-weight: bold;">lib/modules/ieee802Devic</span><span
|
||
|
style="font-style: italic; font-weight: bold;">e.inc</span>.<span
|
||
|
style="font-style: italic;"></span><br>
|
||
|
<br>
|
||
|
<br>
|
||
|
<h2>3. Defining the class</h2>
|
||
|
All module classes have <span style="font-weight: bold;">baeModule</span>
|
||
|
as parent class. This provides common functionality and dummy functions
|
||
|
for all required class functions.<br>
|
||
|
<br>
|
||
|
<span style="font-weight: bold;">Example:</span><br>
|
||
|
<br>
|
||
|
<table style="width: 100%; text-align: left;" class="mod-code"
|
||
|
border="0" cellpadding="2" cellspacing="2">
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td style="vertical-align: top;">/**<br>
|
||
|
* Provides MAC addresses for hosts.<br>
|
||
|
*<br>
|
||
|
* @package modules<br>
|
||
|
*/<span style="font-weight: bold;"><br>
|
||
|
class</span> <span style="color: rgb(255, 0, 0);">ieee802Device</span>
|
||
|
<span style="font-style: italic;">extends </span><span
|
||
|
style="font-weight: bold;">baseModule</span> {<br>
|
||
|
<br>
|
||
|
}<br>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<br>
|
||
|
<h2>4. Meta data</h2>
|
||
|
The module interface inludes a lot of required and optional functions.
|
||
|
Many of these functions do not need to be implemented directly in the
|
||
|
module, you can define <span style="font-weight: bold;">meta data</span>
|
||
|
for them and the <span style="font-weight: bold;">baseModule</span>
|
||
|
will do the rest.<br>
|
||
|
Providing <span style="font-weight: bold;">meta data</span> is
|
||
|
optional, you can implement the required functions in your class, too.<br>
|
||
|
<br>
|
||
|
The <span style="font-weight: bold;">baseModule</span> reads the <span
|
||
|
style="font-weight: bold;">meta data</span> by calling <span
|
||
|
style="font-weight: bold;">get_metaData()</span> in your class.<br>
|
||
|
<br>
|
||
|
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br>
|
||
|
<br>
|
||
|
<table style="width: 100%; text-align: left;" class="mod-code"
|
||
|
border="0" cellpadding="2" cellspacing="2">
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td style="vertical-align: top;"> /**<br>
|
||
|
* Returns meta data that is interpreted by parent
|
||
|
class<br>
|
||
|
*<br>
|
||
|
* @return array array with meta data<br>
|
||
|
*/<br>
|
||
|
<span style="font-weight: bold;">function</span> <span
|
||
|
style="color: rgb(255, 0, 0);">get_metaData</span>() {<br>
|
||
|
$return = array();<br>
|
||
|
// manages host accounts<br>
|
||
|
$return["account_types"] =
|
||
|
array("host");<br>
|
||
|
}<br>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<br>
|
||
|
You will see this functions several times in the next parts of this
|
||
|
HowTo.<br>
|
||
|
<br>
|
||
|
<h2><span style="font-weight: bold;"></span></h2>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|