本文整理汇总了PHP中Message::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::parse方法的具体用法?PHP Message::parse怎么用?PHP Message::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::parse方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: friends_timeline
public static function friends_timeline()
{
$messages = array();
// foreach(R(new TwitterAPI())->friends_timeline() as $message) $messages[] = Message::parse($message);
foreach (R(new WassrAPI())->friends_timeline() as $message) {
$messages[] = Message::parse($message);
}
$messages = omerge($messages, "key");
rosort($messages, "created_at");
return $messages;
}
示例2: getHtml
/**
* Fully parse the text from wikitext to HTML.
*
* @return string Parsed HTML.
*/
public function getHtml()
{
return $this->mMessage->parse();
}
示例3: wrap
/**
* Wrap a message in HTML with a class.
*
* @param Message $msg
* @param string $class
* @param string $tag
* @return string
*/
private static function wrap(Message $msg, $class, $tag = 'span')
{
return Html::rawElement($tag, array('class' => $class), $msg->parse());
}
示例4: showSubpageList
/**
* @param Message|null $error
*/
protected function showSubpageList($error = null)
{
$out = $this->getOutput();
if ($error) {
$out->addHTML($error->parse());
}
$groupedRequests = [];
foreach ($this->authRequests as $req) {
$info = $req->describeCredentials();
$groupedRequests[(string) $info['provider']][] = $req;
}
$out->addHTML(Html::openElement('dl'));
foreach ($groupedRequests as $group => $members) {
$out->addHTML(Html::element('dt', [], $group));
foreach ($members as $req) {
/** @var AuthenticationRequest $req */
$info = $req->describeCredentials();
$out->addHTML(Html::rawElement('dd', [], Linker::link($this->getPageTitle($req->getUniqueId()), htmlspecialchars($info['account'], ENT_QUOTES))));
}
}
$out->addHTML(Html::closeElement('dl'));
}
示例5: readCallbacks
function readCallbacks($timeout = 2000)
{
if (!$this->socket || $this->protocol == 0) {
throw new Exception('transport error - Client not initialized', -32300);
}
if ($this->protocol == 1) {
return false;
}
// flo: moved to end
//$something_received = count($this->cb_message)>0;
$contents = '';
$contents_length = 0;
@stream_set_timeout($this->socket, 0, 10000);
// timeout 10 ms (to read available data)
// (assignment in arguments is forbidden since php 5.1.1)
$read = array($this->socket);
$write = NULL;
$except = NULL;
$nb = false;
try {
$nb = @stream_select($read, $write, $except, 0, $timeout);
} catch (\Exception $e) {
if (strpos($e->getMessage(), 'Invalid CRT') !== false) {
$nb = true;
} elseif (strpos($e->getMessage(), 'Interrupted system call') !== false) {
return;
} else {
throw $e;
}
}
// workaround for stream_select bug with amd64
if ($nb !== false) {
$nb = count($read);
}
while ($nb !== false && $nb > 0) {
$timeout = 0;
// we don't want to wait for the full time again, just flush the available data
$size = 0;
$recvhandle = 0;
// Get result
$contents = fread($this->socket, 8);
if (strlen($contents) == 0) {
throw new Exception('transport error - connection interrupted!', -32700);
}
$array_result = unpack('Vsize/Vhandle', $contents);
$size = $array_result['size'];
$recvhandle = $array_result['handle'];
if ($recvhandle == 0 || $size == 0) {
throw new Exception('transport error - connection interrupted!', -32700);
}
if ($size > SIZE_MAX) {
throw new Exception("transport error - answer too big ({$size})", -32700);
}
self::$received += $size;
$contents = '';
$contents_length = 0;
while ($contents_length < $size) {
$contents .= fread($this->socket, $size - $contents_length);
$contents_length = strlen($contents);
}
if (($recvhandle & 2147483648.0) == 0) {
// this is a callback. handle= $recvhandle, xml-rpc= $contents
//echo 'CALLBACK('.$contents_length.')[ '.$contents.' ]' . LF;
$new_cb_message = new Message($contents);
if ($new_cb_message->parse() && $new_cb_message->messageType != 'fault') {
array_push($this->cb_message, array($new_cb_message->methodName, $new_cb_message->params));
}
// flo: moved to end ...
// $something_received = true;
}
// (assignment in arguments is forbidden since php 5.1.1)
$read = array($this->socket);
$write = NULL;
$except = NULL;
try {
$nb = @stream_select($read, $write, $except, 0, $timeout);
} catch (\Exception $e) {
if (strpos($e->getMessage(), 'Invalid CRT') !== false) {
$nb = true;
} else {
throw $e;
}
}
// workaround for stream_select bug with amd64
if ($nb !== false) {
$nb = count($read);
}
}
return !empty($this->cb_message);
}
示例6: testSerialization
/**
* @covers Message::serialize
* @covers Message::unserialize
*/
public function testSerialization()
{
$msg = new Message('parentheses');
$msg->rawParams('<a>foo</a>');
$msg->title(Title::newFromText('Testing'));
$this->assertEquals('(<a>foo</a>)', $msg->parse(), 'Sanity check');
$msg = unserialize(serialize($msg));
$this->assertEquals('(<a>foo</a>)', $msg->parse());
$title = TestingAccessWrapper::newFromObject($msg)->title;
$this->assertInstanceOf('Title', $title);
$this->assertEquals('Testing', $title->getFullText());
$msg = new Message('mainpage');
$msg->inLanguage('de');
$this->assertEquals('Hauptseite', $msg->plain(), 'Sanity check');
$msg = unserialize(serialize($msg));
$this->assertEquals('Hauptseite', $msg->plain());
}
示例7: showSuccess
/**
* Show a message in a success box.
*
* @since 0.1
*
* @param Message $message
*/
protected function showSuccess(Message $message)
{
$this->getOutput()->addHTML('<div class="successbox"><strong><p>' . $message->parse() . '</p></strong></div>' . '<hr style="display: block; clear: both; visibility: hidden;" />');
}
示例8: actionSendMessage
public function actionSendMessage()
{
if (isset($_POST['send'])) {
if ($this->me == "guest") {
header("location: signin");
exit;
}
if (!isset($_POST['to']) || $_POST['to'] == "") {
$_SESSION['error'] = "No recipient selected";
header("location: " . $_SERVER['HTTP_REFERER']);
exit;
}
$message = new Message();
$message->parse($_POST);
$message->setReceiver($_POST['to']);
$message->setSender($this->me->userID);
if (trim($_POST['message']) == "") {
$_SESSION['error'] = "Cannot send blank message";
header("location: " . $_SERVER['HTTP_REFERER']);
exit;
}
if ($message->create() !== true) {
$_SESSION['error'] = "Your message could not be sent. Please try later";
}
header("location: " . $_SERVER['HTTP_REFERER']);
exit;
}
}
示例9: showIntro
/**
* Show all applicable editing introductions
*
* - new article intro
* - custom intro (editintro=Foo in URL)
* - talk page intro
* - main page educational note (BugId:51755)
*
* Handle preloads (BugId:5652)
*/
protected function showIntro()
{
// Code based on EditPage.php
if (!$this->mTitle->exists()) {
if ($this->app->wg->User->isLoggedIn()) {
$msgName = 'newarticletext';
$class = 'mw-newarticletext';
} else {
$msgName = 'newarticletextanon';
$class = 'mw-newarticletextanon';
}
// Give a notice if the user is editing a deleted/moved page...
$titleText = $this->mTitle->getPrefixedText();
if (!empty($titleText)) {
$out = new OutputPage();
$resultRowsNum = LogEventsList::showLogExtract($out, array('delete', 'move'), $titleText, '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('recreate-moveddeleted-warn')));
}
$msgParams = [];
// check for empty message (BugId:6923)
if (!empty($msgName)) {
$message = wfMessage($msgName, $msgParams);
$messageParsed = $message->parse();
if (!$message->isBlank() && trim(strip_tags($messageParsed)) != '') {
$this->mEditPagePreloads['EditPageIntro'] = ['content' => $messageParsed, 'class' => $class];
}
}
}
wfRunHooks('EditPageLayoutShowIntro', [&$this->mEditPagePreloads, $this->mTitle]);
// custom intro
$this->showCustomIntro();
// Intro text for talk pages (BugId:7092)
if ($this->mTitle->isTalkPage()) {
$this->mEditPagePreloads['EditPageTalkPageIntro'] = array('content' => wfmsgExt('talkpagetext', array('parse')), 'class' => 'mw-talkpagetext');
} elseif ($this->mTitle->isMainPage() && !$this->mTitle->isProtected() && !$this->userDismissedEduNote()) {
//if this is an unprotected main page and user hasn't seen the main page educational notice -- show it :)
/** @var $notice EditPageNotice */
$msg = wfMsgExt('mainpagewarning-notice', array('parse'));
$notice = new EditPageNotice($msg, 'MainPageEduNote');
$this->helper->addJsVariable('mainPageEduNoteHash', $notice->getHash());
$this->addEditNotice($notice);
}
// Edit notice (BugId:7616)
$editnotice_ns_key = 'editnotice-' . $this->mTitle->getNamespace();
$editnotice_ns_msg = new Message($editnotice_ns_key);
if (!$editnotice_ns_msg->isDisabled()) {
$this->mEditPagePreloads['EditPageEditNotice'] = array('content' => $editnotice_ns_msg->parse(), 'class' => 'mw-editnotice');
}
}
示例10: showWarning
/**
* Show a message in a warning box.
*
* @since 0.1
*
* @param Message $message
*/
protected function showWarning(Message $message)
{
$this->getOutput()->addHTML('<p class="visualClear warningbox">' . $message->parse() . '</p>' . '<hr style="display: block; clear: both; visibility: hidden;" />');
}
示例11: header
if ($me == "guest") {
header("location: signin");
exit;
}
if (!isset($_GET['with'])) {
$_SESSION['error'] = "No recipient selected";
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
if (trim($_POST['message']) == "") {
$_SESSION['error'] = "Cannot send blank message";
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
$message = new Message();
$message->parse($_POST);
$message->setReceiver($_GET['with']);
$message->setSender($me->userID);
if ($message->create() !== true) {
$_SESSION['error'] = "Failed to send message";
var_dump($message->create());
}
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
$pageTitle = "Messages";
$limit = 6;
$partner = isset($_GET['with']) ? $_GET['with'] : false;
if ($partner != false) {
$partner = User::getUser($partner);
$pageNum = isset($_GET['aftercursor']) ? $_GET['aftercursor'] : 1;