本文整理汇总了PHP中blocks_name_allowed_in_format函数的典型用法代码示例。如果您正苦于以下问题:PHP blocks_name_allowed_in_format函数的具体用法?PHP blocks_name_allowed_in_format怎么用?PHP blocks_name_allowed_in_format使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了blocks_name_allowed_in_format函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: page_print_add_mods_form
/**
* This function displays the controls to add modules and blocks to a page
*
* @param object $page A fully populated page object
* @param object $course A fully populated course object
* @uses $USER;
* @uses $CFG;
*/
function page_print_add_mods_form($page, $course)
{
global $USER, $CFG, $PAGE;
if (empty($PAGE)) {
$PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
}
print_box_start('centerpara addpageitems');
// Add drop down to add blocks
if ($blocks = get_records('block', 'visible', '1', 'name')) {
$format = $PAGE->get_format_name();
$options = array();
foreach ($blocks as $b) {
if (in_array($b->name, array('format_page', 'page_module'))) {
continue;
}
if (!blocks_name_allowed_in_format($b->name, $format)) {
continue;
}
$blockobject = block_instance($b->name);
if ($blockobject !== false && $blockobject->user_can_addto($PAGE)) {
$options[$b->id] = $blockobject->get_title();
}
}
asort($options);
print '<span class="addblock">';
$common = $CFG->wwwroot . '/course/format/page/format.php?id=' . $course->id . '&page=' . $page->id . '&blockaction=add&sesskey=' . sesskey() . '&blockid=';
popup_form($common, $options, 'addblock', '', get_string('addblock', 'format_page'));
print '</span> ';
}
// Add drop down to add existing module instances
if ($modules = page_get_modules($course, 'name')) {
// From our modules object we can build an existing module menu using separators
$options = array();
foreach ($modules as $modplural => $instances) {
// Sets an optgroup which can't be selected/submitted
$options[$modplural . '_group_start'] = "--{$modplural}";
foreach ($instances as $cmid => $name) {
$options[$cmid] = shorten_text($name);
}
// Ends an optgroup
$options[$modplural . '_group_end'] = '--';
}
print '<span class="addexistingmodule">';
$common = $CFG->wwwroot . '/course/format/page/format.php?id=' . $course->id . '&page=' . $page->id . '&blockaction=addmod&sesskey=' . sesskey() . '&instance=';
popup_form($common, $options, 'addinstance', '', get_string('addexistingmodule', 'format_page'));
print '</span>';
}
print_box_end();
}
示例2: get_addable_blocks
/**
* The list of block types that may be added to this page.
*
* @return array block name => record from block table.
*/
public function get_addable_blocks()
{
$this->check_is_loaded();
if (!is_null($this->addableblocks)) {
return $this->addableblocks;
}
// Lazy load.
$this->addableblocks = array();
$allblocks = blocks_get_record();
if (empty($allblocks)) {
return $this->addableblocks;
}
$unaddableblocks = self::get_undeletable_block_types();
$pageformat = $this->page->pagetype;
foreach ($allblocks as $block) {
if (!($bi = block_instance($block->name))) {
continue;
}
if ($block->visible && !in_array($block->name, $unaddableblocks) && ($bi->instance_allow_multiple() || !$this->is_block_present($block->name)) && blocks_name_allowed_in_format($block->name, $pageformat) && $bi->user_can_addto($this->page)) {
$this->addableblocks[$block->name] = $block;
}
}
return $this->addableblocks;
}
示例3: blocks_remove_inappropriate
function blocks_remove_inappropriate($page)
{
$pageblocks = blocks_get_by_page($page);
if (empty($pageblocks)) {
return;
}
if (($pageformat = $page->get_format_name()) == NULL) {
return;
}
foreach ($pageblocks as $position) {
foreach ($position as $instance) {
$block = blocks_get_record($instance->blockid);
if (!blocks_name_allowed_in_format($block->name, $pageformat)) {
blocks_delete_instance($instance);
}
}
}
}
示例4: get_addable_blocks
/**
* The list of block types that may be added to this page.
*
* @return array block name => record from block table.
*/
public function get_addable_blocks()
{
$this->check_is_loaded();
if (!is_null($this->addableblocks)) {
return $this->addableblocks;
}
// Lazy load.
$this->addableblocks = array();
$allblocks = blocks_get_record();
if (empty($allblocks)) {
return $this->addableblocks;
}
$pageformat = $this->page->pagetype;
foreach ($allblocks as $block) {
if ($block->visible && (block_method_result($block->name, 'instance_allow_multiple') || !$this->is_block_present($block->name)) && blocks_name_allowed_in_format($block->name, $pageformat) && block_method_result($block->name, 'user_can_addto', $this->page)) {
$this->addableblocks[$block->name] = $block;
}
}
return $this->addableblocks;
}