PackageVisionBtodoroff

Created by: btodoroff, Last modification: 20 Feb 2004 (19:03 UTC)

How a bitweaverPackage should function


I've been thinking alot about this the last few days. How should a bitweaverPackage be constructed? How do we make it intuitive, high performance and low maintenace? These are my thoughts so far. I encourage you to send me comments and ideas.

Hello World!


This is my ideal of the most basic of TikiPackages. With just these files, in the directory helloworld in the root directory, bitweaver should be able to:
  1. Add a 'helloworld' to the list of availible packages in the admin menu
  2. Once that package is enabled in the admin menu, a 'helloworld' entry should appear in the main menu with a link to 'helloworld\main.php'
  3. When that menu entry is selected, helloworld/main.php should display the string "Hello World!" in the content area of the site with all menus, and theme elements around it.

helloworld/main.php
<?php
require_once ('bitweaver_setup_min.php');

$smarty->assign('msg', tra("Hello World!"));

$tikpro->display("helloworld.tpl");
php?>

helloworld/templates/main.tpl

{$msg}




More Advaced Package


postit/moduleinfo.php
<?php
$moduleinfo['BaseName']='postit';
$moduleinfo['FullName']='PostIt';
$moduleinfo['Description']='Allows users to post notes to a simple, shared bulliten board';
$moduleinfo['Homepage']='www.bitweaver.org';
$moduleinfo['ContactEmail']='brian@todoroff.com';
php?>

Provides details about a module and it's orgins. Rarely accessed outside of admin pages that list/discover avalible modules.

postit/sql/basic_mysql.sql
DROP DATABASE IF EXISTS ~~PREFIX~~MSG;
CREATE TABLE ~~PREFIX~~MSG;
(
id int(14) NOT NULL auto_increment,
messages text,
PRIMARY KEY (activityId)
) TYPE=MyISAM AUTO_INCREMENT=1 ;

INSERT INTO ~~PREFIX~~MSG (`message') VALUES ('Welcome to the PostIt board');

This file holds the SQL for the database tables needed for the package.
Above ~~PREFIX~~ is the current DB Prefix for this bitweaver install plus the directory name for the current module. ( ie For a DB prefix of MAIN_ and a foldername of postit the ~~PREFIX~~ is repalced by the core with 'MAIN_POSTIT_'. This allows multiple installs of the same module in different directories if needed.)

postit/setup.php
<?php
if(!$bitweaver->hasPermission('tiki_setup_module'))
{
die();
}
//Specify which version of the setup.sql to use
$moduleFactory->setupDB('basic');
//destination for main menu link. Text is the 'FullName' from $moduleinfo above.
$moduleFactory->setMainMenu('main.php');
//Add an item and destination for a submenu under the main menu.
$moduleFactory->addSubMenu('Clean Messages','cleanup.php'); php?>

This file does the actual setup of the module. It gets included() from the admin page when asked to set up / activate a package.

postit/main.php
<?php
require_once ('bitweaver_setup.php');

// If new messge submited insert into db.

// Display all messages
$query="SELECT `id`,`message` FROM `.bitweaver->GetFullDBPrefix()."MSG";
//Build array $results of 'id' => 'message'
$smarty->assign('messages',$results);

$tikpro->display("main.tpl");
php?>


postit/templates/main.tpl

Post It Messages


{foreach from=$messages key=curr_id item=msg_text}
id: {$curr_id} msg: {$msg_text}

{/foreach}