QnA - truncate long question titles in notice content
This commit is contained in:
parent
7fb963bb42
commit
92156317b6
|
@ -356,7 +356,7 @@ class QnAPlugin extends MicroAppPlugin
|
||||||
* @param Notice $notice
|
* @param Notice $notice
|
||||||
* @param HTMLOutputter $out
|
* @param HTMLOutputter $out
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function showNotice($notice, $out)
|
function showNotice($notice, $out)
|
||||||
{
|
{
|
||||||
switch ($notice->object_type) {
|
switch ($notice->object_type) {
|
||||||
|
@ -415,7 +415,7 @@ class QnAPlugin extends MicroAppPlugin
|
||||||
function showNoticeAnswer($notice, $out)
|
function showNoticeAnswer($notice, $out)
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$answer = QnA_Answer::getByNotice($notice);
|
$answer = QnA_Answer::getByNotice($notice);
|
||||||
$question = $answer->getQuestion();
|
$question = $answer->getQuestion();
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ class QnanewquestionAction extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->title = $this->trimmed('title');
|
$this->title = $this->trimmed('title');
|
||||||
|
common_debug("TITLE = " . $this->title);
|
||||||
$this->description = $this->trimmed('description');
|
$this->description = $this->trimmed('description');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -273,15 +273,17 @@ class QnA_Question extends Managed_DataObject
|
||||||
common_log(LOG_DEBUG, "Saving question: $q->id $q->uri");
|
common_log(LOG_DEBUG, "Saving question: $q->id $q->uri");
|
||||||
$q->insert();
|
$q->insert();
|
||||||
|
|
||||||
// TRANS: Notice content creating a question.
|
if (Notice::contentTooLong($q->title . ' ' . $q->uri)) {
|
||||||
// TRANS: %1$s is the title of the question, %2$s is a link to the question.
|
$max = Notice::maxContent();
|
||||||
$content = sprintf(
|
$uriLen = mb_strlen($q->uri);
|
||||||
_m('question: %1$s %2$s'),
|
$targetLen = $max - ($uriLen + 15);
|
||||||
$title,
|
$title = mb_substr($q->title, 0, $targetLen) . '…';
|
||||||
$q->uri
|
|
||||||
);
|
|
||||||
|
|
||||||
$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: Rendered version of the notice content creating a question.
|
||||||
// TRANS: %s a link to the question as link description.
|
// TRANS: %s a link to the question as link description.
|
||||||
$rendered = sprintf(_m('Question: %s'), $link);
|
$rendered = sprintf(_m('Question: %s'), $link);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user