/**
 * This function appends expires_at and job_description_format tags into RSS
 * <item> tag. 
 * 
 * Function is applied once for each <item> in the feed and the additional data
 * is appended to the end of "item".
 * 
 * @param DomElement $item      http://php.net/manual/en/class.domelement.php
 * @param DomDocument $rss      http://php.net/manual/en/class.domdocument.php
 * @param Wpjb_Model_Job $job   Job currently rendered to XML
 * @return DomElement           Modified DomElement object
 */
function feeds_api_rss($item, $rss, $job)
{
    // Using default fields
    $item->appendChild($rss->createElement("expires_at", esc_html($job->job_expires_at)));
    // Using meta fields
    $item->appendChild($rss->createElement("job_description_format", esc_html($job->meta->job_description_format->value())));
    // Make sure to return $item
    return $item;
}
 /**
  * return the document as string.
  *
  * @access public
  * @return string
  */
 public function __toString()
 {
     $this->document->formatOutput = true;
     $this->document->preserveWhitespace = false;
     $title = $this->document->createElement('title', $this->getFullTitle());
     $this->head->appendChild($title);
     if (!empty($this->favicon)) {
         $favicon = $this->document->createElement('link');
         $favicon->setAttribute('rel', 'shortcut icon');
         $favicon->setAttribute('href', $this->favicon);
         $this->head->appendChild($favicon);
         $favicon = $this->document->createElement('link');
         $favicon->setAttribute('rel', 'icon');
         $favicon->setAttribute('href', $this->favicon);
         $this->head->appendChild($favicon);
     }
     if (!empty($this->keywords)) {
         $keywords = $this->document->createElement('meta');
         $keywords->setAttribute('name', 'keywords');
         $keywords->setAttribute('content', $this->keywords);
         $this->head->appendChild($keywords);
     }
     $html = $this->document->getElementsByTagName('html')->item(0);
     $html->appendChild($this->head);
     $html->appendChild($this->body);
     return $this->document->saveXML();
 }
Beispiel #3
0
 private function injectIfNotCode($chr, \DomElement $element, $string)
 {
     if ($chr === '`') {
         $element->appendChild($this->document->createTextNode($string));
     } else {
         $this->inject($element, $string);
     }
 }
Beispiel #4
0
 /**
  * Test name is vaild and add node.
  * If not create node with ARRAY_ITEM_NAME name and
  * set old neme in ARRAY_KEY_ATTRIBUTE
  *
  * @param string $name
  * @param DomElement $element
  * @return DomElement
  */
 protected function _testNodeNameAndAddNode($name, DomElement $element)
 {
     $doc = $element->ownerDocument;
     if (!preg_match(self::NODE_NAME_PATTERN, $name)) {
         if ($element instanceof DOMDocument) {
             $nodeName = self::ARRAY_ITEM_NAME;
         } else {
             $nodeName = rtrim($element->nodeName, 's');
         }
         $newNode = $doc->createElement($nodeName);
         $newNode->setAttribute(self::ARRAY_KEY_ATTRIBUTE, $name);
         $element->appendChild($newNode);
     } else {
         $newNode = $doc->createElement($name);
         $element->appendChild($newNode);
     }
     return $newNode;
 }
Beispiel #5
0
 public function addItemElement($element, $value, $attr = array())
 {
     $element = $this->createElement($element, $this->normalizeString($value));
     foreach ($attr as $key => $value) {
         $element->setAttribute($key, $this->normalizeString($value));
     }
     $this->item->appendChild($element);
     return $this;
 }
 /**
  * Creates a parent element with the given name, with text as given.  
  *
  * Adds the resulting element as a child of the given parent node.
  *
  * @param DomElement $parent Existing parent of all the new nodes.
  * @param string $name Name of the new parent element.
  * @param string $text Text of the new element.
  * @return DomElement The new element.
  */
 protected function appendNewElement($parent, $name, $text = null)
 {
     $document = $this->document;
     $newElement = $document->createElement($name);
     // Use a TextNode, causes escaping of input text
     if ($text) {
         $text = $document->createTextNode($text);
         $newElement->appendChild($text);
     }
     $parent->appendChild($newElement);
     return $newElement;
 }
Beispiel #7
0
 public function addItemElementSub($element, $sub)
 {
     $element = $this->createElement($element);
     foreach ($sub as $key => $value) {
         if (is_array($value)) {
             $subElement = $this->createElement($key);
             foreach ($value as $key => $value) {
                 $subElement->setAttribute($key, $this->normalizeString($value));
             }
         } else {
             $subElement = $this->createElement($key, $this->normalizeString($value));
         }
         $element->appendChild($subElement);
     }
     $this->item->appendChild($element);
     return $this;
 }
