summaryrefslogtreecommitdiffstats
path: root/rpm.php
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2010-10-31 18:02:59 +0100
committerRemi Collet <fedora@famillecollet.com>2010-10-31 18:02:59 +0100
commitefc4cbd224958735e5673507c2acd4efe43ffc65 (patch)
tree3d178d14c4d77d15dcd245d7f0024adb86609737 /rpm.php
parent13f5a889da9cd6fcb864ae0b84eb31e4e97a9d10 (diff)
create TableUpstream class and use it everywhere
Diffstat (limited to 'rpm.php')
-rw-r--r--rpm.php271
1 files changed, 134 insertions, 137 deletions
diff --git a/rpm.php b/rpm.php
index b223130..93f6308 100644
--- a/rpm.php
+++ b/rpm.php
@@ -62,170 +62,167 @@ function report($db, $type)
global $what, $smarty;
$packages = null;
$rpmrepo = new TableRpmRepo($db);
+ $uptable = new TableUpstream($db);
+
$repos = $rpmrepo->getAllRepoHash();
$smarty->assign('repos', $repos);
$i=0;
- $resup=$db->query("SELECT * FROM upstream WHERE type='$type' ORDER BY name");
- if ($resup) {
- while ($upstream = $resup->fetchObject()) {
- $package = null;
- $rpmname = $upstream->name;
+ foreach($uptable->request(array('type'=>$type, 'ORDER'=>'name')) as $up) {
+ $package = null;
+ $rpmname = $up['name'];
- $verup = strtolower(
- $upstream->stable ? $upstream->stable : $upstream->unstable
- );
+ $verup = strtolower($up['stable'] ? $up['stable'] : $up['unstable']);
- $sql2="SELECT DISTINCT owner FROM acls WHERE name = '$rpmname'";
- $res2=$db->query($sql2);
- $owners=array();
- if ( $res2 ) {
- while ($owner= $res2->fetchObject()) {
- $owners[] = $owner->owner;
- }
+ $sql2="SELECT DISTINCT owner FROM acls WHERE name = '$rpmname'";
+ $res2=$db->query($sql2);
+ $owners=array();
+ if ( $res2 ) {
+ while ($owner= $res2->fetchObject()) {
+ $owners[] = $owner->owner;
}
+ }
- $sql = "SELECT * FROM rpm WHERE name = '$rpmname'";
+ $sql = "SELECT * FROM rpm WHERE name = '$rpmname'";
- $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());
- }
+ $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());
+ }
- switch ($what) {
- case '%work':
- $display = false;
- if (count($rpms)
- && isset($rpms['devel-'])
- && $rpms['devel-']->ver != $verup
- ) {
- $display = true;
- }
- break;
- case '%fedora':
- $display = (count($rpms));
- break;
- case '%stable':
- $display = !empty($upstream->stable);
- break;
- case '%all':
+ switch ($what) {
+ case '%work':
+ $display = false;
+ if (count($rpms)
+ && isset($rpms['devel-'])
+ && $rpms['devel-']->ver != $verup
+ ) {
$display = true;
- break;
- default: // owner
- $display = (array_search($what, $owners) !== false);
- break;
}
+ break;
+ case '%fedora':
+ $display = (count($rpms));
+ break;
+ case '%stable':
+ $display = !empty($up['stable']);
+ break;
+ case '%all':
+ $display = true;
+ break;
+ default: // owner
+ $display = (array_search($what, $owners) !== false);
+ break;
+ }
- if ($display) {
- if ($rpm) {
- $package['name'] = '<a href="zoom.php?rpm=' . $rpmname .
- '" title="' . htmlentities($rpm->summary) . '">' .
- $rpmname . '</a>';
- } else {
- $package['name'] = $rpmname;
- }
- if ( $upstream->channel != $upstream->type ) {
- $package['channel'] = $upstream->channel;
- }
+ if ($display) {
+ if ($rpm) {
+ $package['name'] = '<a href="zoom.php?rpm=' . $rpmname .
+ '" title="' . htmlentities($rpm->summary) . '">' .
+ $rpmname . '</a>';
+ } else {
+ $package['name'] = $rpmname;
+ }
+ if ($up['channel'] != $up['type']) {
+ $package['channel'] = $up['channel'];
+ }
- $dispowner="";
- $package['owners'] = $owners;
- if ( $upstream->stable ) {
- $package['upstream_stable'] = $upstream->stable;
- }
- if ( $upstream->unstable
- && (!$upstream->stable
- || $upstream->stable!=$upstream->unstable)
- ) {
- $package['upstream_unstable'] = $upstream->unstable .
- ' <small>(' . $upstream->state . ')</small>';
- }
+ $dispowner="";
+ $package['owners'] = $owners;
+ if ($up['stable']) {
+ $package['upstream_stable'] = $up['stable'];
+ }
+ if ($up['stable']
+ && (!$up['unstable']
+ || $up['stable']!=$up['unstable'])
+ ) {
+ $package['upstream_unstable'] = $up['unstable'] .
+ ' <small>(' . $up['state'] . ')</small>';
+ }
- $versions = null;
- foreach ( $repos as $repomain ) {
- $display="";
- $class="";
- foreach ( $repomain as $k=>$repo ) {
- if ( isset($rpms[$repo['main']."-".$repo['sub']]) ) {
- $rpm=$rpms[$repo['main']."-".$repo['sub']];
+ $versions = null;
+ foreach ( $repos as $repomain ) {
+ $display="";
+ $class="";
+ foreach ( $repomain as $k=>$repo ) {
+ if ( isset($rpms[$repo['main']."-".$repo['sub']]) ) {
+ $rpm=$rpms[$repo['main']."-".$repo['sub']];
- $verpm=$rpm->ver;
- $pat = "/\.((beta|RC)\d*)\./i";
- if (preg_match($pat, $rpm->rel, $res)) {
- $verpm .= strtolower($res[1]);
- }
+ $verpm=$rpm->ver;
+ $pat = "/\.((beta|RC)\d*)\./i";
+ if (preg_match($pat, $rpm->rel, $res)) {
+ $verpm .= strtolower($res[1]);
+ }
- switch ($repo['sub']) {
- case "base":
- if ( isset($rpms[$repo['main']."-updates"]) ) {
- $display .= sprintf(
- "%s-%s<br/>",
- $rpm->ver,
- $rpm->rel
- );
- } else {
- $display .= sprintf(
- "<strong>%s</strong>-%s<br/>",
- $rpm->ver,
- $rpm->rel
- );
- }
- if ( $verup==$verpm ) {
- $class="check";
- }
- break;
- case "":
+ switch ($repo['sub']) {
+ case "base":
+ if ( isset($rpms[$repo['main']."-updates"]) ) {
$display .= sprintf(
- "<strong>%s</strong>-%s<br/>",
+ "%s-%s<br/>",
$rpm->ver,
$rpm->rel
);
- if ( $verup==$verpm ) {
- $class="check";
- }
- break;
- case "updates":
+ } else {
$display .= sprintf(
- "<strong>%s</strong>-%s ".
- "<small>(updates)</small><br/>",
- $rpm->ver,
- $rpm->rel
- );
- if ( $verup==$verpm ) {
- $class="check";
- }
- break;
- case "testing":
- $display .= sprintf(
- "%s-%s <small>(testing)</small><br/>",
+ "<strong>%s</strong>-%s<br/>",
$rpm->ver,
$rpm->rel
);
- if ( $verup==$verpm ) {
- $class="info";
- }
- break;
}
- } // RPM exists
- } // sub repo
- if ( $display && empty($class) ) {
- $class="attn";
- }
- $versions[] = array(
- 'class' => $class,
- 'display' => $display
- );
- $package['versions'] = $versions;
- } // mainrepo
+ if ( $verup==$verpm ) {
+ $class="check";
+ }
+ break;
+ case "":
+ $display .= sprintf(
+ "<strong>%s</strong>-%s<br/>",
+ $rpm->ver,
+ $rpm->rel
+ );
+ if ( $verup==$verpm ) {
+ $class="check";
+ }
+ break;
+ case "updates":
+ $display .= sprintf(
+ "<strong>%s</strong>-%s ".
+ "<small>(updates)</small><br/>",
+ $rpm->ver,
+ $rpm->rel
+ );
+ if ( $verup==$verpm ) {
+ $class="check";
+ }
+ break;
+ case "testing":
+ $display .= sprintf(
+ "%s-%s <small>(testing)</small><br/>",
+ $rpm->ver,
+ $rpm->rel
+ );
+ if ( $verup==$verpm ) {
+ $class="info";
+ }
+ break;
+ }
+ } // RPM exists
+ } // sub repo
+ if ( $display && empty($class) ) {
+ $class="attn";
+ }
+ $versions[] = array(
+ 'class' => $class,
+ 'display' => $display
+ );
+ $package['versions'] = $versions;
+ } // mainrepo
- $i++;
- $packages[] = $package;
- }
- } // each $unstable
+ $i++;
+ $packages[] = $package;
+ }
}
return $packages;
}