From 082f21d3e6e17026eb89613ae448a7db645a6f89 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 19 May 2009 13:34:27 +0000 Subject: [PATCH] "fixed search for new phrases, to also work with newer method hooks and not only with file-hooks (preferences, admin, settings, ...)" --- etemplate/inc/class.solangfile.inc.php | 43 ++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/etemplate/inc/class.solangfile.inc.php b/etemplate/inc/class.solangfile.inc.php index d67f59bbdb..a12bd2967c 100644 --- a/etemplate/inc/class.solangfile.inc.php +++ b/etemplate/inc/class.solangfile.inc.php @@ -87,6 +87,7 @@ class solangfile function special_file($app,$fname,$langs_in) { //echo "

solangfile::special_file(app='$app',fname='$fname',langs_in='$langs_in')

\n"; + $app_in = $app; switch ($langs_in) { case 'config': @@ -104,7 +105,34 @@ class solangfile unset($GLOBALS['acl_manager']); ob_start(); // suppress all output - include($fname); + // call the hooks and not the files direct, as it works for both files and method hooks + switch(basename($fname)) + { + case 'hook_settings.inc.php': + $settings = $GLOBALS['egw']->hooks->single('settings',$app_in,true); + if (!is_array($settings) || !$settings) + { + $settings =& $GLOBALS['settings']; // old method of setting GLOBALS[settings], instead returning the settings + unset($GLOBALS['settings']); + } + break; + + case 'hook_admin.inc.php': + $GLOBALS['egw']->hooks->single('admin',$app_in,true); + break; + + case 'hook_preferences.inc.php': + $GLOBALS['egw']->hooks->single('preferences',$app_in,true); + break; + + case 'hook_acl_manager.inc.php': + $GLOBALS['egw']->hooks->single('acl_manager',$app_in,true); + break; + + default: + include($fname); + break; + } ob_end_clean(); if (isset($GLOBALS['acl_manager'])) // hook_acl_manager @@ -138,7 +166,7 @@ class solangfile $this->plist[$lang] = $app; } } - foreach($GLOBALS['settings'] as $data) + foreach((array)$settings as $data) { foreach(array('label','help') as $key) { @@ -163,6 +191,17 @@ class solangfile { $this->parse_php_app($app,$fd.$fn.SEP); } + if ($fn == 'inc') + { + // make sure all hooks get called, even if they dont exist as hooks + foreach($this->files as $f => $type) + { + if (substr($f,0,5) == 'hook_' && !file_exists($f = $fd.'inc/'.$f)) + { + $this->special_file($app,$f,$this->files[$type]); + } + } + } } elseif (is_readable($fd.$fn)) {