mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Eloy is probably right, the preferred width calculation should be cached.
This commit is contained in:
parent
1eb25080df
commit
82b181f265
1 changed files with 24 additions and 13 deletions
|
@ -47,10 +47,6 @@
|
|||
$courseformat = 0;
|
||||
}
|
||||
|
||||
//We *always* need to get active blocks (perhaps this should be cached
|
||||
//in a session object and updated in when editing = true ????
|
||||
$recblocks = get_records('blocks','visible','1');
|
||||
|
||||
// Doing this now so we can pass the results to block_action()
|
||||
// and dodge the overhead of doing the same work twice.
|
||||
|
||||
|
@ -94,11 +90,11 @@
|
|||
$editing = $USER->editing;
|
||||
|
||||
if (isset($hide)) {
|
||||
set_section_visible($course->id, $hide, "0");
|
||||
set_section_visible($course->id, $hide, '0');
|
||||
}
|
||||
|
||||
if (isset($show)) {
|
||||
set_section_visible($course->id, $show, "1");
|
||||
set_section_visible($course->id, $show, '1');
|
||||
}
|
||||
|
||||
if (isset($_GET['blockaction'])) {
|
||||
|
@ -111,6 +107,8 @@
|
|||
$allblocks = array_merge($leftblocks, $rightblocks);
|
||||
|
||||
$missingblocks = array();
|
||||
$recblocks = get_records('blocks','visible','1');
|
||||
|
||||
if($editing && $recblocks) {
|
||||
foreach($recblocks as $recblock) {
|
||||
// If it's not hidden or displayed right now...
|
||||
|
@ -124,7 +122,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($section)) {
|
||||
if (!empty($move)) {
|
||||
if (!move_section($course, $section, $move)) {
|
||||
|
@ -171,12 +168,26 @@
|
|||
}
|
||||
}
|
||||
|
||||
//Calculate left and right width. This has to be calculated *always*. Perhaps
|
||||
//we could cache it in a session variable and update it only when editing=true ????
|
||||
//This caused some display problems (100 width) in student mode.
|
||||
// If the block width cache is not set, set it
|
||||
if(!isset($SESSION->blockcache->width->{$course->id}) || $editing) {
|
||||
|
||||
// This query might be optimized away if we 're in editing mode
|
||||
if(!isset($recblocks)) {
|
||||
$recblocks = get_records('blocks','visible','1');
|
||||
}
|
||||
$preferred_width_left = blocks_preferred_width($leftblocks, $recblocks);
|
||||
$preferred_width_right = blocks_preferred_width($rightblocks, $recblocks);
|
||||
|
||||
// This may be kind of organizational overkill, granted...
|
||||
// But is there any real need to simplify the structure?
|
||||
$SESSION->blockcache->width->{$course->id}->left = $preferred_width_left;
|
||||
$SESSION->blockcache->width->{$course->id}->right = $preferred_width_right;
|
||||
}
|
||||
else {
|
||||
$preferred_width_left = $SESSION->blockcache->width->{$course->id}->left;
|
||||
$preferred_width_right = $SESSION->blockcache->width->{$course->id}->right;
|
||||
}
|
||||
|
||||
require("$CFG->dirroot/course/format/$course->format/format.php"); // Include the actual course format
|
||||
|
||||
print_footer();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue