From 289218844a493721c629cb9f192040c08c57a6e5 Mon Sep 17 00:00:00 2001 From: mark-nielsen Date: Sun, 19 Mar 2006 01:53:50 +0000 Subject: [PATCH] [Changed] The print_simple_box_start/stop changes conflicted greatly with the display of branch table buttons (the box printed above the buttons some how :( ) To fix this, the tables were taken out and divs were used instead to display and arrange the buttons. This turns out to be a good thing because now the user has more control over the buttons via style sheet. Also did some extra clean up in the section of code printing the branch table. [Added] new styles to styles.php to help display the buttons correctly. --- mod/lesson/styles.php | 33 +++++++++++++-- mod/lesson/view.php | 99 ++++++++++++++++++------------------------- 2 files changed, 71 insertions(+), 61 deletions(-) diff --git a/mod/lesson/styles.php b/mod/lesson/styles.php index f768fc61bc..15f6150cdb 100644 --- a/mod/lesson/styles.php +++ b/mod/lesson/styles.php @@ -143,9 +143,35 @@ .mod-lesson .standardbutton { } +/* Next three classes are for branch table buttons when displayed horizontally */ +.mod-lesson .prevhorizontal { + display: inline; + float: left; +} + +.mod-lesson .nexthorizontal { + display: inline; + float: right; +} + +.mod-lesson .standardhorizontal { + display: inline; +} + +/* Next three classes are for branch table buttons when displayed vertically */ +.mod-lesson .prevvertical { +} + +.mod-lesson .nextvertical a { +} + +.mod-lesson .standardvertical a { +} + /* branchbuttoncontainer wraps around branch table buttons */ .mod-lesson .branchbuttoncontainer { text-align: center; + padding: 3px; } /* branchslidetop and branchslidebottom classes are wrapped around the branch buttons (branchslidetop around @@ -155,13 +181,14 @@ /* You could float them out of the slide position: absolute; top: 60px;*/ - /* You may choose to not show them at all - display: none;*/ + /* You may choose to not show them at all */ + display: none; } .mod-lesson .branchslidebottom { - /* You may choose to not show them at all + /* You may choose to not show them at all display: none; */ + padding-top: 10px; } /*** diff --git a/mod/lesson/view.php b/mod/lesson/view.php index cefa9947ce..dbe366516a 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -832,77 +832,64 @@ case LESSON_BRANCHTABLE : $options = new stdClass; $options->para = false; - $buttons = array('next' => '', 'prev' => '', 'other' => array()); - // seperate out next and previous jumps from the other jumps + $buttons = array('next' => array(), 'prev' => array(), 'other' => array()); + /// seperate out next and previous jumps from the other jumps foreach ($answers as $answer) { if ($answer->jumpto == LESSON_NEXTPAGE) { - $buttons['next'] = '
'. - strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options)).'
'; + $buttons['next'][] = ''. + strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options)).''; } else if ($answer->jumpto == LESSON_PREVIOUSPAGE) { - $buttons['prev'] = '
'. - strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options)).'
'; + $buttons['prev'][] = ''. + strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options)).''; } else { - $buttons['other'][] = '
'. - strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options)).'
'; + $buttons['other'][] = ''. + strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options)).''; } } - - if ($lesson->slideshow) { - $px = $lesson->width - 30; // give us some breathing room - $width = ' width="'.$px.'px"'; - } else { - $width = ' width="100%"'; - } - - $fullbuttonhtml = '
'."\n"; + + /// set the order and orientation (order is very important for the divs to work for horizontal!) if ($page->layout) { - // tried to do this with CSS, but couldnt get it to work in MacIE browser. Using tables instead :( - // don't care if empty or not because we want to keep the table structure - $fullbuttonhtml .= '\n"; - $fullbuttonhtml .= '\n"; - $fullbuttonhtml .= '
'.$buttons['prev']."\n
'.implode("", $buttons['other'])."
'.$buttons['next']."
\n"; - } else { - // care about emptyness here - $temparray = array(); - if (!empty($buttons['next'])) { - $temparray[] = $buttons['next']; + $orientation = 'horizontal'; + $a = 'a'; + $b = 'b'; + $c = 'c'; + $implode = ' '; + $implode2 = "\n "; + if (empty($buttons['other'])) { + $buttons['other'][] = ' '; // very critical! If nothing is in the middle, + // then the div style float left/right will not + // render properly with next/previous buttons } - if (!empty($buttons['other'])) { - $temparray = array_merge($temparray, $buttons['other']); - } - if (!empty($buttons['prev'])) { - $temparray[] = $buttons['prev']; - } - $fullbuttonhtml .= '\n
'. - implode("
", $temparray). - "
\n"; + } else { + $orientation = 'vertical'; + $a = 'c'; + $b = 'a'; + $c = 'b'; + $implode = '

'; + $implode2 = "
\n "; } - $fullbuttonhtml .= "
\n"; + $buttonsarranged = array(); + $buttonsarranged[$a] = '
'.implode($implode, $buttons['prev']).'
'; + $buttonsarranged[$b] = '
'.implode($implode, $buttons['next']).'
'; + $buttonsarranged[$c] = '
'.implode($implode, $buttons['other']).'
'; + ksort($buttonsarranged); // sort by key + + $fullbuttonhtml = "\n
\n " . implode($implode2, $buttonsarranged). "\n
\n"; if ($lesson->slideshow) { - //echo '
' . $fullbuttonhtml . '
'; + echo '
' . $fullbuttonhtml . '
'; $options = new stdClass; $options->noclean = true; - echo '
'.format_text($page->contents, FORMAT_MOODLE, $options).'
';; - echo ''; + echo '
'.format_text($page->contents, FORMAT_MOODLE, $options)."
\n"; + echo ''; + echo '
' . $fullbuttonhtml . '
'; } else { - echo '
'; - } - echo ''; - - if (!$lesson->slideshow) { - if (!empty($buttons['next']) or !empty($buttons['prev'])) { - print_simple_box_start("center", '100%'); - } else { - print_simple_box_start("center"); - } - + print_simple_box_start('center'); echo $fullbuttonhtml; - echo '
'; print_simple_box_end(); - } else { - echo '
' . $fullbuttonhtml . '
'; } + echo ''; + break; case LESSON_ESSAY : if (isset($USER->modattempts[$lesson->id])) { @@ -1233,10 +1220,6 @@ echo "
id\">".get_string("viewgrades", "lesson")."
\n"; //view grades } - if ($lesson->slideshow) { // ends the slideshow div - echo ''; - } - if ($lesson->displayleft || $lesson->slideshow) { // this ends the table cell and table for the leftmenu or for slideshow echo ""; } -- 2.39.5