當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。