本文整理汇总了PHP中blocks_setup函数的典型用法代码示例。如果您正苦于以下问题:PHP blocks_setup函数的具体用法?PHP blocks_setup怎么用?PHP blocks_setup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了blocks_setup函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_header
/**
* 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);
}
}
示例2: set_moodle_cookie
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) {
示例3: redirect
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;
}
}
}
示例4: display_course_blocks_end
/**
* 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);
}
示例5: display_course_blocks_end
/**
* 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);
}
示例6: array
$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();
}
示例7: wiki_header
/**
* 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();
//.........这里部分代码省略.........
示例8: tao_local_header_hook
/**
* 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);
}
示例9: admin_externalpage_print_footer
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();
}
示例10: page_setup
/**
* 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;
}