<?php 
define('THIS_SCRIPT', 'os_publisher');
$loadCacheItems = array('lastFive');
include "admin/main/config.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><head>
<title>Operation Sports - Sports Video Games Publishers</title>
<meta name="description" content="Operation Sports - is dedicated to information about sports video games, Madden, Fifa, sports news, press releases, reviews, screenshots of games" />
<meta name="keywords" content="Publishers, Sports Video Games, Sports Video Games Publishers, sports Publishers, Madden Screenshots, Madden 09, FIFA reviews, FIFA, sports, video games, Football Publishers, Baseball Publishers, Basketball Publishers, Golf Publishers, Hockey Publishers, games Publishers, sports Publishers " />

<link rel="stylesheet" type="text/css" media="screen" href="http://forums.operationsports.com/css/gen_stylev3_<?=filemtime('css/gen_stylev3.css')?>.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
<!--
	var minchars = <?php echo $vbulletin->options['postminchars']?>;
	var SECURITYTOKEN = "<?=$vbulletin->userinfo['securitytoken']?>";
	var BBURL = '<?=$vbulletin->options['bburl2']?>';
	var IMGDIR_MISC = "<?=$stylevar['imgdir_misc']?>";
	var SESSIONURL = "<?=$session['sessionurl_js']?>";
//-->
</script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/connection/connection-min.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>

<script type="text/javascript" src="http://forums.operationsports.com<?php echo $vbulletin->options['bburl2']; ?>/clientscript/vbulletin_global.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>
<script type="text/javascript" src="http://forums.operationsports.com<?php echo $vbulletin->options['bburl2']; ?>/clientscript/vbulletin_menu.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>
<link rel="shortcut icon" href="favicon.ico" >
</head>
<?php
include ("include/header_intergiv3.inc.php");
include (DIR . "/include/bannerlogin_temp_test_intergi.inc.php");
?>
<?php
$vbulletin->input->clean_array_gpc('r', array(
	'order'  => TYPE_STR,
	'sortby' => TYPE_STR
));

switch(strtolower($vbulletin->GPC['order']))
{
	case 'asc':
	case 'desc':
		break;
	default:
		$vbulletin->GPC['order'] = 'asc';
}

if(empty($vbulletin->GPC['sortby']) OR $vbulletin->GPC['sortby'] == 'publisher')
{
	$sql = "
		SELECT cms_publisher.id, cms_publisher.name AS name 
		FROM cms_publisher, cms_game
		WHERE cms_publisher.id = cms_game.publisher_id 
		GROUP BY cms_publisher.id
		ORDER BY cms_publisher.name {$vbulletin->GPC['order']}
	";
}
elseif($vbulletin->GPC['sortby'] == "games")
{
	$sql = "
		SELECT cms_publisher.id, cms_publisher.name AS name 
		FROM cms_publisher, cms_game
		WHERE cms_publisher.id = cms_game.publisher_id 
		GROUP BY cms_publisher.id
		ORDER BY (SELECT count(*) AS count FROM cms_game WHERE cms_game.publisher_id = cms_publisher.id) {$vbulletin->GPC['order']}, cms_publisher.name 
	";
}
$cnx = $db->query_read($sql);

?>
	<div id="left">
    	<?php include ("include/nav.inc.php"); ?>
	</div>
	<div id="content">
		<!--reviews content-->
<div id="title_med">
	<div id="title_text">Publishers</div>
</div>
<div id="overview">
<!--News post-->
	<div id="articlewrapp">
			<div id="articletext">
			<div class="articlecontent">




	<div id="over_row">
		<div id="over_column_165" style="width:75%;">&nbsp;&nbsp;<a href="<?if ($vbulletin->GPC['order'] == "desc" AND $vbulletin->GPC['sortby'] == "publisher"){?>?sortby=publisher&order=asc<?}else {?>?sortby=publisher&order=desc<?}?>" class="white">Publisher Name</a></div>
        <div id="over_column_58" style="width:20%;"><a href="<?if ($vbulletin->GPC['order'] == "desc" AND $vbulletin->GPC['sortby'] == "games"){?>?sortby=games&order=asc<?}else {?>?sortby=games&order=desc<?}?>" class="white">No. Games</a></div>
	</div>
<?
	while ($res = $db->fetch_array($cnx))
	{
		$rescount = $db->query_first("SELECT COUNT(*) AS count FROM cms_game WHERE cms_game.publisher_id = $res[id]");
?>
	<div id="over_row">
		<div id="over_column0_165" style="width:75%;">&nbsp;&nbsp;<a href="game.php?type=publisher&id=<? echo $res["id"]; ?>"  class="news"><? echo $res["name"]; ?></a></div>
        <div id="over_column0_58" style="width:20%;"><? echo $rescount["count"]; ?></div>

	</div>
	
<?
	}
?>
			</div>
			</div>
	</div>
<!--News post-->
</div>
		<!--/reviews content-->
	</div>
	<div id="right">

		<?php include ("include/last5.inc.php"); ?>
    	<?php include ("include/ad300x250.inc.php"); ?>
		<?php include ("include/games.inc.php"); ?>
		<?php include ("include/poll.inc.php"); ?>
	</div>
<?php 

include ("include/footer.inc.php"); 
exec_shut_down();

?>