Beispiel #8
0
 public function addExtension($type, $value)
 {
     // get container
     if (!$this->extensionsDomElement) {
         // get creatives tag
         $this->extensionsDomElement = $this->domElement->getElementsByTagName('Extensions')->item(0);
         if (!$this->extensionsDomElement) {
             $this->extensionsDomElement = $this->domElement->ownerDocument->createElement('Extensions');
             $this->domElement->firstChild->appendChild($this->extensionsDomElement);
         }
     }
     // Creative dom element
     $extensionDomElement = $this->extensionsDomElement->ownerDocument->createElement('Extension');
     $this->extensionsDomElement->appendChild($extensionDomElement);
     // create cdata
     $cdata = $this->domElement->ownerDocument->createCDATASection($value);
     // append
     $extensionDomElement->setAttribute('type', $type);
     $extensionDomElement->appendChild($cdata);
     return $this;
 }
Beispiel #9
0
 public function createInterface(DomDocument $interface_doc, DomElement $interface_root)
 {
     $interface_ele = $interface_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, self::WS_WSDL2_INTERFACE_INTERFACE_ATTR_NAME);
     $interface_ele->setAttribute(self::WS_WSDL_INTERFACE_NAME_ATTR_NAME, $this->svr_name . ucfirst(self::WS_WSDL2_INTERFACE_INTERFACE_ATTR_NAME));
     foreach ($this->operations as $name => $params) {
         $op = $interface_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, self::WS_WSDL_INTERFACE_OPERATION_ATTR_NAME);
         $op->setAttribute(self::WS_WSDL_INTERFACE_NAME_ATTR_NAME, $name);
         $op->setAttribute(self::WS_WSDL2_INTERFACE_PATTERN_ATTR_NAME, WS_WSDL_Const::WS_WSDL2_PATTERN_ATTR_VAL);
         foreach (array(self::WS_WSDL_INTERFACE_INPUT_ATTR_NAME, self::WS_WSDL_INTERFACE_OUTPUT_ATTR_NAME) as $type) {
             $operation_ele = $interface_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, $type);
             if ($type == self::WS_WSDL_INTERFACE_INPUT_ATTR_NAME) {
                 $operation_ele->setAttribute(self::WS_WSDL2_INTERFACE_PATTERN_ATTR_NAME, $name);
             } else {
                 $operation_ele->setAttribute(self::WS_WSDL2_INTERFACE_PATTERN_ATTR_NAME, $name . "Response");
             }
             $op->appendChild($operation_ele);
         }
         $interface_ele->appendChild($op);
     }
     $interface_root->appendChild($interface_ele);
 }
