Debian Codegraph @

docs/devel/mod_basics.htm

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html lang="en"><head><title>Module HowTo - Basic concepts</title>
3
4
5
6 <link rel="stylesheet" type="text/css" href="style/layout.css">
7 <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body>
8 <div style="text-align: center;">
9 <h1>Module HowTo - Basic concepts<br>
10 </h1>
11 <br>
12 <br>
13 <div style="text-align: left;"><br>
14 <h2>1. Licensing</h2>
15 LAM is licensed under the <a href="https://www.gnu.org/licenses/gpl.txt">GNU
16 General Public License</a>. This means your plugins need a compatible
17 license.<br>
18 LAM is distributed with a copy of the GPL license.<br>
19 <br>
20 <h2>2. Naming and position in directory structure</h2>
21 <br>
22 Module names are usually named after the object class they manage.
23 However, you can use any name you want, it should be short and
24 containing only a-z and 0-9. The module name is only shown in the
25 configuration dialog, on all other pages LAM will show a provided <span style="font-style: italic;">alias</span> name.<br>
26 All account modules are stored in <span style="font-weight: bold;">lib/modules</span>.
27 The filename must end with <span style="font-weight: bold;">.inc</span>
28 and the file must have the same name as its inside class.<br>
29 <br>
30 <span style="font-weight: bold; text-decoration: underline;">Example:</span>
31 Our example module will provide the <span style="font-weight: bold;">class
32 ieee802Devic</span><span style="font-style: italic; font-weight: bold;">e</span>,
33 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>
34 <br>
35 <br>
36 <h2>3. Defining the class</h2>
37 All module classes have <span style="font-weight: bold;">baseModule</span>
38 as parent class. This provides common functionality and dummy functions
39 for all required class functions.<br>
40 <br>
41 <span style="font-weight: bold;">Example:</span><br>
42 <br>
43 <div class="mod-code">
44 * Provides MAC addresses for hosts.<br>
45 *<br>
46 * @package modules<br>
47 */<span style="font-weight: bold;"><br>
48 class</span> <span style="color: rgb(255, 0, 0);">ieee802Device</span>
49 <span style="font-style: italic;">extends </span><span style="font-weight: bold;">baseModule</span> {<br>
50 <br>
51 }<br>
52 </div>
53 <br>
54 <h2>4. Meta data</h2>
55 The module interface includes a lot of required and optional functions.
56 Many of these functions do not need to be implemented directly in the
57 module, you can define <span style="font-weight: bold;">meta data</span>
58 for them and the <span style="font-weight: bold;">baseModule</span>
59 will do the rest.<br>
60 Providing <span style="font-weight: bold;">meta data</span> is
61 optional, you can implement the required functions in your class, too.<br>
62 <br>
63 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>
64 <br>
65 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br>
66 <br>
67 <div class="mod-code">
68 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
69 class<br>
70 &nbsp;&nbsp;&nbsp; *<br>
71 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
72 &nbsp;&nbsp;&nbsp; */<br>
73 &nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span> <span style="color: rgb(255, 0, 0);">get_metaData</span>() {<br>
74 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
75 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // icon<br>
76 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return['icon'] = 'user.png';<br>
77 &nbsp;&nbsp;&nbsp; }<br>
78 </div>
79 <br>
80 You will see this functions several times in the next parts of this
81 HowTo.<br>
82 <br>
83 </div>
84 </div>
85 </body></html>