<?php
    if(dw_campaigns_get_selected_type()!='walking') {
        $pcp = dw_campaigns_user_get_pcp_for_campaign($user, $campaign);
    } else {
        $pcp = dw_campaigns_user_get_pcp_for_walking($user);
    }
    if(is_null($pcp->id)) {
        echo t('you do not have any active personal campaign pages');
        return;
    }

    $params = dw_campaigns_get_merge_object($campaign, $pcp);
    $rawurl = dw_campaigns_user_get_pcp_url($user, $campaign, TRUE);

    $url = urlencode($rawurl);
    $text = urlencode( t('Help me support !title', array('!title' => $campaign->title)) );
    $twitter_text = variable_get('dw-campaigns-twitter-text', $text);
    $facebook_text = variable_get('dw-campaigns-facebook-text', $text);

    dw_campaigns_do_merge($twitter_text, $params);
    dw_campaigns_do_merge($facebook_text, $params);
    dw_campaigns_do_merge($text, $params);
    dw_campaigns_do_merge($form['invitation-text'], $params);
?>

<a class="twitter_share" target="_blank" href="http://twitter.com/share?url=<?php echo $url; ?>&text=<?php echo $twitter_text; ?>"> <img src="http://twitter.com/images/goodies/tweetn.png"><span><?php echo t('Tweet on Twitter'); ?></span></a>
<a class="facebook_share" target="_blank" href="http://www.facebook.com/sharer.php?u=<?php echo $url; ?>&t=<?php echo $facebook_text; ?>"> <img src="http://facebook.com/images/connect_favicon.png"><span><?php echo t('Share on Facebook'); ?></span></a>



        
<?php
if(dw_campaigns_get_selected_type()!='derby')
    return;
?>
<div class="derby-header-right">
    <div class="account-box">
    <?php
        if($user->uid>0) {
    ?>
            <?php echo t('Signed in as !name', array('!name' => $user->name)); ?> <a href="/logout?destination=dw" class="btn"><?php echo t('Logout'); ?></a>
    <?php
            $pcps       = _dw_campaigns_get_pcps_for_campaign_keyed_by_contact_ids($campaign);
            $contact_id = _dw_campaigns_user_get_contact_id($user);
            if(isset($pcps[$contact_id])) {
                $campaignId = dw_campaigns_get_default_campaign();
                $campaign   = node_load($campaignId);
                // drupal 'l' doesn't like leading /'s
                $url        = substr(dw_campaigns_user_get_pcp_url($user, $campaign), 1);
                echo '<a href="' . $url . '" class="goto-page">' . t('Go to my page') . '</a>';
            }
        } else {
            echo l(t('Sign In'),"dw/user/login");        
            echo l(t('Sign Up'),"dw/user/register");
        }
    ?>
    </div>
</div>
    <span class="total"><?php echo $goalTotal;?></span>
    <div class="progress-bar progress-yellow progress-pcp"><div class="progress-inner" style="width:<?php echo $goalPercent;?>%"><span><?php echo $goalPercent;?>%</span></div></div>
    <span class="outro">and put them in</span>
    <span class="position-number"><?php echo $position_name;?></span>
    <span class="position-place">Place</span>
-->
    <div class="updated-leaderboard">
        <h2>Updated Leaderboard</h2>
            <table>
        <?php
            $i = 0;
            foreach($pos as $contact_id => $total) {
                $i++;
                $drupal_id      = _dw_campaigns_contact_id_get_user($contact_id);
                $fake_user      = user_load(array('uid'=>$drupal_id));
                $url            = dw_campaigns_user_get_pcp_url($fake_user, $campaign);
        
                $image_match    = '';
                $image_params   = array(
                    'w'                 => 100,
                    'contribution'      => true,
                );
                
                $photo          = _dw_campaigns_get_photo($fake_user, $image_params, 'user-photo', NULL, $image_match);
    
        
				$class = ($contact_id == $pcp->contact_id) ? 'me' : '';
        ?>
                <tr class="<?php echo $class; ?>">
                    <td class="name">
                        <img src="<?php echo $photo; ?>" width="25"> <a href="<?php echo $url; ?>"> <?php echo $fake_user->displayname;?></a>