PageRenderTime 45ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/demos/WoWArenaLadderAndTeam.php

https://github.com/bforchhammer/bnetlib
PHP | 161 lines | 145 code | 12 blank | 4 comment | 0 complexity | 1c537bf7089528f8755281c0aa5dca21 MD5 | raw file
  1. <?php
  2. include dirname(__DIR__) . '/autoload_register.php';
  3. ?>
  4. <!doctype html>
  5. <html>
  6. <head>
  7. <meta charset="utf-8">
  8. <title>Arena Ladder and Team Demo</title>
  9. </head>
  10. <style type="text/css" media="screen">
  11. body{color:#444;background:#ddd;font:normal 14px/20px 'Helvetica Neue',Helvetica,Arial,sans-serif}
  12. a{color:#82bd1a;text-decoration:none}
  13. a:hover{text-decoration:underline}
  14. article a{font-weight:bold}
  15. p,dl{margin:0 0 15px}
  16. h1,h2,h3{color:#555;margin:0 0 30px}
  17. h1{font-size:28px}
  18. h2{font-size:21px}
  19. h3{font-size:17px}
  20. hgroup h1{margin:0 0 15px}
  21. p:last-child,dl:last-child{margin:0}
  22. #main{width:800px;margin:75px auto}
  23. #lib{font-size:40px}
  24. #lib a{color:#444}
  25. #lib a:hover,#lib a:focus{color:#82bd1a;text-decoration:none}
  26. footer{clear:both;color:#999;font-size:11px}
  27. section>section{margin:0;width:800px}
  28. article{background:#fff;margin-bottom:25px;-webkit-box-shadow:0 0 3px rgba(0,0,0,.25);-moz-box-shadow:0 0 3px rgba(0,0,0,.25);-o-box-shadow:0 0 3px rgba(0,0,0,.25);box-shadow:0 0 3px rgba(0,0,0,.25);-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}
  29. section>ul{margin:0;padding:0;list-style:none;font-weight:bold}
  30. header>section{top:0;right:2px;float:right;position:relative}
  31. section>ul>li{font-size:13px;margin-left:5px;display:inline-block}
  32. .nav-space{margin-left:25px}
  33. nav a,section>ul>li>a{color:#eee;line-height:1;background:#888;padding:4px 7px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}
  34. .inner{padding:30px}
  35. section>ul>li>a:hover,section>ul>li>a:focus{color:#eee;background:#82bd1a;text-decoration:none}
  36. table{width:100%;border-spacing:0;border-collapse:collapse;margin-bottom:25px}
  37. table:last-of-type{margin:0}
  38. th{font-weight:bold}
  39. th,td{padding:4px 7px;text-align:right}
  40. td{border-top:1px solid #d0d0d0}
  41. th:last-child,td:last-child{text-align:left}
  42. tr:hover{background:#f5f5f5}
  43. tr tr:hover{background:#e9e9e9}
  44. </style>
  45. <body>
  46. <div id="main">
  47. <header>
  48. <section>
  49. <ul>
  50. <li>Docs:</li>
  51. <li><a href="http://coss.github.com/bnetlib/api" title="API Documentation">API</a></li>
  52. <li><a href="http://coss.github.com/bnetlib" title="End User Documentation">End-User</a></li>
  53. <li class="nav-space">Downlaod:</li>
  54. <li><a href="https://github.com/coss/bnetlib/zipball/master" title="Download as .zip">Zip</a></li>
  55. <li><a href="https://github.com/coss/bnetlib/tarball/master" title="Download as .tar.gz">Tar</a></li>
  56. <li class="nav-space">Actions:</li>
  57. <li><a href="https://github.com/coss/bnetlib" title="Fork bnetlib on GitHub">Fork</a></li>
  58. <li><a href="https://github.com/coss/bnetlib/toggle_watch" title="Watch bnetlib on GitHub">Watch</a></li>
  59. <li><a href="https://github.com/coss/bnetlib/issues" title="Report an Issue">Issues</a></li>
  60. </ul>
  61. </section>
  62. <h1 id="lib"><a href="http://coss.github.com/bnetlib" title="End User Documentation">bnetlib</a></h1>
  63. </header>
  64. <section>
  65. <section>
  66. <article>
  67. <div class="inner">
  68. <h1>Arena Ladder and Team Demo</h1>
  69. <?php
  70. use bnetlib\Locale\Locale;
  71. use bnetlib\Connection\Stub;
  72. use bnetlib\WorldOfWarcraft;
  73. $locale = new Locale(Stub::LOCALE_GB, WorldOfWarcraft::SHORT_NAME);
  74. $wow = new WorldOfWarcraft(new Stub());
  75. $wow->getConnection()->setOptions(array(
  76. 'defaults' => array(
  77. 'region' => Stub::REGION_EU
  78. )
  79. ));
  80. $wow->getServiceLocator()->setLocale($locale);
  81. $ladder = $wow->getArenaLadder(array(
  82. 'battlegroup' => 'Cataclysme / Cataclysm',
  83. 'teamsize' => '2v2'
  84. ));
  85. foreach ($ladder as $entry) {
  86. printf('<h2>#%d %s</h2>', $entry->getRanking(), $entry->getName());
  87. echo '<table><thead><tr><th>Key</th><th>Value</th></tr></thead><tbody>';
  88. echo '<tr>';
  89. echo '<td>Size</td>';
  90. printf('<td>%s</td>', $entry->getSize());
  91. echo '</tr><tr>';
  92. echo '<td>Realm</td>';
  93. printf('<td>%s</td>', $entry->getRealm());
  94. echo '</tr><tr>';
  95. echo '<td>Faction</td>';
  96. printf('<td>%s</td>', $entry->getFactionLocale());
  97. echo '</tr><tr>';
  98. echo '<td>Rating</td>';
  99. printf('<td>%d</td>',$entry->getRating());
  100. echo '</tr><tr>';
  101. echo '<td>Ranking</td>';
  102. printf(
  103. '<td>Current Week: %d, Last Session: %d</td>',
  104. $entry->getCurrentWeekRanking(),
  105. $entry->getLastSessionRanking()
  106. );
  107. echo '</tr><tr>';
  108. echo '<td>Created</td>';
  109. printf('<td>%s</td>', $entry->getCreated()->format('l, d F Y'));
  110. echo '</tr><tr>';
  111. echo '<td>Stats</td>';
  112. printf(
  113. '<td>%d - %d (%d)</td>',
  114. $entry->getWon(),
  115. $entry->getLost(),
  116. $entry->gePlayed()
  117. );
  118. echo '</tr><tr>';
  119. echo '<td>Session Stats</td>';
  120. printf(
  121. '<td>%d - %d (%d)</td>',
  122. $entry->getSessionWon(),
  123. $entry->getSessionLost(),
  124. $entry->getSessionPlayed()
  125. );
  126. echo '</tr><tr>';
  127. echo '<td>Members</td>';
  128. $members = array();
  129. foreach ($entry as $member) {
  130. $string = '';
  131. $string .= $member->getName();
  132. $string .= ' - ' . $member->getRaceLocale() . ' ' . $member->getClassLocale();
  133. $string .= ' (' . $member->getStatistic()->getRating() . ')';
  134. $members[] = $string;
  135. }
  136. printf('<td>%s</td>', implode(', <br>', $members));
  137. echo '</tr>';
  138. echo '</tbody></table>';
  139. }
  140. ?>
  141. </div>
  142. </article>
  143. </section>
  144. <footer>
  145. Š 2012 Eric Boh. All rights reserved.
  146. </footer>
  147. </div>
  148. </body>
  149. </html>