]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '1.0.x' into testing
authorEvan Prodromou <evan@status.net>
Tue, 27 Sep 2011 15:33:13 +0000 (11:33 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 27 Sep 2011 15:33:13 +0000 (11:33 -0400)
actions/publicpeopletagcloud.php [deleted file]
classes/Profile.php
classes/Profile_list.php
classes/Profile_tag.php
db/core.php
doc-src/lists
doc-src/tags
lib/peopletagnoticestream.php
lib/router.php
lib/theme.php
scripts/upgrade.php

diff --git a/actions/publicpeopletagcloud.php b/actions/publicpeopletagcloud.php
deleted file mode 100644 (file)
index cb65bbb..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * Public tag cloud for notices
- *
- * PHP version 5
- *
- * LICENCE: This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * @category  Public
- * @package   StatusNet
- * @author    Mike Cochrane <mikec@mikenz.geek.nz>
- * @author    Evan Prodromou <evan@status.net>
- * @copyright 2008 Mike Cochrane
- * @copyright 2008-2009 StatusNet, Inc.
- * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://status.net/
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-
-define('TAGS_PER_PAGE', 100);
-
-/**
- * Public tag cloud for notices
- *
- * @category Personal
- * @package  StatusNet
- * @author    Mike Cochrane <mikec@mikenz.geek.nz>
- * @author    Evan Prodromou <evan@status.net>
- * @copyright 2008 Mike Cochrane
- * @copyright 2008-2009 StatusNet, Inc.
- * @link     http://status.net/
- */
-class PublicpeopletagcloudAction extends Action
-{
-    function isReadOnly($args)
-    {
-        return true;
-    }
-
-    function title()
-    {
-        // TRANS: Title for page with public list cloud.
-        return _('Public list cloud');
-    }
-
-    function showPageNotice()
-    {
-        $this->element('p', 'instructions',
-                       // TRANS: Page notice for page with public list cloud.
-                       // TRANS: %s is a StatusNet sitename.
-                       sprintf(_('These are largest lists on %s'),
-                               common_config('site', 'name')));
-    }
-
-    function showEmptyList()
-    {
-        // TRANS: Empty list message on page with public list cloud.
-        // TRANS: This message contains Markdown links in the form [description](link).
-        $message = _('No one has [listed](%%doc.tags%%) anyone yet.') . ' ';
-
-        if (common_logged_in()) {
-            // TRANS: Additional empty list message on page with public list cloud for logged in users.
-            $message .= _('Be the first to list someone!');
-        }
-        else {
-            // TRANS: Additional empty list message on page with public list cloud for anonymous users.
-        // TRANS: This message contains Markdown links in the form [description](link).
-            $message .= _('Why not [register an account](%%action.register%%) and be the first to list someone!');
-        }
-
-        $this->elementStart('div', 'guide');
-        $this->raw(common_markup_to_html($message));
-        $this->elementEnd('div');
-    }
-
-    function showLocalNav()
-    {
-        $nav = new PublicGroupNav($this);
-        $nav->show();
-    }
-
-    function handle($args)
-    {
-        parent::handle($args);
-        $this->showPage();
-    }
-
-    function showContent()
-    {
-        // XXX: cache this
-
-        $tags = new Profile_tag();
-        $plist = new Profile_list();
-        $plist->private = false;
-
-        $tags->joinAdd($plist);
-        $tags->selectAdd();
-        $tags->selectAdd('profile_tag.tag');
-        $tags->selectAdd('count(profile_tag.tag) as weight');
-        $tags->groupBy('profile_tag.tag');
-        $tags->orderBy('weight DESC');
-
-        $tags->limit(TAGS_PER_PAGE);
-
-        $cnt = $tags->find();
-
-        if ($cnt > 0) {
-            $this->elementStart('div', array('id' => 'tagcloud',
-                                             'class' => 'section'));
-
-            $tw = array();
-            $sum = 0;
-            while ($tags->fetch()) {
-                $tw[$tags->tag] = $tags->weight;
-                $sum += $tags->weight;
-            }
-
-            ksort($tw);
-
-            $this->elementStart('dl');
-            // TRANS: DT element on on page with public list cloud.
-            $this->element('dt', null, _('List cloud'));
-            $this->elementStart('dd');
-            $this->elementStart('ul', 'tags xoxo tag-cloud');
-            foreach ($tw as $tag => $weight) {
-                if ($sum) {
-                    $weightedSum = $weight/$sum;
-                } else {
-                    $weightedSum = 0.5;
-                }
-                $this->showTag($tag, $weight, $weightedSum);
-            }
-            $this->elementEnd('ul');
-            $this->elementEnd('dd');
-            $this->elementEnd('dl');
-            $this->elementEnd('div');
-        } else {
-            $this->showEmptyList();
-        }
-    }
-
-    function showTag($tag, $weight, $relative)
-    {
-        if ($relative > 0.1) {
-            $rel =  'tag-cloud-7';
-        } else if ($relative > 0.05) {
-            $rel = 'tag-cloud-6';
-        } else if ($relative > 0.02) {
-            $rel = 'tag-cloud-5';
-        } else if ($relative > 0.01) {
-            $rel = 'tag-cloud-4';
-        } else if ($relative > 0.005) {
-            $rel = 'tag-cloud-3';
-        } else if ($relative > 0.002) {
-            $rel = 'tag-cloud-2';
-        } else {
-            $rel = 'tag-cloud-1';
-        }
-
-        $this->elementStart('li', $rel);
-
-        // TRANS: Link title for number of listed people. %d is the number of listed people.
-        $title = sprintf(_m('1 person listed','%d people listed',$weight),$weight);
-        $this->element('a', array('href'  => common_local_url('peopletag', array('tag' => $tag)),
-                                  'title' => $title), $tag);
-        $this->elementEnd('li');
-    }
-}
index 7f45031f6655a9ea8f0e9198ac83c68470c75b7c..f983225fd5df7a341c29915eee2bf81d0820b4c0 100644 (file)
@@ -436,42 +436,55 @@ class Profile extends Managed_DataObject
         return new ArrayWrapper($lists);
     }
 
