DOMDocument PHP Class Code Examples

This page contains top rated real world PHP examples of class DOMDocument extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: Trader.php Project: ztobs/wsf
1
function resultgetPortfolio($response, $symbol1, $op)
{
    $strresponse = $response->str;
    // Making the $strresponse to normal string type thus $output
    $dom = new DOMDocument();
    $dom = DOMDocument::loadXML($strresponse);
    $result = $dom->getElementsByTagName("result");
    $output = $result->item(0)->nodeValue;
    //
    if (strcmp($output, "Match") == 0) {
        $doc = new DOMDocument();
        if (stristr(PHP_OS, 'WIN')) {
            $doc = DOMDocument::load("portfolio.xml");
        } else {
            $doc = DOMDocument::load("portfolio.xml");
        }
        $items = $doc->getElementsByTagName("item");
        ?>
<form >
<table cols="4" border="1" cellpadding="10" cellspacing="0" align="left" width="50%" bgcolor="#eeeeee">
<tr>
<td>
           <?php 
        echo "Symbol ";
        ?>
           <td>
           <?php 
        echo "Amount";
        foreach ($items as $item) {
            $Symbols = $item->getElementsByTagName("Symbol");
            $Symbol = $Symbols->item(0)->nodeValue;
            $amounts = $item->getElementsByTagName("Amount");
            $amount = $amounts->item(0)->nodeValue;
            ?>
<tr>
<td>
           <?php 
            echo "{$Symbol}";
            ?>
</td>
<td>
           <?php 
            echo "{$amount}";
            echo "million";
            ?>
</td>
</tr>
           <?php 
        }
        if ($op == "resultbuy" or $op == "resultsell") {
            echo "Amount of {$symbol1} changed";
        }
    } else {
        echo "{$strresponse}";
    }
    ?>
</table>
</form>
<?php 
}
Example #2
Show file File: PluginPropertiesTest.php Project: ZerGabriel/friendica-addons
0
 function testSupportedPrivilegeSet()
 {
     $plugin = new Sabre_DAVACL_Plugin();
     $server = new Sabre_DAV_Server();
     $server->addPlugin($plugin);
     $requestedProperties = array('{DAV:}supported-privilege-set');
     $returnedProperties = array(200 => array(), 404 => array());
     $this->assertNull($plugin->beforeGetProperties('', new Sabre_DAV_SimpleCollection('root'), $requestedProperties, $returnedProperties));
     $this->assertEquals(1, count($returnedProperties[200]));
     $this->assertArrayHasKey('{DAV:}supported-privilege-set', $returnedProperties[200]);
     $this->assertInstanceOf('Sabre_DAVACL_Property_SupportedPrivilegeSet', $returnedProperties[200]['{DAV:}supported-privilege-set']);
     $server = new Sabre_DAV_Server();
     $prop = $returnedProperties[200]['{DAV:}supported-privilege-set'];
     $dom = new DOMDocument('1.0', 'utf-8');
     $root = $dom->createElement('d:root');
     $root->setAttribute('xmlns:d', 'DAV:');
     $dom->appendChild($root);
     $prop->serialize($server, $root);
     $xpaths = array('/d:root' => 1, '/d:root/d:supported-privilege' => 1, '/d:root/d:supported-privilege/d:privilege' => 1, '/d:root/d:supported-privilege/d:privilege/d:all' => 1, '/d:root/d:supported-privilege/d:abstract' => 1, '/d:root/d:supported-privilege/d:supported-privilege' => 2, '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2, '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 8, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 8, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-current-user-privilege-set' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-acl' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 8);
     // reloading because php dom sucks
     $dom2 = new DOMDocument('1.0', 'utf-8');
     $dom2->loadXML($dom->saveXML());
     $dxpath = new DOMXPath($dom2);
     $dxpath->registerNamespace('d', 'DAV:');
     foreach ($xpaths as $xpath => $count) {
         $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count);
     }
 }
Example #3
Show file File: soap-sign-encrypt.php Project: leoclaro/wse-php
0
 public function __doRequest($request, $location, $saction, $version)
 {
     $doc = new DOMDocument('1.0');
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     /* add Timestamp with no expiration timestamp */
     $objWSSE->addTimestamp();
     /* create new XMLSec Key using AES256_CBC and type is private key */
     $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
     /* load the private key from file - last arg is bool if key in file (true) or is string (false) */
     $objKey->loadKey(PRIVATE_KEY, true);
     /* Sign the message - also signs appropiate WS-Security items */
     $options = array("insertBefore" => false);
     $objWSSE->signSoapDoc($objKey, $options);
     /* Add certificate (BinarySecurityToken) to the message */
     $token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE));
     /* Attach pointer to Signature */
     $objWSSE->attachTokentoSig($token);
     $objKey = new XMLSecurityKey(XMLSecurityKey::AES256_CBC);
     $objKey->generateSessionKey();
     $siteKey = new XMLSecurityKey(XMLSecurityKey::RSA_OAEP_MGF1P, array('type' => 'public'));
     $siteKey->loadKey(SERVICE_CERT, true, true);
     $options = array("KeyInfo" => array("X509SubjectKeyIdentifier" => true));
     $objWSSE->encryptSoapDoc($siteKey, $objKey, $options);
     $retVal = parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
     $doc = new DOMDocument();
     $doc->loadXML($retVal);
     $options = array("keys" => array("private" => array("key" => PRIVATE_KEY, "isFile" => true, "isCert" => false)));
     $objWSSE->decryptSoapDoc($doc, $options);
     return $doc->saveXML();
 }
Example #4
Show file File: xmlMergerTask.php Project: philippjenni/icinga-web
0
 /**
  * Prepares the document, registers the Namespaces and sets up the DOMXPath searcher
  * 
  */
 private function setupDOM()
 {
     $target_file = $this->getTarget();
     $source_file = $this->getSource();
     if (!file_exists($target_file)) {
         throw new BuildException("Unknown XML-Merger target " . $target_file);
     }
     if (!file_exists($source_file)) {
         throw new BuildException("Unknown XML-Merger source " . $source_file);
     }
     $dom_target = new DOMDocument("1.0", "UTF-8");
     $dom_source = new DOMDocument("1.0", "UTF-8");
     $dom_target->load($target_file);
     $dom_source->load($source_file);
     $dom_target->formatOutput = true;
     $dom_source->formatOutput = true;
     $path_target = new DOMXPath($dom_target);
     $path_source = new DOMXPath($dom_source);
     $this->registerXPathNamespaces($target_file, $path_target);
     $this->registerXPathNamespaces($source_file, $path_source);
     $this->setTargetDOM($dom_target);
     $this->setSourceDOM($dom_source);
     $this->setTargetXPath($path_target);
     $this->setSourceXPath($path_source);
 }
Example #5
Show file File: Assert.php Project: CHRISTOPHERVANDOMME/zf2complet
0
 /**
  * Asserts that a hierarchy of DOMElements matches.
  *
  * @param DOMElement $expectedElement
  * @param DOMElement $actualElement
  * @param bool       $checkAttributes
  * @param string     $message
  *
  * @since  Method available since Release 3.3.0
  */
 public static function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = false, $message = '')
 {
     $tmp = new DOMDocument();
     $expectedElement = $tmp->importNode($expectedElement, true);
     $tmp = new DOMDocument();
     $actualElement = $tmp->importNode($actualElement, true);
     unset($tmp);
     self::assertEquals($expectedElement->tagName, $actualElement->tagName, $message);
     if ($checkAttributes) {
         self::assertEquals($expectedElement->attributes->length, $actualElement->attributes->length, sprintf('%s%sNumber of attributes on node "%s" does not match', $message, !empty($message) ? "\n" : '', $expectedElement->tagName));
         for ($i = 0; $i < $expectedElement->attributes->length; $i++) {
             $expectedAttribute = $expectedElement->attributes->item($i);
             $actualAttribute = $actualElement->attributes->getNamedItem($expectedAttribute->name);
             if (!$actualAttribute) {
                 self::fail(sprintf('%s%sCould not find attribute "%s" on node "%s"', $message, !empty($message) ? "\n" : '', $expectedAttribute->name, $expectedElement->tagName));
             }
         }
     }
     PHPUnit_Util_XML::removeCharacterDataNodes($expectedElement);
     PHPUnit_Util_XML::removeCharacterDataNodes($actualElement);
     self::assertEquals($expectedElement->childNodes->length, $actualElement->childNodes->length, sprintf('%s%sNumber of child nodes of "%s" differs', $message, !empty($message) ? "\n" : '', $expectedElement->tagName));
     for ($i = 0; $i < $expectedElement->childNodes->length; $i++) {
         self::assertEqualXMLStructure($expectedElement->childNodes->item($i), $actualElement->childNodes->item($i), $checkAttributes, $message);
     }
 }
Example #6
Show file File: ezsimpleshopaccounthandler.php Project: mugoweb/ezpublish-legacy
0
 function accountInformation($order)
 {
     $firstName = '';
     $lastName = '';
     $email = '';
     $address = '';
     $dom = new DOMDocument('1.0', 'utf-8');
     $xmlString = $order->attribute('data_text_1');
     if ($xmlString != null) {
         $dom = new DOMDocument('1.0', 'utf-8');
         $success = $dom->loadXML($xmlString);
         $firstNameNode = $dom->getElementsByTagName('first-name')->item(0);
         if ($firstNameNode) {
             $firstName = $firstNameNode->textContent;
         }
         $lastNameNode = $dom->getElementsByTagName('last-name')->item(0);
         if ($lastNameNode) {
             $lastName = $lastNameNode->textContent;
         }
         $emailNode = $dom->getElementsByTagName('email')->item(0);
         if ($emailNode) {
             $email = $emailNode->textContent;
         }
         $addressNode = $dom->getElementsByTagName('address')->item(0);
         if ($addressNode) {
             $address = $addressNode->textContent;
         }
     }
     return array('first_name' => $firstName, 'last_name' => $lastName, 'email' => $email, 'address' => $address);
 }
