[ Index ]
 

Code source de PHP PEAR 1.4.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/PEAR/PackageFile/Generator/ -> v2.php (sommaire)

package.xml generation class, package.xml version 2.0 PHP versions 4 and 5

Author: Greg Beaver <cellog@php.net>
Author: Stephan Schmidt (original XML_Serializer code)
Copyright: 1997-2006 The PHP Group
License: http://www.php.net/license/3_0.txt PHP License 3.0
Version: CVS: $Id: v2.php,v 1.35 2006/03/25 21:09:08 cellog Exp $
Poids: 1527 lignes (61 kb)
Inclus ou requis: 2 fois
Référencé: 0 fois
Nécessite: 3 fichiers
 PEAR.php
 System.php
 Archive/Tar.php

Définit 2 classes

PEAR_PackageFile_Generator_v2:: (19 méthodes):
  PEAR_PackageFile_Generator_v2()
  getPackagerVersion()
  toTgz()
  toTgz2()
  toPackageFile()
  toV2()
  toXml()
  _recursiveXmlFilelist()
  _addDir()
  _formatDir()
  _deFormat()
  resetOptions()
  setOption()
  setOptions()
  serialize()
  getSerializedData()
  _serializeValue()
  _serializeArray()
  _createXMLTag()

PEAR_PackageFile_Generator_v2_XML_Util:: (14 méthodes):
  apiVersion()
  replaceEntities()
  getXMLDeclaration()
  getDocTypeDeclaration()
  attributesToString()
  createTag()
  createTagFromArray()
  createStartElement()
  createEndElement()
  createComment()
  createCDataSection()
  splitQualifiedName()
  isValidName()
  raiseError()


Classe: PEAR_PackageFile_Generator_v2  - X-Ref

This class converts a PEAR_PackageFile_v2 object into any output format.

Supported output formats include array, XML string (using S. Schmidt's
XML_Serializer, slightly customized)
PEAR_PackageFile_Generator_v2(&$packagefile)   X-Ref

param: PEAR_PackageFile_v2

getPackagerVersion()   X-Ref

return: string

toTgz(&$packager, $compress = true, $where = null)   X-Ref

param: PEAR_Packager
param: bool generate a .tgz or a .tar
param: string|null temporary directory to package in

toTgz2(&$packager, &$pf1, $compress = true, $where = null)   X-Ref
Package up both a package.xml and package2.xml for the same release

param: PEAR_Packager
param: PEAR_PackageFile_v1
param: bool generate a .tgz or a .tar
param: string|null temporary directory to package in

toPackageFile($where = null, $state = PEAR_VALIDATE_NORMAL, $name = 'package.xml')   X-Ref
Pas de description

toV2()   X-Ref
Pas de description

