Home Private Messages Search
CPG Dragonfly™ CMS Dedicated Server & Bandwidth Sponsored by DedicatedNOW
 
Wiki ⇒ v9 Developer's Manual ⇒ Installer ⇒ cpg_inst.php

Wikiv9 Developer's ManualInstaller ⇒ cpg_inst.php  

Glossary
The Project
Install
Upgrading or Switching
Dragonfly admininistration
Dragonfly public view
Dragonfly Themes
Build local server
Running Dragonfly CVS
Tips and Tricks
Rules & Regulations
v9 Developer's Manual
v10 Developer's manual
13.1.1: cpg_inst.php Parent

It is an installer helper but also a controller for module install and upgrade. Within this document you will find detailed information about cpg_inst.php and how to use it.

Table of content

Structure

Class name
must be the same, case sensitive, module name. Within this document we use Example as Class name

Class constructor
must be the same, case sensitive, as the Class name. Within this document we use Example as constructor name. PHP5 users can directly use function __construct() instead.

$this->radmin
if true you will be able to set admin permission rules for this module.

$this->version
Versioning wiki entry

$this->modname
the name of your module, used in the credits.html

$this->description
the module description that will show up in different areas of DragonflyCMS, including credits.html

$this->author
well thats easy

$this->website
website url where support can be found

$this->prefix
by default every module will prefix tables using is own name. Using the untouched defaults, which we strongly suggest, you will have all of your tables called cms_example. It means that the installer will prepend the global and user defined database tables $prefix to the module's $this->prefix

$this->db_tables
default empty, module doesn't use database tables and you don't even need this file then. If our module needs to store its own data, then we use it as follow:
$this->dbtables = array($this->prefix, $this->prefix.'_cat', $this->prefix.'_config');
we will end up by having cms_example, cms_example_cat and cms_example_config tables.

function install()
called only when installing a module, most luckily we don't need to modify this function at all. Keep reading and you will found out why.

function uninstall()
called only when uninstalling, most luckily we don't need to modify this function at all. Keep reading and you will found out why.

function upgrade()
called for module's upgrade, red or blue pill?

File content

<?php
/*********************************************
  CPG Dragonfly™ CMS
  ********************************************
  Copyright © 2004 - 2008 by CPG-Nuke Dev Team
  http://dragonflycms.org

  Dragonfly is released under the terms and conditions
  of the GNU GPL version 2 or any later version
**********************************************/
if (!defined('ADMIN_MOD_INSTALL')) { exit; }

class 
Example {
    var 
$radmin;
    var 
$version;
    var 
$modname;
    var 
$description;
    var 
$author;
    var 
$website;
    var 
$prefix;
    var 
$dbtables;

    function 
Example() {
        
$this->radmin true;
        
$this->version '0.0.0.1';
        
$this->modname 'Example';
        
$this->description 'Store and display your favorite examples.';
        
$this->author 'Your name';
        
$this->website 'example.com';
        
$this->prefix strtolower(__CLASS__);
        
$this->dbtables = array();
    }

# module installer
    
function install() {
        global 
$tablelist$tables$indexes$records;
        foreach (
$tables AS $table => $columns) {
            if (isset(
$tablelist[$table])) { $db->query('DROP TABLE '.$tablelist[$table]); }
            
db_check::create_table($table$columns$indexes[$table]);
        }
        if (
is_array($records) && !empty($records)) {
            foreach (
$records AS $table => $content) {
                
db_check::table_data($table$content);
            }
        }
        return 
true;
    }
    
# module uninstaller
    
function uninstall() {
        global 
$installer;
        foreach (
$this->dbtables as $table) {
            
$installer->add_query('DROP'$table);
        }
        return 
true;
    }

# module upgrader
    
function upgrade($prev_version) {
        global 
$tablelist$tables$indexes$records$installer;
        foreach (
$tables AS $table => $columns) {
            
db_check::table_structure($table$columns$indexes[$table]);
        }
        if (
is_array($records) && !empty($records)) {
            foreach (
$records AS $table => $content) {
                
db_check::table_data($table$content);
            }
        }
        return 
true;
    }
}

?>

Examples

Install


Upgrade


 
Updated: Sunday, October 23, 2011 (06:07:02) by Dizfunkshunal
Created:  Friday, February 29, 2008 (08:50:44) by NanoCaiordo

You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
Interactive software released under GNU GPL, Code Credits, Privacy Policy