Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
This commit is contained in:
commit
ed8a1e6fe1
@ -297,7 +297,7 @@ class EventPlugin extends MicroappPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @fixme we have to start the name/avatar and open this div
|
// @fixme we have to start the name/avatar and open this div
|
||||||
$out->elementStart('div', array('class' => 'event-info entry-content')); // EVENT-INFO.ENTRY-CONTENT IN
|
$out->elementStart('div', array('class' => 'event-info')); // EVENT-INFO.ENTRY-CONTENT IN
|
||||||
|
|
||||||
$profile = $notice->getProfile();
|
$profile = $notice->getProfile();
|
||||||
$avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
|
$avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
|
||||||
@ -324,7 +324,11 @@ class EventPlugin extends MicroappPlugin
|
|||||||
|
|
||||||
function showRSVPNotice($notice, $out)
|
function showRSVPNotice($notice, $out)
|
||||||
{
|
{
|
||||||
$out->raw($notice->rendered);
|
$rsvp = RSVP::fromNotice($notice);
|
||||||
|
|
||||||
|
$out->elementStart('div', 'rsvp');
|
||||||
|
$out->raw($rsvp->asHTML());
|
||||||
|
$out->elementEnd('div');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +340,7 @@ class EventPlugin extends MicroappPlugin
|
|||||||
assert(!empty($event));
|
assert(!empty($event));
|
||||||
assert(!empty($profile));
|
assert(!empty($profile));
|
||||||
|
|
||||||
$out->elementStart('div', 'vevent'); // VEVENT IN
|
$out->elementStart('div', 'vevent event'); // VEVENT IN
|
||||||
|
|
||||||
$out->elementStart('h3'); // VEVENT/H3 IN
|
$out->elementStart('h3'); // VEVENT/H3 IN
|
||||||
|
|
||||||
@ -351,39 +355,63 @@ class EventPlugin extends MicroappPlugin
|
|||||||
|
|
||||||
$out->elementEnd('h3'); // VEVENT/H3 OUT
|
$out->elementEnd('h3'); // VEVENT/H3 OUT
|
||||||
|
|
||||||
|
$startDate = strftime("%x", $event->start_time);
|
||||||
|
$startTime = strftime("%R", $event->start_time);
|
||||||
|
|
||||||
|
$endDate = strftime("%x", $event->end_time);
|
||||||
|
$endTime = strftime("%R", $event->end_time);
|
||||||
|
|
||||||
// FIXME: better dates
|
// FIXME: better dates
|
||||||
|
|
||||||
$out->elementStart('div', 'event-times'); // VEVENT/EVENT-TIMES IN
|
$out->elementStart('div', 'event-times'); // VEVENT/EVENT-TIMES IN
|
||||||
|
|
||||||
|
$out->element('strong', null, _('Time:'));
|
||||||
|
|
||||||
$out->element('abbr', array('class' => 'dtstart',
|
$out->element('abbr', array('class' => 'dtstart',
|
||||||
'title' => common_date_iso8601($event->start_time)),
|
'title' => common_date_iso8601()),
|
||||||
common_exact_date($event->start_time));
|
$startDate . ' ' . $startTime);
|
||||||
$out->text(' - ');
|
$out->text(' - ');
|
||||||
|
if ($startDate == $endDate) {
|
||||||
$out->element('span', array('class' => 'dtend',
|
$out->element('span', array('class' => 'dtend',
|
||||||
'title' => common_date_iso8601($event->end_time)),
|
'title' => common_date_iso8601($event->end_time)),
|
||||||
common_exact_date($event->end_time));
|
$endTime);
|
||||||
$out->elementEnd('div'); // VEVENT/EVENT-TIMES OUT
|
} else {
|
||||||
|
$out->element('span', array('class' => 'dtend',
|
||||||
if (!empty($event->description)) {
|
'title' => common_date_iso8601($event->end_time)),
|
||||||
$out->element('div', 'description', $event->description);
|
$endDate . ' ' . $endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$out->elementEnd('div'); // VEVENT/EVENT-TIMES OUT
|
||||||
|
|
||||||
if (!empty($event->location)) {
|
if (!empty($event->location)) {
|
||||||
$out->element('div', 'location', $event->location);
|
$out->elementStart('div', 'event-location');
|
||||||
|
$out->element('strong', null, _('Location: '));
|
||||||
|
$out->element('span', 'location', $event->location);
|
||||||
|
$out->elementEnd('div');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($event->description)) {
|
||||||
|
$out->elementStart('div', 'event-description');
|
||||||
|
$out->element('strong', null, _('Description: '));
|
||||||
|
$out->element('span', 'description', $event->description);
|
||||||
|
$out->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
$rsvps = $event->getRSVPs();
|
$rsvps = $event->getRSVPs();
|
||||||
|
|
||||||
$out->element('div', 'event-rsvps',
|
$out->elementStart('div', 'event-rsvps');
|
||||||
|
$out->element('strong', null, _('Attending: '));
|
||||||
|
$out->element('span', 'event-rsvps',
|
||||||
sprintf(_('Yes: %d No: %d Maybe: %d'),
|
sprintf(_('Yes: %d No: %d Maybe: %d'),
|
||||||
count($rsvps[RSVP::POSITIVE]),
|
count($rsvps[RSVP::POSITIVE]),
|
||||||
count($rsvps[RSVP::NEGATIVE]),
|
count($rsvps[RSVP::NEGATIVE]),
|
||||||
count($rsvps[RSVP::POSSIBLE])));
|
count($rsvps[RSVP::POSSIBLE])));
|
||||||
|
$out->elementEnd('div');
|
||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
if (!empty($user)) {
|
if (!empty($user)) {
|
||||||
$rsvp = $event->getRSVP($user->getProfile());
|
$rsvp = $event->getRSVP($user->getProfile());
|
||||||
common_log(LOG_DEBUG, "RSVP is: " . ($rsvp ? $rsvp->id : 'none'));
|
|
||||||
|
|
||||||
if (empty($rsvp)) {
|
if (empty($rsvp)) {
|
||||||
$form = new RSVPForm($event, $out);
|
$form = new RSVPForm($event, $out);
|
||||||
@ -440,4 +468,10 @@ class EventPlugin extends MicroappPlugin
|
|||||||
{
|
{
|
||||||
$action->inlineScript('$(document).ready(function() { $("#startdate").datepicker(); $("#enddate").datepicker(); });');
|
$action->inlineScript('$(document).ready(function() { $("#startdate").datepicker(); $("#enddate").datepicker(); });');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onEndShowStyles($action)
|
||||||
|
{
|
||||||
|
$action->cssLink($this->path('event.css'));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,8 @@ class RSVP extends Managed_DataObject
|
|||||||
$rsvp->event_id = $event->id;
|
$rsvp->event_id = $event->id;
|
||||||
$rsvp->response = self::codeFor($verb);
|
$rsvp->response = self::codeFor($verb);
|
||||||
|
|
||||||
|
common_debug("Got value {$rsvp->response} for verb {$verb}");
|
||||||
|
|
||||||
if (array_key_exists('created', $options)) {
|
if (array_key_exists('created', $options)) {
|
||||||
$rsvp->created = $options['created'];
|
$rsvp->created = $options['created'];
|
||||||
} else {
|
} else {
|
||||||
@ -178,12 +180,9 @@ class RSVP extends Managed_DataObject
|
|||||||
|
|
||||||
// XXX: come up with something sexier
|
// XXX: come up with something sexier
|
||||||
|
|
||||||
$content = sprintf(_('RSVPed %s for an event.'),
|
$content = $rsvp->asString();
|
||||||
($verb == RSVP::POSITIVE) ? _('positively') :
|
|
||||||
($verb == RSVP::NEGATIVE) ? _('negatively') :
|
|
||||||
_('possibly'));
|
|
||||||
|
|
||||||
$rendered = $content;
|
$rendered = $rsvp->asHTML();
|
||||||
|
|
||||||
$options = array_merge(array('object_type' => $verb),
|
$options = array_merge(array('object_type' => $verb),
|
||||||
$options);
|
$options);
|
||||||
@ -209,16 +208,36 @@ class RSVP extends Managed_DataObject
|
|||||||
|
|
||||||
function codeFor($verb)
|
function codeFor($verb)
|
||||||
{
|
{
|
||||||
return ($verb == RSVP::POSITIVE) ? 'Y' :
|
switch ($verb) {
|
||||||
($verb == RSVP::NEGATIVE) ? 'N' :
|
case RSVP::POSITIVE:
|
||||||
($verb == RSVP::POSSIBLE) ? '?' : null;
|
return 'Y';
|
||||||
|
break;
|
||||||
|
case RSVP::NEGATIVE:
|
||||||
|
return 'N';
|
||||||
|
break;
|
||||||
|
case RSVP::POSSIBLE:
|
||||||
|
return '?';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception("Unknown verb {$verb}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function verbFor($code)
|
static function verbFor($code)
|
||||||
{
|
{
|
||||||
return ($code == 'Y') ? RSVP::POSITIVE :
|
switch ($code) {
|
||||||
($code == 'N') ? RSVP::NEGATIVE :
|
case 'Y':
|
||||||
($code == '?') ? RSVP::POSSIBLE : null;
|
return RSVP::POSITIVE;
|
||||||
|
break;
|
||||||
|
case 'N':
|
||||||
|
return RSVP::NEGATIVE;
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
return RSVP::POSSIBLE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception("Unknown code {$code}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotice()
|
function getNotice()
|
||||||
@ -254,4 +273,90 @@ class RSVP extends Managed_DataObject
|
|||||||
|
|
||||||
return $rsvps;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
9
plugins/Event/event.css
Normal file
9
plugins/Event/event.css
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
.event-tags li { display: inline; }
|
||||||
|
.event-mentions li { display: inline; }
|
||||||
|
.event-avatar { float: left; }
|
||||||
|
.event-notice-count { float: right; }
|
||||||
|
.event-info { float: left; }
|
||||||
|
.event-title { margin-left: 0px; }
|
||||||
|
#content .event .entry-title { margin-left: 0px; }
|
||||||
|
#content .event .entry-content { margin-left: 0px; }
|
||||||
|
|
@ -160,10 +160,12 @@ class ExtendedProfileWidget extends Form
|
|||||||
protected function showPhone($name, $field)
|
protected function showPhone($name, $field)
|
||||||
{
|
{
|
||||||
$this->out->elementStart('div', array('class' => 'phone-display'));
|
$this->out->elementStart('div', array('class' => 'phone-display'));
|
||||||
|
if (!empty($field['value'])) {
|
||||||
$this->out->text($field['value']);
|
$this->out->text($field['value']);
|
||||||
if (!empty($field['rel'])) {
|
if (!empty($field['rel'])) {
|
||||||
$this->out->text(' (' . $field['rel'] . ')');
|
$this->out->text(' (' . $field['rel'] . ')');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->out->elementEnd('div');
|
$this->out->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,6 +451,10 @@ address .poweredby {
|
|||||||
overflow:visible;
|
overflow:visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notice .automatic {
|
||||||
|
font-style:italic;
|
||||||
|
}
|
||||||
|
|
||||||
#showstream h1 {
|
#showstream h1 {
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user