/**
  * renders a cloud from a string list 
  */
 private static function renderFromArray($tc_array)
 {
     // count all words and put them into an array
     $tc_a_tags = array();
     foreach ($tc_array as $tc_word) {
         $tc_word = strtolower(trim($tc_word));
         $tc_a_tags[$tc_word] = ktagword::getWeight($tc_word);
     }
     return self::renderImpl($tc_a_tags);
 }
 /**
  * Will return an array of kshows that are 'related' to a given show
  *
  * @param string $kshow_id
  * @return array of
  */
 public static function getRelatedShows($kshow_id, $kuser_id, $amount)
 {
     $c = new Criteria();
     $c->addJoin(kshowPeer::PRODUCER_ID, kuserPeer::ID, Criteria::INNER_JOIN);
     $c->add(kshowPeer::ID, 10000, Criteria::GREATER_EQUAL);
     //$c->add( kshowPeer::PRODUCER_ID, $kuser_id );
     // our related algorithm is based on finding shows that have similar 'heavy' tags
     if ($kshow_id) {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
         if ($kshow) {
             $tags_string = $kshow->getTags();
             if ($tags_string) {
                 $tagsweight = array();
                 foreach (ktagword::getTagsArray($tags_string) as $tag) {
                     $tagsweight[$tag] = ktagword::getWeight($tag);
                 }
                 arsort($tagsweight);
                 $counter = 0;
                 foreach ($tagsweight as $tag => $weight) {
                     if ($counter++ > 2) {
                         break;
                     } else {
                         //we'll be looking for shows that have similar top tags (3 in this case)
                         $c->addOr(kshowPeer::TAGS, '%' . $tag . '%', Criteria::LIKE);
                     }
                 }
             }
             // and of course, we don't want the show itself
             $c->addAnd(kshowPeer::ID, $kshow_id, Criteria::NOT_IN);
         }
     }
     // we want recent ones
     $c->addDescendingOrderByColumn(kshowPeer::UPDATED_AT);
     $c->setLimit($amount);
     $shows = kshowPeer::doSelectJoinKuser($c);
     //did we get enough?
     $amount_related = count($shows);
     if ($amount_related < $amount) {
         // let's get some more, which are not really related, but recent
         $c = new Criteria();
         $c->addJoin(kshowPeer::PRODUCER_ID, kuserPeer::ID, Criteria::INNER_JOIN);
         $c->addDescendingOrderByColumn(kshowPeer::UPDATED_AT);
         $c->setLimit($amount - $amount_related);
         $moreshows = kshowPeer::doSelectJoinKuser($c);
         return array_merge($shows, $moreshows);
     }
     return $shows;
 }