Overview

Packages

  • Pear

Classes

  • Horde_Pear_Exception
  • Horde_Pear_Package_Contents_Ignore_Composite
  • Horde_Pear_Package_Contents_Ignore_Dot
  • Horde_Pear_Package_Contents_Ignore_Git
  • Horde_Pear_Package_Contents_Ignore_Hidden
  • Horde_Pear_Package_Contents_Ignore_Nothing
  • Horde_Pear_Package_Contents_Ignore_Patterns
  • Horde_Pear_Package_Contents_Include_All
  • Horde_Pear_Package_Contents_InstallAs_Horde
  • Horde_Pear_Package_Contents_InstallAs_HordeApplication
  • Horde_Pear_Package_Contents_InstallAs_HordeComponent
  • Horde_Pear_Package_Contents_InstallAs_HordeRole
  • Horde_Pear_Package_Contents_List
  • Horde_Pear_Package_Contents_Role_HordeApplication
  • Horde_Pear_Package_Contents_Role_HordeComponent
  • Horde_Pear_Package_Dependencies
  • Horde_Pear_Package_Task_UpdateContents
  • Horde_Pear_Package_Type_Horde
  • Horde_Pear_Package_Xml
  • Horde_Pear_Package_Xml_Contents
  • Horde_Pear_Package_Xml_Directory
  • Horde_Pear_Package_Xml_Element_Directory
  • Horde_Pear_Package_Xml_Element_File
  • Horde_Pear_Package_Xml_Factory
  • Horde_Pear_Registry
  • Horde_Pear_Remote
  • Horde_Pear_Rest
  • Horde_Pear_Rest_Dependencies
  • Horde_Pear_Rest_Package
  • Horde_Pear_Rest_PackageList
  • Horde_Pear_Rest_Release
  • Horde_Pear_Rest_Releases

Interfaces

  • Horde_Pear_Package_Contents
  • Horde_Pear_Package_Contents_Ignore
  • Horde_Pear_Package_Contents_Include
  • Horde_Pear_Package_Contents_InstallAs
  • Horde_Pear_Package_Contents_Role
  • Horde_Pear_Package_Task
  • Horde_Pear_Package_Type
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Updates the content listings of a package.xml file.
  4:  *
  5:  * PHP version 5
  6:  *
  7:  * @category Horde
  8:  * @package  Pear
  9:  * @author   Gunnar Wrobel <wrobel@pardus.de>
 10:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 11:  * @link     http://pear.horde.org/index.php?package=Pear
 12:  */
 13: 
 14: /**
 15:  * Updates the content listings of a package.xml file.
 16:  *
 17:  * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
 18:  *
 19:  * See the enclosed file COPYING for license information (LGPL). If you
 20:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 21:  *
 22:  * @category Horde
 23:  * @package  Pear
 24:  * @author   Gunnar Wrobel <wrobel@pardus.de>
 25:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 26:  * @link     http://pear.horde.org/index.php?package=Pear
 27:  */
 28: class Horde_Pear_Package_Task_UpdateContents
 29: implements Horde_Pear_Package_Task
 30: {
 31:     /**
 32:      * The package.xml handler.
 33:      *
 34:      * @var Horde_Pear_Package_Xml
 35:      */
 36:     private $_xml;
 37: 
 38:     /**
 39:      * The contents handler.
 40:      *
 41:      * @var Horde_Pear_Package_Contents
 42:      */
 43:     private $_content;
 44: 
 45:     /**
 46:      * Additional options.
 47:      *
 48:      * @var array
 49:      */
 50:     private $_options;
 51: 
 52:     /**
 53:      * Constructor.
 54:      *
 55:      * @param Horde_Pear_Package_Xml      $xml     The package.xml file to
 56:      *                                             operate on.
 57:      * @param Horde_Pear_Package_Contents $content The content list.
 58:      * @param array                       $options Additional options.
 59:      */
 60:     public function __construct(Horde_Pear_Package_Xml $xml,
 61:                                 Horde_Pear_Package_Contents $content = null,
 62:                                 $options = array())
 63:     {
 64:         $this->_xml = $xml;
 65:         $this->_options = $options;
 66:         if ($content === null) {
 67:             $this->_content = $this->_xml->getContent();
 68:         } else {
 69:             $this->_content = $content;
 70:         }
 71:     }
 72: 
 73:     /**
 74:      * Execute the task.
 75:      *
 76:      * @return NULL
 77:      */
 78:     public function run()
 79:     {
 80:         $contents = $this->_xml->findNode('/p:package/p:contents/p:dir');
 81:         if ($contents && !empty($this->_options['regenerate'])) {
 82:             $contents = $this->_xml->findNode('/p:package/p:contents');
 83:             $this->_xml->removeWhitespace($contents->previousSibling);
 84:             $this->_xml->findNode('/p:package')->removeChild($contents);
 85:             $contents = false;
 86:         }
 87: 
 88:         $filelist = $this->_xml->findNode('/p:package/p:phprelease/p:filelist');
 89:         if ($filelist && !empty($this->_options['regenerate'])) {
 90:             $filelist = $this->_xml->findNode('/p:package/p:phprelease');
 91:             $this->_xml->removeWhitespace($filelist->previousSibling);
 92:             $this->_xml->findNode('/p:package')->removeChild($filelist);
 93:             $filelist = false;
 94:         }
 95: 
 96:         if (!$contents) {
 97:             $root = $this->_xml->insert(
 98:                 array(
 99:                     'contents' => array(),
100:                     "\n ",
101:                 ),
102:                 $this->_xml->findNode('/p:package/p:dependencies')
103:             );
104:             $contents = $this->_xml->append(
105:                 array(
106:                     "\n  ",
107:                     'dir' => array('baseinstalldir' => '/', 'name' => '/'),
108:                     ' ',
109:                     $this->_xml->createComment(' / '),
110:                     "\n ",
111:                 ),
112:                 $root
113:             );
114:             $this->_xml->append("\n  ", $contents);
115:         }
116: 
117:         if (!$filelist) {
118:             $root = $this->_xml->insert(
119:                 array(
120:                     'phprelease' => array(),
121:                     "\n ",
122:                 ),
123:                 $this->_xml->findNode('/p:package/p:changelog')
124:             );
125: 
126:             $filelist = $this->_xml->append(
127:                 array(
128:                     "\n  ",
129:                     'filelist' => array(),
130:                     "\n ",
131:                 ),
132:                 $root
133:             );
134:             $this->_xml->append("\n  ", $filelist);
135:         }
136: 
137:         $current = $this->_xml->createContents($this->_xml, $contents, $filelist);
138:         $current->update($this->_content);
139:         try {
140:             if (empty($this->_options['no_timestamp'])) {
141:                 $this->_xml->timestamp();
142:             }
143:             $this->_xml->syncCurrentVersion();
144:         } catch (Horde_Pear_Exception $e) {
145:             /**
146:              * Ignore errors in this operation as it is not mandatory for
147:              * updating the file list.
148:              */
149:         }
150:     }
151: 
152: }
API documentation generated by ApiGen