/** * serialize * * @param Sabre_DAV_Server $server * @param DOMElement $prop * @return void */ public function serialize(Sabre_DAV_Server $server, DOMElement $prop) { $doc = $prop->ownerDocument; $prop->setAttribute('xmlns:b', 'urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/'); $prop->setAttribute('b:dt', 'dateTime.rfc1123'); $prop->nodeValue = Sabre_HTTP_Util::toHTTPDate($this->time); }
private function createUrlSet() { $this->dom = new \DOMDocument('1.0', 'UTF-8'); $this->urlset = $this->dom->createElement("urlset"); $this->urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $this->dom->appendChild($this->urlset); }
public function addUserFormatAttribute(DOMElement $node, $is_anonymous) { $node->setAttribute('format', $is_anonymous ? 'email' : 'username'); if ($is_anonymous) { $node->setAttribute('is_anonymous', "1"); } }
public function appendNamespaces(DOMElement $node) { $node->setAttribute('xmlns', 'http://www.w3.org/2005/Atom'); $node->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $node->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $node->setAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); }
/** * Injects bound in node * * @param \DOMElement $node * @param ResultInterface $bound */ private function injectsBounds(\DOMElement $node, ResultInterface $bound) { $node->setAttribute('loc', $bound->getSum('loc')); $node->setAttribute('lloc', $bound->getSum('logicalLoc')); $node->setAttribute('cyclomaticComplexity', $bound->getAverage('cyclomaticComplexity')); $node->setAttribute('maintainabilityIndex', $bound->getAverage('maintainabilityIndex')); $node->setAttribute('volume', $bound->getAverage('volume')); $node->setAttribute('vocabulary', $bound->getAverage('vocabulary')); $node->setAttribute('difficulty', $bound->getAverage('difficulty')); $node->setAttribute('effort', $bound->getAverage('effort')); $node->setAttribute('bugs', $bound->getAverage('bugs')); $node->setAttribute('time', $bound->getAverage('time')); $node->setAttribute('intelligentContent', $bound->getAverage('intelligentContent')); $node->setAttribute('commentWeight', $bound->getAverage('commentWeight')); $node->setAttribute('length', $bound->getAverage('length')); $hasOOP = null !== $bound->getSum('instability'); if ($hasOOP) { $node->setAttribute('lcom', $bound->getAverage('lcom')); $node->setAttribute('instability', $bound->getAverage('instability')); $node->setAttribute('efferentCoupling', $bound->getAverage('efferentCoupling')); $node->setAttribute('afferentCoupling', $bound->getAverage('afferentCoupling')); $node->setAttribute('sysc', $bound->getAverage('sysc')); $node->setAttribute('rsysc', $bound->getAverage('rsysc')); $node->setAttribute('dc', $bound->getAverage('dc')); $node->setAttribute('rdc', $bound->getAverage('rdc')); $node->setAttribute('sc', $bound->getAverage('sc')); $node->setAttribute('rsc', $bound->getAverage('rsc')); $node->setAttribute('noc', $bound->getSum('noc')); $node->setAttribute('noca', $bound->getSum('noca')); $node->setAttribute('nocc', $bound->getSum('nocc')); $node->setAttribute('noi', $bound->getSum('noi')); $node->setAttribute('nom', $bound->getSum('nom')); } }
public static function generateXML(DOMElement $fieldtype) { $fieldtype->setAttribute('name', self::TYPE); $fieldtype->setAttribute('class', 'solr.StrField'); $fieldtype->setAttribute('sortMissingLast', 'true'); $fieldtype->setAttribute('omitNorms', 'true'); return $fieldtype; }
/** * serialize * * @param DOMElement $prop * @return void */ public function serialize(Sabre_DAV_Server $server, DOMElement $prop) { $doc = $prop->ownerDocument; $prop->setAttribute('xmlns:b', 'urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/'); $prop->setAttribute('b:dt', 'dateTime.rfc1123'); $date = new DateTime('@' . $this->time, new DateTimeZone('UTC')); $prop->nodeValue = $date->format(DATE_RFC1123); }
/** * SiteMap constructor. * * @param string $domain */ public function __construct($domain) { $this->sitemap = new DOMDocument('1.0', 'UTF-8'); $this->sitemap->preserveWhiteSpace = false; $this->sitemap->formatOutput = true; $this->urlset = $this->sitemap->appendChild($this->sitemap->createElement('urlset')); $this->urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $this->setDomain($domain); }
/** * Set an element as root. * * @param DOMElement $rootElement * @return DOMElement The root element, including required attributes. */ protected function _setRootElement($rootElement) { $rootElement->setAttribute('xmlns', self::XMLNS); $rootElement->setAttribute('xmlns:xsi', self::XMLNS_XSI); $rootElement->setAttribute('xsi:schemaLocation', self::XMLNS . ' ' . self::XMLNS_SCHEMALOCATION); $rootElement->setAttribute('uri', $this->_buildUrl()); $rootElement->setAttribute('accessDate', date('c')); return $rootElement; }
public static function gerneateXML(DOMElement $fieldtype) { $fieldtype->setAttribute('name', self::TYPE); $fieldtype->setAttribute('class', 'solr.TrieFloatField'); $fieldtype->setAttribute('precisionStep', 0); $fieldtype->setAttribute('omitNorms', 'true'); $fieldtype->setAttribute('positionIncrementGap', 0); return $fieldtype; }
public function add($name, $href, $minAuthLevel, $maxAuthLevel) { $element = new \DOMElement('Item'); $element->setAttribute('name', $name); $element->setAttribute('href', $href); $element->setAttribute('minAuthLevel', $minAuthLevel); $element->setAttribute('maxAuthLevel', $maxAuthLevel); $this->xml->appendChild($element); }
/** * Set XML property or method argument value. * * @param string $value * @param \DOMElement $node * @param ClassMetadata[] $classesMetadata */ protected function setAttribute(string $value, \DOMElement $node, array $classesMetadata) { if (array_key_exists($value, $classesMetadata)) { $node->setAttribute('service', $value); } elseif (class_exists($value)) { $node->setAttribute('class', $value); } else { $node->setAttribute('value', $value); } }
public function __construct() { // create a new dom object $this->oDocument = new DOMDocument('1.0', 'UTF-8'); $this->oDocument->formatOutput = true; // add a root node with the name specified in the implementing class $this->oRootNode = $this->oDocument->createElement($this->sRootNodeName); $this->oRootNode->setAttribute('xmlns', $this->sXMLNamespace); $this->oDocument->appendChild($this->oRootNode); }
/** * @param string $cut * @param DOMElement $parentNode */ protected function getInstallListing($directory, $cut, $parentNode) { $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS)); foreach ($objects as $name => $object) { $file = ltrim(str_replace($cut, '', $name), '/'); $as = ltrim(str_replace($directory, '', $name), '/'); $parentNode->appendChild($node = new DOMElement('install')); $node->setAttribute('name', $file); $node->setAttribute('as', $as); } }
/** * @param DOMElement $rootNode * @param array $moderator */ protected function _appendContentModeratorXml(DOMElement $rootNode, $moderator) { $document = $rootNode->ownerDocument; $rootNode->setAttribute('content_id', $moderator['content_id']); $rootNode->setAttribute('content_type', $moderator['content_type']); $rootNode->setAttribute('username', $moderator['username']); $rootNode->setAttribute('user_id', $moderator['user_id']); $permissionsNode = $document->createElement('moderator_permissions'); $rootNode->appendChild($permissionsNode); $permissionsNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $moderator['moderator_permissions'])); }
/** * Alters images with an invalid source. * * When the 'Restrict images to this site' filter is enabled, any images that * are not hosted on the site will be passed through this hook, most commonly to * replace the invalid image with an error indicator. * * @param DOMElement $image * An IMG node to format, parsed from the filtered text. */ function hook_filter_secure_image_alter(&$image) { // Turn an invalid image into an error indicator. $image->setAttribute('src', base_path() . 'core/misc/icons/e32700/error.svg'); $image->setAttribute('alt', t('Image removed.')); $image->setAttribute('title', t('This image has been removed. For security reasons, only images from the local domain are allowed.')); // Add a CSS class to aid in styling. $class = $image->getAttribute('class') ? trim($image->getAttribute('class')) . ' ' : ''; $class .= 'filter-image-invalid'; $image->setAttribute('class', $class); }
/** * Creates a new XML Document * * @param numeric $version Version of XML to use * @param string $encoding Charset to use for document * @param string $root The tag name of $root */ public function __construct($version = self::VERSION, $encoding = self::ENCODING, $root = self::ROOT_EL, $xmlns = self::XMLNS, array $attrs = array()) { parent::__construct($version, $encoding); if (filter_var($xmlns, FILTER_VALIDATE_URL)) { $this->root = $this->appendChild($this->createElementNS($xmlns, $root)); } else { $this->root = $this->appendChild($this->createElement($root)); } foreach ($attrs as $prop => $value) { $this->root->setAttribute($prop, $value); } }
/** * @param string $baseUri */ public function __construct($baseUri = null) { parent::__construct('1.0', 'utf-8'); $this->baseUri = rtrim($baseUri, '/'); $type = $this instanceof SiteIndex ? 'siteindex' : 'sitemap'; $this->root = $this->createElement('siteindex' === $type ? 'sitemapindex' : 'urlset'); $this->root->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $this->root->setAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); $this->root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $this->root->setAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/' . $type . '.xsd'); $this->appendChild($this->root); }
/** * @param \DOMDocument $dom * @param \DOMElement $testsuite * @param ReportSummary $reportSummary */ private function createFailedTestCases(\DOMDocument $dom, \DOMElement $testsuite, ReportSummary $reportSummary) { $assertionsCount = 0; foreach ($reportSummary->getChanged() as $file => $fixResult) { $testcase = $this->createFailedTestCase($dom, $file, $fixResult, $reportSummary->shouldAddAppliedFixers()); $testsuite->appendChild($testcase); $assertionsCount += (int) $testcase->getAttribute('assertions'); } $testsuite->setAttribute('tests', count($reportSummary->getChanged())); $testsuite->setAttribute('assertions', $assertionsCount); $testsuite->setAttribute('failures', $assertionsCount); $testsuite->setAttribute('errors', 0); }
/** * Get the html node for this element * * @param \DOMElement $node * @param \AppShed\Remote\XML\DOMDocument $xml * @param \AppShed\Remote\HTML\Settings $settings * * @return \DOMElement */ public function getHTMLNodeInner($node, $xml, $settings) { $node->setAttribute('data-latitude', $this->latitude); $node->setAttribute('data-longitude', $this->longitude); $this->applyLinkToNode($xml, $node, $settings); $node->appendChild($xml->createElement('div', ['class' => 'title', 'text' => $this->title])); $subtitle = $this->subtitle; if (empty($subtitle)) { $xml->addClass($node, 'no-subtitle'); } else { $node->appendChild($xml->createElement('div', ['class' => 'text', 'text' => $this->subtitle])); } return $node; }
protected function postProcessDomNode($field, DOMElement $fieldNode, JForm $form) { $input = JFactory::getApplication()->input; if (JFactory::getApplication()->isAdmin()) { $fieldNode->setAttribute('plugin', JFactory::getConfig()->get('captcha')); } else { if ($input->get('option') == 'com_users' && $input->get('view') == 'profile' && $input->get('layout') != 'edit' && $input->get('task') != 'save') { // The user profile page does show the values by creating the form // and getting the values from it so we need to disable the field $fieldNode->setAttribute('plugin', null); } } $fieldNode->setAttribute('validate', 'captcha'); return parent::postProcessDomNode($field, $fieldNode, $form); }
/** * Get the html node for this element * * @param \DOMElement $node * @param \AppShed\Remote\XML\DOMDocument $xml * @param \AppShed\Remote\HTML\Settings $settings */ protected function getHTMLNodeInner($node, $xml, $settings) { $node->setAttribute('data-capturetype', $this->type); $node->setAttribute('data-name', $this->variableName); $node->setAttribute('data-save-value', $this->save); $node->appendChild($on = $xml->createElement('div', 'on')); $on->appendChild($xml->createElement('div', 'image')); $on->appendChild($xml->createElement('div', ['class' => 'title', 'text' => $this->title])); $on->appendChild($xml->createElement('div', ['class' => 'text', 'text' => $this->subtitle])); $on->appendChild($xml->createElement('button', ['class' => 'capture', 'text' => 'Capture'])); $on->appendChild($xml->createElement('button', ['class' => 'choose', 'text' => 'Choose'])); $node->appendChild($off = $xml->createElement('div', 'off')); $off->appendChild($xml->createElement('div', ['class' => 'title', 'text' => ucfirst($this->type) . ' Capture'])); $off->appendChild($xml->createElement('div', ['class' => 'text', 'text' => "You need to install this app via the store to use {$this->type} capture"])); }
/** * @param \DOMNode|\DOMElement $node * @param int $menuId */ private function getEditXML($node, $menuId) { $menu = \Difra\Plugins\CMS\Menu::get($menuId); $node->setAttribute('depth', $menu->getDepth()); $parentsNode = $node->appendChild($this->xml->createElement('parents')); \Difra\Plugins\CMS::getInstance()->getMenuItemsXML($parentsNode, $menu->getId()); }
/** * @param DOMElement $node * @param string $new_style */ static function append_style(DOMElement $node, $new_style) { $style = rtrim($node->getAttribute(self::$_style_attr), ";"); $style .= $new_style; $style = ltrim($style, ";"); $node->setAttribute(self::$_style_attr, $style); }
/** * Get some configuration variables as XML node attributes * @param \DOMElement|\DOMNode $node */ public static function getStateXML($node) { $config = self::getState(); foreach ($config as $k => $v) { $node->setAttribute($k, $v); } }
/** * Initialize the image resource * * @return void */ protected function _initRenderer() { $barcodeWidth = $this->_barcode->getWidth(true); $barcodeHeight = $this->_barcode->getHeight(true); $backgroundColor = $this->_barcode->getBackgroundColor(); $imageBackgroundColor = 'rgb(' . implode(', ', array(($backgroundColor & 0xff0000) >> 16, ($backgroundColor & 0xff00) >> 8, $backgroundColor & 0xff)) . ')'; $width = $barcodeWidth; $height = $barcodeHeight; if ($this->_userWidth && $this->_barcode->getType() != 'error') { $width = $this->_userWidth; } if ($this->_userHeight && $this->_barcode->getType() != 'error') { $height = $this->_userHeight; } if ($this->_resource === null) { $this->_resource = new DOMDocument('1.0', 'utf-8'); $this->_resource->formatOutput = true; $this->_rootElement = $this->_resource->createElement('svg'); $this->_rootElement->setAttribute('xmlns', "http://www.w3.org/2000/svg"); $this->_rootElement->setAttribute('version', '1.1'); $this->_rootElement->setAttribute('width', $width); $this->_rootElement->setAttribute('height', $height); $this->_appendRootElement('title', array(), "Barcode " . strtoupper($this->_barcode->getType()) . " " . $this->_barcode->getText()); } else { $this->_readRootElement(); $width = $this->_rootElement->getAttribute('width'); $height = $this->_rootElement->getAttribute('height'); } $this->_adjustPosition($height, $width); $this->_appendRootElement('rect', array('x' => $this->_leftOffset, 'y' => $this->_topOffset, 'width' => $this->_leftOffset + $barcodeWidth - 1, 'height' => $this->_topOffset + $barcodeHeight - 1, 'fill' => $imageBackgroundColor)); }
/** * Create basics tags. Definitions (root), schema (contain types), port type * and binding. * * @return void */ protected function createMajorElements() { // >> definitions $this->oDefinitions = $this->createElementNS(self::NS_WSDL, 'wsdl:definitions'); $this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:soap-enc', self::NS_SOAP_ENC); $this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:soap-env', self::NS_SOAP_ENV); $this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:tns', $this->sTns); $this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:wsdl', self::NS_WSDL); $this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:xsd', self::NS_XSD); $this->oDefinitions->setAttribute('targetNamespace', $this->sTns); $this->appendChild($this->oDefinitions); // >> definitions >> types $oTypes = $this->createElementNS(self::NS_WSDL, 'types'); $this->oDefinitions->appendChild($oTypes); // >> definitions >> types >> schema $this->oSchema = $this->createElementNS(self::NS_XSD, 'schema'); $this->oSchema->setAttribute('targetNamespace', $this->sTns); $oTypes->appendChild($this->oSchema); // >> definitions >> types >>port type $this->oPortType = $this->createElementNS(self::NS_WSDL, 'portType'); $this->oPortType->setAttribute('name', $this->oClass->name . 'PortType'); // >> definitions >> types >> binding $this->oBinding = $this->createElementNS(self::NS_WSDL, 'binding'); $this->oBinding->setAttribute('name', $this->oClass->name . 'Binding'); $this->oBinding->setAttribute('type', 'tns:' . $this->oClass->name . 'PortType'); // >> definitions >> types >> binding >> soap binding $oBindingSoap = $this->createElementNS(self::NS_SOAP_ENV, 'binding'); $oBindingSoap->setAttribute('style', 'rpc'); $oBindingSoap->setAttribute('transport', self::BINDING); $this->oBinding->appendChild($oBindingSoap); }
public function filter(DOMElement $element) { $xpath = $this->_getXpath(); $mediaUrl = $this->_config['baseUrl'] . '/media/' . urlencode($this->_config['bookName']) . '/'; // Fix all <img> and <script> tags $images = $xpath->query('//h:img[@src] | //h:script[@src]'); foreach ($images as $imgTag) { $src = $imgTag->getAttribute('src'); if (!preg_match('|^https?://|', $src)) { $imgTag->setAttribute('src', $mediaUrl . $src); } } // Fix all url references in inline style attributes $hasStyle = $xpath->query('//h:*[contains(@style, "url")]'); foreach ($hasStyle as $hs) { $style = $hs->getAttribute('style'); $style = preg_replace('/url\\((.+?)\\)/', 'url(' . $mediaUrl . '\\1)', $style); $hs->setAttribute('style', $style); } // Fix all background references $hasbg = $xpath->query('//h:*[@background]'); foreach ($hasbg as $element) { $bg = $element->getAttribute('background'); if (!preg_match('|^https?://|', $bg)) { $element->setAttribute('background', $mediaUrl . $bg); } } }
/** * Add a {@link http://www.w3.org/TR/wsdl#_types types} data type definition * * @param string $type Name of the class to be specified * @return string XSD Type for the given PHP type */ public function addComplexType($type) { if (in_array($type, $this->_includedTypes)) { return "tns:{$type}"; } if ($this->_schema === null) { $this->_schema = $this->_dom->createElement('xsd:schema'); $this->_schema->setAttribute('targetNamespace', $this->_uri); $types = $this->_dom->createElement('types'); $types->appendChild($this->_schema); $this->_wsdl->appendChild($types); } $class = new ReflectionClass($type); $complexType = $this->_dom->createElement('xsd:complexType'); $complexType->setAttribute('name', $type); $all = $this->_dom->createElement('xsd:all'); foreach ($class->getProperties() as $property) { if (preg_match_all('/@var\\s+([^\\s]+)/m', $property->getDocComment(), $matches)) { /** * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType' * node for describing other classes used as attribute types for current class */ $element = $this->_dom->createElement('xsd:element'); $element->setAttribute('name', $property->getName()); $element->setAttribute('type', $this->getType(trim($matches[1][0]))); $all->appendChild($element); } } $complexType->appendChild($all); $this->_schema->appendChild($complexType); $this->_includedTypes[] = $type; return "tns:{$type}"; }
/** * html::a(array('id'=>1,'class'=>'selected')); * @var array $attributes * * @return DOMElement */ public static function createElement($tagname, $attributes = array()) { $e = new DOMElement($tagname); foreach ($attributes as $k => $v) { $e->setAttribute($k, $v); } }