示例#1
0
} else {
    return;
}
$fontpath = realpath($modulesBasePath . '/images');
//replace . with a different directory if needed
putenv('GDFONTPATH=' . $fontpath);
// General settings
$padding = 10;
$image = imagecreatefrompng($modulesBasePath . '/images/widget.png');
$font['size'] = 40;
$font['angle'] = 0;
$font['file'] = 'Serpentine.ttf';
$font['color'] = imagecolorallocate($image, 0, 0, 0);
$font['minSize'] = 15;
// "Hours" settings
$hours['text'] = dbGetHoursForTeam($TID);
$hours['pos']['x'] = 132;
$hours['pos']['y'] = 114;
$hours['boundary']['side'] = 'left';
$hours['boundary']['x'] = 34 + $padding;
// "Outreaches" settings
$outreaches['text'] = dbGetNumOutreachForTeam($TID);
$outreaches['pos']['x'] = 351;
$outreaches['pos']['y'] = 114;
$outreaches['boundary']['side'] = 'right';
$outreaches['boundary']['x'] = 446 - $padding;
ob_clean();
// ensure output is clean before adding header
header('Content-Type: image/png');
$sizeOne = calculateSize($outreaches['text'], $font, $outreaches['pos'], $outreaches['boundary']);
$sizeTwo = calculateSize($hours['text'], $font, $hours['pos'], $hours['boundary']);
示例#2
0
function viewTeamStatistics()
{
    global $user;
    $params = drupal_get_query_parameters();
    $UID = $user->uid;
    if (isset($params['TID'])) {
        $TID = $params['TID'];
        $team = dbGetTeam($TID);
        $teamNumber = $team['number'];
    } else {
        $currentTeam = getCurrentTeam();
        $TID = $currentTeam['TID'];
        $teamNumber = $currentTeam['number'];
    }
    // checks if team has permission to acces page
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $markup = "<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js\"></script>";
    $markup .= '<script src="numberCounting.js"></script>';
    // create table and header
    $markup .= '<table id="teamStats"><tr><td colspan="2" style="text-align:center">';
    $markup .= '<div class="help tooltip1">';
    $markup .= '<h2><b>Team Stats</b></h2>';
    $markup .= '<span id="helptext"; class="helptext tooltiptext1">';
    $markup .= 'These are the total numbers of hours and outreaches your team has inputted into CROMA.';
    $markup .= '</span></div>';
    $markup .= '</td></tr>';
    // links to all team outreach page
    $markup .= '<tr><td style="text-align:center"><a href="?q=outreach&allTeamOutreach"><b>HOURS</b></a></td>';
    $markup .= '<td style="text-align:center"><a href="?q=outreach&allTeamOutreach"><b>OUTREACHES</b></a></td></tr>';
    $markup .= '<tr style="font-size:48pt; font-family: "Open Sans", sans-serif;"><td style="text-align:center"><b class="countUp">' . dbGetHoursForTeam($TID) . '</a></b></td>';
    $markup .= '<td style="text-align:center"><b class="countUp">' . dbGetNumOutreachForTeam($TID);
    $markup .= '</b></td></tr></table>';
    return array('#markup' => $markup);
}
<?php

/*
  ---- widgets/fancyScrollingStats.php ----
  returns JSON-encoded stats data for a team (when called by fancyScrollingStats.js)
*/
// quick check to determine if this is the release version
// normally this would be set through a define in Drupal
if ($_SERVER['SERVER_PORT'] == ':80') {
    $basePath = '/var/www-croma/database-release';
} else {
    $basePath = '/var/www-croma/database';
}
include $basePath . '/croma_dbFunctions.php';
include $basePath . '/drupalCompatibility.php';
if (isset($_POST['teamNumber'])) {
    $teamNumber = $_POST['teamNumber'];
} else {
    echo 'errorTID';
    return;
}
$TID = dbGetTeamTIDByNumber($teamNumber);
$data['numHours'] = dbGetHoursForTeam($TID);
$data['teamName'] = dbGetTeamName($TID);
$data['numOutreaches'] = dbGetNumOutreachForTeam($TID);
$json = json_encode($data);
echo $json;