Creating a Module

From PGVWiki
Jump to navigation Jump to search

Modules File Structure

modules (dir)
+--your_module (dir)
|  |
|  +--languages (dir)
|  |  +--ym_lang.en.php
|  |
|  +--images (dir)
|  |  +--icon.gif
|  |
|  +--your_module.php
|  +--menu.php
|  +--ym_privacy.php
|  +--ym_functions.php


Copy the following code into your file and save it:

;<?php exit; ?>
type = PGV_MOD_OO

As far as I can tell, this will tell PGV that your module is a PGV module.


Replace instances of your_module with your module's name and ym with the initials for your module


//-- security check, only allow access from module.php. Include this code in each of your module files
if (strstr($_SERVER["SCRIPT_NAME"],"menu.php")) {
   print "Now, why would you want to do that.  You're not hacking are you?";

class your_module_ModuleMenu {
     * get the Your Module menu
     * @return Menu 	the menu item
  function &getMenu() {
      global $TEXT_DIRECTION, $PGV_IMAGE_DIR, $PGV_IMAGES, $GEDCOM, $pgv_lang;
      global $PRIV_USER, $PRIV_PUBLIC;


      if (!file_exists("modules/your_module.php")) return null;
      if ($PRIV_USER<getUserAccessLevel()) return null;  

      if (!file_exists('modules/your_module/languages/ym_lang.en.php')) return null;

      require_once 'modules/your_module/languages/ym_lang.en.php';
      if ($TEXT_DIRECTION=="rtl") $ff="_rtl"; else $ff="";

      //-- main menu item - this uses the icon as the Welcome Page menu
      $menu = new Menu($pgv_lang["your_module"], "module.php?mod=your_module", "down");
      if (!empty($PGV_IMAGES["gedcom"]["large"]))
      $menu->addClass("menuitem$ff", "menuitem_hover$ff", "submenu$ff");
      //'First Task' ddl menu item //this is the first sub menu option
      if (getUserAccessLevel(getUserName())<= $SHOW_FIRST_OPTION)//set $SHOW_FIRST_OPTION is set in ym_privacy.php
           $submenu= new Menu($pgv_lang["first_option"], "module.php?mod=your_module&action=firstop");
           $submenu->addClass("submenuitem$ff", "submenuitem_hover$ff");
          //Additional sub menu options can be added by repeating the code above
         return $menu;