Example #7
Show file File: Importer.php Project: tillk/vufind
0
 /**
  * Transform $xmlFile using the provided $properties configuration.
  *
  * @param string $xmlFile    XML file to transform.
  * @param string $properties Properties file.
  *
  * @throws \Exception
  * @return mixed             Transformed XML.
  */
 protected function generateXML($xmlFile, $properties)
 {
     // Load properties file:
     $properties = ConfigLocator::getConfigPath($properties, 'import');
     if (!file_exists($properties)) {
         throw new \Exception("Cannot load properties file: {$properties}.");
     }
     $options = parse_ini_file($properties, true);
     // Make sure required parameter is set:
     if (!isset($options['General']['xslt'])) {
         throw new \Exception("Properties file ({$properties}) is missing General/xslt setting.");
     }
     $xslFile = ConfigLocator::getConfigPath($options['General']['xslt'], 'import/xsl');
     // Initialize the XSL processor:
     $xsl = $this->initProcessor($options);
     // Load up the style sheet
     $style = new DOMDocument();
     if (!$style->load($xslFile)) {
         throw new \Exception("Problem loading XSL file: {$xslFile}.");
     }
     $xsl->importStyleSheet($style);
     // Load up the XML document
     $xml = new DOMDocument();
     if (!$xml->load($xmlFile)) {
         throw new \Exception("Problem loading XML file: {$xmlFile}.");
     }
     // Process and return the XML through the style sheet
     $result = $xsl->transformToXML($xml);
     if (!$result) {
         throw new \Exception("Problem transforming XML.");
     }
     return $result;
 }
Example #8
Show file File: Installer.php Project: idiscussforum/providence
0
 private function validateProfile()
 {
     // simplexml doesn't support validation -> use DOMDocument
     $vo_profile = new DOMDocument();
     $vo_profile->load($this->ops_profile_dir . "/" . $this->ops_profile_name . ".xml");
     if ($this->opo_base) {
         $vo_base = new DOMDocument();
         $vo_base->load($this->ops_profile_dir . "/" . $this->ops_base_name . ".xml");
         if ($this->opb_debug) {
             ob_start();
             $vb_return = $vo_profile->schemaValidate($this->ops_profile_dir . "/profile.xsd") && $vo_base->schemaValidate($this->ops_profile_dir . "/profile.xsd");
             $this->ops_profile_debug .= ob_get_clean();
         } else {
             $vb_return = @$vo_profile->schemaValidate($this->ops_profile_dir . "/profile.xsd") && @$vo_base->schemaValidate($this->ops_profile_dir . "/profile.xsd");
         }
     } else {
         if ($this->opb_debug) {
             ob_start();
             $vb_return = $vo_profile->schemaValidate($this->ops_profile_dir . "/profile.xsd");
             $this->ops_profile_debug .= ob_get_clean();
         } else {
             $vb_return = @$vo_profile->schemaValidate($this->ops_profile_dir . "/profile.xsd");
         }
     }
     return $vb_return;
 }
Example #9
Show file File: 100.php Project: luisbrito/Phraseanet
0
 public function patch($version, \DOMDocument $domct, \DOMDocument $domth, Connection $connbas, \unicode $unicode)
 {
     if ($version == "") {
         $th = $domth->documentElement;
         $ct = $domct->documentElement;
         $th->setAttribute("id", "0");
         $xp = new DOMXPath($domth);
         $te = $xp->query("/thesaurus/te");
         if ($te->length > 0) {
             $te0 = $te->item(0);
             $th->setAttribute("nextid", $te0->getAttribute("nextid"));
             $te = $xp->query("te", $te0);
             $te1 = [];
             for ($i = 0; $i < $te->length; $i++) {
                 $te1[] = $te->item($i);
             }
             foreach ($te1 as $tei) {
                 $th->appendChild($tei);
                 $this->fixThesaurus2($domth, $tei, 0, $unicode);
             }
             $te0->parentNode->removeChild($te0);
         }
         $ct->setAttribute("version", $version = "2.0.0");
         $th->setAttribute("version", "2.0.0");
         $th->setAttribute("creation_date", $now = date("YmdHis"));
         $th->setAttribute("modification_date", $now);
         $version = "2.0.0";
     }
     return $version;
 }
