[Wiki] created: CreatingYourFirstModule

Wiki Guest <[email protected]>
Newsgroups gmane.comp.horde.cvs
Message-ID <[email protected]>
guest [194.176.193.10]  Fri, 15 Aug 2008 08:52:14 -0400

Created page: http://wiki.horde.org/CreatingYourFirstModule

+ Creating a Horde Module

1. Check out the skeleton module from horde CVS

<code type="sh">
export CVSROOT=:pserver:[email protected]:/repository
# The following password is horde
cvs login
cvs export -d modulename -r HEAD skeleton
</code>

2. Create the following script as prjrename.php - save it somewhere  
sensible, like your home directory:

<code type="php">
<?php

if (count($_SERVER['argv'])==3) {

   $prjUC=strtoupper(trim($_SERVER['argv'][2]));
   $prjLC=strtolower($prjUC);
   $prjMC=substr($prjUC, 0, 1) . substr($prjLC, 1, strlen($prjLC)-1);

   $filehandle=fopen(trim($_SERVER['argv'][1]), 'r');
   $file=fread($filehandle, filesize($_SERVER['argv'][1]));
   fclose($filehandle);
   $newfile=str_replace(array('SKELETON', 'Skeleton', 'skeleton'),  
array($prjUC, $prjMC, $prjLC), $file);
   $filehandle=fopen(trim($_SERVER['argv'][1]), 'w');
   fwrite($filehandle, $newfile);
   fclose($filehandle);
} else {
   help();
}

function help() {
   echo "php prjrename.php [filename] [string]
filename = The file to update
string = the name of the file to replace
";
}

?>
</code>

3. On a unix system, use the following command to replace all skeleton  
strings with your project name (I don't think there's an appropriate  
command for windows, unless you've got cygwin):

<code type="sh">
find /path/to/skeleton/export -type f -exec php -q  
/path/to/prjrename.php '{}' modulename
</code>

4. Perform some file modifications:

<code type="sh">
mv /path/to/modulename/lib/Skeleton.php /path/to/modulename/lib/Modulename.php
mkdir /path/to/modulename/themes/graphics
</code>

5. Upload a PNG icon at 16x16 for the module to the path created  
above, this one is available if you're stuck:

http://spriggs.org.uk/projects/horde_dev/fitlog/themes/graphics/fitlog.png

6. In /path/to/horde/config/registry.d/ create a file called  
modulename.php. Please note the lack of ?> at the end of the php  
block, and also the menu parent. If you want your object to go  
*ANYWHERE ELSE* you will need to change this!

<code type="php">
<?php
$this->applications['modulename'] = array(
     'fileroot' => dirname(__FILE__) . '/../modulename',
     'webroot' => $this->applications['horde']['webroot'] . '/modulename',
     'name' => _("A description of your module"),
     'status' => 'active',
     'menu_parent' => 'horde'
);
</code>

OK, so you now have your first module. Now, you need to populate it  
with content. This will be the subject of the next section.

--
To unsubscribe, mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.