MDL-9506 More work in the unit tests
[moodle-pu.git] / admin / stickyblocks.php
blob38d999e482b31045344cc4b81f93d054c073ce0d
1 <?PHP // $Id$
3 require_once('../config.php');
4 require_once($CFG->dirroot.'/my/pagelib.php');
5 require_once($CFG->dirroot.'/lib/pagelib.php');
6 require_once($CFG->dirroot.'/lib/blocklib.php');
8 $pt = optional_param('pt', null, PARAM_SAFEDIR); //alhanumeric and -
10 $pagetypes = array(PAGE_MY_MOODLE => array('id' => PAGE_MY_MOODLE,
11 'lib' => '/my/pagelib.php',
12 'name' => get_string('mymoodle','admin')),
13 PAGE_COURSE_VIEW => array('id' => PAGE_COURSE_VIEW,
14 'lib' => '/lib/pagelib.php',
15 'name' => get_string('stickyblockscourseview','admin'))
16 // ... more?
19 // for choose_from_menu
20 $options = array();
21 foreach ($pagetypes as $p) {
22 $options[$p['id']] = $p['name'];
25 require_login();
27 require_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID));
29 // first thing to do is print the dropdown menu
31 $strtitle = get_string('stickyblocks','admin');
32 $strheading = get_string('adminhelpstickyblocks');
36 if (!empty($pt)) {
38 require_once($CFG->dirroot.$pagetypes[$pt]['lib']);
40 define('ADMIN_STICKYBLOCKS',$pt);
42 $PAGE = page_create_object($pt, SITEID);
43 $blocks = blocks_setup($PAGE,BLOCKS_PINNED_TRUE);
44 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($blocks[BLOCK_POS_LEFT]), 210);
46 print_header($strtitle,$strtitle,'<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/index.php">'.
47 get_string('administration').'</a> -> '.$strtitle);
49 echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
50 echo '<tr valign="top">';
52 echo '<td valign="top" style="width: '.$blocks_preferred_width.'px;" id="left-column">';
54 blocks_print_group($PAGE, $blocks, BLOCK_POS_LEFT);
55 echo '</td>';
56 echo '<td valign="top" id="middle-column">';
58 } else {
59 require_once($CFG->libdir.'/adminlib.php');
60 $adminroot = admin_get_root();
61 admin_externalpage_setup('stickyblocks', $adminroot);
62 admin_externalpage_print_header($adminroot);
66 print_box_start();
67 print_heading($strheading);
68 popup_form("$CFG->wwwroot/$CFG->admin/stickyblocks.php?pt=", $options, 'selecttype', $pt, 'choose', '', '', false, 'self', get_string('stickyblockspagetype','admin').': ');
69 echo '<p>'.get_string('stickyblocksduplicatenotice','admin').'</p>';
70 print_box_end();
73 if (!empty($pt)) {
74 echo '</td>';
75 echo '<td valign="top" style="width: '.$blocks_preferred_width.'px;" id="left-column">';
76 blocks_print_group($PAGE, $blocks, BLOCK_POS_RIGHT);
77 echo '</td>';
78 echo '</tr></table>';
79 print_footer();
80 } else {
81 admin_externalpage_print_footer($adminroot);