Adds $part to the list of parts and returns the Content-ID of the part.

@param ezcMailPart $part
@return string
508070
public function addRelatedPart( ezcMailPart $part  )
    {
        // it doesn't have a Content-ID, we must set one.
        $contentId = '';
        if ( $part->getHeader( 'Content-ID' ) == '' )
        {
            if ( $part instanceof ezcMailFile )
            {
                $part->contentId = ezcMailTools::generateContentId( basename( $part->fileName ) );
            }
            else
            {
                $part->setHeader( 'Content-ID', ezcMailTools::generateContentId( 'part' ) );
            }
        }
        $contentId = trim( $part->getHeader( 'Content-ID' ), '<>' );

        // Set the content ID property of the ezcMailFile if one was found
        if ( $part instanceof ezcMailFile )
        {
            $part->contentId = $contentId;
        }

        if ( count( $this->parts ) > 0 )
        {
            $this->parts[] = $part;
        }
        else
        {
            $this->parts[1] = $part;
        }
        return $contentId;
    }
1227834
private function encodePart($part)
    {
        if (strpos($part, '?') !== false) {
            if (strpos($part, '?') === 0) {
                $output = '?';
                $part = substr($part, 1);
            } else {
                $pe = explode('?', $part);
                $output = $pe[0].'/?';
                $part = $pe[1];
                unset($pe);
            }

            if (strpos($part, '&')) {
                $parts = explode('&', $part);
            } else {
                $parts = [$part];
            }
            foreach ($parts as &$p) {
                if (strpos($p, '=') !== false) {
                    $pe = explode('=', $p);
                    $p = $pe[0].'='.urlencode($pe[1]);
                }
            }
            unset($p, $pe);

            $output .= implode('&', $parts);

            return $output;
        }

        if (strpos($part, '#') !== false) {
            if (strpos($part, '#') === 0) {
                if (substr($part, 1, 1) === '!') {
                    return '#!'.rawurlencode(substr($part, 2));
                }

                return '#'.rawurlencode(substr($part, 1));
            }

            $pe = explode('#', $part);
            if (substr($pe[1], 0, 1) === '!') {
                return $pe[0].'/#!'.rawurlencode(substr($pe[1], 1));
            }

            return $pe[0].'/#'.rawurlencode($pe[1]);
        }

        return rawurlencode($part);
    }
271080
protected function _generateSearchText(...$contentParts)
    {
        $searchText = '';
        foreach ($contentParts as $contentPart) {
            $contentPart = trim((string) $contentPart);
            if ($contentPart !== '') {
                $searchText .= $contentPart . ' ';
            }
        }
        $searchText = trim(strip_tags($searchText));
        return ($searchText !== '') ? $searchText : null;
    }
1247173
public static function preparePart($part, $firstLower = false)
    {
        $result = str_replace(' ', '', ucwords(str_replace('-', ' ', $part)));
        if ($firstLower && mb_strlen($result) > 0) {
            $result[0] = mb_strtolower($result[0]);
        }
        return $result;
    }
1022016
public function addQueryPart($queryPartName, $queryPart, $append = false)
	{
		$isMultiple = is_array($this->_queryParts[$queryPartName]);
		
		if ($append && $isMultiple) {
			if (is_array($queryPart)) {
				foreach ($queryPart as $key => $part) {
					if (is_numeric($key)) {
						$this->_queryParts[$queryPartName][] = $part;
					} else {
						$this->_queryParts[$queryPartName][$key] = $part;
					}
				}
			} else {
				$this->_queryParts[$queryPartName][] = $queryPart;
			}
		} else {
			$this->_queryParts[$queryPartName] = ($isMultiple && !is_array($queryPart)) ? [$queryPart] : $queryPart;
		}
		
		return $this;
	}
391694
public MultipartBuilder addPart(NetworkRequest part) {
        if (part == null) {
            throw new NullPointerException("part == null");
        }
        parts.add(part);
        return this;
    }
889059
public function url(...$parts)
    {
        $uri = implode('/', $parts);
        return (string)$this->request->uri->make($uri);
    }
