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


PHP wiki_get_subwiki函数代码示例

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


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

示例1: wiki_comment_validate

/**
 * Validate comment parameter before perform other comments actions
 *
 * @param stdClass $comment_param {
 *              context  => context the context object
 *              courseid => int course id
 *              cm       => stdClass course module object
 *              commentarea => string comment area
 *              itemid      => int itemid
 * }
 *
 * @package  mod_wiki
 * @category comment
 *
 * @return boolean
 */
function wiki_comment_validate($comment_param)
{
    global $DB, $CFG;
    require_once $CFG->dirroot . '/mod/wiki/locallib.php';
    // validate comment area
    if ($comment_param->commentarea != 'wiki_page') {
        throw new comment_exception('invalidcommentarea');
    }
    // validate itemid
    if (!($record = $DB->get_record('wiki_pages', array('id' => $comment_param->itemid)))) {
        throw new comment_exception('invalidcommentitemid');
    }
    if (!($subwiki = wiki_get_subwiki($record->subwikiid))) {
        throw new comment_exception('invalidsubwikiid');
    }
    if (!($wiki = wiki_get_wiki_from_pageid($comment_param->itemid))) {
        throw new comment_exception('invalidid', 'data');
    }
    if (!($course = $DB->get_record('course', array('id' => $wiki->course)))) {
        throw new comment_exception('coursemisconf');
    }
    if (!($cm = get_coursemodule_from_instance('wiki', $wiki->id, $course->id))) {
        throw new comment_exception('invalidcoursemodule');
    }
    $context = context_module::instance($cm->id);
    // group access
    if ($subwiki->groupid) {
        $groupmode = groups_get_activity_groupmode($cm, $course);
        if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
            if (!groups_is_member($subwiki->groupid)) {
                throw new comment_exception('notmemberofgroup');
            }
        }
    }
    // validate context id
    if ($context->id != $comment_param->context->id) {
        throw new comment_exception('invalidcontext');
    }
    // validation for comment deletion
    if (!empty($comment_param->commentid)) {
        if ($comment = $DB->get_record('comments', array('id' => $comment_param->commentid))) {
            if ($comment->commentarea != 'wiki_page') {
                throw new comment_exception('invalidcommentarea');
            }
            if ($comment->contextid != $context->id) {
                throw new comment_exception('invalidcontext');
            }
            if ($comment->itemid != $comment_param->itemid) {
                throw new comment_exception('invalidcommentitemid');
            }
        } else {
            throw new comment_exception('invalidcommentid');
        }
    }
    return true;
}
开发者ID:dg711,项目名称:moodle,代码行数:72,代码来源:lib.php

示例2: wiki_parse_content

/**
 * Parses a string with the wiki markup language in $markup.
 *
 * @return Array or false when something wrong has happened.
 *
 * Returned array contains the following fields:
 *     'parsed_text' => String. Contains the parsed wiki content.
 *     'unparsed_text' => String. Constains the original wiki content.
 *     'link_count' => Array of array('destination' => ..., 'new' => "is new?"). Contains the internal wiki links found in the wiki content.
 *      'deleted_sections' => the list of deleted sections.
 *              '' =>
 *
 * @author Josep Arús Pous
 **/
function wiki_parse_content($markup, $pagecontent, $options = array())
{
    global $PAGE;
    $subwiki = wiki_get_subwiki($options['swid']);
    $cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid);
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    $parser_options = array('link_callback' => '/mod/wiki/locallib.php:wiki_parser_link', 'link_callback_args' => array('swid' => $options['swid']), 'table_callback' => '/mod/wiki/locallib.php:wiki_parser_table', 'real_path_callback' => '/mod/wiki/locallib.php:wiki_parser_real_path', 'real_path_callback_args' => array('context' => $context, 'component' => 'mod_wiki', 'filearea' => 'attachments', 'subwikiid' => $subwiki->id, 'pageid' => $options['pageid']), 'pageid' => $options['pageid'], 'pretty_print' => isset($options['pretty_print']) && $options['pretty_print'], 'printable' => isset($options['printable']) && $options['printable']);
    return wiki_parser_proxy::parse($pagecontent, $markup, $parser_options);
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:23,代码来源:locallib.php

示例3: 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

