• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wiki_get_current_version函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: wiki_parser_link

/**
 * This function is the parser callback to parse wiki links.
 *
 * It returns the necesary information to print a link.
 *
 * NOTE: Empty pages and non-existent pages must be print in red color.
 *
 * !!!!!! IMPORTANT !!!!!!
 * It is critical that you call format_string on the content before it is used.
 *
 * @param string|page_wiki $link name of a page
 * @param array $options
 * @return array Array('content' => string, 'url' => string, 'new' => bool, 'link_info' => array)
 *
 * @TODO Doc return and options
 */
function wiki_parser_link($link, $options = null)
{
    global $CFG;
    if (is_object($link)) {
        $parsedlink = array('content' => $link->title, 'url' => $CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $link->id, 'new' => false, 'link_info' => array('link' => $link->title, 'pageid' => $link->id, 'new' => false));
        $version = wiki_get_current_version($link->id);
        if ($version->version == 0) {
            $parsedlink['new'] = true;
        }
        return $parsedlink;
    } else {
        $swid = $options['swid'];
        if ($page = wiki_get_page_by_title($swid, $link)) {
            $parsedlink = array('content' => $link, 'url' => $CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $page->id, 'new' => false, 'link_info' => array('link' => $link, 'pageid' => $page->id, 'new' => false));
            $version = wiki_get_current_version($page->id);
            if ($version->version == 0) {
                $parsedlink['new'] = true;
            }
            return $parsedlink;
        } else {
            return array('content' => $link, 'url' => $CFG->wwwroot . '/mod/wiki/create.php?swid=' . $swid . '&title=' . urlencode($link) . '&action=new', 'new' => true, 'link_info' => array('link' => $link, 'new' => true, 'pageid' => 0));
        }
    }
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:40,代码来源:locallib.php


示例2: set_action

    public function set_action($action, $commentid, $content) {
        $this->action = $action;
        $this->commentid = $commentid;
        $this->content = $content;

        $version = wiki_get_current_version($this->page->id);
        $format = $version->contentformat;

        $this->format = $format;
    }
开发者ID:Burick,项目名称:moodle,代码行数:10,代码来源:pagelib.php


示例3: test_page_version_restored

 /**
  * Test page_version_restored event.
  */
 public function test_page_version_restored()
 {
     $this->setUp();
     $page = $this->wikigenerator->create_first_page($this->wiki);
     $context = context_module::instance($this->wiki->cmid);
     $version = wiki_get_current_version($page->id);
     // Triggering and capturing the event.
     $sink = $this->redirectEvents();
     wiki_restore_page($page, $version, $context);
     $events = $sink->get_events();
     $this->assertCount(2, $events);
     $event = array_pop($events);
     // Checking that the event contains the expected values.
     $this->assertInstanceOf('\\mod_wiki\\event\\page_version_restored', $event);
     $this->assertEquals($context, $event->get_context());
     $this->assertEquals($version->id, $event->objectid);
     $this->assertEquals($page->id, $event->other['pageid']);
     $expected = array($this->course->id, 'wiki', 'restore', 'view.php?pageid=' . $page->id, $page->id, $this->wiki->cmid);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:24,代码来源:events_test.php


示例4: test_edit_page

 /**
  * Test edit_page. We won't test all the possible cases because that's already
  * done in the tests for wiki_save_section / wiki_save_page.
  */
 public function test_edit_page()
 {
     $this->create_individual_wikis_with_groups();
     // Test user with full capabilities.
     $this->setUser($this->student);
     $newpage = $this->getDataGenerator()->get_plugin_generator('mod_wiki')->create_page($this->wikisepind, array('group' => $this->group1->id, 'content' => 'Test'));
     // Test edit whole page.
     $sectioncontent = '<h1>Title1</h1>Text inside section';
     $newpagecontent = $sectioncontent . '<h1>Title2</h1>Text inside section';
     $result = mod_wiki_external::edit_page($newpage->id, $newpagecontent);
     $result = external_api::clean_returnvalue(mod_wiki_external::edit_page_returns(), $result);
     $this->assertInternalType('int', $result['pageid']);
     $version = wiki_get_current_version($result['pageid']);
     $this->assertEquals($newpagecontent, $version->content);
     // Test edit section.
     $newsectioncontent = '<h1>Title2</h1>New test2';
     $section = 'Title2';
     $result = mod_wiki_external::edit_page($newpage->id, $newsectioncontent, $section);
     $result = external_api::clean_returnvalue(mod_wiki_external::edit_page_returns(), $result);
     $this->assertInternalType('int', $result['pageid']);
     $expected = $sectioncontent . $newsectioncontent;
     $version = wiki_get_current_version($result['pageid']);
     $this->assertEquals($expected, $version->content);
     // Test locked section.
     $newsectioncontent = '<h1>Title2</h1>New test2';
     $section = 'Title2';
     try {
         // Using user 1 to avoid other users to edit.
         wiki_set_lock($newpage->id, 1, $section, true);
         mod_wiki_external::edit_page($newpage->id, $newsectioncontent, $section);
         $this->fail('Exception expected due to locked section');
     } catch (moodle_exception $e) {
         $this->assertEquals('pageislocked', $e->errorcode);
     }
     // Test edit non existing section.
     $newsectioncontent = '<h1>Title3</h1>New test3';
     $section = 'Title3';
     try {
         mod_wiki_external::edit_page($newpage->id, $newsectioncontent, $section);
         $this->fail('Exception expected due to non existing section in the page.');
     } catch (moodle_exception $e) {
         $this->assertEquals('invalidsection', $e->errorcode);
     }
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:48,代码来源:externallib_test.php


示例5: edit_page

 /**
  * Edit a page contents.
  *
  * @param int $pageid The page ID.
  * @param string $content Page contents.
  * @param int $section Section to be edited.
  * @return array of warnings and page data.
  * @since Moodle 3.1
  */
 public static function edit_page($pageid, $content, $section = null)
 {
     global $USER;
     $params = self::validate_parameters(self::edit_page_parameters(), array('pageid' => $pageid, 'content' => $content, 'section' => $section));
     $warnings = array();
     // Get wiki page.
     if (!($page = wiki_get_page($params['pageid']))) {
         throw new moodle_exception('incorrectpageid', 'wiki');
     }
     // Get wiki instance.
     if (!($wiki = wiki_get_wiki_from_pageid($params['pageid']))) {
         throw new moodle_exception('incorrectwikiid', 'wiki');
     }
     // Get subwiki instance.
     if (!($subwiki = wiki_get_subwiki($page->subwikiid))) {
         throw new moodle_exception('incorrectsubwikiid', 'wiki');
     }
     // Permission validation.
     $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     if (!wiki_user_can_edit($subwiki)) {
         throw new moodle_exception('cannoteditpage', 'wiki');
     }
     if (wiki_is_page_section_locked($page->id, $USER->id, $params['section'])) {
         throw new moodle_exception('pageislocked', 'wiki');
     }
     // Save content.
     if (!is_null($params['section'])) {
         $version = wiki_get_current_version($page->id);
         $content = wiki_parser_proxy::get_section($version->content, $version->contentformat, $params['section'], false);
         if (!$content) {
             throw new moodle_exception('invalidsection', 'wiki');
         }
         $save = wiki_save_section($page, $params['section'], $params['content'], $USER->id);
     } else {
         $save = wiki_save_page($page, $params['content'], $USER->id);
     }
     wiki_delete_locks($page->id, $USER->id, $params['section']);
     if (!$save) {
         throw new moodle_exception('savingerror', 'wiki');
     }
     $result = array();
     $result['pageid'] = $page->id;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:56,代码来源:external.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wiki_get_formats函数代码示例发布时间:2022-05-23
下一篇:
PHP wiki_get_comments函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap