public function executeTagCloud() { $count = PostTagPeer::doCount(new Criteria()); $tags = TagPeer::getForCloud(); if (!empty($tags) && $count > 0) { foreach ($tags as &$tag) { $p = (double) $tag->getCount() / $count; if ($p > 0.3) { $tag->setSize('2.0'); } elseif ($p > 0.25) { $tag->setSize('1.8'); } elseif ($p > 0.2) { $tag->setSize('1.6'); } elseif ($p > 0.15) { $tag->setSize('1.4'); } else { $tag->setSize('1.0'); } } $this->tags = $tags; } else { $this->tags = array(); } }
/** * Returns the number of related PostTags. * * @param Criteria $criteria * @param boolean $distinct * @param Connection $con * @throws PropelException */ public function countPostTags($criteria = null, $distinct = false, $con = null) { // include the Peer class include_once 'lib/model/om/BasePostTagPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(PostTagPeer::TAG_ID, $this->getId()); return PostTagPeer::doCount($criteria, $distinct, $con); }