*
* @see DB_DataObject
*/
-
class QnA_Question extends Managed_DataObject
{
const OBJECT_TYPE = 'http://activityschema.org/object/question';
public $closed; // int (boolean) whether a question is closed
public $created; // datetime
- /**
- * Get an instance by key
- *
- * This is a utility method to get a single instance with a given key value.
- *
- * @param string $k Key to use to lookup
- * @param mixed $v Value to lookup
- *
- * @return QnA_Question object found, or null for no hits
- *
- */
- function staticGet($k, $v=null)
- {
- return Memcached_DataObject::staticGet('QnA_Question', $k, $v);
- }
-
/**
* Get an instance by compound key
*
*
* @return Question found question or null
*/
- function getByNotice($notice)
+ static function getByNotice($notice)
{
- return self::staticGet('uri', $notice->uri);
+ return self::getKV('uri', $notice->uri);
}
function getNotice()
{
- return Notice::staticGet('uri', $this->uri);
+ return Notice::getKV('uri', $this->uri);
}
function bestUrl()
function getProfile()
{
- $profile = Profile::staticGet('id', $this->profile_id);
+ $profile = Profile::getKV('id', $this->profile_id);
if (empty($profile)) {
- throw new Exception("No profile with ID {$this->profile_id}");
+ // TRANS: Exception trown when getting a profile for a non-existing ID.
+ // TRANS: %s is the provided profile ID.
+ throw new Exception(sprintf(_m('No profile with ID %s'),$this->profile_id));
}
return $profile;
}
static function fromNotice($notice)
{
- return QnA_Question::staticGet('uri', $notice->uri);
+ return QnA_Question::getKV('uri', $notice->uri);
}
function asHTML()
if (!empty($question->description)) {
$out->elementStart('span', 'question-description');
- $out->raw(QnAPlugin::shorten($question->description, $notice));
+ $out->raw(common_render_text($question->description));
$out->elementEnd('span');
}
if (!empty($cnt)) {
$out->elementStart('span', 'answer-count');
- $out->text(sprintf(_m('%s answers'), $cnt));
+ // TRANS: Number of given answers to a question.
+ // TRANS: %s is the number of given answers.
+ $out->text(sprintf(_m('%s answer','%s answers',$cnt), $cnt));
$out->elementEnd('span');
}
if (!empty($question->closed)) {
$out->elementStart('span', 'question-closed');
+ // TRANS: Notification that a question cannot be answered anymore because it is closed.
$out->text(_m('This question is closed.'));
$out->elementEnd('span');
}
$uriLen = mb_strlen($q->uri);
$targetLen = $max - ($uriLen + 15);
$title = mb_substr($q->title, 0, $targetLen) . '…';
-
}
$content = $title . ' ' . $q->uri;