]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add url to events
authorEvan Prodromou <evan@status.net>
Wed, 9 Mar 2011 15:07:30 +0000 (10:07 -0500)
committerEvan Prodromou <evan@status.net>
Wed, 9 Mar 2011 15:07:30 +0000 (10:07 -0500)
plugins/Event/EventPlugin.php
plugins/Event/Happening.php
plugins/Event/RSVP.php
plugins/Event/eventform.php
plugins/Event/newevent.php

index f33de09d78c2bdb9b3f4140453d82979a5d805a5..896ecaf5c85a95a5d5c5c30d362ea2d56bb4a94d 100644 (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('&#160;'); // avoid &nbsp; 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');
     }
 
     /**
index 5ede26706b8f3fbe8139e8bd7c8abc6d226ea11c..503cd8af14623b817e0cb71a50b1d7d705a898ae 100644 (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);
     }
index 69cae4b7dc5972556c96ff0eac540ef13acf027e..851978e8193a91416a29f6f404b5d6fa433c7b61 100644 (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);
     }
index 8d108020a611fa560b56d79a3015d484ee8d165c..e6bc1e7016ae9da560c91b7da278003d3dabe891 100644 (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'),
index 365e9c14343dcab2ca65bc6f3faa047acde6f31a..7c0fd0177fc1441117c49230c2d6635678c2fb7b 100644 (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();