本文整理汇总了PHP中category::listPackages方法的典型用法代码示例。如果您正苦于以下问题:PHP category::listPackages方法的具体用法?PHP category::listPackages怎么用?PHP category::listPackages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类category
的用法示例。
在下文中一共展示了category::listPackages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: savePackagesCategoryREST
public function savePackagesCategoryREST($category)
{
$cdir = $this->getCategoryDirectory();
if (!is_dir($cdir)) {
return;
}
// list packages in a category
$dir = $cdir . urlencode($category) . DIRECTORY_SEPARATOR;
if (!is_dir($dir)) {
if (!mkdir($dir, 0777, true)) {
return PEAR::raiseError('Creating directory ' . $dir . ' failed - Check the permissions');
}
}
$pdir = $this->getPackageDirectory();
$rdir = $this->getReleaseDirectory();
include_once 'pear-database-category.php';
$packages = category::listPackages($category);
$fullpackageinfo = '<?xml version="1.0" encoding="UTF-8" ?>
<f xmlns="http://pear.php.net/dtd/rest.categorypackageinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink"
xsi:schemaLocation="http://pear.php.net/dtd/rest.categorypackageinfo
http://pear.php.net/dtd/rest.categorypackageinfo.xsd">
';
clearstatcache();
foreach ($packages as $package) {
$pmdir = $pdir . strtolower($package['name']) . DIRECTORY_SEPARATOR;
if (!file_exists($pmdir . 'info.xml')) {
continue;
}
$fullpackageinfo .= '<pi>
';
$contents = file_get_contents($pmdir . 'info.xml');
$fullpackageinfo .= '<p>' . substr($contents, strpos($contents, '<n>'));
$rmdir = $rdir . strtolower($package['name']) . DIRECTORY_SEPARATOR;
if (file_exists($rmdir . 'allreleases.xml')) {
$fullpackageinfo .= str_replace($this->_getAllReleasesRESTProlog($package['name']), '
<a>
', file_get_contents($rmdir . 'allreleases.xml'));
$files = scandir($rmdir);
foreach ($files as $entry) {
if (strpos($entry, 'deps.') === 0) {
$version = str_replace(array('deps.', '.txt'), array('', ''), $entry);
$fullpackageinfo .= '
<deps>
<v>' . $version . '</v>
<d>' . htmlspecialchars(utf8_encode(file_get_contents($rmdir . $entry))) . '</d>
</deps>
';
}
}
}
$fullpackageinfo .= '</pi>
';
}
$fullpackageinfo .= '</f>';
$file = $dir . 'packagesinfo.xml';
if (!file_put_contents($file, $fullpackageinfo)) {
return PEAR::raiseError('Writing file ' . $file . ' failed - Check the permissions');
}
@chmod($file, 0666);
}
示例2: savePackagesCategoryREST
function savePackagesCategoryREST($category)
{
$cdir = $this->_restdir . DIRECTORY_SEPARATOR . 'c';
if (!is_dir($cdir)) {
return;
}
$pdir = $this->_restdir . DIRECTORY_SEPARATOR . 'p';
$rdir = $this->_restdir . DIRECTORY_SEPARATOR . 'r';
$packages = category::listPackages($category);
$fullpackageinfo = '<?xml version="1.0" encoding="UTF-8" ?>
<f xmlns="http://pear.php.net/dtd/rest.categorypackageinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink"
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')) {
continue;
}
$fullpackageinfo .= '<pi>
';
$contents = file_get_contents($pdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'info.xml');
$fullpackageinfo .= '<p>' . substr($contents, strpos($contents, '<n>'));
if (file_exists($rdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'allreleases.xml')) {
$fullpackageinfo .= str_replace($this->_getAllReleasesRESTProlog($package['name']), '
<a>
', file_get_contents($rdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . 'allreleases.xml'));
$dirhandle = opendir($rdir . DIRECTORY_SEPARATOR . strtolower($package['name']));
while (false !== ($entry = readdir($dirhandle))) {
if (strpos($entry, 'deps.') === 0) {
$version = str_replace(array('deps.', '.txt'), array('', ''), $entry);
$fullpackageinfo .= '
<deps>
<v>' . $version . '</v>
<d>' . htmlspecialchars(utf8_encode(file_get_contents($rdir . DIRECTORY_SEPARATOR . strtolower($package['name']) . DIRECTORY_SEPARATOR . $entry))) . '</d>
</deps>
';
}
}
}
$fullpackageinfo .= '</pi>
';
}
$fullpackageinfo .= '</f>';
// list packages in a category
if (!is_dir($cdir . DIRECTORY_SEPARATOR . urlencode($category))) {
mkdir($cdir . DIRECTORY_SEPARATOR . urlencode($category));
}
file_put_contents($cdir . DIRECTORY_SEPARATOR . urlencode($category) . DIRECTORY_SEPARATOR . 'packagesinfo.xml', $fullpackageinfo);
@chmod($cdir . DIRECTORY_SEPARATOR . urlencode($category) . DIRECTORY_SEPARATOR . 'packagesinfo.xml', 0666);
}