Beispiel #10
0
 /**
  * Function that creates portType elements for WSDL1.1
  * @param DomDocument $port_doc DomDocument element of the wsdl document
  * @param DomElement $port_root service dom element
  */
 public function createPortType(DomDocument $port_doc, DomElement $port_root)
 {
     $attr_name_to_postfix_map = array(WS_WSDL_Const::WS_WSDL_INPUT_ATTR_NAME => WS_WSDL_Const::WS_WSDL_OPERTION_INPUT_TAG, WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME => WS_WSDL_Const::WS_WSDL_OPERTION_OUTPUT_TAG);
     $port_el = $port_doc->createElementNS(WS_WSDL_Const::WS_SCHEMA_WSDL_NAMESPACE, WS_WSDL_Const::WS_WSDL_PORTTYPE_ATTR_NAME);
     $port_el->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, $this->service_name . "PortType");
     foreach ($this->operations as $name => $params) {
         $operation = $port_doc->createElementNS(WS_WSDL_Const::WS_SCHEMA_WSDL_NAMESPACE, WS_WSDL_Const::WS_WSDL_OPERATION_ATTR_NAME);
         foreach ($this->fun_mapping as $key => $value) {
             if ($value == $name) {
                 $operation->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, $key);
             }
         }
         // be sensitive to the available directions
         $directions_arr = array();
         // we anyway have the input message
         $directions_arr[] = WS_WSDL_Const::WS_WSDL_INPUT_ATTR_NAME;
         if (array_key_exists("output", $params)) {
             $directions_arr[] = WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME;
         }
         foreach ($directions_arr as $type) {
             $sel = $port_doc->createElementNS(WS_WSDL_Const::WS_SCHEMA_WSDL_NAMESPACE, $type);
             foreach ($this->fun_mapping as $key => $value) {
                 if ($value == $name) {
                     $sel->setAttribute(WS_WSDL_Const::WS_WSDL_MESSAGE_ATTR_NAME, WS_WSDL_Const::WS_WSDL_TNS_ATTR_NAME . ":" . "{$key}" . ucfirst($attr_name_to_postfix_map[$type]));
                     if ($this->use_wsa) {
                         $action = NULL;
                         if ($this->r_actions && is_array($this->r_actions) && array_key_exists($key, $this->r_actions)) {
                             $action = $this->r_actions[$key];
                             $sel->setAttributeNS(WS_WSDL_Const::WS_WSDL_WSAW_NAMESPACE, WS_WSDL_Const::WS_WSDL_WSAW_PREFIX . ":" . WS_WSDL_CONST::WS_WSDL_ACTION, $action);
                         }
                     }
                 }
             }
             $operation->appendChild($sel);
         }
         $port_el->appendChild($operation);
     }
     $port_root->appendChild($port_el);
 }
 private function write_rdf_value_to_xml_element(DomDocument $dom, $val, DomElement $el, $s, $p, $parentUris)
 {
     if (in_array($val['type'], array('uri', 'bnode')) and $this->resource_is_a_list($val['value'])) {
         $listValues = $this->list_to_array($val['value']);
         foreach ($listValues as $itemURI) {
             $item = $dom->createElement('item');
             $item = $this->write_resource_on_xml_element($dom, $itemURI, $item, $parentUris);
             $el->appendChild($item);
         }
     } else {
         if ($val['type'] == 'literal') {
             $el->appendChild($dom->createTextNode($val['value']));
             if (isset($val['lang'])) {
                 $xmllang = $dom->createAttribute('xml:lang');
                 $xmllang->appendChild($dom->createTextNode($val['lang']));
                 $el->appendChild($xmllang);
             } else {
                 if (isset($val['datatype'])) {
                     $shortname = $this->get_short_name_for_uri($val['datatype']);
                     $datatypeAttr = $dom->createAttribute('datatype');
                     $datatypeAttr->appendChild($dom->createTextNode($shortname));
                     $el->appendChild($datatypeAttr);
                 }
             }
         } else {
             if ($val['type'] == 'bnode' or $val['type'] == 'uri') {
                 $el = $this->write_resource_on_xml_element($dom, $val['value'], $el, $parentUris);
             }
         }
     }
     return $el;
 }
Beispiel #12
0
 /**
  * Function that creates service elements for WSDL2.0
  * @param DomDocument $svr_name DomDocument element of the wsdl document 
  * @param DomElement $svr_root service dom element 
  */
 public function createWsdl2Service(DomDocument $svr_dom, DomElement $svr_root)
 {
     $svr_ele = $svr_dom->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_SERVICE_ATTR_NAME);
     $svr_ele->setAttribute(WS_WSDL_Const::WS_WSDL_SERVICE_ATTR_NAME, $this->S_name);
     $svr_ele->setAttribute(WS_WSDL_Const::WS_WSDL_INTERFACE_ATTR_NAME, $this->S_name . ucfirst(WS_WSDL_Const::WS_WSDL_INTERFACE_ATTR_NAME));
     $svr_port = $svr_dom->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_ENDPOINT_ATTR_NAME);
     $svr_port->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, $this->S_name);
     $svr_port->setAttribute(WS_WSDL_Const::WS_WSDL_BINDING_ATTR_NAME, "tns" . $this->S_name);
     $svr_port->setAttribute(WS_WSDL_Const::WS_WSDL_ADDRESS_ATTR_NAME, $this->endpoint);
     $svr_ele->appendChild($svr_port);
     $svr_root->appendChild($svr_ele);
 }
 protected function addTypes(DomDocument $doc, DomElement $root)
 {
     $types = $doc->createElementNS(self::SCHEMA_WSDL, 'types');
     $root->appendChild($types);
     $el = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'schema');
     $types->appendChild($el);
     /* BEGIN: crutch */
     $ct = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'complexType');
     $el->appendChild($ct);
     $ct->setAttribute('name', 'array');
     $cc = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'complexContent');
     $ct->appendChild($cc);
     $restriction = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'restriction');
     $cc->appendChild($restriction);
     $restriction->setAttribute('base', 'soapenc:array');
     $attribute = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'attribute');
     $restriction->appendChild($attribute);
     $attribute->setAttribute('ref', 'soapenc:arrayType');
     $attribute->setAttributeNS(self::SCHEMA_WSDL, 'arrayType', 'tns:mixed[]');
     /* END: crutch */
     foreach ($this->complexTypes as $name => $data) {
         $ct = $doc->createElementNS(self::SCHEMA_WSDL, 'complexType');
         $ct->setAttribute('name', $name);
         $all = $doc->createElementNS(self::SCHEMA_WSDL, 'all');
         foreach ($data as $prop) {
             $p = $doc->createElementNS(self::SCHEMA_WSDL, 'element');
             $p->setAttribute('name', $prop['name']);
             $p->setAttribute('name', $prop['name']);
             $prefix = $root->lookupPrefix($this->types[$prop['type']]['ns']);
             $p->setAttribute('type', "{$prefix}:" . $this->types[$prop['type']]['name']);
             $all->appendChild($p);
         }
         $ct->appendChild($all);
         $el->appendChild($ct);
     }
 }