示例4: clean_param

    $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');
}
// Checking course instance
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$context = context_module::instance($cm->id);
$PAGE->set_url('/mod/wiki/files.php', array('pageid' => $pageid));
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:files.php

示例5: optional_param

$action = optional_param('action', 'new', PARAM_TEXT);
// The title of the new page, can be empty
$title = optional_param('title', get_string('newpage', 'wiki'), PARAM_TEXT);
$wid = optional_param('wid', 0, PARAM_INT);
$swid = optional_param('swid', 0, PARAM_INT);
$group = optional_param('group', 0, PARAM_INT);
$uid = optional_param('uid', 0, PARAM_INT);
// 'create' action must be submitted by moodle form
// so sesskey must be checked
if ($action == 'create') {
    if (!confirm_sesskey()) {
        print_error('invalidsesskey');
    }
}
if (!empty($swid)) {
    $subwiki = wiki_get_subwiki($swid);
    if (!($wiki = wiki_get_wiki($subwiki->wikiid))) {
        print_error('incorrectwikiid', 'wiki');
    }
} else {
    $subwiki = wiki_get_subwiki_by_group($wid, $group, $uid);
    if (!($wiki = wiki_get_wiki($wid))) {
        print_error('incorrectwikiid', 'wiki');
    }
}
if (!($cm = get_coursemodule_from_instance('wiki', $wiki->id))) {
    print_error('invalidcoursemodule');
}
$groups = new stdClass();
if (groups_get_activity_groupmode($cm)) {
    $modulecontext = context_module::instance($cm->id);
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:create.php

示例6: test_new_page

 /**
  * Test new_page. We won't test all the possible cases because that's already
  * done in the tests for wiki_create_page.
  */
 public function test_new_page()
 {
     $this->create_individual_wikis_with_groups();
     $sectioncontent = '<h1>Title1</h1>Text inside section';
     $pagecontent = $sectioncontent . '<h1>Title2</h1>Text inside section';
     $pagetitle = 'Page Title';
     // Test user with full capabilities.
     $this->setUser($this->student);
     // Test on existing subwiki.
     $result = mod_wiki_external::new_page($pagetitle, $pagecontent, 'html', $this->fpsepg1indstu->subwikiid);
     $result = external_api::clean_returnvalue(mod_wiki_external::new_page_returns(), $result);
     $this->assertInternalType('int', $result['pageid']);
     $version = wiki_get_current_version($result['pageid']);
     $this->assertEquals($pagecontent, $version->content);
     $this->assertEquals('html', $version->contentformat);
     $page = wiki_get_page($result['pageid']);
     $this->assertEquals($pagetitle, $page->title);
     // Test existing page creation.
     try {
         mod_wiki_external::new_page($pagetitle, $pagecontent, 'html', $this->fpsepg1indstu->subwikiid);
         $this->fail('Exception expected due to creation of an existing page.');
     } catch (moodle_exception $e) {
         $this->assertEquals('pageexists', $e->errorcode);
     }
     // Test on non existing subwiki. Add student to group2 to have a new subwiki to be created.
     $this->getDataGenerator()->create_group_member(array('userid' => $this->student->id, 'groupid' => $this->group2->id));
     $result = mod_wiki_external::new_page($pagetitle, $pagecontent, 'html', null, $this->wikisepind->id, $this->student->id, $this->group2->id);
     $result = external_api::clean_returnvalue(mod_wiki_external::new_page_returns(), $result);
     $this->assertInternalType('int', $result['pageid']);
     $version = wiki_get_current_version($result['pageid']);
     $this->assertEquals($pagecontent, $version->content);
     $this->assertEquals('html', $version->contentformat);
     $page = wiki_get_page($result['pageid']);
     $this->assertEquals($pagetitle, $page->title);
     $subwiki = wiki_get_subwiki($page->subwikiid);
     $expected = new StdClass();
     $expected->id = $subwiki->id;
     $expected->wikiid = $this->wikisepind->id;
     $expected->groupid = $this->group2->id;
     $expected->userid = $this->student->id;
     $this->assertEquals($expected, $subwiki);
     // Check page creation for a user not in course.
     $this->studentnotincourse = self::getDataGenerator()->create_user();
     $this->anothercourse = $this->getDataGenerator()->create_course();
     $this->groupnotincourse = $this->getDataGenerator()->create_group(array('courseid' => $this->anothercourse->id));
     try {
         mod_wiki_external::new_page($pagetitle, $pagecontent, 'html', null, $this->wikisepind->id, $this->studentnotincourse->id, $this->groupnotincourse->id);
         $this->fail('Exception expected due to creation of an invalid subwiki creation.');
     } catch (moodle_exception $e) {
         $this->assertEquals('cannoteditpage', $e->errorcode);
     }
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:56,代码来源:externallib_test.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) {
         $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

示例8: dirname

 * Manage files in wiki
 *
 * @package   mod_wiki
 * @copyright 2011 Dongsheng Cai <dongsheng@moodle.com>
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once 'lib.php';
require_once 'locallib.php';
require_once "{$CFG->dirroot}/mod/wiki/filesedit_form.php";
require_once "{$CFG->dirroot}/repository/lib.php";
$subwikiid = required_param('subwiki', PARAM_INT);
// not being used for file management, we use it to generate navbar link
$pageid = optional_param('pageid', 0, PARAM_INT);
$returnurl = optional_param('returnurl', '', PARAM_LOCALURL);
if (!($subwiki = wiki_get_subwiki($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');
}
// Checking course instance
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$context = context_module::instance($cm->id);
require_login($course, true, $cm);
if (!wiki_user_can_view($subwiki, $wiki)) {
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:filesedit.php

示例9: 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

示例10: 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

示例11: 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

示例12: view_page

 /**
  * Trigger the page viewed event and update the module completion status.
  *
  * @param int $pageid The page ID.
  * @return array of warnings and status result.
  * @since Moodle 3.1
  * @throws moodle_exception if page is not valid.
  */
 public static function view_page($pageid)
 {
     $params = self::validate_parameters(self::view_page_parameters(), array('pageid' => $pageid));
     $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');
     }
     // Permission validation.
     list($course, $cm) = get_course_and_cm_from_instance($wiki, 'wiki');
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     // Check if user can view this wiki.
     if (!($subwiki = wiki_get_subwiki($page->subwikiid))) {
         throw new moodle_exception('incorrectsubwikiid', 'wiki');
     }
     if (!wiki_user_can_view($subwiki, $wiki)) {
         throw new moodle_exception('cannotviewpage', 'wiki');
     }
     // Trigger page_viewed event and completion.
     wiki_page_view($wiki, $page, $course, $cm, $context);
     $result = array();
     $result['status'] = true;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:matiasma,项目名称:moodle,代码行数:38,代码来源:external.php

示例13: get_page_contents

 /**
  * Get a page contents.
  *
  * @param int $pageid The page ID.
  * @return array of warnings and page data.
  * @since Moodle 3.1
  */
 public static function get_page_contents($pageid)
 {
     $params = self::validate_parameters(self::get_page_contents_parameters(), array('pageid' => $pageid));
     $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');
     }
     // Permission validation.
     $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     // Check if user can view this wiki.
     if (!($subwiki = wiki_get_subwiki($page->subwikiid))) {
         throw new moodle_exception('incorrectsubwikiid', 'wiki');
     }
     if (!wiki_user_can_view($subwiki, $wiki)) {
         throw new moodle_exception('cannotviewpage', 'wiki');
     }
     $returnedpage = array();
     $returnedpage['id'] = $page->id;
     $returnedpage['wikiid'] = $wiki->id;
     $returnedpage['subwikiid'] = $page->subwikiid;
     $returnedpage['groupid'] = $subwiki->groupid;
     $returnedpage['userid'] = $subwiki->userid;
     $returnedpage['title'] = $page->title;
     // Refresh page cached content if needed.
     if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
         if ($content = wiki_refresh_cachedcontent($page)) {
             $page = $content['page'];
         }
     }
     list($returnedpage['cachedcontent'], $returnedpage['contentformat']) = external_format_text($page->cachedcontent, FORMAT_HTML, $context->id, 'mod_wiki', 'attachments', $subwiki->id);
     $returnedpage['caneditpage'] = wiki_user_can_edit($subwiki);
     $result = array();
     $result['page'] = $returnedpage;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:rushi963,项目名称:moodle,代码行数:50,代码来源:external.php


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