From 3ab292c678927aeaf5ccac3c612e5708507fb837 Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Wed, 2 Apr 2008 14:04:47 +0000 Subject: [PATCH] Replaced some nasty 'magic numbers' with defines. --- course/format/weeks/format.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index 7ad603e2d4..23923123e2 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -29,6 +29,29 @@ $week = optional_param('week', -1, PARAM_INT); + // Bounds for block widths + // more flexible for theme designers taken from theme config.php + $lmin = (empty($THEME->block_l_min_width)) ? 100 : $THEME->block_l_min_width; + $lmax = (empty($THEME->block_l_max_width)) ? 210 : $THEME->block_l_max_width; + $rmin = (empty($THEME->block_r_min_width)) ? 100 : $THEME->block_r_min_width; + $rmax = (empty($THEME->block_r_max_width)) ? 210 : $THEME->block_r_max_width; + + define('BLOCK_L_MIN_WIDTH', $lmin); + define('BLOCK_L_MAX_WIDTH', $lmax); + define('BLOCK_R_MIN_WIDTH', $rmin); + define('BLOCK_R_MAX_WIDTH', $rmax); + + // some defines for time periods (all are seconds) + define( 'SECONDS_ONEWEEK', 604800 ); + define( 'SECONDS_SIXDAYS', 518400 ); + define( 'SECONDS_TWOHOURS', 7200 ); + + + $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), + BLOCK_L_MAX_WIDTH); + $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), + BLOCK_R_MAX_WIDTH); + if ($week != -1) { $displaysection = course_set_display($course->id, $week); } else { @@ -150,10 +173,10 @@ $timenow = time(); $weekdate = $course->startdate; // this should be 0:00 Monday of that week - $weekdate += 7200; // Add two hours to avoid possible DST problems + $weekdate += SECONDS_TWOHOURS; // Add two hours to avoid possible DST problems $section = 1; $sectionmenu = array(); - $weekofseconds = 604800; + $weekofseconds = SECONDS_ONEWEEK; $course->enddate = $course->startdate + ($weekofseconds * $course->numsections); $strftimedateshort = ' '.get_string('strftimedateshort'); @@ -162,7 +185,7 @@ $nextweekdate = $weekdate + ($weekofseconds); $weekday = userdate($weekdate, $strftimedateshort); - $endweekday = userdate($weekdate+518400, $strftimedateshort); + $endweekday = userdate($weekdate+SECONDS_SIXDAYS, $strftimedateshort); if (!empty($sections[$section])) { $thissection = $sections[$section]; -- 2.39.5