summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2010-08-07 18:32:09 +0200
committerRemi Collet <fedora@famillecollet.com>2010-08-07 18:32:09 +0200
commitfe3d37364bbc072aedac951d4b2acc724ba7393a (patch)
treedc8dcc9ec2f864962dba5c59f46289659861495e /index.php
parent6d2954c5e9da8cd36c231114df5184d4a3101ddd (diff)
add Class TableRpmRepo and use it everywhere
Diffstat (limited to 'index.php')
-rw-r--r--index.php44
1 files changed, 22 insertions, 22 deletions
diff --git a/index.php b/index.php
index 24d4fbd..03412ef 100644
--- a/index.php
+++ b/index.php
@@ -39,38 +39,38 @@ require 'include/main.php';
$smarty->assign('ariane', $ariane);
$smarty->assign('page_title', 'Packages in Fedora repositories');
+
try {
$db = new PDO ("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS);
- $sql='SELECT * FROM repo ORDER BY ID';
- $res=$db->query($sql);
- $repositories = null;
- if ( $res ) {
- for ( $i=0, $prev="xx";
- $repo=$res->fetchObject();
- $i++, $prev=$repo->main
- ) {
- $repositories[] = array(
- 'repo_name' => ($repo->main != $prev ? $repo->main : "&nbsp;"),
- 'active' => ($repo->main != $prev ?
- ($repo->active ? "<strong>Yes</strong>" : "no") :
- "&nbsp;"
- ),
- 'sub_name' => $repo->sub,
- 'url' => $repo->url,
- 'date' => ($repo->stamp
- ? date("r", $repo->stamp)
- : '')
- );
- }
- $smarty->assign('repositories', $repositories);
+ $repo = new TableRpmRepo($db);
+
+ $prev = false;
+ $repositories = array();
+ foreach ($repo->request(array('ORDER'=>'id')) as $repo) {
+ $repositories[] = array(
+ 'repo_name' => ($repo['main'] != $prev ? $repo['main'] : "&nbsp;"),
+ 'active' => ($repo['main'] != $prev ?
+ ($repo['active'] ? "<strong>Yes</strong>" : "no") :
+ "&nbsp;"
+ ),
+ 'sub_name' => $repo['sub'],
+ 'url' => $repo['url'],
+ 'date' => ($repo['stamp']
+ ? date("r", $repo['stamp'])
+ : '')
+ );
+ $prev = $repo['main'];
}
+ $smarty->assign('repositories', $repositories);
+
} catch(PDOException $e) {
$smarty->assign(
'error',
sprintf("%s ERREUR : %s\n", date("r"), $e->getMessage())
);
}
+
$smarty->assign('rpmphp_version', RPMPHP_VERSION);
$smarty->assign('fedcli_version', FedoraClient::VERSION);