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


PHP wiki_add_subwiki函数代码示例

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


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

示例1: create_page

    function create_page($pagetitle) {
        global $USER, $PAGE;

        $data = $this->mform->get_data();
        if (isset($data->groupinfo)) {
            $groupid = $data->groupinfo;
        } else if (!empty($this->gid)) {
            $groupid = $this->gid;
        } else {
            $groupid = '0';
        }
        if (empty($this->subwiki)) {
            // If subwiki is not set then try find one and set else create one.
            if (!$this->subwiki = wiki_get_subwiki_by_group($this->wid, $groupid, $this->uid)) {
                $swid = wiki_add_subwiki($PAGE->activityrecord->id, $groupid, $this->uid);
                $this->subwiki = wiki_get_subwiki($swid);
            }
        }
        if ($data) {
            $this->set_title($data->pagetitle);
            $id = wiki_create_page($this->subwiki->id, $data->pagetitle, $data->pageformat, $USER->id);
        } else {
            $this->set_title($pagetitle);
            $id = wiki_create_page($this->subwiki->id, $pagetitle, $PAGE->activityrecord->defaultformat, $USER->id);
        }
        $this->page = $id;
        return $id;
    }
开发者ID:Burick,项目名称:moodle,代码行数:28,代码来源:pagelib.php

示例2: print_error

