Source for file SimpleGenerator.php
Documentation is available at SimpleGenerator.php
// +------------------------------------------------------------------------+
// | PEAR :: Package File Manager |
// +------------------------------------------------------------------------+
// | Copyright (c) 2004 Gregory Beaver |
// | Email cellog@phpdoc.org |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License, |
// | that is available at http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +------------------------------------------------------------------------+
// | Portions of this code based on phpDocumentor |
// | Web http://www.phpdoc.org |
// | Mirror http://phpdocu.sourceforge.net/ |
// +------------------------------------------------------------------------+
// $Id: SimpleGenerator.php,v 1.4 2005/05/20 22:42:59 cellog Exp $
require_once 'PEAR/PackageFile/Generator/v1.php';
* @author Greg Beaver <cellog@php.net>
* @package PEAR_PackageFileManager
* remove a warning about missing parameters - don't delete this
* Return an XML document based on the package info (as returned
* by the PEAR_Common::infoFrom* methods).
* @param array $pkginfo package info
* @return string XML data
* @deprecated use a PEAR_PackageFile_v* object's generator instead
include_once 'PEAR/PackageFile.php';
include_once 'PEAR/Config.php';
$config = &PEAR_Config ::singleton ();
$packagefile = &new PEAR_PackageFile ($config);
$pf = &$packagefile->fromArray ($pkginfo);
parent ::PEAR_PackageFile_Generator_v1 ($pf);
return PEAR_Common ::getFileRoles ();
return PEAR_Common ::getReplacementTypes ();
* Validate XML package definition file.
* @param string $info Filename of the package archive or of the
* package definition file
* @param array $errors Array that will contain the errors
* @param array $warnings Array that will contain the warnings
* @param string $dir_prefix (optional) directory where source files
* may be found, or empty if they are not available
* @deprecated use the validation of PEAR_PackageFile objects
include_once 'PEAR/PackageFile.php';
include_once 'PEAR/Config.php';
$config = &PEAR_Config ::singleton ();
$packagefile = &new PEAR_PackageFile ($config);
PEAR ::staticPushErrorHandling (PEAR_ERROR_RETURN );
$pf = &$packagefile->fromArray ($info);
if (!$pf->validate (PEAR_VALIDATE_NORMAL )) {
foreach ($pf->getValidationWarnings () as $err) {
if ($error['level'] == 'error') {
$errors[] = $error['message'];
$warnings[] = $error['message'];
$pf = &$packagefile->fromAnyFile ($info, PEAR_VALIDATE_NORMAL );
PEAR ::staticPopErrorHandling ();
if (PEAR ::isError ($pf)) {
$errs = $pf->getUserinfo ();
foreach ($errs as $error) {
if ($error['level'] == 'error') {
$errors[] = $error['message'];
$warnings[] = $error['message'];
foreach ($list as $file => $attributes) {
$this->_addDir ($this->_dirs, explode('/', dirname($file)), $file, $attributes);
if (!isset ($this->_dirs['dirs'])) {
$this->_dirs['dirs'] = array ();
if (count($this->_dirs['dirs']) != 1 || isset ($this->_dirs['files'])) {
$this->_dirs = array ('dirs' => array ('/' => $this->_dirs));
return $this->_formatDir ($this->_dirs, '', '', true );
function _addDir (&$dirs, $dir, $file = null , $attributes = null )
if ($dir == array () || $dir == array ('.')) {
$dirs['files'][basename($file)] = $attributes;
if (!isset ($dirs['dirs'][$curdir])) {
$dirs['dirs'][$curdir] = array ();
$this->_addDir ($dirs['dirs'][$curdir], $dir, $file, $attributes);
function _formatDir ($dirs, $indent = '', $curdir = '', $toplevel = false )
if (isset ($dirs['dirs'])) {
uksort($dirs['dirs'], 'strnatcasecmp');
foreach ($dirs['dirs'] as $dir => $contents) {
$usedir = " $curdir/$dir";
$ret .= " $indent <dir name=\"$dir\"";
$ret .= ' baseinstalldir="' . $this->_options['baseinstalldir'] . '"';
if (isset ($this->_options['installexceptions'][$dir])) {
$ret .= ' baseinstalldir="' . $this->_options['installexceptions'][$dir] . '"';
$ret .= $this->_formatDir ($contents, " $indent " , $usedir);
$ret .= " $indent </dir> <!-- $usedir -->\n";
if (isset ($dirs['files'])) {
uksort($dirs['files'], 'strnatcasecmp');
foreach ($dirs['files'] as $file => $attribs) {
$ret .= $this->_formatFile ($file, $attribs, $indent);
function _formatFile ($file, $attributes, $indent)
$ret = " $indent <file role=\"$attributes[role]\"";
if (isset ($this->_options['installexceptions'][$file])) {
$ret .= ' baseinstalldir="' . $this->_options['installexceptions'][$file] . '"';
if (isset ($attributes['md5sum'])) {
$ret .= " md5sum=\"$attributes[md5sum]\"";
if (isset ($attributes['platform'])) {
$ret .= " platform=\"$attributes[platform]\"";
if (!empty ($attributes['install-as'])) {
$ret .= ' install-as="' .
if (empty ($attributes['replacements'])) {
foreach ($attributes['replacements'] as $r) {
$ret .= " $indent <replace";
foreach ($r as $k => $v) {
$ret .= " $indent </file>\n";
* Generate the <filelist> tag
function _doFileList ($indent, $filelist, $curdir)
foreach ($filelist as $file => $fa) {
if (isset ($fa['##files'])) {
if (isset ($fa['role'])) {
$ret .= " role=\"$fa[role]\"";
if (isset ($fa['baseinstalldir'])) {
$ret .= ' baseinstalldir="' .
if (isset ($fa['md5sum'])) {
$ret .= " md5sum=\"$fa[md5sum]\"";
if (isset ($fa['platform'])) {
$ret .= " platform=\"$fa[platform]\"";
if (!empty ($fa['install-as'])) {
$ret .= ' install-as="' .
if (isset ($fa['##files'])) {
if ($recurdir == '///') {
$ret .= $this->_doFileList (" $indent " , $fa['##files'], $recurdir . $file . '/');
if ($displaydir == '///' || $displaydir == '/') {
$ret .= " $indent </dir> <!-- $displaydir$file -->\n";
if (empty ($fa['replacements'])) {
foreach ($fa['replacements'] as $r) {
$ret .= " $indent <replace";
foreach ($r as $k => $v) {
$ret .= " $indent </file>\n";
Documentation generated on Mon, 11 Mar 2019 14:20:56 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|