From f6794ace8b4a1917706bbaa8165c654c6b730c1a Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Wed, 23 Dec 2009 18:05:58 +0000 Subject: [PATCH] MDL-21125 obsoleting global $THEME --- lib/outputrenderers.php | 14 +++++- lib/weblib.php | 108 ++-------------------------------------- 2 files changed, 17 insertions(+), 105 deletions(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 29d87985e9..3426b809dd 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -612,7 +612,7 @@ class core_renderer extends renderer_base { public function footer() { global $CFG, $DB; - $output = $this->opencontainers->pop_all_but_last(true); + $output = $this->container_end_all(true); $footer = $this->opencontainers->pop('header/footer'); @@ -641,6 +641,18 @@ class core_renderer extends renderer_base { return $output . $footer; } + /** + * Close all but the last open container. This is useful in places like error + * handling, where you want to close all the open containers (apart from ) + * before outputting the error message. + * @param bool $shouldbenone assert that the stack should be empty now - causes a + * developer debug warning if it isn't. + * @return string the HTML required to close any open containers inside . + */ + public function container_end_all($shouldbenone = false) { + return $this->opencontainers->pop_all_but_last($shouldbenone); + } + /** * Output the row of editing icons for a block, as defined by the controls array. * @param array $controls an array like {@link block_contents::$controls}. diff --git a/lib/weblib.php b/lib/weblib.php index 99c1dfb792..3df5258c44 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -740,13 +740,13 @@ function break_up_long_words($string, $maxsize=20, $cutchar=' ') { * to reload the parent window before this one closes. */ function close_window($delay = 0, $reloadopener = false) { - global $THEME, $PAGE, $OUTPUT; + global $PAGE, $OUTPUT; if (!$PAGE->headerprinted) { $PAGE->set_title(get_string('closewindow')); echo $OUTPUT->header(); } else { - print_container_end_all(false, $THEME->open_header_containers); + $OUTPUT->container_end_all(false); } if ($reloadopener) { @@ -2182,106 +2182,6 @@ function print_collapsible_region_end($return = false) { } } -/** - * Returns number of currently open containers - * - * @global object - * @return int number of open containers - */ -function open_containers() { - global $THEME; - - if (!isset($THEME->open_containers)) { - $THEME->open_containers = array(); - } - - return count($THEME->open_containers); -} - -/** - * Force closing of open containers - * - * @param boolean $return, return as string or just print it - * @param int $keep number of containers to be kept open - usually theme or page containers - * @return mixed string or void - */ -function print_container_end_all($return=false, $keep=0) { - global $OUTPUT; - $output = ''; - while (open_containers() > $keep) { - $output .= $OUTPUT->container_end(); - } - if ($return) { - return $output; - } else { - echo $output; - } -} - -/** - * Internal function - do not use directly! - * Starting part of the surrounding divs for custom corners - * - * @param boolean $clearfix, add CLASS "clearfix" to the inner div against collapsing - * @param string $classes - * @param mixed $idbase, optionally, define one idbase to be added to all the elements in the corners - * @return string - */ -function _print_custom_corners_start($clearfix=false, $classes='', $idbase='') { -/// Analise if we want ids for the custom corner elements - $id = ''; - $idbt = ''; - $idi1 = ''; - $idi2 = ''; - $idi3 = ''; - - if ($idbase) { - $id = 'id="'.$idbase.'" '; - $idbt = 'id="'.$idbase.'-bt" '; - $idi1 = 'id="'.$idbase.'-i1" '; - $idi2 = 'id="'.$idbase.'-i2" '; - $idi3 = 'id="'.$idbase.'-i3" '; - } - -/// Calculate current level - $level = open_containers(); - -/// Output begins - $output = '
'."\n"; - $output .= '
 
'; - $output .= "\n"; - $output .= '
'; - $output .= (!empty($clearfix)) ? '
' : '
'; - - return $output; -} - - -/** - * Internal function - do not use directly! - * Ending part of the surrounding divs for custom corners - * - * @param string $idbase - * @return string HTML sttring - */ -function _print_custom_corners_end($idbase) { -/// Analise if we want ids for the custom corner elements - $idbb = ''; - - if ($idbase) { - $idbb = 'id="' . $idbase . '-bb" '; - } - -/// Output begins - $output = '
'; - $output .= "\n"; - $output .= '
 
'."\n"; - $output .= '
'; - - return $output; -} - - /** * Print a specified group's avatar. * @@ -2740,7 +2640,7 @@ function modgradehelpbutton($courseid){ * @return void This function simply exits */ function notice ($message, $link='', $course=NULL) { - global $CFG, $SITE, $THEME, $COURSE, $PAGE, $OUTPUT; + global $CFG, $SITE, $COURSE, $PAGE, $OUTPUT; $message = clean_text($message); // In case nasties are in here @@ -2754,7 +2654,7 @@ function notice ($message, $link='', $course=NULL) { $PAGE->set_title(get_string('notice')); echo $OUTPUT->header(); } else { - print_container_end_all(false, $THEME->open_header_containers); + echo $OUTPUT->container_end_all(false); } echo $OUTPUT->box($message, 'generalbox', 'notice'); -- 2.39.5