mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
MDL-12221 reworked container autoclosing - error() and notice() do not work everywhere though; notice print header if needed now; new print_footer('empty') for empty footer - removes some hacky </body></html> - merged from MOODLE_19_STABLE
This commit is contained in:
parent
fd3b240bd0
commit
d795bfdbf9
lang/en_utf8
lib
message
mod
chat
glossary
resource/type
@ -1079,6 +1079,7 @@ $string['notenrolledprofile'] = 'This profile is not available because this user
|
||||
$string['noteuserschangednonetocourse'] = 'Note: course users need to be restored when restoring user data (in activities, files or messages). This setting has been changed for you.';
|
||||
$string['nothingnew'] = 'Nothing new since your last login';
|
||||
$string['nothingtodisplay'] = 'Nothing to display';
|
||||
$string['notice'] = 'Notice';
|
||||
$string['noticenewerbackup'] = 'This backup file has been created with Moodle $a->backuprelease ($a->backupversion) and it\'s newer than your currently installed Moodle $a->serverrelease ($a->serverversion). This could cause some inconsistencies because backwards compatibility of backup files cannot be guaranteed.';
|
||||
$string['notifications'] = 'Notifications';
|
||||
$string['notifyloginfailuresmessage'] = '$a->time, IP: $a->ip, User: $a->info';
|
||||
|
@ -3115,26 +3115,27 @@ function admin_externalpage_print_header() {
|
||||
foreach ($lt1 as $column) {
|
||||
switch ($column) {
|
||||
case 'left':
|
||||
echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
break;
|
||||
|
||||
case 'middle':
|
||||
echo '<td id="middle-column">';
|
||||
print_container_start(true);
|
||||
echo '<td id="middle-column">';
|
||||
print_container_start(true);
|
||||
$THEME->open_header_containers++; // this is hacky workaround for the error()/notice() autoclosing problems on admin pages
|
||||
break;
|
||||
|
||||
case 'right':
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
|
||||
echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
}
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
|
||||
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3169,27 +3170,27 @@ function admin_externalpage_print_footer() {
|
||||
foreach ($lt as $column) {
|
||||
switch ($column) {
|
||||
case 'left':
|
||||
echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
break;
|
||||
|
||||
case 'middle':
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
print_container_end();
|
||||
$THEME->open_header_containers--; // this is hacky workaround for the error()/notice() autoclosing problems on admin pages
|
||||
echo '</td>';
|
||||
break;
|
||||
|
||||
case 'right':
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
|
||||
echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
}
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
|
||||
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
124
lib/weblib.php
124
lib/weblib.php
@ -80,6 +80,13 @@ define('FORMAT_MARKDOWN', '4'); // Markdown-formatted text http://daringfireba
|
||||
define('TRUSTTEXT', '#####TRUSTTEXT#####');
|
||||
|
||||
|
||||
/**
|
||||
* Javascript related defines
|
||||
*/
|
||||
define('REQUIREJS_BEFOREHEADER', 0);
|
||||
define('REQUIREJS_INHEADER', 1);
|
||||
define('REQUIREJS_AFTERHEADER', 2);
|
||||
|
||||
/**
|
||||
* Allowed tags - string of html tags that can be tested against for safe html tags
|
||||
* @global string $ALLOWED_TAGS
|
||||
@ -2526,6 +2533,9 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
// container debugging info
|
||||
$THEME->open_header_containers = open_containers();
|
||||
|
||||
// Skip to main content, see skip_main_destination().
|
||||
if ($pageid=='course-view' or $pageid=='site-index' or $pageid=='course-index') {
|
||||
$skiplink = '<a class="skip" href="#maincontent">'.get_string('tocontent', 'access').'</a>';
|
||||
@ -2551,10 +2561,6 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
|
||||
}
|
||||
}
|
||||
|
||||
define('REQUIREJS_BEFOREHEADER',0);
|
||||
define('REQUIREJS_INHEADER',1);
|
||||
define('REQUIREJS_AFTERHEADER',2);
|
||||
|
||||
/**
|
||||
* Used to include JavaScript libraries.
|
||||
*
|
||||
@ -2758,12 +2764,14 @@ function print_header_simple($title='', $heading='', $navigation='', $focus='',
|
||||
/**
|
||||
* Can provide a course object to make the footer contain a link to
|
||||
* to the course home page, otherwise the link will go to the site home
|
||||
*
|
||||
* @uses $CFG
|
||||
* @uses $USER
|
||||
* @param course $course {@link $COURSE} object containing course information
|
||||
* @param ? $usercourse ?
|
||||
* @todo Finish documenting this function
|
||||
* @param mixed $course course object, used for course link button or
|
||||
* 'none' means no user link, only docs link
|
||||
* 'empty' means nothing printed in footer
|
||||
* 'home' special frontpage footer
|
||||
* @param object $usercourse course used in user link
|
||||
* @param boolean $return output as string
|
||||
* @return mixed string or void
|
||||
*/
|
||||
function print_footer($course=NULL, $usercourse=NULL, $return=false) {
|
||||
global $USER, $CFG, $THEME, $COURSE;
|
||||
@ -2773,23 +2781,45 @@ function print_footer($course=NULL, $usercourse=NULL, $return=false) {
|
||||
return;
|
||||
}
|
||||
|
||||
/// Course links
|
||||
/// Course links or special footer
|
||||
if ($course) {
|
||||
if (is_string($course) && $course == 'none') { // Don't print any links etc
|
||||
if ($course === 'empty') {
|
||||
// special hack - sometimes we do not want even the docs link in footer
|
||||
$output = '';
|
||||
if (!empty($THEME->open_header_containers)) {
|
||||
for ($i=0; $i<$THEME->open_header_containers; $i++) {
|
||||
$output .= print_container_end_all(); // containers opened from header
|
||||
}
|
||||
} else {
|
||||
//1.8 theme compatibility
|
||||
$output .= "\n</div>"; // content div
|
||||
}
|
||||
$output .= "\n</div>\n</body>\n</html>"; // close page div started in header
|
||||
if ($return) {
|
||||
return $output;
|
||||
} else {
|
||||
echo $output;
|
||||
return;
|
||||
}
|
||||
|
||||
} else if ($course === 'none') { // Don't print any links etc
|
||||
$homelink = '';
|
||||
$loggedinas = '';
|
||||
$home = false;
|
||||
} else if (is_string($course) && $course == 'home') { // special case for site home page - please do not remove
|
||||
|
||||
} else if ($course === 'home') { // special case for site home page - please do not remove
|
||||
$course = get_site();
|
||||
$homelink = '<div class="sitelink">'.
|
||||
'<a title="moodle '. $CFG->release .' ('. $CFG->version .')" href="http://moodle.org/">'.
|
||||
'<img style="width:100px;height:30px" src="pix/moodlelogo.gif" alt="moodlelogo" /></a></div>';
|
||||
$home = true;
|
||||
|
||||
} else {
|
||||
$homelink = '<div class="homelink"><a '.$CFG->frametarget.' href="'.$CFG->wwwroot.
|
||||
'/course/view.php?id='.$course->id.'">'.format_string($course->shortname).'</a></div>';
|
||||
$home = false;
|
||||
}
|
||||
|
||||
} else {
|
||||
$course = get_site(); // Set course as site course by default
|
||||
$homelink = '<div class="homelink"><a '.$CFG->frametarget.' href="'.$CFG->wwwroot.'/">'.get_string('home').'</a></div>';
|
||||
@ -2818,9 +2848,9 @@ function print_footer($course=NULL, $usercourse=NULL, $return=false) {
|
||||
$menu = '';
|
||||
}
|
||||
|
||||
/// there should be exactly one open container 'content'
|
||||
if (open_containers() != 1) {
|
||||
debugging('Unexpected number of open containers: '.open_containers().', expecting 1.', DEBUG_DEVELOPER);
|
||||
/// there should be exactly the same number of open containers as after the header
|
||||
if ($THEME->open_header_containers != open_containers()) {
|
||||
debugging('Unexpected number of open containers: '.open_containers().', expecting '.$THEME->open_header_containers, DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
/// Provide some performance info if required
|
||||
@ -3818,8 +3848,9 @@ function print_continue($link, $return=false) {
|
||||
*
|
||||
* @param string $message, the content of the box
|
||||
* @param string $classes, space-separated class names.
|
||||
* @param string $ids, space-separated id names.
|
||||
* @param string $idbase
|
||||
* @param boolean $return, return as string or just print it
|
||||
* @return mixed string or void
|
||||
*/
|
||||
function print_box($message, $classes='generalbox', $ids='', $return=false) {
|
||||
|
||||
@ -3839,8 +3870,9 @@ function print_box($message, $classes='generalbox', $ids='', $return=false) {
|
||||
* Replaces print_simple_box_start (see deprecatedlib.php)
|
||||
*
|
||||
* @param string $classes, space-separated class names.
|
||||
* @param string $ids, space-separated id names.
|
||||
* @param string $idbase
|
||||
* @param boolean $return, return as string or just print it
|
||||
* @return mixed string or void
|
||||
*/
|
||||
function print_box_start($classes='generalbox', $ids='', $return=false) {
|
||||
global $THEME;
|
||||
@ -3868,9 +3900,11 @@ function print_box_end($return=false) {
|
||||
* Print a message in a standard themed container.
|
||||
*
|
||||
* @param string $message, the content of the container
|
||||
* @param boolean $clearfix clear both sides
|
||||
* @param string $classes, space-separated class names.
|
||||
* @param string $ids, space-separated id names.
|
||||
* @param string $idbase
|
||||
* @param boolean $return, return as string or just print it
|
||||
* @return string or void
|
||||
*/
|
||||
function print_container($message, $clearfix=false, $classes='', $idbase='', $return=false) {
|
||||
|
||||
@ -3888,9 +3922,11 @@ function print_container($message, $clearfix=false, $classes='', $idbase='', $re
|
||||
/**
|
||||
* Starts a container using divs
|
||||
*
|
||||
* @param boolean $clearfix clear both sides
|
||||
* @param string $classes, space-separated class names.
|
||||
* @param string $ids, space-separated id names.
|
||||
* @param string $idbase
|
||||
* @param boolean $return, return as string or just print it
|
||||
* @return mixed string or void
|
||||
*/
|
||||
function print_container_start($clearfix=false, $classes='', $idbase='', $return=false) {
|
||||
global $THEME;
|
||||
@ -3932,12 +3968,13 @@ function print_container_start($clearfix=false, $classes='', $idbase='', $return
|
||||
/**
|
||||
* Simple function to end a container (see above)
|
||||
* @param boolean $return, return as string or just print it
|
||||
* @return mixed string or void
|
||||
*/
|
||||
function print_container_end($return=false) {
|
||||
global $THEME;
|
||||
|
||||
if (empty($THEME->open_containers)) {
|
||||
debugging('Incorrect closing of custom corners - no more open containers.', DEBUG_DEVELOPER);
|
||||
debugging('Incorrect request to end container - no more open containers.', DEBUG_DEVELOPER);
|
||||
$idbase = '';
|
||||
} else {
|
||||
$idbase = array_pop($THEME->open_containers);
|
||||
@ -3971,17 +4008,15 @@ function open_containers() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Force closing of all open containers except the main content one.
|
||||
* 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) {
|
||||
global $THEME;
|
||||
|
||||
function print_container_end_all($return=false, $keep=0) {
|
||||
$output = '';
|
||||
if (!empty($THEME->open_containers)) {
|
||||
while(count($THEME->open_containers) > 1) { // the last one is the 'content' container
|
||||
$output .= print_container_end($return);
|
||||
}
|
||||
while (open_containers() > $keep) {
|
||||
$output .= print_container_end($return);
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
@ -3996,7 +4031,9 @@ function print_container_end_all($return=false) {
|
||||
* Starting part of the surrounding divs for custom corners
|
||||
*
|
||||
* @param boolean $clearfix, add CLASS "clearfix" to the inner div against collapsing
|
||||
* @param mixed $idbase, optionally, define one idbase to be added to all the elements in the corners
|
||||
* @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
|
||||
@ -4031,6 +4068,8 @@ function _print_custom_corners_start($clearfix=false, $classes='', $idbase='') {
|
||||
/**
|
||||
* Internal function - do not use directly!
|
||||
* Ending part of the surrounding divs for custom corners
|
||||
* @param string $idbase
|
||||
* @return string
|
||||
*/
|
||||
function _print_custom_corners_end($idbase) {
|
||||
/// Analise if we want ids for the custom corner elements
|
||||
@ -5639,7 +5678,7 @@ function print_scale_menu_helpbutton($courseid, $scale, $return=false) {
|
||||
*/
|
||||
function error ($message, $link='') {
|
||||
|
||||
global $CFG, $SESSION;
|
||||
global $CFG, $SESSION, $THEME;
|
||||
$message = clean_text($message); // In case nasties are in here
|
||||
|
||||
if (defined('FULLME') && FULLME == 'cron') {
|
||||
@ -5653,7 +5692,7 @@ function error ($message, $link='') {
|
||||
@header('HTTP/1.0 404 Not Found');
|
||||
print_header(get_string('error'));
|
||||
} else {
|
||||
print_container_end_all();
|
||||
print_container_end_all(false, $THEME->open_header_containers);
|
||||
}
|
||||
|
||||
echo '<br />';
|
||||
@ -5909,17 +5948,28 @@ function editorshortcutshelpbutton() {
|
||||
* @todo Finish documenting this function
|
||||
*/
|
||||
function notice ($message, $link='', $course=NULL) {
|
||||
global $CFG, $SITE;
|
||||
global $CFG, $SITE, $THEME, $COURSE;
|
||||
|
||||
print_container_end_all();
|
||||
$message = clean_text($message); // In case nasties are in here
|
||||
|
||||
$message = clean_text($message);
|
||||
if (defined('FULLME') && FULLME == 'cron') {
|
||||
// notices in cron should be mtrace'd.
|
||||
mtrace($message);
|
||||
die;
|
||||
}
|
||||
|
||||
if (! defined('HEADER_PRINTED')) {
|
||||
//header not yet printed
|
||||
print_header(get_string('notice'));
|
||||
} else {
|
||||
print_container_end_all(false, $THEME->open_header_containers);
|
||||
}
|
||||
|
||||
print_box($message, 'generalbox', 'notice');
|
||||
print_continue($link);
|
||||
|
||||
if (empty($course)) {
|
||||
print_footer($SITE);
|
||||
print_footer($COURSE);
|
||||
} else {
|
||||
print_footer($course);
|
||||
}
|
||||
@ -5978,7 +6028,7 @@ if (!function_exists('error_get_last')) {
|
||||
*/
|
||||
function redirect($url, $message='', $delay=-1) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $THEME;
|
||||
|
||||
if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) {
|
||||
$url = sid_process_url($url);
|
||||
@ -6052,7 +6102,7 @@ function redirect($url, $message='', $delay=-1) {
|
||||
print_header('', '', '', '', $errorprinted ? '' : ('<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />'));
|
||||
$delay += 3; // double redirect prevention, it was sometimes breaking upgrades before 1.7
|
||||
} else {
|
||||
print_container_end_all();
|
||||
print_container_end_all(false, $THEME->open_header_containers);
|
||||
}
|
||||
echo '<div style="text-align:center">';
|
||||
echo '<div>'. $message .'</div>';
|
||||
|
@ -87,8 +87,6 @@
|
||||
|
||||
echo '</td></tr></table>';
|
||||
|
||||
// this is hack!
|
||||
print_container_end(); // container "content" started in header
|
||||
echo '</div></body></html>'; // close page div started in header
|
||||
print_footer('empty');
|
||||
|
||||
?>
|
||||
|
@ -59,7 +59,6 @@
|
||||
<input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
|
||||
<input type="hidden" name="chat_message" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
print_footer('empty');
|
||||
?>
|
||||
|
@ -135,7 +135,8 @@
|
||||
echo '</td></tr>';
|
||||
}
|
||||
// added 2 </div>s, xhtml strict complaints
|
||||
echo '</table></div></div></body></html>';
|
||||
echo '</table>';
|
||||
print_footer('empty');
|
||||
|
||||
//
|
||||
// Support HTTP Keep-Alive by printing Content-Length
|
||||
|
@ -71,6 +71,6 @@ function reloadusers() {
|
||||
<input type="hidden" name="chat_msgidnr" value="0" />
|
||||
<input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
print_footer('empty');
|
||||
?>
|
@ -181,5 +181,5 @@
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div></div></body></html>';
|
||||
print_footer('empty');
|
||||
?>
|
||||
|
@ -45,5 +45,6 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
print_footer('empty');
|
||||
?>
|
@ -52,6 +52,6 @@
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
print_footer('empty');
|
||||
?>
|
@ -414,7 +414,7 @@ class resource_file extends resource_base {
|
||||
get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div></div></body></html>';
|
||||
print_footer('empty');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -479,12 +479,8 @@ class resource_ims extends resource_base {
|
||||
}
|
||||
/// content - this produces everything else
|
||||
$this->print_ims($cm, $course, $items, $resource, $page);
|
||||
/// Now, let's print the footer. It's harcoded here to save some space
|
||||
/// because it's impossible to use print_footer() to print NOTHING
|
||||
/// Added programatic support to customcorners themes.
|
||||
// this is hack!
|
||||
print_container_end(); // container "content" started in header
|
||||
echo '</div></body></html>'; // close page div started in header
|
||||
|
||||
print_footer('empty');
|
||||
|
||||
/// log it.
|
||||
add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user