function __construct($type) { parent::__construct(); $check = $this->createElement($type); $this->domainobject = $this->createElement('domain:' . $type); if (!$this->rootNamespaces()) { $this->domainobject->setAttribute('xmlns:domain', 'urn:ietf:params:xml:ns:domain-1.0'); } $check->appendChild($this->domainobject); $this->getCommand()->appendChild($check); }
public function run($value, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) { if ($pseudoMatcher->hasFunction('attr')) { $element->removeAttribute($pseudoMatcher->getFuncArgs('attr')); } else { if (strtolower($value[0]) === 'none') { $element->setAttribute('transphporm', 'remove'); } else { $element->setAttribute('transphporm', 'show'); } } }
protected function setUp() { // Setup DOM $this->domDocument = new \DOMDocument('1', 'UTF-8'); $html = $this->domDocument->createElement('html'); $this->domAnchor = $this->domDocument->createElement('a', 'fake'); $this->domAnchor->setAttribute('href', 'http://php-spider.org/contact/'); $this->domDocument->appendChild($html); $html->appendChild($this->domAnchor); $this->uri = new DiscoveredUri(new Uri($this->domAnchor->getAttribute('href'))); // Setup Spider\Resource $content = $this->domDocument->saveHTML(); $this->spiderResource = new Resource($this->uri, new Response(200, [], $content)); }
private function listFilesPhase1(Application $app, \DOMDocument $dom, \DomElement $node, $path, $server_coll_id, $depth, &$TColls) { $nnew = 0; if (false !== ($sxDotPhrasea = @simplexml_load_file($path . '/.phrasea.xml'))) { // test for magic file if (($magicfile = trim((string) $sxDotPhrasea->magicfile)) != '') { $magicmethod = strtoupper($sxDotPhrasea->magicfile['method']); if ($magicmethod == 'LOCK' && true === $app['filesystem']->exists($path . '/' . $magicfile)) { return; } elseif ($magicmethod == 'UNLOCK' && false === $app['filesystem']->exists($path . '/' . $magicfile)) { return; } } // change collection ? if (($new_cid = $sxDotPhrasea['collection']) != '') { if (isset($TColls['c' . $new_cid])) { $server_coll_id = $new_cid; } else { $this->log('debug', sprintf('Unknown coll_id (%1$d) in "%2$s"', (int) $new_cid, $path . '/.phrasea.xml')); $server_coll_id = -1; } } $node->setAttribute('pxml', '1'); } foreach ($this->listFolder($path) as $file) { if (!$this->isStarted()) { break; } usleep(10); if ($this->isIgnoredFile($file)) { continue; } if (is_dir($path . '/' . $file)) { $n = $node->appendChild($dom->createElement('file')); $n->setAttribute('isdir', '1'); $n->setAttribute('name', $file); $nnew += $this->listFilesPhase1($app, $dom, $n, $path . '/' . $file, $server_coll_id, $depth + 1, $TColls); if (!$this->isStarted()) { break; } } else { $n = $node->appendChild($dom->createElement('file')); $n->setAttribute('name', $file); $stat = stat($path . '/' . $file); foreach (["size", "ctime", "mtime"] as $k) { $n->setAttribute($k, $stat[$k]); } $nnew++; } $n->setAttribute('cid', $server_coll_id); $n->setAttribute('temperature', 'hot'); } return $nnew; }
/** * * Sets the given node it's value (if is array and if not) * @param DomDocumnet $xml * @param SimpleXmlElement $rootNode * @param unknown_type $value * @param string $fieldName * @param string $fieldType */ private static function setElementValue(DOMDocument &$xml, DomElement &$rootNode, $value, $fieldName = null, $fieldType = null) { //If the value is not an array then we just create the element and sets it's value if (!is_array($value)) { $rootNode->nodeValue = $value; if ($fieldType != null) { $rootNode->setAttribute("type", $fieldType); } } else { //create the array node $arrayNode = $xml->createElement("Array"); foreach ($value as $key => $singleValue) { $node = $xml->createElement($fieldName, $singleValue); $node->setAttribute("key", $key); if ($fieldType != null) { ${$node}->setAttribute("type", $fieldType); } $arrayNode->appendChild($node); } $rootNode->appendChild($arrayNode); } }
/** * Adding an attribute * @param string $name * @param mixed $value * @return AppKitXmlTag */ public function addAttribute($name, $value) { $this->tag->setAttribute($name, $value); return $this; }
/** * Function that creates types elements(schema) for WSDL1.1 in rpc style * @param DomDocument $wsdl_doc DomDocument element of the wsdl document * @param DomElement $wsdl_root service dom element * @param array $class_to_prefix reference to class name to prefix array * @param array $schemaType */ public function createRPCType(DomDocument $wsdl_doc, DomElement $wsdl_root, &$class_to_prefix, $schemaTypes) { // this will guide whether the given function is in-out or in only $return_array = array(); $types = $wsdl_doc->createElementNS(WS_WSDL_Const::WS_SCHEMA_WSDL_NAMESPACE, WS_WSDL_Const::WS_WSDL_TYPES_ATTR_NAME); $wsdl_root->appendChild($types); foreach ($schemaTypes as $function_name => $params) { $return_array[$function_name] = array(); if (array_key_exists(WS_WSDL_Const::WS_WSDL_INPUT_ATTR_NAME, $params)) { $return_array[$function_name][WS_WSDL_Const::WS_WSDL_INPUT_ATTR_NAME] = TRUE; $params_in_out = $params[WS_WSDL_Const::WS_WSDL_INPUT_ATTR_NAME]; foreach ($params_in_out as $paramName => $paramValue) { $xsd_type = $paramValue["type"]; if ($paramValue["object"] == "object") { $object_return = $this->createSchemaType($wsdl_doc, $types, $xsd_type); if ($this->rev_classmap && is_array($this->rev_classmap) && array_key_exists($xsd_type, $this->rev_classmap)) { $xsd_type = $this->rev_classmap[$xsd_type]; } $object_prefix = $object_return["prefix"]; $object_namespace = $object_return["namespace"]; $wsdl_root->setAttribute("xmlns:" . $object_prefix, $object_namespace); $class_to_prefix[$xsd_type] = $object_prefix; } } } if (array_key_exists(WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME, $params)) { $return_array[$function_name][WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME] = TRUE; $params_in_out = $params[WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME]; foreach ($params_in_out as $paramName => $paramValue) { $xsd_type = $paramValue["type"]; if ($paramValue["object"] == "object") { $object_return = $this->createSchemaType($wsdl_doc, $types, $xsd_type); if ($this->rev_classmap && is_array($this->rev_classmap) && array_key_exists($xsd_type, $this->rev_classmap)) { $xsd_type = $this->rev_classmap[$xsd_type]; } $object_prefix = $object_return["prefix"]; $object_namespace = $object_return["namespace"]; $wsdl_root->setAttribute("xmlns:" . $object_prefix, $object_namespace); $class_to_prefix[$xsd_type] = $object_prefix; } } } } return $return_array; }
/** * {@inheritdoc} */ public function apply(\DomElement $node) { $attributes = $node->attributes; $attribute = $attributes->getNamedItem($this->getAttributeName()); $value = $this->applyFilter($attribute ? $attribute->nodeValue : ''); // Replace if it already exists if ($attribute) { $attribute->nodeValue = $value; } elseif ($this->isForceAttribute()) { // Otherwise add $node->setAttribute($this->getAttributeName(), $value); } }