From: Andreas A. <a.a...@th...> - 2001-08-12 11:27:42
|
Hi James, > Now I would like to better understand how R2 uses metabase and thus > understand how I can use it. How I currently deal with it: [1] I have libs that are dealing with the database interfacing. e.g. a manager class for managing resources (doing queries, file operations). This class imports metabase stuff at the very beginning. e.g.: r2/binarycloud/user/lib/MgrResources.php: // {{{ import('user.lib.Exception'); import('user.conf.datasources'); import('ext.metabase.metabase_database'); import('ext.metabase.metabase_interface'); import('ext.metabase.metabase_mcrypt'); class MgrResources { function MgrResources() { MetabaseSetup etc like described in docs } function Lister() {} function ListById() {} function Add() {} function Set() {} ... }; // }}} [2] I wrote a module package for managing resources: r2/binarycloud/user/mod/manage_resources/ consisting of 4 atomic modules ListResources, DeleteResource, AddResource, EditResource. Those modules are importing my manager in the constructor and using smarty to generate the html output. e.g. (simplified for better illustration) // {{{ class ListResources { var $mgr; //my manager var $tpl; // my template function ListResources($_params) { import('user.lib.MgrResources'); import('user.lib.Template'); // includes ext.smarty.stuff // doing other stuff, switch(action) or something else // aggregation $this->mgr =& new MgrResources(); $this->tpl =& new Template(); $this->tpl->SetPath(BC_PATH_MOD.'manage_resources/html'); $result =& $this->mgr->Lister(); $this->tpl->assign('RESULT', $result); return true; } function Output() { $this->tpl->display('list.xhtml'); return true; } }; // }}} And that works very good. No, wait: most excellent :-) Andi |