コード例 #1
0
 /**
  * Function that does the actual conversion to xml. Does a single
  * mimepart at a time.
  *
  * @param  object  Input to convert to xml. This is a mimepart object.
  *                 It may or may not contain subparts.
  * @param  integer Number of tabs to indent
  * @return string  XML version of input
  * @access private
  */
 function _getXML($input, $indent = 1)
 {
     $htab = "\t";
     $crlf = "\r\n";
     $output = '';
     $headers = @(array) $input->headers;
     foreach ($headers as $hdr_name => $hdr_value) {
         // Multiple headers with this name
         if (is_array($headers[$hdr_name])) {
             for ($i = 0; $i < count($hdr_value); $i++) {
                 $output .= mimeDecode::_getXML_helper($hdr_name, $hdr_value[$i], $indent);
             }
             // Only one header of this sort
         } else {
             $output .= mimeDecode::_getXML_helper($hdr_name, $hdr_value, $indent);
         }
     }
     if (!empty($input->parts)) {
         for ($i = 0; $i < count($input->parts); $i++) {
             $output .= $crlf . str_repeat($htab, $indent) . '<mimepart>' . $crlf . mimeDecode::_getXML($input->parts[$i], $indent + 1) . str_repeat($htab, $indent) . '</mimepart>' . $crlf;
         }
     } elseif (isset($input->body)) {
         $output .= $crlf . str_repeat($htab, $indent) . '<body><![CDATA[' . $input->body . ']]></body>' . $crlf;
     }
     return $output;
 }