当前位置: 首页>>代码示例>>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;未经允许,请勿转载。