本文整理汇总了PHP中Thread::validateSubject方法的典型用法代码示例。如果您正苦于以下问题:PHP Thread::validateSubject方法的具体用法?PHP Thread::validateSubject怎么用?PHP Thread::validateSubject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread::validateSubject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateSubject
function validateSubject($target)
{
if (!$target) {
return wfMsgExt('lqt_split_nosubject', 'parseinline');
}
$title = null;
$article = $this->mThread->article();
$ok = Thread::validateSubject($target, $title, null, $article);
if (!$ok) {
return wfMsgExt('lqt_split_badsubject', 'parseinline');
}
return true;
}
示例2: showPostEditingForm
/**
* @param $thread Thread
*/
function showPostEditingForm($thread)
{
$submitted_nonce = $this->request->getVal('lqt_nonce');
$nonce_key = wfMemcKey('lqt-nonce', $submitted_nonce, $this->user->getName());
if (!$this->handleNonce($submitted_nonce, $nonce_key)) {
return;
}
$html = Xml::openElement('div', array('class' => 'lqt-edit-form'));
$this->output->addHTML($html);
$subject = $this->request->getVal('lqt_subject_field', '');
if (!$subject) {
$subject = $thread->subject();
}
$t = null;
$subjectOk = Thread::validateSubject($subject, $t, $thread->superthread(), $this->article);
if (!$subjectOk) {
$subject = false;
}
$article = $thread->root();
$talkpage = $thread->article();
Hooks::run('LiquidThreadsEditFormContent', array($thread, &$article, $talkpage));
LqtHooks::$editTalkpage = $talkpage;
LqtHooks::$editArticle = $article;
LqtHooks::$editThread = $thread;
LqtHooks::$editType = 'edit';
LqtHooks::$editAppliesTo = $thread;
$e = new EditPage($article);
global $wgRequest;
// Quietly force a preview if no subject has been specified.
if (!$subjectOk) {
// Dirty hack to prevent saving from going ahead
$wgRequest->setVal('wpPreview', true);
if ($this->request->wasPosted()) {
$e->editFormPageTop .= Xml::tags('div', array('class' => 'error'), wfMessage('lqt_invalid_subject')->parse());
}
}
// Add an offset so it works if it's on the wrong page.
$dbr = wfGetDB(DB_SLAVE);
$offset = wfTimestamp(TS_UNIX, $thread->topmostThread()->sortkey());
$offset++;
$offset = $dbr->timestamp($offset);
$e->suppressIntro = true;
$e->editFormTextBeforeContent .= $this->perpetuate('lqt_method', 'hidden') . $this->perpetuate('lqt_operand', 'hidden') . Html::hidden('lqt_nonce', MWCryptRand::generateHex(32)) . Html::hidden('offset', $offset);
list($signatureEditor, $signatureHTML) = $this->getSignatureEditor($thread);
$e->editFormTextAfterContent .= $signatureEditor;
$e->previewTextAfterContent .= Xml::tags('p', null, $signatureHTML);
if ($thread->isTopmostThread()) {
$e->editFormTextBeforeContent .= $this->getSubjectEditor($thread->subject(), $subject);
}
$e->edit();
if ($e->didSave) {
$bump = !$this->request->getCheck('wpBumpThread') || $this->request->getBool('wpBumpThread');
$signature = $this->request->getVal('wpLqtSignature', null);
LqtView::editMetadataUpdates(array('thread' => $thread, 'text' => $e->textbox1, 'summary' => $e->summary, 'bump' => $bump, 'subject' => $subject, 'signature' => $signature, 'root' => $article));
if ($submitted_nonce && $nonce_key) {
global $wgMemc;
$wgMemc->set($nonce_key, 1, 3600);
}
}
if ($this->output->getRedirect() != '') {
$redirectTitle = clone $talkpage->getTitle();
$redirectTitle->setFragment('#' . $this->anchorName($thread));
$this->output->redirect($this->title->getLocalURL());
}
$this->output->addHTML('</div>');
}
示例3: actionSetSubject
public function actionSetSubject($threads, $params)
{
// Validate thread parameter
if (count($threads) > 1) {
$this->dieUsage('You may only change the subject of one thread at a time', 'too-many-threads');
} elseif (count($threads) < 1) {
$this->dieUsage('You must specify a thread to change the subject of', 'no-specified-threads');
}
$thread = array_pop($threads);
$errors = $thread->title()->getUserPermissionsErrors('edit', $this->getUser());
if ($errors) {
// We don't care about multiple errors, just report one of them
$this->dieUsageMsg(reset($errors));
}
// Validate subject
if (empty($params['subject'])) {
$this->dieUsageMsg(array('missingparam', 'subject'));
}
$talkpage = $thread->article();
$subject = $params['subject'];
$title = null;
$subjectOk = Thread::validateSubject($subject, $title, null, $talkpage);
if (!$subjectOk) {
$this->dieUsage('The subject you specified is not valid', 'invalid-subject');
}
$reason = null;
if (isset($params['reason'])) {
$reason = $params['reason'];
}
if ($thread->dbVersion->subject() !== $subject) {
$thread->setSubject($subject);
$thread->commitRevision(Threads::CHANGE_EDITED_SUBJECT, $thread, $reason);
}
$result = array('action' => 'setsubject', 'result' => 'success', 'thread-id' => $thread->id(), 'thread-title' => $thread->title()->getPrefixedText(), 'new-subject' => $subject);
$result = array('thread' => $result);
$this->getResult()->addValue(null, $this->getModuleName(), $result);
}