本文整理汇总了PHP中block_manager::get_undeletable_block_types方法的典型用法代码示例。如果您正苦于以下问题:PHP block_manager::get_undeletable_block_types方法的具体用法?PHP block_manager::get_undeletable_block_types怎么用?PHP block_manager::get_undeletable_block_types使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block_manager
的用法示例。
在下文中一共展示了block_manager::get_undeletable_block_types方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_to_config_log
add_to_config_log('block_visibility', $block->visible, '1', $block->name);
core_plugin_manager::reset_caches();
admin_get_root(true, false);
// settings not required - only pages
}
if (!empty($protect) && confirm_sesskey()) {
block_manager::protect_block((int) $protect);
admin_get_root(true, false);
// settings not required - only pages
}
if (!empty($unprotect) && confirm_sesskey()) {
block_manager::unprotect_block((int) $unprotect);
admin_get_root(true, false);
// settings not required - only pages
}
$undeletableblocktypes = block_manager::get_undeletable_block_types();
echo $OUTPUT->header();
echo $OUTPUT->heading($strmanageblocks);
/// Main display starts here
/// Get and sort the existing blocks
if (!($blocks = $DB->get_records('block', array(), 'name ASC'))) {
print_error('noblocks', 'error');
// Should never happen
}
$incompatible = array();
/// Print the table of all blocks
$table = new flexible_table('admin-blocks-compatible');
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'settings', 'uninstall'));
$table->define_headers(array($strname, $strcourses, $strversion, $strhide . '/' . $strshow, $strprotecthdr, $strsettings, $struninstall));
$table->define_baseurl($CFG->wwwroot . '/' . $CFG->admin . '/blocks.php');
$table->set_attribute('class', 'admintable blockstable generaltable');
示例2: test_create_all_block_instances
public function test_create_all_block_instances()
{
global $CFG, $PAGE, $DB;
$this->resetAfterTest();
$regionname = 'side-pre';
$context = context_system::instance();
$PAGE->reset_theme_and_output();
$CFG->theme = 'boost';
list($page, $blockmanager) = $this->get_a_page_and_block_manager(array($regionname), $context, 'page-type');
$blockmanager->load_blocks();
$blockmanager->create_all_block_instances();
$blocks = $blockmanager->get_blocks_for_region($regionname);
$this->assertEmpty($blocks);
// There should be no blocks in the DB.
$PAGE->reset_theme_and_output();
// Change to a theme with undeletable blocks.
$CFG->theme = 'clean';
list($page, $blockmanager) = $this->get_a_page_and_block_manager(array($regionname), $context, 'page-type');
$blockmanager->show_only_fake_blocks(true);
$blockmanager->load_blocks();
$blockmanager->create_all_block_instances();
$blocks = $blockmanager->get_blocks_for_region($regionname);
$this->assertEmpty($blocks);
$PAGE->reset_theme_and_output();
list($page, $blockmanager) = $this->get_a_page_and_block_manager(array($regionname), $context, 'page-type');
$blockmanager->show_only_fake_blocks(false);
$blockmanager->load_blocks();
$blockmanager->create_all_block_instances();
$blocks = $blockmanager->get_blocks_for_region($regionname);
$this->assertCount(2, $blocks);
$undeletable = block_manager::get_undeletable_block_types();
foreach ($undeletable as $blockname) {
$instance = $DB->get_record('block_instances', array('blockname' => $blockname));
$this->assertEquals(1, $instance->requiredbytheme);
}
// Switch back and those auto blocks should not be returned.
$PAGE->reset_theme_and_output();
$CFG->theme = 'boost';
list($page, $blockmanager) = $this->get_a_page_and_block_manager(array($regionname), $context, 'page-type');
$blockmanager->load_blocks();
$blockmanager->create_all_block_instances();
$blocks = $blockmanager->get_blocks_for_region($regionname);
$this->assertEmpty($blocks);
// But they should exist in the DB.
foreach ($undeletable as $blockname) {
$count = $DB->count_records('block_instances', array('blockname' => $blockname));
$this->assertEquals(1, $count);
}
}
示例3: blocks_add_default_system_blocks
/**
* Add the default system-context blocks. E.g. the admin tree.
*/
function blocks_add_default_system_blocks()
{
global $DB;
$page = new moodle_page();
$page->set_context(context_system::instance());
$page->blocks->add_blocks(array(BLOCK_POS_LEFT => block_manager::get_undeletable_block_types()), '*', null, true);
$page->blocks->add_blocks(array(BLOCK_POS_LEFT => array('admin_bookmarks')), 'admin-*', null, null, 2);
if ($defaultmypage = $DB->get_record('my_pages', array('userid' => null, 'name' => '__default', 'private' => 1))) {
$subpagepattern = $defaultmypage->id;
} else {
$subpagepattern = null;
}
$newblocks = array('private_files', 'online_users', 'badges', 'calendar_month', 'calendar_upcoming');
$newcontent = array('lp', 'course_overview');
$page->blocks->add_blocks(array(BLOCK_POS_RIGHT => $newblocks, 'content' => $newcontent), 'my-index', $subpagepattern);
}