add url to events

This commit is contained in:
Evan Prodromou 2011-03-09 10:07:30 -05:00
parent 53e67b5ed5
commit f00f5f20b8
5 changed files with 94 additions and 12 deletions

View File

@ -300,8 +300,69 @@ class EventPlugin extends MicroappPlugin
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');
}
/**

View File

@ -60,6 +60,7 @@ class Happening extends Managed_DataObject
public $end_time; // datetime
public $title; // varchar(255)
public $location; // varchar(255)
public $url; // varchar(255)
public $description; // text
public $created; // datetime
@ -92,15 +93,16 @@ class Happening extends Managed_DataObject
'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),
@ -109,10 +111,13 @@ class Happening extends Managed_DataObject
'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']);
@ -130,6 +135,7 @@ class Happening extends Managed_DataObject
$ev->title = $title;
$ev->location = $location;
$ev->description = $description;
$ev->url = $url;
if (array_key_exists('created', $options)) {
$ev->created = $options['created'];
@ -177,6 +183,10 @@ class Happening extends Managed_DataObject
$options['uri'] = $ev->uri;
}
if (!empty($url)) {
$options['urls'] = array($url);
}
$saved = Notice::saveNew($profile->id,
$content,
array_key_exists('source', $options) ?
@ -191,7 +201,7 @@ class Happening extends Managed_DataObject
return Notice::staticGet('uri', $this->uri);
}
static function fromNotice()
static function fromNotice($notice)
{
return Happening::staticGet('uri', $notice->uri);
}

View File

@ -192,7 +192,7 @@ class RSVP extends Managed_DataObject
return Notice::staticGet('uri', $this->uri);
}
static function fromNotice()
static function fromNotice($notice)
{
return RSVP::staticGet('uri', $notice->uri);
}

View File

@ -133,6 +133,13 @@ class EventForm extends Form
_('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'),

View File

@ -91,6 +91,7 @@ class NeweventAction extends Action
$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');
@ -146,12 +147,15 @@ class NeweventAction extends Action
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();