[development] how to watch for modules/themes being enabled
Gabor Hojtsy
gabor at hojtsy.hu
Wed Dec 27 22:33:19 UTC 2006
Hi,
I am in the process of implementing autolocale module, as you might
already know (by reading the development list). This module now nicely
imports PO files in install time and can import PO files later for all
enabled components (modules/themes) with an optional database cleanup.
The next (and for basic operation the last) step is to automatically
import PO files for modules/themes enabled on the admin interface. I have
tried to look into Drupal HEAD source to quickly solve this issue, but
there was no immediate help. The drupal_install_modules() function seemed
to be an inviting place, since it knows what modules are being installed
the first time. Also drupal_enable() is called for modules previously
disabled but being enabled again. None of these "call out" with a hook to
inform possible evesdropping modules that a new module is installed or a
previously disabled module is being enabled again. My autolocale would
however would love to get informed.
I also looked into themes, and found that the logic enabling themes is
in system_themes_submit(). Interesting fact that the block initialization
is wired in, because block module cannot watch for a theme being enabled
(lines 1198-1201): "If theme status is being set to 1 from 0, initialize
block data for this theme if necessary."
After all it seems that my only option is to look for the module/theme
list form appearing on the admin screen and alter the form to hook my
module to the submit action. When the form is submitted, do the same
checks the system.module does to identify installed/enabled/disabled
modules/themes, so I know what autolocale should do.
Maybe it is not too late to stuff a few module_invoke_all() calls to the
proper places so module/theme changes are advertised for modules to watch
for. If it is too late, I would be very interested if others faced the
same problem and how did they solved it.
Gabor
More information about the development
mailing list