-
Notifications
You must be signed in to change notification settings - Fork 4
/
d1_standings.php
144 lines (121 loc) · 4.28 KB
/
d1_standings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
function add_text() {
$width = 1045;
$height = 680;
$team = new Imagick();
$team->newPseudoImage($width, $height, 'xc:none');
$table_data = table_parse();
$organization = "";
$places = "";
$teams = "";
$pts = "";
$record_c = "";
$record_o = "";
$previous_pts = $table_data[0][1] + 1;
$place_count = 1;
for($x = 0 ; $x < count($table_data); $x++)
{
//Adds Text
if($x == count($table_data)-1)
{
$teams += $table_data[$x][0];
$pts += $table_data[$x][1];
$record_c += $table_data[$x][2];
$record_o += $table_data[$x][3];
}
else
{
$teams += $table_data[$x][0];
$pts += $table_data[$x][1];
$record_c += $table_data[$x][2];
$record_o += $table_data[$x][3];
$teams += "\n";
$pts += "\n";
$record_c += "\n";
$record_o += "\n";
}
//Adds Teams Place
if($table_data[$x][1] < $previous_pts)
{
$pts += $place_count;
$pts += "\n";
$place_count++;
}
else
{
$pts += "\n";
}
//Corrects for different name
if($table_data[$x][0] == "St. Lawrence")
{
$organization = fetchOrg("slu");
}
else
{
$organization = fetchOrg(strtolower($table_data[$x][0]));
}
placeImage($team,array('w'=>46,'h'=>46,'x'=>520,'y'=>428 +50*$x ,'path'=>$teams[$table_data[2][0]]['logo']));
}
plainText($team,array('text'=>$places,'w'=>575,'h'=>680,'x'=>445,'y'=>375,'gravity'=>'west','font'=>'fontN','color'=>'white'));
plainText($team,array('text'=>$teams,'w'=>575,'h'=>680,'x'=>595,'y'=>375,'gravity'=>'west','font'=>'fontN','color'=>'white'));
plainText($team,array('text'=>$pts,'w'=>575,'h'=>680,'x'=>930,'y'=>375,'gravity'=>'west','font'=>'fontN','color'=>'white'));
plainText($team,array('text'=>$record_c,'w'=>575,'h'=>680,'x'=>1060,'y'=>375,'gravity'=>'west','font'=>'fontN','color'=>'white'));
plainText($team,array('text'=>$record_o,'w'=>575,'h'=>680,'x'=>1290,'y'=>375,'gravity'=>'west','font'=>'fontN','color'=>'white'));
return $team;
}
function table_parse()
{
$wrpi_stats = fopen($o['liveStatsXML'], "r");
$wrpi_stats = stream_get_contents($wrpi_stats);
$wrpi_stats = mb_convert_encoding($wrpi_stats, 'UTF-8', 'ASCII');
$wrpi_stats = addslashes($wrpi_stats);
$wrpi_stats = str_replace([chr(10), chr(13)], '', $wrpi_stats); // fix newline issues
$wrpi_stats = stristr($wrpi_stats, "<tr align=\\\"center\\\" bgcolor=\\\"#404040\\\"><th align=\\\"left\\\"><font color=\\\"#ffffff\\\">"); // get only stat table data
$wrpi_stats = substr($wrpi_stats, 0, (strripos($wrpi_stats, "</tr></table></center><table width=\\\"1000\\\">")));
$wrpi_array = explode("</tr>",$wrpi_stats);
$lines = array();
for($x = 1; $x <=13 ; $x++ )
{
$wrpi_array_test = explode("<td",$wrpi_stats[$x] );
$team_string = stristr($wrpi_array_test[1], ">"); // get only stat table data
$team_string = substr($team_string, 0, (strripos($team_string, "<")));
$team_string = ltrim($team_string, '>');
$pts_string = stristr($wrpi_array_test[4], ">"); // get only stat table data
$pts_string = substr($pts_string, 0, (strripos($pts_string, "<")));
$pts_string = ltrim($pts_string, '>');
$conf_record_string = stristr($wrpi_array_test[3], ">"); // get only stat table data
$conf_record_string = substr($conf_record_string, 0, (strripos($conf_record_string, "<")));
$conf_record_string = ltrim($conf_record_string, '>');
$overall_record_string = stristr($wrpi_array_test[9], ">"); // get only stat table data
$overall_record_string = substr($overall_record_string, 0, (strripos($overall_record_string, "<")));
$overall_record_string = ltrim($overall_record_string, '>');
$lines[x-1] = array($team_string,$pts_string,$conf_record_string,$overall_record_string);
}
return $lines;
}
function gameSummary(&$canvas,$o) {
$width = 1060;
$height = 680;
$teams = new Imagick();
$teams->newPseudoImage($width, $height, 'xc:none');
$path = $o['wrpiHTML'];
$teams->compositeImage(add_text(),imagick::COMPOSITE_OVER,0,0);
addGeoToCanvas($canvas,array(
'type'=>'flexBox',
'w'=>1920,
'h'=>1080,
'x'=>0,
'y'=>0,
'bodyText'=>'',
'boxHeight'=>680,
'boxWidth'=>1060,
'boxOffset'=>'auto',
'boxPadding'=>10,
'titleColor'=>$o['barColor'],
'titleHeight'=>'70',
'titleText'=>$o['titleText'],
'titleGravity'=>'center',
));
$canvas->compositeImage($teams,imagick::COMPOSITE_OVER,(1920-980)/2,1080-50-10);
}
?>