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


PHP ouwiki_get_current_page函数代码示例

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


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

示例1: ouwiki_get_current_page

<?php

/**
 * Comments page. Shows full comments for a page section and allows the user
 * to post a new comment.
 * @copyright &copy; 2007 The Open University
 * @author s.marshall@open.ac.uk
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package ouwiki
 */
/** */
$countasview = true;
require 'basicpage.php';
// Get the current page version
$pageversion = ouwiki_get_current_page($subwiki, $pagename);
if (!$pageversion) {
    error('Cannot view comments when page does not exist');
}
// Need list of known sections on current version
$knownsections = ouwiki_find_sections($pageversion->xhtml);
// Get section, make sure the name is valid
$section = optional_param('section', '', PARAM_RAW);
if (!preg_match('/^[0-9]+_[0-9]+$/', $section)) {
    $section = null;
}
if ($section) {
    if (!array_key_exists($section, $knownsections)) {
        error("Unknown section {$section}");
    }
}
// Check permissions. (Note that you can always delete your
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:comments.php

示例2: get_string

    case OUWIKI_FORMAT_RTF:
        require_once $CFG->dirroot . '/local/rtf.php';
        $html = '<root><p>' . get_string('savedat', 'ouwiki', userdate(time())) . '</p><hr />';
        break;
    case OUWIKI_FORMAT_HTML:
        // Do header
        echo $ouwikioutput->ouwiki_print_start($ouwiki, $cm, $course, $subwiki, get_string('entirewiki', 'ouwiki'), $context, null, false, true);
        print '<div class="ouwiki_content">';
        break;
}
// Get list of all pages
$first = true;
$index = ouwiki_get_subwiki_index($subwiki->id);
foreach ($index as $pageinfo) {
    // Get page details
    $pageversion = ouwiki_get_current_page($subwiki, $pageinfo->title);
    // If the page hasn't really been created yet, skip it
    if (is_null($pageversion->xhtml)) {
        continue;
    }
    $visibletitle = $pageversion->title === '' ? get_string('startpage', 'ouwiki') : $pageversion->title;
    switch ($format) {
        case OUWIKI_FORMAT_TEMPLATE:
            print '<page>';
            if ($pageversion->title !== '') {
                print '<title>' . htmlspecialchars($pageversion->title) . '</title>';
            }
            print '<xhtml>' . htmlspecialchars($pageversion->xhtml) . '</xhtml>';
            print '</page>';
            break;
        case OUWIKI_FORMAT_RTF:
开发者ID:ndunand,项目名称:moodle-mod_ouwiki,代码行数:31,代码来源:entirewiki.php

示例3: dirname

// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Handles what happens when a user with appropriate permission attempts to
 * override a wiki page editing lock.
 *
 * @copyright &copy; 2007 The Open University
 * @author s.marshall@open.ac.uk
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package ouwiki
 */
require_once dirname(__FILE__) . '/../../config.php';
require $CFG->dirroot . '/mod/ouwiki/basicpage.php';
if (!data_submitted()) {
    print_error("Only POST requests accepted");
}
if (!has_capability('mod/ouwiki:overridelock', $context)) {
    print_error("You do not have the capability to override editing locks");
}
$pageversion = ouwiki_get_current_page($subwiki, $pagename, OUWIKI_GETPAGE_ACCEPTNOVERSION);
ouwiki_override_lock($pageversion->pageid);
$redirpage = optional_param('redirpage', '', PARAM_ALPHA);
if ($redirpage != '') {
    redirect($redirpage . '.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL), '', 0);
} else {
    redirect('edit.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL), '', 0);
}
开发者ID:michaudg,项目名称:moodle-mod_ouwiki,代码行数:31,代码来源:override.php

示例4: test_participation

 public function test_participation()
 {
     global $USER;
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $course = $this->getDataGenerator()->create_course();
     $ouwiki = $this->get_new_ouwiki($course->id, OUWIKI_SUBWIKIS_SINGLE);
     $cm = get_coursemodule_from_instance('ouwiki', $ouwiki->id);
     $this->assertNotEmpty($cm);
     $context = context_module::instance($cm->id);
     $subwiki = ouwiki_get_subwiki($course, $ouwiki, $cm, $context, 0, $USER->id, true);
     $pageversion = ouwiki_get_current_page($subwiki, 'TEST PAGE', OUWIKI_GETPAGE_CREATE);
     $user = $this->get_new_user('student', $course->id);
     $content = 'content';
     $plus = ' plus';
     for ($i = 1; $i <= 5; $i++) {
         $content .= $plus . $i;
         $wordcount = ouwiki_count_words($content);
         $this->save_new_version($pageversion->pageid, $content, $user->id, $wordcount);
     }
     // Remove one word.
     $content = str_replace('plus3', '', $content);
     $wordcount = ouwiki_count_words($content);
     $this->save_new_version($pageversion->pageid, $content, $user->id, $wordcount);
     // User participation.
     list($returneduser, $participation) = ouwiki_get_user_participation($user->id, $subwiki);
     $this->assertEquals($user->id, $returneduser->id);
     $this->assertNotNull($participation);
     $this->assertEquals(6, count($participation));
     // All participation.
     $participation = ouwiki_get_participation($ouwiki, $subwiki, $context, 0);
     $this->assertNotNull($participation);
     $userexists = array_key_exists($user->id, $participation);
     $this->assertTrue($userexists);
     $this->assertEquals(1, count($participation));
     $this->assertEquals(6, $participation[$user->id]->pageedits);
     $this->assertEquals(25, $participation[$user->id]->wordsadded);
     $this->assertEquals(0, $participation[$user->id]->wordsdeleted);
     $this->assertEquals(0, $participation[$user->id]->pagecreates);
     $user2 = $this->get_new_user('student', $course->id);
     $participation = ouwiki_get_participation($ouwiki, $subwiki, $context, 0);
     // A user who is enrolled, but with no contribution.
     $userexists = array_key_exists($user2->id, $participation);
     $this->assertTrue($userexists);
     $this->assertEquals(fullname($user2), fullname($participation[$user2->id]));
 }
开发者ID:michaudg,项目名称:moodle-mod_ouwiki,代码行数:46,代码来源:participation_test.php

示例5: dirname

// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
 * History page, feed version. Shows list of all previous versions of a page.
 *
 * @copyright &copy; 2007 The Open University
 * @author s.marshall@open.ac.uk
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package ouwiki
 */
global $ouwiki_nologin;
$ouwiki_nologin = true;
require_once dirname(__FILE__) . '/../../config.php';
require $CFG->dirroot . '/mod/ouwiki/basicpage.php';
// Get information about page
$pageversion = ouwiki_get_current_page($subwiki, $pagename, OUWIKI_GETPAGE_CREATE);
$magic = required_param('magic', PARAM_RAW);
if ($magic != $subwiki->magic) {
    print_error('Incorrect magic number');
}
$rss = optional_param('format', '', PARAM_RAW) === 'rss';
// Get history
$changes = ouwiki_get_page_history($pageversion->pageid, false, 0, OUWIKI_FEEDSIZE);
$useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$oldbrowser = !preg_match('/Opera/', $useragent) && preg_match('/MSIE [456]/', $useragent) || preg_match('/Firefox\\/1\\./', $useragent);
if ($oldbrowser) {
    header('Content-Type: text/xml; charset=UTF-8');
} else {
    if ($rss) {
        header('Content-Type: application/rss+xml; charset=UTF-8');
    } else {
开发者ID:ndunand,项目名称:moodle-mod_ouwiki,代码行数:31,代码来源:feed-history.php

示例6: ouwiki_create_new_section

/**
 * Creates a new section on a page from scratch
 *
 * @param string $cm ID of course module
 * @param string $subwiki details if it exists
 * @param string $pagename of the original wiki page for which the new page is a link of
 * @param string $newcontent of desired new section
 * @param string $sectionheader for the new section
 */
function ouwiki_create_new_section($course, $cm, $ouwiki, $subwiki, $pagename, $newcontent, $sectionheader, $formdata)
{
    $sourcepage = ouwiki_get_current_page($subwiki, $pagename);
    $sectiondetails = ouwiki_get_new_section_details($sourcepage->xhtml, $sectionheader);
    ouwiki_save_new_version_section($course, $cm, $ouwiki, $subwiki, $pagename, $sourcepage->xhtml, $newcontent, $sectiondetails, $formdata);
}
开发者ID:ndunand,项目名称:moodle-mod_ouwiki,代码行数:15,代码来源:locallib.php

示例7: get_string

                $first = false;
            }
        }
    }
    if ($orphans) {
        if ($format == OUWIKI_FORMAT_HTML) {
            print '<h2 class="ouw_orphans">' . get_string('orphanpages', 'ouwiki') . '</h2>';
        } else {
            if ($format != OUWIKI_FORMAT_TEMPLATE) {
                $markup .= '<h2 class="ouw_orphans">' . get_string('orphanpages', 'ouwiki') . '</h2>';
            }
        }
        foreach ($index as $indexitem) {
            if (count($indexitem->linksfrom) == 0 && $indexitem->title !== '') {
                // Get page details.
                $pageversion = ouwiki_get_current_page($subwiki, $indexitem->title);
                // If the page hasn't really been created yet, skip it.
                if (is_null($pageversion->xhtml)) {
                    continue;
                }
                $markup .= get_online_display_content($format, $pageversion, $context, $subwiki, $cm, $index, $fs, $files);
                if ($first) {
                    $first = false;
                }
            }
        }
    }
}
switch ($format) {
    case OUWIKI_FORMAT_TEMPLATE:
        $markup .= '</wiki>';
开发者ID:michaudg,项目名称:moodle-mod_ouwiki,代码行数:31,代码来源:entirewiki.php

示例8: create_content

 public function create_content($instance, $record = array())
 {
     global $USER, $DB, $CFG;
     require_once $CFG->dirroot . '/mod/ouwiki/locallib.php';
     $cm = get_coursemodule_from_instance('ouwiki', $instance->id);
     $context = context_module::instance($cm->id);
     // Setup subwiki.
     if (!isset($record['subwiki'])) {
         // Create a new sub wiki object for current user.
         $subwiki = ouwiki_get_subwiki($instance->course, $instance, $cm, $context, 0, $USER->id, true);
     } else {
         $subwiki = $record['subwiki'];
     }
     if (isset($record['newversion'])) {
         // Update an existing page with a new version.
         $newverinfo = $record['newversion'];
         if (!isset($newverinfo->formdata)) {
             $newverinfo->formdata = null;
         }
         if (!isset($newverinfo->pagename)) {
             $newverinfo->pagename = null;
         }
         if (!isset($newverinfo->content)) {
             $newverinfo->content = 'Test content';
         }
         return ouwiki_save_new_version($instance->course, $cm, $instance, $subwiki, $newverinfo->pagename, $newverinfo->content, -1, -1, -1, null, $newverinfo->formdata);
     } else {
         // Create a new page - does this by default (off start page).
         if (!isset($record['newpage'])) {
             $record['newpage'] = new stdClass();
         }
         $newpageinfo = $record['newpage'];
         if (!isset($newpageinfo->formdata)) {
             $newpageinfo->formdata = null;
         }
         if (!isset($newpageinfo->pagename)) {
             $newpageinfo->pagename = null;
         }
         // Ensure linked from page exists.
         ouwiki_get_current_page($subwiki, $newpageinfo->pagename, OUWIKI_GETPAGE_CREATE);
         if (!isset($newpageinfo->newpagename)) {
             $this->pagecount++;
             $newpageinfo->newpagename = 'OU Wiki Test Page' . $this->pagecount;
         }
         if (!isset($newpageinfo->content)) {
             $newpageinfo->content = 'Test content';
         }
         ouwiki_create_new_page($instance->course, $cm, $instance, $subwiki, $newpageinfo->pagename, $newpageinfo->newpagename, $newpageinfo->content, $newpageinfo->formdata);
         return ouwiki_get_current_page($subwiki, $newpageinfo->newpagename);
     }
 }
开发者ID:michaudg,项目名称:moodle-mod_ouwiki,代码行数:51,代码来源:lib.php

示例9: test_ouwiki_pages_and_versions

 function test_ouwiki_pages_and_versions()
 {
     $user = $this->get_new_user();
     $course = $this->get_new_course();
     // setup a wiki to use
     $ouwiki = $this->get_new_ouwiki($course->id, OUWIKI_SUBWIKIS_SINGLE);
     $cm = $this->get_new_course_module($course->id, $ouwiki->id, NOGROUPS);
     $context = get_context_instance(CONTEXT_MODULE, $cm->instance);
     $groupid = 0;
     $subwiki = ouwiki_get_subwiki($course, $ouwiki, $cm, $context, $groupid, $user->id, true);
     // create the start page
     $startpagename = 'startpage';
     $formdata = null;
     $startpageversion = ouwiki_get_current_page($subwiki, $startpagename, OUWIKI_GETPAGE_CREATE);
     ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, $startpagename, $startpagename, -1, -1, -1, null, $formdata);
     $this->assertIsA($subwiki, "stdClass");
     // create a page
     $pagename1 = 'testpage1';
     $content1 = 'testcontent';
     // we don't get anything returned for this
     ouwiki_create_new_page($course, $cm, $ouwiki, $subwiki, $startpagename, $pagename1, $content1, $formdata);
     // try get that page
     $pageversion = ouwiki_get_current_page($subwiki, $pagename1);
     $this->assertIsA($subwiki, "stdClass");
     $this->assertEqual($pageversion->title, $pagename1);
     // make some more version
     $content2 = "testcontent2";
     $content3 = "testcontent3";
     ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, $pagename1, $content2, -1, -1, -1, null, $formdata);
     ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, $pagename1, $content3, -1, -1, -1, null, $formdata);
     // get the history
     $history = ouwiki_get_page_history($pageversion->pageid, true);
     $this->assertIsA($history, "array");
     // last version should match $content3
     $lastversion = array_shift($history);
     $pageversion = ouwiki_get_page_version($subwiki, $pagename1, $lastversion->versionid);
     $this->assertEqual($pageversion->xhtml, $content3);
     // add another page
     $pagename2 = 'testpage2';
     $content4 = 'testcontent4';
     // we don't get anything returned for this
     ouwiki_create_new_page($course, $cm, $ouwiki, $subwiki, $startpagename, $pagename2, $content4, $formdata);
     // test recent pages
     $changes = ouwiki_get_subwiki_recentpages($subwiki->id);
     $this->assertIsA($changes, "array");
     // first page should be startpage
     $this->assertEqual($changes[1]->title, $startpagename);
     // 3rd page should be pagename2
     $this->assertEqual($changes[3]->title, $pagename2);
     // test recent wiki changes
     $changes = ouwiki_get_subwiki_recentchanges($subwiki->id);
     $this->assertEqual($changes[1]->title, $startpagename);
     // sixth change should be to testpage2  - when we created testpage2
     $this->assertEqual($changes[6]->title, $pagename2);
     // seventh change shouldbe start page again - when we linked to testpage2 to startpage
     $this->assertEqual($changes[7]->title, $startpagename);
     // test deleting a version
 }