+    /**
+     * Get tags that other people put on this profile, in reverse-chron order
+     *
+     * @param (Profile|User) $auth_user  Authorized user (used for privacy)
+     * @param int            $offset     Offset from latest
+     * @param int            $limit      Max number to get
+     * @param datetime       $since_id   max date
+     * @param datetime       $max_id     min date
+     *
+     * @return Profile_list resulting lists
+     */
+
     function getOtherTags($auth_user=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
     {
-        $lists = new Profile_list();
+        $list = new Profile_list();
 
-        $tags = new Profile_tag();
-        $tags->tagged = $this->id;
+        $qry = sprintf('select profile_list.*, unix_timestamp(profile_tag.modified) as "cursor" ' .
+                       'from profile_tag join profile_list '.
+                       'on (profile_tag.tagger = profile_list.tagger ' .
+                       '    and profile_tag.tag = profile_list.tag) ' .
+                       'where profile_tag.tagged = %d ',
+                       $this->id);
 
-        $lists->joinAdd($tags);
-
-        #@fixme: postgres (round(date_part('epoch', my_date)))
-        $lists->selectAdd('unix_timestamp(profile_tag.modified) as "cursor"');
 
         if ($auth_user instanceof User || $auth_user instanceof Profile) {
-            $lists->whereAdd('( ( profile_list.private = false ) ' .
-                             'OR ( profile_list.tagger = ' . $auth_user->id . ' AND ' .
-                             'profile_list.private = true ) )');
+            $qry .= sprintf('AND ( ( profile_list.private = false ) ' .
+                            'OR ( profile_list.tagger = %d AND ' .
+                            'profile_list.private = true ) )',
+                            $auth_user->id);
         } else {
-            $lists->private = false;
+            $qry .= 'AND profile_list.private = 0 ';
         }
 
-        if ($since_id>0) {
-           $lists->whereAdd('cursor > '.$since_id);
+        if ($since_id > 0) {
+            $qry .= sprintf('AND (cursor > %d) ', $since_id);
         }
 
-        if ($max_id>0) {
-            $lists->whereAdd('cursor <= '.$max_id);
+        if ($max_id > 0) {
+            $qry .= sprintf('AND (cursor < %d) ', $max_id);
         }
 
-        if($offset>=0 && !is_null($limit)) {
-            $lists->limit($offset, $limit);
-        }
+        $qry .= 'ORDER BY profile_tag.modified DESC ';
 
-        $lists->orderBy('profile_tag.modified DESC');
-        $lists->find();
+        if ($offset >= 0 && !is_null($limit)) {
+            $qry .= sprintf('LIMIT %d OFFSET %d ', $limit, $offset);
+        }
 
-        return $lists;
+        $list->query($qry);
+        return $list;
     }
 
     function getPrivateTags($offset=0, $limit=null, $since_id=0, $max_id=0)
index c433a53fee5d865edff350cb9e63739cbf8df8d7..27001978b6dd1ca9de26b02f67fdd9084aa97d8e 100644 (file)
@@ -221,7 +221,10 @@ class Profile_list extends Managed_DataObject
     {
         $subs = new Profile();
 
-        $subs->joinAdd(array('id', 'profile_tag_subscription:profile_tag_id'));
+        $subs->joinAdd(
+            array('id', 'profile_tag_subscription:profile_id')
+        );
+        $subs->whereAdd('profile_tag_subscription.profile_tag_id = ' . $this->id);
 
         $subs->selectAdd('unix_timestamp(profile_tag_subscription.' .
                          'created) as "cursor"');
index d9b094182f1dcb7e11b343d0a2f232e00e4fc8d6..07ed160d19c5f7e51ab8de0ff9110e87be464346 100644 (file)
@@ -79,20 +79,17 @@ class Profile_tag extends Managed_DataObject
             return $tags;
         }
 
-        $profile_tag = new Profile_tag();
-        $profile_list->tagger = $tagger;
-        $profile_tag->tagged = $tagged;
-
-        $profile_list->selectAdd();
+        $qry = 'select profile_list.* from profile_list left join '.
+               'profile_tag on (profile_list.tag = profile_tag.tag and '.
+               'profile_list.tagger = profile_tag.tagger) where '.
+               'profile_tag.tagger = %d and profile_tag.tagged = %d ';
+        $qry = sprintf($qry, $tagger, $tagged);
+
+        if (!$include_priv) {
+            $qry .= ' and profile_list.private = 0';
+        }
 
-        // only fetch id, tag, mainpage and
-        // private hoping this will be faster
-        $profile_list->selectAdd('profile_list.id, ' .
-                                 'profile_list.tag, ' .
-                                 'profile_list.mainpage, ' .
-                                 'profile_list.private');
-        $profile_list->joinAdd($profile_tag);
-        $profile_list->find();
+        $profile_list->query($qry);
 
         Profile_list::setCache($key, $profile_list);
 
@@ -102,23 +99,26 @@ class Profile_tag extends Managed_DataObject
     static function getTagsArray($tagger, $tagged, $auth_user_id=null)
     {
         $ptag = new Profile_tag();
-        $ptag->tagger = $tagger;
-        $ptag->tagged = $tagged;
-
-        if ($tagger != $auth_user_id) {
-            $list = new Profile_list();
-            $list->private = false;
-            $ptag->joinAdd($list);
-            $ptag->selectAdd();
-            $ptag->selectAdd('profile_tag.tag');
+
+        $qry = sprintf('select profile_tag.tag '.
+                       'from profile_tag join profile_list '.
+                       ' on (profile_tag.tagger = profile_list.tagger ' .
+                       '     and profile_tag.tag = profile_list.tag) ' .
+                       'where profile_tag.tagger = %d ' .
+                       'and   profile_tag.tagged = %d ',
+                       $tagger, $tagged);
+
+        if ($auth_user_id != $tagger) {
+            $qry .= 'and profile_list.private = 0';
         }
 
         $tags = array();
-        $ptag->find();
+
+        $ptag->query($qry);
+
         while ($ptag->fetch()) {
             $tags[] = $ptag->tag;
         }
-        $ptag->free();
 
         return $tags;
     }
index b7881a7dc0d6f72ad1808e4004b5be119786d124..bf8cae3c4b83a0146989f6b2e7477063097e21eb 100644 (file)
@@ -29,7 +29,8 @@
  *     double-check what we've been doing on postgres?
  */
 
-$classes = array('Profile',
+$classes = array('Schema_version',
+                 'Profile',
                  'Avatar',
                  'Sms_carrier',
                  'User',
@@ -85,7 +86,6 @@ $classes = array('Profile',
                  'Conversation',
                  'Local_group',
                  'User_urlshortener_prefs',
-                 'Schema_version',
                  'Old_school_prefs',
 );
 
index b2e93aa85362f98412b878a6fc4eeda5f81f66be..01c5d3b65fc1398ace7ad1a2890a6979f91593de 100644 (file)
@@ -56,10 +56,6 @@ private prepend a '.' to the tag in the tags editing box. To set
 an existing public tag as private or vice-versa, go to the tag's
 edit page.
 
-The most used public tags are displayed in the
-[public people tag cloud](%%action.publicpeopletagcloud%%). Their
-size shows their frequency of use.
-
 Remote people tags
 ------------------
 
index b2e93aa85362f98412b878a6fc4eeda5f81f66be..3e9065a100d13611228c1b1f066bb89f78ec317e 100644 (file)
@@ -17,10 +17,6 @@ latin characters are not supported, and non-roman scripts are right out.
 The HTML for the notice will link to a stream of all the other notices
 with that tag. This can be a great way to keep track of a conversation.
 
-The most popular current tags on the site can be found in the [public
-tag cloud](%%action.publictagcloud%%). Their size shows their
-popularity and recency.
-
 Tagging yourself
 ----------------
 
index e82d754e8d63e4da324630eac6facad37df8ad64..4422261ae9a6950881d7823ea1c1190b1123a894 100644 (file)
@@ -96,10 +96,12 @@ class RawPeopletagNoticeStream extends NoticeStream
         $notice->selectAdd();
         $notice->selectAdd('notice.id');
 
+        $ptag = new Profile_tag();
+        $ptag->tag    = $this->profile_list->tag;
+        $ptag->tagger = $this->profile_list->tagger;
         $notice->joinAdd(array('profile_id', 'profile_tag:tagged'));
-
+        $notice->whereAdd('profile_tag.tagger = ' . $this->profile_list->tagger);
         $notice->whereAdd(sprintf('profile_tag.tag = "%s"', $this->profile_list->tag));
-        $notice->whereAdd(sprintf('profile_tag.tagger = %d', $this->profile_list->tagger));
 
         if ($since_id != 0) {
             $notice->whereAdd('notice.id > ' . $since_id);
index b0124375deb62726d3e8b00507c13a54963a17b8..2011d2708c297473831cd303b39c9d54e4dba17d 100644 (file)
@@ -904,10 +904,6 @@ class Router
 
                 // people tags
 
-                if (!common_config('performance', 'high')) {
-                    $m->connect('peopletags', array('action' => 'publicpeopletagcloud'));
-                }
-
                 $m->connect('peopletag/:tag', array('action' => 'peopletag',
                                                     'tag'    => self::REGEX_TAG));
 
index 1239e317f4e9cab68440a00fae206a4ccbb76838..fbcbbe052a3934eaad47fdd94d28ed15f1506dfd 100644 (file)
@@ -106,9 +106,9 @@ class Theme
 
         // Ruh roh. Fall back to default, then.
 
-        common_log(LOG_WARN, sprintf("Unable to find theme '%s', falling back to default theme '%s'",
-                                     $name,
-                                     Theme::FALLBACK));
+        common_log(LOG_WARNING, sprintf("Unable to find theme '%s', falling back to default theme '%s'",
+                                        $name,
+                                        Theme::FALLBACK));
 
         $this->name = Theme::FALLBACK;
         $this->dir  = $instroot.'/'.Theme::FALLBACK;
index 1bf444267cd54b7db7c5766c4792161c6ec1cacb..7d81c1983504f1fd8797a789901b118e5a76e31c 100644 (file)
@@ -52,6 +52,8 @@ function main()
         initSubscriptionURI();
         initGroupMemberURI();
 
+        initProfileLists();
+
         Event::handle('EndUpgrade');
     }
 }
@@ -374,4 +376,47 @@ function initGroupMemberURI()
     printfnq("DONE.\n");
 }
 
+function initProfileLists()
+{
+    printfnq("Ensuring all profile tags have a corresponding list...");
+
+    $ptag = new Profile_tag();
+    $ptag->selectAdd();
+    $ptag->selectAdd('tagger, tag, count(*) as tagged_count');
+    $ptag->whereAdd('NOT EXISTS (SELECT tagger, tagged from profile_list '.
+                    'where profile_tag.tagger = profile_list.tagger '.
+                    'and profile_tag.tag = profile_list.tag)');
+    $ptag->groupBy('tagger, tag');
+    $ptag->orderBy('tagger, tag');
+
+    if ($ptag->find()) {
+        while ($ptag->fetch()) {
+            $plist = new Profile_list();
+
+            $plist->tagger   = $ptag->tagger;
+            $plist->tag      = $ptag->tag;
+            $plist->private  = 0;
+            $plist->created  = common_sql_now();
+            $plist->modified = $plist->created;
+            $plist->mainpage = common_local_url('showprofiletag',
+                                                array('tagger' => $plist->getTagger()->nickname,
+                                                      'tag'    => $plist->tag));;
+
+            $plist->tagged_count     = $ptag->tagged_count;
+            $plist->subscriber_count = 0;
+
+            $plist->insert();
+
+            $orig = clone($plist);
+            // After insert since it uses auto-generated ID
+            $plist->uri      = common_local_url('profiletagbyid',
+                                        array('id' => $plist->id, 'tagger_id' => $plist->tagger));
+
+            $plist->update($orig);
+        }
+    }
+
+    printfnq("DONE.\n");
+}
+
 main();