本文整理汇总了PHP中wiki_get_wiki_from_pageid函数的典型用法代码示例。如果您正苦于以下问题:PHP wiki_get_wiki_from_pageid函数的具体用法?PHP wiki_get_wiki_from_pageid怎么用?PHP wiki_get_wiki_from_pageid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wiki_get_wiki_from_pageid函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wiki_save_page
/**
* Save page content
* @param object $wikipage
* @param string $newcontent
* @param int $userid
*/
function wiki_save_page($wikipage, $newcontent, $userid)
{
global $DB;
$wiki = wiki_get_wiki_from_pageid($wikipage->id);
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (has_capability('mod/wiki:editpage', $context)) {
$version = wiki_get_current_version($wikipage->id);
$version->content = $newcontent;
$version->userid = $userid;
$version->version++;
$version->timecreated = time();
$versionid = $DB->insert_record('wiki_versions', $version);
$wikipage->timemodified = $version->timecreated;
$wikipage->userid = $userid;
$return = wiki_refresh_cachedcontent($wikipage, $newcontent);
return $return;
} else {
return false;
}
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:27,代码来源:locallib.php
示例2: 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
示例3: wiki_delete_page_versions
/**
* Delete specificed versions of a page or versions created by users
* if version is 0 then it will remove all versions of the page
*
* @param array $deleteversions delete versions for a page
* @param context_module $context module context
*/
function wiki_delete_page_versions($deleteversions, $context = null)
{
global $DB;
/// delete page-versions
foreach ($deleteversions as $id => $versions) {
$params = array('pageid' => $id);
if (is_null($context)) {
$wiki = wiki_get_wiki_from_pageid($id);
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
$context = context_module::instance($cm->id);
}
// Delete all versions, if version specified is 0.
if (in_array(0, $versions)) {
$oldversions = $DB->get_records('wiki_versions', $params);
$DB->delete_records('wiki_versions', $params, IGNORE_MISSING);
} else {
list($insql, $param) = $DB->get_in_or_equal($versions);
$insql .= ' AND pageid = ?';
array_push($param, $params['pageid']);
$oldversions = $DB->get_recordset_select('wiki_versions', 'version ' . $insql, $param);
$DB->delete_records_select('wiki_versions', 'version ' . $insql, $param);
}
foreach ($oldversions as $version) {
// Trigger page version deleted event.
$event = \mod_wiki\event\page_version_deleted::create(array('context' => $context, 'objectid' => $version->id, 'other' => array('pageid' => $id)));
$event->add_record_snapshot('wiki_versions', $version);
$event->trigger();
}
}
}
开发者ID:isuruAb,项目名称:moodle,代码行数:37,代码来源:locallib.php
示例4: 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
示例5: 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
示例6: 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_wiki_from_pageid函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论