diff options
author | Remi Collet <fedora@famillecollet.com> | 2010-08-07 18:32:09 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2010-08-07 18:32:09 +0200 |
commit | fe3d37364bbc072aedac951d4b2acc724ba7393a (patch) | |
tree | dc8dcc9ec2f864962dba5c59f46289659861495e /index.php | |
parent | 6d2954c5e9da8cd36c231114df5184d4a3101ddd (diff) |
add Class TableRpmRepo and use it everywhere
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 44 |
1 files changed, 22 insertions, 22 deletions
@@ -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 : " "), - 'active' => ($repo->main != $prev ? - ($repo->active ? "<strong>Yes</strong>" : "no") : - " " - ), - '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'] : " "), + 'active' => ($repo['main'] != $prev ? + ($repo['active'] ? "<strong>Yes</strong>" : "no") : + " " + ), + '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); |