|
HTML clipboard
|
Changes to template functions
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
| Display the component |
<?php echo mosMainBody();?> |
<jdoc:include type="component" /> |
| Count the number of modules in a position |
<?php if (mosCountModules('left')) : ?> |
<?php if ($this->countModules('left')) : ?> |
<?php if (mosCountModules('left') ||
mosCountModules('right')) : ?> |
<?php if ($this->countModules('left OR right')) : ?> |
| Loading modules in a position |
<?php mosLoadModules('left', 0);?> |
<jdoc:include type="modules" name="left"
style="table"/> |
<?php mosLoadModules('left', -1);?> |
<jdoc:include type="modules" name="left" style="raw"/> |
<?php mosLoadModules('left', -2);?> |
<jdoc:include type="modules" name="left" style="xhtml"/> |
<?php mosLoadModules('left', -3);?> |
<jdoc:include type="modules" name="left"
style="rounded"/> |
| Load a single module |
<?php mosLoadModule('Banners', -1);?> |
<jdoc:include type="module" name="Banners" style="raw"
/> |
<?php mosLoadModule('Latest News', -2);?> |
<jdoc:include type="module" name="Latest News" style="xhtml"
/> |
<?php mosLoadModule('Newsflash', -3);?> |
<jdoc:include type="module" name="Newsflash"
style="rounded" /> |
| Include directives in the HEAD tag |
<?php mosShowHead();?> |
<jdoc:include type="head" /> |
| Displaying the pathway |
<?php mosPathWay();?> |
Include a module position to use the "breadcrumbs" module. |
Changes involving global variables
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
| File system path to the site |
global $mosConfig_absolute_path;
$path = $mosConfig_absolute_path.'/file.php';
|
$path = JPATH_SITE.DS.'file.php';
|
| File system path to adminstrator |
global $mosConfig_absolute_path;
$path = $mosConfig_absolute_path.'/administrator/file.php';
|
$path = JPATH_ADMINISTRATOR.DS.'file.php';
|
| File system path to the current component |
| N/A |
$path = JPATH_COMPONENT.DS.'file.php';
|
| URL to the site |
global $mosConfig_live_site; |
$url = JUri::base(true); |
| The application object |
global $mainframe; |
$app = &JFactory::getApplication(); |
$path = $mainframe->getBasePath(0);
$path = $mainframe->getBasePath('site');
$path = $mainframe->getBasePath('front'); |
$path = JPATH_SITE.DS; |
$path = $mainframe->getBasePath(2);
$path = $mainframe->getBasePath('installation');
|
$path = JPATH_INSTALLATION.DS; |
$path = $mainframe->getBasePath(1);
$path = $mainframe->getBasePath('admin');
$path = $mainframe->getBasePath('administrator'); |
$path = JPATH_ADMINISTRATOR.DS; |
$mainframe->setPageTitle($title); |
$document=& JFactory::getDocument();
$document->setTitle($title);
|
$mainframe->getPageTitle(); |
$document=& JFactory::getDocument();
$title = $document->getTitle();
|
| Accessing configuration file variables |
global $mosConfig_list_limit; |
$app = &JFactory::getApplication();
$limit = $app->getCfg('list_limit');
|
global $mosConfig_offset_user; |
$user = &JFactory::getUser();
$userOffset = $user->getParam('timezone');
|
global $mosConfig_debug;
if ($mosConfig_debug) // ...
|
if (JDEBUG) // ...
// or
$app = &JFactory::getApplication();
if ($app->getCfg('debug')) // ...
|
| Getting the option or component name |
global $option; |
$option = JRequest::getCmd('option'); |
| Getting the current user object |
global $my; |
$user = &JFactory::getUser(); |
| Getting the database object |
global $database; |
$db = &JFactory::getDbo(); |
General API and function changes
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
| Direct access check |
defined('_VALID_MOS') or die; |
defined('_JEXEC') or die; |
| Translating text |
<?php echo _COMMENTS_TITLE;?> |
<?php echo JText::_('Comments_Title');?> |
| Accessing request variables |
$cid = mosGetParam($_REQUEST, 'cid', array()); |
$cid = JRequest::getVar('cid', array()); |
$ints = josGetArrayInts($name, $type); |
$ints = JRequest::getVar($name, array(), 'method', 'array');
JArrayHelper::toInteger($ints);
|
| Parameters |
$params = new mosParameters($ini); |
$params = new JParameter($ini); |
| Getting component parameters |
$comp = new mosComponent($database);
$comp->load($foobar_id);
$params = new mosParameters($comp->params);
|
$params = JComponentHelper::getParams('com_foobar');
|
| Bind data to objects |
mosBindArrayToObject($array, &$obj, $ignore, $prefix,
$checkSlashes); |
// Providing object is derived from JTable
$object->bind($array, $ignore);
|
| Hash a string |
$value = mosHash($seed); |
$value = JUtility::getHash($seed); |
| Bounce an unauthorised user |
mosNotAuth(); |
JError::raiseError('401', JText::_('ALERTNOTAUTH')); |
| Display an error popup |
mosErrorAlert($text, $action, $mode); |
No direct replacement. Recommend raising a notice using
JError::raiseNotice or a warning using JError::raiseWarning and
redirecting the page. |
| Clean a file system path |
mosPathName($p_path, $p_addtrailingslash); |
jimport('joomla.filesystem.path');
$path = JPath::clean($p_path);
// Handle trailing slash manually
|
| Sending mails |
mosMail($from, $fromname, $recipient, $subject, $body,
$mode, $cc, $bcc, $attachment, $replyto, $replytoname )
|
JUtility::sendMail($from, $fromname, $recipient,
$subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname
); |
mosSendAdminMail($adminName, $adminEmail, $email,
$type, $title, $author); |
JUtility::sendAdminMail($adminName, $adminEmail,
$email, $type, $title, $author) |
| Making a password |
$pwd = mosMakePassword(); |
jimport('joomla.user.helper');
$pwd = JUserHelper::genRandomPassword();
|
| Redirecting to a new page |
mosRedirect($url, $msg); |
$app = &JFactory::getApplication();
$app->redirect($url, $msg);
|
| Managing folders |
$result = mosMakePath($base, $path, $mode); |
jimport('joomla.filesystem.folder');
$result = JFolder::create($base.$path, $mode == null ? 0755 : $mode);
|
$result = deldir($path); |
jimport('joomla.filesystem.folder');
$result = JFolder::delete($path);
|
| Converting an array to integers |
mosArrayToInts($array, $default); |
JArrayHelper::toInteger($array, $default); |
| File permissions |
$result = mosChmod($path); |
jimport('joomla.filesystem.path');
$result = JPath::setPermissions($path);
|
$result = mosChmodRecursive($path, $filemode,
$dirmode); |
jimport('joomla.filesystem.path');
$result = JPath::setPermissions($path, $filemode, $dirmode);
|
$result = mosIsChmodable($file); |
jimport('joomla.filesystem.path');
$result = JPath::canChmod($file);
|
| Getting browser information |
$browser = mosGetBrowser($agent); |
jimport('joomla.environment.browser');
$browser = &JBrowser::getInstance();
|
$os = mosGetOS($agent); |
jimport('joomla.environment.browser');
$browser = &JBrowser::getInstance();
$os = $instance->getPlatform();
|
| Displaying an ordering select list |
mosGetOrderingList($sql, $chop) |
JHTML::_('list.genericordering', $sql, $chop) |
| Parsing INI formatted strings |
$params = mosParseParams($txt) |
$registry = new JRegistry();
$registry->loadINI($txt);
$params = $registry->toObject();
// or
$params = new JParameter($txt);
|
| Using Editors |
initEditor(); |
$editor = &JFactory::getEditor();
echo $editor->initialise();
|
getEditorContents($editorArea, $hiddenField); |
jimport('joomla.html.editor');
$editor = &JFactory::getEditor();
echo $editor->save($hiddenField);
|
editorArea($name, $content, $hiddenField, $width,
$height, $col, $row); |
jimport( 'joomla.html.editor' );
$editor = &JFactory::getEditor();
echo $editor->display($hiddenField, $content, $width, $height, $col, $row);
|
| Menu based authorisation |
$allowed = mosMenuCheck($Itemid, $menu_option, $task,
$gid); |
$user =& JFactory::getUser();
$menus =& JSite::getMenu();
$allowed = $menus->authorize($Itemid, $user->get('aid'));
|
| Converting an object to an array |
$array = mosObjectToArray($p_obj, $recurse, $regex); |
$array = JArrayHelper::fromObject($p_obj, $recurse,
$regex); |
| Date functions |
echo mosFormatDate($date, $format, $offset); |
echo JHTML::_('date', $date, $format ? $format :
JText::_('DATE_FORMAT_LC1'), $offset); |
echo mosCurrentDate($format); |
echo JHTML::_('date', 'now', $format ? $format :
JText::_('DATE_FORMAT_LC1')); |
| Preparing an variables for safe output |
mosMakeHtmlSafe($row, $quote_style, $exclude_keys); |
JFilterOutput::objectHTMLSafe($row, $quote_style,
$exclude_keys); |
<?php echo ampReplace($text);?> |
<?php echo JFilterOutput::ampReplace($text);?> |
| Sorting an array of objects |
SortArrayObjects($array, $k, $sort_direction); |
JArrayHelper::sortObjects($array, $k,
$sort_direction); |
| CSRF (spoof) checking |
josSpoofValue($alt); |
Place the following code before the end of your form:
<?php echo JHtml::_('form.token'); ?>
|
josSpoofCheck($header, $alternate); |
JRequest::checkToken() or die(JText::_('Invalid
Token')); |
| Load javascript tooltip support |
loadOverlib(); |
JHTML::_('behavior.tooltip'); |
mosToolTip($tooltip, $title, $width, $image, $text, $href,
$link); |
JHTML::_('tooltip', $tooltip, $title, $image, $text, $href,
$link) |
<?php echo mosWarning($warning, $title);?> |
<?php echo JHTML::tooltip($warning, $title, 'warning.png',
null, null, null);?> |
| Routing URLs |
<?php echo sefRelToAbs($link);?> |
<?php echo JRoute::_($link);?> |
| Traversing tree data |
mosTreeRecurse($id, $indent, $list, $children, $maxlevel,
$level, $type); |
JHTML::_('menu.treerecurse', $id, $indent, $list,
$children, $maxlevel, $level, $type) |
| Functions without direct replacements |
mosBackTrace($message); |
|
mosCreateMail($from, $fromname, $subject, $body); |
|
mosShowSource($filename, $withLineNums); |
|
mosLoadComponent($name); |
Handled by JDocument. |
initGzip();
doGzip(); |
Only ever used at the application level. Doesn't affect
extensions. |
Changes involving the database
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
| Database table classes |
class MyTable extends mosDBTable {
// lots of variables defined
function MyTable(&$db) {
$this->mosDBTable('#__table_name', 'id', $db);
}
}
|
class MyTable extends JTable {
// lots of variables defined
function __construct(&$db) {
parent::__construct('#__table_name', 'id', $db);
}
}
|
| Limits in database queries |
$sql = 'SELECT *'
. ' FROM #__table_name'
. ' LIMIT 10, 20';
$database->setQuery($sql);
|
$db = &JFactory::getDbo();
$db->setQuery(
'SELECT *'
.' FROM #__table_name'
.' LIMIT 10, 20',
10, 20
);
|
| Loading an object from the database |
$db->loadObject($object); |
$object = $db->loadObject(); |
Changes to components
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
| Getting a predefined path |
$mainframe->getPath('admin_html'); |
JApplicationHelper::getPath('admin_html'); |
| Getting component parameters |
$comp = new mosComponent($database);
$comp->load($foobar_id);
$params = new mosParameters($comp->params);
|
$params = JComponentHelper::getParams('com_foobar');
|
Changes to the Administrator menus helper
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
| Display an ordering select list |
mosAdminMenus::Ordering($row, $id)
|
JHTML::_('menu.ordering', $row, $id) |
| Display an access level select list |
mosAdminMenus::Access($row) |
JHTML::_('list.accesslevel', $row) |
| Display a published state select list |
mosAdminMenus::Published($row) |
JHTML::_('select.booleanlist', 'published',
'class="inputbox"', $row->published) |
| Display a multi-select menu list |
mosAdminMenus::MenuLinks($lookup, $all, $none,
$unassigned) |
JHTML::_('select.genericlist', $options,
'selections[]', 'class="inputbox" size="15"
multiple="multiple"', 'value', 'text', $lookup, 'selections' ) |
| Display a category select list |
mosAdminMenus::Category($menu, $id, $javascript) |
No direct replacement |
| Display a section select list |
mosAdminMenus::Section($menu, $id, $all) |
No direct replacement |
| Display a component select list |
mosAdminMenus::Component($menu, $id) |
No direct replacement |
| Get the name of a component |
mosAdminMenus::ComponentName($menu, $id) |
No direct replacement |
| Display a select list of images |
mosAdminMenus::Images($name, $active, $javascript,
$directory) |
JHTML::_('list.images', $name, $active, $javascript,
$directory) |
| Display a select list of ordering values |
mosAdminMenus::SpecificOrdering($row, $id, $query, $neworder) |
JHTML::_('list.specificordering', $row, $id, $query, $neworder) |
| Display a select list of users |
mosAdminMenus::UserSelect( $name, $active, $nouser, $javascript,
$order, $reg) |
JHTML::_('list.users', $name, $active, $nouser, $javascript,
$order, $reg); |
| Display a select list of alignment positions |
mosAdminMenus::Positions($name, $active, $javascript,
$none, $center, $left, $right, $id) |
JHTML::_('list.positions', $name, $active, $javascript,
$none, $center, $left, $right, $id) |
| Display a select list of component categories |
mosAdminMenus::ComponentCategory($name, $section,
$active, $javascript, $order, $size, $sel_cat) |
JHTML::_('list.category', $name, $section, $active,
$javascript, $order, $size, $sel_cat) |
| Display a select list of sections |
mosAdminMenus::SelectSection($name, $active,
$javascript, $order) |
JHTML::_('list.section', $name, $active, $javascript,
$order) |
| Display a select list of menu items of a given
type |
mosAdminMenus::Links2Menu($type, $and) |
No direct replacement |
| Display a select list of menu items |
mosAdminMenus::MenuSelect($name, $javascript) |
No direct replacement |
| Return a named array (by folder) of images in
folders |
mosAdminMenus::ReadImages($imagePath, $folderPath,
$folders, $images) |
No direct replacement |
| Display a special select list of image folders |
mosAdminMenus::GetImageFolders($folders, $path) |
No direct replacement |
| Display a special select list of images with
preview behaviours |
mosAdminMenus::GetImages($images, $path) |
No direct replacement |
| Display a special select list of images with
preview behaviours |
mosAdminMenus::GetSavedImages($row, $path) |
No direct replacement |
| Display a frontend image checking for a
template override |
mosAdminMenus::ImageCheck($file, $directory, $param,
$param_directory=, $alt, $name, $type, $align) |
JHTML::_('image.site', $file, $directory, $param,
$param_directory, $alt, array('align' => $align), $type) |
| Display a backend image checking for a template
override |
mosAdminMenus::ImageCheckAdmin($file, $directory,
$param, $param_directory, $alt, $name, $type, $align) |
JHTML::_('image.administrator', $file, $directory,
$param, $param_directory, $alt, array('align' => $align), $type) |
| Deprecated method |
mosAdminMenus::menutypes() |
No longer used |
| Deprecated method |
mosAdminMenus::menuItem($item) |
No longer used |
Changes to the cache API
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
| Get the cache for a group |
$cache = mosCache::getCache($group); |
return JFactory::getCache($group); |
| Clean the cache for a group |
mosCache::cleanCache($group) |
$cache =& JFactory::getCache($group);
$cache->clean($group);
|
Changes to miscellaneous classes
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
class MyClass extends mosAbstractTasker |
class MyController extends JController |
$object = new mosEmpty; |
$object = new JObject; |
MENU_Default::MENU_Default(); |
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::addNew();
JToolBarHelper::editList();
JToolBarHelper::deleteList();
JToolBarHelper::spacer();
|
$tabs = new mosTabs($useCookies); |
$pane = new JPaneTabs(array('useCookies' => $useCookies)); |
Changes to HTML helper classes
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
mosCommonHTML::ContentLegend() |
No direct replacement. |
mosCommonHTML::menuLinksContent($menus) |
No direct replacement. |
mosCommonHTML::menuLinksSecCat($menus) |
No direct replacement. |
| Display a checkbox or checkout icon |
mosCommonHTML::checkedOut($row, $overlib) |
jimport('joomla.html.html.grid');
echo JHTML::_('grid.checkedOut',$row, $overlib);
|
mosCommonHTML::CheckedOutProcessing($row, $i) |
jimport('joomla.html.html.grid');
echo JHTML::_('grid.checkedout', $row, $i);
|
| Load javascript tooltip support |
mosCommonHTML::loadOverlib(); |
JHTML::_('behavior.tooltip'); |
| Load javascript calendar support |
mosCommonHTML::loadCalendar(); |
JHTML::_('behavior.calendar'); |
| Display a link that cycles through the access
levels |
mosCommonHTML::AccessProcessing($row, $i, $archived) |
JHTML::_('grid.access', $row, $i, $archived); |
| Display a published state icon |
mosCommonHTML::PublishedProcessing($row, $i, $imgY,
$imgX) |
JHTML::_('grid.published',$row, $i, $imgY, $imgX) |
| Display a published state icon with toggle |
mosCommonHTML::selectState($filter_state, $published,
$unpublished, $archived) |
JHTML::_('grid.state', $filter_state, $published,
$unpublished, $archived) |
| Display a save order button |
mosCommonHTML::saveorderButton($rows, $image); |
echo JHTML::_('grid.order', $rows, $image) |
| Display the ordering icon in a column heading |
mosCommonHTML::tableOrdering($text, $ordering, $lists,
$task); |
echo JHTML::_('grid.sort', $text, $ordering,
@$lists['order_Dir'], @$lists['order'], $task); |
| Display a back button |
<?php mosHTML::BackButton ($params, $hide_js);?> |
No direct replacement. |
| Clean and prepare text for output |
<?php echo mosHTML::cleanText ($text);?> |
<?php echo JFilterOutput::cleanText($text);?> |
| Displaying a print button |
<?php mosHTML::PrintIcon($row, &$params, $hide_js,
$link, $status);?> |
No direct replacement. |
| Cloak an email |
<?php echo mosHTML::emailCloaking($mail, $mailto,
$text, $email);?> |
<?php echo JHTML::_('email.cloak', $mail, $mailto,
$text, $email);?> |
| Load support to keep the page alive (avoiding
session time-outs) |
<?php mosHTML::keepAlive();?> |
<?php echo JHTML::_('behavior.keepalive');?> |
Working with the menubar and toolbars
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
mosMenuBar::startTable();
mosToolbar::startTable();
|
No longer used. |
mosMenuBar::endTable();
mosToolbar::endTable();
|
No longer used. |
mosMenuBar::addNew();
mosMenuBar::addNewX();
|
JToolbarHelper::addNew('new', 'New'); |
mosMenuBar::saveedit(); |
JToolbarHelper::save('saveedit'); |
mosToolbar |
JToolbarHelper |
Changes to the core database table classes
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
mosCategory |
JTableCategory |
mosContent |
JTableContent |
mosComponent |
JTableComponent |
mosMambot |
JTablePlugin |
mosMambotHandler |
JDispatcher |
mosMenu |
JTableMenu |
mosModule |
JTableModule |
mosSection |
JTableSection |
mosSession |
JTableSession |
mosUser |
JTableUser |
| Updating the order of items |
$result = $row->updateOrder($where); |
$result = $row->reorder($where); |
| Publishing a list of items |
$result = $row->publish_array($cid, $publish, $user_id) |
$result = $row->publish($cid, $publish, $user_id); |
Working with plugins
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
mosMambotHandler::loadBotGroup($group); |
JPluginHelper::importPlugin($group, null, false); |
mosMambotHandler::loadBot($folder, $element,
$published, $params); |
JPluginHelper::importPlugin($folder, $element); |
mosMambotHandler::registerFunction( $event, $function
) |
JApplication::registerEvent( $event, $function ); |
mosMambotHandler::call($event); |
$dispatcher =& JDispatcher::getInstance();
$result = $dispatcher->trigger($event, $arguments);
|
| |
|
File formats
| Usage in Joomla 1.0 |
Usage in Joomla 1.5 |
| Translation files |
/language/english.php |
/language/en-GB/en-GB.ini
/language/en-GB/en-GB.com_content.ini
/language/en-GB/en-GB.mod_latest_news.ini
/language/en-GB/en-GB.plg_content_code.ini |
<?php
// Files saved as PHP files
define('_COMMENTS_TITLE', 'Title');
define('_COMMENTS_GUEST_TO_POST', 'Allow guests to post');
|
# Files must be saved as UTF-8 in INI format
COMMENTS_TITLE=Title
COMMENTS_GUEST_TO_POST=Allow guests to post
|
| |
|
|
| Last Updated on Saturday, 08 August 2009 08:33
|
|