Items that need to be converted...
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')
Horde_Auth::getCredential() -> $registry->getAuthCredential()
Horde_Auth::isAdmin() -> $registry->isAdmin()
Horde_Auth::addHook($user) -> $registry->convertUsername($user, true)
Horde_Auth::removeHook($user) -> $registry->convertUsername($user, false)
Convert files/libraries to be able to be autoloaded.
Remove require/include calls within the code.
All (framework) classes must be prefixed with Horde_ to allow autoloading of the files. When converting from Horde 3 format (e.g. Foo class) to Horde 4 format (e.g. Horde_Foo), the following commands are useful to convert all files automatically:
find . -type f \( ! -wholename "./.git/*" ! -name "CHANGES" \) | xargs grep -l '[] (!)]Foo::' | xargs sed -i -r -e 's/([\ \(\^\!\)])Foo::/\1Horde_Foo::/g' find . -type f \( ! -wholename "./.git/*" ! -name "CHANGES" \) | xargs grep -l '&Foo::' | xargs sed -i -r -e 's/&Foo::/Horde_Foo::/g' find . -type f \( ! -wholename "./.git/*" ! -name "CHANGES" \) | xargs grep -l '^Foo::' | xargs sed -i -r -e 's/^Foo::/Horde_Foo::/g'
Use Horde_Registry::appInit(), with the 'cli' option, to initialize CLI scripts.
Add $Id$ tag to all conf/*.xml files
No more lib/base.php, lib/api.php, lib/version.php. Converted to lib/Application.php and lib/Api.php
TODO
instanceof instead of is_a()
No need for $Horde$ in header comments.
Remove CVS directories.
Remove .cvsignore
Constants should be namespaced - preferably within the utility class (e.g. lib/App.php).
Update documentation.
All database abstraction is done through the Horde_Db library now. SQL scripts from scripts/sql/ need to be converted to Horde_Db migrations in migration/.
Cheat sheet for converting PEAR::DB calls to Horde_Db calls:
PEAR DB | Horde_Db |
---|---|
select()/query() | execute()/insert()/update()/delete() |
getAll() (w/DB_FETCHMODE_ORDERED) | ?? |
getAll() (w/DB_FETCHMODE_ASSOC) | selectAll() |
getAssoc() | selectAssoc() (only with 2 columns) |
getCol() | selectValues() |
getOne() | selectValue() |
getRow() | selectOne() |
setLimit() | addLimitOffset() |
select() return a statement object from the SQL query.
Don't use Horde::fatal() directly - throw an Exception and if uncaught, a fatal exception handler will be triggered.
Remove all use of globals within the application (use injector instead).
Most applications should no longer need a custom header template. Instead use:
require $registry->get('templates', 'horde') . '/common-header.inc';
Hooks are methods of an App_Hooks class in config/hook.php.dist now. They are called different too:
try { Horde::callHook('hookname', array($arg1, $arg2, ...), 'applicationname'); } catch (Horde_Exception_HookNotSet $e) { }
If the hook is supposed to be called often, it should be checked if the code exists with Horde::hookExists() instead of catching the Horde_Exception_HookNotSet exception.
OLD:
$registry->getImageDir() . '/image.png';
NEW:
Horde_Themes::img('image.png');
Horde_Themes::img('image.png'), array('nohorde' => true));
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.
Controller scripts are now initialized by:
require_once dirname(__FILE__) . '/lib/Application.php'; Horde_Registry::appInit('appname');
Various Horde libraries now must be loaded via the injector.
ALL javascript should be in js/. NO javscript (if at all possible) should be contained in scripts/templates.
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:
Horde::logMessage("Something broke", __FILE__, __LINE__, PEAR_LOG_ERR);
NEW:
Horde::logMessage("Something broke", 'ERR');
PEAR's Mail library has been replaced by Horde_Mail.
The menu should be provided now by Appname_Application::menu(). templates/menu.inc can be removed, unless there are any custom elements. To render the menu use:
echo Horde::menu(); $notification->notify(array('listeners' => 'status'));
The MIME library has been rewritten - most calls to the library will probably need to be changed.
Most/all language and/or charset handling has been moved to Horde_Registry. See http://bugs.horde.org/ticket/9124#c8.
Convert from Util::bufferOutput() -> Horde::startBuffer()/Horde::endBuffer()
Remove PEAR_Error usage - convert to Exceptions.
Each application should define a APP_Exception library that extends Horde_Exception.
No more lib/prefs.php - now uses Horde_Registry_Application calls.
Update config/prefs.php to remove unneeded entries.
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:
if (!Horde_Util::getFormData('ajaxui')) require HORDE_BASE . '/services/sidebar.php';
No longer uses test.php - converted to lib/Test.php.
TODO
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.
Horde_Ui_* classes are now Horde_Core_Ui_*
Use Horde::url() instead of Horde::applicationUrl().
Use Horde_Url:: instead of Horde_Util::addParameter()/Horde_Util::removeParameter().