|
Joomla! 1.0 component tutorial - part 2: back-end |
|
Page 4 of 4
8. Backend - toolbarsToolbar is defined with help of two files:
- toolbar.jportfsimple.php
- toolbar.jportfsimple.html.php
toolbar.jportfsimple.php // no direct access defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); require_once( $mainframe->getPath( 'toolbar_html' ) ); $task = mosGetParam( $_REQUEST, 'task', '' ); $act = mosGetParam( $_REQUEST, 'act', '' ); switch ( $task ) { case 'edit': case 'new': menujportfsimple::EDIT_MENU(); break; default: switch($act) { case "configure": case "css": menujportfsimple::CONFIGURE_MENU(); break; case "info": menujportfsimple::INFO_MENU(); break; case "categories": case "projects": menujportfsimple::DEFAULT_MENU(); break; default: break; } break; }
Depending on $act and $task it calls certain menu function from menujportfsimple class, which displays the right toolbar. toolbar.jportfsimple.html.php // no direct access defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); class menujportfsimple{ function DEFAULT_MENU() { mosMenuBar::startTable(); mosMenuBar::publish('publish'); mosMenuBar::unpublish('unpublish'); mosMenuBar::divider(); mosMenuBar::addNew('new'); mosMenuBar::editList('edit', 'Edit'); mosMenuBar::deleteList( ' ', 'delete', 'Remove' ); mosMenuBar::divider(); mosMenuBar::endTable(); } function EDIT_MENU() { mosMenuBar::startTable(); mosMenuBar::cancel(); mosMenuBar::save('save'); mosMenuBar::endTable(); } function CONFIGURE_MENU() { mosMenuBar::startTable(); mosMenuBar::save('save'); mosMenuBar::endTable(); } function INFO_MENU() { mosMenuBar::startTable(); mosMenuBar::endTable(); } }
Each _MENU function uses startTable and endTable from mosMenuBar class at the beginning and at the end of a toolbar. Then it defines actual buttons using functions like: addNew, editList or save.
9. Backend - install, uninstallLast two files contain functions which are run after installing or uninstalling a component.
- install.jportfsimple.php
- uninstall.jportfsimple.php
Both are almost identical, only the function name inside is different, and the constant used to display information.
install.jportfsimple.php // no direct access defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); function com_install() { global $mosConfig_live_site, $mosConfig_absolute_path, $mosConfig_lang; if (file_exists( $mosConfig_absolute_path. "/components/com_jportfsimple/lang/". $mosConfig_lang. ".php")) include_once( $mosConfig_absolute_path."/components/com_jportfsimple/lang/". $mosConfig_lang.".php"); else if (file_exists( $mosConfig_absolute_path. "/components/com_jportfsimple/lang/english.php")) include_once( $mosConfig_absolute_path."/components/com_jportfsimple/lang/english.php"); echo _COM_JP_INFO_BOTTOM; }
10. SummaryIn the above tutorial I tried to explain the structure and functions of sample component written for Joomla! CMS v. 1.0.12.
<< Start < Prev 1 2 3 4 Next > End >> |