Sample Code: Hello World Module
Here a simple example how to create a hello world module.
1. Database changes:
INSERT INTO `liveoffice`.`config` SET `code` = 50, `value` = 'helloworld', `desc` = 'module', `property` = 1;
2. Files:
#1: Create a folder called:
helloworld
#2: Create the following files:
-
helloworld/action.php - view/hide source
<?php
$helloworld = new HelloWorld();
$helloworld->setAction($action);
$helloworld->process();
echo $helloworld->getResult();
-
helloworld/class/HelloWorld.class.php - view/hide source
<?php
/**
* HelloWorld Class [ HelloWorld.class.php ]
*
* @author Eric Potvin
* @package Live-Office
* @subpackage Module
* @copyright Copyright © 2010, Eric Potvin
* @link http://www.live-office.net
*
* @license http://opensource.org/licenses/gpl-license.php
* The GNU Public License
*/
/**
* HelloWorld class
*
* HelloWorld module class.
*
* @package Live-Office
* @subpackage Module
*/
final class HelloWorld extends ModuleAction {
/**
* HelloWorld Constructor.
*
* @param Integer $userId User id.
*/
public function __construct() {
}
/**
* HelloWorld Destructor.
*
*/
function __destruct() {
}
/**
* Execute or assign variables on window open.
*
* @return Array
*/
protected function onWindowOpen() {
}
}
-
helloworld/lang/en.php - view/hide source
<?php
$language['title'] = 'Hello World';
-
helloworld/templates/theme/default/index.html - view/hide source
<div class="drsElement windowFrame_default" style="width:250px;height:250px;left:150px;top:200px;z-index:100">
<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%">
<tr height="25">
<td class="drsMoveHandle windowTitleBar">
<div class="windowTitleText">{$language.title}</div>
</td>
<td class="windowButton">
<img src="{$imgs_path}window_default_close.png" onclick="closeWindow('div_window_helloworld')" style="cursor:pointer;">
</td>
</tr>
<tr>
<td colspan="2" valign="top" style="text-align:center;padding-top:20px;background:white">
Hello World
</td>
</tr>
</table>
</div>
- helloworld/templates/theme/default/imgs/icon_mini.png (16x16)
- helloworld/templates/theme/default/imgs/icon_min.png (48x48)
- helloworld/templates/theme/default/imgs/icon.png (64x64)
- helloworld/templates/theme/default/imgs/icon_small.png (22x22)
3. Create the cache template folder:
mkdir -m 777 -p /tmp/templates_c/preference/theme/default/