From 68d5f00ae8bf08190f8f0d7994071c1aeb456403 Mon Sep 17 00:00:00 2001 From: defacer Date: Wed, 2 Feb 2005 02:25:50 +0000 Subject: [PATCH] Isolating this in a function because it's quite useful to access from elsewhere, too. --- lib/weblib.php | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index f3123fe98a..0ab26b2fdd 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1634,20 +1634,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta= // Create class and id for this page - $path = str_replace($CFG->wwwroot.'/', '', $ME); - $path = str_replace('.php', '', $path); - if (substr($path, -1) == '/') { - $path .= 'index'; - } - if (empty($path) or $path == '/index') { - $pageid = 'site-index'; - $pageclass = 'course'; - } else { - $pageid = str_replace('/', '-', $path); - $pageclass = explode('-', $pageid); - array_pop($pageclass); - $pageclass = implode('-', $pageclass); - } + page_id_and_class($pageid, $pageclass); if (isset($course->id)) { $pageclass .= ' course-'.$course->id; @@ -3659,5 +3646,34 @@ function print_speller_button () { echo ''."\n"; } + +function page_id_and_class(&$getid, &$getclass) { + // Create class and id for this page + global $CFG, $ME; + + static $class = NULL; + static $id = NULL; + + if(empty($class) || empty($id)) { + $path = str_replace($CFG->wwwroot.'/', '', $ME); + $path = str_replace('.php', '', $path); + if (substr($path, -1) == '/') { + $path .= 'index'; + } + if (empty($path) || $path == '/index') { + $id = 'site-index'; + $class = 'course'; + } else { + $id = str_replace('/', '-', $path); + $class = explode('-', $id); + array_pop($class); + $class = implode('-', $class); + } + } + + $getid = $id; + $getclass = $class; +} + // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140: ?> -- 2.39.5