Url::write()

@return
425017
public function write($write_flags = self::WRITE_FLAG_AS_IS)
    {
        $port = $this->getPort();
        $show_scheme = $this->scheme && (!($write_flags & self::WRITE_FLAG_OMIT_SCHEME));
        $url = ($show_scheme ? $this->scheme . ':' : '');
        $url .= '//';
        $url .= $this->host . ($port ? ':' . $port : '');
        $url .= ($this->path ? $this->path : '');
        $url .= ($this->query ? '?' . $this->query : '');
        $url .= ($this->fragment ? '#' . $this->fragment : '');
        return $url;
    }
3908
public function write()
    {
        foreach (config('squanto.locales', []) as $locale) {
            $this->writeLocale($locale, Line::getValuesByLocale($locale));
        }

        return $this;
    }
710971
public function writeAttempt()
    {
        $result = self::OK;

        if (empty($this->filepath)) {
            return self::ERROR;
        }

        /**
         * Open the file for writing only. If the file does not exist, it is created.
         * If it exists, it is not truncated (as opposed to 'w'). File pointer is moved to beginning.
         *
         * "c" is needed instead of "w", because if lock is not acquired, old version of the file is returned.
         * If "w" option is used, file is truncated no matter what, and empty file is returned.
         */
        $fp = fopen($this->filepath, 'c');

        if ($fp === false) {
            return self::ERROR_OPEN;
        }

        /**
         * File locking disabled?
         */
        if (empty($this->file_lock)) {
            ftruncate($fp, 0);
            if (fwrite($fp, $this->content) === false) {
                $result = self::ERROR_WRITE;
            }
            fclose($fp);

            return $result;
        }

        /**
         * File locking is enabled
         *
         * Try to acquire File Write Lock. If lock is not acquired read file and return old contents.
         *
         * Recommended is: LOCK_EX | LOCK_NB.
         * LOCK_EX to acquire an exclusive lock (writer).
         * LOCK_NB - prevents flock() from blocking while locking, so that others could still read
         * (but not write) while lock is active
         */
        if (flock($fp, $this->file_lock)) {
            /**
             * since "c" was used with fopen, file is not truncated. Truncate manually.
             */
            ftruncate($fp, 0);

            //write content
            if (fwrite($fp, $this->content) === false) {
                $result = self::ERROR_WRITE;
            }

            //release lock
            flock($fp, LOCK_UN);
        } else {
            /**
             * Lock was not granted.
             */

            $result = self::ERROR_LOCK;
        }

        fclose($fp);

        return $result;
    }
480466
public function fwrite(string $str, int $length = null)
    {
        $args = [$this->stream, $str];
        if (null !== $length) {
            $args[] = $length;
        }

        return fwrite(...$args);
    }
970600
public function write($data = null) {
		if (!is_resource($this->_resource)) {
			return false;
		}
		if (!is_object($data)) {
			$data = $this->_instance($this->_classes['request'], (array) $data + $this->_config);
		}
		return stream_context_set_option(
			$this->_resource, $data->to('context', ['timeout' => $this->_timeout])
		);
	}
131054
public function write(UrlSetInterface $urlSet, \XMLWriter $xmlWriter = null)
    {
        $xmlWriter = $xmlWriter ?: new \XMLWriter();

        $xmlWriter->openMemory();
        $xmlWriter->startDocument('1.0', 'UTF-8');

        $xmlWriter->startElement('urlset');

        $this->writeNamespaceAttributes($xmlWriter);
        $this->writeUrls($xmlWriter, $urlSet->urls());

        $xmlWriter->endElement();

        $xmlWriter->endDocument();

        return $xmlWriter->outputMemory();
    }
1090404
function write() {
		if (strlen($this->query)) {
			$this->query .= " ";
		}
		$this->query .= array_reduce(func_get_args(), array($this, "reduce"));
		return $this;
	}
