Commit 0dc1f7d1 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Remove extra whitespace in internal notification display


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 91313817
......@@ -85,6 +85,13 @@ class PluginBlocktypeInbox extends SystemBlocktype {
unset($records[$maxitems]);
}
if ($records) {
require_once('activity.php');
foreach ($records as &$r) {
$r->message = format_notification_whitespace($r->message);
}
}
$smarty = smarty_core();
if ($showmore) {
$smarty->assign('desiredtypes', implode(',', $desiredtypes));
......
......@@ -12,8 +12,8 @@
<td>
{if $i->message}
<a href="" class="inbox-showmessage{if !$i->read} unread{/if}">{$i->subject}</a>
<div class="inbox-message hidden" id="inbox-message-{$i->id}">{$i->message}
{if $i->url}<br><a href="{$i->url|escape}" class="s">{if $i->urltext}{$i->urltext|escape} &raquo;{else}{str tag="more..."}{/if}</a>{/if}
<div class="inbox-message hidden" id="inbox-message-{$i->id}">{$i->message|safe}
{if $i->url}<br><a href="{$i->url}" class="s">{if $i->urltext}{$i->urltext} &raquo;{else}{str tag="more..."}{/if}</a>{/if}
</div>
{elseif $i->url}
<a href="{$i->url}">{$i->subject}</a>
......
......@@ -499,12 +499,12 @@ class ActivityTypeInteractionForumNewPost extends ActivityTypePlugin {
$posttime = strftime(get_string('strftimedaydatetime'), $post->ctime);
$htmlbody = $post->body;
$this->message = str_shorten_html($htmlbody, 200, true); // For internal notification
$this->message = strip_tags(str_shorten_html($htmlbody, 200, true)); // For internal notifications.
$textbody = trim(html2text($post->body));
$postlink = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $post->topicid . '#post' . $this->postid;
$this->url = $postlink;
$this->url = $postlink;
$this->add_urltext(array(
'key' => 'Topic',
'section' => 'interaction.forum'
......
......@@ -908,6 +908,13 @@ abstract class ActivityTypePlugin extends ActivityType {
}
}
function format_notification_whitespace($message) {
$message = preg_replace('/^(\s|<br( ?\/)?>|&nbsp;|\xc2\xa0)*/', '', $message);
$message = format_whitespace($message);
return preg_replace('/(<br( ?\/)?>\s*){2,}/', '<br><br>', $message);
}
/**
* Get one page of notifications and return html
*/
......@@ -974,7 +981,7 @@ function activitylist_html($type='all', $limit=10, $offset=0) {
$r->date = format_date(strtotime($r->ctime), 'strfdaymonthyearshort');
$section = empty($r->plugintype) ? 'activity' : "{$r->plugintype}.{$r->pluginname}";
$r->strtype = get_string('type' . $r->type, $section);
$r->message = format_whitespace($r->message);
$r->message = format_notification_whitespace($r->message);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment