getPutPostBodyDescription

@param bool $isCreating

@return string
198678
private function getPutPostBodyDescription($isCreating) {
        $description = ucfirst($this->getModel()->getSource()) . ' Data.';
        if($isCreating) {
            $description .= "\n" . 'Only pass in the fields you wish to update.';
        }
        $description .= $this->getPutPostBodyDescriptionReadyOnlyFields($isCreating);
        $description .= $this->getPutPostBodyDescriptionFiles($isCreating);
        return $description;
    }
356213
public function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        $contentObjectAttributeID = $contentObjectAttribute->attribute( 'id' );

        if ( !$http->hasPostVariable( $base . '_eztags_data_text_' . $contentObjectAttributeID ) )
            return false;

        if ( !$http->hasPostVariable( $base . '_eztags_data_text2_' . $contentObjectAttributeID ) )
            return false;

        if ( !$http->hasPostVariable( $base . '_eztags_data_text3_' . $contentObjectAttributeID ) )
            return false;

        if ( !$http->hasPostVariable( $base . '_eztags_data_text4_' . $contentObjectAttributeID ) )
            return false;

        $keywordString = trim( $http->postVariable( $base . '_eztags_data_text_' . $contentObjectAttributeID ) );
        $parentString = trim( $http->postVariable( $base . '_eztags_data_text2_' . $contentObjectAttributeID ) );
        $idString = trim( $http->postVariable( $base . '_eztags_data_text3_' . $contentObjectAttributeID ) );
        $localeString = trim( $http->postVariable( $base . '_eztags_data_text4_' . $contentObjectAttributeID ) );

        $eZTags = eZTags::createFromStrings( $contentObjectAttribute, $idString, $keywordString, $parentString, $localeString );
        $contentObjectAttribute->setContent( $eZTags );

        return true;
    }
655485
public function getCreatedBy()
    {
        $createdByAttribute = $this->createdByAttribute;
        return (!is_string($createdByAttribute) || empty($createdByAttribute)) ? null : $this->$createdByAttribute->getData();
    }
