<div class="faction-fill" style="width: %d%%;"></div>
         </div>
         </div>
         <div class="faction-level">%s</div>
         <span class="clear"><!-- --></span>
         </div>
         </li>
         ', $subcategories['type'], $subcategories['id'], $subcategories['name'], $subcategories['name'], $subcategories['adjusted'], $subcategories['cap'], $subcategories['percent'], WoW_Locale::GetString('reputation_rank_' . $subcategories['type']));
 } elseif (isset($subcategories[0])) {
     echo sprintf('<li class="reputation-subcategory">
         <div class="faction-details faction-subcategory-details ">
         <h4 class="faction-header">%s</h4>
         <span class="clear"><!-- --></span>
         </div>
         <ul class="factions">
         ', WoW_Reputation::GetFactionNameFromDB($subcat_id));
     foreach ($subcategories as $catid => $cat) {
         echo sprintf('<li class="faction-details">
             <div class="rank-%d">
             <a href="javascript:;" data-fansite="faction|%d|%s" class="fansite-link float-right"> </a>
             <span class="faction-name">%s</span>
             <div class="faction-standing">
             <div class="faction-bar">
             <div class="faction-score">%d/%d</div>
             <div class="faction-fill" style="width: %d%%;"></div>
             </div>
             </div>
             <div class="faction-level">%s</div>
             <span class="clear"><!-- --></span>
             </div>
             </li>
 private static function LoadFactions()
 {
     $factions = DB::WoW()->select("SELECT `id`, `category`, `name_%s` AS `name` FROM `DBPREFIX_faction` WHERE `id` IN (%s) ORDER BY `id` DESC", WoW_Locale::GetLocale(), self::GetFactionsIDs());
     if (!$factions) {
         WoW_Log::WriteError('%s : unable to load factions info for character %d!', __METHOD__, self::$guid);
         return false;
     }
     // Default categories
     $categories = array(1118 => array(67 => array('order' => 1, 'side' => FACTION_HORDE), 892 => array('order' => 2, 'side' => FACTION_HORDE), 469 => array('order' => 1, 'side' => FACTION_ALLIANCE), 891 => array('order' => 2, 'side' => FACTION_ALLIANCE), 169 => array('order' => 3, 'side' => -1)), 980 => array(936 => array('order' => 1, 'side' => -1)), 1097 => array(1117 => array('order' => 1, 'side' => -1), 1052 => array('order' => 2, 'side' => FACTION_HORDE), 1037 => array('order' => 2, 'side' => FACTION_ALLIANCE)), 0 => array(589 => array('order' => 1, 'side' => FACTION_ALLIANCE), 70 => array('order' => 2, 'side' => -1)));
     $storage = array();
     foreach ($factions as $faction) {
         // Standing & adjusted values
         $standing = min(42999, self::$reputation[$faction['id']]['standing']);
         $type = REP_EXALTED;
         $rep_cap = 999;
         $rep_adjusted = $standing - 42000;
         if ($standing < REPUTATION_VALUE_HATED) {
             $type = REP_HATED;
             $rep_cap = 36000;
             $rep_adjusted = $standing + 42000;
         } elseif ($standing < REPUTATION_VALUE_HOSTILE) {
             $type = REP_HOSTILE;
             $rep_cap = 3000;
             $rep_adjusted = $standing + 6000;
         } elseif ($standing < REPUTATION_VALUE_UNFRIENDLY) {
             $type = REP_UNFRIENDLY;
             $rep_cap = 3000;
             $rep_adjusted = $standing + 3000;
         } elseif ($standing < REPUTATION_VALUE_NEUTRAL) {
             $type = REP_NEUTRAL;
             $rep_cap = 3000;
             $rep_adjusted = $standing;
         } elseif ($standing < REPUTATION_VALUE_FRIENDLY) {
             $type = REP_FRIENDLY;
             $rep_cap = 6000;
             $rep_adjusted = $standing - 3000;
         } elseif ($standing < REPUTATION_VALUE_HONORED) {
             $type = REP_HONORED;
             $rep_cap = 12000;
             $rep_adjusted = $standing - 9000;
         } elseif ($standing < REPUTATION_VALUE_REVERED) {
             $type = REP_REVERED;
             $rep_cap = 21000;
             $rep_adjusted = $standing - 21000;
         }
         $faction['standing'] = self::$reputation[$faction['id']]['standing'];
         $faction['type'] = $type;
         $faction['cap'] = $rep_cap;
         $faction['adjusted'] = $rep_adjusted;
         $faction['percent'] = WoW_Utils::GetPercent($rep_cap, $rep_adjusted);
         if (isset($categories[$faction['category']])) {
             if (!isset($storage[$faction['category']])) {
                 $storage[$faction['category']] = array();
             }
             $storage[$faction['category']][] = $faction;
         } else {
             foreach ($categories as $catId => $subcat) {
                 if (isset($categories[$catId][$faction['category']])) {
                     if (!isset($categories[$catId][$faction['category']])) {
                         $categories[$catId][$faction['category']] = array();
                     }
                     $storage[$catId][$faction['category']][] = $faction;
                 }
             }
         }
     }
     self::$factions = $storage;
     unset($storage);
     return true;
 }
 public function main()
 {
     WoW_Template::SetPageData('body_class', WoW_Locale::GetLocale(LOCALE_DOUBLE));
     WoW_Template::SetTemplateTheme('wow');
     $url_data = WoW::GetUrlData('character');
     if (!$url_data) {
         WoW_Template::SetPageIndex('404');
         WoW_Template::SetPageData('page', '404');
         WoW_Template::SetPageData('errorProfile', 'template_404');
     } else {
         if ($url_data['action0'] == 'advanced') {
             // Set "wow.character.summary.view" cookie as "advanced"
             setcookie('wow.character.summary.view', 'advanced', strtotime('NEXT YEAR'), '/' . WoW::GetWoWPath() . '/character/');
         } elseif ($url_data['action0'] == null && (isset($url_data['name']) && isset($url_data['realmName']))) {
             WoW::RedirectToCorrectProfilePage('simple');
             //change to WoW::RedirectTo()?
         } elseif ($url_data['action0'] == 'simple') {
             // Set "wow.character.summary.view" cookie as "simple"
             setcookie('wow.character.summary.view', 'simple', strtotime('NEXT YEAR'), '/' . WoW::GetWoWPath() . '/character/');
         }
         $load_result = WoW_Characters::LoadCharacter($url_data['name'], WoW_Utils::GetRealmIDByName($url_data['realmName']), true, true);
         if (!WoW_Characters::IsCorrect() || $load_result != 3) {
             if ($url_data['action0'] == 'tooltip') {
                 exit;
             }
             if ($load_result == 2) {
                 WoW_Template::SetPageData('errorProfile', 'template_lowlevel');
             } else {
                 WoW_Template::SetPageData('errorProfile', 'template_404');
             }
             WoW_Template::SetPageIndex('404');
             WoW_Template::SetPageData('page', '404');
         } else {
             WoW_Achievements::Initialize();
             WoW_Template::SetPageData('characterName', WoW_Characters::GetName());
             WoW_Template::SetPageData('characterRealmName', WoW_Characters::GetRealmName());
             switch ($url_data['action0']) {
                 default:
                     WoW_Template::SetPageIndex('character_profile_simple');
                     WoW_Template::SetPageData('page', 'character_profile');
                     WoW_Characters::CalculateStats(true);
                     break;
                 case 'advanced':
                     WoW_Template::SetPageIndex('character_profile_advanced');
                     WoW_Template::SetPageData('page', 'character_profile');
                     WoW_Characters::CalculateStats(true);
                     break;
                     /*
                     case 'talent':
                         WoW_Template::SetPageIndex('character_talents');
                         WoW_Template::SetPageData('page', 'character_talents');
                         WoW_Template::SetPageData('talents', 'primary');
                         if($url_data['action1'] == 'secondary') {
                             WoW_Template::SetPageData('talents', 'secondary');
                         }
                         break;
                     */
                 /*
                 case 'talent':
                     WoW_Template::SetPageIndex('character_talents');
                     WoW_Template::SetPageData('page', 'character_talents');
                     WoW_Template::SetPageData('talents', 'primary');
                     if($url_data['action1'] == 'secondary') {
                         WoW_Template::SetPageData('talents', 'secondary');
                     }
                     break;
                 */
                 case 'tooltip':
                     WoW_Template::LoadTemplate('page_character_tooltip');
                     exit;
                     break;
                 case 'achievement':
                     for ($i = 2; $i > 0; $i--) {
                         if (isset($url_data['action' . $i]) && $url_data['action' . $i] != null) {
                             WoW_Achievements::SetCategoryForTemplate($url_data['action' . $i]);
                             WoW_Template::LoadTemplate('page_character_achievements');
                             exit;
                         }
                     }
                     WoW_Template::SetPageIndex('character_achievements');
                     WoW_Template::SetPageData('page', 'character_achievements');
                     break;
                 case 'reputation':
                     if (isset($url_data['action1']) && $url_data['action1'] == 'tabular') {
                         WoW_Template::SetPageIndex('character_reputation_tabular');
                     } else {
                         WoW_Template::SetPageIndex('character_reputation');
                     }
                     WoW_Template::SetPageData('page', 'character_reputation');
                     WoW_Reputation::InitReputation(WoW_Characters::GetGUID());
                     break;
                 case 'pvp':
                     WoW_Template::SetPageIndex('character_pvp');
                     WoW_Template::SetPageData('page', 'character_pvp');
                     WoW_Characters::InitPvP();
                     break;
                 case 'statistic':
                     for ($i = 2; $i > 0; $i--) {
                         if (isset($url_data['action' . $i]) && $url_data['action' . $i] != null) {
                             WoW_Achievements::SetCategoryForTemplate($url_data['action' . $i]);
                             WoW_Template::LoadTemplate('page_character_statistics');
                             exit;
                         }
                     }
                     WoW_Template::SetPageIndex('character_statistics');
                     WoW_Template::SetPageData('page', 'character_statistics');
                     break;
                 case 'feed':
                     WoW_Template::SetPageIndex('character_feed');
                     WoW_Template::SetPageData('page', 'character_feed');
                     break;
                 case 'companion':
                 case 'mount':
                     WoW_Template::SetPageIndex('character_companions_mounts');
                     WoW_Template::SetPageData('page', 'character_companions_mounts');
                     WoW_Template::SetPageData('category', $url_data['action0']);
                     WoW_Characters::InitMounts();
                     break;
             }
         }
     }
     WoW_Template::SetMenuIndex('menu-game');
     WoW_Template::LoadTemplate('page_index');
 }
		<table id="sortable">
			<thead>
				<tr>
					<th><a href="#" class="sort-link"><span class="arrow"><?php 
echo WoW_Locale::GetString('template_reputation_table_name');
?>
</span></a></th>
					<th colspan="2"><a href="#" class="sort-link numeric"><span class="arrow"><?php 
echo WoW_Locale::GetString('template_reputation_table_standing');
?>
</span></a></th>
				</tr>
			</thead>
			<tbody>
            <?php 
$reputation = WoW_Reputation::GetReputation();
$toggleStyle = 2;
if (is_array($reputation)) {
    foreach ($reputation as $categories) {
        foreach ($categories as $subcat) {
            if (isset($subcat['id'])) {
                echo sprintf('<tr class="row%d">
                            <td><span class="faction-name">%s</span></td>
                            <td class="rank-%d" data-raw="%d.%d"><div class="faction-standing"><div class="faction-bar">
                            <div class="faction-score">%d/%d</div>
                            <div class="faction-fill" style="width: %d%%;"></div>
                            </div>
                            </div>
                            </td>
                            <td class="rank-%d" data-raw="%d">
                            <a href="javascript:;" data-fansite="faction|%d|%s" class="fansite-link float-right"> </a>