Inicio arrow Recursos Técnicos arrow Convirtiendo viejas extensiones a Joomla! 1.5
miércoles, 10 de marzo de 2010
 
 
Convirtiendo viejas extensiones a Joomla! 1.5 PDF Imprimir E-Mail

El final del ciclo de vida de Joomla! 1.0 ocurrirá el 22 de Julio de 2009. Joomla! 1.5 proporciona una capa de legado que permite que muchas extensiones de Joomla! 1.0 corran en Joomla! 1.5. Con fin del ciclo de vida es tiempo que los desarrolladores de Joomla! actualicen sus antiguas extensiones. Las siguientes tablas resumen muchos de los cambios en el API
en el formato “antigua forma” versus “nueva forma”

La mejor manera de convertir sus extensiones para que funcionen nativamente con Joomla 1.5 es desactivar el modo de herencia (legacy mode) y observar
los errores que da. Use las tablas para observar las funciones o clases desaparecidas y haga los apropiados cambios. También puedes aprovechar y leer detenidamente nuestro Modo de Herencia (Legacy Mode), si lo encuentras interesante.

Tome en cuenta que estas tablas solo deben ser utilizadas para ayudarlo en el proceso de conversión de sus extensiones para que corran nativamente en Joomla! 1.5. En algunos casos hay mejores formas de hacer las cosas, o puede buscar en las posibilidades que le ofrece Joomla 1.5 vías para solucionar lo que se solucionaba al modo de Joomla 1.0. Para encontrar estas vías de desarrollo al "Estilo Joomla" en Joomla 1.5, yo le aconsejo suscribirte al Art of Joomla Developer Reference.

Cambios de funciones en la plantilla
Usado en Joomla 1.0 Usado en Joomla 1.5
Mostrar el componente
<?php echo mosMainBody();?>
<jdoc:include type="component" />
 Contar el número de módulos en una posición
<?php if (mosCountModules('left')) : ?>

<?php if ($this->countModules('left')) : ?>

<?php if (mosCountModules('left') || mosCountModules('right')) : ?>

<?php if ($this->countModules('left OR right')) : ?>

Cargando los módulos en una posición
<?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"/>
Cargar un único módulo
<?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" />
Incluir directrices en el tag del HEAD
<?php mosShowHead();?>
<jdoc:include type="head" />
Mostrando el pathway
<?php mosPathWay();?>
Incluir un módulo de posición para usar el módulo "breadcrumbs".

 

Cambios que impliquen variables globales
Usado en Joomla 1.0 Usado en Joomla 1.5
Ruta de acceso al sistema de archivos del sitio
global $mosConfig_abosolute_path;
$path = $mosConfig_abosolute_path.'/file.php';
 
$path = JPATH_SITE.DS.'file.php';
Ruta de acceso al sistema del adminstrador 
global $mosConfig_abosolute_path;
$path = $mosConfig_abosolute_path.'/administrator/file.php';
$path = JPATH_ADMINISTRATOR.DS.'file.php';
Ruta de acceso al sistema de archivos del actual componente
N/A
$path = JPATH_COMPONENT.DS.'file.php';
URL del sitio
global $mosConfig_live_site;
$url = JUri::base(true);
Objecto de la aplicación
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();
Acceso al archivo de las variables de configuración  
global $mosConfig_list_limit;
$app = &JFactory::getApplication();
$limit = $app->getCfg('list_limit');

global $mosConfig_offset_user;

$user = &JFactory::getUser();
$userOffset = $user->getParam('timezone');
Obteniendo el nombre de opción o de componente 
global $option;
$option = JRequest::getCmd('option');
Obteniendo el objeto de usuario actual
global $my;
$user = &JFactory::getUser();
Obteniendo el objeto de la base de datos
global $database;
$db = &JFactory::getDbo();

 

General de la API y cambios en las funciones
Usado en Joomla 1.0 Usado en 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 pre 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
Usado en Joomla 1.0 Usado en 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
Usado en Joomla 1.0 Usado en 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
Usado en Joomla 1.0 Usado en 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
Usado en Joomla 1.0 Usado en 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
Usado en Joomla 1.0 Usado en 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
Usado en Joomla 1.0 Usado en 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
Usado en Joomla 1.0 Usado en 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
Usado en Joomla 1.0 Usado en 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);

 

Trabajando con plugins
Usado en Joomla 1.0 Usado en 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);

 

Formatos de los archivos
Usado en Joomla 1.0 Usado en Joomla 1.5
Traducción de archivos
/language/spanish.php
/language/es-ES/es-ES.php
/language/es-ES/en-GB.com_content.php
/language/es-ES/en-GB.mod_latest_news.php
/language/es-ES/en-GB.plg_content_pre.php
<?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

 Texto original: "Converting Old Extensions to Joomla 1.5 ", por Andrew Eddie - Joomla master developer.
 Traducido por: Equipo de Traducción y Documentación de Joomla! Spanish.(Colaboración especial: Leonel Icanton y Antonio Peñalver)

 
< Anterior   Siguiente >

Foros Joomla! Spanish

  • Templates no se cargan y extensiones no se instalan
    Saludos gente de Joomla Spanish antes que nada gracias por este espacio tan productivo. La razón de mi mensaje es que tengo instalado en windows 7...
  • ¿Como y Donde añadir un class?
    Hola a todos, veras estoy diseñando una web con joomla 1.5 y trabajando el modulo de virtuemart, bien la duda que tengo si es posible añadir un class...
  • Docman
    Saludos! He instalado en mi web docman y todo va bien. El problema es que cuando un usuario quiere colgar un articulo la pagina se queda bloqueada y...
  • Colocar un módulo en la zona central
    Hola: Hace poco he empezado a hacer una web. Tengo que avisar que mis conocimientos en programación son escasos (aprendo según trasteo), así que no...
  • Template bt_ingeno
    Hola amigos. instalé este Template en mi web pero el header esta vacio, y cuando entro en la carpeta images no hay nada ni ningun archivo que me...