diff options
-rw-r--r-- | smarty/templates/rpmphp/zoom.tpl | 9 | ||||
-rw-r--r-- | zoom.php | 182 |
2 files changed, 102 insertions, 89 deletions
diff --git a/smarty/templates/rpmphp/zoom.tpl b/smarty/templates/rpmphp/zoom.tpl index 898ddce..6d13dda 100644 --- a/smarty/templates/rpmphp/zoom.tpl +++ b/smarty/templates/rpmphp/zoom.tpl @@ -1,3 +1,12 @@ +{if $error} + {if $error eq 'missing_name'} + <h1>Missing package name</h1> + <form action="?" method="get"> + <p>You have not specified any package name.</p> + <p><label for="rpm">Please enter one package name: </label><input type="text" name="rpm" id="rpm"/> <input type="submit"/></p> + </form> + {/if} +{/if} {if $pkgdb} <p id="pkgdb-link"><a href="?rpm={$name}">Hide pkgdb informations</a></p> {else} @@ -1,4 +1,20 @@ <?php +/** +* 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/agpl-3.0-standalone.html>. +*/ require 'main.inc.php'; require 'FedoraClient.php'; @@ -24,17 +40,17 @@ function getBranchPeople($params) if ($branch == 'rawhide' && isset($fedpkg['devel']['owner']) ) { if ( !$people || $people == '' || $people == 'owner' ) { $ret = $fedpkg['devel']['owner']; - } else if( $people == 'people') { + } 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') { + } else if ( $people == 'people') { $ret_tmp = $fedpkg[$branch]['people']; } } - if( $people == 'people') { + if ( $people == 'people') { foreach ( $ret_tmp as $r ) { if ( $ret !== null ) { $ret .= ', '; @@ -47,100 +63,88 @@ function getBranchPeople($params) $smarty->register_function('getBranchPeople', 'getBranchPeople'); if ( !isset($name) || !$name ) { -?> - <h1>Missing package name</h1> - <form action="?" method="get"> - <p>You have not specified any package name.</p> - <p><label for="rpm">Please enter one package name: </label><input type="text" name="rpm" id="rpm"/> <input type="submit"/></p> - </form> - -<?php + $smarty->assign('error', 'missing_name'); } else { - try { - $db = new PDO ("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); - - $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 upstream WHERE name = '$name'"; - $resup=$db->query($sql); - $up = ($resup ? $resup->fetchObject() : false); - - $sql = "SELECT * FROM acls WHERE name = '$name'"; - $resown=$db->query($sql); - $owner = ($resown ? $resown->fetchObject() : false); - - 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; - } - $summary['Description'] = ((isset($fedpkg['devel']['package']['description'])) ? $fedpkg['devel']['package']['description'] : $ajax_infos); - if ( $rpm->url ) { - $summary['URL'] = $rpm->url; - } - if ($up && $up->type) { - $summary['Type'] = $up->type; - } - if ($up && $up->channel) { - $summary['Channel'] = $up->channel; - } - 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; + try { + $db = new PDO ("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); + + $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 upstream WHERE name = '$name'"; + $resup=$db->query($sql); + $up = ($resup ? $resup->fetchObject() : false); + + $sql = "SELECT * FROM acls WHERE name = '$name'"; + $resown=$db->query($sql); + $owner = ($resown ? $resown->fetchObject() : false); + + 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; } + $summary['Description'] = ((isset($fedpkg['devel']['package']['description'])) ? $fedpkg['devel']['package']['description'] : $ajax_infos); + if ( $rpm->url ) { + $summary['URL'] = $rpm->url; + } + if ($up && $up->type) { + $summary['Type'] = $up->type; + } + if ($up && $up->channel) { + $summary['Channel'] = $up->channel; + } + 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 ($owner && $owner->owner) { - if ($owner->cc) { - $summary['Owner'] = $owner->owner . ' (' . $owner->cc . ')'; + if (isset($_GET['pkgdb'])) { + $fedpkg = $fedcli->getPackageInfo($name); } else { - $summary['Owner'] = $owner->owner; + $fedpkg = false; } + $i=0; + + $prev=false; + do { + $packages[] = $rpm; + if ( $rpm->repo_main != $prev ) { + $prev = $rpm->repo_main; + } + } while ( $rpm = $resrpm->fetchObject() ); } - $summary['ViewVC'] = 'http://cvs.fedoraproject.org/viewvc/rpms/' . $name . '/'; - - - if (isset($_GET['pkgdb'])) { - $fedpkg = $fedcli->getPackageInfo($name); - } else { - $fedpkg = false; - } - $i=0; - - $prev=false; - do { - $packages[] = $rpm; - if( $rpm->repo_main != $prev ) { - $prev = $rpm->repo_main; - } - - } while ($rpm = $resrpm->fetchObject()); - } - } - catch(PDOException $e) { - printf("%s ERREUR : %s\n", date("r"), $e->getMessage()); - } + $smarty->assign('pkgdb', (isset($_GET['pkgdb']) ? $_GET['pkgdb'] : null)); + $smarty->assign('summary', $summary); + $smarty->assign('packages', $packages); + $smarty->assign('fedpkg', $fedpkg); + } catch(PDOException $e) { + printf("%s ERREUR : %s\n", date("r"), $e->getMessage()); + } } -$smarty->assign('pkgdb', (isset($_GET['pkgdb']) ? $_GET['pkgdb'] : null)); -$smarty->assign('summary', $summary); -$smarty->assign('packages', $packages); -$smarty->assign('fedpkg', $fedpkg); $page_content = $smarty->fetch('zoom.tpl'); $smarty->assign('page_content', $page_content); $smarty->display('main.tpl'); |