本文整理汇总了PHP中XenForo_Helper_String::findPhraseNamesFromStringSimple方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Helper_String::findPhraseNamesFromStringSimple方法的具体用法?PHP XenForo_Helper_String::findPhraseNamesFromStringSimple怎么用?PHP XenForo_Helper_String::findPhraseNamesFromStringSimple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Helper_String
的用法示例。
在下文中一共展示了XenForo_Helper_String::findPhraseNamesFromStringSimple方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _sendEmail
protected function _sendEmail(array $email, array $user, Zend_Mail_Transport_Abstract $transport)
{
if (!$user['email']) {
return;
}
$phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($email['email_title'] . $email['email_body']);
/** @var XenForo_Model_Phrase $phraseModel */
$phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
$phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']);
foreach ($phraseTitles as $search => $phraseTitle) {
if (isset($phrases[$phraseTitle])) {
$email['email_title'] = str_replace($search, $phrases[$phraseTitle], $email['email_title']);
$email['email_body'] = str_replace($search, $phrases[$phraseTitle], $email['email_body']);
}
}
$mailObj = new Zend_Mail('utf-8');
$mailObj->setSubject($email['email_title'])->addTo($user['email'], $user['username'])->setFrom($email['from_email'], $email['from_name']);
$options = XenForo_Application::getOptions();
$bounceEmailAddress = $options->bounceEmailAddress;
if (!$bounceEmailAddress) {
$bounceEmailAddress = $options->defaultEmailAddress;
}
$toEmail = $user['email'];
$bounceHmac = substr(hash_hmac('md5', $toEmail, XenForo_Application::getConfig()->globalSalt), 0, 8);
$mailObj->addHeader('X-To-Validate', "{$bounceHmac}+{$toEmail}");
if ($options->enableVerp) {
$verpValue = str_replace('@', '=', $toEmail);
$bounceEmailAddress = str_replace('@', "+{$bounceHmac}+{$verpValue}@", $bounceEmailAddress);
}
$mailObj->setReturnPath($bounceEmailAddress);
if ($email['email_format'] == 'html') {
$replacements = array('{name}' => htmlspecialchars($user['username']), '{email}' => htmlspecialchars($user['email']), '{id}' => $user['user_id']);
$email['email_body'] = strtr($email['email_body'], $replacements);
$text = trim(htmlspecialchars_decode(strip_tags($email['email_body'])));
$mailObj->setBodyHtml($email['email_body'])->setBodyText($text);
} else {
$replacements = array('{name}' => $user['username'], '{email}' => $user['email'], '{id}' => $user['user_id']);
$email['email_body'] = strtr($email['email_body'], $replacements);
$mailObj->setBodyText($email['email_body']);
}
if (!$mailObj->getMessageId()) {
$mailObj->setMessageId();
}
$thisTransport = XenForo_Mail::getFinalTransportForMail($mailObj, $transport);
try {
$mailObj->send($thisTransport);
} catch (Exception $e) {
if (method_exists($thisTransport, 'resetConnection')) {
XenForo_Error::logException($e, false, "Email to {$user['email']} failed: ");
$thisTransport->resetConnection();
try {
$mailObj->send($thisTransport);
} catch (Exception $e) {
XenForo_Error::logException($e, false, "Email to {$user['email']} failed (after retry): ");
}
} else {
XenForo_Error::logException($e, false, "Email to {$user['email']} failed: ");
}
}
}
示例2: _sendAlert
protected function _sendAlert(array $alert, array $replacements, array $fromUser, array $user)
{
$body = $alert['alert_body'];
/** @var XenForo_Model_Phrase $phraseModel */
$phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
$phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($body);
$phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']);
foreach ($phraseTitles as $search => $phraseTitle) {
if (isset($phrases[$phraseTitle])) {
$body = str_replace($search, $phrases[$phraseTitle], $body);
}
}
$replacements = array_merge($replacements, array('{name}' => htmlspecialchars($user['username']), '{id}' => $user['user_id']));
$alert['alert_text'] = strtr($body, $replacements);
XenForo_Model_Alert::alert($user['user_id'], $fromUser['user_id'], $fromUser['username'], 'user', $user['user_id'], 'from_admin', $alert);
}
示例3: _sendMessage
protected function _sendMessage(array $conversation, array $conversationUser, array $user)
{
$title = $conversation['message_title'];
$body = $conversation['message_body'];
$phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($title . $body);
/** @var XenForo_Model_Phrase $phraseModel */
$phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
$phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']);
foreach ($phraseTitles as $search => $phraseTitle) {
if (isset($phrases[$phraseTitle])) {
$title = str_replace($search, $phrases[$phraseTitle], $title);
$body = str_replace($search, $phrases[$phraseTitle], $body);
}
}
$replacements = array('{name}' => $user['username'], '{id}' => $user['user_id']);
$body = strtr($body, $replacements);
/* @var $conversationModel XenForo_Model_Conversation */
$conversationModel = XenForo_Model::create('XenForo_Model_Conversation');
/** @var XenForo_DataWriter_ConversationMaster $conversationDw */
$conversationDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster');
$conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_ACTION_USER, $conversationUser);
$conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_MESSAGE, $body);
$conversationDw->set('user_id', $conversationUser['user_id']);
$conversationDw->set('username', $conversationUser['username']);
$conversationDw->set('title', utf8_substr($title, 0, 100));
$conversationDw->set('open_invite', $conversation['open_invite']);
$conversationDw->set('conversation_open', $conversation['conversation_locked'] ? 0 : 1);
$conversationDw->addRecipientUserIds(array($user['user_id']));
// bypasses permissions
$messageDw = $conversationDw->getFirstMessageDw();
$messageDw->set('message', $body);
$conversationDw->save();
$conversationModel->markConversationAsRead($conversationDw->get('conversation_id'), $conversationUser['user_id'], XenForo_Application::$time);
if ($conversation['delete_type']) {
$conversationModel->deleteConversationForUser($conversationDw->get('conversation_id'), $conversationUser['user_id'], $conversation['delete_type']);
}
}
示例4: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('start' => 0, 'count' => 0, 'criteria' => null, 'userIds' => null, 'conversation' => array()), $data);
$s = microtime(true);
/* @var $userModel XenForo_Model_User */
/* @var $conversationModel XenForo_Model_Conversation */
$userModel = XenForo_Model::create('XenForo_Model_User');
$conversationModel = XenForo_Model::create('XenForo_Model_Conversation');
if (is_array($data['criteria'])) {
$userIds = $userModel->getUserIds($data['criteria'], $data['start'], 1000);
} else {
if (is_array($data['userIds'])) {
$userIds = $data['userIds'];
} else {
$userIds = array();
}
}
if (!$userIds) {
return false;
}
$conversation = $data['conversation'];
$limitTime = $targetRunTime > 0;
foreach ($userIds as $key => $userId) {
$data['count']++;
$data['start'] = $userId;
unset($userIds[$key]);
$conversationUser = $userModel->getUserById($conversation['user_id']);
if ($userId == $conversationUser['user_id']) {
continue;
}
$user = $userModel->getUserById($userId);
$title = $conversation['message_title'];
$body = $conversation['message_body'];
$phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($title . $body);
/** @var XenForo_Model_Phrase $phraseModel */
$phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
$phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']);
foreach ($phraseTitles as $search => $phraseTitle) {
if (isset($phrases[$phraseTitle])) {
$title = str_replace($search, $phrases[$phraseTitle], $title);
$body = str_replace($search, $phrases[$phraseTitle], $body);
}
}
$replacements = array('{name}' => $user['username'], '{id}' => $user['user_id']);
$body = strtr($body, $replacements);
$body = XenForo_Helper_String::autoLinkBbCode($body);
/** @var XenForo_DataWriter_ConversationMaster $conversationDw */
$conversationDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster');
$conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_ACTION_USER, $conversationUser);
$conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_MESSAGE, $body);
$conversationDw->set('user_id', $conversationUser['user_id']);
$conversationDw->set('username', $conversationUser['username']);
$conversationDw->set('title', utf8_substr($title, 0, 100));
$conversationDw->set('open_invite', $conversation['open_invite']);
$conversationDw->set('conversation_open', $conversation['conversation_locked'] ? 0 : 1);
$conversationDw->addRecipientUserIds(array($user['user_id']));
// bypasses permissions
$messageDw = $conversationDw->getFirstMessageDw();
$messageDw->set('message', $body);
$conversationDw->save();
$conversationModel->markConversationAsRead($conversationDw->get('conversation_id'), $conversationUser['user_id'], XenForo_Application::$time);
if ($conversation['delete_type']) {
$conversationModel->deleteConversationForUser($conversationDw->get('conversation_id'), $conversationUser['user_id'], $conversation['delete_type']);
}
if ($limitTime && microtime(true) - $s > $targetRunTime) {
break;
}
}
if (is_array($data['userIds'])) {
$data['userIds'] = $userIds;
}
$actionPhrase = new XenForo_Phrase('messaging');
$typePhrase = new XenForo_Phrase('users');
$status = sprintf('%s... %s (%d)', $actionPhrase, $typePhrase, $data['count']);
return $data;
}
示例5: _sendWelcomeEmail
protected function _sendWelcomeEmail(array $user, array $option)
{
$fromName = $option['emailFromName'];
$fromEmail = $option['emailFromEmail'];
$title = $option['emailTitle'];
$format = $option['emailFormat'];
$body = $option['emailBody'];
$phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($title . $body);
/** @var XenForo_Model_Phrase $phraseModel */
$phraseModel = $this->getModelFromCache('XenForo_Model_Phrase');
$phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']);
foreach ($phraseTitles as $search => $phraseTitle) {
if (isset($phrases[$phraseTitle])) {
$title = str_replace($search, $phrases[$phraseTitle], $title);
$body = str_replace($search, $phrases[$phraseTitle], $body);
}
}
if ($format == 'html') {
$tokens = array('{name}' => htmlspecialchars($user['username']), '{email}' => htmlspecialchars($user['email']), '{id}' => $user['user_id']);
$body = strtr($body, $tokens);
$text = trim(htmlspecialchars_decode(strip_tags($body)));
} else {
$tokens = array('{name}' => $user['username'], '{email}' => $user['email'], '{id}' => $user['user_id']);
$text = strtr($body, $tokens);
$body = nl2br(htmlspecialchars($text));
}
$mail = XenForo_Mail::create('welcome_email', array('title' => $title, 'htmlBody' => $body, 'textBody' => $text), $user['language_id']);
return $mail->queue($user['email'], $user['username'], array(), $fromEmail, $fromName);
}
示例6: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('start' => 0, 'count' => 0, 'criteria' => null, 'userIds' => null, 'alert' => array()), $data);
$s = microtime(true);
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
/** @var XenForo_Model_Phrase $phraseModel */
$phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
if (is_array($data['criteria'])) {
$userIds = $userModel->getUserIds($data['criteria'], $data['start'], 1000);
} else {
if (is_array($data['userIds'])) {
$userIds = $data['userIds'];
} else {
$userIds = array();
}
}
if (!$userIds) {
return false;
}
$replacements = array();
$alert = $data['alert'];
if ($alert['link_url']) {
$link = '<a href="' . $alert['link_url'] . '" class="PopupItemLink">' . ($alert['link_title'] ? $alert['link_title'] : $alert['link_url']) . '</a>';
$replacements['{link}'] = $link;
if (strpos($alert['alert_body'], '{link}') === false) {
$alert['alert_body'] .= ' {link}';
}
}
$limitTime = $targetRunTime > 0;
foreach ($userIds as $key => $userId) {
$data['count']++;
$data['start'] = $userId;
unset($userIds[$key]);
$user = $userModel->getUserById($userId);
$body = $alert['alert_body'];
$phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($body);
$phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']);
foreach ($phraseTitles as $search => $phraseTitle) {
if (isset($phrases[$phraseTitle])) {
$body = str_replace($search, $phrases[$phraseTitle], $body);
}
}
$replacements = array_merge($replacements, array('{name}' => htmlspecialchars($user['username']), '{id}' => $user['user_id']));
$alert['alert_text'] = strtr($body, $replacements);
if ($alert['user_id']) {
$fromUser = $userModel->getUserById($alert['user_id']);
} else {
$fromUser = array('user_id' => 0, 'username' => '');
}
XenForo_Model_Alert::alert($user['user_id'], $fromUser['user_id'], $fromUser['username'], 'user', $user['user_id'], 'from_admin', $alert);
if ($limitTime && microtime(true) - $s > $targetRunTime) {
break;
}
}
if (is_array($data['userIds'])) {
$data['userIds'] = $userIds;
}
$actionPhrase = new XenForo_Phrase('alerting');
$typePhrase = new XenForo_Phrase('users');
$status = sprintf('%s... %s (%d)', $actionPhrase, $typePhrase, $data['count']);
return $data;
}
示例7: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('start' => 0, 'count' => 0, 'criteria' => null, 'userIds' => null, 'email' => array()), $data);
if (!XenForo_Application::get('config')->enableMail) {
return false;
}
$s = microtime(true);
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
if (is_array($data['criteria'])) {
$userIds = $userModel->getUserIds($data['criteria'], $data['start'], 1000);
} else {
if (is_array($data['userIds'])) {
$userIds = $data['userIds'];
} else {
$userIds = array();
}
}
if (!$userIds) {
return false;
}
$options = XenForo_Application::getOptions();
$email = $data['email'];
$transport = XenForo_Mail::getTransport();
$limitTime = $targetRunTime > 0;
foreach ($userIds as $key => $userId) {
$data['count']++;
$data['start'] = $userId;
unset($userIds[$key]);
$user = $userModel->getUserById($userId);
if (!$user['email']) {
continue;
}
$phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($email['email_title'] . $email['email_body']);
/** @var XenForo_Model_Phrase $phraseModel */
$phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
$phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']);
foreach ($phraseTitles as $search => $phraseTitle) {
if (isset($phrases[$phraseTitle])) {
$email['email_title'] = str_replace($search, $phrases[$phraseTitle], $email['email_title']);
$email['email_body'] = str_replace($search, $phrases[$phraseTitle], $email['email_body']);
}
}
$mailObj = new Zend_Mail('utf-8');
$mailObj->setSubject($email['email_title'])->addTo($user['email'], $user['username'])->setFrom($email['from_email'], $email['from_name']);
$bounceEmailAddress = $options->bounceEmailAddress;
if (!$bounceEmailAddress) {
$bounceEmailAddress = $options->defaultEmailAddress;
}
$toEmail = $user['email'];
$bounceHmac = substr(hash_hmac('md5', $toEmail, XenForo_Application::getConfig()->globalSalt), 0, 8);
$mailObj->addHeader('X-To-Validate', "{$bounceHmac}+{$toEmail}");
if ($options->enableVerp) {
$verpValue = str_replace('@', '=', $toEmail);
$bounceEmailAddress = str_replace('@', "+{$bounceHmac}+{$verpValue}@", $bounceEmailAddress);
}
$mailObj->setReturnPath($bounceEmailAddress);
if ($email['email_format'] == 'html') {
$replacements = array('{name}' => htmlspecialchars($user['username']), '{email}' => htmlspecialchars($user['email']), '{id}' => $user['user_id']);
$email['email_body'] = strtr($email['email_body'], $replacements);
$text = trim(htmlspecialchars_decode(strip_tags($email['email_body'])));
$mailObj->setBodyHtml($email['email_body'])->setBodyText($text);
} else {
$replacements = array('{name}' => $user['username'], '{email}' => $user['email'], '{id}' => $user['user_id']);
$email['email_body'] = strtr($email['email_body'], $replacements);
$mailObj->setBodyText($email['email_body']);
}
if (!$mailObj->getMessageId()) {
$mailObj->setMessageId();
}
$thisTransport = XenForo_Mail::getFinalTransportForMail($mailObj, $transport);
try {
$mailObj->send($thisTransport);
} catch (Exception $e) {
XenForo_Error::logException($e, false, "Email to {$user['email']} failed: ");
continue;
}
if ($limitTime && microtime(true) - $s > $targetRunTime) {
break;
}
}
if (is_array($data['userIds'])) {
$data['userIds'] = $userIds;
}
$actionPhrase = new XenForo_Phrase('emailing');
$typePhrase = new XenForo_Phrase('users');
$status = sprintf('%s... %s (%d)', $actionPhrase, $typePhrase, $data['count']);
return $data;
}