diff options
author | Johan "Papa" Cwiklinski <trasher@odysseus.(none)> | 2010-05-29 17:22:42 +0200 |
---|---|---|
committer | Johan "Papa" Cwiklinski <trasher@odysseus.(none)> | 2010-05-29 17:22:42 +0200 |
commit | 8aa3adeb74d3aba8f7cd9498870cd63d87aefd75 (patch) | |
tree | 6ef3a1b764d54008172c65dcc3d020dffab04653 /zoom.php | |
parent | afcf0d9d405ce6cabeedbc1352fb651ef8eb47e7 (diff) |
Use of ajax to load additionnal informations from pkgdb ; closes #45
Diffstat (limited to 'zoom.php')
-rw-r--r-- | zoom.php | 81 |
1 files changed, 56 insertions, 25 deletions
@@ -1,14 +1,11 @@ <?php - require "config.inc.php"; require "FedoraClient.php"; $fedcli = new FedoraPkgdb(); -if (!isset($_GET['rpm'])) { - die("missing arg."); -} $name = $_GET['rpm']; +$ajax_infos = '<span class="ajax">(wit for ajax or <a href="' . $_SERVER['PHP_SELF'] . '?rpm='.$name.'&pkgdb=1">reload with pkgdb</a>)</span>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> @@ -18,6 +15,21 @@ $name = $_GET['rpm']; <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">--> + <script type="text/javascript" src="scripts/jquery-1.4.2.min.js"></script> + <script type="text/javascript" src="scripts/rpmphp.js"></script> +<?php +if ( isset($name) && $name != '' ) { +?> + <script type="text/javascript"> + // <![CDATA[ + $(function(){ + initZoomJS('<?php echo $name; ?>'); + }); + //]]> + </script> +<?php +} +?> <link rel="shortcut icon" href="images/favicon.ico"/> <link rel="icon" href="images/favicon.ico"/> </head> @@ -36,8 +48,15 @@ include '_header.php'; </ul> </div> <?php -if (!$name) { - echo "<h1>Enter a package name</h1>\n"; +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 } else { try { $db = new PDO ("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); @@ -61,49 +80,49 @@ if (!$name) { 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>"; + echo "<p id=\"pkgdb-link\"><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 "<p id=\"pkgdb-link\"><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; if ($rpm->summary) { - echo "<tr class='".($i%2 ? 'odd' : 'even')."'><th>"; $i++; + echo "<tr><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 "<tr><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"; - } + + echo "<tr><th>"; $i++; + echo "Description: </th><td id=\"" . $name . "_desc\">" . ((isset($fedpkg['devel']['package']['description'])) ? $fedpkg['devel']['package']['description'] : $ajax_infos) . "</td></tr>\n"; + if ($rpm->url) { - echo "<tr class='".($i%2 ? 'odd' : 'even')."'><th>"; $i++; + echo "<tr><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 "<tr><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 "<tr><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 "<tr><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 "<tr><th>"; $i++; echo "Unstable version: </th><td><strong>". $up->unstable . "</strong>"; if ($up->state) { echo " (". $up->state . ")\n"; @@ -111,14 +130,14 @@ if (!$name) { echo "</td></tr>\n"; } if ($owner && $owner->owner) { - echo "<tr class=\"".($i%2 ? 'odd' : 'even')."\"><th>"; $i++; + echo "<tr><th>"; $i++; echo "Owner: </th><td><strong>". $owner->owner . "</strong>"; if ($owner->cc) { echo " (". $owner->cc . ")\n"; } echo "</td></tr>\n"; } - echo "<tr class=\"".($i%2 ? 'odd' : 'even')."\"><th>ViewVC: </th>"; $i++; + echo "<tr><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"; @@ -142,14 +161,26 @@ if (!$name) { $comaint = ''; if ($people) foreach ($people as $user) { if (isset($user['aclOrder']['commit']['statuscode']) && $user['aclOrder']['commit']['statuscode']==3) { + if ( $comaint !== '' ) { + $comaint .= ', '; + } $comaint .= $user['username']; } } echo "<tr class='".($i%2 ? 'odd' : 'even')."'>"; $i++; - echo "<td><strong>".($rpm->repo_main==$prev ? " " : $prev=$rpm->repo_main)."</strong></td>"; + echo "<td><strong>".($rpm->repo_main==$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"; + $id = 'pkgdb_' . $rpm->repo_main; + if ( $rpm->repo_main != $prev ) { + echo "<td id=\"" . $id . "_owner\">" . (($fedpkg) ? $owner : $ajax_infos) . "</td><td id=\"" . $id . "_maintainers\">" . (($fedpkg) ? $comaint : $ajax_infos) . "</td></tr>\n"; + } else { + echo '<td> </td><td> </td></tr>'; + } + if( $rpm->repo_main != $prev ) { + $prev = $rpm->repo_main; + } + } while ($rpm = $resrpm->fetchObject()); echo "</tbody></table>"; } |