开发者ID:ndunand,项目名称:moodle-mod_ouwiki,代码行数:58,代码来源:testlocallib.php

示例10: load_data

 public function load_data()
 {
     global $DB;
     // Load basic data
     $page = $DB->get_record('ouwiki_pages', array('id' => $this->pageid), '*', MUST_EXIST);
     $this->load_base_data($page->subwikiid);
     // Load page version
     $this->pageversion = ouwiki_get_current_page($this->subwiki, $page->title);
     // Add files from page
     $this->add_files(array($this->pageversion));
 }
开发者ID:ndunand,项目名称:moodle-mod_ouwiki,代码行数:11,代码来源:portfoliolib.php

示例11: test_ouwiki_get_last_modified

 /**
  * Simple test of last modified time returning
  */
 public function test_ouwiki_get_last_modified()
 {
     global $DB;
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $user = $this->get_new_user();
     $user2 = $this->get_new_user('testouwikiuser2');
     $course = $this->get_new_course();
     $ouwiki = $this->get_new_ouwiki($course->id, OUWIKI_SUBWIKIS_SINGLE);
     $cm = get_coursemodule_from_instance('ouwiki', $ouwiki->id);
     $context = context_module::instance($cm->id);
     $result = ouwiki_get_last_modified($cm, $course);
     $this->assertEmpty($result);
     // Create page + test last modified returns something.
     $subwiki = ouwiki_get_subwiki($course, $ouwiki, $cm, $context, 0, $user2->id, true);
     $page = ouwiki_get_current_page($subwiki, 'startpage', OUWIKI_GETPAGE_CREATE);
     ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, 'startpage', 'content', -1, -1, -1);
     $result = ouwiki_get_last_modified($cm, $course, $user2->id);
     $this->assertNotEmpty($result);
     // Check other user gets a time.
     $result2 = ouwiki_get_last_modified($cm, $course, $user->id);
     $this->assertNotEmpty($result2);
     $this->assertEquals($result, $result2);
     // Check admin gets cached.
     $result = ouwiki_get_last_modified($cm, $course);
     $this->assertEmpty($result);
 }
