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


PHP wiki_save_section函数代码示例

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


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

示例1: print_save

    protected function print_save() {
        global $CFG, $USER, $OUTPUT, $PAGE;

        $url = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $this->page->id;
        if (!empty($this->section)) {
            $url .= "&section=" . urlencode($this->section);
        }

        $params = array(
            'attachmentoptions' => page_wiki_edit::$attachmentoptions,
            'format' => $this->format,
            'version' => $this->versionnumber,
            'contextid' => $this->modcontext->id
        );

        if ($this->format != 'html') {
            $params['fileitemid'] = $this->page->id;
            $params['component']  = 'mod_wiki';
            $params['filearea']   = 'attachments';
        }

        $form = new mod_wiki_edit_form($url, $params);

        $save = false;
        $data = false;
        if ($data = $form->get_data()) {
            if ($this->format == 'html') {
                $data = file_postupdate_standard_editor($data, 'newcontent', page_wiki_edit::$attachmentoptions, $this->modcontext, 'mod_wiki', 'attachments', $this->subwiki->id);
            }

            if (isset($this->section)) {
                $save = wiki_save_section($this->page, $this->section, $data->newcontent, $USER->id);
            } else {
                $save = wiki_save_page($this->page, $data->newcontent, $USER->id);
            }
        }

        if ($save && $data) {
            if (!empty($CFG->usetags)) {
                tag_set('wiki_pages', $this->page->id, $data->tags);
            }

            $message = '<p>' . get_string('saving', 'wiki') . '</p>';

            if (!empty($save['sections'])) {
                foreach ($save['sections'] as $s) {
                    $message .= '<p>' . get_string('repeatedsection', 'wiki', $s) . '</p>';
                }
            }

            if ($this->versionnumber + 1 != $save['version']) {
                $message .= '<p>' . get_string('wrongversionsave', 'wiki') . '</p>';
            }

            if (isset($errors) && !empty($errors)) {
                foreach ($errors as $e) {
                    $message .= "<p>" . get_string('filenotuploadederror', 'wiki', $e->get_filename()) . "</p>";
                }
            }

            //deleting old locks
            wiki_delete_locks($this->page->id, $USER->id, $this->section);
            $url = new moodle_url('view.php', array('pageid' => $this->page->id, 'group' => $this->subwiki->groupid));
            redirect($url);
        } else {
            print_error('savingerror', 'wiki');
        }
    }
开发者ID:Burick,项目名称:moodle,代码行数:68,代码来源:pagelib.php

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