當前位置: 首頁>>代碼示例>>PHP>>正文


PHP KTUtil::formatPlainText方法代碼示例

本文整理匯總了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);
 }
開發者ID:sfsergey,項目名稱:knowledgetree,代碼行數:46,代碼來源:KTDiscussion.php


注:本文中的KTUtil::formatPlainText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。