/** * 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); }
/** * @param $field * @param $value * @param $type * @param $ns * * @return $this */ private function setList($field, $value, $type, $ns) { $result = $this->xpath->query('//rdf:Description/' . $field . '/' . $type . '/rdf:li'); $parent = null; if ($result->length) { $parent = $result->item(0)->parentNode; // remove child nodes for ($i = 0; $i < $result->length; $i++) { $parent->removeChild($result->item($i)); } } else { // find the RDF description root $description = $this->getOrCreateRDFDescription($ns); // create the element and the rdf:Alt child $node = $this->dom->createElementNS($ns, $field); $parent = $this->dom->createElementNS(self::RDF_NS, $type); $description->appendChild($node); $node->appendChild($parent); } if (!$value || !is_array($value) && count($value) == 0) { // remove element $parent->parentNode->parentNode->removeChild($parent->parentNode); } else { foreach ((array) $value as $item) { $node = $this->dom->createElementNS(self::RDF_NS, 'rdf:li'); $node->appendChild($this->dom->createTextNode($item)); if ($type == 'rdf:Alt') { $node->setAttribute('xml:lang', 'x-default'); } $parent->appendChild($node); } } $this->hasChanges = true; return $this; }
/** * Serialize an associative array of pci properties into a pci xml * * @param array $properties * @param string $ns * @return string */ private function serializePortableProperties($properties, $ns = '', $nsUri = '', $name = null, $element = null) { $document = null; $result = ''; if ($element === null) { $document = new \DomDocument(); $element = $ns ? $document->createElementNS($nsUri, $ns . ':properties') : $document->createElement('properties'); $document->appendChild($element); } else { $newElement = $ns ? $element->ownerDocument->createElementNS($nsUri, $ns . ':properties') : $element->ownerDocument->createElement('properties'); $element->appendChild($newElement); $element = $newElement; } if ($name !== null) { $element->setAttribute('key', $name); } foreach ($properties as $name => $value) { if (is_array($value)) { $this->serializePortableProperties($value, $ns, $nsUri, $name, $element); } else { $entryElement = $ns ? $element->ownerDocument->createElementNS($nsUri, $ns . ':entry') : $element->ownerDocument->createElementNS('entry'); $entryElement->setAttribute('key', $name); $entryElement->appendChild(new \DOMText($value)); $element->appendChild($entryElement); } } if ($document !== null) { foreach ($document->childNodes as $node) { $result .= $document->saveXML($node); } } return $result; }
/** * 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, $extra, $operations) { $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); } } //----SIU: INICO if (isset($operations[$name]['documentation'])) { $part = $port_doc->createElementNS(WS_WSDL_Const::WS_SCHEMA_WSDL_NAMESPACE, "documentation"); $part->nodeValue = $operations[$name]['documentation']; $operation->appendChild($part); } //----SIU: FIN // 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); }
/** * Creates the wsdl document for WSDL1.1 */ private function buildWsdlDom() { $wsdl_dom = new DomDocument(WS_WSDL_Const::WS_DOM_DOCUMENT_VERSION_NO, WS_WSDL_Const::WS_DOM_DOCUMENT_ENCODING); $wsdl_root_ele = $wsdl_dom->createElementNS(WS_WSDL_const::WS_SCHEMA_WSDL_NAMESPACE, WS_WSDL_const::WS_WSDL_DEFINITION); $wsdl_dom->appendChild($wsdl_root_ele); $wsdl_root_ele->setAttributeNS(WS_WSDL_const::WS_WSDL_DEF_SCHEMA_URI, WS_WSDL_const::WS_WSDL_DEF_XSD_QN, WS_WSDL_const::WS_SOAP_XML_SCHEMA_NAMESPACE); $wsdl_root_ele->setAttributeNS(WS_WSDL_const::WS_WSDL_DEF_SCHEMA_URI, WS_WSDL_const::WS_WSDL_DEF_TNS_QN, $this->namespace); $wsdl_root_ele->setAttributeNS(WS_WSDL_const::WS_WSDL_DEF_SCHEMA_URI, WS_WSDL_const::WS_WSDL_DEF_ELEMENT_PREFIX, $this->namespace . WS_WSDL_Const::WS_WSDL_DEF_ELEMENT_NS_POSTFIX); $wsdl_root_ele->setAttributeNS(WS_WSDL_const::WS_WSDL_DEF_SCHEMA_URI, WS_WSDL_const::WS_WSDL_DEF_SOAP_ENV_QN, WS_WSDL_const::WS_SCHEMA_SOAP_NAMESPACE); $wsdl_root_ele->setAttributeNS(WS_WSDL_const::WS_WSDL_DEF_SCHEMA_URI, WS_WSDL_const::WS_WSDL_DEF_WSDL_QN, WS_WSDL_const::WS_SCHEMA_WSDL_NAMESPACE); $wsdl_root_ele->setAttributeNS(WS_WSDL_const::WS_WSDL_DEF_SCHEMA_URI, WS_WSDL_const::WS_WSDL_DEF_SOAP_ENC_QN, WS_WSDL_const::WS_SOAP_SCHEMA_ENCODING_NAMESPACE); $wsdl_root_ele->setAttributeNS(WS_WSDL_const::WS_WSDL_DEF_SCHEMA_URI, WS_WSDL_const::WS_WSDL_DEF_HTTP_QN, WS_WSDL_const::WS_WSDL_HTTP12_NAMESPACE); $wsdl_root_ele->setAttribute("xmlns:" . WS_WSDL_Const::WS_WSDL_WSAW_PREFIX, WS_WSDL_Const::WS_WSDL_WSAW_NAMESPACE); $wsdl_root_ele->setAttribute(WS_WSDL_const::WS_WSDL_DEF_TARGET_NS, $this->namespace); if (!$this->annotations) { // we infer doc comments only when annotations are not provided as an array $oper_obj = new WS_WSDL_Operations($this->f_arry, $this->class_arry); $schemaTypes = $oper_obj->getSchemaTypes(); $operations = $oper_obj->operations; } if ($this->Binding_style == WS_WSDL_Const::WSF_WSDL_DOCLIT) { $type_obj = new WS_WSDL_Type($this->namespace, $this->ops_to_functions, $this->classmap); if ($this->annotations) { $ele_names_info = $type_obj->createDocLitTypeWithAnnotations($wsdl_dom, $wsdl_root_ele, $this->annotations); $operations = $ele_names_info; $this->classmap = array(0); //should just go with the classmap behaviour } else { $ele_names_info = $type_obj->createDocLitType($wsdl_dom, $wsdl_root_ele, $schemaTypes); } $msg_obj = new WS_WSDL_Message($operations, $this->ops_to_functions, $this->classmap); $msg_obj->createDocLitMessage($wsdl_dom, $wsdl_root_ele, $ele_names_info); } if ($this->Binding_style == WS_WSDL_Const::WSF_WSDL_RPC) { $type_obj = new WS_WSDL_Type($this->namespace, $this->ops_to_functions, $this->classmap); // class to prefix will be filled from the following function call $class_to_prefix = array(); /* no types for the time being */ $ele_names_info = $type_obj->createRPCType($wsdl_dom, $wsdl_root_ele, $class_to_prefix, $schemaTypes); $msg_obj = new WS_WSDL_Message($operations, $this->ops_to_functions, $this->classmap); $msg_obj->createRPCMessage($wsdl_dom, $wsdl_root_ele, $class_to_prefix, $ele_names_info); } $port_obj = new WS_WSDL_Port($this->service_name, $ele_names_info, $this->ops_to_functions, $this->use_wsa, $this->r_actions); $port_obj->createPortType($wsdl_dom, $wsdl_root_ele, $ele_names_info, $operations); if ($this->Binding_style == WS_WSDL_Const::WSF_WSDL_DOCLIT) { $bind_obj = new WS_WSDL_Binding($this->service_name, $this->endpoint, $ele_names_info, $this->ops_to_functions, $this->r_actions); $bind_obj->createDocLitBinding($wsdl_dom, $wsdl_root_ele, $ele_names_info); } if ($this->Binding_style == WS_WSDL_Const::WSF_WSDL_RPC) { $bind_obj = new WS_WSDL_Binding($this->service_name, $this->endpoint, $ele_names_info, $this->ops_to_functions, $this->r_actions); $bind_obj->createRPCBinding($wsdl_dom, $wsdl_root_ele); } $svr_obj = new WS_WSDL_Service($this->service_name, $this->endpoint); $svr_obj->createService($wsdl_dom, $wsdl_root_ele); return $wsdl_dom->saveXML(); }
/** * Create a new element * * @param string $name * @param string $value * @param string $namespace * @return object $this */ public function element($name, $value = null, $namespace = null) { $element = $namespace ? $this->dom->createElementNS($namespace, $name) : $this->dom->createElement($name); $this->current->appendChild($element); $this->current = $element; if (null !== $value) { $this->text($value); } return $this; }
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); }
/** * Prepare DOM * * @return void */ private function prepareDom() { $this->dom = new \DOMDocument('1.0', 'UTF-8'); if ($this->debug) { $this->dom->formatOutput = true; } $this->wsDefinitions = $this->dom->createElementNS($this->namespaces['wsdl'], 'wsdl:definitions'); $this->dom->appendChild($this->wsDefinitions); $this->wsDefinitions->setAttribute('name', $this->wsdlName); $this->wsDefinitions->setAttribute('targetNamespace', $this->wsdlTargetNamespace); $this->dom->createAttributeNS($this->wsdlTargetNamespace, $this->targetNsPrefix . ':definitions'); // This NS $this->common->dom = $this->dom; }
/** * Serialize this object to XML and return it. */ function as_xml($with_preamble = FALSE) { $dc_xml = new DomDocument(); $oai_dc = $dc_xml->createElementNS('http://www.openarchives.org/OAI/2.0/oai_dc/', 'oai_dc:dc'); $oai_dc->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); foreach ($this->dc as $dc_element => $values) { if (is_array($values) && !empty($values)) { foreach ($values as $value) { $new_item = $dc_xml->createElement($dc_element, $value); $oai_dc->appendChild($new_item); } } else { $new_item = $dc_xml->createElement($dc_element); $oai_dc->appendChild($new_item); } } $dc_xml->appendChild($oai_dc); return $dc_xml->saveXML(); }
/** * Add the service definition * @param DomDocument $dom The document to add to */ protected function addService(DomDocument $dom) { $service = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:service'); $service->setAttribute('name', $this->serviceName . 'Service'); $port = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:port'); $port->setAttribute('name', $this->serviceName . 'Port'); $port->setAttribute('binding', 'tns:' . $this->serviceName . 'Binding'); $soapAddress = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:address'); $soapAddress->setAttribute('location', $this->serviceUri); $port->appendChild($soapAddress); $service->appendChild($port); $this->definitions->appendChild($service); }
$hdrReq['phone_03'] = FALSE; $hdrReq['mobile_03'] = FALSE; // not used $hdrReq['fax_03'] = FALSE; // not used $hdrReq['other_03'] = FALSE; // not used // Open csv to read $inputFile = fopen($inputFilename, 'rt'); // Get the headers of the file $headers = fgetcsv($inputFile); // Create a new dom document with pretty formatting $xmlDoc = new DomDocument('1.0', 'UTF-8'); $xmlDoc->formatOutput = true; // create root node $root = $xmlDoc->createElementNS('http://com/exlibris/digitool/repository/extsystem/xmlbeans', 'users'); $xmlDoc->appendChild($root); $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $counter = 0; $errCtr = 0; $todayDate = date('Ymd'); // Loop through each row creating a <row> node with the correct data while (($row = fgetcsv($inputFile)) !== FALSE) { $userGroup = ""; $status = NULL; $creationDate = NULL; $expiryDate = NULL; $userIdentifiers = NULL; $primary_id = NULL; $statisticalCategory = NULL; $name_type = NULL;
function gglstmp_sitemapcreate() { global $wpdb, $gglstmp_settings; $str_post_type = ""; foreach ($gglstmp_settings['post_type'] as $val) { if ($str_post_type != "") { $str_post_type .= ", "; } $str_post_type .= "'" . $val . "'"; } $taxonomies = array(); foreach ($gglstmp_settings['taxonomy'] as $val) { $taxonomies[] = $val; } $xml = new DomDocument('1.0', 'utf-8'); $xml_stylesheet_path = defined('WP_CONTENT_DIR') ? home_url('/') . basename(WP_CONTENT_DIR) : home_url('/') . 'wp-content'; $xml_stylesheet_path .= defined('WP_PLUGIN_DIR') ? '/' . basename(WP_PLUGIN_DIR) . '/google-sitemap-plugin/sitemap.xsl' : '/plugins/google-sitemap-plugin/sitemap.xsl'; $xslt = $xml->createProcessingInstruction('xml-stylesheet', "type=\"text/xsl\" href=\"{$xml_stylesheet_path}\""); $xml->appendChild($xslt); $gglstmppr_urlset = $xml->appendChild($xml->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset')); if (!empty($str_post_type)) { $loc = $wpdb->get_results("SELECT `ID`, `post_modified` FROM {$wpdb->posts} WHERE `post_status` = 'publish' AND `post_type` IN (" . $str_post_type . ")"); if (!empty($loc)) { foreach ($loc as $val) { $gglstmppr_url = $gglstmppr_urlset->appendChild($xml->createElement('url')); $loc = $gglstmppr_url->appendChild($xml->createElement('loc')); $permalink = get_permalink($val->ID); $loc->appendChild($xml->createTextNode($permalink)); $lastmod = $gglstmppr_url->appendChild($xml->createElement('lastmod')); $now = $val->post_modified; $date = date('Y-m-d\\TH:i:sP', strtotime($now)); $lastmod->appendChild($xml->createTextNode($date)); $changefreq = $gglstmppr_url->appendChild($xml->createElement('changefreq')); $changefreq->appendChild($xml->createTextNode('monthly')); $priority = $gglstmppr_url->appendChild($xml->createElement('priority')); $priority->appendChild($xml->createTextNode(1.0)); } } } if (!empty($taxonomies)) { foreach ($taxonomies as $value) { $terms = get_terms($value, 'hide_empty=1'); if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term_value) { $gglstmppr_url = $gglstmppr_urlset->appendChild($xml->createElement('url')); $loc = $gglstmppr_url->appendChild($xml->createElement('loc')); $permalink = get_term_link((int) $term_value->term_id, $value); $loc->appendChild($xml->createTextNode($permalink)); $lastmod = $gglstmppr_url->appendChild($xml->createElement('lastmod')); $now = $wpdb->get_var("SELECT `post_modified` FROM {$wpdb->posts}, {$wpdb->term_relationships} WHERE `post_status` = 'publish' AND `term_taxonomy_id` = " . $term_value->term_taxonomy_id . " AND {$wpdb->posts}.ID= {$wpdb->term_relationships}.object_id ORDER BY `post_modified` DESC"); $date = date('Y-m-d\\TH:i:sP', strtotime($now)); $lastmod->appendChild($xml->createTextNode($date)); $changefreq = $gglstmppr_url->appendChild($xml->createElement('changefreq')); $changefreq->appendChild($xml->createTextNode('monthly')); $priority = $gglstmppr_url->appendChild($xml->createElement('priority')); $priority->appendChild($xml->createTextNode(1.0)); } } } } $xml->formatOutput = true; if (is_multisite()) { $home_url = preg_replace("/[^a-zA-ZА-Яа-я0-9\\s]/", "_", str_replace('http://', '', str_replace('https://', '', home_url()))); $xml->save(ABSPATH . 'sitemap_' . $home_url . '.xml'); } else { $xml->save(ABSPATH . 'sitemap.xml'); } gglstmp_sitemap_info(); }
function gglstmp_sitemapcreate() { global $wpdb; if (isset($_POST['gglstmp_settings'])) { $gglstmp_settings = $_POST['gglstmp_settings']; } else { global $gglstmp_settings; } $str = ""; foreach ($gglstmp_settings as $val) { if ($str != "") { $str .= ", "; } $str .= "'" . $val . "'"; } $xml = new DomDocument('1.0', 'utf-8'); $xml_stylesheet_path = plugins_url() . "/google-sitemap-plugin/sitemap.xsl"; $xslt = $xml->createProcessingInstruction('xml-stylesheet', "type=\"text/xsl\" href=\"{$xml_stylesheet_path}\""); $xml->appendChild($xslt); $urlset = $xml->appendChild($xml->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset')); if (!empty($str)) { $loc = $wpdb->get_results("SELECT ID, post_modified, post_status, post_type, ping_status FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type IN (" . $str . ")"); foreach ($loc as $val) { $url = $urlset->appendChild($xml->createElement('url')); $loc = $url->appendChild($xml->createElement('loc')); $permalink = get_permalink($val->ID); $loc->appendChild($xml->createTextNode($permalink)); $lastmod = $url->appendChild($xml->createElement('lastmod')); $now = $val->post_modified; $date = date('Y-m-d\\TH:i:sP', strtotime($now)); $lastmod->appendChild($xml->createTextNode($date)); $changefreq = $url->appendChild($xml->createElement('changefreq')); $changefreq->appendChild($xml->createTextNode('monthly')); $priority = $url->appendChild($xml->createElement('priority')); $priority->appendChild($xml->createTextNode(1.0)); } $xml->formatOutput = true; } if (is_multisite()) { $home_url = preg_replace("/[^a-zA-ZА-Яа-я0-9\\s]/", "_", str_replace('http://', '', str_replace('https://', '', home_url()))); $xml->save(ABSPATH . 'sitemap_' . $home_url . '.xml'); } else { $xml->save(ABSPATH . 'sitemap.xml'); } }
/** * Internal function used to add another inlude statement to a supplied * XSLT stylesheet. Include will be added at end of stylesheet. * * @param DomDocument $xsltStylesheet stylesheet to be modified * @param string $absoluteFilePath abs filepath of stylesheet to be imported */ private static function addIncludeReference($xsltStylesheet, $absoluteFilePath) { $include_element = $xsltStylesheet->createElementNS("http://www.w3.org/1999/XSL/Transform", "xsl:include"); $include_element->setAttribute("href", $absoluteFilePath); $xsltStylesheet->documentElement->appendChild($include_element); }
public static function getRelatedWords() { global $LINK_DB; $node_table = PWLemma::getTableName(); $edge_table = PWRelatedWords::getTableName(); // Construct DOM elements $xml = new DomDocument('1.0', 'UTF-8'); $xml->formatOutput = true; // Nicely formats output with indentation and extra space $gexf = $xml->createElementNS(null, 'gexf'); // Create new element node with an associated namespace $gexf = $xml->appendChild($gexf); // Assign namespaces for GexF with VIZ $gexf->setAttribute('xmlns:viz', 'http://www.gexf.net/1.1draft/viz'); // Skip if you don't need viz! $gexf->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $gexf->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation', 'http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd'); $gexf->setAttribute('version', '1.2'); // Add Meta data $meta = $gexf->appendChild($xml->createElement('meta')); $meta->setAttribute('lastmodifieddate', date('Y-m-d')); $meta->appendChild($xml->createElement('creator', 'PHP GEXF Generator v0.1')); $meta->appendChild($xml->createElement('description', 'Related words')); // Add Graph data! $graph = $gexf->appendChild($xml->createElement('graph')); $nodes = $graph->appendChild($xml->createElement('nodes')); $edges = $graph->appendChild($xml->createElement('edges')); // Add Nodes! $res_node = $LINK_DB->query_e("SELECT * FROM {$node_table} WHERE id in (select lemma_id1 from {$edge_table}) or id in (select lemma_id2 from {$edge_table}) order by id", "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>"); while ($row_node = $res_node->fetch_object()) { $node = $xml->createElement('node'); $node->setAttribute('id', $row_node->id); $node->setAttribute('label', $row_node->lemma); /* // Set color for node $color = $xml->createElement('viz:color'); $color->setAttribute('r', '1'); $color->setAttribute('g', '1'); $color->setAttribute('b', '1'); $node->appendChild($color); // Set position for node $position = $xml->createElement('viz:position'); $position->setAttribute('x', '1'); $position->setAttribute('y', '1'); $position->setAttribute('z', '1'); $node->appendChild($position); // Set size for node $size = $xml->createElement('viz:size'); $size->setAttribute('value', '1'); $node->appendChild($size); // Set shape for node $shape = $xml->createElement('viz:shape'); $shape->setAttribute('value', 'disc'); $node->appendChild($shape); */ $nodes->appendChild($node); } // Add Edges $res_relw = $LINK_DB->query_e("SELECT * FROM " . PWRelatedWords::getTableName() . " order by lemma_id1", "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>"); while ($row_relw = $res_relw->fetch_object()) { $edge = $xml->createElement('edge'); $edge->setAttribute('source', $row_relw->lemma_id1); $edge->setAttribute('target', $row_relw->lemma_id2); $edge->setAttribute('weight', $row_relw->weight); $edges->appendChild($edge); } return $xml->saveXML(); }
function _createDOM($action = "view") { $dom = new DomDocument('1.0', 'UTF-8'); if ($this->theme) { if (!$this->theme->hasAction($action)) { $this->err[] = "Whoops! Your current theme does not support the selected action!"; $action = "view"; } $xslt = $this->theme->xslFor($action); $xslt = $dom->createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"{$xslt}\""); $dom->appendChild($xslt); } $root = $dom->createElementNS(SGlossWiki::$NS, 'sgloss'); $dom->appendChild($root); $title = $dom->createElementNS(SGlossWiki::$NS, 'title'); $title->appendChild($dom->createTextNode($this->title)); $root->appendChild($title); foreach ($this->err as $msg) { $e = $dom->createElementNS(SGlossWiki::$NS, 'error'); $e->appendChild($dom->createTextNode($msg)); $root->appendChild($e); } foreach ($this->msg as $msg) { $e = $dom->createElementNS(SGlossWiki::$NS, 'message'); $e->appendChild($dom->createTextNode($msg)); $root->appendChild($e); } foreach ($this->warn as $msg) { $e = $dom->createElementNS(SGlossWiki::$NS, 'warning'); $e->appendChild($dom->createTextNode($msg)); $root->appendChild($e); } if (FALSE && $this->debug) { $node = $dom->createElementNS(SGlossWiki::$NS, 'debug'); $node->appendChild($dom->createTextNode(print_r($this->debug, 1))); $root->appendChild($node); } return $dom; }
/** * Add xlt include instuction to template document * @param DomDocument $xslTemplate */ protected function _addIncludedFiles(DomDocument $xslTemplate) { foreach ($this->_includes as $fileName) { foreach ($this->getScriptPaths() as $scriptPath) { $dir = realpath($scriptPath); $importFile = $dir . DIRECTORY_SEPARATOR . $fileName; if (file_exists($importFile)) { $xslIncludeNode = $xslTemplate->createElementNS('http://www.w3.org/1999/XSL/Transform', 'import'); $xslIncludeNode->setAttribute('href', $importFile); $xslTemplate->documentElement->insertBefore($xslIncludeNode, $xslTemplate->documentElement->firstChild); break; } } } }
/** * Overrides the method __doRequest(). When OAuth authentication is used * the URL has OAuth parameters added. * @param string $request the request XML * @param string $location the URL to request * @param string $action the SOAP action * @param string $version the SOAP version * @param int $one_way if set to 1, this method returns nothing * @return string the XML SOAP response */ function __doRequest($request, $location, $action, $version, $one_way = 0) { $dom = new DomDocument('1.0', 'UTF-8'); $dom->preserveWhiteSpace = false; $dom->loadXML($request); $hdr = $dom->createElementNS('http://schemas.xmlsoap.org/soap/envelope/', 'SOAP-ENV:Header'); $dom->documentElement->insertBefore($hdr, $dom->documentElement->firstChild); foreach ($this->headers as $element_name => $element_value) { $hdr_element = $hdr->appendChild($dom->createElement($element_name)); $hdr_element->appendChild($dom->createTextNode($element_value)); } $request = $dom->saveXML(); //$this->GenerateSoapHeader(); //echo 'YDirect::__doRequest(), $request = '; //var_dump($request); return SoapClient::__doRequest($request, $location, $action, $version); }
function xslfilter($buffer) { global $__xslfilter_debug; global $__xslfilter_phpfunc; global $__xslfilter_prehook; global $__xslfilter_posthook; global $__xslfilter_start_utime; global $__xslfilter_i18n; if (empty($buffer)) { return false; } if ($__xslfilter_debug) { return false; } libxml_use_internal_errors(true); if (!array_key_exists('WEB_LAYOUT', $_SERVER) && !array_key_exists('XSL_DIR', $_SERVER) && !array_key_exists('XSL_STYLESHEET', $_SERVER)) { return __xslfilter_do_error("Missing stylesheet information", "None of the environment variables <code>WEB_LAYOUT</code>, " . "<code>XSL_DIR</code> or <code>XSL_STYLESHEET</code> " . "have been defined"); } libxml_clear_errors(); // Load document $doc = new DOMDocument(); if (!$doc->loadXML($buffer, LIBXML_NONET)) { return __xslfilter_do_error("Error in current document", __xslfilter_build_xmlerrors(libxml_get_errors())); } // Processing instruction if ($r = __xslfilter_process_pi($doc)) { return $r; } // XSLT Processor $xslt = new xsltProcessor(); // Basic information $xslt->setParameter('', 'lastmod', gmstrftime("%Y%m%d%H%M%SZ", getlastmod())); $xslt->setParameter('', 'now', gmstrftime("%Y%m%d%H%M%SZ", time())); // Information about http request $xslt->setParameter('', 'http-referer', array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null); $xslt->setParameter('', 'request-uri', array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : null); $xslt->setParameter('', 'base-uri', array_key_exists('SCRIPT_FILENAME', $_SERVER) ? dirname($_SERVER['SCRIPT_FILENAME']) : null); $xslt->setParameter('', 'server-name', array_key_exists('SERVER_NAME', $_SERVER) ? $_SERVER['SERVER_NAME'] : null); $xslt->setParameter('', 'secure', array_key_exists('HTTPS', $_SERVER) ? 'true' : null); $xslt->setParameter('', 'protocol', array_key_exists('HTTPS', $_SERVER) ? 'https' : 'http'); if (($script_uri = parse_url($_SERVER['SCRIPT_URI'])) !== false) { $xslt->setParameter('', 'uri-scheme', @$script_uri['scheme']); $xslt->setParameter('', 'uri-host', @$script_uri['host']); $xslt->setParameter('', 'uri-port', @$script_uri['port']); $xslt->setParameter('', 'uri-path', @$script_uri['path']); $xslt->setParameter('', 'uri-query', @$script_uri['query']); $xslt->setParameter('', 'uri-fragment', @$script_uri['fragment']); } else { $xslt->setParameter('', 'uri-scheme', null); $xslt->setParameter('', 'uri-host', null); $xslt->setParameter('', 'uri-port', null); $xslt->setParameter('', 'uri-path', null); $xslt->setParameter('', 'uri-query', null); $xslt->setParameter('', 'uri-fragment', null); } // Parameters set from apache server $xslt->setParameter('', 'pagedesc-default-xml', array_key_exists('WEB_LAYOUT', $_SERVER) ? $_SERVER['WEB_LAYOUT'] . '/defaults.xml' : null); $xslt->setParameter('', 'expect-lang', array_key_exists('expect-lang', $_SERVER) ? $_SERVER['expect-lang'] : null); $xslt->setParameter('', 'handheld-client', array_key_exists('handheld-client', $_SERVER) ? $_SERVER['handheld-client'] : null); // Pre hook if (!is_null($__xslfilter_prehook) && ($r = $__xslfilter_prehook($doc, $xslt)) !== true) { return $r; } // PHP function enabling if ($__xslfilter_phpfunc) { $xslt->registerPHPFunctions(is_array($__xslfilter_phpfunc) ? $__xslfilter_phpfunc : null); } // Lang to import localization templates $lang = ''; if ($__xslfilter_i18n === null || $__xslfilter_i18n) { $lang = $doc->documentElement->getAttribute('lang'); } if (empty($lang) && !is_null($__xslfilter_i18n) && is_string($__xslfilter_i18n)) { $lang = $__xslfilter_i18n; } // Listing stylesheet $stylesheet = array(); if (array_key_exists('WEB_LAYOUT', $_SERVER) || array_key_exists('XSL_DIR', $_SERVER)) { $xsl_dir = array_key_exists('XSL_DIR', $_SERVER) ? $_SERVER['XSL_DIR'] : $_SERVER['WEB_LAYOUT']; $style = __xslfilter_get_stylesheet($doc, 'text/xsl'); foreach ($style as $s) { if (!($href = $s['href'])) { continue; } if ($href[0] == '/' || preg_match('|^\\w+://|', $href)) { return __xslfilter_do_error("Error in current document", "Only local and relative stylesheet are allowed"); } $stylesheet[] = $xsl_dir . '/' . $href; } if (empty($stylesheet) && array_key_exists('XSL_STYLESHEET', $_SERVER)) { $href = $_SERVER['XSL_STYLESHEET']; if ($href[0] != '/') { array_push($stylesheet, $xsl_dir . '/' . $href); } } if (!empty($lang)) { $href = 'l10n/' . $lang . '.xsl'; if (file_exists($file = $xsl_dir . '/' . $href)) { $stylesheet[] = $file; } } } else { if (array_key_exists('XSL_STYLESHEET', $_SERVER)) { array_push($stylesheet, $_SERVER['XSL_STYLESHEET']); if (!empty($lang)) { $file = dirname($_SERVER['XSL_STYLESHEET']) . '/' . 'l10n/' . $lang . '.xsl'; if (file_exists($file)) { $stylesheet[] = $file; } } } else { return __xslfilter_do_error("No usable stylesheet", "Missing stylesheet at server and document level"); } } // Importing stylesheet if (count($stylesheet) <= 1) { // Correct code for importing stylesheet // Unfortunately PHP only take into account the last import foreach ($stylesheet as $file) { libxml_clear_errors(); $xsl = new DomDocument(); $xsl->substituteEntities = true; // LIBXML_NOENT if (!$xsl->load($file, LIBXML_NONET)) { return __xslfilter_do_error("Error in stylesheet: {$href}", __xslfilter_build_xmlerrors(libxml_get_errors())); } $xslt->importStyleSheet($xsl); } } else { // Fix code to import several stysheets // By faking a top level stylesheet with import statements libxml_clear_errors(); $xsl = new DomDocument('1.0'); $xsl->substituteEntities = true; // LIBXML_NOENT $root = $xsl->createElementNS('http://www.w3.org/1999/XSL/Transform', 'xsl:stylesheet'); $v = $xsl->createAttribute('version'); $v->value = "1.0"; $root->appendChild($v); $xsl->appendChild($root); foreach ($stylesheet as $file) { $s = $xsl->createElementNS('http://www.w3.org/1999/XSL/Transform', 'xsl:import'); $h = $xsl->createAttribute('href'); $h->value = $file; $s->appendChild($h); $root->appendChild($s); } $xslt->importStyleSheet($xsl); } // Applying transformation $r = $xslt->transformToXML($doc); if ($errors = libxml_get_errors()) { return __xslfilter_do_error("Error while rendering document", __xslfilter_build_xmlerrors($errors)); } // Something wrong, but we have no clue if ($r == false) { return __xslfilter_do_error("Error while rendering document", "Check document and associated stylesheets"); } // Job's done return $r; }
/** * Build the binding operations. * TODO: Still quite incomplete with all the things being stuck in, I don't understand * a lot of it, and it's mostly copied from the output of nusoap's wsdl output. * @param DomDocument $dom The dom document to create the binding as children of * @param string $namespace The namespace this binding is in. * @return DomElement The dom element representing this binding. */ public function getBindingOperation(DomDocument $dom, $namespace, $style = 'rpc') { $operation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:operation'); $operation->setAttribute('name', $this->operationName); $soapOperation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:operation'); $method = $this->operationName; $soapOperation->setAttribute('soapAction', $namespace . '#' . $method); $soapOperation->setAttribute('style', $style); $input = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:input'); $output = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:output'); $soapBody = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:body'); $soapBody->setAttribute('use', 'encoded'); $soapBody->setAttribute('namespace', $namespace); $soapBody->setAttribute('encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/'); $input->appendChild($soapBody); $output->appendChild(clone $soapBody); $operation->appendChild($soapOperation); $operation->appendChild($input); $operation->appendChild($output); return $operation; }
/** * 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); } } } } }
/** * Remove property * * @param string $path * @param string $name * @param string $namespaceUri */ public function removeProperty($path, $name, $namespaceUri = null) { $client = $this->getHttpClient($path); if ($namespaceUri === null) { $namespaceUri = 'DAV:'; } // Create request $dom = new DomDocument('1.0', 'UTF-8'); $root = $dom->createElementNS('DAV:', 'D:propertyupdate'); $set = $dom->createElementNS('DAV:', 'D:remove'); $prop = $dom->createElementNS('DAV', 'D:prop'); $item = $dom->createElementNS($namespaceUri, $name); $prop->appendChild($item); $set->appendChild($prop); $root->appendChild($set); $dom->appendChild($root); $client->setRawData($dom->saveXML()); $response = $client->request('PROPPATCH'); if ($response->isError()) { require_once 'Zym/WebDav/Client/Exception.php'; throw new Zym_WebDav_Client_Exception($response->getStatus() . ' ' . $response->getMessage()); } $client->setHeaders(array(self::DEPTH => null)) ->setRawData(null); // Parse multistatus to ensure success $return = $this->_parsePropPatch($response->getBody()); foreach ($return as $href) { foreach ($href as $prop => $propStatus) { if ($prop == $name) { $statusCode = $this->_extractCode($propStatus); if ($statusCode == 200) { return; } $statusMessage = $this->_extractMessage($propStatus); require_once 'Zym/WebDav/Client/Exception.php'; throw new Zym_WebDav_Client_Exception($statusCode. ' ' . $statusMessage); } } } require_once 'Zym/WebDav/Client/Exception.php'; throw new Zym_WebDav_Client_Exception(sprintf('Property "%s" could not be removed', $name)); }
/** * Returns a DOM structure of the content object and it's attributes. * * Transaction unsafe. If you call several transaction unsafe methods you must enclose * the calls within a db transaction; thus within db->begin and db->commit. * * @param mixed $package * @param int|bool $specificVersion Content object version, true for current version, false for all, else array containing specific versions. * @param array|bool $options Package options or false * @param int[]|bool $contentNodeIDArray Array of allowed nodes or false * @param int[]|bool $topNodeIDArray Array of top nodes in current package export or false * @return bool|DOMElement */ function serialize( $package, $specificVersion = false, $options = false, $contentNodeIDArray = false, $topNodeIDArray = false ) { if ( $options && $options['node_assignment'] == 'main' ) { if ( !isset( $contentNodeIDArray[$this->attribute( 'main_node_id' )] ) ) { return false; } } $dom = new DomDocument(); $objectNode = $dom->createElementNS( 'http://ez.no/ezobject', 'ezremote:object' ); $objectNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:id', $this->ID ); $objectNode->setAttribute( 'name', $this->Name ); $objectNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:section_id', $this->SectionID ); $objectNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:owner_id', $this->OwnerID ); $objectNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:class_id', $this->ClassID ); $objectNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:published', eZDateUtils::rfc1123Date( $this->attribute( 'published' ) ) ); $objectNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:modified', eZDateUtils::rfc1123Date( $this->attribute( 'modified' ) ) ); if ( !$this->attribute( 'remote_id' ) ) { $this->setAttribute( 'remote_id', eZRemoteIdUtility::generate( 'object' ) ); $this->store(); } $objectNode->setAttribute( 'remote_id', $this->attribute( 'remote_id' ) ); $contentClass = $this->attribute( 'content_class' ); $objectNode->setAttribute( 'class_remote_id', $contentClass->attribute( 'remote_id' ) ); $objectNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:class_identifier', $contentClass->attribute( 'identifier' ) ); $alwaysAvailableText = '0'; if ( (int)$this->attribute( 'language_mask' ) & 1 ) { $alwaysAvailableText = '1'; } $objectNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:always_available', $alwaysAvailableText ); $versions = array(); $oneLanguagePerVersion = false; if ( $specificVersion === false ) { $versions = $this->versions(); // Since we are exporting all versions it should only contain // one language per version //$oneLanguagePerVersion = true; // uncomment to get one language per version } else if ( $specificVersion === true ) { $versions[] = $this->currentVersion(); } else { $versions[] = $this->version( $specificVersion ); // Since we are exporting a specific version it should only contain // one language per version? $oneLanguagePerVersion = true; } $this->fetchClassAttributes(); $exportedLanguages = array(); $versionsNode = $dom->createElementNS( 'http://ez.no/object/', 'ezobject:version-list' ); $versionsNode->setAttribute( 'active_version', $this->CurrentVersion ); foreach ( $versions as $version ) { if ( !$version ) { continue; } $options['only_initial_language'] = $oneLanguagePerVersion; $versionNode = $version->serialize( $package, $options, $contentNodeIDArray, $topNodeIDArray ); if ( $versionNode ) { $importedVersionNode = $dom->importNode( $versionNode, true ); $versionsNode->appendChild( $importedVersionNode ); foreach ( $versionNode->getElementsByTagName( 'object-translation' ) as $versionNodeChild ) { $exportedLanguage = $versionNodeChild->getAttribute( 'language' ); $exportedLanguages[] = $exportedLanguage; $exportedLanguages = array_unique( $exportedLanguages ); } } unset( $versionNode ); unset( $versionNode ); } $initialLanguageCode = $this->attribute( 'initial_language_code' ); if ( in_array( $initialLanguageCode, $exportedLanguages ) ) { $objectNode->setAttribute( 'initial_language', $initialLanguageCode ); } $objectNode->appendChild( $versionsNode ); return $objectNode; }
/** * Internal function used to add another inlude statement to a supplied * XSLT stylesheet. Include will be added at end of stylesheet. * * @param DomDocument $xsltStylesheet stylesheet to be modified * @param string $absoluteFilePath abs filepath of stylesheet to be imported */ private function addIncludeReference($xsltStylesheet, $absoluteFilePath) { $absoluteFilePath = str_replace('\\', '/', $absoluteFilePath); // darn windows $include_element = $xsltStylesheet->createElementNS("http://www.w3.org/1999/XSL/Transform", "xsl:include"); $include_element->setAttribute("href", $absoluteFilePath); $xsltStylesheet->documentElement->appendChild($include_element); }
/** * get Metadata of epub * @param string $epub File reference * @return ebook ebook with metadata filled in */ public function get_meta($epub) { $zip = new ZipArchive(); if ($zip->open($epub) === TRUE) { $container = simplexml_load_string($zip->getFromName(ebook::CONTAINER)); // $rootfile = $container->rootfiles->rootfile['full-path']; $rootfile = $this->get_metafile($zip); $path = dirname($rootfile); $this->path = $path != '.' ? $path . '/' : ''; $xml = simplexml_load_string($zip->getFromName($rootfile), 'SimpleXMLElement', LIBXML_NSCLEAN)->children('http://www.idpf.org/2007/opf'); $opf = $xml->metadata; $meta = $opf->children('http://purl.org/dc/elements/1.1/'); $this->title = (string) $meta->title[0]; $this->author = (string) $meta->creator[0]; $this->sortauthor = strtolower($this->author); $this->tags = (array) $meta['subject']; $this->summary = (string) $meta->description[0]; if ($this->summary == '') { $this->summary = "No summary for this book yet."; } $this->allmeta = $meta; //$this->cover = $this->is_cover($zip, $epub); $this->create_id(); // test with DOM $dom = new DomDocument(); $dom->loadXML($zip->getFromName($rootfile)); $meta = $dom->getElementsByTagName('metadata')->item(0); $this->title = $meta->getElementsByTagName('title')->item(0)->nodeValue; $this->author = $meta->getElementsByTagName('creator')->item(0)->nodeValue; $this->summary = $meta->getElementsByTagName('description')->item(0)->nodeValue; $taglist = $dom->getElementsByTagName('subject'); foreach ($taglist as $id => $tagnode) { $this->tags[$id] = $tagnode->nodeValue; } while ($taglist->length > 0) { $meta->removeChild($taglist->item(0)); } foreach ($this->tags as $id => $tag) { $meta->appendChild($dom->createElementNS('http://purl.org/dc/elements/1.1/', 'dc:subject', $tag)); } $this->allmeta = $dom; $manifest = $dom->getElementsByTagName('manifest')->item(0); foreach ($manifest->getElementsByTagName('item') as $id => $node) { $this->manifest[$node->getAttribute('id')] = $node->getAttribute('href'); $this->lookup[$node->getAttribute('href')] = $node->getAttribute('id'); } $spine = $dom->getElementsByTagName('spine')->item(0); foreach ($spine->getElementsByTagName('itemref') as $id => $node) { $this->spine[$node->getAttribute('idref')] = $this->manifest[$node->getAttribute('idref')]; } // toc $toc = new DomDocument(); $toc->loadXML($zip->getFromName($this->path . $this->manifest['ncx'])); $navlist = $toc->getElementsByTagName('navPoint'); foreach ($navlist as $id => $navpoint) { $label = $navpoint->getElementsByTagName('navLabel')->item(0)->getElementsByTagName('text')->item(0)->nodeValue; $src = $navpoint->getElementsByTagName('content')->item(0)->getAttribute('src'); $this->toc[$label] = $src; } $zip->close(); return $this; } else { return 'failed'; } }
/** * Add a relationship string to this object's RELS-EXT. * does not support rels-int yet. * @param string $relationship * @param <type> $object */ function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI) { $ds_list = $this->get_datastreams_list_as_array(); if (empty($ds_list['RELS-EXT'])) { $this->add_datastream_from_string(' <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="info:fedora/' . $this->pid . '"> </rdf:Description> </rdf:RDF>', 'RELS-EXT', 'Fedora object-to-object relationship metadata', 'text/xml', 'X'); } $relsext = $this->get_datastream_dissemination('RELS-EXT'); if (substr($object, 0, 12) != 'info:fedora/') { $object = "info:fedora/{$object}"; } $relsextxml = new DomDocument(); $relsextxml->loadXML($relsext); $description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description')->item(0); // Create the new relationship node. $newrel = $relsextxml->createElementNS($namespaceURI, $relationship); $newrel->setAttribute('rdf:resource', $object); $description->appendChild($newrel); $this->modify_datastream_by_value($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml'); //print ($description->dump_node()); /*$params = array( 'pid' => $this->pid, 'relationship' => $relationship, 'object' => $object, 'isLiteral' => FALSE, 'datatype' => '', ); return $this->soap_call( 'addRelationship', $params ); */ }
/** * @param \DomDocument $dom * @param \DomElement $parentNode * @param string $uri */ protected function createCompetencyFrameworkIncludesNode(\DomDocument $dom, \DomElement $parentNode, $uri) { $includesNode = $dom->createElementNS('http://ns.medbiq.org/competencyframework/v1/', 'cf:Includes'); $parentNode->appendChild($includesNode); $catalogNode = $dom->createElementNS('http://ns.medbiq.org/competencyframework/v1/', 'cf:Catalog', 'URI'); $includesNode->appendChild($catalogNode); $entryNode = $dom->createElementNS('http://ns.medbiq.org/competencyframework/v1/', 'cf:Entry', $uri); $includesNode->appendChild($entryNode); }
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); } }
function metaCreateDomDocument($xmlFilename) { $dom = new DomDocument('1.0', 'utf-8'); $lom = $dom->appendChild($dom->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'lom')); $lom->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $lom->setAttribute('xsi:schemaLocation', 'http://ltsc.ieee.org/xsd/LOM ity.xsd'); // end of lom $general = $lom->appendChild($dom->createElement('general')); $identifier = $general->appendChild($dom->createElement('identifier')); $catalog = $identifier->appendChild($dom->createElement('catalog', 'URL')); $entry = $identifier->appendChild($dom->createElement('entry', $_POST['meta_filename'])); $title = $general->appendChild($dom->createElement('title')); $langstring = $title->appendChild($dom->createElement('string', htmlspecialchars($_POST['meta_title'], ENT_QUOTES, 'utf-8'))); $langstring->setAttribute('language', $_POST['meta_language']); $general->appendChild($dom->createElement('language', $_POST['meta_language'])); $description = $general->appendChild($dom->createElement('description')); $langstring = $description->appendChild($dom->createElement('string', htmlspecialchars($_POST['meta_description'], ENT_QUOTES, 'utf-8'))); $langstring->setAttribute('language', $_POST['meta_language']); metaLangStringLoop($dom, $general, $_POST['meta_language'], 'keyword', $_POST['meta_keywords']); // end of general $lifecycle = $lom->appendChild($dom->createElement('lifeCycle')); $contribute = $lifecycle->appendChild($dom->createElement('contribute')); metaSimpleLoop($dom, $contribute, 'entity', $_POST['meta_author']); // end of lifeCycle $metaMetadata = $lom->appendChild($dom->createElement('metaMetadata')); $contribute = $metaMetadata->appendChild($dom->createElement('contribute')); $entity = $contribute->appendChild($dom->createElement('entity', $_SESSION['givenname'] . " " . $_SESSION['surname'])); $date = $contribute->appendChild($dom->createElement('date')); $dateTime = $date->appendChild($dom->createElement('dateTime', date('Y-m-d'))); // end of metametadata $technical = $lom->appendChild($dom->createElement('technical')); $format = $technical->appendChild($dom->createElement('format', $_POST['meta_mimetype'])); // end of technical $educational = $lom->appendChild($dom->createElement('educational')); if (isset($_POST['meta_learningresourcetype'])) { metaSourceValueArrayLoop($dom, $educational, 'learningResourceType', $_POST['meta_learningresourcetype']); } if (isset($_POST['meta_intendedenduserrole'])) { metaSourceValueArrayLoop($dom, $educational, 'intendedEndUserRole', $_POST['meta_intendedenduserrole']); } if (isset($_POST['meta_level'])) { metaSourceValueArrayLoop($dom, $educational, 'context', $_POST['meta_level']); } metaLangStringLoop($dom, $educational, $_POST['meta_language'], 'typicalAgeRange', $_POST['meta_typicalagerange']); $description = $educational->appendChild($dom->createElement('description')); $langstring = $description->appendChild($dom->createElement('string', htmlspecialchars($_POST['meta_notes'], ENT_QUOTES, 'utf-8'))); $langstring->setAttribute('language', $_POST['meta_language']); // end of educational $rights = $lom->appendChild($dom->createElement('rights')); $copyrightAndOtherRestrictionse = $rights->appendChild($dom->createElement('copyrightAndOtherRestrictions')); $source = $copyrightAndOtherRestrictionse->appendChild($dom->createElement('source', 'LOMv1.0')); $value = $copyrightAndOtherRestrictionse->appendChild($dom->createElement('value', 'yes')); $description = $rights->appendChild($dom->createElement('description')); $langstring = $description->appendChild($dom->createElement('string', htmlspecialchars($_POST['meta_rights'], ENT_QUOTES, 'utf-8'))); $langstring->setAttribute('language', $_POST['meta_language']); // end of rights $classification = $lom->appendChild($dom->createElement('classification')); $purpose = $classification->appendChild($dom->createElement('purpose')); $source = $purpose->appendChild($dom->createElement('source', 'LOMv1.0')); $value = $purpose->appendChild($dom->createElement('value', 'discipline')); $taxonPath = $classification->appendChild($dom->createElement('taxonPath')); $source = $taxonPath->appendChild($dom->createElement('source')); $langstring = $source->appendChild($dom->createElement('string', htmlspecialchars($_POST['meta_topic'], ENT_QUOTES, 'utf-8'))); $langstring->setAttribute('language', $_POST['meta_language']); $taxon = $taxonPath->appendChild($dom->createElement('taxon')); $entry = $taxon->appendChild($dom->createElement('entry')); $langstring = $entry->appendChild($dom->createElement('string', htmlspecialchars($_POST['meta_subtopic'], ENT_QUOTES, 'utf-8'))); $langstring->setAttribute('language', $_POST['meta_language']); // end of classification $dom->formatOutput = true; $dom->save($xmlFilename); }
function set_classification($form) { $classification = new DomDocument(); $classificationRootNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:root'); $classificationNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:classification'); $lang = 'es'; if (!empty($form->purpose)) { $purposeNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:purpose'); $sourceNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:source', "LOMv1.0"); $valueNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:value', $form->purpose); $purposeNode->appendChild($sourceNode); $purposeNode->appendChild($valueNode); $classificationNode->appendChild($purposeNode); } if (!empty($form->source)) { $taxonPathNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:taxonPath'); $sourceNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:source'); $stringNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:string', $form->source); $taxonNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:taxon'); $idNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:id', $form->id); $entryNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:entry'); $stringEntryNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:string', $form->entry); $stringNode->setAttribute('language', $lang); $stringEntryNode->setAttribute('language', $lang); $sourceNode->appendChild($stringNode); $entryNode->appendChild($stringEntryNode); $taxonNode->appendChild($idNode); $taxonNode->appendChild($entryNode); $taxonPathNode->appendChild($sourceNode); $taxonPathNode->appendChild($taxonNode); $classificationNode->appendChild($taxonPathNode); } if (!empty($form->description)) { $descriptionNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:description'); $stringNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:string', $form->description); $stringNode->setAttribute('language', $lang); $descriptionNode->appendChild($stringNode); $classificationNode->appendChild($descriptionNode); } if (!empty($form->keyword)) { $keywordNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:keyword'); $stringNode = $classification->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'imsmd:string', $form->keyword); $stringNode->setAttribute('language', $lang); $keywordNode->appendChild($stringNode); $classificationNode->appendChild($keywordNode); } $classificationRootNode->appendChild($classificationNode); $classification->appendChild($classificationRootNode); $this->set_metadata($classification, "classification"); $this->set_manifest(); }