]> git.mjollnir.org Git - moodle.git/commitdiff
themes & blocks - MDL-19077 & MDL-19010 blocks are now printed by the theme
authortjhunt <tjhunt>
Thu, 9 Jul 2009 07:35:03 +0000 (07:35 +0000)
committertjhunt <tjhunt>
Thu, 9 Jul 2009 07:35:03 +0000 (07:35 +0000)
The code to print blocks in now in theme layout.php files. (Or in
moodle_core_renderer::handle_legacy_theme)

Code for printing blocks everywhere else has been stripped out.
(Total diffstat 1225 insertions, 2019 deletions)

The way the HTML for a block instance is generated has been cleaned
up a lot. Now, the block_instance generates a block_contents
object which gives a structured representation of the block,
and then $OUTPUT->block builds all the HTML from that.

How theme config.php files specify the layout template and block
regions by page general type has been changed to be even more flexible.

Further refinement for how the theme and block code gets initialised.

Ability for scrits to add 'pretend blocks' to the page. That is,
things that look like blocks, but are not normal block_instances.
(Like the add a new block UI.)

Things that are still broken:
 * some pages in lesson, quiz and resource. I'm working on it.
 * lots of developer debug notices pointing out things that
   need to be updated.

58 files changed:
admin/index.php
admin/settings.php
admin/settings/plugins.php
admin/stickyblocks.php [deleted file]
blocks/moodleblock.class.php
blog/footer.php
blog/header.php
course/edit.php
course/format/scorm/format.php
course/format/social/format.php
course/format/topics/format.php
course/format/weeks/format.php
course/modedit.php
course/rest.php
course/view.php
index.php
install.php
lib/adminlib.php
lib/ajax/ajaxlib.php
lib/blocklib.php
lib/deprecatedlib.php
lib/javascript-static.js
lib/outputlib.php
lib/pagelib.php
lib/questionlib.php
lib/setup.php
lib/setuplib.php
lib/upgradelib.php
lib/weblib.php
mod/chat/view.php
mod/data/view.php
mod/lesson/view.php
mod/quiz/accessrules.php
mod/quiz/attempt.php
mod/quiz/attemptlib.php
mod/quiz/locallib.php
mod/quiz/review.php
mod/quiz/view.php
mod/resource/lib.php
my/index.php
tag/index.php
tag/search.php
test.php [new file with mode: 0644]
theme/anomaly/config.php
theme/custom_corners/config.php
theme/custom_corners/renderers.php
theme/standard/config.php
theme/standard/layout-home.php
theme/standard/layout-popup.php [moved from theme/standardwhite/layout-popup.php with 79% similarity]
theme/standard/layout.php
theme/standard/styles_color.css
theme/standard/styles_ie6.css
theme/standard/styles_ie7.css
theme/standard/styles_layout.css
theme/standardwhite/config.php
theme/standardwhite/layout-home.php [deleted file]
theme/standardwhite/layout.php [deleted file]
user/editadvanced.php

index 22e60a51d231591b748693e97901a61df42ab960..f86aa09375450cef4985f8251f63d0596cd42adc 100644 (file)
@@ -105,7 +105,7 @@ $origxmlstrictheaders = !empty($CFG->xmlstrictheaders);
 $CFG->xmlstrictheaders = false;
 
 if (!core_tables_exist()) {
-    // hide errors from headers in case debug enabled in config.php
+    $PAGE->set_generaltype('maintenance');
 
     // fake some settings
     $CFG->docroot = 'http://docs.moodle.org';
@@ -127,7 +127,7 @@ if (!core_tables_exist()) {
         echo '<br />';
         notice_yesno(get_string('doyouagree'), "index.php?agreelicense=1&lang=$CFG->lang",
                                                "http://docs.moodle.org/en/License");
-        print_footer('upgrade');
+        print_footer();
         die;
     }
     if (empty($confirmrelease)) {
@@ -147,7 +147,7 @@ if (!core_tables_exist()) {
             print_continue("index.php?agreelicense=1&amp;confirmrelease=1&amp;lang=$CFG->lang");
         }
 
-        print_footer('upgrade');
+        print_footer();
         die;
     }
 
@@ -178,6 +178,8 @@ if (empty($CFG->version)) {
 }
 
 if ($version > $CFG->version) {  // upgrade
+    $PAGE->set_generaltype('maintenance');
+
     $a->oldversion = "$CFG->release ($CFG->version)";
     $a->newversion = "$release ($version)";
     $strdatabasechecking = get_string('databasechecking', '', $a);
@@ -187,7 +189,7 @@ if ($version > $CFG->version) {  // upgrade
         print_header($strdatabasechecking, $stradministration, $navigation, '', '', false, '&nbsp;', '&nbsp;');
 
         notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=1', 'index.php');
-        print_footer('upgrade');
+        print_footer();
         exit;
 
     } else if (empty($confirmrelease)){
@@ -212,7 +214,7 @@ if ($version > $CFG->version) {  // upgrade
             print_continue('index.php?confirmupgrade=1&amp;confirmrelease=1');
         }
 
-        print_footer('upgrade');
+        print_footer();
         die;
 
     } elseif (empty($confirmplugins)) {
index 667ee3ab98464557fa492a27cb314fe05a8ea31b..58bd013e705255688f3332f0a17c17c647996588 100644 (file)
@@ -83,13 +83,6 @@ if (empty($SITE->fullname)) {
     echo '</form>';
 
 } else {
-    // Note: MDL-19010 there will be further changes to printing header and blocks.
-    // The code will be much nicer than this eventually.
-    $pageblocks = blocks_setup($PAGE);
-
-    $preferred_width_left = blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]);
-    $preferred_width_right = blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]);
-
     if ($PAGE->user_allowed_editing()) {
         $options = $PAGE->url->params();
         if ($PAGE->user_is_editing()) {
@@ -111,22 +104,6 @@ if (empty($SITE->fullname)) {
 
     print_header("$SITE->shortname: " . implode(": ",$visiblepathtosection), $SITE->fullname, $navigation, $focus, '', true, $buttons, '');
 
-    echo '<table id="layout-table"><tr>';
-    $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
-    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>';
-            break;
-            case 'middle':
-    echo '<td id="middle-column">';
-    print_container_start();
-    echo '<a name="startofcontent"></a>';
-
     if ($errormsg !== '') {
         notify ($errormsg);
 
@@ -149,22 +126,6 @@ if (empty($SITE->fullname)) {
 
     echo '</div>';
     echo '</form>';
-
-    print_container_end();
-    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>';
-    }
-            break;
-        }
-    }
-    echo '</tr></table>';
 }
 
 print_footer();
index e5105cdc0041c8a8a8d0bd3d52a890ef45a3cfe3..e329660ef1540b88f3a9859bb45418e0a6447677 100644 (file)
@@ -44,7 +44,6 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
 
     $ADMIN->add('modules', new admin_category('blocksettings', get_string('blocks')));
     $ADMIN->add('blocksettings', new admin_page_manageblocks());
-    $ADMIN->add('blocksettings', new admin_externalpage('stickyblocks', get_string('stickyblocks', 'admin'), "$CFG->wwwroot/$CFG->admin/stickyblocks.php"));
     if ($blocks = $DB->get_records('block')) {
         $blockbyname = array();
 
diff --git a/admin/stickyblocks.php b/admin/stickyblocks.php
deleted file mode 100644 (file)
index 15b7e46..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-<?PHP // $Id$
-
-    require_once('../config.php');
-    require_once($CFG->dirroot.'/lib/pagelib.php');
-
-    $pt  = optional_param('pt', null, PARAM_SAFEDIR); //alhanumeric and -
-
-    $pagetypes = array('my-index' => array('id' => 'my-index',
-                                              'lib' => '/lib/pagelib.php',
-                                              'name' => get_string('mymoodle','admin')),
-                       PAGE_COURSE_VIEW => array('id' => PAGE_COURSE_VIEW,
-                                                'lib' => '/lib/pagelib.php',
-                                                'name' => get_string('stickyblockscourseview','admin'))
-                       // ... more?
-                       );
-
-    // for choose_from_menu
-    $options = array();
-    foreach ($pagetypes as $p) {
-        $options[$p['id']] = $p['name'];
-    }
-
-    require_login();
-
-    require_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM));
-
-    // first thing to do is print the dropdown menu
-
-    $strtitle = get_string('stickyblocks','admin');
-    $strheading = get_string('adminhelpstickyblocks');
-
-
-
-    if (!empty($pt)) {
-
-        require_once($CFG->dirroot.$pagetypes[$pt]['lib']);
-
-        define('ADMIN_STICKYBLOCKS',$pt);
-
-        $PAGE = page_create_object($pt, SITEID);
-        $blocks = blocks_setup($PAGE, BLOCKS_PINNED_TRUE);
-        $blocks_preferred_width = bounded_number(180, blocks_preferred_width($blocks[BLOCK_POS_LEFT]), 210);
-
-        $navlinks = array(array('name' => get_string('administration'),
-                                'link' => "$CFG->wwwroot/$CFG->admin/index.php",
-                                'type' => 'misc'));
-        $navlinks[] = array('name' => $strtitle, 'link' => null, 'type' => 'misc');
-        $navigation = build_navigation($navlinks);
-        print_header($strtitle,$strtitle,$navigation);
-
-        echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
-        echo '<tr valign="top">';
-
-        echo '<td valign="top" style="width: '.$blocks_preferred_width.'px;" id="left-column">';
-        print_container_start();
-        blocks_print_group($PAGE, $blocks, BLOCK_POS_LEFT);
-        print_container_end();
-        echo '</td>';
-        echo '<td valign="top" id="middle-column">';
-        print_container_start();
-
-    } else {
-        require_once($CFG->libdir.'/adminlib.php');
-        admin_externalpage_setup('stickyblocks');
-        admin_externalpage_print_header();
-    }
-
-
-    print_box_start();
-    print_heading($strheading);
-    popup_form("$CFG->wwwroot/$CFG->admin/stickyblocks.php?pt=", $options, 'selecttype', $pt, 'choose', '', '', false, 'self', get_string('stickyblockspagetype','admin').': ');
-    echo '<p>'.get_string('stickyblocksduplicatenotice','admin').'</p>';
-    print_box_end();
-
-
-    if (!empty($pt)) {
-        print_container_end();
-        echo '</td>';
-        echo '<td valign="top" style="width: '.$blocks_preferred_width.'px;" id="right-column">';
-        print_container_start();
-        blocks_print_group($PAGE, $blocks, BLOCK_POS_RIGHT);
-        print_container_end();
-        echo '</td>';
-        echo '</tr></table>';
-        print_footer();
-    } else {
-        admin_externalpage_print_footer();
-    }
-
-?>
index 1ab1eae8bc47acbddc2b4d2eaa6114d16ae38d63..9f1bf0159db7a80dfd1e05aa05efb88575e4de4a 100644 (file)
@@ -331,81 +331,95 @@ class block_base {
     }
 
     /**
-     * Display the block!
+     * Return a block_contents oject representing the full contents of this block.
+     *
+     * This internally calls ->get_content(), and then adds the editing controls etc.
+     *
+     * You probably should not override this method, but instead override
+     * {@link html_attributes()}, {@link formatted_contents()} or {@link get_content()},
+     * {@link hide_header()}, {@link (get_edit_controls)}, etc.
+     *
+     * @return block_contents a represntation of the block, for rendering.
+     * @since Moodle 2.0.
      */
