本文整理汇总了PHP中KunenaHtmlParser::stripBBCode方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaHtmlParser::stripBBCode方法的具体用法?PHP KunenaHtmlParser::stripBBCode怎么用?PHP KunenaHtmlParser::stripBBCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaHtmlParser
的用法示例。
在下文中一共展示了KunenaHtmlParser::stripBBCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
echo $this->getIcon('ktopicsticky', JText::_('MOD_KUNENALATEST_STICKY_TOPIC'));
}
if ($this->params->get('sh_locked') && $this->topic->locked) {
echo $this->getIcon('ktopiclocked', JText::_('COM_KUNENA_GEN_LOCKED_TOPIC'));
}
if ($this->params->get('sh_favorite') && $this->topic->getUserTopic()->favorite) {
echo $this->getIcon('kfavoritestar', JText::_('COM_KUNENA_FAVORITE'));
}
?>
</li>
<?php
if ($this->params->get('sh_firstcontentcharacter')) {
?>
<li class="klatest-preview-content"><?php
echo KunenaHtmlParser::stripBBCode($this->topic->last_post_message, $this->params->get('lengthcontentcharacters'));
?>
</li>
<?php
}
?>
<?php
if ($this->params->get('sh_category')) {
?>
<li class="klatest-cat"><?php
echo JText::_('MOD_KUNENALATEST_IN_CATEGORY') . ' ' . $this->categoryLink;
?>
</li>
<?php
}
示例2: _prepareDocument
protected function _prepareDocument($type)
{
if ($type == 'default') {
$this->headerText = JText::_('COM_KUNENA_MENU_LATEST_DESC');
$this->title = JText::_('COM_KUNENA_ALL_DISCUSSIONS');
$page = intval($this->state->get('list.start') / $this->state->get('list.limit')) + 1;
$pages = intval(($this->total - 1) / $this->state->get('list.limit')) + 1;
$title = JText::sprintf($this->topic->subject) . " ({$page}/{$pages})";
$this->setTitle($title);
// TODO: use real keywords, too
$keywords = $this->escape("{$this->topic->subject}, {$this->category->name}, {$this->category->getParent()->name}, {$this->config->board_title}");
$this->setKeywords($keywords);
// Create Meta Description form the content of the first message
// better for search results display but NOT for search ranking!
$description = KunenaHtmlParser::stripBBCode($this->topic->first_post_message, 182);
$description = preg_replace('/\\s+/', ' ', $description);
// remove newlines
$description = trim($description);
// Remove trailing spaces and beginning
if ($page) {
$description .= " ({$page}/{$pages})";
//avoid the "duplicate meta description" error in google webmaster tools
}
$this->setDescription($description);
} elseif ($type == 'create') {
$this->title = JText::_('COM_KUNENA_POST_NEW_TOPIC');
$this->setTitle($this->title);
// TODO: set keywords and description
} elseif ($type == 'reply') {
$this->title = JText::_('COM_KUNENA_POST_REPLY_TOPIC') . ' ' . $this->topic->subject;
$this->setTitle($this->title);
// TODO: set keywords and description
} elseif ($type == 'edit') {
$this->title = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
$this->setTitle($this->title);
// TODO: set keywords and description
}
}
示例3: createIndexerResult
protected function createIndexerResult($message)
{
// Convert the item to a result object.
$item = new FinderIndexerResult();
$item->id = $message->id;
$item->catid = $message->catid;
// Set title context.
$item->title = $message->subject;
// Build the necessary url, route, path and alias information.
$item->url = $this->getUrl($message->id, $this->extension, $this->layout);
$item->route = $item->url . '&Itemid=' . KunenaRoute::getItemId($item->url);
$item->path = FinderIndexerHelper::getContentPath($item->url);
//route);
$item->alias = KunenaRoute::stringURLSafe($message->subject);
// Set body context.
$item->body = KunenaHtmlParser::stripBBCode($message->message);
$item->summary = $item->body;
// Set other information.
$item->published = intval($message->hold == 0);
// TODO: add topic state
//$item->state = intval($message->getCategory()->published == 1);
$item->state = $item->published;
$item->language = '*';
// TODO: add access control
$item->access = $this->getAccessLevel($item);
// Set the item type.
$item->type_id = $this->type_id;
// Set the mime type.
$item->mime = $this->mime;
// Set the item layout.
$item->layout = $this->layout;
return $item;
}
示例4: attachEmailBody
/**
* @param JMail $mail
* @param int $subscription
* @param string $subject
* @param string $url
* @param bool $once
*
* @return string
*/
protected function attachEmailBody(JMail $mail, $subscription, $subject, $url, $once)
{
$layout = KunenaLayout::factory('Email/Subscription')->debug(false)->set('mail', $mail)->set('message', $this)->set('messageUrl', $url)->set('once', $once);
try {
$msg = trim($layout->render($subscription ? 'default' : 'moderator'));
} catch (Exception $e) {
// TODO: Deprecated in K4.0, remove in K5.0
// Clean up the message for review.
$message = KunenaHtmlParser::stripBBCode($this->message, 0, false);
$config = KunenaFactory::getConfig();
if ($subscription) {
$msg1 = $this->get('parent') ? JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION1') : JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION1_CAT');
$msg2 = $this->get('parent') ? JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION2') : JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION2_CAT');
} else {
$msg1 = JText::_('COM_KUNENA_POST_EMAIL_MOD1');
$msg2 = JText::_('COM_KUNENA_POST_EMAIL_MOD2');
}
$msg = $msg1 . " " . $config->board_title . "\n\n";
// DO NOT REMOVE EXTRA SPACE, JMailHelper::cleanBody() removes "Subject:" from the message body
$msg .= JText::_('COM_KUNENA_MESSAGE_SUBJECT') . " : " . $subject . "\n";
$msg .= JText::_('COM_KUNENA_CATEGORY') . " : " . $this->getCategory()->name . "\n";
$msg .= JText::_('COM_KUNENA_VIEW_POSTED') . " : " . $this->getAuthor()->getName('???', false) . "\n\n";
$msg .= "URL : {$url}\n\n";
if ($config->mailfull == 1) {
$msg .= JText::_('COM_KUNENA_MESSAGE') . " :\n-----\n";
$msg .= $message;
$msg .= "\n-----\n\n";
}
$msg .= $msg2 . "\n";
if ($subscription && $once) {
if ($this->parent) {
$msg .= JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_READ') . "\n";
} else {
$msg .= JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_SUBSCRIBE') . "\n";
}
}
$msg .= "\n";
$msg .= JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION3') . "\n";
}
$mail->setBody($msg);
}
示例5: if
<ul class="kposthead">
<li class="kposthead-replytitle"><h3><?php echo !isset($this->mesid) ? $this->escape($this->message->subject) : $this->escape($this->topic->subject) ?></h3></li>
</ul>
<div class="kmod-container">
<?php if (isset($this->message)) : ?>
<p><?php echo JText::_('COM_KUNENA_MODERATION_TITLE_SELECTED') ?>:</p>
<div class="kmoderate-message">
<h4><?php echo $this->message->subject ?></h4>
<div class="kmessage-timeby">
<span class="kmessage-time" title="<?php echo KunenaDate::getInstance($this->message->time)->toKunena('config_post_dateformat_hover'); ?>">
<?php echo JText::_('COM_KUNENA_POSTED_AT')?> <?php echo KunenaDate::getInstance($this->message->time)->toKunena('config_post_dateformat'); ?>
</span>
<span class="kmessage-by"><?php echo JText::_('COM_KUNENA_BY')?> <?php echo CKunenaLink::GetProfileLink($this->message->userid, $this->message->name) ?></span></div>
<div class="kmessage-avatar"><?php echo KunenaFactory::getAvatarIntegration()->getLink(KunenaFactory::getUser($this->message->userid)); ?></div>
<div class="kmessage-msgtext"><?php echo KunenaHtmlParser::stripBBCode ($this->message->message, 300) ?></div>
<div class="clr"></div>
</div>
<p>
<?php echo JText::_('COM_KUNENA_MODERATE_THIS_USER') ?>:
<strong><?php echo CKunenaLink::GetProfileLink($this->message->userid, $this->escape($this->message->name).' ('.$this->message->userid.')') ?></strong>
</p>
<ul>
<li><label for="kmoderate-mode-selected" class="hasTip" title="<?php echo JText::_('COM_KUNENA_MODERATION_MOVE_SELECTED') ?> :: "><input type="radio" value="0" checked="checked" name="mode" id="kmoderate-mode-selected"><?php echo JText::_('COM_KUNENA_MODERATION_MOVE_SELECTED') ?></label></li>
<li><label for="kmoderate-mode-newer" class="hasTip" title="<?php echo JText::sprintf ( 'COM_KUNENA_MODERATION_MOVE_NEWER', $this->escape($this->replies) ) ?> :: "><input type="radio" value="2" name="mode" id="kmoderate-mode-newer"><?php echo JText::sprintf ( 'COM_KUNENA_MODERATION_MOVE_NEWER', $this->escape($this->replies) ) ?></label></li>
</ul>
<br/>
<?php else: ?>
<label><?php echo JText::_('COM_KUNENA_MODERATION_DEST') ?>:</label>
示例6: report
function report()
{
if (!JRequest::checkToken()) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->redirectBack();
}
if (!$this->me->exists() || $this->config->reportmsg == 0) {
// Deny access if report feature has been disabled or user is guest
$this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ACCESS'), 'notice');
$this->redirectBack();
}
if (!$this->config->get('send_emails')) {
// Emails have been disabled
$this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_DISABLED'), 'notice');
$this->redirectBack();
}
jimport('joomla.mail.helper');
if (!$this->config->getEmail() || !JMailHelper::isEmailAddress($this->config->getEmail())) {
// Error: email address is invalid
$this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_INVALID'), 'error');
$this->redirectBack();
}
// Get target object for the report
if ($this->mesid) {
$message = $target = KunenaForumMessageHelper::get($this->mesid);
$topic = $target->getTopic();
} else {
$topic = $target = KunenaForumTopicHelper::get($this->id);
$message = KunenaForumMessageHelper::get($topic->first_post_id);
}
$messagetext = $message->message;
$baduser = KunenaFactory::getUser($message->userid);
if (!$target->authorise('read')) {
// Deny access if user cannot read target
$this->app->enqueueMessage($target->getError(), 'notice');
$this->redirectBack();
}
$category = $topic->getCategory();
$reason = JRequest::getString('reason');
$text = JRequest::getString('text');
if (empty($reason) && empty($text)) {
// Do nothing: empty subject or reason is empty
$this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_FORG0T_SUB_MES'));
$this->redirectBack();
} else {
$acl = KunenaAccess::getInstance();
$emailToList = $acl->getSubscribers($topic->category_id, $topic->id, false, true, false, $this->me->userid);
if (!empty($emailToList)) {
$mailsender = JMailHelper::cleanAddress($this->config->board_title . ' ' . JText::_('COM_KUNENA_FORUM') . ': ' . $this->me->getName());
$mailsubject = "[" . $this->config->board_title . " " . JText::_('COM_KUNENA_FORUM') . "] " . JText::_('COM_KUNENA_REPORT_MSG') . ": ";
if ($reason) {
$mailsubject .= $reason;
} else {
$mailsubject .= $topic->subject;
}
jimport('joomla.environment.uri');
$uri = JURI::getInstance(JURI::base());
$msglink = $uri->toString(array('scheme', 'host', 'port')) . $target->getPermaUrl(null, false);
$mailmessage = "" . JText::_('COM_KUNENA_REPORT_RSENDER') . " {$this->me->username} ({$this->me->name})";
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RREASON') . " " . $reason;
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RMESSAGE') . " " . $text;
$mailmessage .= "\n\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_POSTER') . " {$baduser->username} ({$baduser->name})";
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_SUBJECT') . ": " . $topic->subject;
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_MESSAGE') . "\n-----\n" . KunenaHtmlParser::stripBBCode($messagetext, 0, false);
$mailmessage .= "\n-----\n\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_LINK') . " " . $msglink;
$mailmessage = JMailHelper::cleanBody(strtr($mailmessage, array(' ' => '')));
foreach ($emailToList as $emailTo) {
if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) {
continue;
}
JUtility::sendMail($this->config->getEmail(), $mailsender, $emailTo->email, $mailsubject, $mailmessage);
}
$this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_SUCCESS'));
} else {
$this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_NOT_SEND'));
}
}
$this->app->redirect($target->getUrl($this->return, false));
}
示例7: setSubjectTitle
/**
* @param KunenaViewTopics $view
* @param string $message
*
* @return string
*/
public static function setSubjectTitle($view, $message)
{
$title = '';
if ($view->params->get('subjecttitle') == 'subject_only') {
$title = $view->escape($view->topic->subject);
} elseif ($view->params->get('subjecttitle') == 'body') {
$title = KunenaHtmlParser::stripBBCode($message, $view->params->get('titlelength'));
}
return $title;
}
示例8: empty
echo empty($this->topicActions) ? 5 : 6;
?>
"> </td>
</tr>
<?php
}
?>
<tr >
<td class="kcol-mid kcol-ktopicicon hidden-phone span1"> <?php
echo $this->getTopicLink($this->topic, 'unread', $this->topic->getIcon());
?>
</td>
<td class="kcol-mid kcol-ktopictitle span6">
<div class="hasTooltip"><span class="Title">
<?php
echo $this->getTopicLink($this->topic, null, null, KunenaHtmlParser::stripBBCode($this->topic->first_post_message, 500), 'hasTooltip');
if ($this->topic->getUserTopic()->favorite) {
?>
<i class="icon-star hasTooltip"><?php
JText::_('COM_KUNENA_FAVORITE');
?>
</i>
<?php
}
if ($this->me->exists() && $this->topic->getUserTopic()->posts) {
?>
<i class="icon-flag hasTooltip" ><?php
JText::_('COM_KUNENA_MYPOSTS');
?>
</i>
<?php
示例9: report
function report()
{
if (!JSession::checkToken('post')) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->setRedirectBack();
return;
}
if (!$this->me->exists() || $this->config->reportmsg == 0) {
// Deny access if report feature has been disabled or user is guest
$this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ACCESS'), 'notice');
$this->setRedirectBack();
return;
}
if (!$this->config->get('send_emails')) {
// Emails have been disabled
$this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_DISABLED'), 'notice');
$this->setRedirectBack();
return;
}
if (!$this->config->getEmail() || !JMailHelper::isEmailAddress($this->config->getEmail())) {
// Error: email address is invalid
$this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_INVALID'), 'error');
$this->setRedirectBack();
return;
}
// Get target object for the report
if ($this->mesid) {
$message = $target = KunenaForumMessageHelper::get($this->mesid);
$topic = $target->getTopic();
} else {
$topic = $target = KunenaForumTopicHelper::get($this->id);
$message = KunenaForumMessageHelper::get($topic->first_post_id);
}
$messagetext = $message->message;
$baduser = KunenaFactory::getUser($message->userid);
if (!$target->authorise('read')) {
// Deny access if user cannot read target
$this->app->enqueueMessage($target->getError(), 'notice');
$this->setRedirectBack();
return;
}
$reason = JRequest::getString('reason');
$text = JRequest::getString('text');
$template = KunenaTemplate::getInstance();
if (method_exists($template, 'reportMessage')) {
$template->reportMessage($message, $reason, $text);
}
// Load language file from the template.
KunenaFactory::getTemplate()->loadLanguage();
if (empty($reason) && empty($text)) {
// Do nothing: empty subject or reason is empty
$this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_FORG0T_SUB_MES'));
$this->setRedirectBack();
return;
} else {
$acl = KunenaAccess::getInstance();
$emailToList = $acl->getSubscribers($topic->category_id, $topic->id, false, true, false);
if (!empty($emailToList)) {
$mailsender = JMailHelper::cleanAddress($this->config->board_title . ' ' . JText::_('COM_KUNENA_FORUM') . ': ' . $this->me->getName());
$mailsubject = "[" . $this->config->board_title . " " . JText::_('COM_KUNENA_FORUM') . "] " . JText::_('COM_KUNENA_REPORT_MSG') . ": ";
if ($reason) {
$mailsubject .= $reason;
} else {
$mailsubject .= $topic->subject;
}
jimport('joomla.environment.uri');
$msglink = JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $target->getPermaUrl(null, false);
$mail = JFactory::getMailer();
$mail->setSender(array($this->me->username, $this->me->email));
$mail->setSubject($mailsubject);
// Render the email.
$layout = KunenaLayout::factory('Email/Report')->debug(false)->set('mail', $mail)->set('message', $message)->set('me', $this->me)->set('title', $reason)->set('content', $text)->set('messageLink', $msglink);
try {
$body = trim($layout->render());
$mail->setBody($body);
} catch (Exception $e) {
// TODO: Deprecated in K4.0, remove in K5.0
$mailmessage = "" . JText::_('COM_KUNENA_REPORT_RSENDER') . " {$this->me->username} ({$this->me->name})";
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RREASON') . " " . $reason;
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RMESSAGE') . " " . $text;
$mailmessage .= "\n\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_POSTER') . " {$baduser->username} ({$baduser->name})";
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_SUBJECT') . ": " . $topic->subject;
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_MESSAGE') . "\n-----\n" . KunenaHtmlParser::stripBBCode($messagetext, 0, false);
$mailmessage .= "\n-----\n\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_LINK') . " " . $msglink;
$mailmessage = JMailHelper::cleanBody(strtr($mailmessage, array(' ' => '')));
$mail->setBody($mailmessage);
}
$receivers = array();
foreach ($emailToList as $emailTo) {
if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) {
continue;
}
$receivers[] = $emailTo->email;
}
//.........这里部分代码省略.........
示例10:
if ($this->params->get('sh_sticky') && $this->topic->ordering) {
echo $this->getIcon('ktopicsticky', JText::_('MOD_KUNENALATEST_STICKY_TOPIC'));
}
if ($this->params->get('sh_locked') && $this->topic->locked) {
echo $this->getIcon('ktopiclocked', JText::_('COM_KUNENA_GEN_LOCKED_TOPIC'));
}
if ($this->params->get('sh_favorite') && $this->topic->getUserTopic()->favorite) {
echo $this->getIcon('kfavoritestar', JText::_('COM_KUNENA_FAVORITE'));
}
?>
</li>
<?php
if ($this->params->get('sh_firstcontentcharacter')) {
?>
<li class="klatest-preview-content"><?php
echo KunenaHtmlParser::stripBBCode($this->message->message, $this->params->get('lengthcontentcharacters'));
?>
</li>
<?php
}
if ($this->params->get('sh_category')) {
?>
<li class="klatest-cat"><?php
echo JText::_('MOD_KUNENALATEST_IN_CATEGORY') . ' ' . $this->categoryLink;
?>
</li>
<?php
}
if ($this->params->get('sh_author')) {
?>
<li class="klatest-author"><?php
示例11: displayDefault
function displayDefault($tpl = null) {
$this->me = KunenaUserHelper::getMyself();
$this->layout = $this->state->get('layout');
if ($this->layout == 'flat') $this->layout = 'default';
$this->setLayout($this->layout);
$this->assignRef ( 'category', $this->get ( 'Category' ) );
$this->assignRef ( 'topic', $this->get ( 'Topic' ) );
$channels = $this->category->getChannels();
if ($this->category->id && ! $this->category->authorise('read')) {
// User is not allowed to see the category
$this->setError($this->category->getError());
} elseif (! $this->topic) {
// Moved topic loop detected (1 -> 2 -> 3 -> 2)
$this->setError(JText::_('COM_KUNENA_VIEW_TOPIC_ERROR_LOOP'));
} elseif (! $this->topic->authorise('read')) {
// User is not allowed to see the topic
$this->setError($this->topic->getError());
} elseif ($this->state->get('item.id') != $this->topic->id || ($this->category->id != $this->topic->category_id && !isset($channels[$this->topic->category_id])) || ($this->state->get('layout') != 'threaded' && $this->state->get('item.mesid'))) {
// Topic has been moved or it doesn't belong to the current category
$db = JFactory::getDBO();
$mesid = $this->state->get('item.mesid');
if (!$mesid) {
$mesid = $this->topic->first_post_id;
}
$message = KunenaForumMessageHelper::get($mesid);
if ($message->exists()) JFactory::getApplication()->redirect($message->getUrl(null, false));
}
$errors = $this->getErrors();
if ($errors) {
return $this->displayNoAccess($errors);
}
$this->assignRef ( 'messages', $this->get ( 'Messages' ) );
$this->assignRef ( 'total', $this->get ( 'Total' ) );
// If page does not exist, redirect to the last page
if ($this->total <= $this->state->get('list.start')) {
JFactory::getApplication()->redirect($this->topic->getUrl(null, false, (int)($this->total / $this->state->get('list.limit'))));
}
$this->assignRef ( 'moderators', $this->get ( 'Moderators' ) );
$this->assignRef ( 'usertopic',$this->topic->getUserTopic());
$this->headerText = JText::_('COM_KUNENA_MENU_LATEST_DESC');
$this->title = JText::_('COM_KUNENA_ALL_DISCUSSIONS');
$this->pagination = $this->getPagination ( 5 );
$this->me = KunenaUserHelper::getMyself();
$this->config = KunenaFactory::getConfig();
// Mark topic read
$this->topic->markRead ();
$this->topic->hits++;
$this->topic->save();
// Check is subscriptions were sent and reset the value
if ($this->topic->authorise('subscribe')) {
$usertopic = $this->topic->getUserTopic();
if ($usertopic->subscribed == 2) {
$usertopic->subscribed = 1;
$usertopic->save();
}
}
$this->keywords = $this->topic->getKeywords(false, ', ');
$this->buttons();
// Get captcha & quick reply
$this->captcha = KunenaSpamRecaptcha::getInstance();
$this->quickreply = ($this->topic->authorise('reply',null, false) && $this->me->exists() && !$this->captcha->enabled());
//meta description and keywords
// TODO: use real keywords, too
$metaKeys = $this->escape ( "{$this->topic->subject}, {$this->category->getParent()->name}, {$this->config->board_title}, " . JText::_('COM_KUNENA_GEN_FORUM') . ', ' . JFactory::getapplication()->getCfg ( 'sitename' ) );
// Create Meta Description form the content of the first message
// better for search results display but NOT for search ranking!
$metaDesc = KunenaHtmlParser::stripBBCode($this->topic->first_post_message);
$metaDesc = preg_replace('/\s+/', ' ', $metaDesc); // remove newlines
$metaDesc = preg_replace('/^[^\w0-9]+/', '', $metaDesc); // remove characters at the beginning that are not letters or numbers
$metaDesc = trim($metaDesc); // Remove trailing spaces and beginning
// remove multiple spaces
while (strpos($metaDesc, ' ') !== false){
$metaDesc = str_replace(' ', ' ', $metaDesc);
}
// limit to 185 characters - google will cut off at ~150
if (strlen($metaDesc) > 185){
$metaDesc = rtrim(JString::substr($metaDesc, 0, 182)).'...';
}
$this->document->setMetadata ( 'keywords', $metaKeys );
$this->document->setDescription ( $this->escape($metaDesc) );
$this->setTitle(JText::sprintf('COM_KUNENA_VIEW_TOPICS_DEFAULT', $this->topic->subject));
$this->display($tpl);
}
示例12: plgSearchKunena
/**
* @param $text
* @param string $phrase
* @param string $ordering
* @param null $areas
*
* @return array
*/
function plgSearchKunena($text, $phrase = '', $ordering = '', $areas = null)
{
//If the array is not correct, return it:
if (is_array($areas) && !array_intersect($areas, array_keys(plgSearchKunenaAreas()))) {
return array();
}
$plugin = JPluginHelper::getPlugin('search', 'kunena');
$pluginParams = new JRegistry();
$pluginParams->loadString($plugin->params);
//And define the parameters. For example like this..
$limit = $pluginParams->get('search_limit', 50);
$contentLimit = $pluginParams->get('content_limit', 40);
$bbcode = $pluginParams->get('show_bbcode', 1);
$openInNewPage = $pluginParams->get('open_new_page', 1);
//Use the function trim to delete spaces in front of or at the back of the searching terms
$text = trim($text);
//Return Array when nothing was filled in
if ($text == '') {
return array();
}
$db = JFactory::getDbo();
//After this, you have to add the database part. This will be the most difficult part, because this changes per situation.
//In the coding examples later on you will find some of the examples used by Joomla! 1.5 core Search Plugins.
//It will look something like this.
switch ($phrase) {
//search exact
case 'exact':
$text = $db->quote('%' . $db->escape($text) . '%', false);
$where = "(m.subject LIKE {$text} OR t.message LIKE {$text})";
break;
//search all or any
//search all or any
case 'all':
case 'any':
default:
$where = array();
$words = explode(' ', $text);
foreach ($words as $word) {
$word = $db->quote('%' . $db->escape(trim($word)) . '%', false);
$where[] = "m.subject LIKE {$word} OR t.message LIKE {$word}";
}
$where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $where) . ')';
break;
}
//ordering of the results
switch ($ordering) {
//oldest first
case 'oldest':
$orderby = 'm.time ASC';
break;
//popular first
//popular first
case 'popular':
// FIXME: should be topic hits
$orderby = 'm.hits DESC, m.time DESC';
break;
//newest first
//newest first
case 'newest':
$orderby = 'm.time DESC';
break;
//alphabetic, ascending
//alphabetic, ascending
case 'alpha':
//default setting: alphabetic, ascending
//default setting: alphabetic, ascending
default:
$orderby = 'm.subject ASC, m.time DESC';
}
$params = array('orderby' => $orderby, 'where' => $where, 'starttime' => -1);
list($total, $messages) = KunenaForumMessageHelper::getLatestMessages(false, 0, $limit, $params);
$rows = array();
foreach ($messages as $message) {
/** @var KunenaForumMessage $message */
// Function must return: href, title, section, created, text, browsernav
$row = new StdClass();
$row->id = $message->id;
$row->href = $message->getUrl();
$row->title = JString::substr($message->subject, '0', $contentLimit);
$row->section = $message->getCategory()->name;
$row->created = $message->time;
if ($bbcode) {
$row->text = KunenaHtmlParser::parseBBCode($message->message, $contentLimit);
} else {
$row->text = KunenaHtmlParser::stripBBCode($message->message, $contentLimit);
}
$row->browsernav = $openInNewPage ? 1 : 0;
$rows[] = $row;
}
//Return the search results in an array
return $rows;
}
示例13: displayDefault
function displayDefault($tpl = null) {
$this->me = KunenaFactory::getUser();
$this->layout = $this->state->get('layout');
if ($this->layout == 'flat') $this->layout = 'default';
$this->setLayout($this->layout);
$this->assignRef ( 'category', $this->get ( 'Category' ) );
$this->assignRef ( 'topic', $this->get ( 'Topic' ) );
$channels = $this->category->getChannels();
if ($this->category->id && ! $this->category->authorise('read')) {
// User is not allowed to see the category
$this->setError($this->category->getError());
} elseif (! $this->topic) {
// Moved topic loop detected (1 -> 2 -> 3 -> 2)
$this->setError(JText::_('COM_KUNENA_VIEW_TOPIC_ERROR_LOOP'));
} elseif (! $this->topic->authorise('read')) {
// User is not allowed to see the topic
$this->setError($this->topic->getError());
} elseif ($this->state->get('item.id') != $this->topic->id || ($this->category->id != $this->topic->category_id && !isset($channels[$this->topic->category_id]))) {
// Topic has been moved or it doesn't belong to the current category
$db = JFactory::getDBO();
$query = "SELECT COUNT(*) FROM #__kunena_messages WHERE thread={$db->Quote($this->topic->id)} AND hold IN ({$this->state->get('hold')}) AND id<={$db->Quote($this->state->get('item.id'))}";
$db->setQuery ( $query );
$replyCount = $db->loadResult ();
if (KunenaError::checkDatabaseError()) return;
$app = JFactory::getApplication();
$app->redirect(CKunenaLink::GetThreadPageURL ( 'view', $this->topic->category_id, $this->topic->id, $replyCount, $this->state->get('list.limit'), $this->state->get('item.id'), false ));
}
$errors = $this->getErrors();
if ($errors) {
return $this->displayNoAccess($errors);
}
$this->assignRef ( 'messages', $this->get ( 'Messages' ) );
$this->assignRef ( 'total', $this->get ( 'Total' ) );
// If page does not exist, redirect to the last page
/* if ($this->total <= $this->state->get('list.start')) {
$app = JFactory::getApplication();
$app->redirect(CKunenaLink::GetThreadPageURL('view', $this->topic->category_id, $this->topic->id, $this->total, $this->state->get('list.start'), '', false));
}
*/
$this->assignRef ( 'moderators', $this->get ( 'Moderators' ) );
$this->assignRef ( 'usertopic',$this->topic->getUserTopic());
$this->headerText = JText::_('COM_KUNENA_MENU_LATEST_DESC');
$this->title = JText::_('COM_KUNENA_ALL_DISCUSSIONS');
$this->pagination = $this->getPagination ( 5 );
$this->me = KunenaFactory::getUser();
$this->config = KunenaFactory::getConfig();
// Mark topic read
$this->topic->markRead ();
$this->topic->hits++;
$this->topic->save();
// Check is subscriptions were sent and reset the value
if ($this->topic->authorise('subscribe')) {
$usertopic = $this->topic->getUserTopic();
if ($usertopic->subscribed == 2) {
$usertopic->subscribed = 1;
$usertopic->save();
}
}
$this->keywords = $this->topic->getKeywords(false, ', ');
$this->buttons();
//meta description and keywords
// TODO: use real keywords, too
$metaKeys = $this->escape ( "{$this->topic->subject}, {$this->category->getParent()->name}, {$this->config->board_title}, " . JText::_('COM_KUNENA_GEN_FORUM') . ', ' . JFactory::getapplication()->getCfg ( 'sitename' ) );
// Create Meta Description form the content of the first message
// better for search results display but NOT for search ranking!
$metaDesc = KunenaHtmlParser::stripBBCode($this->topic->first_post_message);
$metaDesc = preg_replace('/\s+/', ' ', $metaDesc); // remove newlines
$metaDesc = preg_replace('/^[^\w0-9]+/', '', $metaDesc); // remove characters at the beginning that are not letters or numbers
$metaDesc = trim($metaDesc); // Remove trailing spaces and beginning
// remove multiple spaces
while (strpos($metaDesc, ' ') !== false){
$metaDesc = str_replace(' ', ' ', $metaDesc);
}
// limit to 185 characters - google will cut off at ~150
if (strlen($metaDesc) > 185){
$metaDesc = rtrim(JString::substr($metaDesc, 0, 182)).'...';
}
$this->document->setMetadata ( 'keywords', $metaKeys );
$this->document->setDescription ( $this->escape($metaDesc) );
$this->setTitle(JText::sprintf('COM_KUNENA_VIEW_TOPICS_DEFAULT', $this->topic->subject));
$this->display($tpl);
}
示例14:
<?php
echo JText::_('COM_KUNENA_BY') . ' ' . $this->message->getAuthor()->getLink();
?>
</span>
</div>
<div class="kmessage-avatar"><?php
echo $this->user->getAvatarImage('', 'list');
?>
</div>
<div class="kmessage-msgtext"><?php
echo KunenaHtmlParser::stripBBCode($this->message->message, 300);
?>
</div>
</div>
<div>
<?php
if ($this->userLink) {
echo JText::_('COM_KUNENA_MODERATE_THIS_USER');
?>
:
<strong>
示例15: sendNotification
/**
* Send email notifications from the message.
*
* @param null|string $url
*
* @return bool|null
*/
public function sendNotification($url=null) {
$config = KunenaFactory::getConfig();
if (!$config->get('send_emails')) {
return null;
}
if ($this->hold > 1) {
return null;
} elseif ($this->hold == 1) {
$mailsubs = 0;
$mailmods = $config->mailmod >= 0;
$mailadmins = $config->mailadmin >= 0;
} else {
$mailsubs = (bool) $config->allowsubscriptions;
$mailmods = $config->mailmod >= 1;
$mailadmins = $config->mailadmin >= 1;
}
$once = false;
if ($mailsubs) {
if (!$this->parent) {
// New topic: Send email only to category subscribers
$mailsubs = $config->category_subscriptions != 'disabled' ? KunenaAccess::CATEGORY_SUBSCRIPTION : 0;
$once = $config->category_subscriptions == 'topic';
} elseif ($config->category_subscriptions != 'post') {
// Existing topic: Send email only to topic subscribers
$mailsubs = $config->topic_subscriptions != 'disabled' ? KunenaAccess::TOPIC_SUBSCRIPTION : 0;
$once = $config->topic_subscriptions == 'first';
} else {
// Existing topic: Send email to both category and topic subscribers
$mailsubs = $config->topic_subscriptions == 'disabled' ? KunenaAccess::CATEGORY_SUBSCRIPTION : KunenaAccess::CATEGORY_SUBSCRIPTION | KunenaAccess::TOPIC_SUBSCRIPTION;
// FIXME: category subcription can override topic
$once = $config->topic_subscriptions == 'first';
}
}
if (!$url) {
$url = JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $this->getPermaUrl(null);
}
//get all subscribers, moderators and admins who will get the email
$me = KunenaUserHelper::get();
$acl = KunenaAccess::getInstance();
$emailToList = $acl->getSubscribers($this->catid, $this->thread, $mailsubs, $mailmods, $mailadmins, $me->userid);
$topic = $this->getTopic();
if (count ( $emailToList )) {
if (! $config->getEmail() ) {
KunenaError::warning ( JText::_ ( 'COM_KUNENA_EMAIL_DISABLED' ) );
return false;
} elseif ( ! JMailHelper::isEmailAddress ( $config->getEmail() ) ) {
KunenaError::warning ( JText::_ ( 'COM_KUNENA_EMAIL_INVALID' ) );
return false;
}
// clean up the message for review
$message = KunenaHtmlParser::stripBBCode ( $this->message, 0, false );
$mailsender = JMailHelper::cleanAddress ( $config->board_title );
$mailsubject = JMailHelper::cleanSubject ( "[" . $config->board_title . "] " . $topic->subject . " (" . $this->getCategory()->name . ")" );
$subject = $this->subject ? $this->subject : $topic->subject;
// Make a list from all receivers
$sentusers = array();
$receivers = array(0=>array(), 1=>array());
foreach ( $emailToList as $emailTo ) {
if (! $emailTo->email || ! JMailHelper::isEmailAddress ( $emailTo->email )) {
continue;
}
$receivers[$emailTo->subscription][] = $emailTo->email;
$sentusers[] = $emailTo->id;
}
// Create email
$mail = JFactory::getMailer();
$mail->setSubject($mailsubject);
$mail->setSender(array($config->getEmail(), $mailsender));
// Send email to all subscribers
if (!empty($receivers[1])) {
$mail->setBody($this->createEmailBody(1, $subject, $url, $message, $once));
$this->sendEmail($mail, $receivers[1]);
}
// Send email to all moderators
if (!empty($receivers[0])) {
$mail->setBody($this->createEmailBody(0, $subject, $url, $message, $once));
$this->sendEmail($mail, $receivers[0]);
}
// Update subscriptions
if ($once && $sentusers) {
$sentusers = implode (',', $sentusers);
$db = JFactory::getDBO();
$query = "UPDATE #__kunena_user_topics SET subscribed=2 WHERE topic_id={$this->thread} AND user_id IN ({$sentusers}) AND subscribed=1";
//.........这里部分代码省略.........