1188947
protected function getPartHeaderFromText(&$part)
    {
        $start = $part['starting-pos'];
        $end = $part['starting-pos-body'];
        $header = substr($this->data, $start, $end - $start);
        return $header;
    }
88085
public function getPart($key)
    {
        foreach ($this->parts as $part) {
            if ($part->getKey() === $key) {
                return $part;
            }
        }
        
        return false;
    }
910588
private function get_mime_numbers(&$part)
    {
        if (strlen($part->mime_id))
            $this->mime_parts[$part->mime_id] = &$part;

        if (is_array($part->parts))
            for ($i=0; $i<count($part->parts); $i++)
                $this->get_mime_numbers($part->parts[$i]);
    }
308808
protected function getPartBodyFromText(&$part)
    {
        $start = $part['starting-pos-body'];
        $end = $part['ending-pos-body'];

        return substr($this->data, $start, $end - $start);
    }
1026742
public function getPart($num)
    {
        if (isset($this->_parts[$num])) {
            return $this->_parts[$num];
        }

        if (!$this->_mail && $this->_content === null) {
            /**
             * @see Zend_Mail_Exception
             */
            // require_once 'Zend/Mail/Exception.php';
            throw new Zend_Mail_Exception('part not found');
        }

        if ($this->_mail && $this->_mail->hasFetchPart) {
            // TODO: fetch part
            // return
        }

        $this->_cacheContent();

        if (!isset($this->_parts[$num])) {
            /**
             * @see Zend_Mail_Exception
             */
            // require_once 'Zend/Mail/Exception.php';
            throw new Zend_Mail_Exception('part not found');
        }

        return $this->_parts[$num];
    }
320874
protected function commitPart($part)
    {
        $commit_url = FilestackConfig::UPLOAD_URL . '/multipart/commit';
        $commit_data = $this->buildCommitData($part);

        $response = $this->sendRequest('POST', $commit_url,
                                       ['multipart' => $commit_data]);

        $status_code = $response->getStatusCode();
        if ($status_code !== 200) {
            throw new FilestackException($response->getBody(),
                $status_code);
        }
        return $status_code;
    }
677983
public function getPartHeaders($partnum, $EOL = Zend_Mime::LINEEND)
    {
        return $this->_parts[$partnum]->getHeaders($EOL);
    }
147351
protected function getAttachmentStream(&$part)
    {
        /** @var resource $temp_fp */
        $temp_fp = tmpfile();

        $headers = $this->getPart('headers', $part);
        $encodingType = array_key_exists('content-transfer-encoding', $headers) ?
            $headers['content-transfer-encoding'] : '';

        if ($temp_fp) {
            if ($this->stream) {
                $start = $part['starting-pos-body'];
                $end = $part['ending-pos-body'];
                fseek($this->stream, $start, SEEK_SET);
                $len = $end - $start;
                $written = 0;
                while ($written < $len) {
                    $write = $len;
                    $data = fread($this->stream, $write);
                    fwrite($temp_fp, $this->decodeContentTransfer($data, $encodingType));
                    $written += $write;
                }
            } elseif ($this->data) {
                $attachment = $this->decodeContentTransfer($this->getPartBodyFromText($part), $encodingType);
                fwrite($temp_fp, $attachment, strlen($attachment));
            }
            fseek($temp_fp, 0, SEEK_SET);
        } else {
            throw new Exception(
                'Could not create temporary files for attachments. Your tmp directory may be unwritable by PHP.'
            );
        }

        return $temp_fp;
    }
293755
public function removeContentHeadersAndContent(ParentHeaderPart $part)
    {
        foreach (self::$contentHeaders as $header) {
            $part->removeHeader($header);
        }
        $part->detachContentStream();
    }
162580
private function find_part_id($part_id, $data)
    {
        $ids   = explode('.', $part_id);
        $i     = 0;
        $count = count($ids);

        while ($i < $count && strlen($part = implode('.', array_slice($ids, 0, ++$i)))) {
            if (array_key_exists($part, $data)) {
                return $part;
            }
        }
    }