Beispiel #14
0
 protected function addTypes(DomDocument $doc, DomElement $root)
 {
     $types = $doc->createElementNS(self::SCHEMA_WSDL, 'types');
     $root->appendChild($types);
     $el = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'schema');
     $el->setAttribute('attributeFormDefault', 'qualified');
     $el->setAttribute('elementFormDefault', 'qualified');
     $el->setAttribute('targetNamespace', $this->ns);
     $types->appendChild($el);
     foreach ($this->complexTypes as $name => $data) {
         if ($name == 'mixed') {
             continue;
         }
         $ct = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'complexType');
         $ct->setAttribute('name', $name);
         $all = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'sequence');
         foreach ($data as $prop) {
             $p = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element');
             $p->setAttribute('name', $prop['name']);
             $prefix = $root->lookupPrefix($this->types[$prop['type']]['ns']);
             $p->setAttribute('type', "{$prefix}:" . $this->types[$prop['type']]['name']);
             $all->appendChild($p);
         }
         $ct->appendChild($all);
         $el->appendChild($ct);
     }
     $nsPrefix = $root->lookupPrefix($this->ns);
     // Add message types
     foreach ($this->operations as $name => $params) {
         foreach (array('input' => '', 'output' => 'Response') as $type => $postfix) {
             $ce = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element');
             $fullName = "{$name}" . ucfirst($postfix);
             $ce->setAttribute('name', $fullName);
             $ce->setAttribute('type', "{$nsPrefix}:{$fullName}");
             $el->appendChild($ce);
             $ct = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'complexType');
             $ct->setAttribute('name', $fullName);
             $ctseq = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'sequence');
             $ct->appendChild($ctseq);
             foreach ($params[$type] as $param) {
                 $pare = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element');
                 $pare->setAttribute('name', $param['name']);
                 $prefix = $root->lookupPrefix($this->types[$param['type']]['ns']);
                 $pare->setAttribute('type', "{$prefix}:" . $this->types[$param['type']]['name']);
                 $ctseq->appendChild($pare);
             }
             $el->appendChild($ct);
         }
     }
     // Add fault elements
     foreach ($this->faults as $faultType) {
         $ce = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element');
         $ce->setAttribute('name', $faultType);
         $prefix = $root->lookupPrefix($this->types[$faultType]['ns']);
         $ce->setAttribute('type', $prefix . ':' . $faultType);
         $el->appendChild($ce);
         $ce = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element');
         $ce->setAttribute('name', $faultType . 'Fault');
         $ct = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'complexType');
         $seq = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'sequence');
         $elFault = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element');
         $elFault->setAttribute('ref', $prefix . ':' . $faultType);
         $seq->appendChild($elFault);
         $ct->appendChild($seq);
         $ce->appendChild($ct);
         $el->appendChild($ce);
     }
 }
Beispiel #15
0
 /**
  *
  * @param array $item
  * @param DomElement $parentContainer
  * @return bool 
  */
 protected function _addChildMenu($item, $parentContainer, $root = false)
 {
     $active = false;
     $li = $this->_dom->createElement('li');
     // Check if the item has an url and it is active
     if (array_key_exists('url', $item) && $this->_checkActive($item['url'])) {
         $active = true;
     }
     $a = $this->_dom->createElement('a');
     if (!empty($item['url'])) {
         $a->setAttribute('href', $this->view->baseUrl($item['url']));
     } else {
         $a->setAttribute('href', 'javascript:;');
     }
     $a->appendChild($this->_dom->createTextNode($item['label']));
     $li->appendChild($a);
     // If there are children in the item
     if (!empty($item['children'])) {
         $li->setAttribute('class', 'dropdown');
         $a->setAttribute('class', 'dropdown-toggle');
         $a->setAttribute('data-toggle', 'dropdown');
         $spanArrow = $this->_dom->createElement('span');
         $spanArrow->setAttribute('class', 'arrow');
         $a->appendChild($spanArrow);
         $ulContainer = $this->_dom->createElement('ul');
         $ulContainer->setAttribute('class', 'dropdown-menu');
         // Attach all the children itens
         foreach ($item['children'] as $child) {
             $activeTest = $this->_addChildMenu($child, $ulContainer);
             if ($activeTest) {
                 $active = $activeTest;
             }
         }
         if ($ulContainer->childNodes->length < 1) {
             return false;
         }
         $li->appendChild($ulContainer);
     }
     // Check if it's active
     if ($active) {
         $this->_setActive($li, $root);
     }
     $parentContainer->appendChild($li);
     return $active;
 }
