From 6d16792cf2e5307c70f698ff9e536d1237886982 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Thu, 22 Apr 2010 08:45:36 +0000 Subject: [PATCH] MDL-21694 usin new core_subsystesm() in renderers too; adding more docs --- lib/moodlelib.php | 10 ++++++++-- lib/outputfactories.php | 8 +++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index cfa01da9aab..67832d3814f 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -6821,14 +6821,20 @@ function normalize_component($component) { /** * List all core subsystems, this is especially useful for get_string() - * and output renderers. The relative location is not always included. + * and output renderers. + * + * The location is dirroot relative path, NULL means there is no special + * directory for this subsystem. + * + * Unfortunately no module may be named like any core subsystem because + * we are still lazy to use proper "mod_" prefix in get_string() and elsewhere. * * @return array of strings - name=>location */ function get_core_subsystems() { global $CFG; - static $info = null; + static $info = null; if (!$info) { $info = array( diff --git a/lib/outputfactories.php b/lib/outputfactories.php index aebe7a28ca7..0707a7aef70 100644 --- a/lib/outputfactories.php +++ b/lib/outputfactories.php @@ -106,9 +106,6 @@ abstract class renderer_factory_base implements renderer_factory { /** @var theme_config the theme we belong to. */ protected $theme; - /** @var hardcoded list of core subtypes and their locations, add more if ßneeded */ - protected $core_subtypes = array('webservice' => 'webservice'); - /** * Constructor. * @param theme_config $theme the theme we belong to. @@ -176,10 +173,11 @@ abstract class renderer_factory_base implements renderer_factory { } } else if (!empty($subtype)) { - if (!isset($this->core_subtypes[$subtype])) { + $coresubsystems = get_core_subsystems(); + if (!isset($coresubsystems[$subtype])) { throw new coding_exception('Invalid core subtype "' . $subtype . '" in renderer request'); } - $rendererfile = $CFG->dirroot . '/' . $this->core_subtypes[$subtype] . '/renderer.php'; + $rendererfile = $CFG->dirroot . '/' . $coresubsystems[$subtype] . '/renderer.php'; if (file_exists($rendererfile)) { include_once($rendererfile); }