summaryrefslogtreecommitdiffstats
path: root/pkgdb-ajax.php
diff options
context:
space:
mode:
authorJohan "Papa" Cwiklinski <trasher@odysseus.(none)>2010-05-30 23:23:53 +0200
committerJohan "Papa" Cwiklinski <trasher@odysseus.(none)>2010-05-30 23:23:53 +0200
commit80ad1fe372391923f270dc90cfb65c1bf2b39a47 (patch)
treeeedaa090a415bbd2bae4c7917c3d1616252c70e4 /pkgdb-ajax.php
parenteca7d464fd98c8542e3e54552bdc1fc77823c3bd (diff)
Apply PEAR coding standards, refs #48 ; Add licence tag, closes #46
Diffstat (limited to 'pkgdb-ajax.php')
-rw-r--r--pkgdb-ajax.php111
1 files changed, 73 insertions, 38 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);