We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 29a4bb4d authored by Evan Prodromou's avatar Evan Prodromou

better formatting for RSVPs

parent ba2a2469
......@@ -324,7 +324,11 @@ class EventPlugin extends MicroappPlugin
function showRSVPNotice($notice, $out)
{
$out->raw($notice->rendered);
$rsvp = RSVP::fromNotice($notice);
$out->elementStart('div', 'rsvp');
$out->raw($rsvp->asHTML());
$out->elementEnd('div');
return;
}
......
......@@ -180,12 +180,9 @@ class RSVP extends Managed_DataObject
// XXX: come up with something sexier
$content = sprintf(_('RSVPed %s for an event.'),
($verb == RSVP::POSITIVE) ? _('positively') :
($verb == RSVP::NEGATIVE) ? _('negatively') :
_('possibly'));
$content = $rsvp->asString();
$rendered = $content;
$rendered = $rsvp->asHTML();
$options = array_merge(array('object_type' => $verb),
$options);
......@@ -276,4 +273,90 @@ class RSVP extends Managed_DataObject
return $rsvps;
}
function getProfile()
{
$profile = Profile::staticGet('id', $this->profile_id);
if (empty($profile)) {
throw new Exception("No profile with ID {$this->profile_id}");
}
return $profile;
}
function getEvent()
{
$event = Happening::staticGet('id', $this->event_id);
if (empty($event)) {
throw new Exception("No event with ID {$this->event_id}");
}
return $event;
}
function asHTML()
{
return self::toHTML($this->getProfile(),
$this->getEvent(),
$this->response);
}
function asString()
{
return self::toString($this->getProfile(),
$this->getEvent(),
$this->response);
}
static function toHTML($profile, $event, $response)
{
$fmt = null;
$notice = $event->getNotice();
switch ($response) {
case 'Y':
$fmt = _("<span class='automatic event-rsvp'><a href='%1s'>%2s</a> is attending <a href='%3s'>%4s</a>.</span>");
break;
case 'N':
$fmt = _("<span class='automatic event-rsvp'><a href='%1s'>%2s</a> is not attending <a href='%3s'>%4s</a>.</span>");
break;
case '?':
$fmt = _("<span class='automatic event-rsvp'><a href='%1s'>%2s</a> might attend <a href='%3s'>%4s</a>.</span>");
break;
default:
throw new Exception("Unknown response code {$response}");
break;
}
return sprintf($fmt,
htmlspecialchars($profile->profileurl),
htmlspecialchars($profile->getBestName()),
htmlspecialchars($notice->bestUrl()),
htmlspecialchars($event->title));
}
static function toString($profile, $event, $response)
{
$fmt = null;
$notice = $event->getNotice();
switch ($response) {
case 'Y':
$fmt = _("%1s is attending %2s.");
break;
case 'N':
$fmt = _("%1s is not attending %2s.");
break;
case '?':
$fmt = _("%1s might attend %2s.>");
break;
default:
throw new Exception("Unknown response code {$response}");
break;
}
return sprintf($fmt,
$profile->getBestName(),
$event->title);
}
}
......@@ -451,6 +451,10 @@ address .poweredby {
overflow:visible;
}
.notice .automatic {
font-style:italic;
}
#showstream h1 {
display:none;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment