ArchitectureTransition

Created by: spiderr, Last modification: 26 Oct 2008 (10:36 UTC) by laetzer

This documentation page refers to Bitweaver version 1.

1. Moving files

Implement the new bitweaverArchitecture file structure. bitweaver starts with the TikiWiki code base and reorganizes it. The idea is to start with the ReleaseAl code base, and to move what was and TikiWiki's lib/ directory, which is nicely organized, to the root. Then, move all the templates, modules, and php files related to that lib, into its lib directory. See bitweaverArchitecture for example of the new file structure.

2. Creating SQL file

SQL file adds the only required database ALTER:

<?php
ALTER TABLE tiki_modules ADD COLUMN package VARCHAR
(255);
?>

This column is necessary to know which Package directory to go dig the module file from. Also, the "tikiIndex" preference must be deleted if it is "tiki-index.php" since that now longer exists. These SQL changes are in tikiroot/db/spidercore.sql

3. Updating include and require

Use the new naming convention and PathDefine's. This involves testing and running a lot of multi-file search and replace.

<?php
OLD WAY
: include_once ('lib/notifications/notificationlib.php');
NEW 
WAY: include_once ( KERNEL_PKG_PATH.'notification_lib.php' );
?>

I run lots and lot of find commands to do multi-file search and replace. For example, this replaces all include and requires of bloglib.php with the define for the blog package location and new name convention:

<?php
find 
. -name "*php" -exec perl --wpe \
"s/_once[ ]*\(['\"]lib\/blogs\/bloglib.php['\"]\)/_once\( BLOGS_PKG_PATH.'blog_lib.php' \)/g" {} \;
?>


4. Updating template references

Follow the new TemplatesPackage resource method.


<?php
// In the *template files*, change as follows. Note addition of QUOTES and removal of tiki- prefix from file name:
OLD WAY: {include file=tiki-directory_bar.tpl}
NEW 
WAY:{include file="tikipackage:directory/directory_bar.tpl"}

// or

OLD WAY: {popup_init src="lib/overlib.js"}
NEW 
WAY:{popup_init src="`$gTikiLoc.THEMES_PKG_URL`overlib.js"}
?>



<?php
// In *PHP files*, the smarty load and assigns should look like
OLD WAY$smarty->assign('mid''tiki-my_tiki.tpl');
NEW 
WAY$smarty->assign('mid''tikipackge:users/my_tiki.tpl');

// or

OLD WAY$smarty->fetch("debug/tiki-debug_console_tab.tpl");
NEW 
WAY$smarty->fetch"tikipackage:debug/debug_console_tab.tpl' );

// An example find command I often run is replacing template include files
// with the package location url prefix and new file name convention:
find . -name "
*tpl" -exec perl -i -wpe \
's/tiki-view_blog.php/\{\$tiki_url\.blogs_url\}view_blog.php/g' {} \;
?>



<?php
// PHP *lib references** should look like:
OLD WAY: include_once ('lib/charts/chartlib.php');
NEW 
WAY: require_once( CHARTS_PKG_PATH.'chart_lib.php' );

// *other PHP references* should look like:
OLD WAY: return "<img border='0' src='img/icn/else.gif' alt='icon' />";
NEW 
WAY: return '<img border="0" src="'.IMG_PKG_URL.'icn/else.gif" alt="icon" />';
?>


5. see also