Ejemplo n.º 1
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();
     }
 }