本文整理汇总了PHP中Draft::ListDrafts方法的典型用法代码示例。如果您正苦于以下问题:PHP Draft::ListDrafts方法的具体用法?PHP Draft::ListDrafts怎么用?PHP Draft::ListDrafts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Draft
的用法示例。
在下文中一共展示了Draft::ListDrafts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadForm
/**
* EditPage::showEditForm:initial hook
* Load draft...
*/
public static function loadForm(&$editpage)
{
global $wgUser, $wgRequest, $wgOut, $wgTitle, $wgLang;
if (!wfRunHooks("ShouldUseDrafts", array())) {
return true;
}
// Check permissions
//XXCHANGED
$adv = $editpage->mGuided == true ? "" : "&advanced=true";
$wgRequest->setVal("guidededitor", $editpage->mGuided);
if ($wgUser->isAllowed('edit') && $wgUser->isLoggedIn()) {
// Get draft
$draft = Draft::newFromID($wgRequest->getIntOrNull('draft'));
// Load form values
if ($draft->exists()) {
// Override initial values in the form with draft data
$editpage->textbox1 = $draft->getText();
$editpage->summary = $draft->getSummary();
$editpage->scrolltop = $draft->getScrollTop();
$editpage->minoredit = $draft->getMinorEdit() ? true : false;
}
// Save draft on non-save submission
if ($wgRequest->getVal('action') == 'submit' && $wgUser->editToken() == $wgRequest->getText('wpEditToken')) {
// If the draft wasn't specified in the url, try using a form-submitted one
if (!$draft->exists()) {
$draft = Draft::newFromID($wgRequest->getIntOrNull('wpDraftID'));
}
// Load draft with info
$draft->setTitle(Title::newFromText($wgRequest->getText('wpDraftTitle')));
$draft->setSection($wgRequest->getInt('wpSection'));
$draft->setStartTime($wgRequest->getText('wpStarttime'));
$draft->setEditTime($wgRequest->getText('wpEdittime'));
$draft->setSaveTime(wfTimestampNow());
$draft->setScrollTop($wgRequest->getInt('wpScrolltop'));
$draft->setText($wgRequest->getText('wpTextbox1'));
$draft->setSummary($wgRequest->getText('wpSummary'));
$draft->setMinorEdit($wgRequest->getInt('wpMinoredit', 0));
// Save draft
$draft->save();
// Use the new draft id
$wgRequest->setVal('draft', $draft->getID());
}
}
// Internationalization
wfLoadExtensionMessages('Drafts');
$numDrafts = Draft::countDrafts($wgTitle);
// Show list of drafts
if ($numDrafts > 0) {
if ($wgRequest->getText('action') !== 'submit') {
$wgOut->addHTML(Xml::openElement('div', array('id' => 'drafts-list-box', 'class' => 'minor_section')));
$wgOut->addHTML(Xml::element('h2', null, wfMsg('drafts-view-existing')));
Draft::ListDrafts($wgTitle);
$wgOut->addHTML(Xml::closeElement('div'));
} else {
$link = Xml::element('a', array('href' => $wgTitle->getFullURL("action=edit" . $adv), 'onclick' => "if( !wgAjaxSaveDraft.insync ) return confirm('" . Xml::escapeJsString(wfMsgHTML('drafts-view-warn')) . "')"), wfMsgExt('drafts-view-notice-link', array('parsemag'), $wgLang->formatNum($numDrafts)));
$wgOut->addHTML('<div class="minor_section">' . wfMsgHTML('drafts-view-notice', $link) . '</div>');
}
}
// Continue
return true;
}