1272995
private function parsePut()
    {
        $contentType = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : 'application/x-www-form-urlencoded';

        $tmp = explode(';', $contentType);
        $boundary = '';
        $encoding = '';

        $contentType = array_shift($tmp);

        foreach ($tmp as $t) {
            if (strpos($t, 'boundary') !== false) {
                $t = explode('=', $t, 2);
                if (isset($t[1])) {
                    $boundary = '--' . $t[1];
                }
            } elseif (strpos($t, 'charset') !== false) {
                $t = explode('=', $t, 2);
                if (isset($t[1])) {
                    $encoding = $t[1];
                }
            }
            if ($boundary !== '' && $encoding !== '') {
                break;
            }
        }

        switch ($contentType) {
            case 'multipart/form-data':
                #grab multipart boundary from content type header
                if (!empty($boundary)) {
                    break;
                }
                $contentType = 'application/x-www-form-urlencoded';
            // Fallthrough intentional - no boundary supplied with multipart content-type, so treat as url encoded
            case 'application/x-www-form-urlencoded':
                parse_str(file_get_contents($this->unitTestRequestFile ?: 'php://input'), $_POST);
                return;
            default:
                return;
        }

        $_FILES = [];
        $_POST = [];
        $chunkLength = 8096;
        $raw_headers = '';

        $stream = fopen($this->unitTestRequestFile ?: 'php://input', 'rb');

        $sanity = fgets($stream, strlen($boundary) + 5);

        // Skip initial blank line
        if ($sanity == "\r\n") {
            $sanity = fgets($stream, strlen($boundary) + 5);
        }

        if (rtrim($sanity) !== $boundary) {
            #malformed file, boundary should be first item
            return;
        }

        while (($chunk = fgets($stream)) !== false) {
            if ($chunk === $boundary) {
                continue;
            }

            if (rtrim($chunk) == '') { #blank line means we have all the headers and are going to read content
                $raw_headers = explode("\r\n", $raw_headers);
                $headers = [];
                $matches = [];

                foreach ($raw_headers as $header) {
                    if (strpos($header, ':') === false) {
                        continue;
                    }
                    list($name, $value) = explode(':', $header, 2);
                    $headers[strtolower($name)] = ltrim($value, ' ');
                }

                $raw_headers = '';

                if (!isset($headers['content-disposition'])) {
                    continue;
                }

                $filename = null;
                preg_match(
                    '/^(.+); *name="([^"]+)"(; *filename="([^"]+)")?/',
                    $headers['content-disposition'],
                    $matches
                );
                list(, $type, $name) = $matches;

                #process data
                if (isset($matches[4])) { #pull in file
                    $error = UPLOAD_ERR_OK;

                    $filename = $matches[4];
                    $filename_parts = pathinfo($filename);
                    $contentType = 'unknown';

                    if (isset($headers['content-type'])) {
                        $tmp = explode(';', $headers['content-type']);
                        $contentType = $tmp[0];
                    }

                    $tmpnam = tempnam(ini_get('upload_tmp_dir'), 'php');
                    $fileHandle = fopen($tmpnam, 'wb');


                    if ($fileHandle === false) {
                        $error = UPLOAD_ERR_CANT_WRITE;
                    } else {
                        $lastLine = null;
                        while (($chunk = fgets($stream, $chunkLength)) !== false && strpos($chunk, $boundary) !== 0) {
                            if ($lastLine !== null) {
                                if (fwrite($fileHandle, $lastLine) === false) {
                                    $error = UPLOAD_ERR_CANT_WRITE;
                                    break;
                                }
                            }
                            $lastLine = $chunk;
                        }

                        if ($lastLine !== null && $error !== UPLOAD_ERR_CANT_WRITE) {
                            if (fwrite($fileHandle, rtrim($lastLine, "\r\n")) === false) {
                                $error = UPLOAD_ERR_CANT_WRITE;
                            }
                        }
                    }

                    $_FILES[$name] = [
                        'name' => $filename,
                        'type' => $contentType,
                        'tmp_name' => $tmpnam,
                        'error' => $error,
                        'size' => filesize($tmpnam)
                    ];

                    continue;
                } else { #pull in variable
                    $fullValue = '';
                    $lastLine = null;
                    while (($chunk = fgets($stream)) !== false && strpos($chunk, $boundary) !== 0) {
                        if ($lastLine !== null) {
                            $fullValue .= $lastLine;
                        }

                        $lastLine = $chunk;
                    }

                    if ($lastLine !== null) {
                        $fullValue .= rtrim($lastLine, "\r\n");
                    }

                    if (isset($headers['content-type'])) {
                        $tmp = explode(';', $headers['content-type']);
                        $encoding = '';

                        foreach ($tmp as $t) {
                            if (strpos($t, 'charset') !== false) {
                                $t = explode($t, '=', 2);
                                if (isset($t[1])) {
                                    $encoding = $t[1];
                                }
                                break;
                            }
                        }

                        if ($encoding !== '' && strtoupper($encoding) !== 'UTF-8' && strtoupper($encoding) !== 'UTF8') {
                            $tmp = mb_convert_encoding($fullValue, 'UTF-8', $encoding);
                            if ($tmp !== false) {
                                $fullValue = $tmp;
                            }
                        }

                    }

                    $fullValue = $name . '=' . $fullValue;
                    $origName = $name;
                    $tmp = [];
                    parse_str($fullValue, $tmp);
                    $_POST = $this->recursiveSetter($origName, $_POST, $tmp);
                }
                continue;
            }

            $raw_headers .= $chunk;
        }

        $GLOBALS['_PUT'] = $_POST;
        fclose($stream);
    }
271237
protected function _get_description( $post = null ) {
		$post = get_post( $post );

		if ( ! $post ) {
			return;
		}

		$description = $this->_strip_linebreaks( wp_strip_all_tags( strip_shortcodes( $post->post_excerpt ) ) );
		if ( $description ) {
			return $description;
		}

		$description = $this->_strip_linebreaks( wp_trim_words( wp_strip_all_tags( strip_shortcodes( $post->post_content ) ) ) );
		if ( $description ) {
			return $description;
		}
	}
254334
private function _parseRichText($is = null) 
    {
        $value = array();

        if (isset($is->t)) {
            $value[] = (string)$is->t;
        } else {
            foreach ($is->r as $run) {
                $value[] = (string)$run->t;
            }
        }

        return implode('', $value);
    }
879757
public function getBody()
    {
        $body = '';
        if ($this->_method === 'POST' || $this->_method === 'PUT') {
            if ($this->_body === null) {
                $this->_body = $this->getPostBody();
            }
            $this->setHeader('content-length', strlen($this->_body));
            $body = $this->_body . Client::CRLF;
        }
        return $body;
    }
1135513
private function lookUpAutomaticFields(ApiInterface $entity, $isCreating) {
        if($isCreating) {
            $automaticAttributes = $entity->getModelsMetaData()->getAutomaticCreateAttributes($entity);
        } else {
            $automaticAttributes = $entity->getModelsMetaData()->getAutomaticUpdateAttributes($entity);
        }
        $columnMap = $entity->getModelsMetaData()->getColumnMap($entity);
        $automaticFields = array_fill_keys($entity->getAutomaticallyUpdatedFields(), null);
        foreach($automaticAttributes as $fullName => $null) {
            $automaticFields[$columnMap[$fullName]] = null;
        }
        return $automaticFields;
    }
