6.0.0-git
2024-04-27

Diff for Doc/Dev/ConversionH4 between 14 and 15

[[toc]]

+ H4 Conversion !HowTo

Items that need to be converted...

++ Authentication

Remove AUTH_HANDLER - use Horde_Registry::appInit() 'authentication' option instead.
Remove $session_control - use Horde_Registry::appInit() 'session_control' option instead
Most static Horde_Auth:: functions moved to Horde_Registry::

> Horde_Auth::getAuth() -> $registry->getAuth()
> Horde_Auth::getBareAuth() -> $registry->getAuth('bare')
> Horde_Auth::getAuthDomain() -> $registry->getAuth('domain')
> Horde_Auth::getOriginalAuth() -> $registry->getAuth('original')

++ Autoloading

Convert files/libraries to be able to be autoloaded.
Remove require/include calls within the code.

++ CLI

Use Horde_Registry::appInit(), with the 'cli' option, to initialize CLI scripts.

++ Configuration files

Add $Id$ tag to all conf/*.php.dist and conf/*.xml files

++ Convert Base files

No more lib/base.php, lib/api.php, lib/version.php.  Converted to lib/Application.php and lib/Api.php

++ Convert to PHP 5

TODO
instanceof instead of is_a()

++ CVS remnants

No need for $Horde$ in header comments.
Remove CVS directories.
Remove .cvsignore

++ Constants

Constants should be namespaced - preferably within the utility class (e.g. lib/App.php).

++ Documentation

Update documentation.

++ Database

All database abstraction is done through the Horde_Db library now.

Cheat sheet for converting PEAR::DB calls to Horde_Db calls:

||~ PEAR DB                          ||~ Horde_Db                            ||
|| select()                          ||select()/query()                  || execute()/insert()/update()/delete() ||
|| getAll() (w/DB_FETCHMODE_ORDERED) || ??                                   ||
|| getAll() (w/DB_FETCHMODE_ASSOC)   || selectAll()                          ||
|| getAssoc()                        || selectAssoc()                        ||
|| getCol()                          || selectValues()                       ||
|| getOne()                          || selectValue()                        ||
|| getRow()                          || selectOne()                          ||

select() return a statement object from the SQL query.

++ Error Handling

Don't use Horde::fatal() directly - throw an Exception and if uncaught, a fatal exception handler will be triggered.

++ Globals

Remove all use of globals within the application (use injector instead).

++ Images/Graphics

OLD:
<code>
$registry->getImageDir() . '/image.png';
</code>

NEW:
<code>
Horde_Themes::img('image.png');
</code>
Note that if you want to prevent using images from Horde itself and always use the current application, use the following:

<code>
Horde_Themes::img('image.png'), array('nohorde' => true));
</code>

Also note this policy change from H3:
"Do note that doing something like grabbing an image dir and then manually appending various image names to it is NOT supported in H4."

Generating <img> tags of non-static images, e.g. the script files from horde/services/images/ through Horde::img() is not supported anymore.

++ Injector Usage

Various Horde libraries now must be loaded via the injector.

++ Javascript

ALL javascript should be in js/.  NO javscript (if at all possible) should be contained in scripts/templates.

++ Log handling

Log constants have changed: we no longer use the PEAR constants and instead use strings to indicate the severity.
Also note the function signature no longer requires the file name or line number.

OLD:
<code>
Horde::logMessage("Something broke", __FILE__, __LINE__, PEAR_LOG_ERR);
</code>

NEW:
<code>
Horde::logMessage("Something broke", 'ERR');
</code>

++ Mail library

PEAR's Mail library has been replaced by Horde_Mail.

++ MIME library

The MIME library has been rewritten - most calls to the library will probably need to be changed.

++ NLS/Language/Charset handling

Most/all language and/or charset handling has been moved to Horde_Registry.  See http://bugs.horde.org/ticket/9124#c8.

++ Output buffering

Convert from Util::bufferOutput() -> Horde::startBuffer()

++ PEAR_Error

Remove PEAR_Error usage - convert to Exceptions.
Each application should define a APP_Exception library that extends Horde_Exception.

++ Prefs UI

No more lib/prefs.php - now uses Horde_Registry_Application calls.
Update config/prefs.php.dist to remove unneeded entries.

++ Sidebar integration

The sidebar menu is no longer in a separate frame. To integrate with all pages of your application, put the following code after your menu, e.g. at the bottom of templates/menu.inc, but before the notification output:
<code type="php">
if (!Horde_Util::getFormData('ajaxui')) require HORDE_BASE . '/services/portal/sidebar.php';
</code>

++ Test script

No longer uses test.php - converted to lib/Test.php.

++ Themes

TODO

++ Translations

All translations and help files have to be encoded in UTF-8 now. Translation files have been renamed and moved to the locale/ directories. imp/po/de_DE.po is now in imp/locale/de/LC_MESSAGES/imp.po.

++ Url generation

Use Horde_Url:: instead of Horde_Util::addParameter()/Horde_Util::removeParameter().