From 1421a2207c0130030233e901d6f5055f54417e68 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 1 Nov 2010 08:25:47 +0100 Subject: use TableRpm in rpm.php --- rpm.php | 58 ++++++++++++++++++----------------------- smarty/templates/rpmphp/rpm.tpl | 2 +- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/rpm.php b/rpm.php index 3b3a2a9..5b298e8 100644 --- a/rpm.php +++ b/rpm.php @@ -61,14 +61,15 @@ function report($db, $type) { global $what, $smarty; $packages = null; - $rpmrepo = new TableRpmRepo($db); - $uptable = new TableUpstream($db); + $rpmrepo = new TableRpmRepo($db); + $rpmtable = new TableRpm($db); + $uptable = new TableUpstream($db); $repos = $rpmrepo->getAllRepoHash(); $smarty->assign('repos', $repos); $i=0; - foreach($uptable->request(array('type'=>$type, 'ORDER'=>'name')) as $up) { + foreach ($uptable->request(array('type'=>$type, 'ORDER'=>'name')) as $up) { $package = null; $rpmname = $up['name']; @@ -83,15 +84,14 @@ function report($db, $type) } } - $sql = "SELECT * FROM rpm WHERE name = '$rpmname'"; + $package['name'] = $rpmname; + $rpms = array(); + foreach ($rpmtable->request(array('name'=>$rpmname)) as $rpm) { + $rpms[$rpm['repo_main'].'-'.$rpm['repo_sub']] = $rpm; - $res=$db->query($sql); - $rpm = ($res ? $res->fetchObject() : false); - $rpms=array(); - if ( $rpm ) { - do { - $rpms[$rpm->repo_main."-".$rpm->repo_sub]=$rpm; - } while ($rpm = $res->fetchObject()); + $package['name'] = '' . $rpmname . ''; } switch ($what) { @@ -99,7 +99,7 @@ function report($db, $type) $display = false; if (count($rpms) && isset($rpms['devel-']) - && $rpms['devel-']->ver != $verup + && $rpms['devel-']['ver'] != $verup ) { $display = true; } @@ -119,13 +119,6 @@ function report($db, $type) } if ($display) { - if ($rpm) { - $package['name'] = '' . - $rpmname . ''; - } else { - $package['name'] = $rpmname; - } if ($up['channel'] != $up['type']) { $package['channel'] = $up['channel']; } @@ -136,8 +129,7 @@ function report($db, $type) $package['upstream_stable'] = $up['stable']; } if ($up['unstable'] - && (!$up['stable'] - || $up['stable']!=$up['unstable']) + && (!$up['stable'] || $up['stable']!=$up['unstable']) ) { $package['upstream_unstable'] = $up['unstable'] . ' (' . $up['state'] . ')'; @@ -151,9 +143,9 @@ function report($db, $type) if ( isset($rpms[$repo['main']."-".$repo['sub']]) ) { $rpm=$rpms[$repo['main']."-".$repo['sub']]; - $verpm=$rpm->ver; + $verpm = $rpm['ver']; $pat = "/\.((beta|RC)\d*)\./i"; - if (preg_match($pat, $rpm->rel, $res)) { + if (preg_match($pat, $rpm['rel'], $res)) { $verpm .= strtolower($res[1]); } @@ -162,14 +154,14 @@ function report($db, $type) if ( isset($rpms[$repo['main']."-updates"]) ) { $display .= sprintf( "%s-%s
", - $rpm->ver, - $rpm->rel + $rpm['ver'], + $rpm['rel'] ); } else { $display .= sprintf( "%s-%s
", - $rpm->ver, - $rpm->rel + $rpm['ver'], + $rpm['rel'] ); } if ( $verup==$verpm ) { @@ -179,8 +171,8 @@ function report($db, $type) case "": $display .= sprintf( "%s-%s
", - $rpm->ver, - $rpm->rel + $rpm['ver'], + $rpm['rel'] ); if ( $verup==$verpm ) { $class="check"; @@ -190,8 +182,8 @@ function report($db, $type) $display .= sprintf( "%s-%s ". "(updates)
", - $rpm->ver, - $rpm->rel + $rpm['ver'], + $rpm['rel'] ); if ( $verup==$verpm ) { $class="check"; @@ -200,8 +192,8 @@ function report($db, $type) case "testing": $display .= sprintf( "%s-%s (testing)
", - $rpm->ver, - $rpm->rel + $rpm['ver'], + $rpm['rel'] ); if ( $verup==$verpm ) { $class="info"; diff --git a/smarty/templates/rpmphp/rpm.tpl b/smarty/templates/rpmphp/rpm.tpl index b0d942f..9f9d94f 100644 --- a/smarty/templates/rpmphp/rpm.tpl +++ b/smarty/templates/rpmphp/rpm.tpl @@ -66,7 +66,7 @@ {foreach from=$packages item=p name=plist} - {$p.name} + {$p.name} {if $p.channel}
channel: {$p.channel} {/if} -- cgit