function gameSummary(&$canvas, $o) { $maxHeight = 910; $width = 980; $height = $maxHeight; $plays = new Imagick(); $plays->newPseudoImage($width, $height, 'xc:none'); $teams = array(); $teams['V'] = fetchTeam($o['vTeam']); $teams['H'] = fetchTeam($o['hTeam']); $bodyHeight = 200; $path = "http://www.sidearmstats.com/rpi/mhockey/1.xml"; $path = "sidearm.xml"; $path = $o['liveStatsXML']; $scores = getGameSummaryInfo($path); $vOffset = 0; $lastPeriod = 0; $playIndex = 0; foreach ($scores->score as $score) { $playIndex++; if ($vOffset + 150 > $maxHeight && $o["numPlays"] == "auto") { break; } else { if ($o["numPlays"] != "auto" && $o["numPlays"] + $o["startIndex"] < $playIndex) { break; } } if ($o["startIndex"] + 1 > $playIndex) { continue; } if ($vOffset > 0) { $plays->compositeImage(fillRectangle(960, 2, '#FFF'), imagick::COMPOSITE_OVER, 0, $vOffset); } if ($score['prd'] + 0 != $lastPeriod) { $lastPeriod = $score['prd'] + 0; $plays->compositeImage(periodLabel($lastPeriod), imagick::COMPOSITE_OVER, 0, $vOffset); $vOffset += 50; $plays->compositeImage(fillRectangle(960, 2, '#FFF'), imagick::COMPOSITE_OVER, 0, $vOffset); } $plays->compositeImage(scoringPlay($score, $teams), imagick::COMPOSITE_OVER, 0, $vOffset); $vOffset += 100; //print_r($score); } addGeoToCanvas($canvas, array('type' => 'flexBox', 'w' => 1920, 'h' => 1080, 'x' => 0, 'y' => 0, 'bodyText' => '', 'boxHeight' => $vOffset, 'boxWidth' => 1000, 'boxOffset' => 'auto', 'boxPadding' => 10, 'titleColor' => $o['barColor'], 'titleHeight' => '70', 'titleText' => $o['titleText'], 'titleGravity' => 'center', 'logoHeight' => 100, 'logoLeft' => $teams['H']['logo'], 'logoRight' => $teams['V']['logo'])); $canvas->compositeImage($plays, imagick::COMPOSITE_OVER, (1920 - 980) / 2, 1080 - 50 - $vOffset - 10); }
function divingStandings(&$canvas, $geo) { $geo['w'] = 1200; $geo['x'] = 360; $sort = $geo['sort']; $team = $geo['team']; $limit = $geo['limit']; $offset = $geo['offset']; $dir = $geo['sortDirection']; $sort = $geo['sort']; if ($geo['numericalSort'] == 'true') { $sort = '(0 + ' . $sort . ')'; } if ($team == 'ecac') { $team = "rpi-mh,dart-mh,yale-mh,union-mh,clark-mh,brown-mh,colgate-mh,quin-mh,stl-mh,prin-mh,cornell-mh,harvard-mh"; $teamarray = explode(',', $team); $finalteamstring = ""; foreach ($teamarray as $strval) { $finalteamstring = $finalteamstring . "`team`='" . trim($strval) . "' OR "; } $finalteamstring = substr($finalteamstring, 0, -4); $sql = "SELECT * FROM `players` WHERE NOT `pos`='G' AND (" . $finalteamstring . ") ORDER BY " . $sort . " " . $dir . " LIMIT " . $offset . ',' . $limit; } else { if (strpos($team, ',') !== false) { $teamarray = explode(',', $team); $finalteamstring = ""; foreach ($teamarray as $strval) { $finalteamstring = $finalteamstring . "`team`='" . trim($strval) . "' OR "; } $finalteamstring = substr($finalteamstring, 0, -4); $sql = "SELECT * FROM `players` WHERE NOT `pos`='G' AND (" . $finalteamstring . ") ORDER BY " . $sort . " " . $dir . " LIMIT " . $offset . ',' . $limit; } else { $sql = "SELECT * FROM players WHERE `team`='" . $team . "' ORDER BY " . $sort . " " . $dir . " LIMIT " . $offset . ',' . $limit; } } $result = dbQuery($sql); $players = []; while ($row = mysql_fetch_assoc($result)) { $players[] = $row; } $rowHeight = 60; $height = count($players) * $rowHeight; $yLocation = 1080 - $height - 50; $yOffset = $yLocation; blackBox($canvas, array('x' => $geo['x'], 'w' => $geo['w'], 'y' => $yLocation - 65, 'h' => $height + 65)); slantRectangle($canvas, array('x' => $geo['x'] + 200, 'y' => $yLocation - 60, 'w' => 800, 'h' => 50, 'color' => '#333333')); shadowText($canvas, array('x' => $geo['x'] + 220, 'y' => $yLocation - 55, 'gravity' => 'center', 'w' => 760, 'h' => 40, 'text' => $geo['roundText'], 'font' => 'fontN', 'color' => 'white')); slantRectangle($canvas, array('x' => $geo['x'] - 35, 'y' => $yLocation - 130, 'w' => 1270, 'h' => 70, 'color' => 'red')); shadowText($canvas, array('x' => $geo['x'], 'y' => $yLocation - 125, 'gravity' => 'center', 'w' => 1200, 'h' => 60, 'text' => $geo['titleText'], 'font' => 'fontN', 'color' => 'white')); shadowText($canvas, array('x' => $geo['x'] + 1030, 'y' => $yLocation - 50, 'gravity' => 'east', 'w' => 150, 'h' => 50, 'text' => $geo['labelText'], 'font' => 'fontN', 'color' => 'white')); $place = $offset; foreach ($players as $player) { $place++; $team = array(); if ($player['stype'] == 'dive') { $team = fetchOrg($player['pos']); } else { $team = fetchTeam($player['team']); } if ($geo['hideRankColumn'] == 'false') { shadowText($canvas, array('x' => $geo['x'], 'y' => $yOffset, 'gravity' => 'east', 'w' => 65, 'h' => $rowHeight, 'text' => $place, 'font' => 'fontN', 'color' => 'white')); } placeImage($canvas, array('x' => $geo['x'] + 75, 'y' => $yOffset, 'w' => 65, 'h' => $rowHeight, 'path' => $team['logo'])); shadowText($canvas, array('x' => $geo['x'] + 150, 'y' => $yOffset, 'gravity' => 'west', 'w' => 425, 'h' => $rowHeight, 'text' => $player['first'] . ' ' . $player['last'], 'font' => 'fontN', 'color' => 'white')); shadowText($canvas, array('x' => $geo['x'] + 585, 'y' => $yOffset + 4, 'gravity' => 'west', 'w' => 485, 'h' => $rowHeight - 8, 'text' => $team['name'], 'font' => 'fontN', 'color' => 'white')); if ($geo['hideLastColumn'] == 'false') { shadowText($canvas, array('x' => $geo['x'] + 1080, 'y' => $yOffset, 'gravity' => 'east', 'w' => 100, 'h' => $rowHeight, 'text' => $player[$geo['sort']], 'font' => 'fontN', 'color' => 'white')); } $yOffset += $rowHeight; } }
} td.editing input { width: inherit; } td.action, th.action { width:120px; } th { text-align: left; } .s1, .s2, .s3, .s4, .s5, .s6, .s7, .num, .id, .pos, .height, .weight, .year, .stype { width:40px !important; } .hometown, .s8 { width:150px !important; } </style> <!--<button id="all">Edit All</button> If Matt asks for this, I'll add it, otherwise I don't like it --> <? } else { ?> <h2>Select a team</h2> <form action="im_peditor.php" method="get"> <? $query = "SELECT * FROM teams"; $result = dbquery($query); while($row = mysql_fetch_array($result)) { $team = fetchTeam($row['player_abbrev']); echo("<div style=\"float:left;width:100px\"><img width=\"30\" src=\"" . $team["logo"] . "\"><br><input type=\"submit\" name=\"team_sel\" value=\"" . $team["player_abbrev"] . "\"></div>"); } ?> </form> <? } ?>
function getStatscard($id, $o = []) { $lastSeason = false; // sets last season flag timestamp('Get Statscard'); // // Gather required data // $result = dbquery("SELECT * from players WHERE `id` = '{$id}'"); $row = mysql_fetch_assoc($result); $team = fetchTeam($row['team']); $stype = $row["stype"]; if ($stype != "txt") { $result = dbquery("SELECT * FROM stattype WHERE `type` = '{$stype}'"); $slabel = mysql_fetch_array($result); } timestamp('Done getting data'); $title = $row; $title['type'] = 'player'; $geos = array(); // // Set up geometry // $boxHeightModifier = 0; $positionWidth = 130; // Check to see if there are stats if (!$stype) { $boxHeightModifier = -113; } if ($stype == 'dive' && $row['s2'] > 0) { $boxHeightModifier = -50; } else { if ($stype == 'dive') { $boxHeightModifier = -113; } } // Adjust position width if ($stype != dive) { if (strlen($row["pos"]) > 1) { $positionWidth = 110 + 0.75 * getTextWidthFromCache(array('w' => 1000, 'h' => 80, 'text' => $row['pos'], 'font' => "fontN")); } } $nameBarAdjust = 0; $diveTeam = []; if ($stype == 'dive') { $diveTeam = fetchOrg($row['pos']); //print_R($diveTeam); $team['logo'] = $diveTeam['logo']; $team['color'] = $diveTeam['color']; $nameBarAdjust = 200; } // // Lay down initial geometry // $geos[] = array('type' => 'blackBox', 'name' => 'Backdrop', 'x' => 400, 'y' => 870 - $boxHeightModifier, 'w' => 1120, 'h' => 160 + $boxHeightModifier); $geos[] = array('type' => 'slantRectangle', 'name' => 'nameBar', 'x' => 360, 'y' => 800 - $boxHeightModifier, 'w' => 780 + $nameBarAdjust, 'h' => 80, 'color' => $team['color']); if ($stype != 'dive') { $geos[] = array('type' => 'slantRectangle', 'name' => 'numberBox', 'x' => 1230 - $positionWidth, 'y' => 800 - $boxHeightModifier, 'w' => 150, 'h' => 80, 'color' => "#303030"); $geos[] = array('type' => 'slantRectangle', 'name' => 'positionBox', 'x' => 1340 - $positionWidth, 'y' => 800 - $boxHeightModifier, 'w' => $positionWidth, 'h' => 80, 'color' => $team['color']); } $geos[] = array('type' => 'slantRectangle', 'name' => 'yearBox', 'x' => 1300, 'y' => 800 - $boxHeightModifier, 'w' => 150, 'h' => 80, 'color' => "#303030"); $geos[] = array('type' => 'slantRectangle', 'name' => 'logoBox', 'x' => 1410, 'y' => 800 - $boxHeightModifier, 'w' => 150, 'h' => 80, 'color' => "white"); // // Headshot setup // $pPath = "teams/" . $row["team"] . "imgs/" . $row["first"] . $row["last"] . ".png"; $size = @getimagesize($pPath); $nameModifier = 0; $detailsModifier = 0; $useHeadshot = !!$size[0] || $o['emptyHeadshot']; if ($useHeadshot) { // there is a headshot if ($size[0] && !$o['emptyHeadshot']) { if ($stype) { $p = array('type' => 'placeHeadshot', 'name' => 'headshot', 'w' => 192, 'h' => 230, 'x' => 400, 'y' => '801', 'path' => $pPath); } else { $p = array('type' => 'placeHeadshot', 'name' => 'headshot', 'w' => 192, 'h' => 230, 'x' => 400, 'y' => '801', 'shadow' => 5, 'path' => $pPath); } // center align title and send to baseline if title is too narrow if ($size[0] * 1.2 > $size[1]) { $p['h'] = $size[1] / ($size[0] / $p['w']); $p['y'] += 230 - $p['h']; } $geos[] = $p; } if ($stype == 'dive') { if ($row['s2'] > 0) { $nameModifier = 15; } else { $nameModifier = 45; } } $nameModifier = 40; } else { // no headshot $nameModifier = -150; $detailsModifier = -220; } // // Print team logo, name, num, pos, year // $proSpacer = 0; if ($row['s7'] and $stype != 'dive') { // draft pick graphic $geos[] = array('type' => 'placeImage', 'name' => 'draftLogo', 'x' => 1160 - $positionWidth, 'y' => 800 - $boxHeightModifier, 'w' => 76, 'h' => 76, 'shadow' => 5, 'padding' => 7, 'path' => 'other_graphics/NHL/' . strtoupper($row['s7']) . '.png'); $proSpacer = 55; } $geos[] = array('type' => 'placeImage', 'name' => 'teamLogo', 'x' => 1447, 'y' => 800 - $boxHeightModifier, 'w' => 76, 'h' => 76, 'path' => $team['logo'], 'shadow' => 5, 'padding' => 6); $geos[] = array('type' => 'shadowText', 'name' => 'name', 'x' => 560 + $nameModifier, 'y' => 805 - $boxHeightModifier, 'w' => 665 - $nameModifier - $positionWidth - $proSpacer, 'h' => 70, 'text' => $row["first"] . " " . $row["last"], 'gravity' => "west", 'font' => "fontN", 'color' => "white"); if ($stype != 'dive') { $geos[] = array('type' => 'shadowText', 'name' => 'number', 'x' => 1230 - $positionWidth, 'y' => 803 - $boxHeightModifier, 'w' => 150, 'h' => 80, 'text' => $row["num"], 'gravity' => "center", 'font' => "fontN", 'color' => "white"); $geos[] = array('type' => 'shadowText', 'name' => 'position', 'x' => 1338 - $positionWidth, 'y' => 803 - $boxHeightModifier, 'w' => $positionWidth, 'h' => 80, 'text' => $row["pos"], 'gravity' => "center", 'font' => "fontN", 'color' => "white"); } $geos[] = array('type' => 'shadowText', 'name' => 'year', 'x' => 1305, 'y' => 803 - $boxHeightModifier, 'w' => 140, 'h' => 80, 'text' => $row["year"], 'gravity' => "center", 'font' => "fontN", 'color' => "white"); // // Details setup // $details = ''; if ($stype == 'dive') { $details = 'School: ' . $diveTeam['name'] . ' '; } $details .= "Hometown: " . $row["hometown"]; if ($row["height"] . length > 0) { $details .= " " . "Ht: " . $row["height"]; } if ($row["weight"] . length > 0) { $details .= " " . "Wt: " . $row["weight"]; } $detailsGravity = "west"; if (!$useHeadshot) { $detailsGravity = "center"; } $geos[] = array('type' => 'plainText', 'name' => 'details', 'x' => 630 + $detailsModifier, 'y' => 884 - $boxHeightModifier, 'w' => 880 - $detailsModifier, 'h' => 33, 'text' => $details, 'gravity' => $detailsGravity, 'font' => "fontN", 'color' => "white"); // // Stats section // if ($stype && $stype != "txt" && $stype != 'dive') { if ($lastSeason == true && !$useHeadshot) { $geos[] = array('type' => 'plainText', 'name' => 'lastSeason', 'x' => 420, 'y' => 965, 'w' => 80, 'h' => 60, 'text' => 'Last\\nSeason:', 'gravity' => "west", 'font' => "fontN", 'color' => "white"); } else { if ($lastSeason == true && !$o['emptyHeadshot']) { $geos[] = array('type' => 'shadowText', 'name' => 'lastSeason', 'x' => 410, 'y' => 995, 'w' => 172, 'h' => 30, 'text' => 'Last Season:', 'gravity' => "center", 'font' => "fontN", 'color' => "white"); } else { if ($row["team"] == career) { $geos[] = array('type' => 'shadowText', 'name' => 'careerStats', 'x' => 410, 'y' => 995, 'w' => 172, 'h' => 30, 'text' => 'Career Stats:', 'gravity' => "center", 'font' => "fontN", 'color' => "white"); } } } $statsBoxWidth = 880; $statsBoxX = 650; if (!$useHeadshot) { $statsBoxX = 525; $statsBoxWidth = 950; } $i = 1; for (; strlen($slabel['l' . $i]) > 0; $i++) { } timestamp('Calculating widths...'); $boxW = $statsBoxWidth / ($i - 1); $totalwidths = 0; for ($j = 1; $j < $i; $j++) { $totalwidths += getTextWidthFromCache(array('w' => $boxW, 'h' => 80, 'text' => $row['s' . $j], 'font' => "fontN")); timestamp('getTextWidth' . $j); } $spacing = ($statsBoxWidth - $totalwidths) / ($i - 1); for ($j = 1; $j < $i; $j++) { $thisWidth = getTextWidthFromCache(array('w' => $boxW, 'h' => 80, 'text' => $row['s' . $j], 'font' => "fontN")); timestamp('getTextWidth' . $j); $statsBoxX -= ($boxW - $thisWidth) / 2; $geos[] = array('type' => 'plainText', 'name' => 'stat' . $j . 'Label', 'x' => $statsBoxX, 'y' => 915, 'w' => $boxW, 'h' => 40, 'text' => $slabel['l' . $j], 'gravity' => "center", 'font' => "fontN", 'color' => "white"); $geos[] = array('type' => 'plainText', 'name' => 'stat' . $j . 'Value', 'x' => $statsBoxX, 'y' => 955, 'w' => $boxW, 'h' => 80, 'text' => $row['s' . $j], 'gravity' => "center", 'font' => "fontN", 'color' => "white"); $statsBoxX += ($boxW - $thisWidth) / 2 + $thisWidth + $spacing; } } else { if ($stype == 'dive' && $row['s2'] > 0) { $centerMod = 0; if (!$useHeadshot) { $centerMod = -110; } $numY = 970; $labelY = 985; $roundPos = 585; // 150 w $roundNumPos = 875; // 100 w? $totalPos = 835; // 250 w $totalNumPos = 1225; // ~100w if ($row['s1'] && $row['s1'] > 0) { $roundPos = 489; // 150 w $roundNumPos = 764; // 100 w? $scorePos = 695; $scoreNumPos = 970; $totalPos = 960; // 250 w $totalNumPos = 1335; // ~100w $geos[] = array('type' => 'shadowText', 'name' => 'score', 'x' => $scorePos + $centerMod, 'y' => $labelY, 'w' => 250, 'h' => 40, 'text' => 'Score', 'gravity' => "east", 'font' => "fontN", 'color' => "white"); $geos[] = array('type' => 'shadowText', 'name' => 'scoreNumber', 'x' => $scoreNumPos + $centerMod, 'y' => $numY, 'w' => 300, 'h' => 60, 'text' => $row['s1'], 'gravity' => "west", 'font' => "fontN", 'color' => "white"); } $geos[] = array('type' => 'shadowText', 'name' => 'round', 'x' => $roundPos + $centerMod, 'y' => $labelY, 'w' => 250, 'h' => 40, 'text' => 'Round', 'gravity' => "east", 'font' => "fontN", 'color' => "white"); $geos[] = array('type' => 'shadowText', 'name' => 'roundNumber', 'x' => $roundNumPos + $centerMod, 'y' => $numY, 'w' => 300, 'h' => 60, 'text' => $team['chn_id'], 'gravity' => "west", 'font' => "fontN", 'color' => "white"); $geos[] = array('type' => 'shadowText', 'name' => 'totalScore', 'x' => $totalPos + $centerMod, 'y' => $labelY, 'w' => 350, 'h' => 40, 'text' => 'Total Score', 'gravity' => "east", 'font' => "fontN", 'color' => "white"); $geos[] = array('type' => 'shadowText', 'name' => 'scoreAmount', 'x' => $totalNumPos + $centerMod, 'y' => $numY, 'w' => 300, 'h' => 60, 'text' => $row['s2'], 'gravity' => "west", 'font' => "fontN", 'color' => "white"); /*$row['s1']; $row['s2']; $row['s3']; $row['s4'];*/ } } $title['geos'] = $geos; timestamp('Done Getting Statscard'); return $title; }