From 21873b806d6c5cf3e55ea10e49959c944f708688 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Fri, 17 Apr 2009 16:46:49 +0000 Subject: [PATCH 1/5] cosmetic fixes. --- lib/searchaction.php | 2 +- lib/tagcloudsection.php | 124 ---------------------------------------- lib/util.php | 3 +- 3 files changed, 3 insertions(+), 126 deletions(-) delete mode 100644 lib/tagcloudsection.php diff --git a/lib/searchaction.php b/lib/searchaction.php index e74450e11f..e7ad4affda 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -51,7 +51,7 @@ class SearchAction extends Action * * @return boolean true */ - function isReadOnly($args) + function isReadOnly() { return true; } diff --git a/lib/tagcloudsection.php b/lib/tagcloudsection.php deleted file mode 100644 index ff2aca6d6e..0000000000 --- a/lib/tagcloudsection.php +++ /dev/null @@ -1,124 +0,0 @@ -. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @copyright 2009 Control Yourself, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -if (!defined('LACONICA')) { - exit(1); -} - -define('TAGS_PER_SECTION', 20); - -/** - * Base class for sections - * - * These are the widgets that show interesting data about a person - * group, or site. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -class TagCloudSection extends Section -{ - function showContent() - { - $tags = $this->getTags(); - - if (!$tags) { - $this->out->element('p', null, _('None')); - return false; - } - - $cnt = 0; - - $tw = array(); - $sum = 0; - - while ($tags->fetch() && ++$cnt <= TAGS_PER_SECTION) { - $tw[$tags->tag] = $tags->weight; - $sum += $tags->weight; - } - - if ($cnt == 0) { - $this->out->element('p', null, _('(None)')); - return false; - } - - ksort($tw); - - $this->out->elementStart('ul', 'tags xoxo tag-cloud'); - foreach ($tw as $tag => $weight) { - $this->showTag($tag, $weight, ($sum == 0) ? 0 : $weight/$sum); - } - $this->out->elementEnd('ul'); - - return ($cnt > TAGS_PER_SECTION); - } - - function getTags() - { - return null; - } - - 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->out->elementStart('li', $rel); - $this->out->element('a', array('href' => $this->tagUrl($tag)), - $tag); - $this->out->elementEnd('li'); - } - - function tagUrl($tag) - { - return common_local_url('tag', array('tag' => $tag)); - } - - function divId() - { - return 'tagcloud'; - } -} diff --git a/lib/util.php b/lib/util.php index 675ff51f01..5d16e39b56 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1333,4 +1333,5 @@ function common_database_tablename($tablename) } //table prefixes could be added here later return $tablename; -} \ No newline at end of file +} + From 2e06d5a2cb0d05d944bd0f969dbf5a0b10a1d48e Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Fri, 17 Apr 2009 17:24:41 +0000 Subject: [PATCH 2/5] file was removed by mistake. --- lib/tagcloudsection.php | 142 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 lib/tagcloudsection.php diff --git a/lib/tagcloudsection.php b/lib/tagcloudsection.php new file mode 100644 index 0000000000..f5c305c65f --- /dev/null +++ b/lib/tagcloudsection.php @@ -0,0 +1,142 @@ +. + * + * @category Widget + * @package Laconica + * @author Evan Prodromou + * @copyright 2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +define('TAGS_PER_SECTION', 20); + +/** + * Base class for sections + * + * These are the widgets that show interesting data about a person + * group, or site. + * + * @category Widget + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class TagCloudSection extends Section +{ + function showContent() + { + $tags = $this->getAllTags(); + + if (!$tags) { + $this->out->element('p', null, _('None')); + return false; + } + + $cnt = count($tags); + + if ($cnt == 0) { + $this->out->element('p', null, _('(None)')); + return false; + } + + ksort($tags); + + $this->out->elementStart('ul', 'tags xoxo tag-cloud'); + foreach ($tags as $tag => $weight) { + $this->showTag($tag, $weight, ($sum == 0) ? 0 : $weight/$sum); + } + $this->out->elementEnd('ul'); + + return ($cnt > TAGS_PER_SECTION); + } + + function getTags($lst, $usr) + { + $profile_tag = new Profile_tag; + $profile_tag->selectAdd(); + $profile_tag->selectAdd('tag'); + $profile_tag->selectAdd('count(tag) as weight'); + $profile_tag->groupBy('tag'); + $profile_tag->orderBy('weight DESC'); + $cnt = $profile_tag->find(); + + $profile_tag->query(" +SELECT tag, count(tag) as weight from profile_tag, (SELECT subscriber, subscribed from subscription where subscriber=$usr and subscribed != subscriber) as t where tagger=subscriber and tagged=subscribed group by tag order by weight dest"); + + $tags = array(); + while ($profile_tag->fetch()) { +// var_dump($profile_tag); + $tags[$profile_tag->tag] = $profile_tag->weight; + } + $profile_tag->free(); + if (0) { + echo 'tags:
';
+            var_dump($tags);
+            echo '
'; + } + return $tags; + } + + function getAllTags() { + return null; + } + + 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->out->elementStart('li', $rel); + $this->out->element('a', array('href' => $this->tagUrl($tag)), + $tag); + $this->out->elementEnd('li'); + } + + function tagUrl($tag) + { + return common_local_url('tag', array('tag' => $tag)); + } + + function divId() + { + return 'tagcloud'; + } +} From 2873940265611d6556eaee7a01dd53587d7ef446 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Fri, 17 Apr 2009 17:31:22 +0000 Subject: [PATCH 3/5] Fixed file that was removed by mistake. --- lib/tagcloudsection.php | 44 ++++++++++++----------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/lib/tagcloudsection.php b/lib/tagcloudsection.php index f5c305c65f..ff2aca6d6e 100644 --- a/lib/tagcloudsection.php +++ b/lib/tagcloudsection.php @@ -50,24 +50,32 @@ class TagCloudSection extends Section { function showContent() { - $tags = $this->getAllTags(); + $tags = $this->getTags(); if (!$tags) { $this->out->element('p', null, _('None')); return false; } - $cnt = count($tags); + $cnt = 0; + + $tw = array(); + $sum = 0; + + while ($tags->fetch() && ++$cnt <= TAGS_PER_SECTION) { + $tw[$tags->tag] = $tags->weight; + $sum += $tags->weight; + } if ($cnt == 0) { $this->out->element('p', null, _('(None)')); return false; } - ksort($tags); + ksort($tw); $this->out->elementStart('ul', 'tags xoxo tag-cloud'); - foreach ($tags as $tag => $weight) { + foreach ($tw as $tag => $weight) { $this->showTag($tag, $weight, ($sum == 0) ? 0 : $weight/$sum); } $this->out->elementEnd('ul'); @@ -75,34 +83,8 @@ class TagCloudSection extends Section return ($cnt > TAGS_PER_SECTION); } - function getTags($lst, $usr) + function getTags() { - $profile_tag = new Profile_tag; - $profile_tag->selectAdd(); - $profile_tag->selectAdd('tag'); - $profile_tag->selectAdd('count(tag) as weight'); - $profile_tag->groupBy('tag'); - $profile_tag->orderBy('weight DESC'); - $cnt = $profile_tag->find(); - - $profile_tag->query(" -SELECT tag, count(tag) as weight from profile_tag, (SELECT subscriber, subscribed from subscription where subscriber=$usr and subscribed != subscriber) as t where tagger=subscriber and tagged=subscribed group by tag order by weight dest"); - - $tags = array(); - while ($profile_tag->fetch()) { -// var_dump($profile_tag); - $tags[$profile_tag->tag] = $profile_tag->weight; - } - $profile_tag->free(); - if (0) { - echo 'tags:
';
-            var_dump($tags);
-            echo '
'; - } - return $tags; - } - - function getAllTags() { return null; } From b22f446df2384c5bd3fa5cf428106ea0a62f1b7d Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 17 Apr 2009 19:51:20 +0000 Subject: [PATCH 4/5] Clear notice char counter for direct messages as well. --- js/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index 38d2a9a424..3753bd9898 100644 --- a/js/util.js +++ b/js/util.js @@ -179,12 +179,12 @@ $(document).ready(function(){ } else { $("#notices_primary .notices").prepend(document._importNode($("li", xml).get(0), true)); - counter(); $("#notices_primary .notice:first").css({display:"none"}); $("#notices_primary .notice:first").fadeIn(2500); NoticeHover(); NoticeReply(); } + counter(); $("#notice_data-text").val(""); } $("#form_notice").removeClass("processing"); From 81714c6c31569e35f6b068791870bdfec25d005c Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 17 Apr 2009 20:14:06 +0000 Subject: [PATCH 5/5] counter() after val() reset to avoid (weird) bug. --- js/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index 3753bd9898..53e6eb7923 100644 --- a/js/util.js +++ b/js/util.js @@ -184,8 +184,8 @@ $(document).ready(function(){ NoticeHover(); NoticeReply(); } - counter(); $("#notice_data-text").val(""); + counter(); } $("#form_notice").removeClass("processing"); $("#notice_action-submit").removeAttr("disabled");