toXml($state = PEAR_VALIDATE_NORMAL, $options = array()   X-Ref
Return an XML document based on the package info (as returned
by the PEAR_Common::infoFrom* methods).

return: string XML data

_recursiveXmlFilelist($list)   X-Ref
Pas de description

_addDir(&$dirs, $dir, $file = null, $attributes = null, $tasks = null)   X-Ref
Pas de description

_formatDir(&$dirs)   X-Ref
Pas de description

_deFormat(&$dirs)   X-Ref
Pas de description

resetOptions()   X-Ref
reset all options to default options


setOption($name, $value)   X-Ref
set an option

You can use this method if you do not want to set all options in the constructor


setOptions($options)   X-Ref
sets several options at once

You can use this method if you do not want to set all options in the constructor


serialize($data, $options = null)   X-Ref
serialize data

param: mixed    $data data to serialize
return: boolean  true on success, pear error on failure

getSerializedData()   X-Ref
get the result of the serialization

return: string serialized XML

_serializeValue($value, $tagName = null, $attributes = array()   X-Ref
serialize any value

This method checks for the type of the value and calls the appropriate method

param: mixed     $value
param: string    $tagName
param: array     $attributes
return: string

_serializeArray(&$array, $tagName = null, $attributes = array()   X-Ref
serialize an array

param: array   $array       array to serialize
param: string  $tagName     name of the root tag
param: array   $attributes  attributes for the root tag
return: string  $string      serialized data

_createXMLTag( $tag, $replaceEntities = true )   X-Ref
create a tag from an array
this method awaits an array in the following format
array(
'qname'        => $tagName,
'attributes'   => array(),
'content'      => $content,      // optional
'namespace'    => $namespace     // optional
'namespaceUri' => $namespaceUri  // optional
)

param: array   $tag tag definition
param: boolean $replaceEntities whether to replace XML entities in content or not
return: string  $string XML tag

Classe: PEAR_PackageFile_Generator_v2_XML_Util  - X-Ref

utility class for working with XML documents

customized version of XML_Util 0.6.0

apiVersion()   X-Ref
return API version

return: string  $version API version

replaceEntities($string, $replaceEntities = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML)   X-Ref
replace XML entities

With the optional second parameter, you may select, which
entities should be replaced.

<code>
require_once 'XML/Util.php';

// replace XML entites:
$string = PEAR_PackageFile_Generator_v2_XML_Util::replaceEntities("This string contains < & >.");
</code>

param: string  string where XML special chars should be replaced
param: integer setting for entities in attribute values (one of PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML_REQUIRED, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_HTML)
return: string  string with replaced chars

getXMLDeclaration($version = "1.0", $encoding = null, $standalone = null)   X-Ref
build an xml declaration

<code>
require_once 'XML/Util.php';

// get an XML declaration:
$xmlDecl = PEAR_PackageFile_Generator_v2_XML_Util::getXMLDeclaration("1.0", "UTF-8", true);
</code>

param: string  $version     xml version
param: string  $encoding    character encoding
param: boolean $standAlone  document is standalone (or not)
return: string  $decl xml declaration

getDocTypeDeclaration($root, $uri = null, $internalDtd = null)   X-Ref
build a document type declaration

<code>
require_once 'XML/Util.php';

// get a doctype declaration:
$xmlDecl = PEAR_PackageFile_Generator_v2_XML_Util::getDocTypeDeclaration("rootTag","myDocType.dtd");
</code>

param: string  $root         name of the root tag
param: string  $uri          uri of the doctype definition (or array with uri and public id)
param: string  $internalDtd  internal dtd entries   
return: string  $decl         doctype declaration

attributesToString($attributes, $sort = true, $multiline = false, $indent = ' ', $linebreak = "\n", $entities = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML)   X-Ref
create string representation of an attribute list

<code>
require_once 'XML/Util.php';

// build an attribute string
$att = array(
"foo"   =>  "bar",
"argh"  =>  "tomato"
);

$attList = PEAR_PackageFile_Generator_v2_XML_Util::attributesToString($att);
</code>

param: array         $attributes        attribute array
param: boolean|array $sort              sort attribute list alphabetically, may also be an assoc array containing the keys 'sort', 'multiline', 'indent', 'linebreak' and 'entities'
param: boolean       $multiline         use linebreaks, if more than one attribute is given
param: string        $indent            string used for indentation of multiline attributes
param: string        $linebreak         string used for linebreaks of multiline attributes
param: integer       $entities          setting for entities in attribute values (one of PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_NONE, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML_REQUIRED, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_HTML)
return: string                           string representation of the attributes

createTag($qname, $attributes = array()   X-Ref
create a tag

This method will call PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray(), which
is more flexible.

<code>
require_once 'XML/Util.php';

// create an XML tag:
$tag = PEAR_PackageFile_Generator_v2_XML_Util::createTag("myNs:myTag", array("foo" => "bar"), "This is inside the tag", "http://www.w3c.org/myNs#");
</code>

param: string  $qname             qualified tagname (including namespace)
param: array   $attributes        array containg attributes
param: mixed   $content
param: string  $namespaceUri      URI of the namespace
param: integer $replaceEntities   whether to replace XML special chars in content, embedd it in a CData section or none of both
param: boolean $multiline         whether to create a multiline tag where each attribute gets written to a single line
param: string  $indent            string used to indent attributes (_auto indents attributes so they start at the same column)
param: string  $linebreak         string used for linebreaks
param: string  $encoding          encoding that should be used to translate content
return: string  $string            XML tag

createTagFromArray($tag, $replaceEntities = PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES, $multiline = false, $indent = "_auto", $linebreak = "\n", $encoding = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML)   X-Ref
create a tag from an array
this method awaits an array in the following format
<pre>
array(
"qname"        => $qname         // qualified name of the tag
"namespace"    => $namespace     // namespace prefix (optional, if qname is specified or no namespace)
"localpart"    => $localpart,    // local part of the tagname (optional, if qname is specified)
"attributes"   => array(),       // array containing all attributes (optional)
"content"      => $content,      // tag content (optional)
"namespaceUri" => $namespaceUri  // namespaceUri for the given namespace (optional)
)
</pre>

<code>
require_once 'XML/Util.php';

$tag = array(
"qname"        => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes"   => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content"      => "I'm inside the tag",
);
// creating a tag with qualified name and namespaceUri
$string = PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray($tag);
</code>

param: array   $tag               tag definition
param: integer $replaceEntities   whether to replace XML special chars in content, embedd it in a CData section or none of both
param: boolean $multiline         whether to create a multiline tag where each attribute gets written to a single line
param: string  $indent            string used to indent attributes (_auto indents attributes so they start at the same column)
param: string  $linebreak         string used for linebreaks
return: string  $string            XML tag

createStartElement($qname, $attributes = array()   X-Ref
create a start element

<code>
require_once 'XML/Util.php';

// create an XML start element:
$tag = PEAR_PackageFile_Generator_v2_XML_Util::createStartElement("myNs:myTag", array("foo" => "bar") ,"http://www.w3c.org/myNs#");
</code>

param: string  $qname             qualified tagname (including namespace)
param: array   $attributes        array containg attributes
param: string  $namespaceUri      URI of the namespace
param: boolean $multiline         whether to create a multiline tag where each attribute gets written to a single line
param: string  $indent            string used to indent attributes (_auto indents attributes so they start at the same column)
param: string  $linebreak         string used for linebreaks
return: string  $string            XML start element

createEndElement($qname)   X-Ref
create an end element

<code>
require_once 'XML/Util.php';

// create an XML start element:
$tag = PEAR_PackageFile_Generator_v2_XML_Util::createEndElement("myNs:myTag");
</code>

param: string  $qname             qualified tagname (including namespace)
return: string  $string            XML end element

createComment($content)   X-Ref
create an XML comment

<code>
require_once 'XML/Util.php';

// create an XML start element:
$tag = PEAR_PackageFile_Generator_v2_XML_Util::createComment("I am a comment");
</code>

param: string  $content           content of the comment
return: string  $comment           XML comment

createCDataSection($data)   X-Ref
create a CData section

<code>
require_once 'XML/Util.php';

// create a CData section
$tag = PEAR_PackageFile_Generator_v2_XML_Util::createCDataSection("I am content.");
</code>

param: string  $data              data of the CData section
return: string  $string            CData section with content

splitQualifiedName($qname, $defaultNs = null)   X-Ref
split qualified name and return namespace and local part

<code>
require_once 'XML/Util.php';

// split qualified tag
$parts = PEAR_PackageFile_Generator_v2_XML_Util::splitQualifiedName("xslt:stylesheet");
</code>
the returned array will contain two elements:
<pre>
array(
"namespace" => "xslt",
"localPart" => "stylesheet"
);
</pre>

param: string    $qname      qualified tag name
param: string    $defaultNs  default namespace (optional)
return: array     $parts      array containing namespace and local part

isValidName($string)   X-Ref
check, whether string is valid XML name

<p>XML names are used for tagname, attribute names and various
other, lesser known entities.</p>
<p>An XML name may only consist of alphanumeric characters,
dashes, undescores and periods, and has to start with a letter
or an underscore.
</p>

<code>
require_once 'XML/Util.php';

// verify tag name
$result = PEAR_PackageFile_Generator_v2_XML_Util::isValidName("invalidTag?");
if (PEAR_PackageFile_Generator_v2_XML_Util::isError($result)) {
print "Invalid XML name: " . $result->getMessage();
}
</code>

param: string  $string string that should be checked
return: mixed   $valid  true, if string is a valid XML name, PEAR error otherwise

raiseError($msg, $code)   X-Ref
replacement for PEAR_PackageFile_Generator_v2_XML_Util::raiseError

Avoids the necessity to always require
PEAR.php

param: string      error message
param: integer     error code
return: object PEAR_Error



Généré le : Sun Feb 25 14:08:00 2007 par Balluche grâce à PHPXref 0.7