本文整理汇总了PHP中Wiki::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Wiki::update方法的具体用法?PHP Wiki::update怎么用?PHP Wiki::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wiki
的用法示例。
在下文中一共展示了Wiki::update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Wiki
function handler_ajax_update($page)
{
$json = json_decode(Env::v('json'));
$wiki = new Wiki($json->wid);
$page->jsonAssign('success', true);
try {
$wiki->select(Wiki::SELECT_VERSION);
$content = trim($json->content);
if ($content != $wiki->content()) {
$wiki->update($content);
$wiki->select(Wiki::SELECT_VERSION);
}
$page->jsonAssign('html', $wiki->html());
} catch (Exception $e) {
$page->jsonAssign('success', false);
}
return PL_JSON;
}
示例2: from
public static function from($mixed, $insertIfNotExists = false)
{
try {
$w = static::batchFrom(array($mixed))->first();
} catch (ItemNotFoundException $e) {
if ($insertIfNotExists) {
$w = new Wiki(array('name' => $mixed));
$w->insert();
$w->update('');
} else {
throw $e;
}
}
return $w;
}
示例3: execute
/**
* We already knew beforehand what handle was requested and the ID was looked up.
* @param int $id
* @return array(title,content)
*/
function execute($id)
{
$w = new Wiki($this->db);
$w->set($id);
$this->dispatcher->controller->dispatcherObject = $w;
$content = $w->revision->content;
$handle = $w->handle;
if (!$this->hasRights($_SESSION['access'], 'modify', $handle)) {
return array($handle . ' - WikiCreate', 'No Permission');
}
$args = $this->defaultArgs;
$args['content'] = $content;
// Lets save it.
if (isset($_POST['save']) && !empty($_POST['wikicontent'])) {
// Did it actually change?
if (htmlentities($_POST['wikicontent']) !== $content) {
$w->update(htmlentities($_POST['wikicontent']));
header('Location: ' . PATH_TO_DOCROOT . '/wiki/' . $handle);
exit;
}
} elseif (isset($_POST['preview']) && !empty($_POST['wikicontent'])) {
// But only if the content actually
if (htmlentities($_POST['wikicontent']) !== $content) {
$wv = new WikiView($this->dispatcher);
list(, $args['preview_content']) = $wv->execute('', htmlentities($_POST['wikicontent']), false);
$args['content'] = htmlentities($_POST['wikicontent']);
$args['preview'] = $this->template->parse('preview', $args);
}
}
$args['button_action'] = '/wiki/' . $handle;
$args['button'] = 'Cancel';
$args['class'] = 'buttonmargin';
$buttons = $this->template->parse('button', $args);
$args['handle'] = $handle;
$args['formaction'] = '/wiki/' . $handle . '?action=edit';
$args['actiontype'] = 'Submit changes';
$args['buttons'] = $buttons;
$this->siteArgs['edit']['active'] = 'active';
$this->addSiteArgs();
return array($handle . ' - WikiModify', $this->template->parse('create', $args));
}