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


PHP page_import_types函数代码示例

本文整理汇总了PHP中page_import_types函数的典型用法代码示例。如果您正苦于以下问题:PHP page_import_types函数的具体用法?PHP page_import_types怎么用?PHP page_import_types使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了page_import_types函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bigbluebutton_delete_instance

function bigbluebutton_delete_instance($id)
{
    if (!($bigbluebutton = get_record('bigbluebutton', 'id', $id))) {
        return false;
    }
    $result = true;
    # Delete any dependent records here #
    if (!delete_records('bigbluebutton', 'id', $bigbluebutton->id)) {
        $result = false;
    }
    $pagetypes = page_import_types('mod/bigbluebutton/');
    foreach ($pagetypes as $pagetype) {
        if (!delete_records('block_instance', 'pageid', $bigbluebutton->id, 'pagetype', $pagetype)) {
            $result = false;
        }
    }
    if (!delete_records('event', 'modulename', 'bigbluebutton', 'instance', $bigbluebutton->id)) {
        $result = false;
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:21,代码来源:lib.php

示例2: backup_course_blocks

function backup_course_blocks($bf, $preferences)
{
    global $CFG;
    $status = true;
    // Read all of the block table
    $blocks = blocks_get_record();
    $pages = array();
    $pages[] = page_create_object(PAGE_COURSE_VIEW, $preferences->backup_course);
    if (!empty($CFG->showblocksonmodpages)) {
        // get course structure
        $course = get_record('course', 'id', $preferences->backup_course);
        $modinfo =& get_fast_modinfo($course);
        foreach ($preferences->mods as $module) {
            if (!$module->backup) {
                continue;
            }
            if (empty($modinfo->instances[$module->name])) {
                continue;
            }
            $pagetypes = page_import_types('mod/' . $module->name . '/');
            if (empty($pagetypes)) {
                continue;
            }
            foreach ($pagetypes as $pagetype) {
                foreach ($modinfo->instances[$module->name] as $cm) {
                    if (!empty($module->instances[$cm->instance]->backup)) {
                        $pages[] = page_create_object($pagetype, $cm->instance);
                    }
                }
            }
        }
    }
    //Blocks open tag
    fwrite($bf, start_tag('BLOCKS', 2, true));
    foreach ($pages as $page) {
        if ($instances = blocks_get_by_page($page)) {
            //Iterate over every block
            foreach ($instances as $position) {
                foreach ($position as $instance) {
                    //If we somehow have a block with an invalid id, skip it
                    if (empty($blocks[$instance->blockid]->name)) {
                        continue;
                    }
                    $blockname = $blocks[$instance->blockid]->name;
                    if (!($blockobj = block_instance($blockname, $instance))) {
                        // Invalid block
                        continue;
                    }
                    // encode absolute links in block config
                    $instance->configdata = $blockobj->get_backup_encoded_config();
                    //Begin Block
                    fwrite($bf, start_tag('BLOCK', 3, true));
                    fwrite($bf, full_tag('ID', 4, false, $instance->id));
                    fwrite($bf, full_tag('NAME', 4, false, $blockname));
                    fwrite($bf, full_tag('PAGEID', 4, false, $instance->pageid));
                    fwrite($bf, full_tag('PAGETYPE', 4, false, $instance->pagetype));
                    fwrite($bf, full_tag('POSITION', 4, false, $instance->position));
                    fwrite($bf, full_tag('WEIGHT', 4, false, $instance->weight));
                    fwrite($bf, full_tag('VISIBLE', 4, false, $instance->visible));
                    fwrite($bf, full_tag('CONFIGDATA', 4, false, $instance->configdata));
                    // Write instance data if needed
                    if ($blockobj->backuprestore_instancedata_used()) {
                        fwrite($bf, start_tag('INSTANCEDATA', 4, true));
                        $status = $blockobj->instance_backup($bf, $preferences);
                        fwrite($bf, end_tag('INSTANCEDATA', 4, true));
                    }
                    $context = get_context_instance(CONTEXT_BLOCK, $instance->id);
                    write_role_overrides_xml($bf, $context, 4);
                    /// write role_assign code here
                    write_role_assignments_xml($bf, $preferences, $context, 4);
                    //End Block
                    fwrite($bf, end_tag('BLOCK', 3, true));
                }
            }
        }
    }
    //Blocks close tag
    $status = fwrite($bf, end_tag('BLOCKS', 2, true));
    return $status;
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:80,代码来源:backuplib.php

示例3: quiz_delete_instance

function quiz_delete_instance($id)
{
    /// Given an ID of an instance of this module,
    /// this function will permanently delete the instance
    /// and any data that depends on it.
    if (!($quiz = get_record("quiz", "id", "{$id}"))) {
        return false;
    }
    $result = true;
    if ($attempts = get_records("quiz_attempts", "quiz", "{$quiz->id}")) {
        // TODO: this should use the delete_attempt($attempt->uniqueid) function in questionlib.php
        // require_once($CFG->libdir.'/questionlib.php');
        foreach ($attempts as $attempt) {
            if (!delete_records("question_states", "attempt", "{$attempt->uniqueid}")) {
                $result = false;
            }
            if (!delete_records("question_sessions", "attemptid", "{$attempt->uniqueid}")) {
                $result = false;
            }
        }
    }
    $tables_to_purge = array('quiz_attempts' => 'quiz', 'quiz_grades' => 'quiz', 'quiz_question_instances' => 'quiz', 'quiz_grades' => 'quiz', 'quiz_feedback' => 'quizid', 'quiz' => 'id');
    foreach ($tables_to_purge as $table => $keyfield) {
        if (!delete_records($table, $keyfield, $quiz->id)) {
            $result = false;
        }
    }
    $pagetypes = page_import_types('mod/quiz/');
    foreach ($pagetypes as $pagetype) {
        if (!delete_records('block_instance', 'pageid', $quiz->id, 'pagetype', $pagetype)) {
            $result = false;
        }
    }
    if ($events = get_records_select('event', "modulename = 'quiz' and instance = '{$quiz->id}'")) {
        foreach ($events as $event) {
            delete_event($event->id);
        }
    }
    quiz_grade_item_delete($quiz);
    return $result;
}
开发者ID:e-rasvet,项目名称:reader,代码行数:41,代码来源:lib.php

示例4: backup_course_blocks

function backup_course_blocks($bf, $preferences)
{
    global $CFG;
    $status = true;
    // Read all of the block table
    $blocks = blocks_get_record();
    $pages = array();
    $pages[] = page_create_object(PAGE_COURSE_VIEW, $preferences->backup_course);
    // Let's see if we have to backup blocks from modules
    $modulerecords = get_records_sql('SELECT name, id FROM ' . $CFG->prefix . 'modules');
    foreach ($preferences->mods as $module) {
        if (!$module->backup) {
            continue;
        }
        $cmods = get_records_select('course_modules', 'course = ' . $preferences->backup_course . ' AND module = ' . $modulerecords[$module->name]->id);
        if (empty($cmods)) {
            continue;
        }
        $pagetypes = page_import_types('mod/' . $module->name . '/');
        if (empty($pagetypes)) {
            continue;
        }
        foreach ($pagetypes as $pagetype) {
            foreach ($cmods as $cmod) {
                $pages[] = page_create_object($pagetype, $cmod->instance);
            }
        }
    }
    //Blocks open tag
    fwrite($bf, start_tag('BLOCKS', 2, true));
    while ($page = array_pop($pages)) {
        if ($instances = blocks_get_by_page($page)) {
            //Iterate over every block
            foreach ($instances as $position) {
                foreach ($position as $instance) {
                    //If we somehow have a block with an invalid id, skip it
                    if (empty($blocks[$instance->blockid]->name)) {
                        continue;
                    }
                    //Begin Block
                    fwrite($bf, start_tag('BLOCK', 3, true));
                    fwrite($bf, full_tag('ID', 4, false, $instance->id));
                    fwrite($bf, full_tag('NAME', 4, false, $blocks[$instance->blockid]->name));
                    fwrite($bf, full_tag('PAGEID', 4, false, $instance->pageid));
                    fwrite($bf, full_tag('PAGETYPE', 4, false, $instance->pagetype));
                    fwrite($bf, full_tag('POSITION', 4, false, $instance->position));
                    fwrite($bf, full_tag('WEIGHT', 4, false, $instance->weight));
                    fwrite($bf, full_tag('VISIBLE', 4, false, $instance->visible));
                    fwrite($bf, full_tag('CONFIGDATA', 4, false, $instance->configdata));
                    $context = get_context_instance(CONTEXT_BLOCK, $instance->id);
                    write_role_overrides_xml($bf, $context, 4);
                    /// write role_assign code here
                    write_role_assignments_xml($bf, $preferences, $context, 4);
                    //End Block
                    fwrite($bf, end_tag('BLOCK', 3, true));
                }
            }
        }
    }
    //Blocks close tag
    $status = fwrite($bf, end_tag('BLOCKS', 2, true));
    return $status;
}
开发者ID:veritech,项目名称:pare-project,代码行数:63,代码来源:backuplib.php

示例5: error

        if (!($page = page_get($pageid))) {
            error('Invalid page ID');
        }
    }
    // Ensure this page is with this course
    if ($page->courseid != $course->id) {
        error(get_string('invalidpageid', 'format_page', $pageid));
    }
} else {
    // We don't have a page ID to work with
    if (has_capability('format/page:editpages', $context)) {
        $action = 'editpage';
        $page = new stdClass();
        $page->id = 0;
    } else {
        // Nothing this person can do about it, error out
        error(get_string('nopageswithcontent', 'format_page'));
    }
}
/// There are a couple processes that need some help via the session... take care of those.
$action = page_handle_session_hacks($course->id, $action);
/// Check if page wants to redirect
if (!empty($page->redirect) && empty($action)) {
    redirect($page->redirect, '', 0);
}
/// Override PAGE_COURSE_VIEW class mapping
page_import_types('course/format/page');
$PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
$PAGE->set_formatpage($page);
/// Handle format actions
page_format_execute_url_action($action);
开发者ID:NextEinstein,项目名称:riverhills,代码行数:31,代码来源:format.php

示例6: stdClass

    }
} else {
    // We don't have a page ID to work with
    if (has_capability('format/page:editpages', $context)) {
        $action = 'editpage';
        $page = new stdClass();
        $page->id = 0;
    } else {
        // Nothing this person can do about it, error out
        error(get_string('nopageswithcontent', 'format_page'));
    }
}
// TODO: put in equivalent of 'session hacks' used in page/format.php
// Override PAGE_COURSE_VIEW class mapping
//     we need to reset various things that have been previously set by moodle core
page_import_types('course/format/learning');
// note hat this includes /course/format/page/pagelib.php
$PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
$PAGE->set_formatpage($page);
$editing = $PAGE->user_is_editing();
$pageblocks = page_blocks_setup();
/// Handle format actions
page_format_execute_url_action($action, $course);
// ** Only get to his part if page_format_execute_url_action returns ** //
/// Make sure the individual page is 'published'
if (!($page->display & DISP_PUBLISH) and !(has_capability('format/page:editpages', $context) and $editing)) {
    error(get_string('thispageisnotpublished', 'format_page'));
}
/// Finally, we can print the page
if ($editing) {
    $PAGE->print_tabs('layout');
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:format.php


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