summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkgdb-ajax.php111
-rw-r--r--scripts/rpmphp.js93
2 files changed, 131 insertions, 73 deletions
diff --git a/pkgdb-ajax.php b/pkgdb-ajax.php
index b92a5c4..a07a3e4 100644
--- a/pkgdb-ajax.php
+++ b/pkgdb-ajax.php
@@ -1,49 +1,84 @@
<?php
+
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Load PKGDB informations into a JSON object passed to the Javascript
+ *
+ * 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
+ * @link http://github.com/remicollet/rpmphp/
+ * @since The begining of times.
+*/
header('Content-Type: application/json;charset=utf-8');
require 'main.inc.php';
$name = $_GET['name'];
if ( !isset($name) || !$name ) {
- $fedpkg = array('error' => 'No name provided');
+ $fedpkg = array('error' => 'No name provided');
} else {
- $fedcli = new FedoraPkgdb();
- $fedpkg = $fedcli->getPackageInfo($name);
- if ( $fedpkg === false ) {
- $fedpkg = array('error' => 'Unknown package');
- } else {
- //let's clean all little to avoid heavy json
- foreach ( array_keys($fedpkg) as $k ) {
- unset($fedpkg[$k]['specfile']);
- unset($fedpkg[$k]['groups']);
- unset($fedpkg[$k]['collection']);
- unset($fedpkg[$k]['collectionid']);
- unset($fedpkg[$k]['critpath']);
- unset($fedpkg[$k]['qacontact']);
- unset($fedpkg[$k]['statuschange']);
- unset($fedpkg[$k]['statuscode']);
- unset($fedpkg[$k]['id']);
- unset($fedpkg[$k]['packageid']);
- unset($fedpkg[$k]['package']['reviewurl']);
- unset($fedpkg[$k]['package']['shouldopen']);
- unset($fedpkg[$k]['package']['id']);
- unset($fedpkg[$k]['package']['statuscode']);
- unset($fedpkg[$k]['package']['upstreamurl']);
- $people = $fedpkg[$k]['people'];
- $new_people = null;
- foreach( $people as $p ) {
- $new_people[] = array(
- 'username' => $p['username'],
- 'aclOrder' => array(
- 'commit' => array(
- 'statuscode' => $p['aclOrder']['commit']['statuscode']
- )
- )
- );
- }
- $fedpkg[$k]['people'] = $new_people;
+ $fedcli = new FedoraPkgdb();
+ $fedpkg = $fedcli->getPackageInfo($name);
+ if ( $fedpkg === false ) {
+ $fedpkg = array('error' => 'Unknown package');
+ } else {
+ //let's clean all little to avoid heavy json
+ foreach ( array_keys($fedpkg) as $k ) {
+ unset($fedpkg[$k]['specfile']);
+ unset($fedpkg[$k]['groups']);
+ unset($fedpkg[$k]['collection']);
+ unset($fedpkg[$k]['collectionid']);
+ unset($fedpkg[$k]['critpath']);
+ unset($fedpkg[$k]['qacontact']);
+ unset($fedpkg[$k]['statuschange']);
+ unset($fedpkg[$k]['statuscode']);
+ unset($fedpkg[$k]['id']);
+ unset($fedpkg[$k]['packageid']);
+ unset($fedpkg[$k]['package']['reviewurl']);
+ unset($fedpkg[$k]['package']['shouldopen']);
+ unset($fedpkg[$k]['package']['id']);
+ unset($fedpkg[$k]['package']['statuscode']);
+ unset($fedpkg[$k]['package']['upstreamurl']);
+ $people = $fedpkg[$k]['people'];
+ $new_people = null;
+ foreach ( $people as $p ) {
+ $new_people[] = array(
+ 'username' => $p['username'],
+ 'aclOrder' => array(
+ 'commit' => array(
+ 'statuscode' => $p['aclOrder']['commit']['statuscode']
+ )
+ )
+ );
+ }
+ $fedpkg[$k]['people'] = $new_people;
$fedpkg[$k]['package']['description'] = nl2br($fedpkg[$k]['package']['description']);
- }
- }
+ }
+ }
}
echo json_encode($fedpkg);
diff --git a/scripts/rpmphp.js b/scripts/rpmphp.js
index 7dfe0b5..864b9c6 100644
--- a/scripts/rpmphp.js
+++ b/scripts/rpmphp.js
@@ -1,38 +1,61 @@
+/**
+ * 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/>.
+ */
+
+/**
+* Initialize Zoom page using ajax:
+* - loads description from pkgdb
+* - loads packages informations from pkgdb
+* @param String name Name of the package
+*/
function initZoomJS(name)
{
- $('#pkgdb-link').remove();
- $.ajax({
- url: 'pkgdb-ajax.php?name=' + name,
- success: function(data) {
- if ( data.error ) {
- alert(data.error);
- } else {
- $('#' + name + '_desc').empty().html(data.devel.package.description);
- $.each(
- data,
- function(k, v){
- _data = data[k];
- if ( k === 'devel' ) {
- k = 'rawhide';
- }
- _owner_cell = $('#pkgdb_' + k + '_owner');
- if ( _owner_cell ) {
- _owner_cell.empty().text(_data.owner);
- _maintainers_cell = $('#pkgdb_' + k + '_maintainers');
- _maintainers = '';
- if ( _data.people != null ) {
- $.each(
- _data.people,
- function(){
- _maintainers += this.username + ', ';
- }
- )
- }
- _maintainers_cell.empty().text(_maintainers.slice(0, -2));
- }
- }
- );
- }
- }
- });
+ $('#pkgdb-link').remove();
+ $.ajax({
+ url: 'pkgdb-ajax.php?name=' + name,
+ success: function(data) {
+ if ( data.error ) {
+ alert(data.error);
+ } else {
+ $('#' + name + '_desc').empty().html(data.devel.package.description);
+ $.each(
+ data,
+ function(k, v){
+ _data = data[k];
+ if ( k === 'devel' ) {
+ k = 'rawhide';
+ }
+ _owner_cell = $('#pkgdb_' + k + '_owner');
+ if ( _owner_cell ) {
+ _owner_cell.empty().text(_data.owner);
+ _maintainers_cell = $('#pkgdb_' + k + '_maintainers');
+ _maintainers = '';
+ if ( _data.people != null ) {
+ $.each(
+ _data.people,
+ function(){
+ _maintainers += this.username + ', ';
+ }
+ )
+ }
+ _maintainers_cell.empty().text(_maintainers.slice(0, -2));
+ }
+ }
+ );
+ }
+ }
+ });
} \ No newline at end of file