Beispiel #16
0
 /**
  * Function that creates type elements(schema) for WSDL2.0
  * @param DomDocument $type-doc DomDocument element of the wsdl
  * document
  * @param DomElement $wsdl_root service dom element
  */
 public function createWsdl2Type(DomDocument $wsdl_doc, DomElement $wsdl_root, $schemaTypes)
 {
     $types = $wsdl_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_TYPES_ATTR_NAME);
     $wsdl_root->appendChild($types);
     $el = $wsdl_doc->createElementNS(WS_WSDL_Const::WS_SOAP_XML_SCHEMA_NAMESPACE, WS_WSDL_Const::WS_WSDL_SCHEMA_ATTR_NAME);
     $el->setAttribute(WS_WSDL_Const::WS_WSDL_ELEMENTFROMDEFAULT_ATTR_NAME, WS_WSDL_Const::WS_WSDL_QUALIFIED_ATTR_NAME);
     $types->appendChild($el);
     foreach ($schemaTypes as $function_name => $params) {
         foreach ($params as $requestType => $params_in_out) {
             $ct = $wsdl_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_ELEMENT_ATTR_NAME);
             if ($requestType == WS_WSDL_Const::WS_WSDL_INPUT_ATTR_NAME) {
                 $ct->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, $function_name);
                 $el->appendChild($ct);
                 $comtype = $wsdl_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_COMPLXTYPE_ATTR_NAME);
                 $ct->appendChild($comtype);
                 $seq = $wsdl_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_SEQUENCE_ATTR_NAME);
                 $comtype->appendChild($seq);
                 foreach ($params_in_out as $paramName => $xsType) {
                     $element_ele = $wsdl_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_ELEMENT_ATTR_NAME);
                     $element_ele->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, $paramName);
                     $element_ele->setAttribute(WS_WSDL_Const::WS_WSDL_TYPE_ATTR_NAME, WS_WSDL_Const::WS_WSDL_XSD_ATTR_NAME . $xsType);
                     $seq->appendChild($element_ele);
                 }
             }
             if ($requestType == WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME) {
                 $ct->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, $function_name . WS_WSDL_Const::WS_WSDL_RESPONSE_ATTR_NAME);
                 $el->appendChild($ct);
                 $comtype = $wsdl_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_COMPLXTYPE_ATTR_NAME);
                 $ct->appendChild($comtype);
                 $seq = $wsdl_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_SEQUENCE_ATTR_NAME);
                 $comtype->appendChild($seq);
                 foreach ($params_in_out as $paramName => $xsType) {
                     $element_ele = $wsdl_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_ELEMENT_ATTR_NAME);
                     $element_ele->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, $paramName);
                     $element_ele->setAttribute(WS_WSDL_Const::WS_WSDL_TYPE_ATTR_NAME, WS_WSDL_Const::WS_WSDL_XSD_ATTR_NAME . $xsType);
                     $seq->appendChild($element_ele);
                 }
             }
         }
     }
 }
 /**
  * Flags the tag to be not empty
  * @return AppKitXmlTag
  */
 public function setNotEmpty()
 {
     $textNode = $this->dom->createTextNode('');
     $this->tag->appendChild($textNode);
     return $this;
 }
