]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Usability with photos tab
authorMax Shinn <trombonechamp@gmail.com>
Mon, 27 Dec 2010 02:42:45 +0000 (20:42 -0600)
committerMax Shinn <trombonechamp@gmail.com>
Mon, 27 Dec 2010 02:42:45 +0000 (20:42 -0600)
plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php
plugins/GNUsocialPhotos/actions/photo.php
plugins/GNUsocialPhotos/actions/photos.php
plugins/GNUsocialPhotos/classes/gnusocialphoto.php

index d0a58533dfc666cb20d12262f566c69ececf2351..4ba5aee732cd73b4566fa422f1dbd95575af1cf6 100644 (file)
@@ -22,6 +22,7 @@
  * @category  Widget
  * @package   GNU Social
  * @author    Ian Denhardt <ian@zenhack.net>
+ * @author    Max Shinn    <trombonechamp@gmail.com>
  * @copyright 2010 Free Software Foundation, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  */
@@ -85,7 +86,7 @@ class GNUsocialPhotosPlugin extends Plugin
     {
         $m->connect(':nickname/photos', array('action' => 'photos'));
         $m->connect('main/uploadphoto', array('action' => 'photoupload'));
-        $m->connect(':nickname/photo/:photoid', array('action' => 'photo'));
+        $m->connect('photo/:photoid', array('action' => 'photo'));
         return true;
     }
 
@@ -162,7 +163,7 @@ class GNUsocialPhotosPlugin extends Plugin
         if($photo) { 
             $action->out->elementStart('div', 'entry-title');
             $action->showAuthor();
-            $action->out->elementStart('a', array('href' => $photo->uri));
+            $action->out->elementStart('a', array('href' => $photo->getPageLink()));
             $action->out->element('img', array('src' => $photo->thumb_uri,
                                     'width' => 256, 'height' => 192));
             $action->out->elementEnd('a');
@@ -174,9 +175,22 @@ class GNUsocialPhotosPlugin extends Plugin
         return true;
     } 
 
+    /*    function onEndShowNoticeFormData($action)
+    {
+        $link = "/main/uploadphoto";
+        $action->out->element('label', array('for' => 'photofile'),_('Attach'));
+        $action->out->element('input', array('id' => 'photofile',
+                                     'type' => 'file',
+                                     'name' => 'photofile',
+                                     'title' => _('Upload a photo')));
+    }
+    */
     function onEndPersonalGroupNav($nav)
     {
+      
         $nav->out->menuItem(common_local_url('photos',
-            array('nickname' => $nav->action->trimmed('nickname'))), 'Photos');
+                           array('nickname' => $nav->action->trimmed('nickname'))), _('Photos'), 
+                           _('Photo gallery'), $nav->action->trimmed('action') == 'photos', 'nav_photos');
     }
 }
+
index 3c2014eb8cce8787bcf5c406b04df315ed0bc8f8..64d3e16a17b4f4a7b21c1c29b008a310a824960f 100644 (file)
@@ -44,18 +44,13 @@ class PhotoAction extends Action
         parent::prepare($args);
 
         $args = $this->returnToArgs();
-        $username = $args[1]['nickname'];
                $this->photoid = $args[1]['photoid'];
-        if (common_valid_profile_tag($username) == 0) {
-            $this->user = null;
-        } else {
-            $this->user = Profile::staticGet('nickname', $username);
-        }
                $this->photo = GNUsocialPhoto::staticGet('notice_id', $this->photoid);
-               
                $this->notice = Notice::staticGet('id', $this->photoid);
-        $notices = Notice::conversationStream((int)$this->photoid-1, null, null); //Why do I have to do -1?
 
+        $this->user = Profile::staticGet('id', $this->notice->profile_id);
+               
+        $notices = Notice::conversationStream((int)$this->photoid-1, null, null); //Why do I have to do -1?
         $this->conversation = new ConversationTree($notices, $this);
         return true;
 
@@ -97,7 +92,7 @@ class PhotoAction extends Action
         $this->elementEnd('a');
                $this->element('p', array(), $this->photo->photo_description);
                //This is a hack to hide the top-level comment
-               //$this->element('style', array(), "#notice-{$this->photoid} div { display: none } #notice-{$this->photoid} ol li div { display: inline }");
+               $this->element('style', array(), "#notice-{$this->photoid} div { display: none } #notice-{$this->photoid} ol li div { display: inline }");
                $this->conversation->show();
     }
 }
index 37ec8ce32f7961a5e11b2cc2075e69dfbe41d025..7adcaadadd5dcbd0d43b8c082bcde3cece6adc94 100644 (file)
@@ -31,6 +31,8 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
+require_once INSTALLDIR.'/lib/personalgroupnav.php';
+
 class PhotosAction extends Action
 {
     var $user = null;
@@ -66,7 +68,7 @@ class PhotosAction extends Action
 
     function showLocalNav()
     {
-        $nav = new GNUsocialPhotoNav($this);
+        $nav = new PersonalGroupNav($this);
         $nav->show();
     }
 
@@ -80,21 +82,22 @@ class PhotosAction extends Action
             $page = 1;
         }
    
-        if ($page > 1) { 
-            $this->element('a', array('href' => 'photos?pageid=' . ($page-1)), 'Previous page');
-        }
-        $this->element('a', array('href' => 'photos?pageid=' . ($page+1) ), 'Next page');
-
         //TODO choice of available albums by user.
         //Currently based on fact that each user can only have one album.
         $album = GNUSocialPhotoAlbum::staticGet('profile_id', $this->user->id);
         $photos = GNUsocialPhoto::getGalleryPage($page, $album->album_id, 9);
 
+        if ($page > 1) { 
+            $this->element('a', array('href' => 'photos?pageid=' . ($page-1)), 'Previous page');
+        }
+        if (GNUsocialPhoto::getGalleryPage($page+1, $album->album_id, 9)) {
+            $this->element('a', array('href' => 'photos?pageid=' . ($page+1) ), 'Next page');
+        }
+
         $this->elementStart('ul', array('class' => 'photothumbs'));
         foreach ($photos as $photo) {
             $this->elementStart('li');
-                       $photolink = '/' . $this->user->nickname . '/photo/' . $photo->notice_id;
-            $this->elementStart('a', array('href' => $photolink));
+            $this->elementStart('a', array('href' => $photo->getPageLink()));
             $this->element('img', array('src' => $photo->thumb_uri));
             $this->elementEnd('a');
             $this->elementEnd('li');
index 5e6a63b44caebaa0dd369de7f5032fe2d986d063..34daff73bb23ca9932b78ab27a135957d1b2f4de 100644 (file)
@@ -116,6 +116,10 @@ class GNUsocialPhoto extends Memcached_DataObject
         }
     }
 
+    function getPageLink()
+    {
+        return '/photo/' . $this->notice_id;
+    }
 
     /*
      * TODO: -Sanitize input