1021796
public function write()
    {
        
        $tf = $this->getTranslationFile();
        $buffer = "<?php\n";
        foreach ($tf->getTranslationUnits() as $tu){
            // Prevent empty messages.
            if ($tu->getSource() != '' && $tu->getTarget() != ''){
                $escapes = array("\\", '$', '"', "\n", "\t", "\v", "\r", "\f");
                $replace = array("\\\\", '\\$', '\\"', "\\n", "\\t", "\\v", "\\r", "\\f");
                $source = str_replace($escapes, $replace, $tu->getSource());
                $target = str_replace($escapes, $replace, $tu->getTarget());
                $buffer .= '$GLOBALS[\'__l10n\']["' . $source . '"]="' . $target . '";' . "\n";
            }
        }
        $buffer .= "\n?>";
        
        file_put_contents($this->getFilePath(), $buffer);
        
    }
743478
function Write($h, $txt, $currentx = 0, $link = '', $directionality = 'ltr', $align = '', $fill = 0)
	{
		if (empty($this->directWrite)) {
			$this->directWrite = new DirectWrite($this, $this->otl, $this->sizeConverter, $this->colorConverter);
		}

		$this->directWrite->Write($h, $txt, $currentx, $link, $directionality, $align, $fill);
	}
363560
protected function _write($data) {
		if (!$this->connected && !$this->connect()) {
			return false;
		}

		$data .= "\r\n";
		return fwrite($this->_connection, $data, strlen($data));
	}
1222798
public function write()
	{
		// do we have something to write?
		if ( ! empty($this->keys) or ! empty($this->data) or ! empty($this->flash))
		{
			parent::write();

			// rotate the session id if needed
			$this->rotate(false);

			// record the last update time of the session
			$this->keys['updated'] = $this->time->get_timestamp();

			// session payload
			$payload = $this->_serialize(array($this->keys, $this->data, $this->flash));

			// create the session file
			$this->_write_memcached($this->keys['session_id'], $payload);

			// was the session id rotated?
			if ( isset($this->keys['previous_id']) and $this->keys['previous_id'] != $this->keys['session_id'])
			{
				// point the old session file to the new one, we don't want to lose the session
				$payload = $this->_serialize(array('rotated_session_id' => $this->keys['session_id']));
				$this->_write_memcached($this->keys['previous_id'], $payload);
			}

			$this->_set_cookie(array($this->keys['session_id']));
		}

		return $this;
	}
607006
public function write()
    {
        
        $targetPath = $this->getFilePath();
        $file = $this->getTranslationFile();
        $semanticNamespaces = array('rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
                                    'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#');
        
        $xmlNS = 'http://www.w3.org/XML/1998/namespace';
        $xmlnsNS = 'http://www.w3.org/2000/xmlns/';
        
        try {
            $targetFile = new DOMDocument('1.0', 'UTF-8');
            $targetFile->formatOutput = true;
            
            // Create the RDF root node and annotate if possible.
            $rdfNode = $targetFile->createElementNS($semanticNamespaces['rdf'], 'rdf:RDF');
            $targetFile->appendChild($rdfNode);
            $rootAnnotations = $this->getTranslationFile()->getAnnotations();
            if (count($rootAnnotations)){
                $annotationsString = tao_helpers_translation_RDFUtils::serializeAnnotations($rootAnnotations);
                $annotationsNode = $targetFile->createComment("\n    " . $annotationsString . "\n");
                $targetFile->insertBefore($annotationsNode, $rdfNode);
            }
            
            $rdfNode->setAttributeNS($xmlNS, 'xml:base', $file->getBase());
            $rdfNode->setAttributeNS($xmlnsNS, 'xmlns:rdfs', $semanticNamespaces['rdfs']);
            
            $xPath = new DOMXPath($targetFile);
            $xPath->registerNamespace($semanticNamespaces['rdf'], 'rdf');
            $xPath->registerNamespace($semanticNamespaces['rdfs'], 'rdfs');
            
            foreach ($file->getTranslationUnits() as $tu){
                // Look if the predicate is a semantic namespace.
                $uri = explode('#', $tu->getPredicate());
                if (count($uri) == 2) {
                    $namespace = $uri[0] . '#';
                    $qName = $uri[1];
                    if (($searchedNS = array_search($namespace, $semanticNamespaces)) !== false) {
                        $tuNode = $targetFile->createElement("${searchedNS}:${qName}");
                        $tuNode->setAttributeNS($xmlNS, 'xml:lang', $tu->getTargetLanguage());
                        $cdataValue = (($tu->getTarget() == '') ? $tu->getSource() : $tu->getTarget());
                        $tuNodeValue = $targetFile->createCDATASection($cdataValue);
                        
                        $tuNode->appendChild($tuNodeValue);
                        // Check if an rdf:Description exists for
                        // the target of the TranslationUnit.
                        $subject = $tu->getSubject();
                        $result = $xPath->query("//rdf:Description[@rdf:about='${subject}']");
                
                        if ($result->length > 0){
                            // Append to the existing rdf:Description.
                            $existingDescription = $result->item(0);
                            $existingDescription->appendChild($tuNode);
                        }
                        else {
                            // Append to a new rdf:Description node.
                            $descriptionNode = $targetFile->createElementNS($semanticNamespaces['rdf'], 'rdf:Description');
                            $descriptionNode->setAttributeNS($semanticNamespaces['rdf'], 'rdf:about', $subject);
                            $descriptionNode->appendChild($tuNode);
                            $rdfNode->appendChild($descriptionNode);
                        }
                        
                        // Finally add annotations.
                        $annotations = $tu->getAnnotations();
                        
                        if (count($annotations) > 0){
                            $annotationString = "\n    " . tao_helpers_translation_RDFUtils::serializeAnnotations($annotations) . "\n    ";
                            $annotationNode = $targetFile->createComment($annotationString);
                            $tuNode->parentNode->insertBefore($annotationNode, $tuNode);
                        }
                    }
                }
            }

            $targetFile->save($targetPath);   
        }
        catch (DOMException $e) {
            throw new tao_helpers_translation_TranslationException("An error occured while writing the RDF File at '${targetPath}'.");
        }
        
    }