Beispiel #18
0
 /**
  * Function for creating Binding element in WSDL2.0
  * @param DomDocument $binding_doc DomDocument element of the wsdl document 
  * @param DomElement $binding_root root element of the document
  */
 public function createWsdl2Binding(DomDocument $binding_doc, DomElement $binding_root)
 {
     $binding_ele = $binding_doc->createElementNS(WS_WSDL_Const::WS_WSDL2_NAMESPACE, WS_WSDL_Const::WS_WSDL_BINDING_ATTR_NAME);
     $binding_ele->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, $this->svr_name . strtoupper(WS_WSDL_Const::WS_WSDL_SOAP_ATTR_NAME) . ucfirst(WS_WSDL_Const::WS_WSDL_BINDING_ATTR_NAME));
     $binding_ele->setAttribute(WS_WSDL_Const::WS_WSDL_TYPE_ATTR_NAME, WS_WSDL_Const::WS_WSDL2_WSOAP_ATTR_VAL);
     $binding_ele->setAttribute(WS_WSDL_Const::WS_WSDL_INTERFACE_ATTR_NAME, $this->svr_name . ucfirst(WS_WSDL_Const::WS_WSDL_INTERFACE_ATTR_NAME));
     $binding_ele->setAttribute(WS_WSDL_Const::WS_WSDL_VERSION_ATTR_NAME, self::WS_WSDL2_BINDING_VERSION_ATTR_VAL);
     $binding_ele->setAttribute(WS_WSDL_Const::WS_WSDL_PROTOCAL_ATTR_NAME, WS_WSDL_Const::WS_WSDL2_BINDING_ATTR_VAL);
     $binding_root->appendChild($binding_ele);
 }
Beispiel #19
0
 /**
  * @param \DomDocument $dom
  * @param \DomElement $parentNode
  * @param string $relUri1
  * @param string $relUri2
  * @param string $relationshipUri
  */
 protected function createCompetencyFrameworkRelationNode(\DomDocument $dom, \DomElement $parentNode, $relUri1, $relUri2, $relationshipUri)
 {
     $relationNode = $dom->createElement('cf:Relation');
     $parentNode->appendChild($relationNode);
     $referenceNode = $dom->createElement('cf:Reference1');
     $relationNode->appendChild($referenceNode);
     $catalogNode = $dom->createElement('cf:Catalog', 'URI');
     $referenceNode->appendChild($catalogNode);
     $entryNode = $dom->createElement('cf:Entry', $relUri1);
     $referenceNode->appendChild($entryNode);
     $relationshipNode = $dom->createElement('cf:Relationship', $relationshipUri);
     $relationNode->appendChild($relationshipNode);
     $referenceNode = $dom->createElement('cf:Reference2');
     $relationNode->appendChild($referenceNode);
     $catalogNode = $dom->createElement('cf:Catalog', 'URI');
     $referenceNode->appendChild($catalogNode);
     $entryNode = $dom->createElement('cf:Entry', $relUri2);
     $referenceNode->appendChild($entryNode);
 }
 /**
  * 
  * 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);
     }
 }
Beispiel #21
0
 protected function buildITunes(DomElement $root, AbstractFeedData $fd)
 {
     /* author node */
     $author = '';
     if (isset($fd->itunes->author)) {
         $author = $fd->itunes->author;
     } elseif (isset($fd->author)) {
         $author = $fd->author;
     }
     if (!empty($author)) {
         $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:author', $author);
         $root->appendChild($node);
     }
     /* owner node */
     $author = '';
     $email = '';
     if (isset($fd->itunes->owner)) {
         if (isset($fd->itunes->owner['name'])) {
             $author = $fd->itunes->owner['name'];
         }
         if (isset($fd->itunes->owner['email'])) {
             $email = $fd->itunes->owner['email'];
         }
     }
     if (empty($author) && isset($fd->author)) {
         $author = $fd->author;
     }
     if (empty($email) && isset($fd->email)) {
         $email = $fd->email;
     }
     if (!empty($author) || !empty($email)) {
         $owner = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:owner');
         if (!empty($author)) {
             $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:name', $author);
             $owner->appendChild($node);
         }
         if (!empty($email)) {
             $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:email', $email);
             $owner->appendChild($node);
         }
         $root->appendChild($owner);
     }
     $image = '';
     if (isset($fd->itunes->image)) {
         $image = $fd->itunes->image;
     } elseif (isset($fd->image)) {
         $image = $fd->image;
     }
     if (!empty($image)) {
         $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:image');
         $node->setAttribute('href', $image);
         $root->appendChild($node);
     }
     $subtitle = '';
     if (isset($fd->itunes->subtitle)) {
         $subtitle = $fd->itunes->subtitle;
     } elseif (isset($fd->description)) {
         $subtitle = $fd->description;
     }
     if (!empty($subtitle)) {
         $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:subtitle', $subtitle);
         $root->appendChild($node);
     }
     $summary = '';
     if (isset($fd->itunes->summary)) {
         $summary = $fd->itunes->summary;
     } elseif (isset($fd->description)) {
         $summary = $fd->description;
     }
     if (!empty($summary)) {
         $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:summary', $summary);
         $root->appendChild($node);
     }
     if (isset($fd->itunes->block)) {
         $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:block', $fd->itunes->block);
         $root->appendChild($node);
     }
     if (isset($fd->itunes->explicit)) {
         $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:explicit', $fd->itunes->explicit);
         $root->appendChild($node);
     }
     if (isset($fd->itunes->keywords)) {
         $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:keywords', $fd->itunes->keywords);
         $root->appendChild($node);
     }
     if (isset($fd->itunes->new_feed_url)) {
         $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:new-feed-url', $fd->itunes->new_feed_url);
         $root->appendChild($node);
     }
     if (isset($fd->itunes->category)) {
         foreach ($fd->itunes->category as $i => $category) {
             $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:category');
             $node->setAttribute('text', $category['main']);
             $root->appendChild($node);
             $add_end_category = false;
             if (!empty($category['sub'])) {
                 $add_end_category = true;
                 $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:category');
                 $node->setAttribute('text', $category['sub']);
                 $root->appendChild($node);
             }
             if ($i > 0 || $add_end_category) {
                 $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:category');
                 $root->appendChild($node);
             }
         }
     }
 }
