cvs: pearweb / generateREST.php /include pear-database.php pear-rest.php /public_html package-edit.php /public_html/admin package-approval.php
| From: | Greg Beaver | Date: | Thu, 27 Oct 2005 04:57:53 +0000 |
| Subject: | cvs: pearweb / generateREST.php /include pear-database.php pear-rest.php /public_html package-edit.php /public_html/admin package-approval.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-cvs+get-35891@lists.php.net to get a copy of this message | ||
cellog Thu Oct 27 00:57:53 2005 EDT
Modified files:
/pearweb generateREST.php
/pearweb/include pear-database.php pear-rest.php
/pearweb/public_html/admin package-approval.php
/pearweb/public_html package-edit.php
Log:
fully implement REST1.1
- adds listing of maintainers in /rest/m/allmaintainers.xml
- adds listing of categories in /rest/c/categories.xml
- adds full listing of packages with info for list-all/remote-list commands
in /rest/c/Categoryname/packagesinfo.xml
fix package::info($package, 'category') - it was never working!
remove pear-prepend magic from generateREST.php - magic is almost always a
bad idea
http://cvs.php.net/diff.php/pearweb/generateREST.php?r1=1.7&r2=1.8&ty=u Index: pearweb/generateREST.php diff -u pearweb/generateREST.php:1.7 pearweb/generateREST.php:1.8 --- pearweb/generateREST.php:1.7 Sat Oct 22 00:28:01 2005 +++ pearweb/generateREST.php Thu Oct 27 00:57:51 2005 @@ -2,17 +2,64 @@ /** * Generate static REST files for pear.php.net from existing data * @author Greg Beaver <cellog@php.net> - * @version $Id: generateREST.php,v 1.7 2005/10/22 04:28:01 cellog Exp $ + * @version $Id: generateREST.php,v 1.8 2005/10/27 04:57:51 cellog Exp $ */ /** * Useful files to have */ -if (isset($_SERVER['argv']) && $_SERVER['argv'][1] == 'pear') { - $_SERVER['SERVER_NAME'] = 'pear.php.net'; -} set_include_path(dirname(__FILE__) . '/include' . PATH_SEPARATOR . get_include_path()); ob_start(); -@require_once 'pear-prepend.php'; +require_once "pear-config.php"; +if ($_SERVER['SERVER_NAME'] != PEAR_CHANNELNAME) { + error_reporting(E_ALL); + define('DEVBOX', true); +} else { + error_reporting(E_ALL ^ E_NOTICE); + define('DEVBOX', false); +} + +require_once "PEAR.php"; + +include_once "pear-database.php"; +include_once "pear-rest.php"; +if (!isset($pear_rest)) { + if (isset($_SERVER['argv']) && $_SERVER['argv'][1] == 'pear') { + $pear_rest = new pear_rest('/var/lib/pearweb/rest'); + } else { + $pear_rest = new pear_rest(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'public_html' . + DIRECTORY_SEPARATOR . 'rest'); + } +} + +if (!function_exists('file_get_contents')) { + function file_get_contents($file, $use_include_path = false) { + if (!$fp = fopen($file, 'r', $use_include_path)) { + return false; + } + $data = fread($fp, filesize($file)); + fclose($fp); + return $data; + } +} + +if (!function_exists('file_put_contents')) { + function file_put_contents($fname, $contents) + { + $fp = fopen($fname, 'wb'); + fwrite($fp, $contents); + fclose($fp); + } +} +include_once "DB.php"; +include_once "DB/storage.php"; + +if (empty($dbh)) { + $options = array( + 'persistent' => false, + 'portability' => DB_PORTABILITY_ALL, + ); + $dbh =& DB::connect(PEAR_DATABASE_DSN, $options); +} ob_end_clean(); PEAR::setErrorHandling(PEAR_ERROR_DIE); require_once 'System.php'; @@ -34,6 +81,9 @@ $pear_rest->saveMaintainerREST($maintainer['handle']); echo "done\n"; } +echo "Generating All Maintainers REST...\n"; +$pear_rest->saveAllMaintainersREST(); +echo "done\n"; echo "Generating Package REST...\n"; $pear_rest->saveAllPackagesREST(); require_once 'Archive/Tar.php'; http://cvs.php.net/diff.php/pearweb/include/pear-database.php?r1=1.297&r2=1.298&ty=u Index: pearweb/include/pear-database.php diff -u pearweb/include/pear-database.php:1.297 pearweb/include/pear-database.php:1.298 --- pearweb/include/pear-database.php:1.297 Sat Oct 22 00:28:02 2005 +++ pearweb/include/pear-database.php Thu Oct 27 00:57:51 2005 @@ -17,7 +17,7 @@ | Tomas V.V.Cox <cox@php.net> | | Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: pear-database.php,v 1.297 2005/10/22 04:28:02 cellog Exp $ + $Id: pear-database.php,v 1.298 2005/10/27 04:57:51 cellog Exp $ */ require_once 'DB/storage.php'; @@ -762,7 +762,7 @@ } elseif ($field == 'category') { $sql = "SELECT c.name FROM categories c, packages p ". "WHERE c.id = p.category AND " . $package_type . " p.{$what} = ?"; - $info = $dbh->getAssoc($sql, false, array($pkg)); + $info = $dbh->getOne($sql, array($pkg)); } elseif ($field == 'description') { $sql = "SELECT description FROM packages p WHERE " . $package_type . " p.{$what} = ?"; $info = $dbh->query($sql, array($pkg)); @@ -1095,7 +1095,9 @@ $sql = 'UPDATE packages SET ' . implode(', ', $fields) . " WHERE id=$package_id"; $row = package::info($pkgid, 'name'); + $GLOBALS['pear_rest']->saveAllPackagesREST(); $GLOBALS['pear_rest']->savePackageREST($row); + $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($pkgid, 'category')); return $dbh->query($sql, $prep); } @@ -1834,6 +1836,7 @@ $GLOBALS['pear_rest']->saveAllReleasesREST($package); $GLOBALS['pear_rest']->saveReleaseREST($file, $packagexml, $pkg_info, $auth_user->handle, $release_id); + $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($package, 'category')); // gotta clear all the permutations $cache->remove('package.listAll', array(false)); $cache->remove('package.listAll', array(true)); @@ -2255,6 +2258,7 @@ $sth = $dbh->query($query); $GLOBALS['pear_rest']->saveAllReleasesREST($pname); $GLOBALS['pear_rest']->deleteReleaseREST($pname, $version); + $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($pname, 'category')); if (PEAR::isError($sth)) { return false; @@ -2355,6 +2359,7 @@ global $dbh; note::removeAll("uid", $uid); $GLOBALS['pear_rest']->deleteMaintainerREST($uid); + $GLOBALS['pear_rest']->saveAllMaintainersREST(); $dbh->query('DELETE FROM users WHERE handle = '. $dbh->quote($uid)); return ($dbh->affectedRows() > 0); } @@ -2403,6 +2408,7 @@ $karma->grant($user->handle, $karmalevel); if ($karma->has($user->handle, 'pear.dev')) { $GLOBALS['pear_rest']->saveMaintainerREST($user->handle); + $GLOBALS['pear_rest']->saveAllmaintainerREST(); } note::add("uid", $uid, "Account opened"); $msg = "Your PEAR account request has been opened.\n". http://cvs.php.net/diff.php/pearweb/include/pear-rest.php?r1=1.24&r2=1.25&ty=u Index: pearweb/include/pear-rest.php diff -u pearweb/include/pear-rest.php:1.24 pearweb/include/pear-rest.php:1.25 --- pearweb/include/pear-rest.php:1.24 Sat Oct 22 00:28:02 2005 +++ pearweb/include/pear-rest.php Thu Oct 27 00:57:52 2005 @@ -106,8 +106,11 @@ $rdir = $this->_restdir . DIRECTORY_SEPARATOR . 'r'; $packages = category::listPackages($category); $fullpackageinfo = '<?xml version="1.0" encoding="UTF-8" ?> -<f> +<f xmlns="http://pear.php.net/dtd/rest.categorypackageinfo" + xsi:schemaLocation="http://pear.php.net/dtd/rest.categorypackageinfo + http://pear.php.net/dtd/rest.categorypackageinfo.xsd"> '; + clearstatcache(); foreach ($packages as $package) { if (!file_exists($pdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'info.xml')) { @@ -115,24 +118,15 @@ } $fullpackageinfo .= '<pi> '; - $fullpackageinfo .= str_replace( - '<?xml version="1.0" encoding="UTF-8" ?> -<p xmlns="http://pear.php.net/dtd/rest.package" - xsi:schemaLocation="http://pear.php.net/dtd/rest.package - http://pear.php.net/dtd/rest.package.xsd">', '<p>', + $fullpackageinfo .= str_replace($this->_getPackageRESTProlog(), '<p>', file_get_contents($pdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'info.xml')); if (file_exists($rdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'allreleases.xml')) { $fullpackageinfo .= str_replace( - '<?xml version="1.0" encoding="UTF-8" ?> -<a xmlns="http://pear.php.net/dtd/rest.allreleases" - xsi:schemaLocation="http://pear.php.net/dtd/rest.allreleases - http://pear.php.net/dtd/rest.allreleases.xsd"> - <p>' . $package['name'] . '</p> - <c>' . PEAR_CHANNELNAME . '</c>', ' - <a> - ', + $this->_getAllReleasesRESTProlog($package['name']), ' +<a> +', file_get_contents($rdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'allreleases.xml')); @@ -198,6 +192,14 @@ @chmod($pdir . DIRECTORY_SEPARATOR . 'packages.xml', 0666); } + function _getPackageRESTProlog() + { + return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" . +"<p xmlns=\"http://pear.php.net/dtd/rest.package\"" . +" xsi:schemaLocation=\"http://pear.php.net/dtd/rest.package\"" . +' http://pear.php.net/dtd/rest.package.xsd">'; + } + function savePackageREST($package) { require_once 'System.php'; @@ -240,10 +242,7 @@ } $package['summary'] = htmlspecialchars($package['summary']); $package['description'] = htmlspecialchars($package['description']); - $info = '<?xml version="1.0" encoding="UTF-8" ?> -<p xmlns="http://pear.php.net/dtd/rest.package" - xsi:schemaLocation="http://pear.php.net/dtd/rest.package - http://pear.php.net/dtd/rest.package.xsd"> + $info = $this->_getPackageRESTProlog() . ' <n>' . $package['name'] . '</n> <c>' . PEAR_CHANNELNAME . '</c> <ca xlink:href="' . $extra . 'c/' . htmlspecialchars(urlencode($catinfo)) . '">' . @@ -278,6 +277,16 @@ System::rm(array('-r', $rdir . DIRECTORY_SEPARATOR . $package)); } + function _getAllReleasesRESTProlog($package) + { + return '<?xml version="1.0" encoding="UTF-8" ?>' . "\n" . +'<a xmlns="http://pear.php.net/dtd/rest.allreleases"' . "\n" . +' xsi:schemaLocation="http://pear.php.net/dtd/rest.allreleases' . "\n" . +' http://pear.php.net/dtd/rest.allreleases.xsd">' . "\n" . +' <p>' . $package . '</p>' . "\n" . +' <c>' . PEAR_CHANNELNAME . '</c>' . "\n"; + } + function saveAllReleasesREST($package) { require_once 'System.php'; @@ -298,13 +307,7 @@ System::rm(array('-r', $rdir . DIRECTORY_SEPARATOR . strtolower($package))); return; } - $info = '<?xml version="1.0" encoding="UTF-8" ?> -<a xmlns="http://pear.php.net/dtd/rest.allreleases" - xsi:schemaLocation="http://pear.php.net/dtd/rest.allreleases - http://pear.php.net/dtd/rest.allreleases.xsd"> - <p>' . $package . '</p> - <c>' . PEAR_CHANNELNAME . '</c> -'; + $info = $this->_getAllReleasesRESTProlog($package); foreach ($releases as $release) { $packagexml = $dbh->getOne('SELECT packagexml FROM files WHERE package = ? AND release = ?', array($pid, $release['id'])); @@ -554,5 +557,32 @@ @chmod($mdir . DIRECTORY_SEPARATOR . $maintainer['handle'] . DIRECTORY_SEPARATOR . 'info.xml', 0666); } + + function saveAllMaintainersREST() + { + $maintainers = user::listAll(); + $info = '<?xml version="1.0" encoding="UTF-8" ?> +<m xmlns="http://pear.php.net/dtd/rest.allmaintainers" + xsi:schemaLocation="http://pear.php.net/dtd/rest.allmaintainers + http://pear.php.net/dtd/rest.allmaintainers.xsd">' . "\n"; + // package information + require_once 'Damblan/Karma.php'; + $karma = &new Damblan_Karma($GLOBALS['dbh']); + foreach ($maintainers as $maintainer) { + if (!$karma->has($maintainer['handle'], 'pear.dev')) { + continue; + } + $info .= ' <h xlink:href="/rest/m/' . $maintainer['handle'] . '">' . + $maintainer['handle'] . '</h>' . "\n"; + } + $info .= '</m>'; + $mdir = $this->_restdir . DIRECTORY_SEPARATOR . 'm'; + if (!is_dir($mdir)) { + System::mkdir(array('-p', $mdir)); + @chmod($mdir, 0777); + } + file_put_contents($mdir . DIRECTORY_SEPARATOR . 'allmaintainers.xml', $info); + @chmod($mdir . DIRECTORY_SEPARATOR . 'allmaintainers.xml', 0666); + } } ?> http://cvs.php.net/diff.php/pearweb/public_html/admin/package-approval.php?r1=1.12&r2=1.13&ty=u Index: pearweb/public_html/admin/package-approval.php diff -u pearweb/public_html/admin/package-approval.php:1.12 pearweb/public_html/admin/package-approval.php:1.13 --- pearweb/public_html/admin/package-approval.php:1.12 Sun Jul 3 21:00:49 2005 +++ pearweb/public_html/admin/package-approval.php Thu Oct 27 00:57:52 2005 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: package-approval.php,v 1.12 2005/07/04 01:00:49 rasmus Exp $ + $Id: package-approval.php,v 1.13 2005/10/27 04:57:52 cellog Exp $ */ auth_require("pear.group"); @@ -46,6 +46,7 @@ if ($action == 'approved') { $pear_rest->savePackageREST($row['name']); $pear_rest->saveAllPackagesREST(); + $pear_rest->savePackagesCategoryREST(package::info($row['name'], 'category')); } // {{{ Logging mechanism require_once "Damblan/Log.php"; http://cvs.php.net/diff.php/pearweb/public_html/package-edit.php?r1=1.39&r2=1.40&ty=u Index: pearweb/public_html/package-edit.php diff -u pearweb/public_html/package-edit.php:1.39 pearweb/public_html/package-edit.php:1.40 --- pearweb/public_html/package-edit.php:1.39 Thu Oct 20 20:03:00 2005 +++ pearweb/public_html/package-edit.php Thu Oct 27 00:57:52 2005 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: package-edit.php,v 1.39 2005/10/21 00:03:00 cellog Exp $ + $Id: package-edit.php,v 1.40 2005/10/27 04:57:52 cellog Exp $ */ /* @@ -95,7 +95,9 @@ if (PEAR::isError($sth)) { report_error('Unable to save data!'); } else { + $pear_rest->saveAllPackagesREST(); $pear_rest->savePackageREST($_POST['name']); + $pear_rest->savePackagesCategoryREST(package::info($_POST['name'], 'category')); echo "<b>Package information successfully updated.</b><br /><br />\n"; } }
http://cvs.php.net/diff.php/pearweb/generateREST.php?r1=1.7&r2=1.8&ty=u Index: pearweb/generateREST.php diff -u pearweb/generateREST.php:1.7 pearweb/generateREST.php:1.8 --- pearweb/generateREST.php:1.7 Sat Oct 22 00:28:01 2005 +++ pearweb/generateREST.php Thu Oct 27 00:57:51 2005 @@ -2,17 +2,64 @@ /** * Generate static REST files for pear.php.net from existing data * @author Greg Beaver <cellog@php.net> - * @version $Id: generateREST.php,v 1.7 2005/10/22 04:28:01 cellog Exp $ + * @version $Id: generateREST.php,v 1.8 2005/10/27 04:57:51 cellog Exp $ */ /** * Useful files to have */ -if (isset($_SERVER['argv']) && $_SERVER['argv'][1] == 'pear') { - $_SERVER['SERVER_NAME'] = 'pear.php.net'; -} set_include_path(dirname(__FILE__) . '/include' . PATH_SEPARATOR . get_include_path()); ob_start(); -@require_once 'pear-prepend.php'; +require_once "pear-config.php"; +if ($_SERVER['SERVER_NAME'] != PEAR_CHANNELNAME) { + error_reporting(E_ALL); + define('DEVBOX', true); +} else { + error_reporting(E_ALL ^ E_NOTICE); + define('DEVBOX', false); +} + +require_once "PEAR.php"; + +include_once "pear-database.php"; +include_once "pear-rest.php"; +if (!isset($pear_rest)) { + if (isset($_SERVER['argv']) && $_SERVER['argv'][1] == 'pear') { + $pear_rest = new pear_rest('/var/lib/pearweb/rest'); + } else { + $pear_rest = new pear_rest(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'public_html' . + DIRECTORY_SEPARATOR . 'rest'); + } +} + +if (!function_exists('file_get_contents')) { + function file_get_contents($file, $use_include_path = false) { + if (!$fp = fopen($file, 'r', $use_include_path)) { + return false; + } + $data = fread($fp, filesize($file)); + fclose($fp); + return $data; + } +} + +if (!function_exists('file_put_contents')) { + function file_put_contents($fname, $contents) + { + $fp = fopen($fname, 'wb'); + fwrite($fp, $contents); + fclose($fp); + } +} +include_once "DB.php"; +include_once "DB/storage.php"; + +if (empty($dbh)) { + $options = array( + 'persistent' => false, + 'portability' => DB_PORTABILITY_ALL, + ); + $dbh =& DB::connect(PEAR_DATABASE_DSN, $options); +} ob_end_clean(); PEAR::setErrorHandling(PEAR_ERROR_DIE); require_once 'System.php'; @@ -34,6 +81,9 @@ $pear_rest->saveMaintainerREST($maintainer['handle']); echo "done\n"; } +echo "Generating All Maintainers REST...\n"; +$pear_rest->saveAllMaintainersREST(); +echo "done\n"; echo "Generating Package REST...\n"; $pear_rest->saveAllPackagesREST(); require_once 'Archive/Tar.php'; http://cvs.php.net/diff.php/pearweb/include/pear-database.php?r1=1.297&r2=1.298&ty=u Index: pearweb/include/pear-database.php diff -u pearweb/include/pear-database.php:1.297 pearweb/include/pear-database.php:1.298 --- pearweb/include/pear-database.php:1.297 Sat Oct 22 00:28:02 2005 +++ pearweb/include/pear-database.php Thu Oct 27 00:57:51 2005 @@ -17,7 +17,7 @@ | Tomas V.V.Cox <cox@php.net> | | Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: pear-database.php,v 1.297 2005/10/22 04:28:02 cellog Exp $ + $Id: pear-database.php,v 1.298 2005/10/27 04:57:51 cellog Exp $ */ require_once 'DB/storage.php'; @@ -762,7 +762,7 @@ } elseif ($field == 'category') { $sql = "SELECT c.name FROM categories c, packages p ". "WHERE c.id = p.category AND " . $package_type . " p.{$what} = ?"; - $info = $dbh->getAssoc($sql, false, array($pkg)); + $info = $dbh->getOne($sql, array($pkg)); } elseif ($field == 'description') { $sql = "SELECT description FROM packages p WHERE " . $package_type . " p.{$what} = ?"; $info = $dbh->query($sql, array($pkg)); @@ -1095,7 +1095,9 @@ $sql = 'UPDATE packages SET ' . implode(', ', $fields) . " WHERE id=$package_id"; $row = package::info($pkgid, 'name'); + $GLOBALS['pear_rest']->saveAllPackagesREST(); $GLOBALS['pear_rest']->savePackageREST($row); + $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($pkgid, 'category')); return $dbh->query($sql, $prep); } @@ -1834,6 +1836,7 @@ $GLOBALS['pear_rest']->saveAllReleasesREST($package); $GLOBALS['pear_rest']->saveReleaseREST($file, $packagexml, $pkg_info, $auth_user->handle, $release_id); + $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($package, 'category')); // gotta clear all the permutations $cache->remove('package.listAll', array(false)); $cache->remove('package.listAll', array(true)); @@ -2255,6 +2258,7 @@ $sth = $dbh->query($query); $GLOBALS['pear_rest']->saveAllReleasesREST($pname); $GLOBALS['pear_rest']->deleteReleaseREST($pname, $version); + $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($pname, 'category')); if (PEAR::isError($sth)) { return false; @@ -2355,6 +2359,7 @@ global $dbh; note::removeAll("uid", $uid); $GLOBALS['pear_rest']->deleteMaintainerREST($uid); + $GLOBALS['pear_rest']->saveAllMaintainersREST(); $dbh->query('DELETE FROM users WHERE handle = '. $dbh->quote($uid)); return ($dbh->affectedRows() > 0); } @@ -2403,6 +2408,7 @@ $karma->grant($user->handle, $karmalevel); if ($karma->has($user->handle, 'pear.dev')) { $GLOBALS['pear_rest']->saveMaintainerREST($user->handle); + $GLOBALS['pear_rest']->saveAllmaintainerREST(); } note::add("uid", $uid, "Account opened"); $msg = "Your PEAR account request has been opened.\n". http://cvs.php.net/diff.php/pearweb/include/pear-rest.php?r1=1.24&r2=1.25&ty=u Index: pearweb/include/pear-rest.php diff -u pearweb/include/pear-rest.php:1.24 pearweb/include/pear-rest.php:1.25 --- pearweb/include/pear-rest.php:1.24 Sat Oct 22 00:28:02 2005 +++ pearweb/include/pear-rest.php Thu Oct 27 00:57:52 2005 @@ -106,8 +106,11 @@ $rdir = $this->_restdir . DIRECTORY_SEPARATOR . 'r'; $packages = category::listPackages($category); $fullpackageinfo = '<?xml version="1.0" encoding="UTF-8" ?> -<f> +<f xmlns="http://pear.php.net/dtd/rest.categorypackageinfo" + xsi:schemaLocation="http://pear.php.net/dtd/rest.categorypackageinfo + http://pear.php.net/dtd/rest.categorypackageinfo.xsd"> '; + clearstatcache(); foreach ($packages as $package) { if (!file_exists($pdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'info.xml')) { @@ -115,24 +118,15 @@ } $fullpackageinfo .= '<pi> '; - $fullpackageinfo .= str_replace( - '<?xml version="1.0" encoding="UTF-8" ?> -<p xmlns="http://pear.php.net/dtd/rest.package" - xsi:schemaLocation="http://pear.php.net/dtd/rest.package - http://pear.php.net/dtd/rest.package.xsd">', '<p>', + $fullpackageinfo .= str_replace($this->_getPackageRESTProlog(), '<p>', file_get_contents($pdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'info.xml')); if (file_exists($rdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'allreleases.xml')) { $fullpackageinfo .= str_replace( - '<?xml version="1.0" encoding="UTF-8" ?> -<a xmlns="http://pear.php.net/dtd/rest.allreleases" - xsi:schemaLocation="http://pear.php.net/dtd/rest.allreleases - http://pear.php.net/dtd/rest.allreleases.xsd"> - <p>' . $package['name'] . '</p> - <c>' . PEAR_CHANNELNAME . '</c>', ' - <a> - ', + $this->_getAllReleasesRESTProlog($package['name']), ' +<a> +', file_get_contents($rdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'allreleases.xml')); @@ -198,6 +192,14 @@ @chmod($pdir . DIRECTORY_SEPARATOR . 'packages.xml', 0666); } + function _getPackageRESTProlog() + { + return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" . +"<p xmlns=\"http://pear.php.net/dtd/rest.package\"" . +" xsi:schemaLocation=\"http://pear.php.net/dtd/rest.package\"" . +' http://pear.php.net/dtd/rest.package.xsd">'; + } + function savePackageREST($package) { require_once 'System.php'; @@ -240,10 +242,7 @@ } $package['summary'] = htmlspecialchars($package['summary']); $package['description'] = htmlspecialchars($package['description']); - $info = '<?xml version="1.0" encoding="UTF-8" ?> -<p xmlns="http://pear.php.net/dtd/rest.package" - xsi:schemaLocation="http://pear.php.net/dtd/rest.package - http://pear.php.net/dtd/rest.package.xsd"> + $info = $this->_getPackageRESTProlog() . ' <n>' . $package['name'] . '</n> <c>' . PEAR_CHANNELNAME . '</c> <ca xlink:href="' . $extra . 'c/' . htmlspecialchars(urlencode($catinfo)) . '">' . @@ -278,6 +277,16 @@ System::rm(array('-r', $rdir . DIRECTORY_SEPARATOR . $package)); } + function _getAllReleasesRESTProlog($package) + { + return '<?xml version="1.0" encoding="UTF-8" ?>' . "\n" . +'<a xmlns="http://pear.php.net/dtd/rest.allreleases"' . "\n" . +' xsi:schemaLocation="http://pear.php.net/dtd/rest.allreleases' . "\n" . +' http://pear.php.net/dtd/rest.allreleases.xsd">' . "\n" . +' <p>' . $package . '</p>' . "\n" . +' <c>' . PEAR_CHANNELNAME . '</c>' . "\n"; + } + function saveAllReleasesREST($package) { require_once 'System.php'; @@ -298,13 +307,7 @@ System::rm(array('-r', $rdir . DIRECTORY_SEPARATOR . strtolower($package))); return; } - $info = '<?xml version="1.0" encoding="UTF-8" ?> -<a xmlns="http://pear.php.net/dtd/rest.allreleases" - xsi:schemaLocation="http://pear.php.net/dtd/rest.allreleases - http://pear.php.net/dtd/rest.allreleases.xsd"> - <p>' . $package . '</p> - <c>' . PEAR_CHANNELNAME . '</c> -'; + $info = $this->_getAllReleasesRESTProlog($package); foreach ($releases as $release) { $packagexml = $dbh->getOne('SELECT packagexml FROM files WHERE package = ? AND release = ?', array($pid, $release['id'])); @@ -554,5 +557,32 @@ @chmod($mdir . DIRECTORY_SEPARATOR . $maintainer['handle'] . DIRECTORY_SEPARATOR . 'info.xml', 0666); } + + function saveAllMaintainersREST() + { + $maintainers = user::listAll(); + $info = '<?xml version="1.0" encoding="UTF-8" ?> +<m xmlns="http://pear.php.net/dtd/rest.allmaintainers" + xsi:schemaLocation="http://pear.php.net/dtd/rest.allmaintainers + http://pear.php.net/dtd/rest.allmaintainers.xsd">' . "\n"; + // package information + require_once 'Damblan/Karma.php'; + $karma = &new Damblan_Karma($GLOBALS['dbh']); + foreach ($maintainers as $maintainer) { + if (!$karma->has($maintainer['handle'], 'pear.dev')) { + continue; + } + $info .= ' <h xlink:href="/rest/m/' . $maintainer['handle'] . '">' . + $maintainer['handle'] . '</h>' . "\n"; + } + $info .= '</m>'; + $mdir = $this->_restdir . DIRECTORY_SEPARATOR . 'm'; + if (!is_dir($mdir)) { + System::mkdir(array('-p', $mdir)); + @chmod($mdir, 0777); + } + file_put_contents($mdir . DIRECTORY_SEPARATOR . 'allmaintainers.xml', $info); + @chmod($mdir . DIRECTORY_SEPARATOR . 'allmaintainers.xml', 0666); + } } ?> http://cvs.php.net/diff.php/pearweb/public_html/admin/package-approval.php?r1=1.12&r2=1.13&ty=u Index: pearweb/public_html/admin/package-approval.php diff -u pearweb/public_html/admin/package-approval.php:1.12 pearweb/public_html/admin/package-approval.php:1.13 --- pearweb/public_html/admin/package-approval.php:1.12 Sun Jul 3 21:00:49 2005 +++ pearweb/public_html/admin/package-approval.php Thu Oct 27 00:57:52 2005 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: package-approval.php,v 1.12 2005/07/04 01:00:49 rasmus Exp $ + $Id: package-approval.php,v 1.13 2005/10/27 04:57:52 cellog Exp $ */ auth_require("pear.group"); @@ -46,6 +46,7 @@ if ($action == 'approved') { $pear_rest->savePackageREST($row['name']); $pear_rest->saveAllPackagesREST(); + $pear_rest->savePackagesCategoryREST(package::info($row['name'], 'category')); } // {{{ Logging mechanism require_once "Damblan/Log.php"; http://cvs.php.net/diff.php/pearweb/public_html/package-edit.php?r1=1.39&r2=1.40&ty=u Index: pearweb/public_html/package-edit.php diff -u pearweb/public_html/package-edit.php:1.39 pearweb/public_html/package-edit.php:1.40 --- pearweb/public_html/package-edit.php:1.39 Thu Oct 20 20:03:00 2005 +++ pearweb/public_html/package-edit.php Thu Oct 27 00:57:52 2005 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: package-edit.php,v 1.39 2005/10/21 00:03:00 cellog Exp $ + $Id: package-edit.php,v 1.40 2005/10/27 04:57:52 cellog Exp $ */ /* @@ -95,7 +95,9 @@ if (PEAR::isError($sth)) { report_error('Unable to save data!'); } else { + $pear_rest->saveAllPackagesREST(); $pear_rest->savePackageREST($_POST['name']); + $pear_rest->savePackagesCategoryREST(package::info($_POST['name'], 'category')); echo "<b>Package information successfully updated.</b><br /><br />\n"; } }