File: stickyblocks.php

package info (click to toggle)
moodle 1.6.3-2%2Betch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 37,172 kB
  • ctags: 51,688
  • sloc: php: 231,916; sql: 5,631; xml: 2,688; sh: 1,185; perl: 638; makefile: 48; pascal: 36
file content (87 lines) | stat: -rw-r--r-- 3,196 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?PHP // $Id: stickyblocks.php,v 1.2.2.2 2006/07/19 07:59:17 skodak Exp $
    
    require_once('../config.php');
    require_once($CFG->dirroot.'/my/pagelib.php');
    require_once($CFG->dirroot.'/lib/pagelib.php');
    require_once($CFG->dirroot.'/lib/blocklib.php');

    $pt  = optional_param('pt', null, PARAM_SAFEDIR); //alhanumeric and -

    $pagetypes = array(PAGE_MY_MOODLE => array('id' => PAGE_MY_MOODLE,
                                              'lib' => '/my/pagelib.php',
                                              'name' => get_string('stickyblocksmymoodle','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();
  
    if (!isadmin()) {
        error("Only the admin can use this page");
    }

    // first thing to do is print the dropdown menu

    $strtitle = get_string('stickyblocks','admin');
    $strheading = get_string('adminhelpstickyblocks');
    
    print_header($strtitle,$strtitle,'<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/index.php">'.
                 get_string('admin').'</a> -> <a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/misc.php">'.
                 get_string('miscellaneous').'</a> ->'.$strtitle);

    echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
    echo '<tr valign="top">';
    

    if (!empty($pt)) {
        require_once($CFG->dirroot.$pagetypes[$pt]['lib']);
        
        define('ADMIN_STICKYBLOCKS',$pt);
        
        $PAGE = page_create_object($pt);
        
        $blocks = blocks_setup($PAGE,BLOCKS_PINNED_TRUE);
        
        $blocks_preferred_width = bounded_number(180, blocks_preferred_width($blocks[BLOCK_POS_LEFT]), 210);
        echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
        
        blocks_print_group($PAGE, $blocks, BLOCK_POS_LEFT);
    } else {
        echo '<td style="vertical-align: top;" id="left-column">';
    }
    echo '</td>';


    echo '<td valign="top" width="*" id="middle-column">';
    print_simple_box_start('center');
    print_heading($strheading);
    echo '<form method="post" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/stickyblocks.php">'
        .'<p align="center">'.get_string('stickyblockspagetype','admin').': ';
    choose_from_menu($options,'pt',$pt,'choose','this.form.submit();');
    echo '</p></form>';
    echo get_string('stickyblocksduplicatenotice','admin');
    print_simple_box_end();
    echo '</td>';


    if (!empty($pt)) {
        echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
        blocks_print_group($PAGE, $blocks, BLOCK_POS_RIGHT);
    }
    echo '<td style="vertical-align: top;" id="left-column">';
    echo '</td>';
  
    echo '</tr></table>';

    print_footer();
    

?>