Example #10
Show file File: mainScraper.php Project: shilsu/Scraper-Consoleapp
0
 /**
  * main function extracts url data and returns json array
  * @return json array
  */
 public function getData()
 {
     $results = array();
     $total = 0;
     $htmlMain = $this->getHtml($this->url);
     $doc = new DOMDocument();
     @$doc->loadHTML($htmlMain['result']);
     $xpath = new DOMXpath($doc);
     $products = $xpath->query('//div[@class="productInfo"]');
     foreach ($products as $entry) {
         $htmlLinks = $entry->getElementsByTagName("a");
         foreach ($htmlLinks as $item) {
             $href = $item->getAttribute("href");
             $link = trim(preg_replace("/[\r\n]+/", " ", $item->nodeValue));
             $html = $this->getHtml($href);
             $doc = new DOMDocument();
             @$doc->loadHTML($html['result']);
             $xpath = new DOMXpath($doc);
             $productUnitPrice = $xpath->query('//p[@class="pricePerUnit"]');
             foreach ($productUnitPrice as $itemPrice) {
                 $unitPrice = preg_replace('/[^0-9.]*/', '', $itemPrice->nodeValue);
                 break;
             }
             $productText = $xpath->query('//div[@class="productText"]');
             foreach ($productText as $itemText) {
                 $description = trim($itemText->nodeValue);
                 break;
             }
             $results['result'][] = array('title' => $link, 'size' => $html['size'], 'unit_price' => $unitPrice, 'description' => $description);
             $total += $unitPrice;
         }
     }
     $results['total'] = $total;
     return json_encode($results);
 }
Example #11
Show file File: Crawler.php Project: spiderling-php/kohana-driver
0
 /**
  * @param DOMDocument|null $document
  */
 public function __construct(DOMDocument $document = null)
 {
     if (null === $document) {
         $document = new DOMDocument('1.0', 'UTF-8');
     }
     parent::__construct(new Loader(), $document);
 }
Example #12
Show file File: z_carddav.php Project: SvKn/Z-Push-contrib
0
 /**
  * Cleans CardDAV XML response
  *
  * @param	string	$response	CardDAV XML response
  * @return	string	$response	Cleaned CardDAV XML response
  */
 private function remove_namespaces($response)
 {
     //         $response = preg_replace('/<[a-z0-9]+:(.*)/i', '<$1', $response);
     //         $response = preg_replace('/<\/[a-z0-9]+:(.*)/i', '</$1', $response);
     // Removing namespace it's pretty hard with regex.
     // Also, each server uses different namespaces, so using namespaces it's impossible
     // This uses DOMDocument, so it won't be the fastest or least memory-using way.
     // Feel free to suggest or improve it
     // http://stackoverflow.com/questions/15634291/remove-name-space-from-xml-file-and-save-as-new-xml
     $xsl = <<<EOFXSL
l:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" encoding="UTF-8" />
     <xsl:template match="*">
             <xsl:element name="{local-name()}">
                     <xsl:apply-templates select="@* | node()"/>
             </xsl:element>
     </xsl:template>
sl:stylesheet>
XSL;
     $dom = new DOMDocument();
     $dom->loadXML($response);
     $stylesheet = new DOMDocument();
     $stylesheet->loadXML($xsl);
     $xsltprocessor = new XSLTProcessor();
     $xsltprocessor->importStylesheet($stylesheet);
     $response = $xsltprocessor->transformToXML($dom);
     $dom = null;
     $stylesheet = null;
     $xsltprocessor = null;
     return $response;
 }