1227408
public function write()
	{
		//var_dump($this->map);die();
		$returnstring = '{';
		
		foreach($this->map as $key => $value)
		{
			$returnstring .= '"' . $key . '":';
			
			if($value instanceof JSONObject || $value instanceof JSONArray)
				$returnstring .= $value->write();
			elseif(gettype($value) == 'integer' || gettype($value) == 'double')
				$returnstring .= $value;
			elseif(gettype($value) == 'boolean')
				$returnstring .= (($value) ? 'true' : 'false');
			elseif(gettype($value) == 'NULL')
				$returnstring .= 'null';
			elseif(gettype($value) == 'string')
				$returnstring .= '"' . $value . '"';
			else
				throw new JSONException('Invalid type ' . gettype($value));
			
			if($value !== end($this->map)) $returnstring .= ',';
		}
		
		$returnstring .= '}';
		
		return $returnstring;
	}
876568
public function stream_write($aData)
    {
        if ($this->write) {
            $left = substr(self::$string[$this->path], 0, $this->position);
            $right = substr(self::$string[$this->path], $this->position + strlen($aData));
            self::$string[$this->path] = $left . $aData . $right;
            $this->position += strlen($aData);
            return strlen($aData);
        } else {
            return false;
        }
    }
192536
public WriteStreamOld openWrite()
  {
    if (_cb != null)
      _cb.clear();
    else
      _cb = CharBuffer.allocate();

    if (_ws == null)
      _ws = new WriteStreamOld(this);
    else
      _ws.init(this);

    try {
      _ws.setEncoding("utf-8");
    } catch (UnsupportedEncodingException e) {
    }

    return _ws;
  }
972586
public function write()
    {
        foreach ($this->parameters as $prop => $value) {
            $placeHolders[] = sprintf('<%s>', $prop);
            $replacements[] = $value;
        }

        $config = str_replace($placeHolders, $replacements, self::$configTemplate);
        $config = sprintf('%s%s%s', self::$defaultConfigTemplate, PHP_EOL, $config);

        if (true === $this->parameters['composer']) {
            $config = sprintf('%s%s%s', $config, PHP_EOL, self::$downloadComposerTaskTemplate);
        }

        if (true === $this->parameters['schemadb']) {
            $config = sprintf('%s%s%s', $config, PHP_EOL, self::$updateSchemaTaskTemplate);
        }

        fwrite($this->file, $this->addHeaders($config));
    }
