Skip to content

Commit 094ff95

Browse files
michieldbramley
andauthored
Use <wbr> element instead of zero-width space character to allow wrapping of an email address or URL (#952)
Co-authored-by: Duncan Cameron <[email protected]>
1 parent 4c22987 commit 094ff95

File tree

6 files changed

+118
-97
lines changed

6 files changed

+118
-97
lines changed

public_html/lists/admin/lib.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,15 +1971,36 @@ function shortenText($text, $max = 30)
19711971
* mostly used for columns in listings to retrict the width, particularly on mobile devices
19721972
* it will show the full text as the title tip but restrict the size of the output
19731973
*
1974-
* will also place a space after / and @ to facilitate wrapping in the browser
1975-
*
19761974
*/
19771975
function shortenTextDisplay($text, $max = 30)
1976+
{
1977+
$display = shortenText($text, $max);
1978+
1979+
return sprintf('<span title="%s">%s</span>', htmlspecialchars($text), $display);
1980+
}
1981+
/*
1982+
* shortenEmailDisplay
1983+
*
1984+
* Similar to shortenTextDisplay() but adds a wbr element after @ to allow wrapping
1985+
*/
1986+
function shortenEmailDisplay($text, $max = 30)
1987+
{
1988+
$display = shortenText($text, $max);
1989+
$display = str_replace('@', '@<wbr>', $display);
1990+
1991+
return sprintf('<span title="%s">%s</span>', htmlspecialchars($text), $display);
1992+
}
1993+
1994+
/*
1995+
* shortenUrlDisplay
1996+
*
1997+
* Similar to shortenTextDisplay() but adds a wbr element after each / to allow wrapping
1998+
*/
1999+
function shortenUrlDisplay($text, $max = 30)
19782000
{
19792001
$display = preg_replace('!^https?://!i', '', $text);
19802002
$display = shortenText($display, $max);
1981-
$display = str_replace('/', '/&#x200b;', $display);
1982-
$display = str_replace('@', '@&#x200b;', $display);
2003+
$display = str_replace('/', '/<wbr>', $display);
19832004

19842005
return sprintf('<span title="%s">%s</span>', htmlspecialchars($text), $display);
19852006
}

public_html/lists/admin/mclicks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
);
141141

142142
if (!$download) {
143-
$element = shortenTextDisplay($row['url']);
143+
$element = shortenUrlDisplay($row['url']);
144144
} else {
145145
$element = $row['url'];
146146
}

