PageRenderTime 28ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/missingrecipes/char/index.php

http://wowroster-addons.googlecode.com/
PHP | 366 lines | 283 code | 35 blank | 48 comment | 21 complexity | f151ba69f62b2dbb4ad49504acae9252 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /*
  3. * Missing Recipes
  4. * Originally by: Zeryl
  5. * Ported to 2.0 and maintained by: Teta
  6. */
  7. if( !defined('IN_ROSTER') )
  8. {
  9. exit('Detected invalid access to this file!');
  10. }
  11. require_once (ROSTER_LIB . 'skill.php');
  12. require_once (ROSTER_LIB . 'recipes.php');
  13. $roster->output['html_head'] = '<link rel="stylesheet" type="text/css" href="/pb/roster/addons/missingrecipes/templates/style.css" />';
  14. if ($addon['config']['mr_show_wowheadtooltips']) {
  15. // This part courtesy of Ulminia
  16. // Enable wowhead tooltips
  17. $roster->output['html_head'] = '<script src="http://www.wowhead.com/widgets/power.js"></script>';
  18. function get_icon_link($string){
  19. $id = null;
  20. $matches = array('/db/spell.html?wspell=','/db/item.html?witem=','&source=live','&amp;source=live');
  21. $id = str_replace( $matches, '', $string );
  22. return $id;
  23. }
  24. function get_icon_linka($string){
  25. global $roster;
  26. $id = null;
  27. $matchesa = array('<a href="http://wow.allakhazam.com/db/item.html?witem=','"><img alt="" src="' . ROSTER_URL . $roster->config['interface_url'] . 'img/Interface/Icons"', '" alt="" height="32" width="32" border="0" /></a>','"><img alt="" src="');
  28. $imagex = str_replace( $matchesa, ':', $string );
  29. if (stristr($imagex,":")) {
  30. list($a,$b,$c,$d) = explode(":", $imagex);
  31. return $b;
  32. } else {
  33. return null;
  34. }
  35. }
  36. // End tooltips part
  37. }
  38. //aprint($addon);
  39. // Assign initial tpl vars
  40. $roster->tpl->assign_vars(array(
  41. 'L_ITEM' => $roster->locale->act['item'],
  42. 'L_NAME' => $roster->locale->act['name'],
  43. 'L_SLVL' => $roster->locale->act['skill_level'],
  44. 'L_DISPLAY' => (($addon['config']['display_mr_list'])?'inline-table':'none'),
  45. 'L_SHOWBAR' => $addon['config']['mr_show_progressbar'],
  46. 'A_THEME_IMG_PATH' => $addon['url_path'] . 'templates/images/',
  47. 'R_THEME_PATH' => ROSTER_PATH . 'templates/' . $roster->tpl->tpl // Since Roster likes to set the THEME_PATH to the current template directory
  48. )
  49. );
  50. $charid = $roster->data['member_id'];
  51. $skills = skill_get_many($charid);
  52. $skill_list = array();
  53. $i=0;
  54. $skill_name = '';
  55. $skill_name_divider = '';
  56. $known_count = array();
  57. foreach ($skills as $skillgroup)
  58. {
  59. foreach ($skillgroup as $skill)
  60. {
  61. $st = $skill->data['skill_type'];
  62. if ($skill->data['skill_type']==$roster->locale->wordings[$roster->data['clientLocale']]['professions'] || $skill->data['skill_type']==$roster->locale->wordings[$roster->data['clientLocale']]['secondary'])
  63. {
  64. if ($skill->data['skill_name']!=$roster->locale->wordings[$roster->data['clientLocale']]['riding'] && $skill->data['skill_name']!=$roster->locale->wordings[$roster->data['clientLocale']]['Fishing'] && $skill->data['skill_name']!=$roster->locale->wordings[$roster->data['clientLocale']]['Skinning'] && $skill->data['skill_name']!=$roster->locale->wordings[$roster->data['clientLocale']]['Mining'] && $skill->data['skill_name']!=$roster->locale->wordings[$roster->data['clientLocale']]['Herbalism'])
  65. {
  66. $skill_list[$i] = $skill->data['skill_name'];
  67. $skill_level[$i] = $skill->data['skill_level'];
  68. $skill_name_header = $skill->data['skill_name'];
  69. $query = "SELECT count(`recipe_id`) as cnt FROM `" . $roster->db->table('recipes') . "` WHERE `member_id` = '$charid' AND `skill_name` = '$skill_name_header'";
  70. $result = $roster->db->query($query);
  71. $kc = $roster->db->fetch($result);
  72. $known_count[$i] = $kc['cnt'];
  73. $i++;
  74. $roster->tpl->assign_block_vars('mr', array(
  75. 'LINK' => makelink('#' . strtolower(str_replace(' ','',$skill_name_header))),
  76. 'NAME' => $skill_name_header,
  77. 'DIVIDER' => $skill_name_divider,
  78. )
  79. );
  80. $skill_name_divider = '-&nbsp;';
  81. }
  82. }
  83. }
  84. }
  85. $allrecipes=array();
  86. $i=0;
  87. foreach($skill_list as $skill)
  88. {
  89. switch($skill)
  90. {
  91. case $roster->locale->act['Alchemy']:
  92. $allrecipes[$i] = urlgrabber('http://wow.allakhazam.com/db/skill.html?line=171&source=live&tier=apprentice&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  93. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=171&source=live&tier=journeyman&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  94. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=171&source=live&tier=expert&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  95. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=171&source=live&tier=artisan&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  96. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=171&source=live&tier=master&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  97. $i++;
  98. break;
  99. case $roster->locale->act['Blacksmithing']:
  100. $allrecipes[$i] = urlgrabber('http://wow.allakhazam.com/db/skill.html?line=164&source=live&tier=apprentice&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  101. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=164&source=live&tier=journeyman&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  102. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=164&source=live&tier=expert&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  103. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=164&source=live&tier=artisan&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  104. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=164&source=live&tier=master&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  105. $i++;
  106. break;
  107. case $roster->locale->act['Cooking']:
  108. $allrecipes[$i] = urlgrabber('http://wow.allakhazam.com/db/skill.html?line=185&source=live&tier=apprentice&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  109. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=185&source=live&tier=journeyman&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  110. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=185&source=live&tier=expert&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  111. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=185&source=live&tier=artisan&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  112. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=185&source=live&tier=master&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  113. $i++;
  114. break;
  115. case $roster->locale->act['Enchanting']:
  116. $allrecipes[$i] = urlgrabber('http://wow.allakhazam.com/db/skill.html?line=333&source=live&tier=apprentice&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  117. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=333&source=live&tier=journeyman&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  118. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=333&source=live&tier=expert&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  119. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=333&source=live&tier=artisan&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  120. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=333&source=live&tier=master&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  121. $i++;
  122. break;
  123. case $roster->locale->act['Engineering']:
  124. $allrecipes[$i] = urlgrabber('http://wow.allakhazam.com/db/skill.html?line=202&source=live&tier=apprentice&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  125. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=202&source=live&tier=journeyman&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  126. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=202&source=live&tier=expert&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  127. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=202&source=live&tier=artisan&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  128. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=202&source=live&tier=master&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  129. $i++;
  130. break;
  131. case $roster->locale->act['First Aid']:
  132. $allrecipes[$i] = urlgrabber('http://wow.allakhazam.com/db/skill.html?line=129&source=live&tier=apprentice&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  133. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=129&source=live&tier=journeyman&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  134. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=129&source=live&tier=expert&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  135. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=129&source=live&tier=artisan&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  136. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=129&source=live&tier=master&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  137. $i++;
  138. break;
  139. case $roster->locale->act['Leatherworking']:
  140. $allrecipes[$i] = urlgrabber('http://wow.allakhazam.com/db/skill.html?line=165&source=live&tier=apprentice&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  141. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=165&source=live&tier=journeyman&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  142. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=165&source=live&tier=expert&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  143. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=165&source=live&tier=artisan&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  144. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=165&source=live&tier=master&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  145. $i++;
  146. break;
  147. case $roster->locale->act['Tailoring']:
  148. $allrecipes[$i] = urlgrabber('http://wow.allakhazam.com/db/skill.html?line=197&source=live&tier=apprentice&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  149. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=197&source=live&tier=journeyman&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  150. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=197&source=live&tier=expert&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  151. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=197&source=live&tier=artisan&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  152. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=197&source=live&tier=master&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  153. $i++;
  154. break;
  155. case $roster->locale->act['Jewelcrafting']:
  156. $allrecipes[$i] = urlgrabber('http://wow.allakhazam.com/db/skill.html?line=755&source=live&tier=apprentice&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  157. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=755&source=live&tier=journeyman&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  158. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=755&source=live&tier=expert&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  159. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=755&source=live&tier=artisan&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  160. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=755&source=live&tier=master&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  161. $i++;
  162. break;
  163. case $roster->locale->act['Inscription']:
  164. $allrecipes[$i] = urlgrabber('http://wow.allakhazam.com/db/skill.html?line=773&source=live&tier=apprentice&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  165. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=773&source=live&tier=journeyman&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  166. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=773&source=live&tier=expert&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  167. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=773&source=live&tier=artisan&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  168. $allrecipes[$i] .= urlgrabber('http://wow.allakhazam.com/db/skill.html?line=773&source=live&tier=master&locale='.$roster->data['clientLocale'],$addon['config']['mr_urlgrabber_timeout']);
  169. $i++;
  170. break;
  171. default:
  172. $allrecipes[$i] ='';
  173. $i++;
  174. break;
  175. }
  176. }
  177. foreach($allrecipes as $index => $allrecipesperskill)
  178. {
  179. preg_match_all('/(?<=\<tr class=\"[dl]r\"\>)((.(?!\<\/tr))*)/si',$allrecipesperskill,$matches);
  180. foreach ($matches[0] as $nr => $recipe)
  181. {
  182. preg_match_all('/(\<td[\w \\\'\"=]*\>)(.*)(?=\<\/td)/mi',$recipe,$lines)."\n";
  183. // aprint($lines);
  184. $parsedrecipes[$index][$nr]['icon'] = strtolower($lines[2][0]);
  185. // preg_match('/(\<a[^\>]* href=\"([^\"]*)\"\>)([^<]*)/i',$parsedrecipes[$index][$nr]['icon'],$match);
  186. // $fulliconlink = "<a href=\"http://wow.allakhazam.com".$match[2]."&locale=".$roster->data['clientLocale'];
  187. $parsedrecipes[$index][$nr]['icon'] = str_replace("src=\"/images/icons", "src=\"".$roster->config['interface_url']."Interface/Icons", $parsedrecipes[$index][$nr]['icon']);
  188. $parsedrecipes[$index][$nr]['icon'] = str_replace(".png", ".".$roster->config['img_suffix']."\" alt=\"" , $parsedrecipes[$index][$nr]['icon']);
  189. $parsedrecipes[$index][$nr]['icon'] = str_replace("href=\"", "href=\"http://wow.allakhazam.com" , $parsedrecipes[$index][$nr]['icon']);
  190. $parsedrecipes[$index][$nr]['icon'] = str_replace("\"><img", "&locale=".$roster->data['clientLocale']."\"><img" , $parsedrecipes[$index][$nr]['icon']);
  191. preg_match_all('/(\<a[^\>]* href=\"([^\"]*)\"\>)([^<]*)/i',$lines[2][1],$name);
  192. // aprint($name);
  193. $parsedrecipes[$index][$nr]['name'] = $name[3][0];
  194. //preg_match('/href=\"([^\"]*)\"/i',$lines[2][5],$link);
  195. //$recipes[$index][$nr]['components'] = $lines[2][4];
  196. if(array_key_exists('0',$name[2]))
  197. {
  198. $parsedrecipes[$index][$nr]['i_link'] = $name[2][0];
  199. }
  200. //$recipes[$index][$nr]['category'] = $lines[2][2];
  201. $parsedrecipes[$index][$nr]['skill'] = $lines[2][3];
  202. // preg_match('/(\<a[^\>]* href=\"([^\"]*)\"\>)([^<]*)(.*(\<a[^\>]* href=\"([^\"]*)\"\>\<span[^\>]*\>)([^<]*))?/i',$lines[2][1],$name);
  203. $parsedrecipes[$index][$nr]['r_link'] = $name[2][0];
  204. if (isset($name[3][1]))
  205. {
  206. $parsedrecipes[$index][$nr]['pat_link'] = $name[2][1];
  207. $parsedrecipes[$index][$nr]['pat_name'] = $name[3][1];
  208. }
  209. }
  210. }
  211. //aprint($parsedrecipes);
  212. $known = recipe_get_many( $charid,'', 'level' );
  213. // aprint($known);
  214. $all_count = array();
  215. foreach($known as $kindex => $krecipe)
  216. {
  217. $knownrecipenames[]=$krecipe->data['recipe_name'];
  218. }
  219. foreach($skill_list as $sindex => $skill)
  220. {
  221. foreach($parsedrecipes[$sindex] as $nr => $recipe)
  222. {
  223. $allrecipenames[$sindex][]=str_replace("&nbsp;"," ",$recipe['name']);
  224. }
  225. // $diffrecipenames[$sindex] = array_diff($allrecipenames[$sindex],$knownrecipenames);
  226. foreach($allrecipenames[$sindex] as $recipekey => $recipename) {
  227. if (!in_array($recipename,$knownrecipenames)) {
  228. $diffrecipenames[$sindex][$recipekey]=$recipename;
  229. }
  230. }
  231. $all_count[$sindex] = count($allrecipenames[$sindex]);
  232. // aprint($allrecipenames[$sindex]);
  233. // aprint($knownrecipenames);
  234. // aprint($diffrecipenames[$sindex]);
  235. }
  236. //aprint($allrecipenames);
  237. //aprint($knownrecipenames);
  238. //aprint($skill_level);
  239. //aprint($diffrecipenames);
  240. //aprint($known_count);
  241. //aprint($all_count);
  242. foreach($skill_list as $sindex => $skill_name)
  243. {
  244. list($charskill_level, $maxskill_level) = explode(':', $skill_level[$sindex], 2);
  245. // make skill header
  246. // Set an link to the top behind the profession image
  247. $skill_image = 'Interface/Icons/' . $roster->locale->wordings[$roster->data['clientLocale']]['ts_iconArray'][$skill_name];
  248. $percentage = round(($known_count[$sindex]/$all_count[$sindex])*100);
  249. $tooltip = makeOverlib($known_count[$sindex] .'/'. $all_count[$sindex] . ' - ' . $percentage,'','',2,'',',WRAP');
  250. /* $cell_value = '<div ' . $tooltip . ' style="cursor:default;"><div class="levelbarParent" style="width:70px;"><div class="levelbarChild">' . $know_count[$sindex] .'/'. $all_count[$sindex] . ' - ' . $percentage . '</div></div>';
  251. $cell_value .= '<table class="expOutline" border="0" cellpadding="0" cellspacing="0" width="70">';
  252. $cell_value .= '<tr>';
  253. $cell_value .= '<td style="background-image: url(\'' . $roster->config['img_url'] . 'expbar-var2.gif\');" width="' . $percentage . '%"><img src="' . $roster->config['img_url'] . 'pixel.gif" height="14" width="1" alt="" /></td>';
  254. $cell_value .= '<td width="' . (100 - $percentage) . '%"></td>';
  255. $cell_value .= "</tr>\n</table>\n</div>\n";
  256. return '<div style="display:none;">' . str_pad($row['level'],2,'0',STR_PAD_LEFT) . '</div>' . $cell_value;
  257. */
  258. $roster->tpl->assign_block_vars('mr_skill', array(
  259. 'INDEX' => $sindex,
  260. 'ICON' => $skill_image,
  261. 'ANCHOR' => strtolower(str_replace(' ','',$skill_name)),
  262. 'NAME' => $skill_name,
  263. 'LEVEL' => $charskill_level,
  264. 'MAXLEVEL' => $maxskill_level,
  265. 'TOOLTIP' => $tooltip,
  266. 'PERCENTAGE' => $percentage,
  267. 'LPERCENTAGE' => 100-$percentage,
  268. 'KCOUNT' => $known_count[$sindex],
  269. 'ACOUNT' => $all_count[$sindex],
  270. )
  271. );
  272. foreach($diffrecipenames[$sindex] as $dindex => $diffrecipename)
  273. {
  274. // make recipe row
  275. // skill level color (thanks to Ulminia)
  276. // Improved skill color by Zanix
  277. // Strip out &nbsp; for a clean match
  278. $skill_check = str_replace('&nbsp;','',$parsedrecipes[$sindex][$dindex]['skill']);
  279. preg_match_all('/<span class="(.+?)">(.+?)<\/span>/i',$skill_check,$skillmatches);
  280. // Check for difficulty level, set to red if it doesn't meet orange level
  281. // Also keep the previous color if it doesn't exceed the next level
  282. $skill_color = ( $charskill_level >= $skillmatches[2][0] ? 'orange' : 'red');
  283. $skill_color = ( $charskill_level >= $skillmatches[2][1] ? 'yellow' : $skill_color);
  284. $skill_color = ( $charskill_level >= $skillmatches[2][2] ? 'green' : $skill_color);
  285. $skill_color = ( $charskill_level >= $skillmatches[2][3] ? 'grey' : $skill_color);
  286. // Implode the color level arry into a string we can use
  287. $skill_levels = implode(' ',$skillmatches[2]);
  288. // Check if the recipe exists in the database and use the tooltip data
  289. $sqlquery = 'SELECT recipe_name, item_color, recipe_tooltip FROM '.$roster->db->table('recipes').' WHERE recipe_name = \''.addslashes($parsedrecipes[$sindex][$dindex]['name']).'\'';
  290. $sqlresult = $roster->db->query($sqlquery);
  291. $sqlrow = $roster->db->fetch($sqlresult);
  292. $inserttt = '';
  293. if ($sqlrow)
  294. {
  295. $inserttt = makeOverlib($sqlrow['recipe_tooltip']."\n",$sqlrow['recipe_name'],'',0,'','');
  296. }
  297. $link = '';
  298. if(array_key_exists('i_link', $parsedrecipes[$sindex][$dindex]))
  299. {
  300. if ($addon['config']['mr_show_wowheadtooltips']) {
  301. $link = "http://".$roster->locale->act['wowhead_hostname'].".wowhead.com/?item=".get_icon_linka($parsedrecipes[$sindex][$dindex]['icon']);
  302. } else {
  303. $link = 'http://wow.allakhazam.com'.$parsedrecipes[$sindex][$dindex]['i_link'];
  304. }
  305. }
  306. $plink = $pname = '';
  307. if(array_key_exists('pat_link', $parsedrecipes[$sindex][$dindex]))
  308. {
  309. if ($addon['config']['mr_show_wowheadtooltips']) {
  310. $plink = "http://".$roster->locale->act['wowhead_hostname'].".wowhead.com/?item=".get_icon_link($parsedrecipes[$sindex][$dindex]['pat_link']);
  311. } else {
  312. $plink = "http://wow.allakhazam.com".$parsedrecipes[$sindex][$dindex]['pat_link'];
  313. }
  314. $pname = $parsedrecipes[$sindex][$dindex]['pat_name'];
  315. }
  316. $roster->tpl->assign_block_vars('mr_skill.mr_recipe', array(
  317. 'ROW_CLASS' => $roster->switch_row_class(),
  318. 'TOOLTIP' => $inserttt,
  319. 'ICON' => $parsedrecipes[$sindex][$dindex]['icon'],
  320. 'NAME' => $parsedrecipes[$sindex][$dindex]['name'],
  321. 'SKILL' => $skill_levels,
  322. 'LINK' => $link,
  323. 'PNAME' => $pname,
  324. 'PLINK' => $plink,
  325. 'SKILLCOLOR' => $skill_color,
  326. )
  327. );
  328. }
  329. }
  330. $roster->tpl->set_handle('mr',$addon['basename'] . '/mr.html');
  331. $roster->tpl->display('mr');