Esempio n. 1
0
 /**
  * Return an XML document based on the package info (as returned
  * by the PEAR_Common::infoFrom* methods).
  *
  * @return string XML data
  */
 function toXml($state = PEAR_VALIDATE_NORMAL, $options = array())
 {
     $this->_packagefile->setDate(date('Y-m-d'));
     $this->_packagefile->setTime(date('H:i:s'));
     if (!$this->_packagefile->validate($state)) {
         return false;
     }
     if (is_array($options)) {
         $this->options = array_merge($this->_defaultOptions, $options);
     } else {
         $this->options = $this->_defaultOptions;
     }
     $arr = $this->_packagefile->getArray();
     if (isset($arr['filelist'])) {
         unset($arr['filelist']);
     }
     if (isset($arr['_lastversion'])) {
         unset($arr['_lastversion']);
     }
     // Fix the notes a little bit
     if (isset($arr['notes'])) {
         // This trims out the indenting, needs fixing
         $arr['notes'] = "\n" . trim($arr['notes']) . "\n";
     }
     if (isset($arr['changelog']) && !empty($arr['changelog'])) {
         // Fix for inconsistency how the array is filled depending on the changelog release amount
         if (!isset($arr['changelog']['release'][0])) {
             $release = $arr['changelog']['release'];
             unset($arr['changelog']['release']);
             $arr['changelog']['release'] = array();
             $arr['changelog']['release'][0] = $release;
         }
         foreach (array_keys($arr['changelog']['release']) as $key) {
             $c =& $arr['changelog']['release'][$key];
             if (isset($c['notes'])) {
                 // This trims out the indenting, needs fixing
                 $c['notes'] = "\n" . trim($c['notes']) . "\n";
             }
         }
     }
     if ($state ^ PEAR_VALIDATE_PACKAGING && !isset($arr['bundle'])) {
         $use = $this->_recursiveXmlFilelist($arr['contents']['dir']['file']);
         unset($arr['contents']['dir']['file']);
         if (isset($use['dir'])) {
             $arr['contents']['dir']['dir'] = $use['dir'];
         }
         if (isset($use['file'])) {
             $arr['contents']['dir']['file'] = $use['file'];
         }
         $this->options['beautifyFilelist'] = true;
     }
     $arr['attribs']['packagerversion'] = '@PEAR-VER@';
     if ($this->serialize($arr, $options)) {
         return $this->_serializedData . "\n";
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Return an XML document based on the package info (as returned
  * by the PEAR_Common::infoFrom* methods).
  *
  * @return string XML data
  */
 function toXml($state = PEAR_VALIDATE_NORMAL, $options = array())
 {
     $this->_packagefile->setDate(date('Y-m-d'));
     $this->_packagefile->setTime(date('H:i:s'));
     if (!$this->_packagefile->validate($state)) {
         return false;
     }
     if (is_array($options)) {
         $this->options = array_merge($this->_defaultOptions, $options);
     } else {
         $this->options = $this->_defaultOptions;
     }
     $arr = $this->_packagefile->getArray();
     if (isset($arr['filelist'])) {
         unset($arr['filelist']);
     }
     if (isset($arr['_lastversion'])) {
         unset($arr['_lastversion']);
     }
     if ($state ^ PEAR_VALIDATE_PACKAGING && !isset($arr['bundle'])) {
         $use = $this->_recursiveXmlFilelist($arr['contents']['dir']['file']);
         unset($arr['contents']['dir']['file']);
         if (isset($use['dir'])) {
             $arr['contents']['dir']['dir'] = $use['dir'];
         }
         if (isset($use['file'])) {
             $arr['contents']['dir']['file'] = $use['file'];
         }
         $this->options['beautifyFilelist'] = true;
     }
     $arr['attribs']['packagerversion'] = '1.4.2';
     if ($this->serialize($arr, $options)) {
         return $this->_serializedData . "\n";
     }
     return false;
 }