QnA - truncate long question titles in notice content

This commit is contained in:
Zach Copley 2011-04-04 17:04:13 -07:00
parent 7fb963bb42
commit 92156317b6
3 changed files with 13 additions and 10 deletions

View File

@ -88,6 +88,7 @@ class QnanewquestionAction extends Action
}
$this->title = $this->trimmed('title');
common_debug("TITLE = " . $this->title);
$this->description = $this->trimmed('description');
return true;

View File

@ -273,15 +273,17 @@ class QnA_Question extends Managed_DataObject
common_log(LOG_DEBUG, "Saving question: $q->id $q->uri");
$q->insert();
// TRANS: Notice content creating a question.
// TRANS: %1$s is the title of the question, %2$s is a link to the question.
$content = sprintf(
_m('question: %1$s %2$s'),
$title,
$q->uri
);
if (Notice::contentTooLong($q->title . ' ' . $q->uri)) {
$max = Notice::maxContent();
$uriLen = mb_strlen($q->uri);
$targetLen = $max - ($uriLen + 15);
$title = mb_substr($q->title, 0, $targetLen) . '…';
$link = '<a href="' . htmlspecialchars($q->uri) . '">' . htmlspecialchars($title) . '</a>';
}
$content = $title . ' ' . $q->uri;
$link = '<a href="' . htmlspecialchars($q->uri) . '">' . htmlspecialchars($q->title) . '</a>';
// TRANS: Rendered version of the notice content creating a question.
// TRANS: %s a link to the question as link description.
$rendered = sprintf(_m('Question: %s'), $link);