Skip to content
Browse files

Added views images, defaut view, TODO modify readme, improve views ha…

…ndler options.
  • Loading branch information...
1 parent 2a16251 commit 8e381b9c86d7ea4f9902bd75b73f65046ce9c87e @ameerkat committed Nov 15, 2010
Showing with 277 additions and 3 deletions.
  1. +11 −0 includes/sc2ranks_handler_field_fav_race.inc
  2. +11 −0 includes/sc2ranks_handler_field_league.inc
  3. +255 −3 sc2ranks.views.inc
View
11 includes/sc2ranks_handler_field_fav_race.inc
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Custom views handler for race (provides images)
+ */
+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."\" />";
+ }
+}
View
11 includes/sc2ranks_handler_field_league.inc
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Custom views handler for league (provides images)
+ */
+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;\"/>";
+ }
+}
View
258 sc2ranks.views.inc
@@ -1,5 +1,24 @@
<?php
/**
+ * Custom handlers
+ */
+function sc2ranks_views_handlers() {
+ return array(
+ 'info' => array(
+ 'path' => drupal_get_path('module', 'sc2ranks') . '/includes',
+ ),
+ 'handlers' => array(
+ 'sc2ranks_handler_field_league' => array(
+ 'parent' => 'views_handler_field',
+ ),
+ 'sc2ranks_handler_field_fav_race' => array(
+ 'parent' => 'views_handler_field',
+ ),
+ ),
+ );
+}
+
+/**
* Implementation of hook_views_data
* @author Ameer Ayoub <ameer.ayoub@gmail.com>
*
@@ -75,7 +94,7 @@ function sc2ranks_views_data() {
'title' => t("League"),
'help' => t("The 1v1 ranked league of the player."),
'field' => array(
- 'handler' => 'views_handler_field',
+ 'handler' => 'sc2ranks_handler_field_league'
),
'sort' => array(
'handler' => 'views_handler_sort',
@@ -154,7 +173,7 @@ function sc2ranks_views_data() {
'title' => t("Favorite Race"),
'help' => t("Most played race of this player"),
'field' => array(
- "handler" => "views_handler_field",
+ "handler" => "sc2ranks_handler_field_fav_race",
"click sortable" => TRUE,
),
"filter" => array(
@@ -184,4 +203,237 @@ function sc2ranks_views_data() {
);
return $data;
-}
+}
+
+/**
+ * Default View
+ */
+function sc2ranks_views_default_views() {
+ $view = new view;
+ $view->name = 'player_listing';
+ $view->description = 'Player listing using player stats from sc2ranks module.';
+ $view->tag = 'sc2ranks';
+ $view->view_php = '';
+ $view->base_table = 'cache_sc2ranks';
+ $view->is_cacheable = FALSE;
+ $view->api_version = 2;
+ $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+ $handler = $view->new_display('default', 'Defaults', 'default');
+ $handler->override_option('relationships', array(
+ 'uid' => array(
+ 'label' => 'Associated user',
+ 'required' => 0,
+ 'id' => 'uid',
+ 'table' => 'cache_sc2ranks',
+ 'field' => 'uid',
+ 'relationship' => 'none',
+ ),
+ ));
+ $handler->override_option('fields', array(
+ 'name' => array(
+ 'label' => 'User',
+ 'alter' => array(
+ 'alter_text' => 0,
+ 'text' => '',
+ 'make_link' => 0,
+ 'path' => '',
+ 'link_class' => '',
+ 'alt' => '',
+ 'prefix' => '',
+ 'suffix' => '',
+ 'target' => '',
+ 'help' => '',
+ 'trim' => 0,
+ 'max_length' => '',
+ 'word_boundary' => 1,
+ 'ellipsis' => 1,
+ 'html' => 0,
+ 'strip_tags' => 0,
+ ),
+ 'empty' => '',
+ 'hide_empty' => 0,
+ 'empty_zero' => 0,
+ 'link_to_user' => 1,
+ 'overwrite_anonymous' => 0,
+ 'anonymous_text' => '',
+ 'exclude' => 0,
+ 'id' => 'name',
+ 'table' => 'users',
+ 'field' => 'name',
+ 'relationship' => 'uid',
+ ),
+ 'character_name' => array(
+ 'label' => 'Battle.Net Character Name',
+ 'alter' => array(
+ 'alter_text' => 0,
+ 'text' => '',
+ 'make_link' => 0,
+ 'path' => '',
+ 'link_class' => '',
+ 'alt' => '',
+ 'prefix' => '',
+ 'suffix' => '',
+ 'target' => '',
+ 'help' => '',
+ 'trim' => 0,
+ 'max_length' => '',
+ 'word_boundary' => 1,
+ 'ellipsis' => 1,
+ 'html' => 0,
+ 'strip_tags' => 0,
+ ),
+ 'empty' => '',
+ 'hide_empty' => 0,
+ 'empty_zero' => 0,
+ 'exclude' => 1,
+ 'id' => 'character_name',
+ 'table' => 'cache_sc2ranks',
+ 'field' => 'character_name',
+ 'relationship' => 'none',
+ ),
+ 'character_code' => array(
+ 'label' => 'Battle.Net Character',
+ 'alter' => array(
+ 'alter_text' => 1,
+ 'text' => '[character_name]#[character_code]',
+ 'make_link' => 0,
+ 'path' => '',
+ 'link_class' => '',
+ 'alt' => '',
+ 'prefix' => '',
+ 'suffix' => '',
+ 'target' => '',
+ 'help' => '',
+ 'trim' => 0,
+ 'max_length' => '',
+ 'word_boundary' => 1,
+ 'ellipsis' => 1,
+ 'html' => 0,
+ 'strip_tags' => 0,
+ ),
+ 'empty' => '',
+ 'hide_empty' => 0,
+ 'empty_zero' => 0,
+ 'exclude' => 0,
+ 'id' => 'character_code',
+ 'table' => 'cache_sc2ranks',
+ 'field' => 'character_code',
+ 'relationship' => 'none',
+ ),
+ 'division' => array(
+ 'id' => 'division',
+ 'table' => 'cache_sc2ranks',
+ 'field' => 'division',
+ ),
+ 'fav_race' => array(
+ 'id' => 'fav_race',
+ 'table' => 'cache_sc2ranks',
+ 'field' => 'fav_race',
+ ),
+ 'league' => array(
+ 'id' => 'league',
+ 'table' => 'cache_sc2ranks',
+ 'field' => 'league',
+ ),
+ 'wins' => array(
+ 'id' => 'wins',
+ 'table' => 'cache_sc2ranks',
+ 'field' => 'wins',
+ ),
+ 'losses' => array(
+ 'id' => 'losses',
+ 'table' => 'cache_sc2ranks',
+ 'field' => 'losses',
+ ),
+ 'points' => array(
+ 'id' => 'points',
+ 'table' => 'cache_sc2ranks',
+ 'field' => 'points',
+ ),
+ ));
+ $handler->override_option('access', array(
+ 'type' => 'none',
+ ));
+ $handler->override_option('cache', array(
+ 'type' => 'none',
+ ));
+ $handler->override_option('footer', 'Data provided by <a href="http://sc2ranks.com/">sc2ranks.com</a>');
+ $handler->override_option('footer_format', '1');
+ $handler->override_option('footer_empty', 0);
+ $handler->override_option('items_per_page', 50);
+ $handler->override_option('style_plugin', 'table');
+ $handler->override_option('style_options', array(
+ 'grouping' => '',
+ 'override' => 1,
+ 'sticky' => 0,
+ 'order' => 'asc',
+ 'columns' => array(
+ 'character_name' => 'character_name',
+ 'wins' => 'wins',
+ 'name' => 'name',
+ 'character_code' => 'character_code',
+ 'bnet_id' => 'bnet_id',
+ 'division' => 'division',
+ 'fav_race' => 'fav_race',
+ 'league' => 'league',
+ 'losses' => 'losses',
+ 'points' => 'points',
+ ),
+ 'info' => array(
+ 'character_name' => array(
+ 'sortable' => 0,
+ 'separator' => '',
+ ),
+ 'wins' => array(
+ 'sortable' => 0,
+ 'separator' => '',
+ ),
+ 'name' => array(
+ 'sortable' => 0,
+ 'separator' => '',
+ ),
+ 'character_code' => array(
+ 'separator' => '',
+ ),
+ 'bnet_id' => array(
+ 'sortable' => 0,
+ 'separator' => '',
+ ),
+ 'division' => array(
+ 'separator' => '',
+ ),
+ 'fav_race' => array(
+ 'sortable' => 0,
+ 'separator' => '',
+ ),
+ 'league' => array(
+ 'separator' => '',
+ ),
+ 'losses' => array(
+ 'sortable' => 0,
+ 'separator' => '',
+ ),
+ 'points' => array(
+ 'separator' => '',
+ ),
+ ),
+ 'default' => '-1',
+ ));
+ $handler = $view->new_display('page', 'Page', 'page_1');
+ $handler->override_option('path', 'sc2ranks/player_listing');
+ $handler->override_option('menu', array(
+ 'type' => 'none',
+ 'title' => '',
+ 'description' => '',
+ 'weight' => 0,
+ 'name' => 'navigation',
+ ));
+ $handler->override_option('tab_options', array(
+ 'type' => 'none',
+ 'title' => '',
+ 'description' => '',
+ 'weight' => 0,
+ 'name' => 'navigation',
+ ));
+ return array($view);
+}

0 comments on commit 8e381b9

Please sign in to comment.
Something went wrong with that request. Please try again.