* @return User_greeting_count object found, or null for no hits
*
*/
-
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Poll', $k, $v);
* @return Bookmark object found, or null for no hits
*
*/
-
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Poll', $kv);
*
* @return Poll found poll or null
*/
-
function getByNotice($notice)
{
return self::staticGet('uri', $notice->uri);
return explode("\n", $this->options);
}
+ /**
+ * Is this a valid selection index?
+ *
+ * @param numeric $selection (1-based)
+ * @return boolean
+ */
+ function isValidSelection($selection)
+ {
+ if ($selection != intval($selection)) {
+ return false;
+ }
+ if ($selection < 1 || $selection > count($this->getOptions())) {
+ return false;
+ }
+ return true;
+ }
+
function getNotice()
{
return Notice::staticGet('uri', $this->uri);
*
* @return Notice saved notice
*/
-
static function saveNew($profile, $question, $opts, $options=null)
{
if (empty($options)) {
common_log(LOG_DEBUG, "Saving poll: $p->id $p->uri");
$p->insert();
- $content = sprintf(_m('Poll: %s %s'),
+ // TRANS: Notice content creating a poll.
+ // TRANS: %1$s is the poll question, %2$s is a link to the poll.
+ $content = sprintf(_m('Poll: %1$s %2$s'),
$question,
$p->uri);
- $rendered = sprintf(_m('Poll: <a href="%s">%s</a>'),
- htmlspecialchars($p->uri),
- htmlspecialchars($question));
+ $link = '<a href="' . htmlspecialchars($p->uri) . '">' . htmlspecialchars($question) . '</a>';
+ // TRANS: Rendered version of the notice content creating a poll.
+ // TRANS: %s is a link to the poll with the question as link description.
+ $rendered = sprintf(_m('Poll: %s'), $link);
$tags = array('poll');
$replies = array();