本文整理汇总了PHP中KTUtil::formatPlainText方法的典型用法代码示例。如果您正苦于以下问题:PHP KTUtil::formatPlainText方法的具体用法?PHP KTUtil::formatPlainText怎么用?PHP KTUtil::formatPlainText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTUtil
的用法示例。
在下文中一共展示了KTUtil::formatPlainText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_postreply
function do_postreply()
{
$aErrorOptions = array('redirect_to' => array('main', sprintf('fDocumentId=%d', $this->oDocument->getId())));
$iThreadId = KTUtil::arrayGet($_REQUEST, 'fThreadId');
$oThread = DiscussionThread::get($iThreadId);
$this->oValidator->notError($oThread, $aErrorOptions);
$aErrorOptions = array('redirect_to' => array('viewthread', sprintf('fDocumentId=%d&fThreadId=%d', $this->oDocument->getId(), $oThread->getId())));
$aErrorOptions['message'] = _kt("No subject provided");
$sSubject = KTUtil::arrayGet($_REQUEST, 'subject');
$sSubject = $this->oValidator->validateString($sSubject, $aErrorOptions);
$aErrorOptions['message'] = _kt("No body provided");
$sBody = KTUtil::arrayGet($_REQUEST, 'body');
$sBody = $this->oValidator->validateString($sBody, $aErrorOptions);
// Start the transaction comment creation
$this->startTransaction();
// Create comment
$oComment = DiscussionComment::createFromArray(array('threadid' => $oThread->getId(), 'userid' => $this->oUser->getId(), 'subject' => $sSubject, 'body' => KTUtil::formatPlainText($sBody)));
$aErrorOptions['message'] = _kt("There was an error adding the comment to the thread");
$this->oValidator->notError($oComment, $aErrorOptions);
// Update thread
$oThread->setLastCommentId($oComment->getId());
$oThread->incrementNumberOfReplies();
$res = $oThread->update();
// add to searchable_text.
$sTable = KTUtil::getTableName('comment_searchable_text');
$aSearch = array('comment_id' => $oComment->getId(), 'document_id' => $this->oDocument->getId(), 'body' => sprintf("%s %s", KTUtil::formatPlainText($sBody), $sSubject));
DBUtil::autoInsert($sTable, $aSearch, array('noid' => true));
$aErrorOptions['message'] = _kt("There was an error updating the thread with the new comment");
$this->oValidator->notError($res, $aErrorOptions);
$oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
$aTriggers = $oKTTriggerRegistry->getTriggers('discussion', 'postValidate');
foreach ($aTriggers as $aTrigger) {
$sTrigger = $aTrigger[0];
$oTrigger = new $sTrigger();
$aInfo = array("document" => $this->oDocument, "comment" => $oComment);
$oTrigger->setInfo($aInfo);
$ret = $oTrigger->postValidate();
if (PEAR::isError($ret)) {
$this->oValidator->notError($res, $aErrorOptions);
}
}
// Thread and comment created correctly, commit to database
$this->commitTransaction();
$this->successRedirectTo('viewThread', _kt("Reply posted"), sprintf('fDocumentId=%d&fThreadId=%d', $this->oDocument->getId(), $oThread->getId()));
exit(0);
}