function showEventNotice($notice, $out)
{
- $out->raw($notice->rendered);
- return;
+ $profile = $notice->getProfile();
+ $event = Happening::fromNotice($notice);
+
+ assert(!empty($event));
+ assert(!empty($profile));
+
+ $out->elementStart('div', 'vevent');
+
+ $out->elementStart('h3');
+
+ if (!empty($event->url)) {
+ $out->element('a',
+ array('href' => $att->url,
+ 'class' => 'event-title entry-title summary'),
+ $event->title);
+ } else {
+ $out->text($event->title);
+ }
+
+ $out->elementEnd('h3');
+
+ $out->elementStart('div', 'event-times');
+ $out->element('abbr', array('class' => 'dtstart',
+ 'title' => common_date_iso8601($event->start_time)),
+ common_exact_date($event->start_time));
+ $out->text(' - ');
+ $out->element('span', array('class' => 'dtend',
+ 'title' => common_date_iso8601($event->end_time)),
+ common_exact_date($event->end_time));
+ $out->elementEnd('div');
+
+ if (!empty($event->description)) {
+ $out->element('div', 'description', $event->description);
+ }
+
+ if (!empty($event->location)) {
+ $out->element('div', 'location', $event->location);
+ }
+
+ $out->elementStart('div', array('class' => 'event-info entry-content'));
+
+ $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
+
+ $out->element('img',
+ array('src' => ($avatar) ?
+ $avatar->displayUrl() :
+ Avatar::defaultImage(AVATAR_MINI_SIZE),
+ 'class' => 'avatar photo bookmark-avatar',
+ 'width' => AVATAR_MINI_SIZE,
+ 'height' => AVATAR_MINI_SIZE,
+ 'alt' => $profile->getBestName()));
+
+ $out->raw(' '); // avoid for AJAX XML compatibility
+
+ $out->elementStart('span', 'vcard author'); // hack for belongsOnTimeline; JS needs to be able to find the author
+ $out->element('a',
+ array('class' => 'url',
+ 'href' => $profile->profileurl,
+ 'title' => $profile->getBestName()),
+ $profile->nickname);
+ $out->elementEnd('span');
+
+ $out->elementEnd('div');
}
/**
public $end_time; // datetime
public $title; // varchar(255)
public $location; // varchar(255)
+ public $url; // varchar(255)
public $description; // text
public $created; // datetime
'uri' => array('type' => 'varchar',
'length' => 255,
'not null' => true),
- 'profile_id' => array('type' => 'int'),
- 'start_time' => array('type' => 'datetime'),
- 'end_time' => array('type' => 'datetime'),
+ 'profile_id' => array('type' => 'int', 'not null' => true),
+ 'start_time' => array('type' => 'datetime', 'not null' => true),
+ 'end_time' => array('type' => 'datetime', 'not null' => true),
'title' => array('type' => 'varchar',
'length' => 255,
'not null' => true),
'location' => array('type' => 'varchar',
- 'length' => 255,
- 'not null' => true),
+ 'length' => 255),
+ 'url' => array('type' => 'varchar',
+ 'length' => 255),
'description' => array('type' => 'text'),
'created' => array('type' => 'datetime',
'not null' => true),
'unique keys' => array(
'happening_uri_key' => array('uri'),
),
+ 'foreign keys' => array('happening_profile_id__key' => array('profile', array('profile_id' => 'id'))),
+ 'indexes' => array('happening_created_idx' => array('created'),
+ 'happening_start_end_idx' => array('start_time', 'end_time')),
);
}
- function saveNew($profile, $start_time, $end_time, $title, $location, $description, $options=array())
+ function saveNew($profile, $start_time, $end_time, $title, $location, $description, $url, $options=array())
{
if (array_key_exists('uri', $options)) {
$other = Happening::staticGet('uri', $options['uri']);
$ev->title = $title;
$ev->location = $location;
$ev->description = $description;
+ $ev->url = $url;
if (array_key_exists('created', $options)) {
$ev->created = $options['created'];
$options['uri'] = $ev->uri;
}
+ if (!empty($url)) {
+ $options['urls'] = array($url);
+ }
+
$saved = Notice::saveNew($profile->id,
$content,
array_key_exists('source', $options) ?
return Notice::staticGet('uri', $this->uri);
}
- static function fromNotice()
+ static function fromNotice($notice)
{
return Happening::staticGet('uri', $notice->uri);
}
return Notice::staticGet('uri', $this->uri);
}
- static function fromNotice()
+ static function fromNotice($notice)
{
return RSVP::staticGet('uri', $notice->uri);
}
_('Event location'));
$this->unli();
+ $this->li();
+ $this->out->input('url',
+ _('URL'),
+ null,
+ _('URL for more information'));
+ $this->unli();
+
$this->li();
$this->out->input('description',
_('Description'),
$this->title = $this->trimmed('title');
$this->location = $this->trimmed('location');
+ $this->url = $this->trimmed('url');
$this->description = $this->trimmed('description');
$start_date = $this->trimmed('start_date');
throw new ClientException(_('Event must have an end time.'));
}
- $saved = Happening::saveNew($this->user->getProfile(),
+ $profile = $this->user->getProfile();
+
+ $saved = Happening::saveNew($profile,
$this->start_time,
$this->end_time,
$this->title,
$this->location,
- $this->description);
+ $this->description,
+ $this->url);
} catch (ClientException $ce) {
$this->error = $ce->getMessage();