当前位置: 首页>>代码示例>>PHP>>正文


PHP blocks_name_allowed_in_format函数代码示例

本文整理汇总了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 . '&amp;page=' . $page->id . '&amp;blockaction=add&amp;sesskey=' . sesskey() . '&amp;blockid=';
        popup_form($common, $options, 'addblock', '', get_string('addblock', 'format_page'));
        print '</span>&nbsp;';
    }
    // 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 . '&amp;page=' . $page->id . '&amp;blockaction=addmod&amp;sesskey=' . sesskey() . '&amp;instance=';
        popup_form($common, $options, 'addinstance', '', get_string('addexistingmodule', 'format_page'));
        print '</span>';
    }
    print_box_end();
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:57,代码来源:lib.php

示例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;
 }
开发者ID:Burick,项目名称:moodle,代码行数:29,代码来源:blocklib.php

示例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);
            }
        }
    }
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:18,代码来源:blocklib.php

示例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;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:25,代码来源:blocklib.php


注:本文中的blocks_name_allowed_in_format函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。