Example #13
Show file File: functions.php Project: cs-team/tiny_tiny_rss-openshift-quickstart
0
function rewrite_urls($html)
{
    libxml_use_internal_errors(true);
    $charset_hack = '<head>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		</head>';
    $doc = new DOMDocument();
    $doc->loadHTML($charset_hack . $html);
    $xpath = new DOMXPath($doc);
    $entries = $xpath->query('//*/text()');
    foreach ($entries as $entry) {
        if (strstr($entry->wholeText, "://") !== false) {
            $text = preg_replace("/((?<!=.)((http|https|ftp)+):\\/\\/[^ ,!]+)/i", "<a target=\"_blank\" href=\"\\1\">\\1</a>", $entry->wholeText);
            if ($text != $entry->wholeText) {
                $cdoc = new DOMDocument();
                $cdoc->loadHTML($charset_hack . $text);
                foreach ($cdoc->childNodes as $cnode) {
                    $cnode = $doc->importNode($cnode, true);
                    if ($cnode) {
                        $entry->parentNode->insertBefore($cnode);
                    }
                }
                $entry->parentNode->removeChild($entry);
            }
        }
    }
    $node = $doc->getElementsByTagName('body')->item(0);
    // http://tt-rss.org/forum/viewtopic.php?f=1&t=970
    if ($node) {
        return $doc->saveXML($node);
    } else {
        return $html;
    }
}
Example #14
Show file File: ConfigValuesCommand.php Project: eniuz/EAVCleaner
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->_input = $input;
     $this->_output = $output;
     $this->_info('Start Compare ConfigValues');
     $this->detectMagento($output);
     if ($this->initMagento()) {
         $magentoExportDir = \Mage::getBaseDir('export');
         $currentValues = \Mage::app()->getConfig()->getNode('default');
         if (!$currentValues) {
             throw new \InvalidArgumentException('xpath was not found');
         }
         // new Values
         $dom = new \DOMDocument();
         $dom->preserveWhiteSpace = false;
         $dom->formatOutput = true;
         $dom->loadXML($currentValues->asXml());
         $currentValues = $this->xml_to_array($dom);
         // oldValues
         $domOldValues = new \DOMDocument();
         $domOldValues->preserveWhiteSpace = false;
         $domOldValues->formatOutput = true;
         $domOldValues->loadXML(file_get_contents($magentoExportDir . DS . 'configvaluescompare.xml'));
         $oldValues = $this->xml_to_array($domOldValues);
         // Compare
         $diffValues = $this->arrayRecursiveDiff($currentValues, $oldValues);
         if (count($diffValues) > 0) {
             $this->output($diffValues, $output);
             file_put_contents($magentoExportDir . DS . 'configvaluescompare.xml', $dom->saveXML());
         }
     }
 }
Example #15
Show file File: ResponseTest.php Project: bloveing/openulteo
0
 /**
  * Tests the isValid method of the OneLogin_Saml2_Response
  * Case valid sign response / sign assertion / both signed
  *
  * Strict mode will always fail due destination problem, if we manipulate it
  * the sign will fail.
  *
  * @covers OneLogin_Saml2_Response::isValid
  */
 public function testIsValidSign()
 {
     $xml = file_get_contents(TEST_ROOT . '/data/responses/signed_message_response.xml.base64');
     $response = new OneLogin_Saml2_Response($this->_settings, $xml);
     $this->assertTrue($response->isValid());
     $xml2 = file_get_contents(TEST_ROOT . '/data/responses/signed_assertion_response.xml.base64');
     $response2 = new OneLogin_Saml2_Response($this->_settings, $xml2);
     $this->assertTrue($response2->isValid());
     $xml3 = file_get_contents(TEST_ROOT . '/data/responses/double_signed_response.xml.base64');
     $response3 = new OneLogin_Saml2_Response($this->_settings, $xml3);
     $this->assertTrue($response3->isValid());
     $dom = new DOMDocument();
     $dom->loadXML(base64_decode($xml));
     $dom->firstChild->firstChild->nodeValue = 'https://example.com/other-idp';
     $xml4 = base64_encode($dom->saveXML());
     $response4 = new OneLogin_Saml2_Response($this->_settings, $xml4);
     $this->assertFalse($response4->isValid());
     $dom2 = new DOMDocument();
     $dom2->loadXML(base64_decode($xml2));
     $dom2->firstChild->firstChild->nodeValue = 'https://example.com/other-idp';
     $xml5 = base64_encode($dom2->saveXML());
     $response5 = new OneLogin_Saml2_Response($this->_settings, $xml5);
     $this->assertTrue($response5->isValid());
     $dom3 = new DOMDocument();
     $dom3->loadXML(base64_decode($xml3));
     $dom3->firstChild->firstChild->nodeValue = 'https://example.com/other-idp';
     $xml6 = base64_encode($dom3->saveXML());
     $response6 = new OneLogin_Saml2_Response($this->_settings, $xml6);
     $this->assertFalse($response6->isValid());
 }
Example #16
Show file File: EmbedTest.php Project: Pixy/ezpublish-kernel
0
 /**
  * @dataProvider providerForTestConvert
  */
 public function testConvert($xmlString, $expectedXmlString, array $errors, array $renderParams)
 {
     if (isset($errors)) {
         foreach ($errors as $index => $error) {
             $this->loggerMock->expects($this->at($index))->method('error')->with($error);
         }
     } else {
         $this->loggerMock->expects($this->never())->method('error');
     }
     $this->rendererMock->expects($this->never())->method('renderTag');
     if (!empty($renderParams)) {
         foreach ($renderParams as $index => $params) {
             $this->rendererMock->expects($this->at($index))->method($params['method'])->with($params['id'], $params['viewType'], array('embedParams' => $params['embedParams']), $params['is_inline'])->will($this->returnValue($params['id']));
         }
     } else {
         $this->rendererMock->expects($this->never())->method('renderContentEmbed');
         $this->rendererMock->expects($this->never())->method('renderLocationEmbed');
     }
     $document = new DOMDocument();
     $document->preserveWhiteSpace = false;
     $document->formatOutput = false;
     $document->loadXML($xmlString);
     $document = $this->getConverter()->convert($document);
     $expectedDocument = new DOMDocument();
     $expectedDocument->preserveWhiteSpace = false;
     $expectedDocument->formatOutput = false;
     $expectedDocument->loadXML($expectedXmlString);
     $this->assertEquals($expectedDocument, $document);
 }