102770
public function getRawBody(): string
	{
		if($this->rawBody === null)
		{
			$this->rawBody = file_get_contents('php://input');
		}

		return $this->rawBody;
	}
917622
public function getFieldBody() //TODO: Check caching here
    {
        $body = parent::getFieldBody();
        foreach ($this->params as $name => $value) {
            if (null !== $value) {
                // Add the parameter
                $body .= '; '.$this->createParameter($name, $value);
            }
        }

        return $body;
    }
1091618
function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        $enabledName = $base . '_ezcomcomments_enabled_' . $contentObjectAttribute->attribute( 'id' );
        $shownName = $base . '_ezcomcomments_shown_' . $contentObjectAttribute->attribute( 'id' );
        $enabledValue = -1;
        $shownValue = -1;
        if ( $http->hasPostVariable( $enabledName ) )
        {
            $enabledValue = 1;
        }
        if ( $http->hasPostVariable( $shownName ) )
        {
            $shownValue = 1;
        }
        $contentObjectAttribute->setAttribute( 'data_float', $shownValue );
        $contentObjectAttribute->setAttribute( 'data_int', $enabledValue );
        return true;
    }
647024
static public function getPostInputInfo()
    {
        if ($input = file_get_contents('php://input')) {
            if (strpos(trim($input), '{') === 0 || strpos(trim($input), '[') === 0) {
                $posts = json_decode($input, true);
            } elseif (strpos(trim($input), '<') === 0) {
                $posts = XmlFormatter::decodeElement($input, false);
            } else {
                parse_str($input, $posts);
            }
            
            return [$input, $posts];
        }
        return [];
    }
534783
function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        if ( $http->hasPostVariable( $base . '_ezkeyword_data_text_' . $contentObjectAttribute->attribute( 'id' ) ) )
        {
            $data = $http->postVariable( $base . '_ezkeyword_data_text_' . $contentObjectAttribute->attribute( 'id' ) );
            $keyword = new eZKeyword();
            $keyword->initializeKeyword( $data );
            $contentObjectAttribute->setContent( $keyword );
            return true;
        }
        return false;
    }
222433
public function handlePartBody($mailbox, $id, $is_uid=false, $part='', $encoding=null, $print=null, $file=null, $formatted=false, $max_bytes=0)
    {
        if (!$this->select($mailbox)) {
            return false;
        }

        $binary = true;

        do {
            if (!$initiated) {
                switch ($encoding) {
                case 'base64':
                    $mode = 1;
                    break;
                case 'quoted-printable':
                    $mode = 2;
                    break;
                case 'x-uuencode':
                case 'x-uue':
                case 'uue':
                case 'uuencode':
                    $mode = 3;
                    break;
                default:
                    $mode = 0;
                }

                // Use BINARY extension when possible (and safe)
                $binary     = $binary && $mode && preg_match('/^[0-9.]+$/', $part) && $this->hasCapability('BINARY');
                $fetch_mode = $binary ? 'BINARY' : 'BODY';
                $partial    = $max_bytes ? sprintf('<0.%d>', $max_bytes) : '';

                // format request
                $key       = $this->nextTag();
                $cmd       = ($is_uid ? 'UID ' : '') . 'FETCH';
                $request   = "$key $cmd $id ($fetch_mode.PEEK[$part]$partial)";
                $result    = false;
                $found     = false;
                $initiated = true;

                // send request
                if (!$this->putLine($request)) {
                    $this->setError(self::ERROR_COMMAND, "Failed to send $cmd command");
                    return false;
                }

                if ($binary) {
                    // WARNING: Use $formatted argument with care, this may break binary data stream
                    $mode = -1;
                }
            }

            $line = trim($this->readLine(1024));

            if (!$line) {
                break;
            }

            // handle UNKNOWN-CTE response - RFC 3516, try again with standard BODY request
            if ($binary && !$found && preg_match('/^' . $key . ' NO \[(UNKNOWN-CTE|PARSE)\]/i', $line)) {
                $binary = $initiated = false;
                continue;
            }

            // skip irrelevant untagged responses (we have a result already)
            if ($found || !preg_match('/^\* ([0-9]+) FETCH (.*)$/', $line, $m)) {
                continue;
            }

            $line = $m[2];

            // handle one line response
            if ($line[0] == '(' && substr($line, -1) == ')') {
                // tokenize content inside brackets
                // the content can be e.g.: (UID 9844 BODY[2.4] NIL)
                $tokens = $this->tokenizeResponse(preg_replace('/(^\(|\)$)/', '', $line));

                for ($i=0; $i<count($tokens); $i+=2) {
                    if (preg_match('/^(BODY|BINARY)/i', $tokens[$i])) {
                        $result = $tokens[$i+1];
                        $found  = true;
                        break;
                    }
                }

                if ($result !== false) {
                    if ($mode == 1) {
                        $result = base64_decode($result);
                    }
                    else if ($mode == 2) {
                        $result = quoted_printable_decode($result);
                    }
                    else if ($mode == 3) {
                        $result = convert_uudecode($result);
                    }
                }
            }
            // response with string literal
            else if (preg_match('/\{([0-9]+)\}$/', $line, $m)) {
                $bytes = (int) $m[1];
                $prev  = '';
                $found = true;

                // empty body
                if (!$bytes) {
                    $result = '';
                }
                else while ($bytes > 0) {
                    $line = $this->readLine(8192);

                    if ($line === null) {
                        break;
                    }

                    $len = strlen($line);

                    if ($len > $bytes) {
                        $line = substr($line, 0, $bytes);
                        $len  = strlen($line);
                    }
                    $bytes -= $len;

                    // BASE64
                    if ($mode == 1) {
                        $line = preg_replace('|[^a-zA-Z0-9+=/]|', '', $line);
                        // create chunks with proper length for base64 decoding
                        $line = $prev.$line;
                        $length = strlen($line);
                        if ($length % 4) {
                            $length = floor($length / 4) * 4;
                            $prev = substr($line, $length);
                            $line = substr($line, 0, $length);
                        }
                        else {
                            $prev = '';
                        }
                        $line = base64_decode($line);
                    }
                    // QUOTED-PRINTABLE
                    else if ($mode == 2) {
                        $line = rtrim($line, "\t\r\0\x0B");
                        $line = quoted_printable_decode($line);
                    }
                    // UUENCODE
                    else if ($mode == 3) {
                        $line = rtrim($line, "\t\r\n\0\x0B");
                        if ($line == 'end' || preg_match('/^begin\s+[0-7]+\s+.+$/', $line)) {
                            continue;
                        }
                        $line = convert_uudecode($line);
                    }
                    // default
                    else if ($formatted) {
                        $line = rtrim($line, "\t\r\n\0\x0B") . "\n";
                    }

                    if ($file) {
                        if (fwrite($file, $line) === false) {
                            break;
                        }
                    }
                    else if ($print) {
                        echo $line;
                    }
                    else {
                        $result .= $line;
                    }
                }
            }
        }
        while (!$this->startsWith($line, $key, true) || !$initiated);

        if ($result !== false) {
            if ($file) {
                return fwrite($file, $result);
            }
            else if ($print) {
                echo $result;
                return true;
            }

            return $result;
        }

        return false;
    }
