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:  * Handles a XML file node in the contents list.
  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:  * Handles a XML file node in the contents list.
 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_Xml_Element_File
 29: {
 30:     /**
 31:      * The package.xml handler to operate on.
 32:      *
 33:      * @var Horde_Pear_Package_Xml
 34:      */
 35:     private $_xml;
 36: 
 37:     /**
 38:      * The parent directory
 39:      *
 40:      * @var Horde_Pear_Package_Xml_Element_Directory
 41:      */
 42:     private $_parent;
 43: 
 44:     /**
 45:      * The file node.
 46:      *
 47:      * @var DOMNode
 48:      */
 49:     private $_file;
 50: 
 51:     /**
 52:      * The name of this file.
 53:      *
 54:      * @var string
 55:      */
 56:     private $_name;
 57: 
 58:     /**
 59:      * The role of this file.
 60:      *
 61:      * @var string
 62:      */
 63:     private $_role;
 64: 
 65:     /**
 66:      * The level in the tree.
 67:      *
 68:      * @var int
 69:      */
 70:     private $_level;
 71: 
 72:     /**
 73:      * Constructor.
 74:      *
 75:      * @param string                                   $name   The name of
 76:      *                                                         the directory.
 77:      * @param Horde_Pear_Package_Xml_Element_Directory $parent The parent
 78:      *                                                         directory.
 79:      * @param string                                   $role   The file role.
 80:      */
 81:     public function __construct($name, $parent, $role = null)
 82:     {
 83:         $this->_name = $name;
 84:         $this->_role = $role;
 85:         $this->_parent = $parent;
 86:         $this->_xml = $parent->getDocument();
 87:         $this->_level = $parent->getLevel() + 1;
 88:     }
 89: 
 90:     /**
 91:      * Set the DOM node of the file entry.
 92:      *
 93:      * @param DOMNode $directory The file node.
 94:      *
 95:      * @return NULL
 96:      */
 97:     public function setFileNode(DOMNode $file)
 98:     {
 99:         $this->_file = $file;
100:     }
101: 
102:     /**
103:      * Get the DOM node of the file entry.
104:      *
105:      * @return DOMNode The file node.
106:      */
107:     public function getFileNode()
108:     {
109:         if ($this->_file === null) {
110:             throw new Horde_Pear_Exception('The file node has been left undefined!');
111:         }
112:         return $this->_file;
113:     }
114: 
115:     /**
116:      * Insert the file entry into the XML at the given point.
117:      *
118:      * @param DOMNode $point Insertion point.
119:      *
120:      * @return NULL
121:      */
122:     public function insert(DOMNode $point = null)
123:     {
124:         if ($point === null) {
125:             $point = $this->_parent->getDirectoryNode()->lastChild;
126:         } else {
127:             if ($point->previousSibling) {
128:                 $ws = trim($point->previousSibling->textContent);
129:                 if (empty($ws)) {
130:                     $point = $point->previousSibling;
131:                 }
132:             }
133:         }
134: 
135:         $this->setFileNode(
136:             $this->_xml->insert(
137:                 array(
138:                     "\n " . str_repeat(" ", $this->_level),
139:                     'file' => array(
140:                         'name' => $this->_name, 'role' => $this->_role
141:                     ),
142:                 ),
143:                 $point
144:             )
145:         );
146:     }
147: 
148:     /**
149:      * Remove the file entry from the XML.
150:      *
151:      * @return NULL
152:      */
153:     public function delete()
154:     {
155:         $file = $this->getFileNode();
156:         $dir = $this->_parent->getDirectoryNode();
157:         $this->_xml->removeWhitespace($file->previousSibling);
158:         $dir->removeChild($file);
159:     }
160: }
API documentation generated by ApiGen