public_html/lists/admin/members.php

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ function addUserForm($listid)
316316
$ls = new WebblerListing($GLOBALS['I18N']->get('Members'));
317317
$ls->usePanel($paging);
318318
while ($user = Sql_fetch_array($result)) {
319-
$element = shortenTextDisplay($user['email']);
319+
$element = shortenEmailDisplay($user['email']);
320320
$ls->addElement($element, PageUrl2('user&amp;id='.$user['id']));
321321
$ls->setClass($element, 'row1');
322322
$ls_delete = '';
@@ -364,14 +364,14 @@ function addUserForm($listid)
364364

365365
?>
366366
<div class="panel">
367-
<h3><?php echo s('Actions') ?></h3>
368-
<div class=" content well">
369-
<div class="row">
370-
<div class="col-sm-6 membersProcess">
371-
<h4 style="margin-bottom:0"><?php echo $GLOBALS['I18N']->get('What to do with "Tagged" users') ?>:</h4>
367+
<h3><?php echo s('Actions') ?></h3>
368+
<div class=" content well">
369+
<div class="row">
370+
<div class="col-sm-6 membersProcess">
371+
<h4 style="margin-bottom:0"><?php echo $GLOBALS['I18N']->get('What to do with "Tagged" users') ?>:</h4>
372372
<h6><?php echo $GLOBALS['I18N']->get('This will only process the users in this page that have the "Tag" checkbox checked') ?></h6>
373373
<div class="row col-sm-12" style="margin:10px 0 5px">
374-
<p><input type="radio" name="tagaction" value="delete"/> <?php echo $GLOBALS['I18N']->get('Delete') ?>
374+
<p><input type="radio" name="tagaction" value="delete"/> <?php echo $GLOBALS['I18N']->get('Delete') ?>
375375
(<?php echo $GLOBALS['I18N']->get('from this list') ?>)</p>
376376
</div>
377377
<div class="clearfix" style="margin-bottom:10px;margin-top:-10px"></div>
@@ -385,26 +385,26 @@ function addUserForm($listid)
385385
}
386386
if ($html) {
387387
?>
388-
<div class="row col-sm-12" style="margin:0px 0 10px">
389-
<div class="fleft">
390-
<input type="radio" name="tagaction" value="move"/> <?php echo $GLOBALS['I18N']->get('Move').'&nbsp;'.$GLOBALS['I18N']->get('to').': &nbsp;&nbsp;' ?>
391-
</div>
392-
<div class="fleft">
393-
<select name="movedestination">
388+
<div class="row col-sm-12" style="margin:0px 0 10px">
389+
<div class="fleft">
390+
<input type="radio" name="tagaction" value="move"/> <?php echo $GLOBALS['I18N']->get('Move').'&nbsp;'.$GLOBALS['I18N']->get('to').': &nbsp;&nbsp;' ?>
391+
</div>
392+
<div class="fleft">
393+
<select name="movedestination">
394394
<?php echo $html ?>
395-
</select>
396-
</div>
395+
</select>
396+
</div>
397397
</div>
398-
<div class="row col-sm-12" style="margin:0px 0 10px">
399-
<div class="fleft">
400-
<input type="radio" name="tagaction" value="copy"/> <?php echo $GLOBALS['I18N']->get('Copy').'&nbsp;'.$GLOBALS['I18N']->get('to').':&nbsp;&nbsp;' ?>
401-
</div>
402-
<div class="fleft">
403-
<select name="copydestination">
398+
<div class="row col-sm-12" style="margin:0px 0 10px">
399+
<div class="fleft">
400+
<input type="radio" name="tagaction" value="copy"/> <?php echo $GLOBALS['I18N']->get('Copy').'&nbsp;'.$GLOBALS['I18N']->get('to').':&nbsp;&nbsp;' ?>
401+
</div>
402+
<div class="fleft">
403+
<select name="copydestination">
404404
<?php echo $html ?>
405-
</select>
406-
</div>
407-
</div>
405+
</select>
406+
</div>
407+
</div>
408408
<div class="row col-sm-12" style="margin:0px 0 10px">
409409
<input type="radio" name="tagaction" value="nothing" checked="checked"/><?php echo $GLOBALS['I18N']->get('Nothing') ?>
410410
</div>
@@ -413,7 +413,7 @@ function addUserForm($listid)
413413
</div>
414414
<br class="visible-xs" />
415415
<div class="col-sm-6 membersProcess">
416-
<h4 style="margin-bottom:0"><?php echo s('What to do with all subscribers') ?></h4>
416+
<h4 style="margin-bottom:0"><?php echo s('What to do with all subscribers') ?></h4>
417417
<h6><?php echo s('This will process all subscribers on this list, confirmed and unconfirmed') ?></h6>
418418
<div class="row col-sm-12" style="margin:10px 0 5px">
419419
<p><input type="radio" name="tagaction_all" value="delete"/> <?php echo $GLOBALS['I18N']->get('Delete') ?>
@@ -422,29 +422,29 @@ function addUserForm($listid)
422422
<div class="clearfix" style="margin-bottom:10px;margin-top:-10px"></div>
423423
<?php if ($html) {
424424
?>
425-
<div class="row col-sm-12" style="margin:0px 0 10px">
426-
<div class="fleft">
427-
<input type="radio" name="tagaction_all" value="move"/> <?php echo $GLOBALS['I18N']->get('Move').'&nbsp;'.$GLOBALS['I18N']->get('to').':&nbsp;&nbsp' ?>
428-
</div>
429-
<div class="fleft">
430-
<select name="movedestination_all">
425+
<div class="row col-sm-12" style="margin:0px 0 10px">
426+
<div class="fleft">
427+
<input type="radio" name="tagaction_all" value="move"/> <?php echo $GLOBALS['I18N']->get('Move').'&nbsp;'.$GLOBALS['I18N']->get('to').':&nbsp;&nbsp' ?>
428+
</div>
429+
<div class="fleft">
430+
<select name="movedestination_all">
431431
<?php echo $html ?>
432-
</select>
433-
</div>
432+
</select>
433+
</div>
434434
</div>
435-
<div class="row col-sm-12" style="margin:0px 0 10px">
436-
<div class="fleft">
437-
<input type="radio" name="tagaction_all" value="copy"/> <?php echo $GLOBALS['I18N']->get('Copy').'&nbsp;'.$GLOBALS['I18N']->get('to').':&nbsp;&nbsp' ?>
438-
</div>
439-
<div class="fleft">
440-
<select name="copydestination_all">
435+
<div class="row col-sm-12" style="margin:0px 0 10px">
436+
<div class="fleft">
437+
<input type="radio" name="tagaction_all" value="copy"/> <?php echo $GLOBALS['I18N']->get('Copy').'&nbsp;'.$GLOBALS['I18N']->get('to').':&nbsp;&nbsp' ?>
438+
</div>
439+
<div class="fleft">
440+
<select name="copydestination_all">
441441
<?php echo $html ?>
442-
</select>
443-
</div>
442+
</select>
443+
</div>
444444
</div>
445445
<div class="row col-sm-12" style="margin:0px 0">
446-
<input type="radio" name="tagaction_all" value="nothing" checked="checked"/> <?php echo $GLOBALS['I18N']->get('Nothing') ?>
447-
</div>
446+
<input type="radio" name="tagaction_all" value="nothing" checked="checked"/> <?php echo $GLOBALS['I18N']->get('Nothing') ?>
447+
</div>
448448
<?php
449449

450450
} ?>

public_html/lists/admin/mviews.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
if ($id) {
2424
$allow = Sql_Fetch_Row_query(
2525
sprintf(
26-
'select
27-
owner
28-
from
29-
%s
30-
where
26+
'select
27+
owner
28+
from
29+
%s
30+
where
3131
id = %d %s'
3232
, $GLOBALS['tables']['message']
3333
, $id
@@ -78,11 +78,11 @@
7878

7979
//print '<h3>'.s('View Details for a Message').'</h3>';
8080
$messagedata = Sql_Fetch_Array_query(
81-
"SELECT
82-
*
83-
FROM
84-
{$tables['message']}
85-
WHERE
81+
"SELECT
82+
*
83+
FROM
84+
{$tables['message']}
85+
WHERE
8686
id = $id $subselect"
8787
);
8888
echo '<table class="mviewsDetails table table-bordered"><tr><td>' .
@@ -102,16 +102,16 @@
102102

103103
$req = Sql_Query(
104104
sprintf(
105-
'select
105+
'select
106106
um.userid
107-
from
107+
from
108108
%s um
109-
, %s msg
110-
where
111-
um.messageid = %d
112-
and um.messageid = msg.id
109+
, %s msg
110+
where
111+
um.messageid = %d
112+
and um.messageid = msg.id
113113
and um.viewed is not null %s
114-
group by
114+
group by
115115
userid'
116116
, $GLOBALS['tables']['usermessage']
117117
, $GLOBALS['tables']['message']
@@ -150,7 +150,7 @@
150150

151151
$req = Sql_Query(
152152
sprintf(
153-
'select
153+
'select
154154
userid
155155
, email
156156
, um.entered as sent
@@ -159,21 +159,21 @@
159159
, count(um.viewed) as uniqueviews
160160
, msg.viewed as totalcampaignviews
161161
, abs(unix_timestamp(um.entered) - unix_timestamp(um.viewed)) as responsetime
162-
from
162+
from
163163
%s um
164164
, %s user
165-
, %s msg
166-
where
167-
um.messageid = %d
168-
and um.messageid = msg.id
169-
and um.userid = user.id
170-
and um.status = "sent"
171-
and um.viewed is not null
165+
, %s msg
166+
where
167+
um.messageid = %d
168+
and um.messageid = msg.id
169+
and um.userid = user.id
170+
and um.status = "sent"
171+
and um.viewed is not null
172172
%s
173-
group by
173+
group by
174174
userid
175175
order by
176-
lastview desc
176+
lastview desc
177177
%s'
178178
, $GLOBALS['tables']['usermessage']
179179
, $GLOBALS['tables']['user']
@@ -189,14 +189,14 @@
189189

190190
$allViewsReq = Sql_Query(
191191
sprintf(
192-
'select
193-
*
194-
from
195-
%s
196-
where
197-
userid = %d
198-
and messageid = %d
199-
order by
192+
'select
193+
*
194+
from
195+
%s
196+
where
197+
userid = %d
198+
and messageid = %d
199+
order by
200200
viewed'
201201
, $GLOBALS['tables']['user_message_view']
202202
, $row['userid']
@@ -209,7 +209,7 @@
209209
$element = $row['email'];
210210
$separator = ',';
211211
} else {
212-
$element = shortenTextDisplay($row['email'], 35);
212+
$element = shortenEmailDisplay($row['email'], 35);
213213
$separator = '<br/>';
214214
}
215215
$ls->addElement($element, PageUrl2('user&amp;id='.$row['userid']));

public_html/lists/admin/uclicks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
while ($row = Sql_Fetch_Array($req)) {
5858
$some = 1;
5959
if (!$download) {
60-
$element = shortenTextDisplay($row['url'], 30);
60+
$element = shortenUrlDisplay($row['url'], 30);
6161
} else {
6262
$element = $row['url'];
6363
}

public_html/lists/admin/userclicks.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
echo '<div class="fright">'.PageLinkButton('userclicks&fwdid='.$fwdid.'&msgid='.$msgid.'&dl=1',
8888
s('Download subscribers')).'</div>';
8989
$query = sprintf('select htmlclicked, textclicked, user.email,user.id as userid,firstclick,latestclick,clicked
90-
from %s as uml_click, %s as user where uml_click.userid = user.id
90+
from %s as uml_click, %s as user where uml_click.userid = user.id
9191
and uml_click.forwardid = %d and uml_click.messageid = %d
9292
and uml_click.clicked', $GLOBALS['tables']['linktrack_uml_click'], $GLOBALS['tables']['user'], $fwdid, $msgid);
9393
} elseif ($userid && $msgid) {
@@ -105,7 +105,7 @@
105105
<tr><td>' .$GLOBALS['I18N']->get('Sent').'<td><td>'.$messagedata['sent'].'</td></tr>
106106
</table>';
107107
$query = sprintf('select htmlclicked, textclicked,user.email,user.id as userid,firstclick,latestclick,
108-
clicked,messageid,forwardid,url from %s as uml_click, %s as user, %s as forward where uml_click.userid = user.id
108+
clicked,messageid,forwardid,url from %s as uml_click, %s as user, %s as forward where uml_click.userid = user.id
109109
and uml_click.userid = %d and uml_click.messageid = %d and forward.id = uml_click.forwardid',
110110
$GLOBALS['tables']['linktrack_uml_click'], $GLOBALS['tables']['user'], $GLOBALS['tables']['linktrack_forward'],
111111
$userid, $msgid);
@@ -151,7 +151,7 @@
151151
MAX(latestclick) AS latestclick,
152152
SUM(clicked) AS clicked
153153
FROM %s AS uml_click
154-
JOIN %s AS user ON uml_click.userid = user.id
154+
JOIN %s AS user ON uml_click.userid = user.id
155155
WHERE uml_click.messageid = %d
156156
GROUP BY uml_click.userid
157157
',
@@ -177,18 +177,18 @@
177177
messageid SEPARATOR \' \') AS messageid,
178178
forwardid,
179179
url
180-
FROM
180+
FROM
181181
'.$GLOBALS['tables']['linktrack_uml_click'].' AS uml_click
182182
JOIN
183183
'.$GLOBALS['tables']['user'].' AS user ON uml_click.userid = user.id
184-
JOIN
184+
JOIN
185185
'.$GLOBALS['tables']['linktrack_forward'].' AS forward ON forward.id = uml_click.forwardid
186-
WHERE
186+
WHERE
187187
uml_click.userid = '.sprintf('%d', $userid).'
188-
GROUP BY
188+
GROUP BY
189189
forwardid
190-
ORDER BY
191-
clicked DESC,
190+
ORDER BY
191+
clicked DESC,
192192
url
193193
';
194194
}
@@ -214,13 +214,13 @@
214214
$downloadContent .= $row['email'].PHP_EOL;
215215
} else {
216216
if (!$userid) {
217-
$element = shortenTextDisplay($row['email']);
217+
$element = shortenEmailDisplay($row['email']);
218218
$ls->addElement($element, PageUrl2('user&amp;id='.$row['userid']));
219219
$ls->setClass($element, 'row1');
220220
} else {
221221
// $link = substr($row['url'],0,50);
222222
// $element = PageLink2($link,$link,PageUrl2('uclicks&amp;id='.$row['forwardid']),"",true,$row['url']);
223-
$element = shortenTextDisplay($row['url']);
223+
$element = shortenUrlDisplay($row['url']);
224224
$ls->addElement($element, PageUrl2('uclicks&amp;id='.$row['forwardid']));
225225
$ls->setClass($element, 'row1');
226226
$messageLinks = preg_replace_callback(

0 commit comments

Comments
 (0)