/**
  * Render a view
  * 
  * @param	string		$view		Type of View
  * @param	integer		$relId		Relationship ID
  * @param	array		$opts		Options
  * @param	integer		$memberId	Member ID
  * @return	@e string	Formatted HTML
  * @todo	If $cache['count'] is 0, we can probably skip the getDataByMemberIdAndRelationshipId() call as it will be empty
  */
 public function render($view, $relId, $opts = array(), $memberId = null)
 {
     /* In the future we could abstract this out to its own class 
      *  At this time we only have a few views so it would be overkill */
     if ($view == 'summary') {
         $data = array('names' => array(), 'count' => 0, 'formatted' => '', 'iLike' => false, 'iLikeAnon' => false);
         $cache = $this->likeCache->get($relId, $memberId);
         $max = 0;
         /* Fetch data for us? */
         if ($this->memberData['member_id'] && $cache['count'] + $cache['count_anon'] > 0) {
             /* We can't use isLiked or it runs twice the query and adding a cache to the function doesn't work either */
             $_me = $this->getDataByMemberIdAndRelationshipId($relId, $this->memberData['member_id']);
             if (is_array($_me) && count($_me) && $_me['like_id']) {
                 /* Now mix up the data */
                 $data['names'][] = array('name' => $this->lang->words['fave_moi'], 'seo' => $this->memberData['members_seo_name'], 'id' => $this->memberData['member_id']);
                 /* Flag as me */
                 $data['iLike'] = true;
                 /* Anonymous? Let the template know */
                 if ($_me['like_is_anon']) {
                     $data['iLikeAnon'] = true;
                 }
             }
         }
         /* We had the total count set from cache.get - doesn't count anonymous members thought! */
         if (classes_like_registry::getTotalCount()) {
             if (is_array($cache['members'])) {
                 $i = 1;
                 $max = 3;
                 foreach ($cache['members'] as $mid => $mdata) {
                     $_last = $i == $cache['count'] || $i == $max ? 1 : 0;
                     /* Is this you? */
                     if ($mid == $this->memberData['member_id']) {
                         continue;
                     }
                     /* Push it on */
                     $data['names'][] = array('name' => $mdata['n'], 'seo' => $mdata['s'], 'id' => $mid, 'last' => $_last);
                     $i++;
                     if ($i > $max) {
                         /* Done thanks */
                         break;
                     }
                 }
             }
         }
         /* Finish off */
         $data['totalCount'] = $cache['count'] + $cache['count_anon'];
         $data['anonCount'] = $cache['count_anon'];
         $data['othersCount'] = $cache['count'] > $max ? $cache['count'] - $max : 0;
         $data['app'] = $this->_app;
         $data['area'] = $this->_area;
         $data['formatted'] = $this->_formatNameString($data);
         $data['vernacular'] = $this->getVernacular();
         if (IPS_IS_AJAX) {
             $_template = $this->templatePrefix() . 'likeSummaryContents';
             /* Got an override template? */
             if (method_exists($this->registry->output->getTemplate($this->skin()), $_template)) {
                 return $this->registry->output->getTemplate($this->skin())->{$_template}($data, $relId, $opts);
             } else {
                 /* Fallback on default template */
                 return $this->registry->output->getTemplate('global_other')->likeSummaryContents($data, $relId, $opts);
             }
         } else {
             $_template = $this->templatePrefix() . 'likeSummary';
             /* Got an override template? */
             if (method_exists($this->registry->output->getTemplate($this->skin()), $_template)) {
                 return $this->registry->output->getTemplate($this->skin())->{$_template}($data, $relId, $opts);
             } else {
                 /* Fallback on default template */
                 return $this->registry->output->getTemplate('global_other')->likeSummary($data, $relId, $opts);
             }
         }
     } else {
         if ($view == 'more') {
             /* We need some counts here because we need them! */
             $cache = $this->likeCache->get($relId, $memberId);
             $cache['totalCount'] = $cache['count'] + $cache['count_anon'];
             $cache['anonCount'] = $cache['count_anon'];
             /* Fetch members who have wanted to like this item */
             $data = $this->getDataByRelationshipId($relId);
             $_template = $this->templatePrefix() . 'likeMoreDialogue';
             /* Sort out some numbers if we're following anonymously */
             if ($this->memberData['member_id'] && isset($data[$this->memberData['member_id']]) && $data[$this->memberData['member_id']]['like_is_anon']) {
                 $cache['count_anon']--;
                 $cache['anonCount']--;
             }
             /* Got an override template? */
             if (method_exists($this->registry->output->getTemplate($this->skin()), $_template)) {
                 return $this->registry->output->getTemplate($this->skin())->{$_template}($data, $relId, $cache);
             } else {
                 /* Fallback on default template */
                 return $this->registry->output->getTemplate('global_other')->likeMoreDialogue($data, $relId, $cache);
             }
         }
     }
 }