本文整理汇总了PHP中Draft::newToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Draft::newToken方法的具体用法?PHP Draft::newToken怎么用?PHP Draft::newToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Draft
的用法示例。
在下文中一共展示了Draft::newToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: controls
/**
* EditPageBeforeEditButtons hook
* Add draft saving controls
*/
public static function controls(&$editpage, &$buttons)
{
global $wgUser, $wgTitle, $wgRequest, $egDraftsAutoSaveWait;
// Check permissions
if ($wgUser->isAllowed('edit') && $wgUser->isLoggedIn() && wfRunHooks("ShouldUseDrafts", array())) {
// Internationalization
wfLoadExtensionMessages('Drafts');
// Build XML
$buttons['savedraft'] = Xml::openElement('script', array('type' => 'text/javascript', 'language' => 'javascript'));
$buttonAttribs = array('id' => 'wpDraftSave', 'name' => 'wpDraftSave', 'tabindex' => 8, 'value' => wfMsg('drafts-save-save'), 'class' => 'button secondary disabled ');
$accesskey = $wgUser->getSkin()->accesskey('drafts-save');
if ($accesskey !== false) {
$buttonAttribs['accesskey'] = $accesskey;
}
$tooltip = $wgUser->getSkin()->titleAttrib('drafts-save', 'withaccess');
if ($tooltip !== false) {
$buttonAttribs['title'] = $tooltip;
}
$ajaxButton = Xml::escapeJsString(Xml::element('input', array('type' => 'button') + $buttonAttribs + ($wgRequest->getText('action') !== 'submit' ? array('disabled' => 'disabled', 'class' => 'disabled') : array())));
$buttons['savedraft'] .= "document.write( '{$ajaxButton}' );";
$buttons['savedraft'] .= Xml::closeElement('script');
$buttons['savedraft'] .= Xml::openElement('noscript');
$buttons['savedraft'] .= Xml::element('input', array('type' => 'submit') + $buttonAttribs);
$buttons['savedraft'] .= Xml::closeElement('noscript');
$buttons['savedraft'] .= Xml::element('input', array('type' => 'hidden', 'name' => 'wpDraftAutoSaveWait', 'value' => $egDraftsAutoSaveWait));
$buttons['savedraft'] .= Xml::element('input', array('type' => 'hidden', 'name' => 'wpDraftToken', 'value' => Draft::newToken()));
$buttons['savedraft'] .= Xml::element('input', array('type' => 'hidden', 'name' => 'wpDraftID', 'value' => $wgRequest->getInt('draft', '')));
$buttons['savedraft'] .= Xml::element('input', array('type' => 'hidden', 'name' => 'wpDraftTitle', 'value' => $wgTitle->getPrefixedText()));
$buttons['savedraft'] .= Xml::element('input', array('type' => 'hidden', 'name' => 'wpMsgSaved', 'value' => wfMsg('drafts-save-saved')));
$buttons['savedraft'] .= Xml::element('input', array('type' => 'hidden', 'name' => 'wpMsgSaveDraft', 'value' => wfMsg('drafts-save-save')));
$buttons['savedraft'] .= Xml::element('input', array('type' => 'hidden', 'name' => 'wpMsgError', 'value' => wfMsg('drafts-save-error')));
}
// Continue
return true;
}