-    function _print_block() {
-        global $COURSE;
+    public function get_content_for_output($output) {
+        global $CFG;
 
-        // is_empty() includes a call to get_content()
-        if ($this->is_empty() && empty($COURSE->javascriptportal)) {
-            if (empty($this->edit_controls)) {
-                // No content, no edit controls, so just shut up
-                return;
-            } else {
-                // No content but editing, so show something at least
-                $this->_print_shadow();
-            }
-        } else {
-            if ($this->hide_header() && empty($this->edit_controls)) {
-                // Header wants to hide, no edit controls to show, so no header it is
-                print_side_block(NULL, $this->content->text, NULL, NULL, $this->content->footer, $this->html_attributes());
-            } else {
-                // The full treatment, please. Include the title text.
-                print_side_block($this->_title_html(), $this->content->text, NULL, NULL, $this->content->footer, $this->html_attributes(), $this->title);
-            }
-        }
-    }
+        $bc = new block_contents();
+        $bc->blockinstanceid = $this->instance->id;
+        $bc->blockpositionid = $this->instance->blockpositionid;
 
-    /**
-     * Block contents are missing. Simply display an empty block so that
-     * edit controls are accessbile to the user and they are aware that this
-     * block is in place, even if empty.
-     */
-    function _print_shadow() {
-        print_side_block($this->_title_html(), '&nbsp;', NULL, NULL, '', array('class' => 'hidden'), $this->title);
-    }
+        $attributes = $this->html_attributes();
+        if (isset($attributes['id'])) {
+            $bc->id = $attributes['id'];
+            unset($attributes['id']);
+        }
+        if (isset($attributes['class'])) {
+            $bc->set_classes($attributes['class']);
+            unset($attributes['class']);
+        }
+        $bc->attributes = $attributes;
 
+        if (!$this->hide_header()) {
+            $bc->title = $this->title;
+        }
+        $bc->content = $this->formatted_contents($output);
+        if (!empty($this->content->footer)) {
+            $bc->footer = $this->content->footer;
+        }
 
-    function _title_html() {
-        global $OUTPUT;
-
-        //Accessibility: validation, can't have <div> inside <h2>, use <span>.
-        $title = '<div class="title">';
-
-        if (!empty($CFG->allowuserblockhiding)) {
-            //Accessibility: added 'alt' text for the +- icon.
-            //Theme the buttons using, Admin - Miscellaneous - smartpix.
-            $strshow = addslashes_js(get_string('showblocka', 'access', strip_tags($this->title)));
-            $strhide = addslashes_js(get_string('hideblocka', 'access', strip_tags($this->title)));
-            $title .= '<input type="image" src="'.$OUTPUT->old_icon_url('t/switch_minus') . '" '. 
-                'id="togglehide_inst'.$this->instance->id.'" '.
-                'onclick="elementToggleHide(this, true, function(el) {'.
-                'return findParentNode(el, \'DIV\', \'sideblock\'); },'.
-                ' \''.$strshow.'\', \''.$strhide.'\'); return false;" '.
-                'alt="'.$strhide.'" title="'.$strhide.'" class="hide-show-image" />';
+        if ($this->is_empty() && !$bc->controls) {
+            return null;
         }
 
-        //Accesssibility: added H2 (was in, weblib.php: print_side_block)
-        $title .= '<h2>'.format_string($this->title).'</h2>';
+        if ($this->page->user_is_editing()) {
+            $bc->controls = $this->get_edit_controls($output);
+        }
 
-        if ($this->edit_controls !== NULL) {
-            $title .= $this->edit_controls;
+        if (empty($CFG->allowuserblockhiding)) {
+            $bc->collapsible = block_contents::NOT_HIDEABLE;
+        } else if (get_user_preferences('block' . $bc->blockinstanceid . 'hidden', false)) {
+            $bc->collapsible = block_contents::HIDDEN;
+        } else {
+            $bc->collapsible = block_contents::VISIBLE;
         }
 
-        $title .= '</div>';
-        return $title;
+        $bc->annotation = ''; // TODO
+
+        return $bc;
     }
 
     /**
-     * Sets class $edit_controls var with correct block manipulation links.
+     * Convert the contents of the block to HTML.
      *
-     * @uses $CFG
-     * @uses $USER
-     * @param stdObject $options ?
-     * @todo complete documenting this function. Define $options.
+     * This is used by block base classes like block_list to convert the structured
+     * $this->content->list and $this->content->icons arrays to HTML. So, in most
+     * blocks, you probaby want to override the {@link get_contents()} method,
+     * which generates that structured representation of the contents.
+     *
+     * @param $output The core_renderer to use when generating the output.
+     * @return string the HTML that should appearn in the body of the block.
+     * @since Moodle 2.0.
      */
-    function _add_edit_controls($options) {
-        global $CFG, $USER, $OUTPUT;
+    protected function formatted_contents($output) {
+        $this->get_content();
+        if (!empty($this->content->text)) {
+            return $this->content->text;
+        } else {
+            return '';
+        }
+    }
+
+    /**
+     * Get the appropriate list of editing icons for this block. This is used
+     * to set {@link block_contents::$controls} in {@link get_contents_for_output()}.
+     *
+     * @param $output The core_renderer to use when generating the output. (Need to get icon paths.)
+     * @return an array in the format for {@link block_contents::$controls}
+     * @since Moodle 2.0.
+     */
+    protected function get_edit_controls($output) {
+        global $CFG, $DB;
 
         // TODO - temporary hack to get the block context only if it already exists.
         global $DB;
@@ -415,86 +429,50 @@ class block_base {
             $context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
         }
 
-        // context for site or course, i.e. participant list etc
-        // check to see if user can edit site or course blocks.
-        // blocks can appear on other pages such as mod and blog pages...
-
-        if (!$this->page->user_can_edit_blocks()) {
-            return null;
-        }
-
-        if (!isset($this->str)) {
-            $this->str->delete    = get_string('delete');
-            $this->str->moveup    = get_string('moveup');
-            $this->str->movedown  = get_string('movedown');
-            $this->str->moveright = get_string('moveright');
-            $this->str->moveleft  = get_string('moveleft');
-            $this->str->hide      = get_string('hide');
-            $this->str->show      = get_string('show');
-            $this->str->configure = get_string('configuration');
-            $this->str->assignroles = get_string('assignroles', 'role');
-        }
+        $returnurlparam = '&amp;returnurl=' . urlencode($this->page->url->out_returnurl());
+        $actionurl = $CFG->wwwroot.'/blocks/action.php?block=' . $this->instance->id .
+                '&amp;sesskey=' . sesskey() . $returnurlparam;
 
-        // RTL support - exchange right and left arrows
-        if (right_to_left()) {
-            $rightarrow = 't/left';
-            $leftarrow  = 't/right';
-        } else {
-            $rightarrow = 't/right';
-            $leftarrow  = 't/left';
-        }
+        $controls = array();
 
-        $movebuttons = '<div class="commands">';
-
-        if ($this->instance->visible) {
-            $icon = 't/hide';
-            $title = $this->str->hide;
-        } else {
-            $icon = 't/show';
-            $title = $this->str->show;
+        // Assign roles icon.
+        if ($context->contextlevel == CONTEXT_BLOCK && has_capability('moodle/role:assign', $context)) {
+            $controls[] = array('url' => $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id,
+                    'icon' => $output->old_icon_url('i/roles'), 'caption' => get_string('assignroles', 'role'));
         }
 
-        $page = $this->page;
-        $script = $page->url->out(false, array('instanceid' => $this->instance->id, 'sesskey' => sesskey()));
-
-        $movebuttons .= '<a class="icon roles" title="'. $this->str->assignroles .'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id.'">' .
-                        '<img src="'.$OUTPUT->old_icon_url('i/roles') . '" alt="'.$this->str->assignroles.'" /></a>';
-
-        // TODO MDL-19010 fix and re-enable.
-        if (false && $this->user_can_edit()) {
-            $movebuttons .= '<a class="icon hide" title="'. $title .'" href="'.$script.'&amp;blockaction=toggle">' .
-                            '<img src="'. $OUTPUT->old_icon_url($icon) .'" alt="'.$title.'" /></a>';
-        }
+        if ($this->user_can_edit() && $this->page->user_can_edit_blocks()) {
+            // Show/hide icon.
+            if ($this->instance->visible) {
+                $controls[] = array('url' => $actionurl . '&amp;action=hide',
+                        'icon' => $output->old_icon_url('t/hide'), 'caption' => get_string('hide'));
+            } else {
+                $controls[] = array('url' => $actionurl . '&amp;action=show',
+                        'icon' => $output->old_icon_url('t/show'), 'caption' => get_string('show'));
+            }
 
-        if ($options & BLOCK_CONFIGURE && $this->user_can_edit()) {
-            $movebuttons .= '<a class="icon edit" title="'. $this->str->configure .'" href="'.$script.'&amp;blockaction=config">' .
-                            '<img src="'. $OUTPUT->old_icon_url('t/edit') . '" alt="'. $this->str->configure .'" /></a>';
-        }
+            // Edit config icon.
+            if ($this->instance_allow_multiple() || $this->instance_allow_config()) {
+                $editurl = $CFG->wwwroot . '/blocks/edit.php?block=' . $this->instance->id;
+                if (!empty($this->instance->blockpositionid)) {
+                    $editurl .= '&amp;positionid=' . $this->instance->blockpositionid;
+                }
+                $controls[] = array('url' => $editurl . $returnurlparam,
+                        'icon' => $output->old_icon_url('t/edit'), 'caption' => get_string('configuration'));
+            }
 
-        if ($this->user_can_addto($page)) {
-            $movebuttons .= '<a class="icon delete" title="'. $this->str->delete .'" href="'.$script.'&amp;blockaction=delete">' .
-                            '<img src="'. $OUTPUT->old_icon_url('t/delete') . '" alt="'. $this->str->delete .'" /></a>';
-        }
+            // Delete icon.
+            if ($this->user_can_addto($this->page)) {
+                $controls[] = array('url' => $actionurl . 'action=delete',
+                    'icon' => $output->old_icon_url('t/delete'), 'caption' => get_string('deletet'));
+            }
 
-        if ($options & BLOCK_MOVE_LEFT) {
-            $movebuttons .= '<a class="icon left" title="'. $this->str->moveleft .'" href="'.$script.'&amp;blockaction=moveleft">' .
-                            '<img src="'. $OUTPUT->old_icon_url($leftarrow).'" alt="'. $this->str->moveleft .'" /></a>';
-        }
-        if ($options & BLOCK_MOVE_UP) {
-            $movebuttons .= '<a class="icon up" title="'. $this->str->moveup .'" href="'.$script.'&amp;blockaction=moveup">' .
-                            '<img src="'. $OUTPUT->old_icon_url('t/up') . '" alt="'. $this->str->moveup .'" /></a>';
-        }
-        if ($options & BLOCK_MOVE_DOWN) {
-            $movebuttons .= '<a class="icon down" title="'. $this->str->movedown .'" href="'.$script.'&amp;blockaction=movedown">' .
-                            '<img src="'. $OUTPUT->old_icon_url('t/down') . '" alt="'. $this->str->movedown .'" /></a>';
-        }
-        if ($options & BLOCK_MOVE_RIGHT) {
-            $movebuttons .= '<a class="icon right" title="'. $this->str->moveright .'" href="'.$script.'&amp;blockaction=moveright">' .
-                            '<img src="'. $OUTPUT->old_icon_url($rightarrow).'" alt="'. $this->str->moveright .'" /></a>';
+            // Move icon.
+            $controls[] = array('url' => $this->page->url->out(false, array('moveblockid' => $this->instance->id)),
+                    'icon' => $output->old_icon_url('t/move'), 'caption' => get_string('move'));
         }
 
-        $movebuttons .= '</div>';
-        $this->edit_controls = $movebuttons;
+        return $controls;
     }
 
     /**
@@ -556,7 +534,6 @@ class block_base {
      * Default behavior: print the config_global.html file
      * You don't need to override this if you're satisfied with the above
      *
-     * @uses $CFG
      * @return boolean
      */
     function config_print() {
@@ -597,14 +574,6 @@ class block_base {
     }
     
 
-    /**
-     * Default case: the block wants to be 180 pixels wide
-     * @return int
-     */
-    function preferred_width() {
-        return 180;
-    }
-    
     /**
      * Default return is false - header will be shown
      * @return boolean
@@ -614,18 +583,17 @@ class block_base {
     }
 
     /**
-     * Default case: an id with the instance and a class with our name in it
-     * @return array
-     * @todo finish documenting this function
+     * Return any HTML attributes that you want added to the outer <div> that
+     * of the block when it is output.
+     * @return array attribute name => value.
      */
     function html_attributes() {
         return array(
-            'id' => 'inst'.$this->instance->id, 
-            'class' => 'block_'. $this->name().
-                ($this->edit_controls ? ' block_with_controls' :'')
+            'id' => 'inst' . $this->instance->id, 
+            'class' => 'block_' . $this->name()
         );
     }
-    
+
     /**
      * Given an instance set the class var $instance to it and
      * load class var $config
@@ -727,7 +695,7 @@ class block_base {
         $this->instance_config_save($this->config);
     }
 
-     /**
+    /**
      * Do any additional initialization you may need at the time a new block instance is created
      * @return boolean
      * @todo finish documenting this function
@@ -736,7 +704,7 @@ class block_base {
         return true;
     }
 
-     /**
+    /**
      * Delete everything related to this instance if you have been using persistent storage other than the configdata field.
      * @return boolean
      * @todo finish documenting this function
@@ -745,7 +713,7 @@ class block_base {
         return true;
     }
 
-     /**
+    /**
      * Allows the block class to have a say in the user's ability to edit (i.e., configure) blocks of this type.
      * The framework has first say in whether this will be allowed (e.g., no editing allowed unless in edit mode)
      * but if the framework does allow it, the block can still decide to refuse.
@@ -756,7 +724,7 @@ class block_base {
         return true;
     }
 
-     /**
+    /**
      * Allows the block class to have a say in the user's ability to create new instances of this block.
      * The framework has first say in whether this will be allowed (e.g., no adding allowed unless in edit mode)
      * but if the framework does allow it, the block can still decide to refuse.
@@ -771,11 +739,54 @@ class block_base {
     function get_extra_capabilities() {
         return array('moodle/block:view');
     }
+
+    // Methods deprecated in Moodle 2.0 ========================================
+
+    /**
+     * Default case: the block wants to be 180 pixels wide
+     * @deprecated since Moodle 2.0.
+     * @return int
+     */
+    function preferred_width() {
+        return 180;
+    }
+
+    /** @deprecated since Moodle 2.0. */
+    function _print_block() {
+        throw new coding_exception('_print_block is no longer used. It was a private ' .
+                'method of the block class, only for use by the blocks system. You ' .
+                'should not have been calling it anyway.');
+    }
+
+    /** @deprecated since Moodle 2.0. */
+    function _print_shadow() {
+        throw new coding_exception('_print_shadow is no longer used. It was a private ' .
+                'method of the block class, only for use by the blocks system. You ' .
+                'should not have been calling it anyway.');
+    }
+
+    /** @deprecated since Moodle 2.0. */
+    function _title_html() {
+        throw new coding_exception('_title_html is no longer used. It was a private ' .
+                'method of the block class, only for use by the blocks system. You ' .
+                'should not have been calling it anyway.');
+    }
+
+    /** @deprecated since Moodle 2.0. */
+    function _add_edit_controls() {
+        throw new coding_exception('_add_edit_controls is no longer used. It was a private ' .
+                'method of the block class, only for use by the blocks system. You ' .
+                'should not have been calling it anyway.');
+    }
+
 }
 
 /**
  * Specialized class for displaying a block with a list of icons/text labels
  *
+ * The get_content method should set $this->content->items and (optionally)
+ * $this->content->icons, instead of $this->content->text.
+ *
  * @author Jon Papaioannou
  * @package blocks
  */
@@ -801,31 +812,14 @@ class block_list extends block_base {
         return (empty($this->content->items) && empty($this->content->footer));
     }
 
-    function _print_block() {
-        global $COURSE;
-
-        // is_empty() includes a call to get_content()
-        if ($this->is_empty() && empty($COURSE->javascriptportal)) {
-            if (empty($this->edit_controls)) {
-                // No content, no edit controls, so just shut up
-                return;
-            } else {
-                // No content but editing, so show something at least
-                $this->_print_shadow();
-            }
+    protected function formatted_contents($output) {
+        $this->get_content();
+        if (!empty($this->content->items)) {
+            return $output->list_block_contents($this->content->icons, $this->content->items);
         } else {
-            if ($this->hide_header() && empty($this->edit_controls)) {
-                // Header wants to hide, no edit controls to show, so no header it is
-                print_side_block(NULL, '', $this->content->items, $this->content->icons, 
-                                 $this->content->footer, $this->html_attributes());
-            } else {
-                // The full treatment, please. Include the title text.
-                print_side_block($this->_title_html(), '', $this->content->items, $this->content->icons, 
-                                 $this->content->footer, $this->html_attributes(), $this->title);
-            }
+            return '';
         }
     }
-
 }
 
 ?>
index d01553e1a950a3514c03defd7beffd9bda8c7c04..9ffb57d2dff35f2651c6bf64e903ec2183b8f5b9 100644 (file)
@@ -1,27 +1,6 @@
                 </td>
             </tr>
         </table>
-    <?php print_container_end(); ?>
-    </td>
-<?php
-print '<!-- End page content -->'."\n";
-
-// The right column
-if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
-    echo '<td style="vertical-align: top; width: '. $preferred_width_right .'px;" id="right-column">';
-    echo '<!-- Begin right side blocks -->'."\n";
-    print_container_start();
-    blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-    print_spacer(1, 120, true);
-    print_container_end();
-    echo '<!-- End right side blocks -->'."\n";
-    echo '</td>';
-}
-?>
-
-    </tr>
-</table>
-
 <?php
 
 print_footer($course);
index 3d8986422ef4a7e4774849e2ace26a6ce9ffcc16..4efbc0a5bbe04c1f3d51e13055de9ad33566a3ad 100755 (executable)
@@ -18,18 +18,6 @@ if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
     print_error('invalidcourseid', '', '', $courseid);
 }
 
-// Bounds for block widths
-// more flexible for theme designers taken from theme config.php
-$lmin = (empty($THEME->block_l_min_width)) ? 160 : $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)) ? 160 : $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);
-
 //_____________ new page class code ________
 $pagetype = PAGE_BLOG_VIEW;
 $pageclass = 'page_blog';
@@ -70,12 +58,6 @@ if ($PAGE->user_allowed_editing()) {
     $editing = $PAGE->user_is_editing();
 }
 
-// Calculate the preferred width for left, right and center (both center positions will use the same)
-$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 (!empty($tagid)) {
     $taginstance = $DB->get_record('tag', array('id'=>$tagid));
 } elseif (!empty($tag)) {
@@ -241,25 +223,6 @@ $currenttab = 'blogs';
 require_once($CFG->dirroot .'/user/tabs.php');
 
 
-/// Layout the whole page as three big columns.
-print '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">' . "\n";
-print '<tr valign="top">' . "\n";
-
-/// The left column ...
-if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
-    print '<td style="vertical-align: top; width: '. $preferred_width_left .'px;" id="left-column">' . "\n";
-    print '<!-- Begin left side blocks -->' . "\n";
-    print_container_start();
-    blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-    print_container_end();
-    print '<!-- End left side blocks -->' . "\n";
-    print '</td>' . "\n";
-}
-
-/// Start main column
-print '<!-- Begin page content -->' . "\n";
-print '<td>';
-print_container_start();
 ?>
 <table width="100%">
 <tr>
index d680a13e1b4e07852f58336a9ab90d545536f1e4..5ba15b74fb78302e97bc778d4d46cfea20f3e2c8 100644 (file)
@@ -9,6 +9,7 @@
     $id         = optional_param('id', 0, PARAM_INT);       // course id
     $categoryid = optional_param('category', 0, PARAM_INT); // course category - can be changed in edit form
 
+    $PAGE->set_generaltype('form');
 
 /// basic access control checks
     if ($id) { // editing course
index 299b6aedd15f837a8eece994260a4219947c6340..37032b5eefab551c5d44bb762487b8ba3eff2da2 100644 (file)
@@ -5,53 +5,13 @@
     $module = $course->format;
     require_once($CFG->dirroot.'/mod/'.$module.'/locallib.php');
 
-    // 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);
-  
-    $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);
-
     $strgroups  = get_string('groups');
     $strgroupmy = get_string('groupmy');
     $editing    = $PAGE->user_is_editing();
 
-    echo '<table id="layout-table" cellspacing="0" summary="'.get_string('layouttable').'">';
-    echo '<tr>';
-
-    if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
-        echo '<td style="width:'.$preferred_width_left.'px" id="left-column">';
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-        echo '</td>';
-    }
-
-    echo '<td id="middle-column">'. skip_main_destination();
     $moduleformat = $module.'_course_format_display';
     if (function_exists($moduleformat)) {
         $moduleformat($USER,$course);
     } else { 
         notify('The module '. $module. ' does not support single activity course format');
     }
-    echo '</td>';
-
-    // The right column
-    if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
-        echo '<td style="width:'.$preferred_width_right.'px" id="right-column">';
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-        echo '</td>';
-    }
-
-    echo '</tr>';
-    echo '</table>';
-
-?>
index 7dd42a5302c603511ad66da0531d69a620a5f563..8492a0538331149727c110d4b9e5666c90153f65 100644 (file)
@@ -1,42 +1,11 @@
 <?php // $Id$
       // format.php - course format featuring social forum
       //              included from view.php
-    
-    // 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);
-  
-    $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);
 
     $strgroups  = get_string('groups');
     $strgroupmy = get_string('groupmy');
     $editing    = $PAGE->user_is_editing();
 
-    echo '<table id="layout-table" cellspacing="0" summary="'.get_string('layouttable').'">';
-    echo '<tr>';
-
-    if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
-        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 id="middle-column">';
-    print_container_start();
-    echo skip_main_destination();
     if ($forum = forum_get_course_forum($course->id, 'social')) {
 
     /// Print forum intro above posts  MDL-18483
     } else {
         notify('Could not find or create a social forum here');
     }
-    print_container_end();
-    echo '</td>';
-
-    // The right column
-    if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
-        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>';
-    }
-
-    echo '</tr>';
-    echo '</table>';
-
-?>
index 6e3acffec4e7a0ced993a2401c0728040ad00d4b..c2f923612588961ab02432dfa4ee6731ef2dcbd6 100644 (file)
         $strmovedown = get_string('movedown');
     }
 
-/* Internet Explorer min-width fix. (See theme/standard/styles_layout.css: min-width for Firefox.)
-   Window width: 800px, Firefox 763px, IE 752px. (Window width: 640px, Firefox 602px, IE 588px.)    
-*/
-?>
-
-<!--[if IE]>
-  <style type="text/css">
-  .topics-format { width: expression(document.body.clientWidth < 800 ? "752px" : "auto"); }
-  </style>
-<![endif]-->
-<?php
-/// Layout the whole page as three big columns (was, id="layout-table")
-    echo '<div class="topics-format">';
-
-/// The left column ...
-
-    if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
-        echo '<div id="left-column">';
-        print_container_start();
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-        print_container_end();
-        echo '</div>';
-    }
-    
-/// The right column, BEFORE the middle-column.
-    if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
-        echo '<div id="right-column">';
-        print_container_start();
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-        print_container_end();
-        echo '</div>';
-    }
-
-/// Start main column
-    echo '<div id="middle-column">';
-    print_container_start();
-
-    echo skip_main_destination();
-
     // Print the Your progress icon if the track completion is enabled
     $completioninfo = new completion_info($course);
     $completioninfo->print_help_icon();
                    'sectionmenu', '', get_string('jumpto'), '', '', true);
         echo '</div>';
     }
-
-    print_container_end();
-    echo '</div>';
-
-    echo '</div>';
-    echo '<div class="clearer"></div>';
-
-?>
index 5c570023a6e82fd5a61b5d5bdb7e6393ce3bd2b7..8601ccf46b1d4c010d1c63174230a2f681a2fa10 100644 (file)
     }
 
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
-/* Internet Explorer min-width fix. (See theme/standard/styles_layout.css: min-width for Firefox.)
-   Window width: 800px, Firefox 763px, IE 752px. (Window width: 640px, Firefox 602px, IE 588px.)    
-*/
-?>
-
-<!--[if IE]>
-  <style type="text/css">
-  .weeks-format { width: expression(document.body.clientWidth < 800 ? "752px" : "auto"); }
-  </style>
-<![endif]-->
-<?php
-/// Layout the whole page as three big columns (was, id="layout-table")
-    echo '<div class="weeks-format">';
-
-/// The left column ...
-
-    if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
-        print_container_start();
-        echo '<div id="left-column">';
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-        echo '</div>';
-        print_container_end();
-    }
-    
-/// The right column, BEFORE the middle-column.
-    if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
-        print_container_start();
-        echo '<div id="right-column">';
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-        echo '</div>';
-        print_container_end();
-    }
-
-/// Start main column
-    echo '<div id="middle-column">';
-    print_container_start();
-
-    echo skip_main_destination();
 
     //Print the Your progress icon if the track completion is enabled
     $completioninfo = new completion_info($course);
 
         // Note, 'right side' is BEFORE content.
         echo '<li id="section-0" class="section main" >';
-       echo '<div class="left side">&nbsp;</div>';
+        echo '<div class="left side">&nbsp;</div>';
         echo '<div class="right side" >&nbsp;</div>';        
         echo '<div class="content">';
         
                    'sectionmenu', '', get_string('jumpto'), '', '', true);
         echo '</div>';
     }
-
-    print_container_end();
-    echo '</div>';
-
-    echo '</div>';
-    echo '<div class="clearer"></div>';
-
-?>
index e8c4f4cce4d585844b5c8a743989e8523ba602b5..924b7f9c391cef955ca864bb01d40330a6614ceb 100644 (file)
@@ -14,6 +14,8 @@
     $return = optional_param('return', 0, PARAM_BOOL); //return to course/view.php if false or mod/modname/view.php if true
     $type   = optional_param('type', '', PARAM_ALPHANUM);
 
+    $PAGE->set_generaltype('form');
+
     require_login();
 
     if (!empty($add)) {
index 7f445849cf1b78e7ce0a8c04cc130327b71dd7cc..562af297bd2db9c16fa575afebb17869930c292f 100644 (file)
@@ -25,25 +25,10 @@ if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
     die;
 }
 
-$PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
-$pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);
-
-if (!empty($instanceid)) {
-    throw new moodle_exception('ajax blocks editing currently broken. MDL-19010');
-//    $blockinstance = blocks_find_instance($instanceid, $pageblocks);
-//    if (!$blockinstance || $blockinstance->pageid != $course->id
-//                        || $blockinstance->pagetype != 'course-view') {
-//        error_log('AJAX commands.php: Bad block ID '.$instanceid);
-//        die;
-//    }
-}
-
 $context = get_context_instance(CONTEXT_COURSE, $course->id);
 require_login($course);
 require_capability('moodle/course:update', $context);
 
-
-
 // OK, now let's process the parameters and do stuff
 switch($_SERVER['REQUEST_METHOD']) {
     case 'POST':
index a3e58eea4856429aefb0746b2cb76b689b27cb60..4c7288d517dce4c13f369ec93e335d122c68497e 100644 (file)
     $PAGE->set_pagetype('course-view-' . $course->format);
     $PAGE->set_other_editing_capability('moodle/course:manageactivities');
 
-    // Note: MDL-19010 there will be further changes to printing header and blocks.
-    // The code will be much nicer than this eventually.
-    $pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);
-
     if ($reset_user_allowed_editing) {
         // ugly hack
         unset($PAGE->_user_allowed_editing);
index aee1d81e2ec74e130d0dff0aa285d6b69a704cca..d6b680c2f950959202194e31b20c80c74c45c087 100644 (file)
--- a/index.php
+++ b/index.php
     require_once($CFG->dirroot .'/course/lib.php');
     require_once($CFG->libdir .'/filelib.php');
 
-    // 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);
-
     // check if major upgrade needed - also present in login/index.php
     if (empty($CFG->version) or (int)$CFG->version < 2009011900 or !empty($CFG->adminsetuppending)) { //1.9 or older
         @require_logout();
     $PAGE->set_url('');
     $PAGE->set_docs_path('');
     $PAGE->set_generaltype('home');
-    $pageblocks = blocks_setup($PAGE);
     $editing = $PAGE->user_is_editing();
-    $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);
-    print_header($SITE->fullname, $SITE->fullname, 'home', '', '', true, '', user_login_string($SITE).$langmenu);
-
-?>
-
-
-<table id="layout-table" summary="layout">
-  <tr>
-  <?php
-    $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
-    foreach ($lt as $column) {
-        switch ($column) {
-            case 'left':
-    if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
-        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">'. skip_main_destination();
-
-    print_container_start();
+    $PAGE->set_title($SITE->fullname);
+    $PAGE->set_heading($SITE->fullname);
+    echo $OUTPUT->header('', user_login_string($SITE) . $langmenu);
 
 /// Print Section
     if ($SITE->numsections > 0) {
         echo '<br />';
     }
 
-    print_container_end();
-
-    echo '</td>';
-            break;
-            case 'right':
-    // The right column
-    if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing || $PAGE->user_allowed_editing()) {
-        echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
-        print_container_start();
-        if ($PAGE->user_allowed_editing()) {
-            echo '<div style="text-align:center">'.update_course_icon($SITE->id).'</div>';
-            echo '<br />';
-        }
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-        print_container_end();
-        echo '</td>';
-    }
-            break;
-        }
-    }
-?>
-
-  </tr>
-</table>
-
-
-<?php
-    print_footer();
-?>
+    echo $OUTPUT->footer();
index 0cc136f75ece28f1e61872a966a2131f4e69d681..283140b00f43c124e826a6fb0e0d0e92022b8607 100644 (file)
@@ -146,6 +146,7 @@ require_once($CFG->libdir.'/weblib.php');
 require_once($CFG->libdir.'/outputlib.php');
 require_once($CFG->libdir.'/dmllib.php');
 require_once($CFG->libdir.'/moodlelib.php');
