Sunday, May 30, 2010

Openbiz Cubi Menu

Cubi Menu is the core component that manages the application navigation.

Normally, a web application (or web site) hand code several navigation elements, such as menus, tabs, breadcrumb and so on. This was the way used in previous Openbiz application - manually add left menu items on each view or template.

Let's talk how the new menu system works in Openbiz Cubi.
1. Definition of menu
  • Menu is a tree structure
  • Each menu item include navigation attributes like name, title, url, icon...
2. Menu presentation on web page
Menu is tree structure. It can be presented as application tab, breadcrumb, navigation menu, sitemap on a web page.


The diagram below shows how the menu tree maps to UI elements.


3. How to add menu in your own module
Each module can add entries in Cubi menu. In module/mod.xml, there is a Menu section to add MenuItem. The key to append module menu to system menu is
  • In the top MenuItem element, set Parent="existing_menuitem". It will append this menu as a child of specified menuitem
  • Or leave the Parent="". It will tell this menu as a root first level menu item.



4. How to manage menu in the Cubi application
Once a module is loaded in the system, its menu is inserted as well. Then you can see the menu items appear on proper place like navigation menu or application tab.

If you are admin, you can manage menu items in "Menu Management" views. This will be cover in separate topic.

Sunday, May 23, 2010

Cubi module enhancement

The goal of Cubi module is to allow developers to write their own components and plug in to Cubi application. So each module should have its own
  • module description information
  • database tables and preload data
  • menu definition. menu tells users where to access the module functionality
  • depend-on modules who need to be installed before this module
Let's see how cubi enhance its module management. The mod.xml is the main description file. It schema has 3 major part:
  1. ACL
  2. Menu
  3. Dependency
Sample mod.xml can be found in cubi/modules/help/mod.xml

Developer can add the module specific sql in
  • mod.install.sql and
  • mod.uninstall.sql
Cubi provides a command line tool to load module. The command is cubi/install/load_module.php
# php load_module.php module_name

To help prepare fresh cubi installation data, developer can use script at cubi/install/create_cubidb.php
# php create_cubidb.php
This script create a fresh database called "cubi_install". You can dump the database to cubi/install/cubi.sql. This database will be used in installation wizard.

Monday, May 17, 2010

Cubi cronjob manager

Every week Openbiz makes progress on feature implementation and bug fixes. I should have worked more harder to record them in the blog.

Cronjob manager is added in Cubi. What cronjob manager does?
  • Provide a backend management UI to allow administrator to add/edit/delete command in cronjob format
  • A job manager script that reads and parses the jobs in the cronjob list, then execute them.
A cronjob defined in Cubi can have following attributes.
  • name
  • minute, hour, day, month, weekday. Unix cronjob format is used. Note: */N format is not supported.
  • command. This is the command to run in this job.
  • sendmail. This field includes the emails to be sent after completing executing the job.
  • max_run. max_run tells how many concurrent execution of this job. By default max_run=1. It means only single job can run as the same time. If max_run=0, then no limit of the concurrent job execution.
  • description
To start cronjob manager, add "cubi/bin/cronjob/cron.php" in system crontab.

cronjob log files are outputted to cubi/log. Each job will have its own log.

Cubi provides a helper command called run_svc.php that can invoke service with following format.
usage: php run_svc.php service_name method parameter1 parameter2 ...

Cronjob manager can add this command to the job list.