421339
protected function write()
	{
		$file		= new FS_File_Writer( $this->fileName );
		$newLines	= array();
		$currentSection	= "";
		foreach( $this->lines as $line )
		{
			if( $this->usesSections() && preg_match( $this->patternSection, $line ) )
			{
				$lastSection = $currentSection;
#				$newAdded = array();
				if( $lastSection )
				{
					foreach( $this->added as $nr => $property )
					{
						if( $property['section'] == $lastSection )
						{
							if( !trim( $newLines[count($newLines)-1] ) )
								array_pop( $newLines );
							$newLines[]	= $this->buildLine( $property['key'], $property['value'], $property['comment'] );
							$newLines[]	= "";
							unset( $this->added[$nr] );
						}
#						else $newAdded[] = $property;
					}
				}
				$currentSection =  substr( trim( $line ), 1, -1 );
				if( !in_array( $currentSection, $this->sections ) )
					continue;
			}
			else if( preg_match( $this->patternProperty, $line ) )
			{
				$pos		= strpos( $line, "=" );
				$key		= trim( substr( $line, 0, $pos ) );
				$pureKey	= preg_replace( $this->patternDisabled, "", $key );
				$parts		= explode(  "//", trim( substr( $line, $pos+1 ) ) );
				if( count( $parts ) > 1 )
					$comment = trim( $parts[1] );
				if( $this->usesSections() )
				{
					if( in_array( $currentSection, $this->sections ) )
					{
						if( isset( $this->deleted[$currentSection] ) && in_array( $pureKey, $this->deleted[$currentSection] ) )
							unset( $line );
						else if( isset( $this->renamed[$currentSection] ) && in_array( $pureKey, array_keys( $this->renamed[$currentSection] ) ) )
						{
							$newKey	= $key	= $this->renamed[$currentSection][$pureKey];
							if( !$this->isActiveProperty( $newKey, $currentSection) )
								$key = $this->signDisabled.$key;
							$comment	= isset( $this->comments[$currentSection][$newKey] ) ? $this->comments[$currentSection][$newKey] : "";
							$line = $this->buildLine( $key, $this->properties[$currentSection][$newKey], $comment );
						}
						else
						{
							if( $this->isActiveProperty( $pureKey, $currentSection ) && preg_match( $this->patternDisabled, $key ) )
								$key = substr( $key, 1 );
							else if( !$this->isActiveProperty( $pureKey, $currentSection ) && !preg_match( $this->patternDisabled, $key ) )
								$key = $this->signDisabled.$key;
							$comment	= isset( $this->comments[$currentSection][$pureKey] ) ? $this->comments[$currentSection][$pureKey] : "";
							$line = $this->buildLine( $key, $this->properties[$currentSection][$pureKey], $comment );
						}
					}
					else
						unset( $line );
				}
				else
				{
					if( in_array( $pureKey, $this->deleted ) )
						unset( $line);
					else if( in_array( $pureKey, array_keys( $this->renamed ) ) )
					{
						$newKey	= $key	= $this->renamed[$pureKey];
						if( !$this->isActiveProperty( $newKey ) )
							$key = $this->signDisabled.$key;
						$line = $this->buildLine( $newKey, $this->properties[$newKey], $this->comments[$newKey] );
					}
					else
					{
						if( $this->isActiveProperty( $pureKey ) && preg_match( $this->patternDisabled, $key ) )
							$key = substr( $key, 1 );
						else if( !$this->isActiveProperty( $pureKey) && !preg_match( $this->patternDisabled, $key ) )
							$key = $this->signDisabled.$key;
						$line = $this->buildLine( $key, $this->properties[$pureKey], $this->getComment( $pureKey ) );
					}
				}
			}
			if( isset( $line ) )
				$newLines[] = $line;
		}
		foreach( $this->added as $property )
		{
			$newLine	= $this->buildLine( $property['key'], $property['value'], $property['comment'] );
			$newLines[]	= $newLine;
		}
		$result			= $file->writeArray( $newLines );
		$this->added	= array();
		$this->deleted	= array();
		$this->renamed	= array();
		$this->read();
		return $result;
	}