+require_once($CFG->libdir .'/pagelib.php');
 require_once($CFG->libdir.'/deprecatedlib.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/environmentlib.php');
index 62e7408c57e91ea0243f04c3464edd75c1aeb9cd..3cccbf97580e2e90fa4d3a7619ec29b5856e2322 100644 (file)
@@ -5046,143 +5046,57 @@ function admin_externalpage_setup($section, $extrabutton = '',
  * @param string $focus focus element
  */
 function admin_externalpage_print_header($focus='') {
+    global $CFG, $PAGE, $SITE, $THEME;
 
     if (!is_string($focus)) {
         $focus = ''; // BC compatibility, there used to be adminroot parameter
     }
 
-    global $CFG, $PAGE, $SITE, $THEME;
-
-    define('ADMIN_EXT_HEADER_PRINTED', 'true');
-
-    if (!empty($SITE->fullname) and !empty($SITE->shortname)) {
-        // Note: MDL-19010 there will be further changes to printing header and blocks.
-        // The code will be much nicer than this eventually.
-        $pageblocks = blocks_setup($PAGE);
-
-        $preferred_width_left = blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]);
-        $preferred_width_right = blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]);
-
-        $adminroot = admin_get_root(false, false); //settings not required - only pages
-
-        // fetch the path parameter
-        $section = $PAGE->url->param('section');
-        $current = $adminroot->locate($section, true);
-        $visiblepathtosection = array_reverse($current->visiblepath);
-
-        if ($PAGE->user_allowed_editing()) {
-            $options = $PAGE->url->params();
-            if ($PAGE->user_is_editing()) {
-                $caption = get_string('blockseditoff');
-                $options['adminedit'] = 'off';
-            } else {
-                $caption = get_string('blocksediton');
-                $options['adminedit'] = 'on';
-            }
-            $buttons = print_single_button($PAGE->url->out(false), $options, $caption, 'get', '', true);
-        }
-
-        $navlinks = array();
-        foreach ($visiblepathtosection as $element) {
-            $navlinks[] = array('name' => $element, 'link' => null, 'type' => 'misc');
-        }
-        $navigation = build_navigation($navlinks);
-
-        print_header("$SITE->shortname: " . implode(": ",$visiblepathtosection), $SITE->fullname, $navigation, $focus, '', true, $buttons, '');
-
-        echo '<table id="layout-table" summary=""><tr>';
-
-        $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
-        foreach ($lt as $column) {
-            $lt1[] = $column;
-            if ($column == 'middle') break;
-        }
-        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>';
-                break;
-
-                case 'middle':
-                    echo '<td id="middle-column">';
-                    print_container_start(true);
-                    $THEME->open_header_containers++; // this is hacky workaround for the print_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>';
-                    }
-                break;
-            }
-        }
-    } else {
+    if (empty($SITE->fullname) || empty($SITE->shortname)) {
+        // During initial install.
         $strinstallation = get_string('installation', 'install');
         $strsettings = get_string('settings');
         $navigation = build_navigation(array(array('name'=>$strsettings, 'link'=>null, 'type'=>'misc')));
         print_header($strinstallation, $strinstallation, $navigation, "", "", false, "&nbsp;", "&nbsp;");
+        return;
     }
-}
 
-/**
- * Print footer on admin page - please use normal print_footer() instead
- */
-function admin_externalpage_print_footer() {
-
-    global $CFG, $PAGE, $SITE, $THEME;
+    // Normal case.
+    $adminroot = admin_get_root(false, false); //settings not required - only pages
 
-    define('ADMIN_EXT_FOOTER_PRINTED', 'true');
+    // fetch the path parameter
+    $section = $PAGE->url->param('section');
+    $current = $adminroot->locate($section, true);
+    $visiblepathtosection = array_reverse($current->visiblepath);
 
-    if (!empty($SITE->fullname)) {
-        $pageblocks = blocks_setup($PAGE);
-        $preferred_width_left = blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]);
-        $preferred_width_right = blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]);
-
-        $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
-        foreach ($lt as $column) {
-            if ($column != 'middle') {
-                array_shift($lt);
-            } else if ($column == 'middle') {
-                break;
-            }
+    if ($PAGE->user_allowed_editing()) {
+        $options = $PAGE->url->params();
+        if ($PAGE->user_is_editing()) {
+            $caption = get_string('blockseditoff');
+            $options['adminedit'] = 'off';
+        } else {
+            $caption = get_string('blocksediton');
+            $options['adminedit'] = 'on';
         }
-        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>';
-                break;
-
-                case 'middle':
-                    print_container_end();
-                    $THEME->open_header_containers--; // this is hacky workaround for the print_error()/notice() autoclosing problems on admin pages
-                    echo '</td>';
-                break;
+        $buttons = print_single_button($PAGE->url->out(false), $options, $caption, 'get', '', true);
+    }
 
-                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>';
-                    }
-                break;
-            }
-        }
-        echo '</tr></table>';
+    $navlinks = array();
+    foreach ($visiblepathtosection as $element) {
+        $navlinks[] = array('name' => $element, 'link' => null, 'type' => 'misc');
     }
+    $navigation = build_navigation($navlinks);
+
+    print_header("$SITE->shortname: " . implode(": ",$visiblepathtosection), $SITE->fullname, $navigation, $focus, '', true, $buttons, '');
+}
+
+/**
+ * @deprecated since Moodle 1.9. Please use normal print_footer() instead
+ */
+function admin_externalpage_print_footer() {
+// Still 103 referernces in core code. Don't do debugging output yet.
+//    debugging('admin_externalpage_print_footer is deprecated. Please  use print_footer ' .
+//            '(or even $OUTPUT->footer() instead.', DEBUG_DEVELOPER);
     print_footer();
 }
 
index 897f12986a81053dcaf9b45a23ecc8c28a5414f4..1e88bcac94c27f3aa266b04f5a597da3eb481081 100644 (file)
@@ -51,6 +51,8 @@ function setup_core_javascript(page_requirements_manager $requires) {
         $requires->yui_lib('logger');
     }
 
+    $requires->skip_link_to('maincontent', get_string('tocontent', 'access'));
+
     // Note that, as a short-cut, the code 
     // $js = "document.body.className += ' jsenabled';\n";
     // is hard-coded in {@link page_requirements_manager::get_top_of_body_code)
index 0f505cbb9f94537667c1e7ef16934c7f21e138a3..02cb6af8ca46dcb61dc8c5389e00ed2fac88779f 100644 (file)
 /**
  * Block Class and Functions
  *
- * @todo Document what this file does
- * 
+ * This file defines the {@link block_manager} class, 
+ *
  * @package   moodlecore
  * @copyright 1999 onwards Martin Dougiamas  http://dougiamas.com
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
- /**
 * Block Defines
 */
+/**
+ * Block Defines
+ */
 define('BLOCK_MOVE_LEFT',   0x01);
 define('BLOCK_MOVE_RIGHT',  0x02);
 define('BLOCK_MOVE_UP',     0x04);
@@ -41,19 +41,19 @@ define('BLOCKS_PINNED_TRUE',0);
 define('BLOCKS_PINNED_FALSE',1);
 define('BLOCKS_PINNED_BOTH',2);
 
-require_once($CFG->libdir.'/pagelib.php');
-
 /**
+ * Exception thrown when someone tried to do something with a block that does
+ * not exist on a page.
  *
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @package moodlecore
+ * @copyright 2009 Tim Hunt
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
  */
 class block_not_on_page_exception extends moodle_exception {
     /**
      * Contructor
-     *
-     * @param int $instanceid
-     * @param object $page
+     * @param int $instanceid the block instance id of the block that was looked for.
+     * @param object $page the current page.
      */
     public function __construct($instanceid, $page) {
         $a = new stdClass;
@@ -64,47 +64,36 @@ class block_not_on_page_exception extends moodle_exception {
 }
 
 /**
- * Block Manager
- *
  * This class keeps track of the block that should appear on a moodle_page.
- * The page to work with as passed to the constructor.
- * The only fields of moodle_page that is uses are ->context, ->pagetype and
- * ->subpage, so instead of passing a full moodle_page object, you may also
- * pass a stdClass object with those three fields. These field values are read
- * only at the point that the load_blocks() method is called. It is the caller's
- * responsibility to ensure that those fields do not subsequently change.
  *
+ * The page to work with as passed to the constructor.
  *
- * Note about the weird 'implements ArrayAccess' part of the declaration:
- *
- * ArrayAccess is a magic PHP5 thing. If your class implements the ArrayAccess
- * interface, then other code can use the $object[$index] syntax, and it will
- * call the offsetGet method of the object.
- * See http://php.net/manual/en/class.arrayaccess.php
- *
- * So, why do we do this here? Basically, some of the deprecated blocks methods
- * like blocks_setup used to return an array of blocks on the page, with array
- * keys BLOCK_POS_LEFT, BLOCK_POS_RIGHT. We can keep legacy code that calls those
- * deprecated functions mostly working by changing blocks_setup to return the
- * block_manger object, and then use 'implements ArrayAccess' so that the right
- * thing happens when legacy code does something like $pageblocks[BLOCK_POS_LEFT].
- *
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @package moodlecore
+ * @copyright 2009 Tim Hunt
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
  */
-class block_manager implements ArrayAccess {
+class block_manager {
 
 /// Field declarations =========================================================
-    /** @var object */
+
+    /** @var moodle_page the moodle_page we aremanaging blocks for. */
     protected $page;
-    /** @var array */
+
+    /** @var array region name => 1.*/
     protected $regions = array();
-    /** @var string */
-    protected $defaultregion;
-    /** @var array */
-    protected $allblocks = null; // Will be get_records('blocks');
-    /** @var array */
-    protected $addableblocks = null; // Will be a subset of $allblocks.
+
+    /** @var string the region where new blocks are added.*/
+    protected $defaultregion = null;
+
+    /** @var array will be $DB->get_records('blocks') */
+    protected $allblocks = null;
+
+    /**
+     * @var array blocks that this user can add to this page. Will be a subset
+     * of $allblocks. Access this via the {@link get_addable_blocks()} method
+     * to ensure it is lazy-loaded.
+     */
+    protected $addableblocks = null;
 
     /**
      * Will be an array region-name => array(db rows loaded in load_blocks);
@@ -120,12 +109,19 @@ class block_manager implements ArrayAccess {
     protected $blockinstances = array();
 
     /**
-     * array region-name => array(block_content objects) what acutally needs to
+     * array region-name => array(block_contents objects) what acutally needs to
      * be displayed in each region.
      * @var array
      */
     protected $visibleblockcontent = array();
 
+    /**
+     * array region-name => array(block_contents objects) extra block-like things
+     * to be displayed in each region, before the real blocks.
+     * @var array
+     */
+    protected $extracontent = array();
+
 /// Constructor ================================================================
 
     /**
@@ -146,6 +142,7 @@ class block_manager implements ArrayAccess {
      * @return array the internal names of the regions on this page where block may appear.
      */
     public function get_regions() {
+        $this->page->initialise_theme_and_output();
         return array_keys($this->regions);
     }
 
@@ -158,6 +155,7 @@ class block_manager implements ArrayAccess {
      * to a theme with different block positions.)
      */
     public function get_default_region() {
+        $this->page->initialise_theme_and_output();
         return $this->defaultregion;
     }
 
@@ -243,19 +241,37 @@ class block_manager implements ArrayAccess {
     /**
      * Returns an array of block content objects that exist in a region
      *
-     * @param $region a block region that exists on this page.
-     * @return array of block block_content objects for all the blocks in a region.
+     * @param string $region a block region that exists on this page.
+     * @return array of block block_contents objects for all the blocks in a region.
      */
-    public function get_content_for_region($region) {
+    public function get_content_for_region($region, $output) {
         $this->check_is_loaded();
-        $this->ensure_content_created($region);
+        $this->ensure_content_created($region, $output);
         return $this->visibleblockcontent[$region];
     }
 
+    /**
+     * Determine whether a region contains anything. (Either any real blocks, or
+     * the add new block UI.)
+     * @param string $region a block region that exists on this page.
+     * @return boolean Whether there is anything in this region.
+     */
+    public function region_has_content($region) {
+        if (!$this->is_known_region($region)) {
+            return false;
+        }
+        $this->check_is_loaded();
+        if ($this->page->user_is_editing() && $this->page->user_can_edit_blocks()) {
+            // If editing is on, we need all the block regions visible, for the
+            // move blocks UI.
+            return true;
+        }
+        return !empty($this->blockinstances[$region]) || !empty($this->extracontent[$region]);
+    }
+
     /**
      * Get an array of all of the installed blocks.
      *
-     * @global object
      * @return array contents of the block table.
      */
     public function get_installed_blocks() {
@@ -305,16 +321,29 @@ class block_manager implements ArrayAccess {
         $this->defaultregion = $defaultregion;
     }
 
+    /**
+     * Add something that looks like a block, but which isn't an actual block_instance,
+     * to this page.
+     *
+     * @param block_contents $bc the content of the block like thing.
+     * @param string $region a block region that exists on this page.
+     */
+    public function add_pretend_block($bc, $region) {
+        $this->page->initialise_theme_and_output();
+        $this->check_region_is_known($region);
+        if (array_key_exists($region, $this->visibleblockcontent)) {
+            throw new coding_exception('block_manager has already prepared the blocks in region ' .
+                    $region . 'for output. It is too late to add a pretend block.');
+        }
+        $this->extracontent[$region][] = $bc;
+    }
+
 /// Actions ====================================================================
 
     /**
      * This method actually loads the blocks for our page from the database.
      *
-     * @global object
-     * @global object
-     * @uses SQL_PARAMS_NAMED
      * @param bool|null $includeinvisible
-     * @return void
      */
     public function load_blocks($includeinvisible = NULL) {
         global $DB, $CFG;
@@ -329,8 +358,14 @@ class block_manager implements ArrayAccess {
             return;
         }
 
+        // Ensure we have been initialised.
         if (!isset($this->defaultregion)) {
             $this->page->initialise_theme_and_output();
+            // If there are still no block regions, then there are no blocks on this page.
+            if (empty($this->regions)) {
+                $this->birecordsbyregion = array();
+                return;
+            }
         }
 
         if (is_null($includeinvisible)) {
@@ -365,6 +400,7 @@ class block_manager implements ArrayAccess {
         );
         $sql = "SELECT
                     bi.id,
+                    bp.id AS blockpositionid,
                     bi.blockname,
                     bi.contextid,
                     bi.showinsubcontexts,
@@ -404,16 +440,20 @@ class block_manager implements ArrayAccess {
                 $unknown[] = $bi;
             }
         }
-        $this->birecordsbyregion[$this->defaultregion] = array_merge($this->birecordsbyregion[$this->defaultregion], $unknown);
+
+        // Pages don't necessarily have a defaultregion. The  one time this can
+        // happen is when there are no theme block regions, but the script itself
+        // has a block region in the main content area.
+        if (!empty($this->defaultregion)) {
+            $this->birecordsbyregion[$this->defaultregion] =
+                    array_merge($this->birecordsbyregion[$this->defaultregion], $unknown);
+        }
     }
 
     /**
      * Add a block to the current page, or related pages. The block is added to
      * context $this->page->contextid. If $pagetypepattern $subpagepattern
      *
-     * @global object
-     * @uses CONTEXT_COURSE
-     * @uses CONTEXT_BLOCK
      * @param string $blockname The type of block to add.
      * @param string $region the block region on this page to add the block to.
      * @param integer $weight determines the order where this block appears in the region.
@@ -600,14 +640,10 @@ class block_manager implements ArrayAccess {
      * @param array $instances An array of block instances
      * @return array An array of content vars
      */
-    protected function create_block_content($instances) {
+    protected function create_block_contents($instances, $output) {
         $results = array();
         foreach ($instances as $instance) {
-            if ($instance->is_empty()) {
-                continue;
-            }
-
-            $content = $instance->get_content();
+            $content = $instance->get_content_for_output($output);
             if (!empty($content)) {
                 $results[] = $content;
             }
@@ -615,6 +651,46 @@ class block_manager implements ArrayAccess {
         return $results;
     }
 
+    /**
+     * Return a {@link block_contents} representing the add a new block UI, if
+     * this user is allowed to see it.
+     *
+     * @return block_contents an appropriate block_contents, or null if the user
+     * cannot add any blocks here.
+     */
+    function add_block_ui($output) {
+        global $CFG;
+        if (!$this->page->user_is_editing() || !$this->page->user_can_edit_blocks()) {
+            return null;
+        }
+
+        $bc = new block_contents();
+        $bc->title = get_string('addblock');
+        $bc->add_class('block_adminblock');
+
+        $missingblocks = array_keys($this->get_addable_blocks());
+        if (empty($missingblocks)) {
+            $bc->title = get_string('noblockstoaddhere');
+            return $bc;
+        }
+
+        $menu = array();
+        foreach ($missingblocks as $blockid) {
+            $block = blocks_get_record($blockid);
+            $blockobject = block_instance($block->name);
+            if ($blockobject !== false && $blockobject->user_can_addto($page)) {
+                $menu[$block->id] = $blockobject->get_title();
+            }
+        }
+        asort($menu, SORT_LOCALE_STRING);
+
+        // TODO convert to $OUTPUT.
+        $returnurlparam = '&amp;returnurl=' . urlencode($this->page->url->out_returnurl());
+        $actionurl = $CFG->wwwroot . '/blocks/add.php?sesskey=' . sesskey() . $returnurlparam . '&amp;blocktype=';
+        $bc->content = popup_form($actionurl, $menu, 'add_block', '', get_string('adddots'), '', '', true);
+        return $bc;
+    }
+
     /**
      * Ensure block instances exist for a given region
      * 
@@ -633,66 +709,23 @@ class block_manager implements ArrayAccess {
      *
      * @param string $region The name of the region to check
      */
-    protected function ensure_content_created($region) {
+    protected function ensure_content_created($region, $output) {
         $this->ensure_instances_exist($region);
         if (!array_key_exists($region, $this->visibleblockcontent)) {
-            $this->visibleblockcontent[$region] =
-                    $this->create_block_content($this->blockinstances[$region]);
+            $contents = array();
+            if (array_key_exists($region, $this->extracontent)) {
+                $contents = $this->extracontent[$region];
+            }
+            $contents = array_merge($contents, $this->create_block_contents($this->blockinstances[$region], $output));
+            if ($region == $this->defaultregion) {
+                $addblockui = $this->add_block_ui($output);
+                if ($addblockui) {
+                    $contents[] = $addblockui;
+                }
+            }
+            $this->visibleblockcontent[$region] = $contents;
         }
     }
-
-/// Deprecated stuff for backwards compatibility ===============================
-    /** @deprecated Remains to ensure backwards compatibility */
-    public function offsetSet($offset, $value) {
-    }
-    /** @deprecated Remains to ensure backwards compatibility */
-    public function offsetExists($offset) {
-        return $this->is_known_region($offset);
-    }
-    /** @deprecated Remains to ensure backwards compatibility */
-    public function offsetUnset($offset) {
-    }
-    /** @deprecated Remains to ensure backwards compatibility */
-    public function offsetGet($offset) {
-        return $this->get_blocks_for_region($offset);
-    }
-}
-
-/**
- * This class holds all the information required to view a block.
- *
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @package moodlecore
- */
-abstract class block_content {
-    /** @var int    Id used to uniquely identify this block in the HTML. */
-    public $id = null;
-    /** @var array  Class names to add to this block's container in the HTML. */
-    public $classes = array();
-    /** @var string The content that appears in the title bar at the top of the block (HTML). */
-    public $heading = null;
-    /** @var string Plain text name of this block instance, used in the skip links. */
-    public $title = null;
-    /**
-     * A (possibly empty) array of editing controls. Array keys should be a
-     * short string, e.g. 'edit', 'move' and the values are the HTML of the icons.
-     * @var array
-     */
-    public $editingcontrols = array();
-    /** @var string The content that appears within the block, as HTML. */
-    public $content = null;
-    /** @var string The content that appears at the end of the block. */
-    public $footer = null;
-    /**
-     * Any small print that should appear under the block to explain to the
-     * teacher about the block, for example 'This is a sticky block that was
-     * added in the system context.'
-     * @var string
-     */
-    public $annotation = null;
-    /** @var string The result of the preferred_width method, which the theme may choose to use, or ignore. */
-    public $preferredwidth = null;
-    public abstract function get_content();
 }
 
 /// Helper functions for working with block classes ============================
@@ -739,7 +772,6 @@ function block_instance($blockname, $instance = NULL, $page = NULL) {
 /**
  * Load the block class for a particular type of block.
  *
- * @global object
  * @param string $blockname the name of the block.
  * @return boolean success or failure.
  */
@@ -839,8 +871,6 @@ function blocks_name_allowed_in_format($name, $pageformat) {
 /**
  * Delete a block, and associated data.
  *
- * @global object
- * @uses CONTEXT_BLOCK
  * @param object $instance a row from the block_instances table
  * @param bool $nolongerused legacy parameter. Not used, but kept for bacwards compatibility.
  * @param bool $skipblockstables for internal use only. Makes @see blocks_delete_all_for_context() more efficient.
@@ -859,28 +889,9 @@ function blocks_delete_instance($instance, $nolongerused = false, $skipblockstab
     }
 }
 
-/**
- * @deprecated since 2.0
- * Delete all the blocks from a particular page.
- *
- * @global object
- * @param string $pagetype the page type.
- * @param integer $pageid the page id.
- * @return bool success or failure.
- */
-function blocks_delete_all_on_page($pagetype, $pageid) {
-    global $DB;
-
-    debugging('Call to deprecated function blocks_delete_all_on_page. ' .
-            'This function cannot work any more. Doing nothing. ' .
-            'Please update your code to use another method.', DEBUG_DEVELOPER);
-    return false;
-}
-
 /**
  * Delete all the blocks that belong to a particular context.
  *
- * @global object
  * @param int $contextid the context id.
  */
 function blocks_delete_all_for_context($contextid) {
@@ -895,98 +906,54 @@ function blocks_delete_all_for_context($contextid) {
 }
 
 /**
- * Accepts an array of block instances and checks to see if any of them have content to display
- * (causing them to calculate their content in the process). Returns true or false. Parameter passed
- * by reference for speed; the array is actually not modified.
- *
- * @todo Deprecate this function
- * @deprecated
+ * @deprecated since 2.0
+ * Delete all the blocks from a particular page.
  *
- * @param object $blockmanager
- * @param string $region
- * @return bool
+ * @param string $pagetype the page type.
+ * @param integer $pageid the page id.
+ * @return bool success or failure.
  */
-function blocks_have_content(&$blockmanager, $region) {
-    // TODO deprecate
-    $content = $blockmanager->get_content_for_region($region);
-    return !empty($content);
+function blocks_delete_all_on_page($pagetype, $pageid) {
+    global $DB;
+
+    debugging('Call to deprecated function blocks_delete_all_on_page. ' .
+            'This function cannot work any more. Doing nothing. ' .
+            'Please update your code to use a block_manager method $PAGE->blocks->....', DEBUG_DEVELOPER);
+    return false;
 }
 
 /**
- * This function prints one group of blocks in a page
+ * Dispite what this function is called, it seems to be mostly used to populate
+ * the default blocks when a new course (or whatever) is created.
  *
- * @todo Complete this function
+ * @deprecated since 2.0
  *
- * @global object
- * @global object
- * @global object
- * @param object $page
- * @param object $blockmanager
- * @param string $region
+ * @param object $page the page to add default blocks to.
+ * @return boolean success or failure.
  */
-function blocks_print_group($page, $blockmanager, $region) {
-    global $COURSE, $CFG, $USER;
-
-    $isediting = $page->user_is_editing();
-    $groupblocks = $blockmanager->get_blocks_for_region($region);
-
-    foreach($groupblocks as $instance) {
-        if (($isediting && empty($instance->pinned))) {
-            $options = 0;
-            // The block can be moved up if it's NOT the first one in its position. If it is, we look at the OR clause:
-            // the first block might still be able to move up if the page says so (i.e., it will change position)
-// TODO            $options |= BLOCK_MOVE_UP    * ($instance->weight != 0          || ($page->blocks_move_position($instance, BLOCK_MOVE_UP)   != $instance->position));
-            // Same thing for downward movement
-// TODO            $options |= BLOCK_MOVE_DOWN  * ($instance->weight != $maxweight || ($page->blocks_move_position($instance, BLOCK_MOVE_DOWN) != $instance->position));
-            // For left and right movements, it's up to the page to tell us whether they are allowed
-// TODO            $options |= BLOCK_MOVE_RIGHT * ($page->blocks_move_position($instance, BLOCK_MOVE_RIGHT) != $instance->position);
-// TODO            $options |= BLOCK_MOVE_LEFT  * ($page->blocks_move_position($instance, BLOCK_MOVE_LEFT ) != $instance->position);
-            // Finally, the block can be configured if the block class either allows multiple instances, or if it specifically
-            // allows instance configuration (multiple instances override that one). It doesn't have anything to do with what the
-            // administrator has allowed for this block in the site admin options.
-            $options |= BLOCK_CONFIGURE * ( $instance->instance_allow_multiple() || $instance->instance_allow_config() );
-            $instance->_add_edit_controls($options);
-        }
+function blocks_repopulate_page($page) {
+    global $CFG;
 
-        if (false /* TODO */&& !$instance->visible && empty($COURSE->javascriptportal)) {
-            if ($isediting) {
-                $instance->_print_shadow();
-            }
-        } else {
-            global $COURSE;
-            if(!empty($COURSE->javascriptportal)) {
-                 $COURSE->javascriptportal->currentblocksection = $region;
-            }
-            $instance->_print_block();
-        }
-        if (!empty($COURSE->javascriptportal)
-                    && (empty($instance->pinned) || !$instance->pinned)) {
-            $COURSE->javascriptportal->block_add('inst'.$instance->id, !$instance->visible);
-        }
-    } // End foreach
+    debugging('Call to deprecated function blocks_repopulate_page. ' .
+            'Use a more specific method like blocks_add_default_course_blocks, ' .
+            'or just call $PAGE->blocks->add_blocks()', DEBUG_DEVELOPER);
 
-    if ($page->blocks->get_default_region() == $region &&
-            $page->user_is_editing() && $page->user_can_edit_blocks()) {
-        blocks_print_adminblock($page, $blockmanager);
+    /// If the site override has been defined, it is the only valid one.
+    if (!empty($CFG->defaultblocks_override)) {
+        $blocknames = $CFG->defaultblocks_override;
+    } else {
+        $blocknames = $page->blocks_get_default();
     }
-}
 
-/**
- * This iterates over an array of blocks and calculates the preferred width
- * Parameter passed by reference for speed; it's not modified.
- *
- * @todo Finish this function
- *
- * @param mixed $instances
- */
-function blocks_preferred_width($instances) {
-    $width = 210;
+    $blocks = blocks_parse_default_blocks_list($blocknames);
+    $page->blocks->add_blocks($blocks);
+
+    return true;
 }
 
 /**
- * Get the block record for a particulr blockid.
+ * Get the block record for a particular blockid - that is, a particul type os block.
  *
- * @global object
  * @param $int blockid block type id. If null, an array of all block types is returned.
  * @param bool $notusedanymore No longer used.
  * @return array|object row from block table, or all rows.
@@ -1028,28 +995,8 @@ function blocks_find_block($blockid, $blocksarray) {
 }
 
 /**
- * Simple entry point for anyone that wants to use blocks
+ * TODO Document this function, description
  *
- * @uses BLOCKS_PINNED_FALSE
- * @param object $page
- * @return array
- */
-function blocks_setup(&$page, $pinned = BLOCKS_PINNED_FALSE) {
-    $page->blocks->load_blocks();
-    blocks_execute_url_action($page, $page->blocks);
-    return $page->blocks;
-}
-
-/**
- * @todo Document this function, description
- *
- * @global object
- * @global object
- * @global object
- * @uses BLOCK_MOVE_UP
- * @uses BLOCK_MOVE_DOWN
- * @uses BLOCK_MOVE_RIGHT
- * @uses BLOCK_MOVE_LEFT
  * @param object $page The page object
  * @param object $blockmanager The block manager object
  * @param string $blockaction One of [config, add, delete]
@@ -1272,10 +1219,10 @@ function blocks_execute_action($page, &$blockmanager, $blockaction, $instanceori
 }
 
 /**
+ * TODO deprecate
+ *
  * You can use this to get the blocks to respond to URL actions without much hassle
  *
- * @uses PARAM_ALPHA
- * @uses PARAM_INT
  * @param object $PAGE
  * @param object $blockmanager
  * @param bool $pinned
@@ -1299,6 +1246,7 @@ function blocks_execute_url_action(&$PAGE, &$blockmanager,$pinned=false) {
 }
 
 /**
+ * TODO deprecate
  * This shouldn't be used externally at all, it's here for use by blocks_execute_action()
  * in order to reduce code repetition.
  *
@@ -1348,10 +1296,9 @@ function blocks_execute_repositioning(&$instance, $newpos, $newweight, $pinned=f
 
 
 /**
+ * TODO deprecate
  * Moves a block to the new position (column) and weight (sort order).
  *
- * @global object
- * @global object
  * @param object $instance The block instance to be moved.
  * @param string $destpos BLOCK_POS_LEFT or BLOCK_POS_RIGHT. The destination column.
  * @param string $destweight The destination sort order. If NULL, we add to the end
@@ -1368,9 +1315,9 @@ function blocks_move_block($page, &$instance, $destpos, $destweight=NULL, $pinne
     throw new moodle_exception('Sorry, blocks editing is currently broken. Will be fixed. See MDL-19010.');
 
     if ($pinned) {
-        $blocklist = blocks_get_pinned($page);
+        $blocklist = array(); //blocks_get_pinned($page);
     } else {
-        $blocklist = blocks_get_by_page($page);
+        $blocklist = array(); //blocks_get_by_page($page);
     }
 
     if ($blocklist[$instance->position][$instance->weight]->id != $instance->id) {
@@ -1425,137 +1372,11 @@ function blocks_move_block($page, &$instance, $destpos, $destweight=NULL, $pinne
     return $DB->update_record($table, $instance);
 }
 
-
-/**
- * Returns an array consisting of 2 arrays:
- * 1) Array of pinned blocks for position BLOCK_POS_LEFT
- * 2) Array of pinned blocks for position BLOCK_POS_RIGHT
- *
- * @global object
- * @param object $page
- */
-function blocks_get_pinned($page) {
-    global $DB;
-
-    $visible = true;
-    $select = "pagetype = ?";
-    $params = array($page->pagetype);
-
-     if ($visible) {
-        $select .= " AND visible = 1";
-     }
-
-    $blocks = $DB->get_records_select('block_pinned_old', $select, $params, 'position, weight');
-
-    $regions = $page->blocks->get_regions();
-    $arr = array();
-
-    foreach($regions as $key => $region) {
-        $arr[$region] = array();
-    }
-
-    if(empty($blocks)) {
-        return $arr;
-    }
-
-    foreach($blocks as $block) {
-        $block->pinned = true; // so we know we can't move it.
-        // make up an instanceid if we can..
-        $block->pageid = $page->get_id();
-        $arr[$block->position][$block->weight] = $block;
-    }
-
-    return $arr;
-}
-
-
-/**
- * Similar to blocks_get_by_page(), except that, the array returned includes
- * pinned blocks as well. Pinned blocks are always appended before normal
- * block instances.
- *
- * @param object $page
- * @return array
- */
-function blocks_get_by_page_pinned($page) {
-    $pinned = blocks_get_pinned($page);
-    $user = blocks_get_by_page($page);
-
-    $weights = array();
-
-    foreach ($pinned as $pos => $arr) {
-        $weights[$pos] = count($arr);
-    }
-
-    foreach ($user as $pos => $blocks) {
-        if (!array_key_exists($pos,$pinned)) {
-             $pinned[$pos] = array();
-        }
-        if (!array_key_exists($pos,$weights)) {
-            $weights[$pos] = 0;
-        }
-        foreach ($blocks as $block) {
-            $pinned[$pos][$weights[$pos]] = $block;
-            $weights[$pos]++;
-        }
-    }
-    return $pinned;
-}
-
-
-/**
- * Returns an array of blocks for the page. Pinned blocks are excluded.
- *
- * @todo Check backwards compatibility hack
- * @global object
- * @param object $page
- */
-function blocks_get_by_page($page) {
-    global $DB;
-
-    // TODO check the backwards compatibility hack.
-    return $page->blocks;
-}
-
-/**
- * This function prints the block to admin blocks as necessary
- *
- * @global object
- * @uses SORT_LOCALE_STRING
- * @param object $page
- * @param object $blockmanager
- */
-function blocks_print_adminblock($page, $blockmanager) {
-    global $USER;
-
-    $missingblocks = array_keys($page->blocks->get_addable_blocks());
-
-    if (!empty($missingblocks)) {
-        $strblocks = '<div class="title"><h2>';
-        $strblocks .= get_string('blocks');
-        $strblocks .= '</h2></div>';
-
-        $stradd    = get_string('add');
-        foreach ($missingblocks as $blockid) {
-            $block = blocks_get_record($blockid);
-            $blockobject = block_instance($block->name);
-            if ($blockobject !== false && $blockobject->user_can_addto($page)) {
-                $menu[$block->id] = $blockobject->get_title();
-            }
-        }
-        asort($menu, SORT_LOCALE_STRING);
-
-        $target = $page->url->out(false, array('sesskey' => sesskey(), 'blockaction' => 'add'));
-        $content = popup_form($target.'&amp;blockid=', $menu, 'add_block', '', $stradd .'...', '', '', true);
-        print_side_block($strblocks, $content, NULL, NULL, NULL, array('class' => 'block_adminblock'));
-    }
-}
+// Functions for programatically adding default blocks to pages ================
 
 /**
  * Parse a list of default blocks. See config-dist for a description of the format.
  *
- * @uses BLOCK_POS_LEFT
- * @uses BLOCK_POS_RIGHT
  * @param string $blocksstr
  * @return array
  */
@@ -1572,9 +1393,6 @@ function blocks_parse_default_blocks_list($blocksstr) {
 }
 
 /**
- * @global object
- * @uses BLOCK_POS_LEFT
- * @uses BLOCK_POS_RIGHT
  * @return array the blocks that should be added to the site course by default.
  */
 function blocks_get_default_site_course_blocks() {
@@ -1593,10 +1411,6 @@ function blocks_get_default_site_course_blocks() {
 /**
  * Add the default blocks to a course.
  *
- * @global object
- * @uses SITEID
- * @uses BLOCK_POS_LEFT
- * @uses BLOCK_POS_RIGHT
  * @param object $course a course object.
  */
 function blocks_add_default_course_blocks($course) {
@@ -1646,44 +1460,9 @@ function blocks_add_default_course_blocks($course) {
 
 /**
  * Add the default system-context blocks. E.g. the admin tree.
- *
- * @uses BLOCK_POS_LEFT
- * @uses CONTEXT_SYSTEM
  */
 function blocks_add_default_system_blocks() {
     $page = new moodle_page();
     $page->set_context(get_context_instance(CONTEXT_SYSTEM));
     $page->blocks->add_blocks(array(BLOCK_POS_LEFT => array('admin_tree', 'admin_bookmarks')), 'admin-*');
 }
-
-/**
- * Dispite what this function is called, it seems to be mostly used to populate
- * the default blocks when a new course (or whatever) is created.
- *
- * @deprecated since 2.0
- * @global object
- * @uses DEBUG_DEVELOPER
- * @param object $page the page to add default blocks to.
- * @return boolean success or failure.
- */
-function blocks_repopulate_page($page) {
-    global $CFG;
-
-    debugging('Call to deprecated function blocks_repopulate_page. ' .
-            'Use a more specific method like blocks_add_default_course_blocks, ' .
-            'or just call $PAGE->blocks->add_blocks()', DEBUG_DEVELOPER);
-
-    /// If the site override has been defined, it is the only valid one.
-    if (!empty($CFG->defaultblocks_override)) {
-        $blocknames = $CFG->defaultblocks_override;
-    } else {
-        $blocknames = $page->blocks_get_default();
-    }
-
-    $blocks = blocks_parse_default_blocks_list($blocknames);
-    $page->blocks->add_blocks($blocks);
-
-    return true;
-}
-
-?>
index 77e7c2a3343cd67e59ef79bbb2e8b212a0bad801..57cc4415338d0418932f129c9de6ba0b6fb842fe 100644 (file)
@@ -2225,11 +2225,20 @@ function print_footer($course = NULL, $usercourse = NULL, $return = false) {
  */
 function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array(), $title='') {
     global $OUTPUT;
+
+    // We don't use $heading, becuse it often contains HTML that we don't want.
+    // However, sometimes $title is not set, but $heading is.
+    if (empty($title)) {
+        $title = strip_tags($heading);
+    }
+
+    // Render list contents to HTML if required.
+    if (empty($content) && $list) {
+        $content = $OUTPUT->list_block_contents($icons, $list);
+    }
+
     $bc = new block_contents();
-    $bc->heading = $heading;
     $bc->content = $content;
-    $bc->list = $list;
-    $bc->icons = $icons;
     $bc->footer = $footer;
     $bc->title = $title;
 
@@ -2275,3 +2284,66 @@ function print_side_block_start($heading='', $attributes = array()) {
 function print_side_block_end($attributes = array(), $title='') {
     throw new coding_exception('print_side_block_end has been deprecated. Please cahnge your code to use $OUTPUT->block().');
 }
+
+/**
+ * This was used by old code to see whether a block region had anything in it,
+ * and hence wether that region should be printed.
+ *
+ * We don't ever want old code to print blocks, so we now always return false.
+ * The function only exists to avoid fatal errors in old code.
+ *
+ * @deprecated since Moodle 2.0. always returns false.
+ *
+ * @param object $blockmanager
+ * @param string $region
+ * @return bool
+ */
+function blocks_have_content(&$blockmanager, $region) {
+    debugging('The function blocks_have_content should no longer be used. Blocks are now printed by the theme.');
+    return false;
+}
+
+/**
+ * This was used by old code to print the blocks in a region.
+ * 
+ * We don't ever want old code to print blocks, so this is now a no-op.
+ * The function only exists to avoid fatal errors in old code.
+ *
+ * @deprecated since Moodle 2.0. does nothing.
+ *
+ * @param object $page
+ * @param object $blockmanager
+ * @param string $region
+ */
+function blocks_print_group($page, $blockmanager, $region) {
+    debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.');
+}
+
+/**
+ * This used to be the old entry point for anyone that wants to use blocks.
+ * Since we don't want people people dealing with blocks this way any more,
+ * just return a suitable empty array.
+ *
+ * @deprecated since Moodle 2.0.
+ *
+ * @param object $page
+ * @return array
+ */
+function blocks_setup(&$page, $pinned = BLOCKS_PINNED_FALSE) {
+    debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.');
+    return array(BLOCK_POS_LEFT => array(), BLOCK_POS_RIGHT => array());
+}
+
+/**
+ * This iterates over an array of blocks and calculates the preferred width
+ * Parameter passed by reference for speed; it's not modified.
+ *
+ * @deprecated since Moodle 2.0. Layout is now controlled by the theme.
+ *
+ * @param mixed $instances
+ */
+function blocks_preferred_width($instances) {
+    debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.');
+    $width = 210;
+}
+
index 2c3bc83ab40a349a0142557f5a25eabe922f3742..fe0da0c29e4a82b0bbea70f340043747bc548222 100644 (file)
@@ -617,55 +617,6 @@ date_selector_calendar.prototype.release_calendar = function() {
     date_selector_calendar.calendar.selectEvent.unsubscribe(this.set_selects_from_date, this);
 }
 
-/**
-    elementToggleHide (element, elementFinder)
-
-    If elementFinder is not provided, toggles the "hidden" class for the specified element.
-    If elementFinder is provided, then the "hidden" class will be toggled for the object
-    returned by the function call elementFinder(element).
-
-    If persistent == true, also sets a cookie for this.
-*/
-function elementToggleHide(el, persistent, elementFinder, strShow, strHide) {
-    if(!elementFinder) {
-        var obj = el;  //el:container
-        el = document.getElementById('togglehide_'+obj.id);
-    }
-    else {
-        var obj = elementFinder(el);  //el:button.
-    }
-    if(obj.className.indexOf('hidden') == -1) {
-        obj.className += ' hidden';
-        if (el.src) {
-            el.src = el.src.replace('switch_minus', 'switch_plus');
-            el.alt = strShow;
-            el.title = strShow;
-        }
-        var shown = 0;
-    }
-    else {
-        obj.className = obj.className.replace(new RegExp(' ?hidden'), '');
-        if (el.src) {
-            el.src = el.src.replace('switch_plus', 'switch_minus');
-            el.alt = strHide;
-            el.title = strHide;
-        }
-        var shown = 1;
-    }
-
-    if(persistent == true) {
-        new cookie('hide:' + obj.id, 1, (shown ? -1 : 356), '/').set();
-    }
-}
-
-function elementCookieHide(id, strShow, strHide) {
-    var obj  = document.getElementById(id);
-    var cook = new cookie('hide:' + id).read();
-    if(cook != null) {
-        elementToggleHide(obj, false, null, strShow, strHide);
-    }
-}
-
 function filterByParent(elCollection, parentFinder) {
     var filteredCollection = [];
     for (var i = 0; i < elCollection.length; ++i) {
@@ -921,8 +872,7 @@ function collapsible_region(id, userpref, strtooltip, collapsedicon, expandedico
     a.appendChild(this.icon);
 
     // Hook up the event handler.
-    var self = this;
-    YAHOO.util.Event.addListener(a, 'click', function(e) {self.handle_click(e);});
+    YAHOO.util.Event.addListener(a, 'click', this.handle_click, null, this);
 
     // Handler for the animation finishing.
     this.animation.onComplete.subscribe(function() {self.handle_animation_complete();});
@@ -1007,6 +957,67 @@ collapsible_region.prototype.handle_animation_complete = function() {
     }
 }
 
+/**
+ * Oject to handle expanding and collapsing blocks when an icon is clicked on.
+ * @constructor
+ * @param String id the HTML id for the div.
+ * @param String userpref the user preference that records the state of this block.
+ * @param String visibletooltip tool tip/alt to show when the block is visible.
+ * @param String hiddentooltip tool tip/alt to show when the block is hidden.
+ * @param String visibleicon URL of the icon to show when the block is visible.
+ * @param String hiddenicon URL of the icon to show when the block is hidden.
+ */
+function block_hider(id, userpref, visibletooltip, hiddentooltip, visibleicon, hiddenicon) {
+    // Find the elemen that is the block.
+    this.block = document.getElementById(id);
+    var title_div = YAHOO.util.Dom.getElementsByClassName('title', 'div', this.block);
+    if (!title_div || !title_div[0]) {
+        return this;
+    }
+    title_div = title_div[0];
+    this.ishidden = YAHOO.util.Dom.hasClass(this.block, 'hidden');
+
+    // Record the pref name
+    this.userpref = userpref;
+    this.visibletooltip = visibletooltip;
+    this.hiddentooltip = hiddentooltip;
+    this.visibleicon = visibleicon;
+    this.hiddenicon = hiddenicon;
+
+    // Add the icon.
+    this.icon = document.createElement('input');
+    this.icon.type = 'image';
+    this.icon.className = 'hide-show-image';
+    this.update_state();
+    title_div.insertBefore(this.icon, title_div.firstChild);
+
+    // Hook up the event handler.
+    YAHOO.util.Event.addListener(this.icon, 'click', this.handle_click, null, this);
+}
+
+/** Handle click on a block show/hide icon. */
+block_hider.prototype.handle_click = function(e) {
+    YAHOO.util.Event.stopEvent(e);
+    this.ishidden = !this.ishidden;
+    this.update_state();
+    set_user_preference(this.userpref, this.ishidden);
+}
+
+/** Set the state of the block show/hide icon to this.ishidden. */
+block_hider.prototype.update_state = function () {
+    if (this.ishidden) {
+        YAHOO.util.Dom.addClass(this.block, 'hidden');
+        this.icon.alt = this.hiddentooltip;
+        this.icon.title = this.hiddentooltip;
+        this.icon.src = this.hiddenicon;
+    } else {
+        YAHOO.util.Dom.removeClass(this.block, 'hidden');
+        this.icon.alt = this.visibletooltip;
+        this.icon.title = this.visibletooltip;
+        this.icon.src = this.visibleicon;
+    }
+}
+
 /** Close the current browser window. */
 function close_window() {
     window.close();
index c084b27f547f13b9c45db23ed119608bfeb9aa2a..7b750cc86039119be80b90e76f7ad00d1e997dff 100644 (file)
@@ -147,7 +147,7 @@ class theme_config {
     /**
      * You can base your theme on another theme by linking to the other theme as
      * a parent. This lets you use the CSS from the other theme
-     * (see {@link $parentsheets}), or layout templates (see {@link $layouttemplates}).
+     * (see {@link $parentsheets}), or layout templates (see {@link $layouts}).
      * That makes it easy to create a new theme that is similar to another one
      * but with a few changes. In this theme's CSS you only need to override
      * those rules you want to change.
@@ -240,50 +240,67 @@ class theme_config {
     /**
      * Which template to use for each general type of page.
      *
-     * The array should have keys that are the page types, and values that are
-     * the template names, as described below.
+     * This is an array of arrays. The keys of the outer array are the different
+     * types of page. Pages in Moodle are categorised into one of a short list of
+     * types like 'normal', 'home', 'popup', 'form', .... The most reliable way
+     * to get a complete list is to look at
+     * {@link http://cvs.moodle.org/moodle/theme/standard/config.php?view=markup the standard theme config.php file}.
+     * That file also has a good example of how to set this setting.
      *
-     * There are a few recognised page tyes like 'normal', 'popup', 'home'.
-     * If the current page if of a type not listed here, then the first listed
-     * template is used. Therefore you should probably list the 'normal' template
-     * first.
+     * If Moodle encouters a general type of page that is not listed in your theme,
+     * then it will use the first layout. Therefore, should probably put 'normal'
+     * first in this array.
      *
-     * To promote conisitency, you are encouraged to call your templates
-     * layout.php or layout-something.php.
+     * For each page type, the value in the outer array is an array that describes
+     * how you want that type of page to look. For example
+     * <pre>
+     *   $THEME->layouts = array(
+     *       // Most pages. Put this first, so if we encounter an unknown page type, this is used.
+     *       'normal' => array(
+     *           'layout' => 'parent:layout.php',
+     *           'regions' => array('side-pre', 'side-post'),
+     *           'defaultregion' => 'side-post'
+     *       ),
+     *       // The site home page.
+     *       'home' => array(
+     *           'layout' => 'layout-home.php',
+     *           'regions' => array('side-pre', 'side-post'),
+     *           'defaultregion' => 'side-post'
+     *       ),
+     *       // ...
+     *   );
+     * </pre>
      *
-     * The name of the template can take one of three forms:
+     * 'layout' is the layout template to use for this type of page. You can
+     * specify this in one of three ways:
      * <ol>
-     * <li><b>filename</b> for example 'layout.php'. Use that file from this theme.</li>
-     * <li><b>parent:filename</b> for example 'parent:layout-popup.php'. Use the
+     * <li><b>filename</b> for example 'layout-home.php' as above. Use that file from this theme.</li>
+     * <li><b>parent:filename</b> for example 'parent:layout.php' as above. Use the
      *      specified file from the parent theme. (Obviously, you can only do this
      *      if this theme has a parent!)</li>
      * <li><b>standard:filename</b> for example 'standard:layout-popup.php'. Use
      *      the specified file from the standard theme.</li>
      * </ol>
+     * To promote conisitency, you are encouraged to call your layout files
+     * layout.php or layout-something.php.
      *
-     * @var array
-     */
-    public $layouttemplates = array();
-
-    /**
-     * Names of the regions where blocks may appear on the page.
+     * 'regions' This lists the regions on the page where blocks may appear. For
+     * each region you list here, your layout file must include a call to
+     * <pre>
+     *   echo $OUTPUT->blocks_for_region($regionname);
+     * </pre>
+     * or equivalent so that the blocks are actually visible.
      *
-     * For each region you list in $THEME->blockregions you must call
-     * blocks_print_group with that region id somewhere in your layout template.
+     * 'defaultregion' If the list of regions is non-empty, then you must pick
+     * one of the one of them as 'default'. This has two meanings. First, this is
+     * where new blocks are added. Second, if there are any blocks associated with
+     * the page, but in non-existant regions, they appear here. (Imaging, for example,
+     * that someone added blocks using a different theme that used different region
+     * names, and then switched to this theme.)
      *
      * @var array
      */
-    public $blockregions = array('side-pre', 'side-post');
-
-    /**
-     * The blocks region where new blocks will be added.
-     * 
-     * Also, where any blocks in unrecognised regions will be shown.
-     * (Suppose someone added a block when another theme was selected).
-     * 
-     * @var string
-     */
-    public $defaultblockregion = 'side-post';
+    public $layouts = array();
 
     /**
      * With this you can control the colours of the big MP3 player
@@ -572,6 +589,19 @@ class theme_config {
         return $metatags;
     }
 
+    /**
+     * Get the information from {@link $layouts} for this type of page.
+     * @param string $generaltype the general type of the page.
+     * @return array the appropriate part of {@link $layouts}.
+     */
+    protected function layout_info_for_page($generaltype) {
+        if (array_key_exists($generaltype, $this->layouts)) {
+            return $this->layouts[$generaltype];
+        } else {
+            return reset($this->layouts);
+        }
+    }
+
     /**
      * Given the settings of this theme, and the page generaltype, return the
      * full path of the page layout template to use.
@@ -580,28 +610,25 @@ class theme_config {
      * template cannot be found, returns false to signal that the old-style
      * header.html and footer.html files should be used.
      *
+     * @param string $generaltype the general type of the page.
      * @return string Full path to the template to use, or false if a new-style
      * template cannot be found.
      */
-    public function find_page_template($generaltype) {
+    public function template_for_page($generaltype) {
         global $CFG;
 
         // Legacy fallback.
-        if (empty($this->layouttemplates)) {
+        if (empty($this->layouts)) {
             return false;
         }
 
-        // Look up the page type in the config array.
-        if (array_key_exists($generaltype, $this->layouttemplates)) {
-            $templatefile = $this->layouttemplates[$generaltype];
-        } else {
-            $templatefile = reset($this->layouttemplates);
-        }
+        $layoutinfo = $this->layout_info_for_page($generaltype);
+        $templatefile = $layoutinfo['layout'];
 
         // Parse the name that was found.
-        if (strpos('standard:', $templatefile) === 0) {
+        if (strpos($templatefile, 'standard:') === 0) {
             $templatepath = $CFG->themedir . '/standard/' . substr($templatefile, 9);
-        } else if (strpos('parent:', $templatefile) === 0) {
+        } else if (strpos($templatefile, 'parent:') === 0) {
             if (empty($this->parent)) {
                 throw new coding_exception('This theme (' . $this->name .
                         ') does not have a parent. You cannot specify a layout template like ' .
@@ -622,6 +649,29 @@ class theme_config {
         return $templatepath;
     }
 
+    /**
+     * Inform a block_manager about the block regions this theme wants on this
+     * type of page.
+     * @param string $generaltype the general type of the page.
+     * @param block_manager $blockmanager the block_manger to set up.
+     */
+    public function setup_blocks($generaltype, $blockmanager) {
+        // Legacy fallback.
+        if (empty($this->layouts)) {
+            if (!in_array($generaltype, array('form', 'popup', 'maintenance'))) {
+                $blockmanager->add_regions(array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT));
+                $blockmanager->set_default_region(BLOCK_POS_RIGHT);
+            }
+            return;
+        }
+
+        $layoutinfo = $this->layout_info_for_page($generaltype);
+        if (!empty($layoutinfo['regions'])) {
+            $blockmanager->add_regions($layoutinfo['regions']);
+            $blockmanager->set_default_region($layoutinfo['defaultregion']);
+        }
+    }
+
     /**
      * Helper method used by {@link update_legacy_information()}. Update one entry
      * in the $this->pluginsheets array, based on the legacy $property propery.
@@ -629,7 +679,8 @@ class theme_config {
      * @param $property e.g. 'modsheets'.
      */
     protected function update_legacy_plugin_sheets($plugintype, $property) {
-        if (property_exists($this, $property)) {
+        // In Moodle 1.9, modsheets etc. were ignored if standardsheets was false.
+        if (!empty($this->standardsheets) && property_exists($this, $property)) {
             debugging('$THEME->' . $property . ' is deprecated. Please use the new $THEME->pluginsheets instead.', DEBUG_DEVELOPER);
             if (!empty($this->$property) && !in_array($plugintype, $this->pluginsheets)) {
                 $this->pluginsheets[] = $plugintype;
@@ -652,14 +703,6 @@ class theme_config {
         $this->update_legacy_plugin_sheets('format', 'formatsheets');
         $this->update_legacy_plugin_sheets('gradereport', 'gradereportsheets');
 
-        if (empty($this->standardsheets)) {
-            // In Moodle 1.9, these settings were dependant on each other. They
-            // are now independant, at least at the time when the CSS is served,
-            // to this is necessary to maintain backwards compatibility. Hmm.
-            // What if you don't want this?
-            $this->pluginsheets = array();
-        }
-
         if (!empty($this->langsheets)) {
             debugging('$THEME->langsheets is no longer supported. No languages were ' .
                     'using it for anything, and it did not seem to serve any purpose.', DEBUG_DEVELOPER);
@@ -990,7 +1033,7 @@ class theme_overridden_renderer_factory extends standard_renderer_factory {
         }
     }
 
-    /* Implement the subclass method. */
+    /* Implement the interface method. */
     public function get_renderer($module, $page, $subtype=null) {
         foreach ($this->prefixes as $prefix) {
             if (is_null($subtype)) {
@@ -1073,8 +1116,8 @@ class template_renderer_factory extends renderer_factory_base {
         $searchpaths = array();
         foreach ($this->searchpaths as $rootpath) {
             $path = $rootpath . '/' . $module;
-            if (!is_null($subtype)) { 
-                $path .= '/' . $subtype; 
+            if (!is_null($subtype)) {
+                $path .= '/' . $subtype;
             }
             if (is_dir($path)) {
                 $searchpaths[] = $path;
@@ -1784,7 +1827,7 @@ class moodle_core_renderer extends moodle_renderer_base {
         $this->page->set_state(moodle_page::STATE_PRINTING_HEADER);
 
         // Find the appropriate page template, based on $this->page->generaltype.
-        $templatefile = $this->page->theme->find_page_template($this->page->generaltype);
+        $templatefile = $this->page->theme->template_for_page($this->page->generaltype);
         if ($templatefile) {
             // Render the template.
             $template = $this->render_page_template($templatefile, $menu, $navigation);
@@ -1828,10 +1871,11 @@ class moodle_core_renderer extends moodle_renderer_base {
     }
 
     protected function handle_legacy_theme($navigation, $menu) {
-        global $CFG, $SITE, $THEME, $USER;
+        global $CFG, $SITE, $USER;
         // Set a pretend global from the properties of this class.
         // See the comment in render_page_template for a fuller explanation.
         $COURSE = $this->page->course;
+        $THEME = $this->page->theme;
 
         // Set up local variables that header.html expects.
         $direction = $this->htmlattributes();
@@ -1860,10 +1904,53 @@ class moodle_core_renderer extends moodle_renderer_base {
             $menu = $loggedinas;
         }
 
+        if (!empty($this->page->theme->layouttable)) {
+            $lt = $this->page->theme->layouttable;
+        } else {
+            $lt = array('left', 'middle', 'right');
+        }
+
+        if (!empty($this->page->theme->block_l_max_width)) {
+            $preferredwidthleft = $this->page->theme->block_l_max_width;
+        } else {
+            $preferredwidthleft = 210;
+        }
+        if (!empty($this->page->theme->block_r_max_width)) {
+            $preferredwidthright = $this->page->theme->block_r_max_width;
+        } else {
+            $preferredwidthright = 210;
+        }
+
         ob_start();
-        include($THEME->dir . '/header.html');
+        include($this->page->theme->dir . '/header.html');
         $this->page->requires->get_top_of_body_code();
-        echo self::MAIN_CONTENT_TOKEN;
+
+        echo '<table id="layout-table"><tr>';
+        foreach ($lt as $column) {
+            if ($column == 'left' && $this->page->blocks->region_has_content(BLOCK_POS_LEFT)) {
+                echo '<td id="left-column" style="width: ' . $preferredwidthright . 'px; vertical-align: top;">';
+                echo $this->container_start();
+                echo $this->blocks_for_region(BLOCK_POS_LEFT);
+                echo $this->container_end();
+                echo '</td>';
+
+            } else if ($column == 'middle') {
+                echo '<td id="middle-column" style="vertical-align: top;">';
+                echo $this->container_start();
+                echo $this->skip_link_target();
+                echo self::MAIN_CONTENT_TOKEN;
+                echo $this->container_end();
+                echo '</td>';
+
+            } else if ($column == 'right' && $this->page->blocks->region_has_content(BLOCK_POS_RIGHT)) {
+                echo '<td id="right-column" style="width: ' . $preferredwidthright . 'px; vertical-align: top;">';
+                echo $this->container_start();
+                echo $this->blocks_for_region(BLOCK_POS_RIGHT);
+                echo $this->container_end();
+                echo '</td>';
+            }
+        }
+        echo '</tr></table>';
 
         $menu = str_replace('navmenu', 'navmenufooter', $menu);
         include($THEME->dir . '/footer.html');
@@ -1901,26 +1988,45 @@ class moodle_core_renderer extends moodle_renderer_base {
         return $output . $footer;
     }
 
+    /**
+     * Output the row of editing icons for a block, as defined by the controls array.
+     * @param $controls an array like {@link block_contents::$controls}.
+     * @return HTML fragment.
+     */
+    public function block_controls($controls) {
+        if (empty($controls)) {
+            return '';
+        }
+        $controlshtml = array();
+        foreach ($controls as $control) {
+            $controlshtml[] = $this->output_tag('a', array('class' => 'icon',
+                    'title' => $control['caption'], 'href' => $control['url']),
+                    $this->output_empty_tag('img',  array('src' => $control['icon'],
+                    'alt' => $control['caption'])));
+        }
+        return $this->output_tag('div', array('class' => 'commands'), implode('', $controlshtml));
+    }
+
     /**
      * Prints a nice side block with an optional header.
      *
      * The content is described
      * by a {@link block_contents} object.
      *
-     * @param block $content HTML for the content
+     * @param block_contents $bc HTML for the content
      * @return string the HTML to be output.
      */
     function block($bc) {
-        $bc = clone($bc);
+        $bc = clone($bc); // Avoid messing up the object passed in.
         $bc->prepare();
 
-        $title = strip_tags($bc->title);
-        if (empty($title)) {
+        $skiptitle = strip_tags($bc->title);
+        if (empty($skiptitle)) {
             $output = '';
             $skipdest = '';
         } else {
             $output = $this->output_tag('a', array('href' => '#sb-' . $bc->skipid, 'class' => 'skip-block'),
-                    get_string('skipa', 'access', $title));
+                    get_string('skipa', 'access', $skiptitle));
             $skipdest = $this->output_tag('span', array('id' => 'sb-' . $bc->skipid, 'class' => 'skip-block-to'), '');
         }
 
@@ -1928,56 +2034,83 @@ class moodle_core_renderer extends moodle_renderer_base {
         $bc->attributes['class'] = $bc->get_classes_string();
         $output .= $this->output_start_tag('div', $bc->attributes);
 
-        if ($bc->heading) {
-            // Some callers pass in complete html for the heading, which may include
-            // complicated things such as the 'hide block' button; some just pass in
-            // text. If they only pass in plain text i.e. it doesn't include a
-            // <div>, then we add in standard tags that make it look like a normal
-            // page block including the h2 for accessibility
-            if (strpos($bc->heading, '</div>') === false) {
-                $bc->heading = $this->output_tag('div', array('class' => 'title'),
-                        $this->output_tag('h2', null, $bc->heading));
-            }
+        $controlshtml = $this->block_controls($bc->controls);
 
-            $output .= $this->output_tag('div', array('class' => 'header'), $bc->heading);
+        $title = '';
+        if ($bc->title) {
+            $title = $this->output_tag('h2', null, $bc->title);
         }
 
-        $output .= $this->output_start_tag('div', array('class' => 'content'));
-
-        if ($bc->content) {
-            $output .= $bc->content;
-
-        } else if ($bc->list) {
-            $row = 0;
-            $items = array();
-            foreach ($bc->list as $key => $string) {
-                $item = $this->output_start_tag('li', array('class' => 'r' . $row));
-                if ($bc->icons) {
-                    $item .= $this->output_tag('div', array('class' => 'icon column c0'), $bc->icons[$key]);
-                }
-                $item .= $this->output_tag('div', array('class' => 'column c1'), $string);
-                $item .= $this->output_end_tag('li');
-                $items[] = $item;
-                $row = 1 - $row; // Flip even/odd.
-            }
-            $output .= $this->output_tag('ul', array('class' => 'list'), implode("\n", $items));
+        if ($title || $controlshtml) {
+            $output .= $this->output_tag('div', array('class' => 'header'),
+                    $this->output_tag('div', array('class' => 'title'),
+                    $title . $controlshtml));
         }
 
+        $output .= $this->output_start_tag('div', array('class' => 'content'));
+        $output .= $bc->content;
+
         if ($bc->footer) {
             $output .= $this->output_tag('div', array('class' => 'footer'), $bc->footer);
         }
 
         $output .= $this->output_end_tag('div');
         $output .= $this->output_end_tag('div');
+        if ($bc->annotation) {
+            $output .= $this->output_tag('div', array('class' => 'blockannotation'), $bc->annotation);
+        }
         $output .= $skipdest;
 
-        if (!empty($CFG->allowuserblockhiding) && isset($attributes['id'])) {
-            $strshow = addslashes_js(get_string('showblocka', 'access', $title));
-            $strhide = addslashes_js(get_string('hideblocka', 'access', $title));
-            $output .= $this->page->requires->js_function_call('elementCookieHide', array(
-                    $bc->id, $strshow, $strhide))->asap();
+        $this->init_block_hider_js($bc);
+        return $output;
+    }
+
+    protected function init_block_hider_js($bc) {
+        if ($bc->collapsible != block_contents::NOT_HIDEABLE) {
+            $userpref = 'block' . $bc->blockinstanceid . 'hidden';
+            user_preference_allow_ajax_update($userpref, PARAM_BOOL);
+            $this->page->requires->yui_lib('dom');
+            $this->page->requires->yui_lib('event');
+            $plaintitle = strip_tags($bc->title);
+            $this->page->requires->js_function_call('new block_hider', array($bc->id, $userpref,
+                    get_string('hideblocka', 'access', $plaintitle), get_string('showblocka', 'access', $plaintitle),
+                    $this->old_icon_url('t/switch_minus'), $this->old_icon_url('t/switch_plus')));
         }
+    }
+
+    /**
+     * Render the contents of a block_list.
+     * @param array $icons the icon for each item.
+     * @param array $items the content of each item.
+     * @return string HTML
+     */
+    public function list_block_contents($icons, $items) {
+        $row = 0;
+        $lis = array();
+        foreach ($items as $key => $string) {
+            $item = $this->output_start_tag('li', array('class' => 'r' . $row));
+            if ($icons) {
+                $item .= $this->output_tag('div', array('class' => 'icon column c0'), $icons[$key]);
+            }
+            $item .= $this->output_tag('div', array('class' => 'column c1'), $string);
+            $item .= $this->output_end_tag('li');
+            $lis[] = $item;
+            $row = 1 - $row; // Flip even/odd.
+        }
+        return $this->output_tag('ul', array('class' => 'list'), implode("\n", $lis));
+    }
 
+    /**
+     * Output all the blocks in a particular region.
+     * @param $region the name of a region on this page.
+     * @return string the HTML to be output.
+     */
+    public function blocks_for_region($region) {
+        $blockcontents = $this->page->blocks->get_content_for_region($region, $this);
+        $output = '';
+        foreach ($blockcontents as $bc) {
+            $output .= $this->block($bc);
+        }
         return $output;
     }
 
@@ -2172,7 +2305,7 @@ class moodle_core_renderer extends moodle_renderer_base {
      * @param $id The target name from the corresponding $PAGE->requires->skip_link_to($target) call.
      * @return string the HTML to output.
      */
-    public function skip_link_target($id = 'maincontent') {
+    public function skip_link_target($id = '') {
         return $this->output_tag('span', array('id' => $id), '');
     }
 
@@ -2240,7 +2373,7 @@ class moodle_html_component {
      *      string containing class names.
      * @return array the class names as an array.
      */
-    public static function clean_clases($classes) {
+    public static function clean_classes($classes) {
         if (is_array($classes)) {
             return $classes;
         } else {
@@ -2254,7 +2387,7 @@ class moodle_html_component {
      *      string containing class names.
      */
     public function set_classes($classes) {
-        $this->classes = self::clean_clases($classes);
+        $this->classes = self::clean_classes($classes);
     }
 
     /**
@@ -2271,7 +2404,7 @@ class moodle_html_component {
      *      string containing class names.
      */
     public function add_classes($classes) {
-        $this->classes += self::clean_clases($classes);
+        $this->classes += self::clean_classes($classes);
     }
 
     /**
@@ -2287,7 +2420,7 @@ class moodle_html_component {
      * instance of this class is output.
      */
     public function prepare() {
-        $this->classes = array_unique(self::clean_clases($this->classes));
+        $this->classes = array_unique(self::clean_classes($this->classes));
     }
 }
 
@@ -2401,57 +2534,107 @@ class moodle_select_menu extends moodle_html_component {
 
 
 /**
- * This class hold all the information required to describe a Moodle block.
+ * This class represents how a block appears on a page.
+ *
+ * During output, each block instance is asked to return a block_contents object,
+ * those are then passed to the $OUTPUT->block function for display.
+ *
+ * {@link $contents} should probably be generated using a moodle_block_..._renderer.
  *
- * That is, it holds all the different bits of HTML content that need to be put into the block.
+ * Other block-like things that need to appear on the page, for example the
+ * add new block UI, are also represented as block_contents objects.
  *
  * @copyright 2009 Tim Hunt
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
 class block_contents extends moodle_html_component {
+    /** @var int used to set $skipid. */
     protected static $idcounter = 1;
+
+    const NOT_HIDEABLE = 0;
+    const VISIBLE = 1;
+    const HIDDEN = 2;
+
     /**
-     * @param string $heading HTML for the heading. Can include full HTML or just
-     *   plain text - plain text will automatically be enclosed in the appropriate
-     *   heading tags.
+     * @param integer $skipid All the blocks (or things that look like blocks)
+     * printed on a page are given a unique number that can be used to construct
+     * id="" attributes. This is set automatically be the {@link prepare()} method.
+     * Do not try to set it manually.
      */
-    public $heading = '';
+    public $skipid;
+
+    /**
+     * @var integer If this is the contents of a real block, this should be set to
+     * the block_instance.id. Otherwise this should be set to 0.
+     */
+    public $blockinstanceid = 0;
+
     /**
-     * @param string $title Plain text title, as embedded in the $heading.
+     * @var integer if this is a real block instance, and there is a corresponding
+     * block_position.id for the block on this page, this should be set to that id.
+     * Otherwise it should be 0.
+     */
+    public $blockpositionid = 0;
+
+    /**
+     * @param array $attributes an array of attribute => value pairs that are put on the
+     * outer div of this block. {@link $id} and {@link $classes} attributes should be set separately.
+     */
+    public $attributes = array();
+
+    /**
+     * @param string $title The title of this block. If this came from user input,
+     * it should already have had format_string() processing done on it. This will
+     * be output inside <h2> tags. Please do not cause invalid XHTML.
      */
     public $title = '';
+
     /**
      * @param string $content HTML for the content
      */
     public $content = '';
+
     /**
      * @param array $list an alternative to $content, it you want a list of things with optional icons.
      */
-    public $list = array();
-    /**
-     * @param array $icons optional icons for the things in $list.
-     */
-    public $icons = array();
+    public $footer = '';
+
     /**
-     * @param string $footer Extra HTML content that gets output at the end, inside a &lt;div class="footer">
+     * Any small print that should appear under the block to explain to the
+     * teacher about the block, for example 'This is a sticky block that was
+     * added in the system context.'
+     * @var string
      */
-    public $footer = '';
+    public $annotation = '';
+
     /**
-     * @param array $attributes an array of attribute => value pairs that are put on the
-     * outer div of this block. {@link $id} and {@link $classes} attributes should be set separately.
+     * @var integer one of the constants NOT_HIDEABLE, VISIBLE, HIDDEN. Whether
+     * the user can toggle whether this block is visible.
      */
-    public $attributes = array();
+    public $collapsible = self::NOT_HIDEABLE;
+
     /**
-     * @param integer $skipid do not set this manually. It is set automatically be the {@link prepare()} method.
+     * A (possibly empty) array of editing controls. Each element of this array
+     * should be an array('url' => $url, 'icon' => $icon, 'caption' => $caption)
+     * @var array
      */
-    public $skipid;
+    public $controls = array();
 
     /* @see lib/moodle_html_component#prepare() */
     public function prepare() {
         $this->skipid = self::$idcounter;
         self::$idcounter += 1;
         $this->add_class('sideblock');
+        if (empty($this->blockinstanceid) || !strip_tags($this->title)) {
+            $this->collapsible = self::NOT_HIDEABLE;
+        }
+        if ($this->collapsible == self::HIDDEN) {
+            $this->add_class('hidden');
+        }
+        if (!empty($this->controls)) {
+            $this->add_class('block_with_controls');
+        }
         parent::prepare();
     }
 }
index 7f0c049f15ad591aaa29a313639f6769878835a3..7c1a822ab39a13d2db7b6e9feba4205a86fafb29 100644 (file)
@@ -336,8 +336,8 @@ class moodle_page {
     public function get_url() {
         if (is_null($this->_url)) {
             debugging('This page did no call $PAGE->set_url(...). Realying on a guess.', DEBUG_DEVELOPER);
-            global $ME;
-            return new moodle_url($ME);
+            global $FULLME;
+            return new moodle_url($FULLME);
         }
         return new moodle_url($this->_url); // Return a clone for safety.
     }
@@ -888,6 +888,10 @@ class moodle_page {
     public function initialise_theme_and_output() {
         global $OUTPUT, $PAGE, $SITE, $THEME;
 
+        if (!empty($this->_wherethemewasinitialised)) {
+            return;
+        }
+
         if (!$this->_course && !during_initial_install()) {
             $this->set_course($SITE);
         }
@@ -897,8 +901,7 @@ class moodle_page {
             $this->_theme = theme_config::load($themename);
         }
 
-        $this->blocks->add_regions($this->_theme->blockregions);
-        $this->blocks->set_default_region($this->_theme->defaultblockregion);
+        $this->_theme->setup_blocks($this->generaltype, $this->blocks);
 
         if ($this === $PAGE) {
             $THEME = $this->_theme;
index 5833a7c2b87033267813694d231d544a538381c2..458424309771570886a3cd06082c0361902df4a5 100644 (file)
@@ -1458,7 +1458,7 @@ function question_extract_responses($questions, $formdata, $defaultevent=QUESTIO
  * @return string
  */
 function question_get_feedback_image($fraction, $selected=true) {
-    global $CFG;
+    global $CFG, $OUTPUT;
     static $icons = array('correct' => 'tick_green', 'partiallycorrect' => 'tick_amber',
             'incorrect' => 'cross_red');
 
index 74905e26d7774e0f33f360bfab6cc8aa86310581..f2ed938a50db81d32825394dfe1aaad0a63f77f8 100644 (file)
@@ -246,6 +246,7 @@ global $SCRIPT;
     require_once($CFG->libdir .'/accesslib.php');       // Access control functions
     require_once($CFG->libdir .'/deprecatedlib.php');   // Deprecated functions included for backward compatibility
     require_once($CFG->libdir .'/moodlelib.php');       // Other general-purpose functions
+    require_once($CFG->libdir .'/pagelib.php');         // Library that defines the moodle_page class, used for $PAGE
     require_once($CFG->libdir .'/blocklib.php');        // Library for controlling blocks
     require_once($CFG->libdir .'/eventslib.php');       // Events functions
     require_once($CFG->libdir .'/grouplib.php');        // Groups functions
index 2e8f4abf92c10386c5f7e8a1620f353acaa36e4e..d73a8c74fe657616e0fa8d5424b0402037ffc515 100644 (file)
@@ -297,7 +297,7 @@ function prepare_error_message($errorcode, $module, $link, $a) {
     }
     $moreinfourl = $errordocroot . '/en/error/' . $modulelink . '/' . $errorcode;
 
-    if (empty($link) && !defined('ADMIN_EXT_HEADER_PRINTED')) {
+    if (empty($link)) {
         if (!empty($SESSION->fromurl)) {
             $link = $SESSION->fromurl;
             unset($SESSION->fromurl);
index 420977ad723312adb96ad8ea0035a3c1764f0780..778d9aa3481f0d9b88ec4a9e7316f9ab7293ae0e 100644 (file)
@@ -725,7 +725,7 @@ function upgrade_started($preinstall=false) {
     } else {
         if (!CLI_SCRIPT and !$PAGE->headerprinted) {
             $strupgrade  = get_string('upgradingversion', 'admin');
-
+            $PAGE->set_generaltype('maintenance');
             upgrade_get_javascript();
             print_header($strupgrade.' - Moodle '.$CFG->target_release, $strupgrade,
                 build_navigation(array(array('name' => $strupgrade, 'link' => null, 'type' => 'misc'))), '',
@@ -764,7 +764,7 @@ function upgrade_finished($continueurl=null) {
         ignore_user_abort(false);
         if ($continueurl) {
             print_continue($continueurl);
-            print_footer('upgrade');
+            print_footer();
             die;
         }
     }
index 8a72f14024e585cc237750d6cbdc7ea3540258e1..9b84b376e89c549ba67ec4d2c3dd73420d6ebca5 100644 (file)
@@ -444,6 +444,30 @@ class moodle_url {
         return $uri;
     }
 
+    /**
+     * Return a URL relative to $CFG->wwwroot.
+     *
+     * Throws an exception if this URL does not start with $CFG->wwwroot.
+     *
+     * The main use for this is when you want to pass a returnurl from one script to another.
+     * In this case the returnurl should be relative to $CFG->wwwroot for two reasons.
+     * First, it is shorter. More imporatantly, some web servers (e.g. IIS by default)
+     * give a 'security' error if you try to pass a full URL as a GET parameter in another URL.
+     *
+     * @return string the URL relative to $CFG->wwwroot. Note, you will need to urlencode
+     * this result if you are outputting a URL manually (but not if you are adding
+     * it to another moodle_url).
+     */
+    public function out_returnurl() {
+        global $CFG;
+        $fulluri = $this->out(false, array(), false);
+        $uri = str_replace($CFG->wwwroot . '/', '', $fulluri);
+        if ($uri == $fulluri) {
+            throw new coding_exception('This URL (' . $fulluri . ') is not relative to $CFG->wwwroot.');
+        }
+        return $uri;
+    }
+
     /**
      * Output action url with sesskey
      *
@@ -5112,6 +5136,7 @@ function print_maintenance_message() {
     global $CFG, $SITE, $PAGE;
 
     $PAGE->set_pagetype('maintenance-message');
+    $PAGE->set_generaltype('maintenance');
     print_header(strip_tags($SITE->fullname), $SITE->fullname, 'home');
     print_heading(get_string('sitemaintenance', 'admin'));
     if (isset($CFG->maintenance_message) and !html_is_blank($CFG->maintenance_message)) {
index 0262da25251e23554d18e95c2a8d533f94d79609..e0d05bb390e50cd7fe9aaa02d088076079d729a1 100644 (file)
 // Initialize $PAGE, compute blocks
     $PAGE->set_url('mod/chat/view.php', array('id' => $cm->id));
 
-    // Note: MDL-19010 there will be further changes to printing header and blocks.
-    // The code will be much nicer than this eventually.
-    $pageblocks = blocks_setup($PAGE);
-    $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
-
 /// Print the page header
     $strenterchat    = get_string('enterchat', 'chat');
     $stridle         = get_string('idle', 'chat');
     $navigation = build_navigation(array(), $cm);
     print_header($title, $course->fullname, $navigation, '', '', true, $buttons, navmenu($course, $cm));
 
-    echo '<table id="layout-table"><tr>';
-
-    $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
-    foreach ($lt as $column) {
-        switch ($column) {
-            case 'left':
-
-                if(!empty($CFG->showblocksonmodpages) && (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
-                    echo '<td style="width: '.$blocks_preferred_width.'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();
-
-                /// Check to see if groups are being used here
-                $groupmode = groups_get_activity_groupmode($cm);
-                $currentgroup = groups_get_activity_group($cm, true);
-                groups_print_activity_menu($cm, "view.php?id=$cm->id");
-
-                if ($currentgroup) {
-                    $groupselect = " AND groupid = '$currentgroup'";
-                    $groupparam = "&amp;groupid=$currentgroup";
-                } else {
-                    $groupselect = "";
-                    $groupparam = "";
-                }
-
-                if ($chat->studentlogs or has_capability('mod/chat:readlog',$context)) {
-                    if ($msg = $DB->get_records_select('chat_messages', "chatid = ? $groupselect", array($chat->id))) {
-                        echo '<div class="reportlink">';
-                        echo "<a href=\"report.php?id=$cm->id\">".
-                            get_string('viewreport', 'chat').'</a>';
-                        echo '</div>';
-                    }
-                }
-
-
-                print_heading(format_string($chat->name));
-
-                if (has_capability('mod/chat:chat',$context)) {
-                    /// Print the main part of the page
-                    print_box_start('generalbox', 'enterlink');
-                    // users with screenreader set, will only see 1 link, to the manual refresh page
-                    // for better accessibility
-                    if (!empty($USER->screenreader)) {
-                        $chattarget = "/mod/chat/gui_basic/index.php?id=$chat->id$groupparam";
-                    } else {
-                        $chattarget = "/mod/chat/gui_$CFG->chat_method/index.php?id=$chat->id$groupparam"; 
-                    }
-
-                    echo '<p>';
-                    link_to_popup_window ($chattarget,
-                            "chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, get_string('modulename', 'chat'));
-                    echo '</p>';
-
-                    if ($CFG->enableajax) {
-                        echo '<p>';
-                        link_to_popup_window ("/mod/chat/gui_ajax/index.php?id=$chat->id$groupparam",
-                            "chat$course->id$chat->id$groupparam", get_string('ajax_gui', 'message'), 500, 700, get_string('modulename', 'chat'));
-                        echo '</p>';
-                    }
-
-                    // if user is using screen reader, then there is no need to display this link again
-                    if ($CFG->chat_method == 'header_js' && empty($USER->screenreader)) {
-                        // show frame/js-less alternative
-                        echo '<p>(';
-                        link_to_popup_window ("/mod/chat/gui_basic/index.php?id=$chat->id$groupparam",
-                            "chat$course->id$chat->id$groupparam", get_string('noframesjs', 'message'), 500, 700, get_string('modulename', 'chat'));
-                        echo ')</p>';
-                    }
-
-                    print_box_end();
-
-                } else {
-                    print_box_start('generalbox', 'notallowenter');
-                    echo '<p>'.get_string('notallowenter', 'chat').'</p>';
-                    print_box_end();
-                }
-
-                if ($chat->chattime and $chat->schedule) {  // A chat is scheduled
-                    echo "<p class=\"nextchatsession\">$strnextsession: ".userdate($chat->chattime).' ('.usertimezone($USER->timezone).')</p>';
-                } else {
-                    echo '<br />';
-                }
-
-                if ($chat->intro) {
-                    print_box(format_module_intro('chat', $chat, $cm->id), 'generalbox', 'intro');
-                }
-
-                chat_delete_old_users();
-
-                if ($chatusers = chat_get_users($chat->id, $currentgroup, $cm->groupingid)) {
-                    $timenow = time();
-                    print_simple_box_start('center');
-                    print_heading($strcurrentusers);
-                    echo '<table id="chatcurrentusers">';
-                    foreach ($chatusers as $chatuser) {
-                        $lastping = $timenow - $chatuser->lastmessageping;
-                        echo '<tr><td class="chatuserimage">';
-                        echo "<a href=\"$CFG->wwwroot/user/view.php?id=$chatuser->id&amp;course=$chat->course\">";
-                        print_user_picture($chatuser, 0, $chatuser->picture, false, false, false);
-                        echo '</a></td><td class="chatuserdetails">';
-                        echo '<p>';
-                        echo fullname($chatuser).'<br />';
-                        echo "<span class=\"idletime\">$stridle: ".format_time($lastping)."</span>";
-                        echo '</p>';
-                        echo '</td></tr>';
-                    }
-                    echo '</table>';
-                    print_simple_box_end();
-                }
-
-                print_container_end();
-                echo '</td>';
-
-                break;
+    /// Check to see if groups are being used here
+    $groupmode = groups_get_activity_groupmode($cm);
+    $currentgroup = groups_get_activity_group($cm, true);
+    groups_print_activity_menu($cm, "view.php?id=$cm->id");
+
+    if ($currentgroup) {
+        $groupselect = " AND groupid = '$currentgroup'";
+        $groupparam = "&amp;groupid=$currentgroup";
+    } else {
+        $groupselect = "";
+        $groupparam = "";
+    }
+
+    if ($chat->studentlogs or has_capability('mod/chat:readlog',$context)) {
+        if ($msg = $DB->get_records_select('chat_messages', "chatid = ? $groupselect", array($chat->id))) {
+            echo '<div class="reportlink">';
+            echo "<a href=\"report.php?id=$cm->id\">".
+                get_string('viewreport', 'chat').'</a>';
+            echo '</div>';
         }
     }
 
-    echo '</tr></table>';
+
+    print_heading(format_string($chat->name));
+
+    if (has_capability('mod/chat:chat',$context)) {
+        /// Print the main part of the page
+        print_box_start('generalbox', 'enterlink');
+        // users with screenreader set, will only see 1 link, to the manual refresh page
+        // for better accessibility
+        if (!empty($USER->screenreader)) {
+            $chattarget = "/mod/chat/gui_basic/index.php?id=$chat->id$groupparam";
+        } else {
+            $chattarget = "/mod/chat/gui_$CFG->chat_method/index.php?id=$chat->id$groupparam"; 
+        }
+
+        echo '<p>';
+        link_to_popup_window ($chattarget,
+                "chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, get_string('modulename', 'chat'));
+        echo '</p>';
+
+        if ($CFG->enableajax) {
+            echo '<p>';
+            link_to_popup_window ("/mod/chat/gui_ajax/index.php?id=$chat->id$groupparam",
+                "chat$course->id$chat->id$groupparam", get_string('ajax_gui', 'message'), 500, 700, get_string('modulename', 'chat'));
+            echo '</p>';
+        }
+
+        // if user is using screen reader, then there is no need to display this link again
+        if ($CFG->chat_method == 'header_js' && empty($USER->screenreader)) {
+            // show frame/js-less alternative
+            echo '<p>(';
+            link_to_popup_window ("/mod/chat/gui_basic/index.php?id=$chat->id$groupparam",
+                "chat$course->id$chat->id$groupparam", get_string('noframesjs', 'message'), 500, 700, get_string('modulename', 'chat'));
+            echo ')</p>';
+        }
+
+        print_box_end();
+
+    } else {
+        print_box_start('generalbox', 'notallowenter');
+        echo '<p>'.get_string('notallowenter', 'chat').'</p>';
+        print_box_end();
+    }
+
+    if ($chat->chattime and $chat->schedule) {  // A chat is scheduled
+        echo "<p class=\"nextchatsession\">$strnextsession: ".userdate($chat->chattime).' ('.usertimezone($USER->timezone).')</p>';
+    } else {
+        echo '<br />';
+    }
+
+    if ($chat->intro) {
+        print_box(format_module_intro('chat', $chat, $cm->id), 'generalbox', 'intro');
+    }
+
+    chat_delete_old_users();
+
+    if ($chatusers = chat_get_users($chat->id, $currentgroup, $cm->groupingid)) {
+        $timenow = time();
+        print_simple_box_start('center');
+        print_heading($strcurrentusers);
+        echo '<table id="chatcurrentusers">';
+        foreach ($chatusers as $chatuser) {
+            $lastping = $timenow - $chatuser->lastmessageping;
+            echo '<tr><td class="chatuserimage">';
+            echo "<a href=\"$CFG->wwwroot/user/view.php?id=$chatuser->id&amp;course=$chat->course\">";
+            print_user_picture($chatuser, 0, $chatuser->picture, false, false, false);
+            echo '</a></td><td class="chatuserdetails">';
+            echo '<p>';
+            echo fullname($chatuser).'<br />';
+            echo "<span class=\"idletime\">$stridle: ".format_time($lastping)."</span>";
+            echo '</p>';
+            echo '</td></tr>';
+        }
+        echo '</table>';
+        print_simple_box_end();
+    }
 
     print_footer($course);
 
index 840ff67cf88a89b349bc264c83ea6ca6a4610c66..8501027627417d706c7f01838e8aa7a8e9f26fd7 100755 (executable)
 
 // Initialize $PAGE, compute blocks
     $PAGE->set_url('mod/data/view.php', array('id' => $cm->id));
-    $pageblocks = blocks_setup($PAGE);
-    $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
 
     if (($edit != -1) and $PAGE->user_allowed_editing()) {
         $USER->editing = $edit;
     $navigation = build_navigation(array(), $cm);
     print_header($title, $course->fullname, $navigation, '', '', true, $buttons, navmenu($course, $cm));
 
-/// If we have blocks, then print the left side here
-    if (!empty($CFG->showblocksonmodpages)) {
-        echo '<table id="layout-table"><tr>';
-        if ((blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
-            echo '<td style="width: '.$blocks_preferred_width.'px;" id="left-column">';
-            print_container_start();
-            blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-            print_container_end();
-            echo '</td>';
-        }
-        echo '<td id="middle-column">';
-        print_container_start();
-    }
-
 /// Check to see if groups are being used here
     $returnurl = 'view.php?d='.$data->id.'&amp;search='.s($search).'&amp;sort='.s($sort).'&amp;order='.s($order).'&amp;';
     groups_print_activity_menu($cm, $returnurl);
         data_print_preference_form($data, $perpage, $search, $sort, $order, $search_array, $advanced, $mode);
     }
 
-/// If we have blocks, then print the left side here
-    if (!empty($CFG->showblocksonmodpages)) {
-        print_container_end();
-        echo '</td>';   // Middle column
-        if ((blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing())) {
-            echo '<td style="width: '.$blocks_preferred_width.'px;" id="right-column">';
-            print_container_start();
-            blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-            print_container_end();
-            echo '</td>';
-        }
-        echo '</tr></table>';
-    }
-
-    print_footer($course);
-
 /// Mark as viewed
     $completion=new completion_info($course);
     $completion->set_module_viewed($cm);
+
+    print_footer($course);
 ?>
index 9a9c49d79b476904024dd05a841a2c11b5e383dc..b882bf7a94f8fa952569b7a38adb0e1b1a06feaa 100644 (file)
 
         $PAGE->set_url('mod/lesson/view.php', array('id' => $cm->id, 'pageid' => $page->id));
         $PAGE->set_subpage($page->id);
-        $pageblocks = blocks_setup($PAGE);
-
-        $leftcolumnwidth  = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
-        $rightcolumnwidth = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
 
         if (($edit != -1) and $PAGE->user_allowed_editing()) {
             $USER->editing = $edit;
index 9f31e62d80126b01ca778fd873f00eca9d985054..baf66601bd7fedc00e991f4a7f502582ed1fbffb 100644 (file)
@@ -158,6 +158,7 @@ class quiz_access_manager {
     }
 
     public function show_attempt_timer_if_needed($attempt, $timenow) {
+        global $PAGE;
         $timeleft = false;
         foreach ($this->_rules as $rule) {
             $ruletimeleft = $rule->time_left($attempt, $timenow);
index f429e77aef7fb9e8a4028a77cd7425240e8fde42..0bc05abc169a2b167dda5c5cb277196c1b94d659 100644 (file)
 
 /// Print the quiz page ////////////////////////////////////////////////////////
 
+    // Arrange for the navigation to be displayed.
+    $navbc = $attemptobj->get_navigation_panel('quiz_attempt_nav_panel', $page);
+    $firstregion = reset($PAGE->blocks->get_regions());
+    $PAGE->blocks->add_pretend_block($navbc, $firstregion);
+
     // Print the page header
     $PAGE->requires->yui_lib('event');
     $title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number());
     echo $PAGE->requires->js_function_call('init_quiz_form')->asap();
     echo '<div>';
 
-/// Print the navigation panel in a left column.
-    print_container_start();
-    echo '<div id="left-column">';
-    $attemptobj->print_navigation_panel('quiz_attempt_nav_panel', $page);
-    echo '</div>';
-    print_container_end();
-
-/// Start the main column.
-    echo '<div id="middle-column">';
-    print_container_start();
-    echo skip_main_destination();
-
 /// Print all the questions
     foreach ($attemptobj->get_question_ids($page) as $id) {
         $attemptobj->print_question($id, false, $attemptobj->attempt_url($id, $page));
     echo '<input type="hidden" name="questionids" value="' .
             implode(',', $attemptobj->get_question_ids($page)) . "\" />\n";
 
-    // End middle column.
-    print_container_end();
-
     // Finish the form
     echo '</div>';
-    echo '</div>';
     echo "</form>\n";
 
-    echo '<div class="clearer"></div>';
-
     // Finish the page
     $accessmanager->show_attempt_timer_if_needed($attemptobj->get_attempt(), time());
     if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) {
index d8f8644a9123b5662999908f5b8c52c921c35f0e..6fca3878b7e9be13a2b6adb91ccbb8bdb92c3a19 100644 (file)
@@ -707,9 +707,9 @@ class quiz_attempt extends quiz {
                 $this->context, $this->cm);
     }
 
-    public function print_navigation_panel($panelclass, $page) {
+    public function get_navigation_panel($panelclass, $page) {
         $panel = new $panelclass($this, $this->get_review_options(), $page);
-        $panel->display();
+        return $panel->get_contents();
     }
 
     /// List of all this user's attempts for people who can see reports.
@@ -807,8 +807,13 @@ class quiz_attempt extends quiz {
             $page = 0;
         }
         $fragment = '';
-        if ($questionid && $questionid != reset($this->pagequestionids[$page])) {
-            $fragment = '#q' . $questionid;
+        if ($questionid) {
+            if ($questionid == reset($this->pagequestionids[$page])) {
+                // First question on page, go to top.
+                $fragment = '#';
+            } else {
+                $fragment = '#q' . $questionid;
+            }
         }
         $param = '';
         if ($showall) {
@@ -936,15 +941,19 @@ abstract class quiz_nav_panel_base {
         return $classes;
     }
 
-    public function display() {
-        $strquiznavigation = get_string('quiznavigation', 'quiz');
+    public function get_contents() {
         $content = '';
         if ($this->attemptobj->get_quiz()->showuserpicture) {
             $content .= $this->get_user_picture() . "\n";
         }
         $content .= $this->get_question_buttons() . "\n";
         $content .= '<div class="othernav">' . "\n" . $this->get_end_bits() . "\n</div>\n";
-        print_side_block($strquiznavigation, $content, NULL, NULL, '', array('id' => 'quiznavigation'), $strquiznavigation);
+
+        $bc = new block_contents();
+        $bc->id = 'quiznavigation';
+        $bc->title = get_string('quiznavigation', 'quiz');
+        $bc->content = $content;
+        return $bc;
     }
 }
 
index d5f7c5b49df48247122b4a985aed2ec98f8a42bc..00cd7d7061f0b8551668b24930afa5d696fe8053 100644 (file)
@@ -362,39 +362,6 @@ function quiz_repaginate($layout, $perpage, $shuffle = false) {
     return $layout.'0';
 }
 
-/**
- * Print navigation panel for quiz attempt and review pages
- *
- * @param integer $page     The number of the current page (counting from 0).
- * @param integer $pages    The total number of pages.
- */
-function quiz_print_navigation_panel($page, $pages) {
-    //$page++;
-    echo '<div class="paging pagingbar">';
-    echo '<span class="title">' . get_string('page') . ':</span>';
-    if ($page > 0) {
-        // Print previous link
-        $strprev = get_string('previous');
-        echo '<a class="previous" href="javascript:navigate(' . ($page - 1) . ');" title="'
-         . $strprev . '">(' . $strprev . ')</a>';
-    }
-    for ($i = 0; $i < $pages; $i++) {
-        if ($i == $page) {
-            echo '<span class="thispage">'.($i+1).'</span>';
-        } else {
-            echo '<a href="javascript:navigate(' . ($i) . ');">'.($i+1).'</a>';
-        }
-    }
-
-    if ($page < $pages - 1) {
-        // Print next link
-        $strnext = get_string('next');
-        echo '<a class="next" href="javascript:navigate(' . ($page + 1) . ');" title="'
-         . $strnext . '">(' . $strnext . ')</a>';
-    }
-    echo '</div>';
-}
-
 /// Functions to do with quiz grades //////////////////////////////////////////
 
 /**
index 22e9a397da3f3dc71bb75dda9c0598c02b76f7e7..619f0a0b200b90f03e0d83d30b3a801856984caa 100644 (file)
         $strreviewtitle = get_string('reviewofattempt', 'quiz', $attemptobj->get_attempt_number());
     }
 
+/// Arrange for the navigation to be displayed.
+    $navbc = $attemptobj->get_navigation_panel('quiz_review_nav_panel', $page);
+    $firstregion = reset($PAGE->blocks->get_regions());
+    $PAGE->blocks->add_pretend_block($navbc, $firstregion);
+
 /// Print the page header
     $PAGE->requires->js('mod/quiz/quiz.js');
     $headtags = $attemptobj->get_html_head_contributions($page);
     }
     print_heading($strreviewtitle);
 
-/// Print the navigation panel in a left column.
-    print_container_start();
-    echo '<div id="left-column">';
-    $attemptobj->print_navigation_panel('quiz_review_nav_panel', $page);
-    echo '</div>';
-    print_container_end();
-
-/// Start the main column.
-    echo '<div id="middle-column">';
-    echo skip_main_destination();
-
 /// Summary table start ============================================================================
 
 /// Work out some time-related things.
     }
     echo "</div>";
 
-    // End middle column.
-    echo '</div>';
-
-    echo '<div class="clearer"></div>';
-
     // Finish the page
     if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) {
         print_footer('empty');
index d621b3c909eb220c0c6cc63290963906c8fa0fd0..40dd99a6af316e86807512ddb7805c79ba770300 100644 (file)
@@ -57,8 +57,6 @@
 
 /// Initialize $PAGE, compute blocks
     $PAGE->set_url('mod/quiz/view.php', array('id' => $cm->id));
-    $pageblocks = blocks_setup($PAGE);
-    $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
 
     $edit = optional_param('edit', -1, PARAM_BOOL);
     if ($edit != -1 && $PAGE->user_allowed_editing()) {
     $navigation = build_navigation(array(), $cm);
     print_header($title, $course->fullname, $navigation, '', '', true, $buttons, navmenu($course, $cm), false, $bodytags);
 
-/// Print any blocks on the left of the page.
-    echo '<table id="layout-table"><tr>';
-    if(!empty($CFG->showblocksonmodpages) && (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
-        echo '<td style="width: '.$blocks_preferred_width.'px;" id="left-column">';
-        print_container_start();
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-        print_container_end();
-        echo "</td>\n";
-    }
-
-/// Start the main part of the page
-    echo '<td id="middle-column">';
-    print_container_start();
-
 /// Print heading and tabs (if there is more than one).
     $currenttab = 'info';
     include('tabs.php');
     if (isguestuser()) {
         notice_yesno('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n<p>" .
                 get_string('liketologin') . "</p>\n", get_login_url(), get_referer(false));
-        finish_page($course);
+        print_footer($course);
+        exit;
     }
 
 /// If they are not enrolled in this course in a good enough role, tell them to enrol.
         print_box('<p>' . get_string('youneedtoenrol', 'quiz') . "</p>\n\n<p>" .
                 print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id, true) .
                 "</p>\n", 'generalbox', 'notice');
-        finish_page($course);
+        print_footer($course);
+        exit;
     }
 
 /// Get this user's attempts.
     }
     print_box_end();
 
-    // Should we not be seeing if we need to print right-hand-side blocks?
-
-    finish_page($course);
-    
     // Mark module as viewed (note, we do this here and not in finish_page,
     // otherwise the 'not enrolled' error conditions would result in marking 
     // 'viewed', I think it's better if they don't.)
     $completion=new completion_info($course);
-    $completion->set_module_viewed(cm);
-
-// Utility functions =================================================================
+    $completion->set_module_viewed($cm);
 
-function finish_page($course) {
-    global $THEME;
-    print_container_end();
-    echo '</td></tr></table>';
     print_footer($course);
-    exit;
-}
-?>
index 704f592b628bd1f07fb8c1e01b79df134c60e0c6..62a84e9161091b1fa94af93e603e9ba537b2be52 100644 (file)
@@ -108,27 +108,11 @@ class resource_base {
 
     /**
      * Display the resource with the course blocks.
-     *
-     * @global stdClass
-     * @uses PAGE_COURSE_VIEW
-     * @uses PARAM_BOOL
-     * @uses BLOCK_POS_LEFT
-     * @uses BLOCK_POS_RIGHT
      */
     function display_course_blocks_start() {
-        global $CFG, $USER, $THEME;
-
-        require_once($CFG->dirroot.'/course/lib.php'); //required by some blocks
-
-        $PAGE = page_create_object(PAGE_COURSE_VIEW, $this->course->id);
-        $PAGE->set_url('mod/resource/view.php', array('id' => $this->cm->id));
-        $this->PAGE = $PAGE;
-        $pageblocks = blocks_setup($PAGE);
-
-        $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
+        global $CFG, $USER, $PAGE;
 
     /// Print the page header
-
         $edit = optional_param('edit', -1, PARAM_BOOL);
 
         if (($edit != -1) and $PAGE->user_allowed_editing()) {
@@ -140,53 +124,11 @@ class resource_base {
 
         $PAGE->print_header($this->course->shortname.': %fullname%', $morenavlinks, "", "",
                             update_module_button($this->cm->id, $this->course->id, $this->strresource));
-
-        echo '<table id="layout-table"><tr>';
-
-            $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
-        foreach ($lt as $column) {
-            $lt1[] = $column;
-            if ($column == 'middle') break;
-        }
-        foreach ($lt1 as $column) {
-            switch ($column) {
-                case 'left':
-                    if((blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
-                        echo '<td style="width: '.$blocks_preferred_width.'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(false, 'middle-column-wrap');
-                    echo '<div id="resource">';
-                break;
-
-                case 'right':
-                    if((blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing())) {
-                        echo '<td style="width: '.$blocks_preferred_width.'px;" id="right-column">';
-                        print_container_start();
-                        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-                        print_container_end();
-                        echo '</td>';
-                    }
-                break;
-            }
-        }
     }
 
 
     /**
      * Finish displaying the resource with the course blocks
-     *
-     * @global stdClass
-     * @global object
-     * @uses BLOCK_POS_LEFT
-     * @uses BLOCK_POS_RIGHT
      */
     function display_course_blocks_end() {
         global $CFG, $THEME;
index 5a5eb8c433eda58e7c2664158f5772d4175c20e1..57f1a022af8429243442e0a874ac46e67528d183 100644 (file)
     $PAGE->set_url('my/index.php');
     $PAGE->set_blocks_editing_capability('moodle/my:manageblocks');
 
-    // Note: MDL-19010 there will be further changes to printing header and blocks.
-    // The code will be much nicer than this eventually.
-    $pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
-
     if (($edit != -1) and $PAGE->user_allowed_editing()) {
         $USER->editing = $edit;
     }
 
     print_header($strmymoodle, $header, $navigation, '', '', true, $button, $loggedinas . $langmenu);
 
-    echo '<table id="layout-table">';
-    echo '<tr valign="top">';
-
-    $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
-    foreach ($lt as $column) {
-        switch ($column) {
-            case 'left':
-
-    $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
-
-    if(blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
-        echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'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 valign="top" id="middle-column">';
-    print_container_start(TRUE);
-
 /// The main overview in the middle of the page
-    
+
     // limits the number of courses showing up
     $courses_limit = 21;
     if (!empty($CFG->mycoursesperpage)) {
             $courses[$c->id]->lastaccess = 0;
         }
     }
-    
+
     if (empty($courses)) {
-        print_simple_box(get_string('nocourses','my'),'center');
+        print_box(get_string('nocourses','my'));
     } else {
         print_overview($courses);
     }
-    
+
     // if more than 20 courses
     if (count($courses) > 20) {
         echo '<br />...';  
     }
-    
-    print_container_end();
-    echo '</td>';
-    
-            break;
-            case 'right':
-            
-    $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
-
-    if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
-        echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
-        print_container_start();
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-        print_container_end();
-        echo '</td>';
-    }
-            break;
-        }
-    }
-
-    /// Finish the page
-    echo '</tr></table>';
 
     print_footer();
 
index a29ca6719b4822e3dddafee0f8a424b57d897460..a254f1d64b4b55c115778dba1a981e9dc3bb18c1 100644 (file)
@@ -33,7 +33,6 @@ if (empty($tag)) {
 $PAGE->set_url('tag/index.php', array('id' => $tag->id));
 $PAGE->set_subpage($tag->id);
 $PAGE->set_blocks_editing_capability('moodle/tag:editblocks');
-$pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
 
 if (($edit != -1) and $PAGE->user_allowed_editing()) {
     $USER->editing = $edit;
@@ -61,23 +60,6 @@ if (has_capability('moodle/tag:manage', $systemcontext)) {
     echo '<div class="managelink"><a href="'. $CFG->wwwroot .'/tag/manage.php">'. get_string('managetags', 'tag') .'</a></div>' ;
 }
 
-echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
-echo '<tr valign="top">';
-
-//----------------- left column -----------------
-
-$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
-
-if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
-    echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
-    blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-    echo '</td>';
-}
-
-//----------------- middle column -----------------
-
-echo '<td valign="top" id="middle-column">';
-
 $tagname  = tag_display_name($tag);
 
 if ($tag->flag > 0 && has_capability('moodle/tag:manage', $systemcontext)) {
@@ -168,20 +150,5 @@ if ($usercount > 0) {
     print_box_end();
 }
 
-echo '</td>';
-
-//----------------- right column -----------------
-
-$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
-
-if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
-    echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
-    blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-    echo '</td>';
-}
-
-/// Finish the page
-echo '</tr></table>';
-
 print_footer();
 ?>
index 313ca0504817750e65ec4dd78effd26b533bad9d..4bfd1b8e2c1602bb329a38ef71b51b9fa7b602d1 100644 (file)
@@ -14,6 +14,18 @@ $query   = optional_param('query', '', PARAM_RAW);
 $page    = optional_param('page', 0, PARAM_INT); // which page to show
 $perpage = optional_param('perpage', 18, PARAM_INT);
 
+$params = array();
+if ($query) {
+    $params['query'] = $query;
+}
+if ($page) {
+    $params['page'] = $page;
+}
+if ($perpage) {
+    $params['perpage'] = $perpage;
+}
+$PAGE->set_url('tag/search.php', $params);
+
 $navlinks = array();
 $navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
 $navigation = build_navigation($navlinks);
diff --git a/test.php b/test.php
new file mode 100644 (file)
index 0000000..76a873f
--- /dev/null
+++ b/test.php
@@ -0,0 +1,8 @@
+<?php
+$things = array('block', 'mod', 'format');
+unset($things[array_search('mod', $things)]);
+echo '<pre>';
+var_dump($things);
+echo '</pre>';
+
+?>
\ No newline at end of file
index ff07fda9a355dcec99e96b6dca63b32ff0404433..aa3fcf901e12e6d3537f5654dd5470dcc1eaf474 100644 (file)
@@ -81,6 +81,11 @@ $THEME->parentmetainclude = false;
 /// <head></head> part of the page.
 
 
+$THEME->block_l_max_width = 200;
+$THEME->block_r_max_width = 200;
+/// Deprecated, but needed until this themes is updated to use layout.php
+
+
 $THEME->navmenuwidth = 50;
 
 /// You can use this to control the cutoff point for strings 
index e6cb506c1ef6dbb057bb640811b7325b3b741308..eed045b1577ab83f764be8866d6dd1728e3c37ca 100644 (file)
@@ -79,6 +79,9 @@ $THEME->parentmetainclude = false;
 /// to include a file meta.php from the parent theme into the
 /// <head></head> part of the page.
 
+$THEME->block_l_max_width = 200;
+$THEME->block_r_max_width = 200;
+/// Deprecated, but needed until this themes is updated to use layout.php
 
 $THEME->navmenuwidth = 50;
 
index 9f666af3aeb3218f91950c818a05791203eef1d7..e87e8610f02fea32985104b3e607541ee2cc67e4 100644 (file)
@@ -133,46 +133,24 @@ class custom_corners_core_renderer extends moodle_core_renderer {
         $output .= $this->output_start_tag('div', $bc->attributes);
         $output .= $this->output_start_tag('div', array('class' => 'wrap'));
 
-        if ($bc->heading) {
-            // Some callers pass in complete html for the heading, which may include
-            // complicated things such as the 'hide block' button; some just pass in
-            // text. If they only pass in plain text i.e. it doesn't include a
-            // <div>, then we add in standard tags that make it look like a normal
-            // page block including the h2 for accessibility
-            if (strpos($bc->heading, '</div>') === false) {
-                $bc->heading = $this->output_tag('div', array('class' => 'title'),
-                        $this->output_tag('h2', null, $bc->heading));
-            }
+        $controlshtml = $this->block_controls($bc->controls);
 
+        $title = '';
+        if ($bc->title) {
+            $title = $this->output_tag('h2', null, $bc->title);
+        }
+
+        if ($title || $controlshtml) {
             $output .= '<div class="header"><div class="bt"><div>&nbsp;</div></div>';
             $output .= '<div class="i1"><div class="i2"><div class="i3">';
-            $output .= $bc->heading;
+            $output .= '<div class="title">' . $title . $controlshtml . '</div>';
             $output .= '</div></div></div></div>';
         } else {
             $output .= '<div class="bt"><div>&nbsp;</div></div>';
         }
 
         $output .= '<div class="i1"><div class="i2"><div class="i3"><div class="content">';
-
-        if ($bc->content) {
-            $output .= $bc->content;
-
-        } else if ($bc->list) {
-            $row = 0;
-            $output .= $this->output_start_tag('ul', array('class' => 'list'));
-            $items = array();
-            foreach ($bc->list as $key => $string) {
-                $item = $this->output_start_tag('li', array('class' => 'r' . $row));
-                if ($bc->icons) {
-                    $item .= $this->output_tag('div', array('class' => 'icon column c0'), $bc->icons[$key]);
-                }
-                $item .= $this->output_tag('div', array('class' => 'column c1'), $string);
-                $item .= $this->output_end_tag('li');
-                $items[] = $item;
-                $row = 1 - $row; // Flip even/odd.
-            }
-            $output .= $this->output_tag('ul', array('class' => 'list'), implode("\n", $items));
-        }
+        $output .= $bc->content;
 
         if ($bc->footer) {
             $output .= $this->output_tag('div', array('class' => 'footer'), $bc->footer);
@@ -181,13 +159,7 @@ class custom_corners_core_renderer extends moodle_core_renderer {
         $output .= '</div></div></div></div><div class="bb"><div>&nbsp;</div></div></div></div>';
         $output .= $skipdest;
 
-        if (!empty($CFG->allowuserblockhiding) && isset($attributes['id'])) {
-            $strshow = addslashes_js(get_string('showblocka', 'access', $title));
-            $strhide = addslashes_js(get_string('hideblocka', 'access', $title));
-            $output .= $this->page->requires->js_function_call('elementCookieHide', array(
-                    $bc->id, $strshow, $strhide))->asap();
-        }
-
+        $this->init_block_hider_js($bc);
         return $output;
     }
 
index 97aea111999fc3aa1eadd54e4ed795f661d3f597..dd28ffb765c5966fed2bf0ae6c3345a84e7e86be 100644 (file)
@@ -44,12 +44,35 @@ $THEME->standardmetainclude = true;
 
 $THEME->custompix = false;
 
-$THEME->layouttemplates = array(
-    'normal' => 'layout.php',
-    'home' => 'layout-home.php',
+$THEME->layouts = array(
+    // Most pages. Put this first, so if we encounter an unknown page type, this is used.
+    'normal' => array(
+        'layout' => 'layout.php',
+        'regions' => array('side-pre', 'side-post'),
+        'defaultregion' => 'side-post'
+    ),
+    // The site home page.
+    'home' => array(
+        'layout' => 'layout-home.php',
+        'regions' => array('side-pre', 'side-post'),
+        'defaultregion' => 'side-post'
+    ),
+    // Settings form pages, like course of module settings.
+    'form' => array(
+        'layout' => 'layout.php',
+        'regions' => array(),
+    ),
+    // Pages that appear in pop-up windows.
+    'popup' => array(
+        'layout' => 'layout-popup.php',
+        'regions' => array(),
+    ),
+    // Used during upgrade and install, and for the 'This site is undergoing maintenance' message.
+    'maintenance' => array(
+        'layout' => 'layout-popup.php',
+        'regions' => array(),
+    ),
 );
-$THEME->blockregions = array('side-pre', 'side-post');
-$THEME->defaultblockregion = 'side-post';
 
 $THEME->resource_mp3player_colors =
  'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.
index 28edf447cdcd9f087148481fe50b66ab2a003a59..e5c45d511f67c55734192745e214e6be8fce31f2 100644 (file)
     <hr />
 <!-- END OF HEADER -->
 
-    <div id="content" class="clearfix">
-        [MAIN CONTENT GOES HERE]
-    </div>
+<!-- Note, we will not be using tables for layout evenutally. However, for now
+     I have enough other things to worry about that I don't have time to make
+     a multi-column cross-browser layout too, so this is a temporary hack. -->
+    <table id="layout-table" summary="layout">
+        <tr>
+            <?php if ($PAGE->blocks->region_has_content('side-pre')) { ?>
+            <td id="region-side-pre" class="block-region">
+                <?php echo $OUTPUT->blocks_for_region('side-pre') ?>
+            </td>
+            <?php } ?>
+            <td id="content">
+                [MAIN CONTENT GOES HERE]
+            </td>
+            <?php if ($PAGE->blocks->region_has_content('side-post')) { ?>
+            <td id="region-side-post" class="block-region">
+                <?php echo $OUTPUT->blocks_for_region('side-post') ?>
+            </td>
+            <?php } ?>
+        </tr>
+    </table>
 
 <!-- START OF FOOTER -->
     <div id="footer" class="clearfix">
similarity index 79%
rename from theme/standardwhite/layout-popup.php
rename to theme/standard/layout-popup.php
index b4ada2ae2dc07b2dbf3bbc5447561943dc38a51e..e62ec7f328316426755b03219f963dab56c6472c 100644 (file)
 
 <div id="page">
 
+<?php if ($PAGE->heading) { ?>
+    <div id="header" class="clearfix">
+        <h1 class="headermain"><?php echo $PAGE->heading ?></h1>
+        <div class="headermenu"><?php echo $menu ?></div>
+    </div>
+<?php } ?>
+
 <?php if ($navigation) { // This is the navigation bar with breadcrumbs  ?>
     <div class="navbar clearfix">
         <div class="breadcrumb"><?php print_navigation($navigation); ?></div>
@@ -26,7 +33,7 @@
 
 <!-- START OF FOOTER -->
     <div id="footer" class="clearfix">
-
+        <?php echo $OUTPUT->standard_footer_html() ?>
     </div>
 </div>
 <?php echo $OUTPUT->standard_end_of_body_html() ?>
index f0c441ae81183c14d06c3d511e0ed2eea0798153..48b8ac90426e1956ed397154715305f9a6267812 100644 (file)
 <?php } ?>
 <!-- END OF HEADER -->
 
-    <div id="content" class="clearfix">
-        [MAIN CONTENT GOES HERE]
-    </div>
+<!-- Note, we will not be using tables for layout evenutally. However, for now
+     I have enough other things to worry about that I don't have time to make
+     a multi-column cross-browser layout too, so this is a temporary hack. -->
+    <table id="layout-table" summary="layout">
+        <tr>
+            <?php if ($PAGE->blocks->region_has_content('side-pre')) { ?>
+            <td id="region-side-pre" class="block-region">
+                <?php echo $OUTPUT->blocks_for_region('side-pre') ?>
+            </td>
+            <?php } ?>
+            <td id="content">
+                <?php echo $OUTPUT->skip_link_target(); ?>
+                [MAIN CONTENT GOES HERE]
+            </td>
+            <?php if ($PAGE->blocks->region_has_content('side-post')) { ?>
+            <td id="region-side-post" class="block-region">
+                <?php echo $OUTPUT->blocks_for_region('side-post') ?>
+            </td>
+            <?php } ?>
+        </tr>
+    </table>
 
 <!-- START OF FOOTER -->
     <div id="footer" class="clearfix">
index 7f75dd855503ca0e9c65ad5f81891cfe9d589f0a..a12bb92f032352c108bac202946639db2d49bc4b 100644 (file)
@@ -488,9 +488,7 @@ table.flexible .r1 {
   border-top-color:#999999;
 }
 
-#left-column .hidden .header,
-#right-column .hidden .header
-{
+.block-region .hidden .header {
   border-bottom-color: #dddddd;
 }
 
index 366d71fcdf6bfb51aa3158184e356ea5a498f187..1c827d69b02e5161a0f6068880640e8ab0b5b183 100755 (executable)
@@ -66,9 +66,6 @@ form.mform textarea {
 .course-view li.activity {
   height:0;
 }
-#mod-quiz-review #middle-column {
-  height: 1%;
-}
 #mod-quiz-edit div.question div.content .questiontext,
 #mod-quiz-edit #categoryquestions .questionname{
     /*ie6 shows this as an arrow if this is not specified*/
index 9b85a45d364058f615745f825e4b577a660c2b9d..3a5d6857e0cf823252b3d13e14a228732ddeee5c 100755 (executable)
@@ -56,9 +56,6 @@ form.mform textarea {
 form.mform .fcheckbox input {
   margin-left: -3px;
 }
-#mod-quiz-review #middle-column {
-  height: 1%;
-}
 .mod-quiz div.tabtree a span img.iconsmall {
   margin: 0;
   vertical-align: baseline;
index 6889b0f82c3517c14d4470c1e66eab286215395e..1604c6e3b2f74b36c3d6ff12643230c5f2388291 100644 (file)
@@ -50,14 +50,14 @@ h6.main {
   margin-top: 8px;
 }
 
-#layout-table #left-column,
-#layout-table #middle-column,
-#layout-table #right-column
+#layout-table #region-side-pre,
+#layout-table #content,
+#layout-table #region-side-post
 {
   vertical-align:top;
 }
 
-#layout-table #middle-column {
+#layout-table #content {
   padding-left:12px;
   padding-right:12px;
 }
@@ -1569,16 +1569,19 @@ a.skip:focus, a.skip:active {
   margin: 0px 2px;
 }
 
-#left-column .hidden .header,
-#right-column .hidden .header
-{
+.block-region .hidden .header {
   border-bottom-width: 1px;
   border-bottom-style: solid;
 }
+#region-side-pre,
+#region-side-post {
+  width: 12em;
+}
+#content {
+  width: auto;
+}
 
-#left-column .hidden .content,
-#right-column .hidden .content
-{
+.block-region .hidden .content {
   display: none;
 }
 
@@ -2194,24 +2197,6 @@ border-width:0px;
 .topics-format .block_calendar_month .minicalendar td {
   padding: 0.1em 0 0.1em 1px;
 }
-.weeks-format #middle-column ,
-.topics-format #middle-column {
-  margin: 0 12.5em 0 12.5em;
-}
-.weeks-format #left-column,
-.weeks-format #right-column,
-.topics-format #left-column,
-.topics-format #right-column {
-  width: 11.5em;
-}
-.weeks-format #left-column,
-.topics-format #left-column {
-  float: left;
-}
-.weeks-format #right-column,
-.topics-format #right-column {
-  float: right;
-}
 .weeks li.section ,
 .topics li.section {
   margin-bottom: 0.5em;
@@ -2334,20 +2319,20 @@ body#admin-course-category .buttons {
   margin-bottom: 15px;
 }
 
-body#admin-course-index #middle-column .editcourse {
+body#admin-course-index .editcourse {
   margin-left:auto;
   margin-right:auto;
   margin-top:20px;
   margin-bottom:20px;
 }
 
-body#admin-course-index #middle-column .editcourse th,
-body#admin-course-index #middle-column .editcourse td {
+body#admin-course-index .editcourse th,
+body#admin-course-index .editcourse td {
   padding-left:10px;
   padding-right:10px;
 }
 
-body#admin-course-index #middle-column .editcourse .count {
+body#admin-course-index .editcourse .count {
   text-align:right;
 }
 
@@ -4366,16 +4351,6 @@ body.jsenabled .jshidewhenenabled {
 #passwordform {
   margin: 1em 0;
 }
-#mod-quiz-attempt #middle-column,
-#mod-quiz-review #middle-column {
-  text-align: center;
-  margin: 0 0 0 12.5em;
-}
-#mod-quiz-attempt #left-column,
-#mod-quiz-review #left-column {
-  width: 11.5em;
-  float: left;
-}
 #mod-quiz-attempt .submitbtns,
 #mod-quiz-review .submitbtns {
   text-align: left;
@@ -4603,10 +4578,6 @@ table.quizreviewsummary td.cell {
   text-align: center;
   margin: 6px 0;
 }
-#mod-quiz-attempt #left-column,
-#mod-quiz-review #left-column {
-  padding-top: 1px;
-}
 #quiznavigation .qnbutton {
   display: block;
   float: left;
index 89ecba31fc729cecfdc7446ea225adb20fec1106..f57def84ce261d3c50b02d6a26f03eb062b0e7e0 100644 (file)
@@ -44,12 +44,35 @@ $THEME->standardmetainclude = true;
 
 $THEME->custompix = false;
 
-$THEME->layouttemplates = array(
-    'normal' => 'layout.php',
-    'home' => 'layout-home.php',
+$THEME->layouts = array(
+    // Most pages. Put this first, so if we encounter an unknown page type, this is used.
+    'normal' => array(
+        'layout' => 'standard:layout.php',
+        'regions' => array('side-pre', 'side-post'),
+        'defaultregion' => 'side-post'
+    ),
+    // The site home page.
+    'home' => array(
+        'layout' => 'standard:layout-home.php',
+        'regions' => array('side-pre', 'side-post'),
+        'defaultregion' => 'side-post'
+    ),
+    // Settings form pages, like course of module settings.
+    'form' => array(
+        'layout' => 'standard:layout.php',
+        'regions' => array(),
+    ),
+    // Pages that appear in pop-up windows.
+    'popup' => array(
+        'layout' => 'standard:layout-popup.php',
+        'regions' => array(),
+    ),
+    // Used during upgrade and install, and for the 'This site is undergoing maintenance' message.
+    'maintenance' => array(
+        'layout' => 'standard:layout-popup.php',
+        'regions' => array(),
+    ),
 );
-$THEME->blockregions = array('side-pre', 'side-post');
-$THEME->defaultblockregion = 'side-post';
 
 $THEME->resource_mp3player_colors = 
  'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.
diff --git a/theme/standardwhite/layout-home.php b/theme/standardwhite/layout-home.php
deleted file mode 100644 (file)
index 28edf44..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php echo $OUTPUT->doctype() ?>
-<html <?php echo $OUTPUT->htmlattributes() ?>>
-<head>
-    <?php echo $OUTPUT->standard_head_html() ?>
-    <title><?php echo $PAGE->title ?></title>
-    <link rel="shortcut icon" href="<?php echo $CFG->themewww .'/'. current_theme() ?>/favicon.ico" />
-    <meta name="description" content="<?php echo strip_tags(format_text($SITE->summary, FORMAT_HTML)) ?>" />
-</head>
-<body id="<?php echo $PAGE->pagetype ?>" class="<?php echo $PAGE->bodyclasses ?>">
-<?php echo $OUTPUT->standard_top_of_body_html() ?>
-
-<div id="page">
-
-    <div id="header-home" class="clearfix">
-        <h1 class="headermain"><?php echo $PAGE->heading ?></h1>
-        <div class="headermenu"><?php
-        if ($menu) {
-            echo $menu;
-        } else {
-            echo $OUTPUT->login_info();
-        }
-        ?></div>
-    </div>
-    <hr />
-<!-- END OF HEADER -->
-
-    <div id="content" class="clearfix">
-        [MAIN CONTENT GOES HERE]
-    </div>
-
-<!-- START OF FOOTER -->
-    <div id="footer" class="clearfix">
-        <p class="helplink">
-        <?php echo page_doc_link(get_string('moodledocslink')) ?>
-        </p>
-
-        <?php
-        echo $OUTPUT->login_info();
-        echo $OUTPUT->home_link();
-        echo $OUTPUT->standard_footer_html();
-        ?>
-    </div>
-</div>
-<?php echo $OUTPUT->standard_end_of_body_html() ?>
-</body>
-</html>
\ No newline at end of file
diff --git a/theme/standardwhite/layout.php b/theme/standardwhite/layout.php
deleted file mode 100644 (file)
index f0c441a..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php echo $OUTPUT->doctype() ?>
-<html <?php echo $OUTPUT->htmlattributes() ?>>
-<head>
-    <title><?php echo $PAGE->title ?></title>
-    <link rel="shortcut icon" href="<?php echo $CFG->themewww .'/'. current_theme() ?>/favicon.ico" />
-    <?php echo $OUTPUT->standard_head_html() ?>
-</head>
-<body id="<?php echo $PAGE->pagetype ?>" class="<?php echo $PAGE->bodyclasses ?>">
-<?php echo $OUTPUT->standard_top_of_body_html() ?>
-
-<div id="page">
-
-<?php if ($PAGE->heading) { ?>
-    <div id="header" class="clearfix">
-        <h1 class="headermain"><?php echo $PAGE->heading ?></h1>
-        <div class="headermenu"><?php echo $menu ?></div>
-    </div>
-<?php } ?>
-
-<?php if ($navigation) { // This is the navigation bar with breadcrumbs  ?>
-    <div class="navbar clearfix">
-        <div class="breadcrumb"><?php print_navigation($navigation); ?></div>
-        <div class="navbutton"><?php echo $PAGE->button; ?></div>
-    </div>
-<?php } else if ($PAGE->heading) { // If no navigation, but a heading, then print a line ?>
-    <hr />
-<?php } ?>
-<!-- END OF HEADER -->
-
-    <div id="content" class="clearfix">
-        [MAIN CONTENT GOES HERE]
-    </div>
-
-<!-- START OF FOOTER -->
-    <div id="footer" class="clearfix">
-        <p class="helplink">
-        <?php echo page_doc_link(get_string('moodledocslink')) ?>
-        </p>
-
-        <?php
-        echo $OUTPUT->login_info();
-        echo $OUTPUT->home_link();
-        echo $OUTPUT->standard_footer_html();
-        ?>
-    </div>
-</div>
-<?php echo $OUTPUT->standard_end_of_body_html() ?>
-</body>
-</html>
\ No newline at end of file
index f36d938a6c218e56a2f8317c8ad179a4a357d7b8..b62d5dcebc084eaa0a34460b5d938867fff77f3e 100644 (file)
@@ -18,6 +18,7 @@
     }
     if (!empty($USER->newadminuser)) {
         $PAGE->set_course($SITE);
+        $PAGE->set_generaltype('maintenance');
     } else {
         require_login($course);
     }
     $userform->display();
 
 /// and proper footer
-    if (!empty($USER->newadminuser)) {
-        print_footer('none');
-    } else {
-        print_footer($course);
-    }
+    print_footer();
 
 ?>