diff options
author | Remi Collet <fedora@famillecollet.com> | 2010-05-30 08:40:54 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2010-05-30 08:40:54 +0200 |
commit | b2955d2b93937913334580dfad856e7b5c18c613 (patch) | |
tree | f788f81c482ba4c8aa9564a7d17c575c5f809ff5 /zoom.php | |
parent | 2c61a7ac0a3cfc86f74031ba6ec41ea81d4a8fcc (diff) | |
parent | caa9d9178232885b7e02aab8be94e01e438cc1d7 (diff) |
Merge branch 'master' of http://github.com/trasher/rpmphp
Diffstat (limited to 'zoom.php')
-rw-r--r-- | zoom.php | 323 |
1 files changed, 170 insertions, 153 deletions
@@ -1,173 +1,190 @@ <?php -require "config.inc.php"; -require "FedoraClient.php"; +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * Display informations from a specific package + * + * PHP version 5 + * + * Copyright © 2010 Remi Collet + * + * This file is part of rpmphp. + * + * rpmphp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * rpmphp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with rpmphp. If not, see <http://www.gnu.org/licenses/>. + * + * @category Main + * @package RPMPHP + * + * @author Remi Collet <unknown@unknwown.com> + * @author Johan Cwiklinski <johan@x-tnd.be> + * @copyright 2010 Remi Collet + * @license http://www.gnu.org/licenses/agpl-3.0-standalone.html AGPL License 3.0 or (at your option) any later version + * @version SVN: $Id: ajouter_adherent.php 836 2010-02-27 08:11:44Z trashy $ + * @link http://github.com/remicollet/rpmphp/ + * @since The begining of times. +*/ +require 'main.inc.php'; +require 'FedoraClient.php'; $fedcli = new FedoraPkgdb(); -if (!isset($_GET['rpm'])) { - die("missing arg."); -} $name = $_GET['rpm']; -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> - <head> - <title>Packages in Fedora</title> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <link rel="stylesheet" type="text/css" media="screen" href="css/rpmphp.css"/> - <!--<link rel="stylesheet" type="text/css" media="print" href="css/rpmphp-print.css">--> - <link rel="shortcut icon" href="images/favicon.ico"/> - <link rel="icon" href="images/favicon.ico"/> - </head> +$smarty->assign('name_required', true); +$smarty->assign('name', $name); +$ariane[] = array( + 'url' => '#', + 'text' => 'Package: ' . $name +); +$ajax_infos = '<span class="ajax">(wait for ajax or <a href="' . + $_SERVER['PHP_SELF'] . '?rpm='.$name. + '&pkgdb=1">reload with pkgdb</a>)</span>'; +$smarty->assign('ajax_infos', $ajax_infos); +$smarty->assign('ariane', $ariane); +$smarty->assign('page_title', 'Package: ' . $name); - <body> - <div id="wrapper"> -<?php -include '_header.php'; -?> - <div id="fedora-content"> - <div id="ariane"> - <p>You are here: </p> - <ul> - <li><a href="./">Reports home</a></li> - <li><a href="#">Package detail</a></li> - </ul> - </div> -<?php -if (!$name) { - echo "<h1>Enter a package name</h1>\n"; -} else { - try { - $db = new PDO ("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); +/** +* Retrieve people informations for a specific branch +* +* @param array $params Array of parameters +* +* @return string +*/ +function getBranchPeople($params) +{ + global $fedpkg; + extract($params); + $ret = null; + if ($branch == 'rawhide' && isset($fedpkg['devel']['owner']) ) { + if ( !$people || $people == '' || $people == 'owner' ) { + $ret = $fedpkg['devel']['owner']; + } else if ( $people == 'people') { + $ret_tmp = $fedpkg['devel']['people']; + } + } else if (isset($fedpkg[$branch]['owner'])) { + if ( !$people || $people == '' || $people == 'owner' ) { + $ret = $fedpkg[$branch]['owner']; + } else if ( $people == 'people') { + $ret_tmp = $fedpkg[$branch]['people']; + } + } + if ( $people == 'people') { + foreach ( $ret_tmp as $r ) { + if ( $ret !== null ) { + $ret .= ', '; + } + $ret .= $r['username']; + } + } + return $ret; +} +$smarty->register_function('getBranchPeople', 'getBranchPeople'); - $sql = "SELECT rpm.* - FROM rpm - INNER JOIN repo ON (repo.main=rpm.repo_main AND repo.sub=rpm.repo_sub) - WHERE rpm.name='$name' - ORDER BY repo.id DESC"; - $resrpm = $db->query($sql); - $rpm = ($resrpm ? $resrpm->fetchObject() : false); +if ( !isset($name) || !$name ) { + $smarty->assign('error', 'missing_name'); +} else { + try { + $db = new PDO ("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); - $sql = "SELECT * FROM upstream WHERE name = '$name'"; - $resup=$db->query($sql); - $up = ($resup ? $resup->fetchObject() : false); + $sql = "SELECT rpm.* + FROM rpm + INNER JOIN repo ON (repo.main=rpm.repo_main AND repo.sub=rpm.repo_sub) + WHERE rpm.name='$name' + ORDER BY repo.id DESC"; + $resrpm = $db->query($sql); + $rpm = ($resrpm ? $resrpm->fetchObject() : false); - $sql = "SELECT * FROM acls WHERE name = '$name'"; - $resown=$db->query($sql); - $owner = ($resown ? $resown->fetchObject() : false); + $sql = "SELECT * FROM upstream WHERE name = '$name'"; + $resup=$db->query($sql); + $up = ($resup ? $resup->fetchObject() : false); - if (!$rpm) { - echo "<h1>$name not found</h1>\n"; - } else { - - echo "<h1>Package: $name</h1>\n"; - - if (isset($_GET['pkgdb'])) { - $fedpkg = $fedcli->getPackageInfo($name); - echo "<p><a href='".$_SERVER['PHP_SELF']."?rpm=$name'>Hide pkgdb informations</a></p>"; - } else { - $fedpkg = false; - echo "<p><a href='".$_SERVER['PHP_SELF']."?rpm=$name&pkgdb=1'>Show more informations from pkgdb</a></p>"; - } - echo "<table id=\"upstream\">\n"; - echo "<caption>Upstream info</caption>\n"; - $i=0; + $sql = "SELECT * FROM acls WHERE name = '$name'"; + $resown=$db->query($sql); + $owner = ($resown ? $resown->fetchObject() : false); - if ($rpm->summary) { - echo "<tr class='".($i%2 ? 'odd' : 'even')."'><th>"; $i++; - echo "Summary: </th><td><strong>". $rpm->summary . "</strong></td></tr>\n"; - } else if ($owner->summary) { - echo "<tr class='".($i%2 ? 'odd' : 'even')."'><th>"; $i++; - echo "Summary: </th><td><strong>". $owner->summary . "</strong></td></tr>\n"; - } - if (isset($fedpkg['devel']['package']['description'])) { - echo "<tr class='".($i%2 ? 'odd' : 'even')."'><th>"; $i++; - echo "Description: </th><td>".$fedpkg['devel']['package']['description']."</td></tr>\n"; - } - if ($rpm->url) { - echo "<tr class='".($i%2 ? 'odd' : 'even')."'><th>"; $i++; - echo "URL: </th><td><strong><a href='".$rpm->url."'>". $rpm->url . "</a></strong></td></tr>\n"; - } - if ($up && $up->type) { - echo "<tr class='".($i%2 ? 'odd' : 'even')."'><th>"; $i++; - echo "Type: </th><td><strong>". $up->type . "</strong></td></tr>\n"; - } - if ($up && $up->channel) { - echo "<tr class='".($i%2 ? 'odd' : 'even')."'><th>"; $i++; - echo "Channel: </th><td><strong>". $up->channel . "</strong></td></tr>\n"; - } - if ($up && $up->stable) { - echo "<tr class='".($i%2 ? 'odd' : 'even')."'><th>"; $i++; - echo "Stable version: </th><td><strong>". $up->stable . "</strong></td></tr>\n"; - } - if ($up && $up->unstable && $up->stable!=$up->unstable) { - echo "<tr class='".($i%2 ? 'odd' : 'even')."'><th>"; $i++; - echo "Unstable version: </th><td><strong>". $up->unstable . "</strong>"; - if ($up->state) { - echo " (". $up->state . ")\n"; + if (!$rpm) { + echo "<h1>$name not found</h1>\n"; + } else { + if ($rpm->summary) { + $summary['Summary'] = $rpm->summary; + } else if ($owner->summary) { + $summary['Summary'] = $owner->summary; } - echo "</td></tr>\n"; - } - if ($owner && $owner->owner) { - echo "<tr class=\"".($i%2 ? 'odd' : 'even')."\"><th>"; $i++; - echo "Owner: </th><td><strong>". $owner->owner . "</strong>"; - if ($owner->cc) { - echo " (". $owner->cc . ")\n"; + $summary['Description'] = ( + (isset($fedpkg['devel']['package']['description'])) ? + $fedpkg['devel']['package']['description'] : + $ajax_infos + ); + if ( $rpm->url ) { + $summary['URL'] = $rpm->url; } - echo "</td></tr>\n"; - } - echo "<tr class=\"".($i%2 ? 'odd' : 'even')."\"><th>ViewVC: </th>"; $i++; - echo "<td><a href=\"http://cvs.fedoraproject.org/viewvc/rpms/$name/\">http://cvs.fedoraproject.org/viewvc/rpms/$name/</a>"; - echo "</td></tr>\n"; - - echo "</table>"; - - echo "<table id=\"list-packages\">\n"; - echo "<caption>Packages available in Fedora Repositories</caption>\n"; - echo "<thead><tr><th>Branch</th><th>Repository</th><th>Version-Release</th><th>Owner</th><th>Co-maintainers</th></tr></thead><tbody>\n"; - $prev=false; - do { - if ($rpm->repo_main=='rawhide' && isset($fedpkg['devel']['owner'])) { - $owner = $fedpkg['devel']['owner']; - $people = $fedpkg['devel']['people']; - } else if (isset($fedpkg[$rpm->repo_main]['owner'])) { - $owner = $fedpkg[$rpm->repo_main]['owner']; - $people = $fedpkg[$rpm->repo_main]['people']; - } else { - $owner =" "; - $people = false; + if ($up && $up->type) { + $summary['Type'] = $up->type; } - $comaint = ''; - if ($people) foreach ($people as $user) { - if (isset($user['aclOrder']['commit']['statuscode']) && $user['aclOrder']['commit']['statuscode']==3) { - $comaint .= $user['username']; - } + if ($up && $up->channel) { + $summary['Channel'] = $up->channel; } - echo "<tr class='".($i%2 ? 'odd' : 'even')."'>"; $i++; - echo "<td><strong>".($rpm->repo_main==$prev ? " " : $prev=$rpm->repo_main)."</strong></td>"; - echo "<td>".$rpm->repo_sub."</td>"; - echo "<td>".($rpm->epoch ? $rpm->epoch.":" : "").$rpm->ver."-".$rpm->rel."</td>"; - echo "<td>$owner</td><td>$comaint</td></tr>\n"; - } while ($rpm = $resrpm->fetchObject()); - echo "</tbody></table>"; - } - } - catch(PDOException $e) { - printf("%s ERREUR : %s\n", date("r"), $e->getMessage()); - } -} -?> + if ($up && $up->stable) { + $summary['Stabe version'] = $up->stable; + } + if ($up && $up->unstable && $up->stable!=$up->unstable) { + if ($up->state) { + $summary['Unstable version'] = $up->unstable . ' (' . + $up->state . ')'; + } else { + $summary['Unstable version'] = $up->unstable; + } + } + if ($owner && $owner->owner) { + if ($owner->cc) { + $summary['Owner'] = $owner->owner . ' (' . $owner->cc . ')'; + } else { + $summary['Owner'] = $owner->owner; + } + } + $summary['ViewVC'] = 'http://cvs.fedoraproject.org/viewvc/rpms/' . + $name . '/'; + if (isset($_GET['pkgdb'])) { + $fedpkg = $fedcli->getPackageInfo($name); + } else { + $fedpkg = false; + } + $i=0; - <!-- document END --> - </div> + $prev=false; + do { + $packages[] = $rpm; + if ( $rpm->repo_main != $prev ) { + $prev = $rpm->repo_main; + } + } while ( $rpm = $resrpm->fetchObject() ); + } + $smarty->assign('pkgdb', (isset($_GET['pkgdb']) ? $_GET['pkgdb'] : null)); + $smarty->assign('summary', $summary); + $smarty->assign('packages', $packages); + $smarty->assign('fedpkg', $fedpkg); + } catch(PDOException $e) { + $smarty->assign( + 'error', + sprintf("%s ERREUR : %s\n", date("r"), $e->getMessage()) + ); + } +} - <!-- content END --> -<?php -include '_footer.php'; -?> - </div> - </body> -</html> +$page_content = $smarty->fetch('zoom.tpl'); +$smarty->assign('page_content', $page_content); +$smarty->display('main.tpl'); +?>
\ No newline at end of file |