if (!($page = wiki_get_page($pageid))) {
    print_error('incorrectpageid', 'wiki');
}
if ($groupanduser) {
    list($currentgroup, $userid) = explode('-', $groupanduser);
    $currentgroup = clean_param($currentgroup, PARAM_INT);
    $userid = clean_param($userid, PARAM_INT);
}
if ($wid) {
    // in group mode
    if (!($wiki = wiki_get_wiki($wid))) {
        print_error('incorrectwikiid', 'wiki');
    }
    if (!($subwiki = wiki_get_subwiki_by_group($wiki->id, $currentgroup, $userid))) {
        // create subwiki if doesn't exist
        $subwikiid = wiki_add_subwiki($wiki->id, $currentgroup, $userid);
        $subwiki = wiki_get_subwiki($subwikiid);
    }
} else {
    // no group
    if (!($subwiki = wiki_get_subwiki($page->subwikiid))) {
        print_error('incorrectsubwikiid', 'wiki');
    }
    // Checking wiki instance of that subwiki
    if (!($wiki = wiki_get_wiki($subwiki->wikiid))) {
        print_error('incorrectwikiid', 'wiki');
    }
}
// Checking course module instance
if (!($cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid))) {
    print_error('invalidcoursemodule');
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:files.php

示例3: create_page

 function create_page($pagetitle)
 {
     global $USER, $CFG, $PAGE;
     $data = $this->mform->get_data();
     if (empty($this->subwiki)) {
         $swid = wiki_add_subwiki($PAGE->activityrecord->id, $this->gid, $this->uid);
         $this->subwiki = wiki_get_subwiki($swid);
     }
     if ($data) {
         $id = wiki_create_page($this->subwiki->id, $data->pagetitle, $data->pageformat, $USER->id);
     } else {
         $id = wiki_create_page($this->subwiki->id, $pagetitle, $PAGE->activityrecord->defaultformat, $USER->id);
     }
     redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $id);
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:15,代码来源:pagelib.php

示例4: test_tag_removed

 /**
  * Test the tag removed event.
  */
 public function test_tag_removed()
 {
     global $DB;
     $this->setAdminUser();
     // Create a course to tag.
     $course = $this->getDataGenerator()->create_course();
     // Create a wiki page to tag.
     $wikigenerator = $this->getDataGenerator()->get_plugin_generator('mod_wiki');
     $wiki = $wikigenerator->create_instance(array('course' => $course->id));
     $subwikiid = wiki_add_subwiki($wiki->id, 0);
     $wikipageid = wiki_create_page($subwikiid, 'Title', FORMAT_HTML, '2');
     // Create the tag.
     $tag = $this->getDataGenerator()->create_tag();
     // Assign a tag to a course.
     tag_assign('course', $course->id, $tag->id, 1, 2, 'core', context_course::instance($course->id)->id);
     // Trigger and capture the event for untagging a course.
     $sink = $this->redirectEvents();
     coursetag_delete_keyword($tag->id, 2, $course->id);
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the tag was removed from the course and the event data is valid.
     $this->assertEquals(0, $DB->count_records('tag_instance'));
     $this->assertInstanceOf('\\core\\event\\tag_removed', $event);
     $this->assertEquals(context_course::instance($course->id), $event->get_context());
     // Create the tag.
     $tag = $this->getDataGenerator()->create_tag();
     // Assign a tag to a wiki this time.
     tag_assign('wiki_pages', $wikipageid, $tag->id, 1, 2, 'mod_wiki', context_module::instance($wiki->cmid)->id);
     // Trigger and capture the event for deleting this tag instance.
     $sink = $this->redirectEvents();
     tag_delete_instance('wiki_pages', $wikipageid, $tag->id);
     $events = $sink->get_events();
     $event = reset($events);
     // Check that tag was removed from the wiki page and the event data is valid.
     $this->assertEquals(0, $DB->count_records('tag_instance'));
     $this->assertInstanceOf('\\core\\event\\tag_removed', $event);
     $this->assertEquals(context_module::instance($wiki->cmid), $event->get_context());
     // Create a tag again - the other would have been deleted since there were no more instances associated with it.
     $tag = $this->getDataGenerator()->create_tag();
     // Assign a tag to the wiki again.
     tag_assign('wiki_pages', $wikipageid, $tag->id, 1, 2, 'mod_wiki', context_module::instance($wiki->cmid)->id);
     // Now we want to delete this tag, and because there is only one tag instance
     // associated with it, it should get deleted as well.
     $sink = $this->redirectEvents();
     tag_delete($tag->id);
     $events = $sink->get_events();
     $event = reset($events);
     // Check that tag was removed from the wiki page and the event data is valid.
     $this->assertEquals(0, $DB->count_records('tag_instance'));
     $this->assertInstanceOf('\\core\\event\\tag_removed', $event);
     $this->assertEquals(context_module::instance($wiki->cmid), $event->get_context());
     // Create a tag again - the other would have been deleted since there were no more instances associated with it.
     $tag = $this->getDataGenerator()->create_tag();
     // Assign a tag to the wiki again.
     tag_assign('wiki_pages', $wikipageid, $tag->id, 1, 2, 'mod_wiki', context_module::instance($wiki->cmid)->id);
     // Delete all tag instances for this wiki instance.
     $sink = $this->redirectEvents();
     tag_delete_instances('mod_wiki', context_module::instance($wiki->cmid)->id);
     $events = $sink->get_events();
     $event = reset($events);
     // Check that tag was removed from the wiki page and the event data is valid.
     $this->assertEquals(0, $DB->count_records('tag_instance'));
     $this->assertInstanceOf('\\core\\event\\tag_removed', $event);
     $this->assertEquals(context_module::instance($wiki->cmid), $event->get_context());
     // Create another wiki.
     $wiki2 = $wikigenerator->create_instance(array('course' => $course->id));
     $subwikiid2 = wiki_add_subwiki($wiki2->id, 0);
     $wikipageid2 = wiki_create_page($subwikiid2, 'Title', FORMAT_HTML, '2');
     // Assign a tag to both wiki pages.
     tag_assign('wiki_pages', $wikipageid, $tag->id, 1, 2, 'mod_wiki', context_module::instance($wiki->cmid)->id);
     tag_assign('wiki_pages', $wikipageid2, $tag->id, 1, 2, 'mod_wiki', context_module::instance($wiki2->cmid)->id);
     // Now remove all tag_instances associated with all wikis.
     $sink = $this->redirectEvents();
     tag_delete_instances('mod_wiki');
     $events = $sink->get_events();
     // There will be two events - one for each wiki instance removed.
     $event1 = reset($events);
     $event2 = $events[1];
     // Check that the tags were removed from the wiki pages.
     $this->assertEquals(0, $DB->count_records('tag_instance'));
     // Check the first event data is valid.
     $this->assertInstanceOf('\\core\\event\\tag_removed', $event1);
     $this->assertEquals(context_module::instance($wiki->cmid), $event1->get_context());
     // Check that the second event data is valid.
     $this->assertInstanceOf('\\core\\event\\tag_removed', $event2);
     $this->assertEquals(context_module::instance($wiki2->cmid), $event2->get_context());
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:90,代码来源:events_test.php

示例5: create_page

 function create_page($pagetitle)
 {
     global $USER, $PAGE;
     $data = $this->mform->get_data();
     if (isset($data->groupinfo)) {
         $groupid = $data->groupinfo;
     } else {
         $groupid = '0';
     }
     if (!($this->subwiki = wiki_get_subwiki_by_group($this->wid, $groupid))) {
         $swid = wiki_add_subwiki($PAGE->activityrecord->id, $groupid, $this->uid);
         $this->subwiki = wiki_get_subwiki($swid);
     }
     if ($data) {
         $this->set_title($data->pagetitle);
         $id = wiki_create_page($this->subwiki->id, $data->pagetitle, $data->pageformat, $USER->id);
     } else {
         $this->set_title($pagetitle);
         $id = wiki_create_page($this->subwiki->id, $pagetitle, $PAGE->activityrecord->defaultformat, $USER->id);
     }
     $this->page = $id;
     return $id;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:23,代码来源:pagelib.php

示例6: new_page

 /**
  * Creates a new page.
  *
  * @param string $title New page title.
  * @param string $content Page contents.
  * @param int $contentformat Page contents format. If an invalid format is provided, default wiki format is used.
  * @param int $subwikiid The Subwiki ID where to store the page.
  * @param int $wikiid Page\'s wiki ID. Used if subwiki does not exists.
  * @param int $userid Subwiki\'s user ID. Used if subwiki does not exists.
  * @param int $groupid Subwiki\'s group ID. Used if subwiki does not exists.
  * @return array of warnings and page data.
  * @since Moodle 3.1
  */
 public static function new_page($title, $content, $contentformat = null, $subwikiid = null, $wikiid = null, $userid = null, $groupid = null)
 {
     global $USER;
     $params = self::validate_parameters(self::new_page_parameters(), array('title' => $title, 'content' => $content, 'contentformat' => $contentformat, 'subwikiid' => $subwikiid, 'wikiid' => $wikiid, 'userid' => $userid, 'groupid' => $groupid));
     $warnings = array();
     // Get wiki and subwiki instances.
     if (!empty($params['subwikiid'])) {
         if (!($subwiki = wiki_get_subwiki($params['subwikiid']))) {
             throw new moodle_exception('incorrectsubwikiid', 'wiki');
         }
         if (!($wiki = wiki_get_wiki($subwiki->wikiid))) {
             throw new moodle_exception('incorrectwikiid', 'wiki');
         }
         // Permission validation.
         $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
         $context = context_module::instance($cm->id);
         self::validate_context($context);
     } else {
         if (!($wiki = wiki_get_wiki($params['wikiid']))) {
             throw new moodle_exception('incorrectwikiid', 'wiki');
         }
         // Permission validation.
         $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
         $context = context_module::instance($cm->id);
         self::validate_context($context);
         // Determine groupid and userid to use.
         list($groupid, $userid) = self::determine_group_and_user($cm, $wiki, $params['groupid'], $params['userid']);
         // Get subwiki and validate it.
         $subwiki = wiki_get_subwiki_by_group_and_user_with_validation($wiki, $groupid, $userid);
         if ($subwiki === false) {
             // User cannot view page.
             throw new moodle_exception('cannoteditpage', 'wiki');
         } else {
             if ($subwiki->id < 0) {
                 // Subwiki needed to check edit permissions.
                 if (!wiki_user_can_edit($subwiki)) {
                     throw new moodle_exception('cannoteditpage', 'wiki');
                 }
                 // Subwiki does not exists and it can be created.
                 $swid = wiki_add_subwiki($wiki->id, $groupid, $userid);
                 if (!($subwiki = wiki_get_subwiki($swid))) {
                     throw new moodle_exception('incorrectsubwikiid', 'wiki');
                 }
             }
         }
     }
     // Subwiki needed to check edit permissions.
     if (!wiki_user_can_edit($subwiki)) {
         throw new moodle_exception('cannoteditpage', 'wiki');
     }
     if ($page = wiki_get_page_by_title($subwiki->id, $params['title'])) {
         throw new moodle_exception('pageexists', 'wiki');
     }
     // Ignore invalid formats and use default instead.
     if (!$params['contentformat'] || $wiki->forceformat) {
         $params['contentformat'] = $wiki->defaultformat;
     } else {
         $formats = wiki_get_formats();
         if (!in_array($params['contentformat'], $formats)) {
             $params['contentformat'] = $wiki->defaultformat;
         }
     }
     $newpageid = wiki_create_page($subwiki->id, $params['title'], $params['contentformat'], $USER->id);
     if (!($page = wiki_get_page($newpageid))) {
         throw new moodle_exception('incorrectpageid', 'wiki');
     }
     // Save content.
     $save = wiki_save_page($page, $params['content'], $USER->id);
     if (!$save) {
         throw new moodle_exception('savingerror', 'wiki');
     }
     $result = array();
     $result['pageid'] = $page->id;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:89,代码来源:external.php

示例7: create_page

 function create_page($pagetitle) {
     global $USER, $CFG, $PAGE;
     $data = $this->mform->get_data();
     if (empty($this->subwiki)) {
         $swid = wiki_add_subwiki($PAGE->activityrecord->id, $this->gid, $this->uid);
         $this->subwiki = wiki_get_subwiki($swid);
     }
     if ($data) {
         $this->set_title($data->pagetitle);
         $id = wiki_create_page($this->subwiki->id, $data->pagetitle, $data->pageformat, $USER->id);
     } else {
         $this->set_title($pagetitle);
         $id = wiki_create_page($this->subwiki->id, $pagetitle, $PAGE->activityrecord->defaultformat, $USER->id);
     }
     $this->page = $id;
     return $id;
 }
开发者ID:robadobdob,项目名称:moodle,代码行数:17,代码来源:pagelib.php

示例8: create_page

 /**
  * Generates a page in wiki.
  *
  * @param stdClass wiki object returned from create_instance (if known)
  * @param stdClass|array $record data to insert as wiki entry.
  * @return stdClass
  * @throws coding_exception if neither $record->wikiid nor $wiki->id is specified
  */
 public function create_page($wiki, $record = array())
 {
     global $CFG, $USER;
     require_once $CFG->dirroot . '/mod/wiki/locallib.php';
     $this->pagecount++;
     $record = (array) $record + array('title' => 'wiki page ' . $this->pagecount, 'wikiid' => $wiki->id, 'subwikiid' => 0, 'group' => 0, 'content' => 'Wiki page content ' . $this->pagecount, 'format' => $wiki->defaultformat);
     if (empty($record['wikiid']) && empty($record['subwikiid'])) {
         throw new coding_exception('wiki page generator requires either wikiid or subwikiid');
     }
     if (!$record['subwikiid']) {
         if (!isset($record['userid'])) {
             $record['userid'] = $wiki->wikimode == 'individual' ? $USER->id : 0;
         }
         if ($subwiki = wiki_get_subwiki_by_group($record['wikiid'], $record['group'], $record['userid'])) {
             $record['subwikiid'] = $subwiki->id;
         } else {
             $record['subwikiid'] = wiki_add_subwiki($record['wikiid'], $record['group'], $record['userid']);
         }
     }
     if ($wikipage = wiki_get_page_by_title($record['subwikiid'], $record['title'])) {
         $rv = wiki_save_page($wikipage, $record['content'], $USER->id);
         return $rv['page'];
     }
     $pageid = wiki_create_page($record['subwikiid'], $record['title'], $record['format'], $USER->id);
     $wikipage = wiki_get_page($pageid);
     $rv = wiki_save_page($wikipage, $record['content'], $USER->id);
     return $rv['page'];
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:36,代码来源:lib.php

示例9: create_page

 /**
  * Generates a page in wiki.
  *
  * @param stdClass wiki object returned from create_instance (if known)
  * @param stdClass|array $record data to insert as wiki entry.
  * @return stdClass
  * @throws coding_exception if neither $record->wikiid nor $wiki->id is specified
  */
 public function create_page($wiki, $record = array())
 {
     global $CFG, $USER;
     require_once $CFG->dirroot . '/mod/wiki/locallib.php';
     $this->pagecount++;
     $record = (array) $record + array('title' => 'wiki page ' . $this->pagecount, 'wikiid' => $wiki->id, 'subwikiid' => 0, 'group' => 0, 'content' => 'Wiki page content ' . $this->pagecount, 'format' => $wiki->defaultformat);
     if (empty($record['wikiid']) && empty($record['subwikiid'])) {
         throw new coding_exception('wiki page generator requires either wikiid or subwikiid');
     }
     if (!$record['subwikiid']) {
         if (!isset($record['userid'])) {
             $record['userid'] = $wiki->wikimode == 'individual' ? $USER->id : 0;
         }
         if ($subwiki = wiki_get_subwiki_by_group($record['wikiid'], $record['group'], $record['userid'])) {
             $record['subwikiid'] = $subwiki->id;
         } else {
             $record['subwikiid'] = wiki_add_subwiki($record['wikiid'], $record['group'], $record['userid']);
         }
     }
     $wikipage = wiki_get_page_by_title($record['subwikiid'], $record['title']);
     if (!$wikipage) {
         $pageid = wiki_create_page($record['subwikiid'], $record['title'], $record['format'], $USER->id);
         $wikipage = wiki_get_page($pageid);
     }
     $rv = wiki_save_page($wikipage, $record['content'], $USER->id);
     if (array_key_exists('tags', $record)) {
         $tags = is_array($record['tags']) ? $record['tags'] : preg_split('/,/', $record['tags']);
         if (empty($wiki->cmid)) {
             $cm = get_coursemodule_from_instance('wiki', $wiki->id, isset($wiki->course) ? $wiki->course : 0);
             $wiki->cmid = $cm->id;
         }
         core_tag_tag::set_item_tags('mod_wiki', 'wiki_pages', $wikipage->id, context_module::instance($wiki->cmid), $tags);
     }
     return $rv['page'];
 }
开发者ID:evltuma,项目名称:moodle,代码行数:43,代码来源:lib.php


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