Commit 968ea5cc by Scott Vivian

Rename qa_list_all_registered_modules_info() to qa_list_modules_info()

parent 39b13f70
...@@ -491,9 +491,8 @@ ...@@ -491,9 +491,8 @@
foreach ($modules as $module) { foreach ($modules as $module) {
$value = $module->option_default($name); $value = $module->option_default($name);
if (strlen($value)) { if (strlen($value))
return $value; return $value;
}
} }
$value=''; $value='';
......
...@@ -612,53 +612,41 @@ ...@@ -612,53 +612,41 @@
// Functions for listing, loading and getting info on modules // Functions for listing, loading and getting info on modules
function qa_list_all_registered_modules_info() function qa_list_modules_info()
/* /*
Return an array with all registered modules' information Return an array with all registered modules' information
*/ */
{ {
global $qa_modules; global $qa_modules;
return $qa_modules; return $qa_modules;
} }
function qa_list_module_types()
/*
Return an array of all the module types for which at least one module has been registered
*/
{
return array_keys(qa_list_all_registered_modules_info());
}
function qa_list_module_types() function qa_list_module_types()
/* /*
Return an array of all the module types for which at least one module has been registered Return an array of all the module types for which at least one module has been registered
*/ */
{ {
return array_keys(qa_list_all_registered_modules_info()); return array_keys(qa_list_modules_info());
} }
function qa_list_modules($type) function qa_list_modules($type)
/* /*
Return a list of names of registered modules of $type Return a list of names of registered modules of $type
*/ */
{ {
$modules = qa_list_all_registered_modules_info(); $modules = qa_list_modules_info();
return is_array(@$modules[$type]) ? array_keys($modules[$type]) : array(); return is_array(@$modules[$type]) ? array_keys($modules[$type]) : array();
} }
function qa_get_module_info($type, $name) function qa_get_module_info($type, $name)
/* /*
Return an array containing information about the module of $type named $name Return an array containing information about the module of $type named $name
*/ */
{ {
$modules = qa_list_all_registered_modules_info(); $modules = qa_list_modules_info();
return @$modules[$type][$name]; return @$modules[$type][$name];
} }
function qa_load_module($type, $name) function qa_load_module($type, $name)
/* /*
Return an instantiated class for module of $type named $name, whose functions can be called, or null if it doesn't exist Return an instantiated class for module of $type named $name, whose functions can be called, or null if it doesn't exist
...@@ -666,7 +654,7 @@ ...@@ -666,7 +654,7 @@
{ {
global $qa_modules; global $qa_modules;
$module=@$qa_modules[$type][$name]; $module = @$qa_modules[$type][$name];
if (is_array($module)) { if (is_array($module)) {
if (isset($module['object'])) if (isset($module['object']))
...@@ -676,19 +664,19 @@ ...@@ -676,19 +664,19 @@
require_once $module['directory'].$module['include']; require_once $module['directory'].$module['include'];
if (strlen(@$module['class'])) { if (strlen(@$module['class'])) {
$object=new $module['class']; $object = new $module['class'];
if (method_exists($object, 'load_module')) if (method_exists($object, 'load_module'))
$object->load_module($module['directory'], qa_path_to_root().$module['urltoroot'], $type, $name); $object->load_module($module['directory'], qa_path_to_root().$module['urltoroot'], $type, $name);
$qa_modules[$type][$name]['object']=$object; $qa_modules[$type][$name]['object'] = $object;
return $object; return $object;
} }
} }
return null; return null;
} }
function qa_load_all_modules_with($method) function qa_load_all_modules_with($method)
/* /*
Return an array of instantiated clases for modules which have defined $method Return an array of instantiated clases for modules which have defined $method
...@@ -696,10 +684,10 @@ ...@@ -696,10 +684,10 @@
*/ */
{ {
$modules = array(); $modules = array();
$registeredmodules = qa_list_all_registered_modules_info(); $regmodules = qa_list_modules_info();
foreach ($registeredmodules as $moduletype => $modulesinfo) { foreach ($regmodules as $moduletype => $modulesinfo) {
foreach ($modulesinfo as $modulename => $moduleinfo) { foreach ($modulesinfo as $modulename => $moduleinfo) {
$module = qa_load_module($moduletype, $modulename); $module = qa_load_module($moduletype, $modulename);
...@@ -707,25 +695,25 @@ ...@@ -707,25 +695,25 @@
$modules[$moduletype] = $module; $modules[$moduletype] = $module;
} }
} }
return $modules; return $modules;
} }
function qa_load_modules_with($type, $method) function qa_load_modules_with($type, $method)
/* /*
Return an array of instantiated clases for modules of $type which have defined $method Return an array of instantiated clases for modules of $type which have defined $method
(other modules of that type are also loaded but not included in the returned array) (other modules of that type are also loaded but not included in the returned array)
*/ */
{ {
$modules=array(); $modules = array();
$trynames=qa_list_modules($type); $trynames = qa_list_modules($type);
foreach ($trynames as $tryname) { foreach ($trynames as $tryname) {
$module=qa_load_module($type, $tryname); $module = qa_load_module($type, $tryname);
if (method_exists($module, $method)) if (method_exists($module, $method))
$modules[$tryname]=$module; $modules[$tryname] = $module;
} }
return $modules; return $modules;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment