/** * Prints the page header. */ function print_header() { global $CFG, $USER, $PAGE; require_once $CFG->libdir . '/blocklib.php'; require_once $CFG->dirroot . '/course/lib.php'; require_once $CFG->dirroot . '/my/pagelib.php'; /// My Moodle arguments: $edit = optional_param('edit', -1, PARAM_BOOL); $blockaction = optional_param('blockaction', '', PARAM_ALPHA); $mymoodlestr = get_string('mymoodle', 'my'); if (isguest()) { $wwwroot = $CFG->wwwroot . '/login/index.php'; if (!empty($CFG->loginhttps)) { $wwwroot = str_replace('http:', 'https:', $wwwroot); } print_header($mymoodlestr); notice_yesno(get_string('noguest', 'my') . '<br /><br />' . get_string('liketologin'), $wwwroot, $CFG->wwwroot); print_footer(); die; } /// Add curriculum stylesheets... if (file_exists($CFG->dirroot . '/curriculum/styles.css')) { $CFG->stylesheets[] = $CFG->wwwroot . '/curriculum/styles.css'; } /// Fool the page library into thinking we're in My Moodle. $CFG->pagepath = $CFG->wwwroot . '/my/index.php'; $PAGE = page_create_instance($USER->id); if ($section = optional_param('section', '', PARAM_ALPHAEXT)) { $PAGE->section = $section; } $this->pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH); /// Make sure that the curriculum block is actually on this /// user's My Moodle page instance. if ($cablockid = get_field('block', 'id', 'name', 'curr_admin')) { if (!record_exists('block_pinned', 'blockid', $cablockid, 'pagetype', 'my-index')) { blocks_execute_action($PAGE, $this->pageblocks, 'add', (int) $cablockid, true, false); } } if ($edit != -1 and $PAGE->user_allowed_editing()) { $USER->editing = $edit; } //$PAGE->print_header($mymoodlestr); $title = $this->get_title(); print_header($title, $title, build_navigation($this->get_navigation())); echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">'; echo '<tr valign="top">'; $blocks_preferred_width = bounded_number(180, blocks_preferred_width($this->pageblocks[BLOCK_POS_LEFT]), 210); if (blocks_have_content($this->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, $this->pageblocks, BLOCK_POS_LEFT); echo '</td>'; } echo '<td valign="top" id="middle-column">'; if (blocks_have_content($this->pageblocks, BLOCK_POS_CENTRE) || $PAGE->user_is_editing()) { blocks_print_group($PAGE, $this->pageblocks, BLOCK_POS_CENTRE); } }
set_moodle_cookie('nobody'); // To help search for cookies on login page } if (!empty($USER->id)) { add_to_log(SITEID, 'course', 'view', 'view.php?id=' . SITEID, SITEID); } if (empty($CFG->langmenu)) { $langmenu = ''; } else { $currlang = current_language(); $langs = get_list_of_languages(); $langlabel = get_accesshide(get_string('language')); $langmenu = popup_form($CFG->wwwroot . '/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true, 'self', $langlabel); } $PAGE = page_create_object(PAGE_COURSE_VIEW, SITEID); $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', '', '<meta name="description" content="' . strip_tags(format_text($SITE->summary, FORMAT_HTML)) . '" />', 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) {
if (function_exists('extern_server_course')) { if ($extern_url = extern_server_course($course)) { redirect($extern_url); } } } require_once $CFG->dirroot . '/calendar/lib.php'; /// This is after login because it needs $USER add_to_log($course->id, 'course', 'view', "view.php?id={$course->id}", "{$course->id}"); $course->format = clean_param($course->format, PARAM_ALPHA); if (!file_exists($CFG->dirroot . '/course/format/' . $course->format . '/format.php')) { $course->format = 'weeks'; // Default format is weeks } $PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id); $pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH); if (!isset($USER->editing)) { $USER->editing = 0; } if ($PAGE->user_allowed_editing()) { if ($edit == 1 and confirm_sesskey()) { $USER->editing = 1; } else { if ($edit == 0 and confirm_sesskey()) { $USER->editing = 0; if (!empty($USER->activitycopy) && $USER->activitycopycourse == $course->id) { $USER->activitycopy = false; $USER->activitycopycourse = NULL; } } }
/** * Finish displaying the resource with the course blocks */ function display_course_blocks_end() { global $CFG; global $THEME; $PAGE = $this->PAGE; $pageblocks = blocks_setup($PAGE); $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210); $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; } } } foreach ($lt 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 '</div>'; print_container_end(); echo '</td>'; 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; } } echo '</tr></table>'; print_footer($this->course); }
/** * Print footer on admin page - please use normal print_footer() instead */ function admin_externalpage_print_footer() { global $CFG, $PAGE, $SITE, $THEME; define('ADMIN_EXT_FOOTER_PRINTED', 'true'); if (!empty($SITE->fullname)) { $pageblocks = blocks_setup($PAGE); $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); $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; } } } 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 error()/notice() autoclosing problems on admin pages echo '</td>'; break; case 'right': if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) { echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">'; print_container_start(); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); print_container_end(); echo '</td>'; } break; } } echo '</tr></table>'; } print_footer(); }
/** * Finish displaying the resource with the course blocks */ function display_course_blocks_end() { global $CFG; $PAGE = $this->PAGE; $pageblocks = blocks_setup($PAGE); $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210); echo '</div>'; if (!empty($THEME->customcorners)) { print_custom_corners_end(); } echo '</td>'; if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) { echo '<td style="width: ' . $blocks_preferred_width . 'px;" id="right-column">'; if (!empty($THEME->customcorners)) { print_custom_corners_start(); } blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); if (!empty($THEME->customcorners)) { print_custom_corners_end(); } echo '</td>'; } echo '</tr></table>'; print_footer($this->course); }
$pagetypes = array(PAGE_MY_MOODLE => array('id' => PAGE_MY_MOODLE, 'lib' => '/my/pagelib.php', 'name' => get_string('mymoodle', 'admin')), PAGE_COURSE_VIEW => array('id' => PAGE_COURSE_VIEW, 'lib' => '/lib/pagelib.php', 'name' => get_string('stickyblockscourseview', 'admin'))); // 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, SITEID)); // 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">'; if (!empty($THEME->customcorners)) { print_custom_corners_start(); } blocks_print_group($PAGE, $blocks, BLOCK_POS_LEFT); if (!empty($THEME->customcorners)) { print_custom_corners_end(); }
/** * Module Blocked Format for Moodle * * @author DFWiki LABS * @author Marc Alier i Forment * @author David Castro, Ferran Recio, Jordi Piguillem, UPC, * and members of DFWikiteam listed at http://morfeo.upc.edu/crom * @version $Id: web.lib.php,v 1.5 2008/05/05 09:10:43 pigui Exp $ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package Activity_Format */ function wiki_header() { global $COURSE, $CFG, $WS; //define block sizes define('BLOCK_L_MIN_WIDTH', 100); define('BLOCK_L_MAX_WIDTH', 210); define('BLOCK_R_MIN_WIDTH', 100); define('BLOCK_R_MAX_WIDTH', 210); $edit = optional_param('edit', NULL, PARAM_ALPHA); //This structure is used to use blocks //Standard blocks: $dfwiki = wiki_param('dfwiki'); //$PAGE = page_create_instance($dfwiki->id); $PAGE = page_create_object('mod-wiki-view', $dfwiki->id); //little patch: if body class is a subtype od mod-wiki, class is mod-wiki if (substr($PAGE->body_class, 0, 8) == 'mod-wiki') { $PAGE->body_class = 'mod-wiki'; } wiki_page_info('PAGE', $PAGE); //Needed function to make blocks work properly $pageblocks = blocks_setup($PAGE); wiki_page_info('pageblocks', $pageblocks); //Function that checks the edit permissions of the wiki wiki_check_edition($PAGE, $edit); //setup the module /// Print the page header if ($COURSE->category) { $navigation = "<a href=\"../../course/view.php?id={$COURSE->id}\">{$COURSE->shortname}</a> ->"; } //get names in both singular and plural $strdfwikis = get_string("modulenameplural", 'wiki'); $strdfwiki = get_string("modulename", 'wiki'); $PAGE->print_header($COURSE->shortname . ': %fullname%'); /// Print the main part of the page $prop = new stdClass(); $prop->class = "course-content"; wiki_div_start($prop); // course wrapper start //to work out the default widths need to check all blocks $preferred_width_left = optional_param('preferred_width_left', blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), PARAM_INT); //preferred_width_left sizes //should be between BLOCK_x_MAX_WIDTH and BLOCK_x_MIN_WIDTH. $preferred_width_left = min($preferred_width_left, BLOCK_L_MAX_WIDTH); $preferred_width_left = max($preferred_width_left, BLOCK_L_MIN_WIDTH); $cm = wiki_param('cm'); $context = get_context_instance(CONTEXT_MODULE, $cm->id); //shows a specific topic if (has_capability('mod/wiki:editawiki', $context) and isset($marker) and confirm_sesskey()) { $COURSE->marker = $marker; if (!set_field("course", "marker", $marker, "id", $COURSE->id)) { error("Could not mark that topic for this course"); } } //load strings $streditsummary = get_string('editsummary'); $stradd = get_string('add'); $stractivities = get_string('activities'); $strshowalltopics = get_string('showalltopics'); $strtopic = get_string('topic'); $strgroups = get_string('groups'); $strgroupmy = get_string('groupmy'); //checks if the user is editing $editing = $PAGE->user_is_editing(); //load editing strings if ($editing) { $strstudents = moodle_strtolower($COURSE->students); $strtopichide = get_string('topichide', '', $strstudents); $strtopicshow = get_string('topicshow', '', $strstudents); $strmarkthistopic = get_string('markthistopic'); $strmarkedthistopic = get_string('markedthistopic'); $strmoveup = get_string('moveup'); $strmovedown = get_string('movedown'); } //--------------------------------------------- INTERFACES BEGINS HERE /// Layout the whole page as three big columns. /// The left column ... //checks if there are blocks to place on the left-hand side if (!empty($CFG->showblocksonmodpages) && (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing)) { $prop = new stdClass(); $prop->id = "layout-table"; $prop->idtd = "left-column"; $prop->classtd = "blockcourse"; wiki_table_start($prop); $prop = new stdClass(); $prop->width = $preferred_width_left . 'px'; wiki_table_start($prop); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); wiki_table_end(); $prop = new stdClass(); $prop->id = "middle-column"; wiki_change_column($prop); } else { $prop = new stdClass(); $prop->id = "layout-table"; $prop->idtd = "middle-column"; wiki_table_start($prop); } /// Start main column //central block title //print_heading_block(get_string('wiki','wiki'), 'outline'); echo "<br />"; print_box($dfwiki->intro, "generalbox", "intro"); //begin the content table $prop = new stdClass(); $prop->class = "topics"; $prop->width = "100%"; wiki_table_start($prop); //print_tabs //TODO: clean it when all functionalities are parts global $CFG; //this function is the responsable of printing the content of the module. $dfcontent = wiki_param('dfcontent'); $dfcontentf = wiki_param('dfcontentf'); if (isset($dfcontent) && $dfcontent >= 0 && $dfcontent < count($dfcontentf)) { //we won't print tabs cause is an special situation (this comprobation will be removed when all ead are passed to parts) } else { wiki_print_tabs(); } }
/** * hook function from inside the theme. * in this case, detect lack of $PAGE and do a horrible hack * to get a consistent page format. */ function tao_local_header_hook() { global $CFG; require_once $CFG->libdir . '/blocklib.php'; require_once $CFG->libdir . '/pagelib.php'; global $PAGE; if (!empty($PAGE)) { return true; } if (defined('ADMIN_STICKYBLOCKS')) { return true; } if (optional_param('inpopup')) { return true; } $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; !defined('BLOCK_L_MIN_WIDTH') && define('BLOCK_L_MIN_WIDTH', $lmin); !defined('BLOCK_L_MAX_WIDTH') && define('BLOCK_L_MAX_WIDTH', $lmax); !defined('BLOCK_R_MIN_WIDTH') && define('BLOCK_R_MIN_WIDTH', $rmin); !defined('BLOCK_R_MAX_WIDTH') && define('BLOCK_R_MAX_WIDTH', $rmax); $PAGE = new tao_page_class_hack(); $pageblocks = blocks_setup($PAGE, true); // we could replace this with a stickyblocks implementation, this is a proof of concept. $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH); echo '<table id="layout-table" summary="layout"> <tr> '; echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">'; ob_start(); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); $blockscontent = ob_get_clean(); if (!$blockscontent) { $rec = (object) array('id' => 0, 'blockid' => 0, 'pageid' => 0, 'pagetype' => tao_page_class_hack::get_type(), 'position' => BLOCK_POS_LEFT, 'visible' => true, 'configdata' => '', 'weight' => 0); $pageblocks = array(BLOCK_POS_LEFT => array(0 => $rec)); $pageblocks[BLOCK_POS_LEFT][0]->rec = $rec; $pageblocks[BLOCK_POS_LEFT][0]->obj = new tao_dummy_block($rec); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); } else { echo $blockscontent; } echo '</td>'; echo '<td id="middle-column">'; define('TAO_HEADER_OVERRIDDEN', 1); }
function admin_externalpage_print_footer($adminroot) { global $CFG, $PAGE, $SITE, $THEME; if (!empty($SITE->fullname)) { $pageblocks = blocks_setup($PAGE); $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH); $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; } } } foreach ($lt as $column) { switch ($column) { case 'left': echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">'; if (!empty($THEME->customcorners)) { print_custom_corners_start(); } blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); if (!empty($THEME->customcorners)) { print_custom_corners_end(); } echo '</td>'; break; case 'middle': if (!empty($THEME->customcorners)) { print_custom_corners_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">'; if (!empty($THEME->customcorners)) { print_custom_corners_start(); } blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); if (!empty($THEME->customcorners)) { print_custom_corners_end(); } echo '</td>'; } break; } } echo '</tr></table>'; } print_footer(); }
/** * Setup page requirements, and some globals used by the format files. Ideally, these globals should be * moved to within the object. * */ function page_setup() { global $CFG, $course; global $PAGE, $pageblocks; /// These are needed in various library functions. require_once $CFG->dirroot . '/calendar/lib.php'; /// This is after login because it needs $USER add_to_log($course->id, 'course', 'view', "view.php?id={$course->id}", "{$course->id}"); if (!isset($PAGE)) { $this->page = page_create_object(PAGE_COURSE_VIEW, $this->course->id); $GLOBALS['PAGE'] =& $this->page; } else { $this->page = $PAGE; } if (!isset($pageblocks)) { $this->blocks = blocks_setup($this->page, BLOCKS_PINNED_BOTH); $GLOBALS['pageblocks'] =& $this->blocks; } else { $this->blocks = $pageblocks; } /// $PAGE is expecting to have its courserecord loaded at some point (usually in print_header). /// This means it will do another database call, which we don't need. Force the courserecord to be /// loaded and indicated here. (this really needs to be a $PAGE method). $this->page->courserecord =& $this->course; $this->page->full_init_done = true; }