Copyright 2011-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Gunnar Wrobel (wrobel@pardus.de)
Example #1
0
 private function _getList($package)
 {
     $xml = new Horde_Pear_Package_Xml(fopen($package . '/package.xml', 'r'));
     $element = new Horde_Pear_Package_Xml_Element_Directory('/');
     $element->setDocument($xml);
     $element->setDirectoryNode($xml->findNode('/p:package/p:contents/p:dir'));
     return new Horde_Pear_Package_Xml_Directory($element, $xml);
 }
Example #2
0
 /**
  * Remove the file entry from the XML.
  *
  * @return NULL
  */
 public function delete()
 {
     $file = $this->getFileNode();
     $dir = $this->_parent->getDirectoryNode();
     $this->_xml->removeWhitespace($file->previousSibling);
     $dir->removeChild($file);
 }
Example #3
0
 /**
  * Ensure the provided path hierarchy.
  *
  * @param array $tree The path elements that are required.
  *
  * @return DOMNode The parent directory for the file.
  */
 public function getParent($tree)
 {
     $next = array_shift($tree);
     while ($next === '') {
         $next = array_shift($tree);
     }
     if (empty($tree) && !strlen($next)) {
         return $this;
     }
     if (!isset($this->_subdirectories[$next])) {
         $this->_subdirectories[$next] = $this->_create($this->_element->insertSubDirectory($next, $this->_getDirectoryInsertionPoint($next)), $this);
     }
     return $this->_subdirectories[$next]->getParent($tree);
 }
Example #4
0
 /**
  * Insert the directory entry into the XML at the given point.
  *
  * @param Horde_Pear_Package_Xml_Element_Directory $parent The parent.
  * @param DOMNode                                  $point  Insertion point.
  *
  * @return NULL
  */
 private function _insert(Horde_Pear_Package_Xml_Element_Directory $parent, DOMNode $point = null)
 {
     if ($point === null) {
         $point = $parent->getDirectoryNode()->lastChild;
     } else {
         if ($point->previousSibling) {
             $ws = trim($point->previousSibling->textContent);
             if (empty($ws)) {
                 $point = $point->previousSibling;
             }
         }
     }
     $dir = $this->_xml->insert(array("\n " . str_repeat(" ", $this->_level), 'dir' => array('name' => $this->_name), ' ', $this->_xml->createComment(' ' . $this->_path . ' ')), $point);
     $this->_xml->append("\n" . str_repeat(' ', $this->_level + 1), $dir);
     $this->setDirectoryNode($dir);
 }