开发者ID:michaudg,项目名称:moodle-mod_ouwiki,代码行数:30,代码来源:locallib_test.php

示例12: test_participation

 public function test_participation()
 {
     $ouwiki = $this->get_new_ouwiki($this->courses['single']->id, OUWIKI_SUBWIKIS_SINGLE);
     $cm = $this->get_new_course_module($this->courses['single']->id, $ouwiki->id, NOGROUPS);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     $subwiki = ouwiki_get_subwiki($this->courses['single'], $ouwiki, $cm, $context, 0, $this->admin->id, true);
     $pageversion = ouwiki_get_current_page($subwiki, 'TEST PAGE', OUWIKI_GETPAGE_CREATE);
     $user = $this->get_new_user('student');
     $content = 'content';
     $plus = ' plus';
     for ($i = 1; $i <= 5; $i++) {
         $content .= $plus . $i;
         $wordcount = ouwiki_count_words($content);
         $this->save_new_version($pageversion->pageid, $content, $user->id, $wordcount);
     }
     // remove one word
     $content = preg_replace('/plus3/', '', $content);
     $wordcount = ouwiki_count_words($content);
     $this->save_new_version($pageversion->pageid, $content, $user->id, $wordcount);
     list($returneduser, $participation) = ouwiki_get_user_participation($user->id, $subwiki);
     $this->assertEqual($returneduser->id, $user->id);
     $this->assertNotNull($participation);
     // another user
     $user2 = $this->get_new_user('student');
     $users[0] = $user->id;
     $users[1] = $user2->id;
     $participation = ouwiki_get_participation($ouwiki, $subwiki, $context, 0);
     $this->assertNotNull($participation);
     $userexists = array_key_exists($user->id, $participation);
     $this->assertTrue($userexists);
     // a user who isn't enrolled
     $userexists = array_key_exists($this->nouser->id, $participation);
     $this->assertFalse($userexists);
 }
