Write a config object to a string.

@return string|false   Returns a XML encoded string on success. False on failure.
488023
public function toString()
    {
        $addChildren = function($value, $key, $node)
        {
            if (is_scalar($value))
            {
                $n = $node->addChild('option', $value);
                $n->addAttribute('name', $key);
                $n->addAttribute('type', gettype($value));
            }
            else
            {
                $n = $node->addChild('config');
                $n->addAttribute('name', $key);
                $n->addAttribute('type', gettype($value));

                array_walk($value, $addChildren, $n);
            }
        };

        $xml  = simplexml_load_string('<config />');
        $data = $this->toArray();
        array_walk($data, $addChildren, $xml);

        return $xml->asXML();
    }
845089
public function toString(): string
    {
        $conditions = \array_map(static function (ConditionInterface $condition) {
            return $condition->toString();
        }, $this->conditions);

        return \sprintf('( %s )', \implode(' OR ', $conditions));
    }
363305
public function write_setting($data) {
        if (!$this->load_choices() or empty($this->choices)) {
            return '';
        }
        if (!array_key_exists($data, $this->choices)) {
            return ''; // ignore it
        }

        return ($this->config_write($this->name, $data) ? '' : get_string('errorsetting', 'admin'));
    }
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}'.");
        }
        
    }
1191342
public function toString()
    {
        if (!$this->getCommand()->getExecuted() && !$this->execute()) {
            return false;
        }
        return file_get_contents($this->getTmpFile()->getFileName());
    }
592071
public function xmlOutput() {
        $o = '';
        $o.= '        <INDEX NAME="' . $this->name . '"';
        if ($this->unique) {
            $unique = 'true';
        } else {
            $unique = 'false';
        }
        $o.= ' UNIQUE="' . $unique . '"';
        $o.= ' FIELDS="' . implode(', ', $this->fields) . '"';
        if ($this->hints) {
            $o.= ' HINTS="' . implode(', ', $this->hints) . '"';
        }
        if ($this->comment) {
            $o.= ' COMMENT="' . htmlspecialchars($this->comment) . '"';
        }
        $o.= '/>' . "\n";

        return $o;
    }
190734
public function write_setting($data) {
        if (!is_array($data)) {
            return ''; // ignore it
        }
        if (!$this->load_choices() or empty($this->choices)) {
            return '';
        }
        $result = '';
        foreach ($this->choices as $key=>$unused) {
            if (!empty($data[$key])) {
                $result .= '1';
            } else {
                $result .= '0';
            }
        }
        return $this->config_write($this->name, $result) ? '' : get_string('errorsetting', 'admin');
    }
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));
    }
205194
public function write_setting($data) {
        if (!is_array($data)) {
            return ''; //ignore it
        }
        if (!$this->load_choices() or empty($this->choices)) {
            return '';
        }

        unset($data['xxxxx']);

        $save = array();
        foreach ($data as $value) {
            if (!array_key_exists($value, $this->choices)) {
                continue; // ignore it
            }
            $save[] = $value;
        }

        return ($this->config_write($this->name, implode(',', $save)) ? '' : get_string('errorsetting', 'admin'));
    }
974835
public function write()
	{
		$writer	= new XML_DOM_FileWriter( $this->fileName );
		$root	= new XML_DOM_Node( $this->getOption( 'tag_root' ) );
		$this->writeRecursive( $root, $this->storage );
		return $writer->write( $root );
	}
1331155
public function serialize()
    {
        $ns_string = '';
        foreach ($this->namespaces as $k => $v) {
            $ns_string .= "\n  xmlns:$k=\"$v\"";
        }
        $return_msg =
            '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?>' .
            '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"' . $ns_string . ">\n" .
            '<SOAP-ENV:Body>' .
            '<SOAP-ENV:Fault>' .
            $this->serialize_val($this->faultcode, 'faultcode') .
            $this->serialize_val($this->faultactor, 'faultactor') .
            $this->serialize_val($this->faultstring, 'faultstring') .
            $this->serialize_val($this->faultdetail, 'detail') .
            '</SOAP-ENV:Fault>' .
            '</SOAP-ENV:Body>' .
            '</SOAP-ENV:Envelope>';
        return $return_msg;
    }
907597
final public function serialize(): string
    {
        $vars = array_filter(get_object_vars($this));
        $vars['adviceMethod'] = static::serializeAdvice($this->adviceMethod);

        return serialize($vars);
    }
869884
public function putXML(){
		$xml = $this->getXML();
		return $this->distributor->write($xml, $this->proper_path);
	}
917133
public function toXML()
    {
        $namespace = 'tns';
        $writer = new XMLWriter();
        $writer->openMemory();
        $writer->setIndent(true);
        $writer->setIndentString('    ');
        $writer->startElementNs($namespace, 'Porez', null);
        if ($this->getName()) {
            $writer->writeElementNs($namespace, 'Naziv', null, $this->getName());
        }
        $writer->writeElementNs($namespace, 'Stopa', null, $this->getRate());
        $writer->writeElementNs($namespace, 'Osnovica', null, $this->getBaseValue());
        $writer->writeElementNs($namespace, 'Iznos', null, $this->getValue());
        $writer->endElement();

        return $writer->outputMemory();
    }
2782
public function serializeToString()
    {
        $output = new CodedOutputStream($this->byteSize());
        $this->serializeToStream($output);
        return $output->getData();
    }
1126490
protected function attributesToString()
    {
        $string = '';
        $XMLConvention = in_array(static::$outputLanguage, array(ENT_XML1, ENT_XHTML));
        if (!empty($this->attributeList)) {
            foreach ($this->attributeList as $key => $value) {
                if ($value!==null && ($value!==false || $XMLConvention)) {
                    $string.= ' ' . $key;
                    if ($value===true) {
                        if ($XMLConvention) {
                            $value = $key;
                        } else {
                            continue;
                        }
                    }
                    $string.= '="' . implode(
                        ' ',
                        array_map(
                            static::$avoidXSS ? 'static::unXSS' : 'strval',
                            is_array($value) ? $value : array($value)
                        )
                    ) . '"';
                }
            }
        }
        return $string;
    }
536643
public function Write()
    {
        $content = "";

        foreach($this->preferences as $key => $data)
        {
            if(is_array($data))
            {
                $is_section = true;

                foreach($data as $dataKey => $dataValues)
                {
                    if(is_long($dataKey))
                    {
                        $is_section = false;
                        break;
                    }
                }

                $content .= "\n";

                //Write global array value
                if(!$is_section)
                {
                    foreach($data as $dataKey => $dataValue)
                    {
                        $content .= $key . '[] = "' . $dataValue . '"' . "\n";
                    }
                }

                //Write section
                else
                {
                    $content .= "[" . $key . "]\n";

                    foreach($data as $dataKey => $dataValue)
                    {
                        if(is_array($dataValue))
                        {
                            foreach($dataValue as $dataInnerValue)
                            {
                                $content .= $dataKey . '[] = "' . $dataInnerValue . '"' . "\n";
                            }
                        }
                        else
                        {
                            $content .= $dataKey . ' = "' . $dataValue . '"' . "\n";
                        }
                    }
                }

                $content .= "\n";
            }

            //Write global value
            else
            {
                $content .= $key . ' = "' . $data . '"' . "\n";
            }
        }

        file_put_contents($this->file, $content);
    }