PEAR_PackageFileManager
[ class tree: PEAR_PackageFileManager ] [ index: PEAR_PackageFileManager ] [ all elements ]

Source for file XMLOutput.php

Documentation is available at XMLOutput.php

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: Package File Manager                                           |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2004 Gregory Beaver                                      |
  7. // | Email         cellog@phpdoc.org                                        |
  8. // +------------------------------------------------------------------------+
  9. // | This source file is subject to version 3.00 of the PHP License,        |
  10. // | that is available at http://www.php.net/license/3_0.txt.               |
  11. // | If you did not receive a copy of the PHP license and are unable to     |
  12. // | obtain it through the world-wide-web, please send a note to            |
  13. // | license@php.net so we can mail you a copy immediately.                 |
  14. // +------------------------------------------------------------------------+
  15. // | Portions of this code based on phpDocumentor                           |
  16. // | Web           http://www.phpdoc.org                                    |
  17. // | Mirror        http://phpdocu.sourceforge.net/                          |
  18. // +------------------------------------------------------------------------+
  19. // $Id: XMLOutput.php,v 1.4 2004/02/07 18:04:00 cellog Exp $
  20. //
  21.  
  22. /**
  23.  * Class for XML output
  24.  *
  25.  * @author Greg Beaver <cellog@php.net>
  26.  * @since 1.2.0
  27.  * @copyright 2003
  28.  * @package PEAR_PackageFileManager
  29.  */
  30. class PEAR_PackageFileManager_XMLOutput extends PEAR_Common {
  31.  
  32.     /**
  33.      * Generate part of an XML description with release information.
  34.      *
  35.      * @param array  $pkginfo    array with release information
  36.      * @param bool   $changelog  whether the result will be in a changelog element
  37.      *
  38.      * @return string XML data
  39.      *
  40.      * @access private
  41.      */
  42.     function _makeReleaseXml($pkginfo$changelog = false)
  43.     {
  44.         $indent $changelog "  " "";
  45.         $ret = "$indent  <release>\n";
  46.         if (!empty($pkginfo['version'])) {
  47.             $ret .= "$indent    <version>$pkginfo[version]</version>\n";
  48.         }
  49.         if (!empty($pkginfo['release_date'])) {
  50.             $ret .= "$indent    <date>$pkginfo[release_date]</date>\n";
  51.         }
  52.         if (!empty($pkginfo['release_license'])) {
  53.             $ret .= "$indent    <license>$pkginfo[release_license]</license>\n";
  54.         }
  55.         if (!empty($pkginfo['release_state'])) {
  56.             $ret .= "$indent    <state>$pkginfo[release_state]</state>\n";
  57.         }
  58.         if (!empty($pkginfo['release_notes'])) {
  59.             $ret .= "$indent    <notes>".htmlspecialchars($pkginfo['release_notes'])."</notes>\n";
  60.         }
  61.         if (!empty($pkginfo['release_warnings'])) {
  62.             $ret .= "$indent    <warnings>".htmlspecialchars($pkginfo['release_warnings'])."</warnings>\n";
  63.         }
  64.         if (isset($pkginfo['release_deps']&& sizeof($pkginfo['release_deps']> 0{
  65.             $ret .= "$indent    <deps>\n";
  66.             foreach ($pkginfo['release_deps'as $dep{
  67.                 $ret .= "$indent      <dep type=\"$dep[type]\" rel=\"$dep[rel]\"";
  68.                 if (isset($dep['version'])) {
  69.                     $ret .= " version=\"$dep[version]\"";
  70.                 }
  71.                 if (isset($dep['optional'])) {
  72.                     $ret .= " optional=\"$dep[optional]\"";
  73.                 }
  74.                 if (isset($dep['name'])) {
  75.                     $ret .= ">$dep[name]</dep>\n";
  76.                 else {
  77.                     $ret .= "/>\n";
  78.                 }
  79.             }
  80.             $ret .= "$indent    </deps>\n";
  81.         }
  82.         if (isset($pkginfo['configure_options'])) {
  83.             $ret .= "$indent    <configureoptions>\n";
  84.             foreach ($pkginfo['configure_options'as $c{
  85.                 $ret .= "$indent      <configureoption name=\"".
  86.                     htmlspecialchars($c['name']"\"";
  87.                 if (isset($c['default'])) {
  88.                     $ret .= " default=\"" htmlspecialchars($c['default']"\"";
  89.                 }
  90.                 $ret .= " prompt=\"" htmlspecialchars($c['prompt']"\"";
  91.                 $ret .= "/>\n";
  92.             }
  93.             $ret .= "$indent    </configureoptions>\n";
  94.         }
  95.         if (isset($pkginfo['provides'])) {
  96.             foreach ($pkginfo['provides'as $key => $what{
  97.                 $ret .= "$indent    <provides type=\"$what[type]\" ";
  98.                 $ret .= "name=\"$what[name]\" ";
  99.                 if (isset($what['extends'])) {
  100.                     $ret .= "extends=\"$what[extends]\" ";
  101.                 }
  102.                 $ret .= "/>\n";
  103.             }
  104.         }
  105.         if (isset($pkginfo['filelist'])) {
  106.             $ret .= "$indent    <filelist>\n";
  107.             $ret .= $this->_doFileList($indent$pkginfo['filelist']'/');
  108.             $ret .= "$indent    </filelist>\n";
  109.         }
  110.         $ret .= "$indent  </release>\n";
  111.         return $ret;
  112.     }
  113.  
  114.     /**
  115.      * Generate the <filelist> tag
  116.      * @access private
  117.      * @return string 
  118.      */
  119.     function _doFileList($indent$filelist$curdir)
  120.     {
  121.         $ret '';
  122.         foreach ($filelist as $file => $fa{
  123.             if (isset($fa['##files'])) {
  124.                 $ret .= "$indent      <dir";
  125.             else {
  126.                 $ret .= "$indent      <file";
  127.             }
  128.  
  129.             if (isset($fa['role'])) {
  130.                 $ret .= " role=\"$fa[role]\"";
  131.             }
  132.             if (isset($fa['baseinstalldir'])) {
  133.                 $ret .= ' baseinstalldir="' .
  134.                     htmlspecialchars($fa['baseinstalldir']'"';
  135.             }
  136.             if (isset($fa['md5sum'])) {
  137.                 $ret .= " md5sum=\"$fa[md5sum]\"";
  138.             }
  139.             if (isset($fa['platform'])) {
  140.                 $ret .= " platform=\"$fa[platform]\"";
  141.             }
  142.             if (!empty($fa['install-as'])) {
  143.                 $ret .= ' install-as="' .
  144.                     htmlspecialchars($fa['install-as']'"';
  145.             }
  146.             $ret .= ' name="' htmlspecialchars($file'"';
  147.             if (isset($fa['##files'])) {
  148.                 $ret .= ">\n";
  149.                 $recurdir $curdir;
  150.                 if ($recurdir == '///'{
  151.                     $recurdir '';
  152.                 }
  153.                 $ret .= $this->_doFileList("$indent "$fa['##files']$recurdir $file '/');
  154.                 $displaydir $curdir;
  155.                 if ($displaydir == '///' || $displaydir == '/'{
  156.                     $displaydir '';
  157.                 }
  158.                 $ret .= "$indent      </dir> <!-- $displaydir$file -->\n";
  159.             else {
  160.                 if (empty($fa['replacements'])) {
  161.                     $ret .= "/>\n";
  162.                 else {
  163.                     $ret .= ">\n";
  164.                     foreach ($fa['replacements'as $r{
  165.                         $ret .= "$indent        <replace";
  166.                         foreach ($r as $k => $v{
  167.                             $ret .= " $k=\"" . htmlspecialchars($v.'"';
  168.                         }
  169.                         $ret .= "/>\n";
  170.                     }
  171.                     $ret .= "$indent      </file>\n";
  172.                 }
  173.             }
  174.         }
  175.         return $ret;
  176.     }
  177.     
  178. }
  179.  
  180. ?>

Documentation generated on Mon, 11 Mar 2019 14:15:37 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.