Example #1
0
 /**
  * Update package.xml file.
  *
  * @param string                 $log     The log entry.
  * @param Horde_Pear_Package_Xml $xml     The package xml handler.
  * @param string                 $file    Path to the package.xml.
  * @param array                  $options Additional options.
  *
  * @return NULL
  */
 public function packageXml($log, $xml, $file, $options)
 {
     if (file_exists($file)) {
         if (empty($options['pretend'])) {
             $xml->addNote($log);
             file_put_contents($file, (string) $xml);
             $this->_output->ok('Added new note to version ' . $xml->getVersion() . ' of ' . $file . '.');
         } else {
             $this->_output->info(sprintf('Would add change log entry to %s now.', $file));
         }
         return $file;
     }
 }
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
 /**
  * Remove the directory entry from the XML.
  *
  * @return NULL
  */
 public function delete()
 {
     $dir = $this->getDirectoryNode();
     $this->_xml->removeWhitespace($dir->nextSibling);
     $this->_xml->removeComment($dir->nextSibling, $this->_path);
     $this->_xml->removeWhitespace($dir->nextSibling);
     $dir->parentNode->removeChild($dir);
 }
Example #4
0
 /**
  * Delete a file from the list.
  *
  * @param string $file The file name.
  *
  * @return NULL
  */
 public function delete($file)
 {
     $this->_dir_list->deleteFile($file);
     if (isset($this->_install_list[$file])) {
         $this->_xml->removeWhitespace($this->_install_list[$file]->nextSibling);
         $this->_filelist->removeChild($this->_install_list[$file]);
     }
 }
Example #5
0
 /**
  * Execute the task.
  *
  * @return NULL
  */
 public function run()
 {
     $contents = $this->_xml->findNode('/p:package/p:contents/p:dir');
     if ($contents && !empty($this->_options['regenerate'])) {
         $contents = $this->_xml->findNode('/p:package/p:contents');
         $this->_xml->removeWhitespace($contents->previousSibling);
         $this->_xml->findNode('/p:package')->removeChild($contents);
         $contents = false;
     }
     $filelist = $this->_xml->findNode('/p:package/p:phprelease/p:filelist');
     if ($filelist && !empty($this->_options['regenerate'])) {
         $filelist = $this->_xml->findNode('/p:package/p:phprelease');
         $this->_xml->removeWhitespace($filelist->previousSibling);
         $this->_xml->findNode('/p:package')->removeChild($filelist);
         $filelist = false;
     }
     if (!$contents) {
         $root = $this->_xml->insert(array('contents' => array(), "\n "), $this->_xml->findNode('/p:package/p:dependencies'));
         $contents = $this->_xml->append(array("\n  ", 'dir' => array('baseinstalldir' => '/', 'name' => '/'), ' ', $this->_xml->createComment(' / '), "\n "), $root);
         $this->_xml->append("\n  ", $contents);
     }
     if (!$filelist) {
         $root = $this->_xml->insert(array('phprelease' => array(), "\n "), $this->_xml->findNode('/p:package/p:changelog'));
         $filelist = $this->_xml->append(array("\n  ", 'filelist' => array(), "\n "), $root);
         $this->_xml->append("\n  ", $filelist);
     }
     $current = $this->_xml->createContents($this->_xml, $contents, $filelist);
     $current->update($this->_content);
     try {
         if (empty($this->_options['no_timestamp'])) {
             $this->_xml->timestamp();
         }
         $this->_xml->syncCurrentVersion();
     } catch (Horde_Pear_Exception $e) {
         /**
          * Ignore errors in this operation as it is not mandatory for
          * updating the file list.
          */
     }
 }
Example #6
0
 private function _getUpdatedContents($package)
 {
     $xml = new Horde_Pear_Package_Xml(fopen($package . '/package.xml', 'r'));
     $xml->updateContents(new Horde_Pear_Package_Contents_List(new Horde_Pear_Package_Type_Horde($package)));
     return $xml;
 }