本文整理汇总了PHP中wiki_get_page_by_title函数的典型用法代码示例。如果您正苦于以下问题:PHP wiki_get_page_by_title函数的具体用法?PHP wiki_get_page_by_title怎么用?PHP wiki_get_page_by_title使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wiki_get_page_by_title函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wiki_extend_navigation
function wiki_extend_navigation(navigation_node $navref, $course, $module, $cm)
{
global $CFG, $PAGE, $USER;
require_once $CFG->dirroot . '/mod/wiki/locallib.php';
$context = context_module::instance($cm->id);
$url = $PAGE->url;
$userid = 0;
if ($module->wikimode == 'individual') {
$userid = $USER->id;
}
if (!($wiki = wiki_get_wiki($cm->instance))) {
return false;
}
if (!($gid = groups_get_activity_group($cm))) {
$gid = 0;
}
if (!($subwiki = wiki_get_subwiki_by_group($cm->instance, $gid, $userid))) {
return null;
} else {
$swid = $subwiki->id;
}
$pageid = $url->param('pageid');
$cmid = $url->param('id');
if (empty($pageid) && !empty($cmid)) {
// wiki main page
$page = wiki_get_page_by_title($swid, $wiki->firstpagetitle);
$pageid = $page->id;
}
if (wiki_can_create_pages($context)) {
$link = new moodle_url('/mod/wiki/create.php', array('action' => 'new', 'swid' => $swid));
$node = $navref->add(get_string('newpage', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (is_numeric($pageid)) {
if (has_capability('mod/wiki:viewpage', $context)) {
$link = new moodle_url('/mod/wiki/view.php', array('pageid' => $pageid));
$node = $navref->add(get_string('view', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (wiki_user_can_edit($subwiki)) {
$link = new moodle_url('/mod/wiki/edit.php', array('pageid' => $pageid));
$node = $navref->add(get_string('edit', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:viewcomment', $context)) {
$link = new moodle_url('/mod/wiki/comments.php', array('pageid' => $pageid));
$node = $navref->add(get_string('comments', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:viewpage', $context)) {
$link = new moodle_url('/mod/wiki/history.php', array('pageid' => $pageid));
$node = $navref->add(get_string('history', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:viewpage', $context)) {
$link = new moodle_url('/mod/wiki/map.php', array('pageid' => $pageid));
$node = $navref->add(get_string('map', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:viewpage', $context)) {
$link = new moodle_url('/mod/wiki/files.php', array('pageid' => $pageid));
$node = $navref->add(get_string('files', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:managewiki', $context)) {
$link = new moodle_url('/mod/wiki/admin.php', array('pageid' => $pageid));
$node = $navref->add(get_string('admin', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
}
}
开发者ID:dg711,项目名称:moodle,代码行数:63,代码来源:lib.php
示例2: 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
示例3: print_error
$manageandedit = $manage && $edit;
if ($groupmode == VISIBLEGROUPS and ($modeanduser || $modeandgroupmember) and !$manageandedit) {
print_error('nocontent','wiki');
}
$params = array('wid' => $wiki->id, 'group' => $gid, 'uid' => $uid, 'title' => $title);
$url = new moodle_url('/mod/wiki/create.php', $params);
redirect($url);
}
// Checking is there is a page with this title. If it does not exists, redirect to first page
if (!$page = wiki_get_page_by_title($subwiki->id, $title)) {
$params = array('wid' => $wiki->id, 'group' => $gid, 'uid' => $uid, 'title' => $wiki->firstpagetitle);
// Check to see if the first page has been created
if (!wiki_get_page_by_title($subwiki->id, $wiki->firstpagetitle)) {
$url = new moodle_url('/mod/wiki/create.php', $params);
} else {
$url = new moodle_url('/mod/wiki/view.php', $params);
}
redirect($url);
}
// /*
// * Case 3:
// *
// * A user switches group when is 'reading' a non-existent page.
// *
// * URL Params: wid -> wiki id
// * title -> page title
// * currentgroup -> group id
开发者ID:JP-Git,项目名称:moodle,代码行数:31,代码来源:view.php
示例4: 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
示例5: array
$gid = 0;
$uid = 0;
} else {
$gid = $currentgroup;
$uid = 0;
}
}
}
// Getting subwiki instance. If it does not exists, redirect to create page
if (!($subwiki = wiki_get_subwiki_by_group($wiki->id, $gid, $uid))) {
$params = array('wid' => $wiki->id, 'gid' => $gid, 'uid' => $uid, 'title' => $title);
$url = new moodle_url('/mod/wiki/create.php', $params);
redirect($url);
}
// Checking is there is a page with this title. If it does not exists, redirect to first page
if (!($page = wiki_get_page_by_title($subwiki->id, $title))) {
$params = array('wid' => $wiki->id, 'gid' => $gid, 'uid' => $uid, 'title' => $wiki->firstpagetitle);
$url = new moodle_url('/mod/wiki/view.php', $params);
redirect($url);
}
// /*
// * Case 3:
// *
// * A user switches group when is 'reading' a non-existent page.
// *
// * URL Params: wid -> wiki id
// * title -> page title
// * currentgroup -> group id
// *
// */
//} elseif ($wid && $title && $currentgroup) {
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:view.php
示例6: 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
示例7: 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_get_page_by_title函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论