当前位置: 首页>>代码示例>>PHP>>正文


PHP category::listPackages方法代码示例

本文整理汇总了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);
    }
开发者ID:stof,项目名称:pearweb,代码行数:62,代码来源:pear-rest.php

示例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);
    }
开发者ID:ThaDafinser,项目名称:web-pecl,代码行数:53,代码来源:pear-rest.php


注:本文中的category::listPackages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。