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');
     }
     $tags = array();
     $ptag->find();
     while ($ptag->fetch()) {
         $tags[] = $ptag->tag;
     }
     $ptag->free();
     return $tags;
 }
Example #2
0
 function hasLocalTags()
 {
     $tags = new Profile_tag();
     $tags->joinAdd(array('tagger', 'user:id'));
     $tags->whereAdd('tagged  = ' . $this->id);
     $tags->whereAdd('tagger != ' . $this->id);
     $tags->limit(0, 1);
     $tags->fetch();
     return $tags->N == 0 ? false : true;
 }
 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();
     }
 }