开发者ID:ndunand,项目名称:moodle-mod_ouwiki,代码行数:34,代码来源:test_participation.php

示例13: ouwiki_save_new_version

                 ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, $title, $xhtmlcontent);
             } else {
                 $updatepagelist[] = $importedpages;
             }
             // Set linkfrom to 'Imported pages'.
             $linkfrom = $importedpages;
             $updatepagelist[] = get_string('startpage', 'ouwiki');
         } else {
             // Add links into selected page.
             if (!($pageinfo = $DB->get_record('ouwiki_pages', array('id' => $linkfrom)))) {
                 throw new moodle_exception('Error. Page to import into missing.');
             }
             // Store page name so we can go there.
             $linkfrom = $pageinfo->title;
             // Add links into selected page content.
             $linkfrompage = ouwiki_get_current_page($subwiki, $pageinfo->title, OUWIKI_GETPAGE_CREATE);
             $linkfrompageid = $linkfrompage->pageid;
             // Merge links xhtml into import into page xhtml content.
             $linkfrompage->xhtml = $linkfrompage->xhtml . $mergexhtml;
             $versionid = ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, $linkfrompage->title, $linkfrompage->xhtml);
             if ($pageinfo->title == '') {
                 // Start page.
                 $updatepagelist[] = get_string('startpage', 'ouwiki');
             } else {
                 $updatepagelist[] = $pageinfo->title;
             }
         }
     }
 }
 // Provide summary output.
 echo $OUTPUT->heading(get_string('import_process_summary', 'ouwiki'), 3);
