本文整理汇总了PHP中wiki_get_formats函数的典型用法代码示例。如果您正苦于以下问题:PHP wiki_get_formats函数的具体用法?PHP wiki_get_formats怎么用?PHP wiki_get_formats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wiki_get_formats函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
function definition()
{
global $COURSE;
$mform =& $this->_form;
//-------------------------------------------------------------------------------
/// Adding the "general" fieldset, where all the common settings are showed
$mform->addElement('header', 'general', get_string('general', 'form'));
/// Adding the standard "name" field
$mform->addElement('text', 'name', get_string('wikiname', 'wiki'), array('size' => '64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
/// Adding the optional "intro" and "introformat" pair of fields
// $mform->addElement('htmleditor', 'intro', get_string('wikiintro', 'wiki'));
// $mform->setType('intro', PARAM_RAW);
// $mform->addRule('intro', get_string('required'), 'required', null, 'client');
//
// $mform->addElement('format', 'introformat', get_string('format'));
$this->add_intro_editor(true, get_string('wikiintro', 'wiki'));
//-------------------------------------------------------------------------------
/// Adding the rest of wiki settings, spreeading all them into this fieldset
/// or adding more fieldsets ('header' elements) if needed for better logic
$mform->addElement('header', 'wikifieldset', get_string('wikisettings', 'wiki'));
$attr = array('size' => '20');
if (!empty($this->_instance)) {
$attr['disabled'] = 'disabled';
} else {
$attr['value'] = get_string('firstpagetitle', 'wiki');
}
$mform->addElement('text', 'firstpagetitle', get_string('firstpagetitle', 'wiki'), $attr);
$mform->addHelpButton('firstpagetitle', 'firstpagetitle', 'wiki');
if (empty($this->_instance)) {
$mform->addRule('firstpagetitle', null, 'required', null, 'client');
}
$wikimodeoptions = array('collaborative' => get_string('wikimodecollaborative', 'wiki'), 'individual' => get_string('wikimodeindividual', 'wiki'));
// don't allow to change wiki type once is set
$wikitype_attr = array();
if (!empty($this->_instance)) {
$wikitype_attr['disabled'] = 'disabled';
}
$mform->addElement('select', 'wikimode', get_string('wikimode', 'wiki'), $wikimodeoptions, $wikitype_attr);
$mform->addHelpButton('wikimode', 'wikimode', 'wiki');
$formats = wiki_get_formats();
$editoroptions = array();
foreach ($formats as $format) {
$editoroptions[$format] = get_string($format, 'wiki');
}
$mform->addElement('select', 'defaultformat', get_string('defaultformat', 'wiki'), $editoroptions);
$mform->addHelpButton('defaultformat', 'defaultformat', 'wiki');
$mform->addElement('checkbox', 'forceformat', get_string('forceformat', 'wiki'));
$mform->addHelpButton('forceformat', 'forceformat', 'wiki');
//-------------------------------------------------------------------------------
// add standard elements, common to all modules
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
// add standard buttons, common to all modules
$this->add_action_buttons();
}
示例2: definition
protected function definition()
{
$mform = $this->_form;
$required = get_string('required');
//-------------------------------------------------------------------------------
// Adding the "general" fieldset, where all the common settings are shown.
$mform->addElement('header', 'general', get_string('general', 'form'));
// Adding the standard "name" field.
$mform->addElement('text', 'name', get_string('wikiname', 'wiki'), array('size' => '64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', $required, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Adding the optional "intro" and "introformat" pair of fields
$this->add_intro_editor(true, get_string('wikiintro', 'wiki'));
$wikimodeoptions = array('collaborative' => get_string('wikimodecollaborative', 'wiki'), 'individual' => get_string('wikimodeindividual', 'wiki'));
// Don't allow changes to the wiki type once it is set.
$wikitype_attr = array();
if (!empty($this->_instance)) {
$wikitype_attr['disabled'] = 'disabled';
}
$mform->addElement('select', 'wikimode', get_string('wikimode', 'wiki'), $wikimodeoptions, $wikitype_attr);
$mform->addHelpButton('wikimode', 'wikimode', 'wiki');
$attr = array('size' => '20');
if (!empty($this->_instance)) {
$attr['disabled'] = 'disabled';
}
$mform->addElement('text', 'firstpagetitle', get_string('firstpagetitle', 'wiki'), $attr);
$mform->addHelpButton('firstpagetitle', 'firstpagetitle', 'wiki');
$mform->setType('firstpagetitle', PARAM_TEXT);
if (empty($this->_instance)) {
$mform->addRule('firstpagetitle', $required, 'required', null, 'client');
}
// Format.
$mform->addElement('header', 'wikifieldset', get_string('format'));
$formats = wiki_get_formats();
$editoroptions = array();
foreach ($formats as $format) {
$editoroptions[$format] = get_string($format, 'wiki');
}
$mform->addElement('select', 'defaultformat', get_string('defaultformat', 'wiki'), $editoroptions);
$mform->addHelpButton('defaultformat', 'defaultformat', 'wiki');
$mform->addElement('checkbox', 'forceformat', get_string('forceformat', 'wiki'));
$mform->addHelpButton('forceformat', 'forceformat', 'wiki');
//-------------------------------------------------------------------------------
// Add standard elements, common to all modules.
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
// Add standard buttons, common to all modules.
$this->add_action_buttons();
}
示例3: set_action
function set_action($action) {
global $PAGE;
$this->action = $action;
require_once(dirname(__FILE__) . '/create_form.php');
$url = new moodle_url('/mod/wiki/create.php', array('action' => 'create', 'wid' => $PAGE->activityrecord->id, 'group' => $this->gid, 'uid' => $this->uid));
$formats = wiki_get_formats();
$options = array('formats' => $formats, 'defaultformat' => $PAGE->activityrecord->defaultformat, 'forceformat' => $PAGE->activityrecord->forceformat, 'groups' => $this->groups);
if ($this->title != get_string('newpage', 'wiki')) {
$options['disable_pagetitle'] = true;
}
$this->mform = new mod_wiki_create_form($url->out(false), $options);
}
示例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;
}