Example #17
Show file File: CCR.php Project: nhom5UET/tichhophethong
0
 function viewCCD($raw)
 {
     $this->ccr->preserveWhiteSpace = false;
     $this->ccr->formatOutput = true;
     $this->ccr->save($_SESSION['site']['temp']['path'] . '/ccrForCCD.xml');
     $xmlDom = new DOMDocument();
     $xmlDom->loadXML($this->ccr->saveXML());
     $ccr_ccd = new DOMDocument();
     $ccr_ccd->load('../lib/ccr/ccd/ccr_ccd.xsl');
     //
     if (class_exists('XSLTProcessor')) {
         $xslt = new XSLTProcessor();
         $xslt->importStylesheet($ccr_ccd);
         $ccd = new DOMDocument();
         $ccd->preserveWhiteSpace = false;
         $ccd->formatOutput = true;
         $ccd->loadXML($xslt->transformToXML($xmlDom));
         $ccd->save($_SESSION['site']['temp']['path'] . '/ccdDebug.xml');
         if ($raw == 'yes') {
             // simply send the xml to a textarea (nice debugging tool)
             echo '<textarea rows="35" cols="500" style="width:100%; height:99%" readonly>';
             echo $ccd->saveXml();
             echo '</textarea>';
             return;
         }
         $ss = new DOMDocument();
         $ss->load($_SESSION['root'] . '/lib/ccr/stylesheet/cda.xsl');
         $xslt->importStyleSheet($ss);
         print $xslt->transformToXML($ccd);
     } else {
         print 'PHP Error Class \'XsltProcessor\' not found. <a href="http://php.net/manual/en/xsl.installation.php" target="_blank">[more info]</a>';
     }
 }
Example #18
Show file File: Inverse.php Project: ingoratsdorf/Tine-2.0-Open-Source-Groupware-and-CRM
0
 /**
  * 
  * @param DOMDocument $dom
  */
 public function userQuery(DOMDocument $dom)
 {
     $users = $dom->getElementsByTagNameNS(self::NS_INVERSE, 'users');
     if ($users->length == 1) {
         $match = $users->item(0)->getAttribute('match-name');
         $filter = new Addressbook_Model_ContactFilter(array(array('field' => 'query', 'operator' => 'contains', 'value' => $match), array('field' => 'type', 'operator' => 'equals', 'value' => 'user')));
         $records = Addressbook_Controller_Contact::getInstance()->search($filter);
         $domout = new DOMDocument('1.0', 'utf-8');
         $domout->formatOutput = true;
         $users = $domout->createElement('users');
         $domout->appendChild($users);
         foreach ($records as $record) {
             $user = $domout->createElement('user');
             $user->appendChild(new DOMElement('id', $record->id));
             $user->appendChild(new DOMElement('displayName', $record->n_fileas));
             $user->appendChild(new DOMElement('email', $record->email));
             $users->appendChild($user);
         }
         $xmml = $domout->saveXML();
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' id container : ' . str_replace(array("\r\n", "\n", "\r", "  "), '', $xmml));
         }
         $this->server->httpResponse->sendStatus(207);
         $this->server->httpResponse->setHeader('Content-Type', 'text/xml; charset=utf-8');
         $this->server->httpResponse->sendBody(str_replace(array("\r\n", "\n", "\r", "  "), '', $xmml));
     }
 }