Beispiel #22
0
 /**
  * Add nodes to content node
  * @param $nodes
  */
 public function addNodes($nodes)
 {
     foreach ((array) $nodes as $node) {
         $this->_contentNode->appendChild($this->_document->importNode($node, true));
     }
 }
Beispiel #23
0
 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;
 }
Beispiel #24
0
 /**
  * Function that creates Message elements for WSDL1.1 in rpc style
  * @param DomDocument $svr_name DomDocument element of the wsdl  document
  * @param DomElement $svr_root service dom element
  */
 public function createRPCMessage(DomDocument $msg_doc, DomElement $msg_root, $class_to_prefix, $msg_ele_names_info)
 {
     $attr_name_to_postfix_map = array(WS_WSDL_Const::WS_WSDL_INPUT_ATTR_NAME => WS_WSDL_Const::WS_WSDL_OPERTION_INPUT_TAG, WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME => WS_WSDL_Const::WS_WSDL_OPERTION_OUTPUT_TAG);
     foreach ($this->operations as $op_name => $op_params) {
         $in_only = !array_key_exists(WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME, $msg_ele_names_info[$op_name]) || $msg_ele_names_info[$op_name][WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME] == NULL;
         if ($in_only) {
             $mep_patterns = array(WS_WSDL_Const::WS_WSDL_INPUT_ATTR_NAME);
         } else {
             $mep_patterns = array(WS_WSDL_Const::WS_WSDL_INPUT_ATTR_NAME, WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME);
         }
         foreach ($mep_patterns as $in_or_out) {
             $op_params3 = $op_params[$in_or_out];
             $el = $msg_doc->createElementNS(WS_WSDL_Const::WS_SCHEMA_WSDL_NAMESPACE, WS_WSDL_Const::WS_WSDL_MESSAGE_ATTR_NAME);
             foreach ($this->fun_mapping as $key => $value) {
                 if ($op_name == $value) {
                     $el->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, "{$key}" . ucfirst($attr_name_to_postfix_map[$in_or_out]));
                 }
             }
             if ($in_or_out == WS_WSDL_Const::WS_WSDL_INPUT_ATTR_NAME) {
                 foreach ($op_params3 as $name3 => $op_params4) {
                     $part = $msg_doc->createElementNS(WS_WSDL_Const::WS_SCHEMA_WSDL_NAMESPACE, WS_WSDL_Const::WS_WSDL_PART_ATTR_NAME);
                     foreach ($op_params4 as $name4 => $param5) {
                         if ($name4 == WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME) {
                             $part->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, $param5);
                         }
                         if ($name4 == WS_WSDL_Const::WS_WSDL_TYPE_ATTR_NAME) {
                             $xsd_type = $param5;
                             if ($op_params4["object"] == "object") {
                                 $prefix = $class_to_prefix[$xsd_type];
                                 $part->setAttribute(WS_WSDL_Const::WS_WSDL_TYPE_ATTR_NAME, $prefix . ":" . $param5);
                             } else {
                                 $part->setAttribute(WS_WSDL_Const::WS_WSDL_TYPE_ATTR_NAME, WS_WSDL_Const::WS_WSDL_XSD_ATTR_NAME . $param5);
                             }
                         }
                         $el->appendChild($part);
                     }
                 }
             }
             if ($in_or_out == WS_WSDL_Const::WS_WSDL_OUTPUT_ATTR_NAME) {
                 foreach ($op_params3 as $name3 => $op_params4) {
                     $part = $msg_doc->createElementNS(WS_WSDL_Const::WS_SCHEMA_WSDL_NAMESPACE, WS_WSDL_Const::WS_WSDL_PART_ATTR_NAME);
                     foreach ($op_params4 as $name4 => $param5) {
                         if ($name4 == WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME) {
                             $part->setAttribute(WS_WSDL_Const::WS_WSDL_NAME_ATTR_NAME, $param5);
                         }
                         if ($name4 == WS_WSDL_Const::WS_WSDL_TYPE_ATTR_NAME) {
                             $xsd_type = $param5;
                             if ($op_params4["object"] == "object") {
                                 $prefix = $class_to_prefix[$xsd_type];
                                 $part->setAttribute(WS_WSDL_Const::WS_WSDL_TYPE_ATTR_NAME, $prefix . ":" . $param5);
                             } else {
                                 $part->setAttribute(WS_WSDL_Const::WS_WSDL_TYPE_ATTR_NAME, WS_WSDL_Const::WS_WSDL_XSD_ATTR_NAME . $param5);
                             }
                         }
                         $el->appendChild($part);
                     }
                 }
             }
             $msg_root->appendChild($el);
         }
     }
 }
 protected static function createPathElement(DOMDocument $xml, \DomElement $targetNode, $path)
 {
     $pathnode = $xml->createElement("path-element");
     $pathtext = $xml->createTextNode($path);
     $pathnode->appendChild($pathtext);
     $targetNode->appendChild($pathnode);
 }
 /**
  * 
  * Creates a new node in the given DomDocument xml under the root node with the values of the field (name and value)
  * @param DomDocumnet $xml
  * @param SimpleXmlElement $rootNode
  * @param unknown_type $value
  * @param string $fieldName
  * @param string $fieldType
  * @param string $fieldDbValue
  */
 private static function createFieldElement(DOMDocument $xml, DomElement $rootNode, $value, $fieldName, $fieldType = null, $fieldDbValue = null)
 {
     //If the value is not an array then we just create the element and sets it's value
     if (!is_array($value)) {
         $node = $xml->createElement($fieldName, $value);
         if ($fieldType !== null) {
             $node->setAttribute("type", $fieldType);
         }
         if ($fieldDbValue != null) {
             $node->setAttribute("dbValue", $fieldDbValue);
         }
         $rootNode->appendChild($node);
     } else {
         //create the array node
         $arrayNode = $xml->createElement("Array");
         foreach ($value as $key => $singleValue) {
             $node = $xml->createElement($fieldName, $singleValue);
             if ($fieldType != null) {
                 $node->setAttribute("type", $fieldType);
             }
             if ($fieldDbValue != null) {
                 $dbValue = null;
                 if (isset($fieldDbValue[$key])) {
                     $dbValue = $fieldDbValue[$key];
                 }
                 $node->setAttribute("dbValue", $dbValue);
             }
             $node->setAttribute("key", $key);
             $arrayNode->appendChild($node);
         }
         if (!$arrayNode->hasChildNodes()) {
             //we add the name of the property
             $node = $xml->createElement($fieldName, "");
             $arrayNode->appendChild($node);
         }
         $rootNode->appendChild($arrayNode);
     }
 }
 /**
  * Appends an element as a child to another element.
  * 
  * @param \DomElement $element
  * @param \DomElement $child
  * @throws SoapException\AppendChildException
  */
 public function appendChildToElement(\DomElement $element, \DomElement $child)
 {
     try {
         return $element->appendChild($child);
     } catch (\Exception $e) {
         throw new SoapException\AppendChildException(sprintf("Error appending element: [%s] %s", get_class($e), $e->getMessage()));
     }
 }
Beispiel #28
0
 /**
  * Adds a resumptionToken to a a listNode if the is a resumption token otherwise it does nothing
  * @param ResultListInterface $resultList
  * @param \DomElement $listNode
  */
 private function addResumptionToken(ResultListInterface $resultList, $listNode)
 {
     // @TODO Add support for expirationDate
     $resumptionTokenNode = null;
     if ($resultList->getResumptionToken()) {
         $resumptionTokenNode = $this->response->createElement('resumptionToken', $resultList->getResumptionToken());
     } elseif ($resultList->getCompleteListSize() !== null || $resultList->getCursor() !== null) {
         // An empty resumption token with attributes completeListSize and/or cursor.
         $resumptionTokenNode = $this->response->createElement('resumptionToken');
     }
     if ($resultList->getCompleteListSize() !== null) {
         $resumptionTokenNode->setAttribute('completeListSize', $resultList->getCompleteListSize());
     }
     if ($resultList->getCursor() !== null) {
         $resumptionTokenNode->setAttribute('cursor', $resultList->getCursor());
     }
     if ($resumptionTokenNode !== null) {
         $listNode->appendChild($resumptionTokenNode);
     }
 }