Skip to content

Commit

Permalink
Merge pull request #1 from craigjackson/master
Browse files Browse the repository at this point in the history
Tons of changes
  • Loading branch information
ameerkat committed May 11, 2011
2 parents 32eaf66 + 17c46c1 commit 2951ba8
Show file tree
Hide file tree
Showing 19 changed files with 199 additions and 65 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*.swp
Binary file added images/blue_ribbon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/icon-race-protoss.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/icon-race-terran.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/icon-race-zerg.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/icon-rank-bronze.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/icon-rank-diamond.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/icon-rank-gold.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon-rank-master.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/icon-rank-platinum.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/icon-rank-silver.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion includes/sc2ranks_handler_field_fav_race.inc
Expand Up @@ -6,6 +6,7 @@ class sc2ranks_handler_field_fav_race extends views_handler_field {
function render($values){
return "<img src=\"".base_path().drupal_get_path('module', 'sc2ranks').
"/images/icon-race-".$values->cache_sc2ranks_fav_race.".jpg\" alt=\"".
$values->cache_sc2ranks_fav_race."\" title=\"".
$values->cache_sc2ranks_fav_race."\" />";
}
}
}
5 changes: 3 additions & 2 deletions includes/sc2ranks_handler_field_league.inc
Expand Up @@ -5,7 +5,8 @@
class sc2ranks_handler_field_league extends views_handler_field {
function render($values){
return "<img src=\"".base_path().drupal_get_path('module', 'sc2ranks').
"/images/icon-rank-".$values->cache_sc2ranks_league.".png\" alt=\"".
$values->cache_sc2ranks_league."\" style=\"width: 25px;\"/>";
"/images/icon-rank-".helper_int_to_league($values->cache_sc2ranks_league).".png\" alt=\"".
helper_int_to_league($values->cache_sc2ranks_league)."\" title=\"".
helper_int_to_league($values->cache_sc2ranks_league)."\"/>";
}
}
16 changes: 14 additions & 2 deletions lib/sc2ranks.php
Expand Up @@ -82,18 +82,29 @@ function __construct($site_key = null){
}
}

/**
* URL validator used in get_character_data.
*/
private function isValidURL($url){
return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
}
/**
* Returns the deserialized character data object from the info
* provided to the function.
* @param string $name character name
* @param string|int $code 3 digit character code
* @param string|int $code 3 digit character code or bnet profile id from the bnet url.
* @param string $region optional region information, defaults to US
* @return object the deserialized character data
*/
public function get_character_data($name, $code, $region = "us"){
$parse_character = "!";
//Checks to see if the code is the charcode.
if(sizeof($code) == 3){
$parse_character = "$";
}
$request_url = $this->site_address.
rawurlencode($region)."/".
rawurlencode($name)."$".
rawurlencode($name).$parse_character.
rawurlencode($code).
".json?appKey=".$this->request_site_key;
$this->last_request = $request_url;
Expand Down Expand Up @@ -187,5 +198,6 @@ public function last_response(){
public function is_json_last_error_enabled(){
return $this->json_errors_enabled;
}

}
?>
25 changes: 18 additions & 7 deletions profile-sc2ranks.tpl.php
Expand Up @@ -4,6 +4,7 @@
<thead>
<tr>
<th>Character</th>
<th>Region</th>
<th>Race</th>
<th>League</th>
<th>Points</th>
Expand All @@ -19,17 +20,27 @@
<span id="sc2ranks-character-name">
<?php print($record_data->character_name); ?>
</span>
<span id="sc2ranks-character-code" style="color: #AAAAAA;">
#<?php print($record_data->character_code); ?>
</span>
<?php if ($show_code || user_access('access character code')): ?>
<span id="sc2ranks-character-code" style="color: #AAAAAA;">
#<?php print($record_data->character_code); ?>
</span>
<?php endif; ?>
</td>
<td><img src="<?php print $race_image_url ?>" alt="<?php print($record_data->fav_race); ?>" /></td>
<td><img src="<?php print $league_image_url ?>" alt="<?php print($record_data->league); ?>" style="width: 25px;"/></td>
<td><?php print($record_data->region); ?></td>
<td><img src="<?php print $race_image_url ?>" alt="<?php print($record_data->fav_race); ?>" title="<?php print($record_data->fav_race); ?>" /></td>
<td><img src="<?php print $league_image_url ?>" alt="<?php print($record_data->league); ?>" title="<?php print($record_data->league); ?>" style="width: 25px;"/></td>
<td><?php print($record_data->points); ?></td>
<td><?php print($record_data->division); ?></td>
<td><?php print($record_data->wins); ?></td>
<td><?php print($record_data->losses); ?></td>
<td><?php print($ratio); ?>%</td>
<?php
if($record_data->league == "masters"){
print("<td> $record_data->losses</td>");
}
else{
print("<td> <img src='$blue_ribbion_url' title='Losses? This guy is a winner!'> </img> </td>");
}
?>
<td><?php print(number_format($ratio, 2)); ?>%</td>
</tr>
</tbody>
</table>
Expand Down
3 changes: 1 addition & 2 deletions readme.markdown
Expand Up @@ -2,7 +2,7 @@

## Usage
1. Make sure you have the profile module enabled.
2. Create two fields for user's to enter character name and character code
2. Create two fields for user's to enter character region, character name and character code
data for battle.net, be sure to note the names of these fields.
3. Install and enable the sc2ranks module.
4. Configure permissions to view and administer the sc2ranks module
Expand Down Expand Up @@ -33,7 +33,6 @@ all the information stored in the system about the user.
## TODO
* Better Theming documentation
* Player Portraits (Merge w/Troyan's Code)
* Support other regions besides U.S.
* Better Views integration
* Custom sort on league field
* Make image handlers optional, add profile link handlers.
Expand Down
7 changes: 6 additions & 1 deletion sc2ranks.install
Expand Up @@ -10,6 +10,11 @@ function sc2ranks_schema() {
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0),
'region' => array(
'description' => t('The bnet region this data is related to.'),
'type' => 'varchar',
'length' => 255,
'not null' => FALSE),
'character_name' => array(
'description' => t('The bnet character this data is related to.'),
'type' => 'varchar',
Expand All @@ -23,7 +28,7 @@ function sc2ranks_schema() {
'unsigned' => TRUE),
'league' => array(
'description' => t('League of the player.'),
'type' => 'varchar',
'type' => 'int',
'length' => 255,
'not null' => FALSE),
'points' => array(
Expand Down

0 comments on commit 2951ba8

Please sign in to comment.