824449
protected function getObjectFromPost()
    {
        $oInput = Factory::service('Input');
        $oUri   = Factory::service('Uri');
        $aData  = [
            'ref'             => $oInput->post('ref') ?: null,
            'state'           => $oInput->post('state') ?: null,
            'dated'           => $oInput->post('dated') ?: null,
            'currency'        => $oInput->post('currency') ?: null,
            'terms'           => (int) $oInput->post('terms') ?: 0,
            'customer_id'     => (int) $oInput->post('customer_id') ?: null,
            'additional_text' => $oInput->post('additional_text') ?: null,
            'items'           => [],
            'currency'        => $oInput->post('currency'),
        ];

        if ($oInput->post('items')) {
            foreach ($oInput->post('items') as $aItem) {

                //  @todo convert to pence using a model
                $aData['items'][] = [
                    'id'        => array_key_exists('id', $aItem) ? $aItem['id'] : null,
                    'quantity'  => array_key_exists('quantity', $aItem) ? $aItem['quantity'] : null,
                    'unit'      => array_key_exists('unit', $aItem) ? $aItem['unit'] : null,
                    'label'     => array_key_exists('label', $aItem) ? $aItem['label'] : null,
                    'body'      => array_key_exists('body', $aItem) ? $aItem['body'] : null,
                    'unit_cost' => array_key_exists('unit_cost', $aItem) ? intval($aItem['unit_cost'] * 100) : null,
                    'tax_id'    => array_key_exists('tax_id', $aItem) ? $aItem['tax_id'] : null,
                ];
            }
        }

        if ($oUri->rsegment(5) == 'edit') {
            unset($aData['ref']);
        }

        return $aData;
    }
128944
public function body($fromEncoding = null, $toEncoding = 'UTF-8')
    {
        if(null === $fromEncoding)
        {
            return (string)$this->getBody();
        }
        else
        {
            return mb_convert_encoding((string)$this->getBody(), $toEncoding, $fromEncoding);
        }
    }
702979
protected function buildPostBody($js, $returnErrors = false)
    {
        return http_build_query(
            array_merge(
                self::$DEFAULT_OPTIONS,
                $this->additionalOptions,
                array(
                    'js_code' => $js,
                    'output_info' => ($returnErrors ? 'errors' : 'compiled_code')
                )
            ),
            null,
            '&'
        );
    }