Example #19
Show file File: createCCR.php Project: nhom5UET/tichhophethong
0
function viewCCD($ccr, $raw = "no")
{
    $ccr->preserveWhiteSpace = false;
    $ccr->formatOutput = true;
    $ccr->save(dirname(__FILE__) . '/generatedXml/ccrForCCD.xml');
    $xmlDom = new DOMDocument();
    $xmlDom->loadXML($ccr->saveXML());
    $ccr_ccd = new DOMDocument();
    $ccr_ccd->load(dirname(__FILE__) . '/ccd/ccr_ccd.xsl');
    $xslt = new XSLTProcessor();
    $xslt->importStylesheet($ccr_ccd);
    $ccd = new DOMDocument();
    $ccd->preserveWhiteSpace = false;
    $ccd->formatOutput = true;
    $ccd->loadXML($xslt->transformToXML($xmlDom));
    $ccd->save(dirname(__FILE__) . '/generatedXml/ccdDebug.xml');
    if ($raw == "yes") {
        // simply send the xml to a textarea (nice debugging tool)
        echo "<textarea rows='35' cols='500' style='width:95%' readonly>";
        echo $ccd->saveXml();
        echo "</textarea>";
        return;
    }
    $ss = new DOMDocument();
    $ss->load(dirname(__FILE__) . "/stylesheet/cda.xsl");
    $xslt->importStyleSheet($ss);
    $html = $xslt->transformToXML($ccd);
    echo $html;
}
Example #20
Show file File: plugins_model.php Project: denzilferreira/aware-server
0
 function get_play_store()
 {
     $remote = array();
     $store_page = new DOMDocument();
     $internalErrors = libxml_use_internal_errors(true);
     $store_page->loadHTMLFile("https://play.google.com/store/search?q=awareframework%20plugin");
     $xpath = new DOMXpath($store_page);
     $packages_titles = $xpath->query('//a[@class="title"]/@href');
     foreach ($packages_titles as $pkgs) {
         $package_name = substr($pkgs->textContent, strrpos($pkgs->textContent, "=") + 1, strlen($pkgs->textContent));
         preg_match("/^com\\.aware\\.plugin\\..*/", $package_name, $matches, PREG_OFFSET_CAPTURE);
         if (count($matches) == 0) {
             continue;
         }
         $package_page = new DOMDocument();
         $package_page->loadHTMLFile("https://play.google.com/store/apps/details?id={$package_name}");
         $xpath = new DOMXpath($package_page);
         $icon = $xpath->query('//img[@class="cover-image"]/@src');
         $version = $xpath->query('//div[@itemprop="softwareVersion"]');
         $description = $xpath->query('//div[@itemprop="description"]');
         $pkg = array('title' => trim($pkgs->parentNode->textContent), 'package' => $package_name, 'version' => trim($version->item(0)->textContent), 'desc' => $description->item(0)->childNodes->item(1)->nodeValue, 'iconpath' => 'https:' . $icon->item(0)->value, 'first_name' => 'AWARE', 'last_name' => 'Framework', 'email' => 'aware@comag.oulu.fi');
         $remote[] = $pkg;
     }
     return $remote;
 }
Example #21
Show file File: AuthnetXML.class.php Project: httvncoder/151722441
0
 public function __toString()
 {
     $output = '';
     $output .= '<table summary="Authorize.Net Results" id="authnet">' . "\n";
     $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n";
     $output .= '<tr>' . "\n\t\t" . '<td><b>API Login ID</b></td><td>' . $this->login . '</td>' . "\n" . '</tr>' . "\n";
     $output .= '<tr>' . "\n\t\t" . '<td><b>Transaction Key</b></td><td>' . $this->transkey . '</td>' . "\n" . '</tr>' . "\n";
     $output .= '<tr>' . "\n\t\t" . '<td><b>Authnet Server URL</b></td><td>' . $this->url . '</td>' . "\n" . '</tr>' . "\n";
     $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Request XML</b></th>' . "\n" . '</tr>' . "\n";
     if (isset($this->xml) && !empty($this->xml)) {
         $dom = new DOMDocument('1.0');
         $dom->preserveWhiteSpace = false;
         $dom->formatOutput = true;
         $dom->loadXML(self::removeResponseXMLNS($this->xml));
         $outgoing_xml = $dom->saveXML();
         $output .= '<tr><td>' . "\n";
         $output .= 'XML:</td><td><pre>' . "\n";
         $output .= htmlentities($outgoing_xml) . "\n";
         $output .= '</pre></td></tr>' . "\n";
     }
     if (!empty($this->response)) {
         $dom = new DOMDocument('1.0');
         $dom->preserveWhiteSpace = false;
         $dom->formatOutput = true;
         $dom->loadXML(self::removeResponseXMLNS($this->response));
         $response_xml = $dom->saveXML();
         $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Response XML</b></th>' . "\n" . '</tr>' . "\n";
         $output .= '<tr><td>' . "\n";
         $output .= 'XML:</td><td><pre>' . "\n";
         $output .= htmlentities($response_xml) . "\n";
         $output .= '</pre></td></tr>' . "\n";
     }
     $output .= '</table>';
     return $output;
 }
Example #22
Show file File: test_ProxyClient.php Project: gtoffoli/swete
0
 function testRequestToOutputFile()
 {
     $client = new ProxyClient();
     $client->URL = df_absolute_url('tests/test_ProxyClient/test1.html');
     $outputFile = tempnam(sys_get_temp_dir(), 'test_ProxyClient');
     $client->outputFile = $outputFile;
     $client->process();
     $this->assertEquals(null, $client->content, 'Content should be written to output file, not saved to variable.');
     $expected = file_get_contents('tests/test_ProxyClient/test1.html');
     $doc = new DOMDocument();
     @$doc->loadHtml($expected);
     $expected = $doc->saveHtml();
     $actual = file_get_contents($outputFile);
     $actual = '';
     $fh = fopen($outputFile, 'r');
     while (!feof($fh) and trim($line = fgets($fh, 1024))) {
         // We skip the headers
     }
     ob_start();
     fpassthru($fh);
     fclose($fh);
     $actual = ob_get_contents();
     ob_end_clean();
     unset($doc);
     $doc = new DOMDocument();
     @$doc->loadHtml($actual);
     $actual = $doc->saveHtml();
     unset($doc);
     $this->assertEquals($expected, $actual);
 }