开发者ID:michaudg,项目名称:moodle-mod_ouwiki,代码行数:31,代码来源:import.php

示例14: test_attachment_diff

 public function test_attachment_diff()
 {
     global $CFG, $USER;
     require_once $CFG->dirroot . '/mod/ouwiki/locallib.php';
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $course = $this->getDataGenerator()->create_course();
     $generator = $this->getDataGenerator()->get_plugin_generator('mod_ouwiki');
     $ouwiki = $generator->create_instance((object) array('course' => $course->id));
     $cm = get_coursemodule_from_instance('ouwiki', $ouwiki->id);
     $this->assertNotEmpty($cm);
     $context = context_module::instance($cm->id);
     $subwiki = ouwiki_get_subwiki($course, $ouwiki, $cm, $context, 0, $USER->id, true);
     // Add start page.
     $startpageversion = ouwiki_get_current_page($subwiki, null, OUWIKI_GETPAGE_CREATE);
     // Add version1 - no attachments.
     $ver1id = ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, null, 'TEST', -1, -1, -1, false, null);
     // Add version 2 - no attachments.
     $ver2id = ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, null, 'TEST', -1, -1, -1, false, null);
     // Check diff when no attachments.
     $fs = get_file_storage();
     $files1 = ($files1 = $fs->get_area_files($context->id, 'mod_ouwiki', 'attachment', $ver1id, 'timemodified', false)) ? $files1 : null;
     $files2 = ($files2 = $fs->get_area_files($context->id, 'mod_ouwiki', 'attachment', $ver2id, 'timemodified', false)) ? $files2 : null;
     list($attachdiff1, $attachdiff2, $attachnumchanges) = ouwiki_diff_attachments($files1, $files2, $context->id, $ver1id, $ver2id);
     $this->assertEquals(0, $attachnumchanges);
     $hasno1 = strpos(get_string('noattachments', 'ouwiki'), $attachdiff1);
     $hasno2 = strpos(get_string('noattachments', 'ouwiki'), $attachdiff2);
     $this->assertTrue($hasno1 !== false && $hasno2 !== false);
     // Add attachment to first and re-check.
     $filerecord = (object) array('contextid' => $context->id, 'component' => 'mod_ouwiki', 'filearea' => 'attachment', 'itemid' => $ver1id, 'filename' => 'test1.txt', 'filepath' => '/');
     $fs->create_file_from_string($filerecord, 'test');
     $files1 = ($files1 = $fs->get_area_files($context->id, 'mod_ouwiki', 'attachment', $ver1id, 'timemodified', false)) ? $files1 : null;
     list($attachdiff1, $attachdiff2, $attachnumchanges) = ouwiki_diff_attachments($files1, $files2, $context->id, $ver1id, $ver2id);
     $this->assertEquals(1, $attachnumchanges);
     $hasno1 = strpos($attachdiff1, 'test1.txt');
     $hasno2 = strpos($attachdiff2, get_string('noattachments', 'ouwiki'));
     $this->assertTrue($hasno1 !== false && $hasno2 !== false);
     // Add same attachment to second and test no changes.
     $filerecord->itemid = $ver2id;
     $fs->create_file_from_string($filerecord, 'test');
     $files2 = ($files2 = $fs->get_area_files($context->id, 'mod_ouwiki', 'attachment', $ver2id, 'timemodified', false)) ? $files2 : null;
     list($attachdiff1, $attachdiff2, $attachnumchanges) = ouwiki_diff_attachments($files1, $files2, $context->id, $ver1id, $ver2id);
     $this->assertEquals(0, $attachnumchanges);
     $hasno1 = strpos($attachdiff1, 'test1.txt');
     $hasno2 = strpos($attachdiff2, 'test1.txt');
     $this->assertTrue($hasno1 !== false && $hasno2 !== false);
     // Add a second attachemnt to second version and test.
     $filerecord->filename = 'test2.txt';
     $fs->create_file_from_string($filerecord, 'test2');
     $files2 = ($files2 = $fs->get_area_files($context->id, 'mod_ouwiki', 'attachment', $ver2id, 'timemodified', false)) ? $files2 : null;
     list($attachdiff1, $attachdiff2, $attachnumchanges) = ouwiki_diff_attachments($files1, $files2, $context->id, $ver1id, $ver2id);
     $this->assertEquals(1, $attachnumchanges);
     $hasno1 = strpos($attachdiff1, 'test1.txt');
     $hasno2 = strpos($attachdiff2, 'test2.txt');
     $this->assertTrue($hasno1 !== false && $hasno2 !== false);
 }
开发者ID:michaudg,项目名称:moodle-mod_ouwiki,代码行数:56,代码来源:diff_test.php


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