Example #23
Show file File: XsltFilter.php Project: Daniel-Marynicz/symfony1-legacy
0
 /**
  * Try to process the XSLT transformation
  *
  * @param   string  XML to process.
  * @param   string  XSLT sheet to use for the processing.
  *
  * @throws BuildException   On XSLT errors
  */
 protected function process($xml, $xsl)
 {
     $processor = new XSLTProcessor();
     $xmlDom = new DOMDocument();
     $xslDom = new DOMDocument();
     if ($this->html) {
         $xmlDom->loadHTML($xml);
     } else {
         $xmlDom->loadXML($xml);
     }
     $xslDom->loadxml($xsl);
     $processor->importStylesheet($xslDom);
     // ignoring param "type" attrib, because
     // we're only supporting direct XSL params right now
     foreach ($this->xsltParams as $param) {
         $this->log("Setting XSLT param: " . $param->getName() . "=>" . $param->getExpression(), PROJECT_MSG_DEBUG);
         $processor->setParameter(null, $param->getName(), $param->getExpression());
     }
     $result = $processor->transformToXML($xmlDom);
     if (!$result) {
         //$errno = xslt_errno($processor);
         //$err   = xslt_error($processor);
         throw new BuildException("XSLT Error");
     } else {
         return $result;
     }
 }
Example #24
Show file File: XsltTesterApiAction.php Project: DBezemer/server
0
 public function doAction(Zend_Controller_Action $action)
 {
     $entryId = $action->getRequest()->getParam('entry-id');
     $xslt = $action->getRequest()->getParam('xslt');
     $this->client = Infra_ClientHelper::getClient();
     $xml = $this->client->media->getMrss($entryId);
     $xslParams = array();
     $xslParams['entryDistributionId'] = '';
     $xslParams['distributionProfileId'] = '';
     ob_start();
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($xml);
     $xsltDoc = new DOMDocument();
     $xsltDoc->loadXML($xslt);
     $xslt = new XSLTProcessor();
     $xslt->registerPHPFunctions();
     // it is safe to register all php fuctions here
     $xslt->setParameter('', $xslParams);
     $xslt->importStyleSheet($xsltDoc);
     $ob = ob_get_clean();
     ob_end_clean();
     if ($ob) {
         $action->getHelper('json')->direct(array('error' => $ob));
     }
     $obj = array('result' => $xslt->transformToXml($xmlDoc));
     $action->getHelper('json')->direct($obj);
 }
Example #25
Show file File: sfListTask.class.php Project: cuongnv540/jobeet
0
 protected function outputAsXml($namespace, $tasks)
 {
     $dom = new DOMDocument('1.0', 'UTF-8');
     $dom->formatOutput = true;
     $dom->appendChild($symfonyXML = $dom->createElement('symfony'));
     $symfonyXML->appendChild($tasksXML = $dom->createElement('tasks'));
     if ($namespace) {
         $tasksXML->setAttribute('namespace', $namespace);
     } else {
         $symfonyXML->appendChild($namespacesXML = $dom->createElement('namespaces'));
     }
     // display tasks
     ksort($tasks);
     $currentNamespace = 'foobar';
     $namespaceArrayXML = array();
     foreach ($tasks as $name => $task) {
         if (!$namespace && $currentNamespace != $task->getNamespace()) {
             $currentNamespace = $task->getNamespace();
             $namespacesXML->appendChild($namespaceArrayXML[$task->getNamespace()] = $dom->createElement('namespace'));
             $namespaceArrayXML[$task->getNamespace()]->setAttribute('id', $task->getNamespace() ? $task->getNamespace() : '_global');
         }
         if (!$namespace) {
             $namespaceArrayXML[$task->getNamespace()]->appendChild($taskXML = $dom->createElement('task'));
             $taskXML->appendChild($dom->createTextNode($task->getName()));
         }
         $taskXML = new DOMDocument('1.0', 'UTF-8');
         $taskXML->formatOutput = true;
         $taskXML->loadXML($task->asXml());
         $node = $taskXML->getElementsByTagName('task')->item(0);
         $node = $dom->importNode($node, true);
         $tasksXML->appendChild($node);
     }
     echo $dom->saveXml();
 }