コード例 #1
1
 /**
  * (non-PHPdoc)
  * @see lib/Faett/Channel/Serializer/Interfaces/Faett_Channel_Serializer_Interfaces_Serializer#serialize()
  */
 public function serialize()
 {
     try {
         // initialize a new DOM document
         $doc = new DOMDocument('1.0', 'UTF-8');
         // create new namespaced root element
         $a = $doc->createElementNS($this->_namespace, 'a');
         // add the schema to the root element
         $a->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', 'http://pear.php.net/dtd/rest.allcategories http://pear.php.net/dtd/rest.allcategories.xsd');
         // create an element for the channel's name
         $ch = $doc->createElement('ch');
         $ch->nodeValue = Mage::helper('channel')->getChannelName();
         // append the element with the channel's name to the root element
         $a->appendChild($ch);
         // load the product's attributes
         $attributes = $this->_category->getSelectOptions();
         // iterate over the channel's categories
         foreach ($attributes as $attribute) {
             $c = $doc->createElement('c');
             $c->setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '/channel/index/c/' . $attribute . '/info.xml');
             $c->nodeValue = $attribute;
             // append the XLink to the root element
             $a->appendChild($c);
         }
         // append the root element to the DOM tree
         $doc->appendChild($a);
         // return the XML document
         return $doc->saveXML();
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
コード例 #2
1
 /**
  *
  * @return string
  */
 public function getMessage()
 {
     if (empty($this->_jobTraining)) {
         return '';
     }
     $this->_dom = new DOMDocument();
     $classMessage = 'alert ';
     $divFluid = $this->_dom->createElement('div');
     $divMessage = $this->_dom->createElement('div');
     $divFluid->setAttribute('class', 'row-fluid');
     if ($this->_jobTraining->status != 1) {
         $classMessage .= 'alert-error';
         $iconClass = 'icon-remove-sign';
         $alertText = ' Atensaun ';
         $message = ' Job Training ' . ($this->_jobTraining->status == 2 ? 'Kansela' : 'Taka') . ' tiha ona, La bele halo Atualizasaun.';
     } else {
         $iconClass = 'icon-ok-sign';
         $classMessage .= 'alert-success';
         $alertText = '';
         $message = ' Job Training Loke, então bele halo Atualizasaun.';
     }
     $divMessage->setAttribute('class', $classMessage);
     $strong = $this->_dom->createElement('strong');
     $i = $this->_dom->createElement('i');
     $i->setAttribute('class', $iconClass);
     $strong->appendChild($i);
     $strong->appendChild($this->_dom->createTextNode($alertText));
     $divMessage->appendChild($strong);
     $divMessage->appendChild($this->_dom->createTextNode($message));
     $divFluid->appendChild($divMessage);
     $this->_dom->appendChild($divFluid);
     return $this->_dom->saveHTML();
 }
コード例 #3
0
ファイル: PDO.php プロジェクト: nurfiantara/ehri-ica-atom
 /**
  * Load DOMDocument from xml string
  *
  * @param string $source xml string
  * @param string $contentType
  * @return DOMDocument|FALSE
  */
 public function load($source, $contentType)
 {
     if (is_object($source) && $source instanceof PDOStatement) {
         $source->setFetchMode(PDO::FETCH_NUM);
         $columnCount = $source->columnCount();
         $columns = array();
         for ($i = 0; $i < $columnCount; $i++) {
             $columnData = $source->getColumnMeta($i);
             $columns[$i] = array('name' => $this->_normalizeColumnName($columnData['name']), 'type' => $this->_getNodeType($columnData));
         }
         $dom = new DOMDocument();
         $dom->formatOutput = TRUE;
         $dom->appendChild($rootNode = $dom->createElement($this->_tagNameRoot));
         foreach ($source as $row) {
             $rootNode->appendChild($recordNode = $dom->createElement($this->_tagNameRecord));
             foreach ($row as $columnId => $value) {
                 switch ($columns[$columnId]['type']) {
                     case self::ATTRIBUTE_VALUE:
                         $recordNode->setAttribute($columns[$columnId]['name'], $value);
                         break;
                     default:
                         $recordNode->appendChild($valueNode = $dom->createElement($columns[$columnId]['name'], $value));
                         break;
                 }
             }
         }
         return $dom;
     }
     return FALSE;
 }
コード例 #4
0
ファイル: PmdDescriptor.php プロジェクト: ftdysa/insight
 protected function describeAnalysis(Analysis $analysis, array $options = array())
 {
     $output = $options['output'];
     $xml = new \DOMDocument('1.0', 'UTF-8');
     $xpath = new \DOMXPath($xml);
     $xml->formatOutput = true;
     $xml->preserveWhiteSpace = true;
     $pmd = $xml->createElement('pmd');
     $pmd->setAttribute('timestamp', $analysis->getEndAt()->format('c'));
     $xml->appendChild($pmd);
     foreach ($analysis->getViolations() as $violation) {
         /**
          * @var $violation \SensioLabs\Insight\Sdk\Model\Violation
          */
         $filename = $violation->getResource();
         $nodes = $xpath->query(sprintf('//file[@name="%s"]', $filename));
         if ($nodes->length > 0) {
             $node = $nodes->item(0);
         } else {
             $node = $xml->createElement('file');
             $node->setAttribute('name', $filename);
             $pmd->appendChild($node);
         }
         $violationNode = $xml->createElement('violation', $violation->getMessage());
         $node->appendChild($violationNode);
         $violationNode->setAttribute('beginline', $violation->getLine());
         $violationNode->setAttribute('endline', $violation->getLine());
         $violationNode->setAttribute('rule', $violation->getTitle());
         $violationNode->setAttribute('ruleset', $violation->getCategory());
         $violationNode->setAttribute('priority', $this->getPriority($violation));
     }
     $output->writeln($xml->saveXML());
 }
コード例 #5
0
 public function __call($method, $arguments)
 {
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->createElement('method');
     $element->setAttribute('name', $method);
     foreach ($arguments as $argument) {
         $child = $dom->createElement('argument');
         $textNode = $dom->createTextNode($argument);
         $child->appendChild($textNode);
         $element->appendChild($child);
     }
     $dom->appendChild($element);
     $data = 'service=' . $dom->saveXML();
     $params = array('http' => array('method' => 'POST', 'content' => $data));
     $ctx = stream_context_create($params);
     $fp = @fopen($this->server, 'rb', false, $ctx);
     if (!$fp) {
         throw new Exception('Problem with URL');
     }
     $response = @stream_get_contents($fp);
     if ($response === false) {
         throw new Exception("Problem reading data from {$this->server}");
     }
     $dom = new DOMDocument(null, 'UTF-8');
     $dom->loadXML($response);
     $result = $dom->childNodes->item(0)->childNodes->item(0)->nodeValue;
     $type = $dom->childNodes->item(0)->childNodes->item(1)->nodeValue;
     settype($result, $type);
     return $result;
 }
コード例 #6
0
ファイル: ValueConstraint.php プロジェクト: marklogic/mlphp
 /**
  * Get the constraint as a DOMElement object.
  *
  * @param DOMDocument $dom The DOMDocument object with which to create the element.
  */
 public function getAsElem($dom)
 {
     $constElem = $dom->createElement('constraint');
     $constElem->setAttribute('name', $this->name);
     $valElem = $dom->createElement('value');
     $elemElem = $dom->createElement('element');
     $elemElem->setAttribute('ns', $this->ns);
     $elemElem->setAttribute('name', $this->elem);
     $valElem->appendChild($elemElem);
     if ($this->attr) {
         $attrElem = $dom->createElement('attribute');
         $attrElem->setAttribute('ns', $this->attrNs);
         $attrElem->setAttribute('name', $this->attr);
         $valElem->appendChild($attrElem);
     }
     $this->addTermOptions($dom, $valElem);
     $this->addFragmentScope($dom, $valElem);
     $constElem->appendChild($valElem);
     /* <constraint name='flavor'>
         <value>
             <element ns='http://example.com' name='flavor-descriptor'/>
         </value>
        </constraint> */
     return $constElem;
 }
コード例 #7
0
ファイル: SerializeVisitor.php プロジェクト: moovly/recurly
 /**
  * Sets a child on the given DOMDocument
  * Returns true if a child was set, false if not
  *
  * @param \DOMElement $xml
  * @param mixed       $value
  * @param string      $variable
  * @param array       $options
  *
  * @return boolean
  */
 protected function setChild(\DOMElement $xml, $value, $variable, $options)
 {
     if (null === $value) {
         return false;
     }
     switch ($options['type']) {
         case 'string':
         case 'integer':
             $element = $this->dom->createElement($variable, $value);
             break;
         case 'boolean':
             $element = $this->dom->createElement($variable, $this->visitBoolean($value));
             break;
         case 'datetime':
             $element = $this->dom->createElement($variable, $this->visitDatetime($value));
             break;
         default:
             if (class_exists($options['type'])) {
                 // We mapped to an existing class
                 $element = $this->visitModel($value);
             } elseif ($this->isArrayType($options['type'], $arrayType, $keepKey)) {
                 // We mapped to an array<type>
                 $element = $this->dom->createElement($variable);
                 foreach ($value as $key => $val) {
                     $key = $keepKey ? $key : $options['key'];
                     $this->setChild($element, $val, $key, ['type' => $arrayType]);
                 }
             } else {
                 // A type we can't handle
                 return false;
             }
     }
     $xml->appendChild($element);
     return true;
 }
コード例 #8
0
ファイル: XmlHandler.php プロジェクト: Thomvh/turbine
 /**
  * @author Zack Douglas <*****@*****.**>
  */
 private function _future_serializeAsXml($value, $node = null, $dom = null)
 {
     if (!$dom) {
         $dom = new \DOMDocument();
     }
     if (!$node) {
         if (!is_object($value)) {
             $node = $dom->createElement('response');
             $dom->appendChild($node);
         } else {
             $node = $dom;
         }
     }
     if (is_object($value)) {
         $objNode = $dom->createElement(get_class($value));
         $node->appendChild($objNode);
         $this->_future_serializeObjectAsXml($value, $objNode, $dom);
     } else {
         if (is_array($value)) {
             $arrNode = $dom->createElement('array');
             $node->appendChild($arrNode);
             $this->_future_serializeArrayAsXml($value, $arrNode, $dom);
         } else {
             if (is_bool($value)) {
                 $node->appendChild($dom->createTextNode($value ? 'TRUE' : 'FALSE'));
             } else {
                 $node->appendChild($dom->createTextNode($value));
             }
         }
     }
     return array($node, $dom);
 }
コード例 #9
0
ファイル: sitemap.php プロジェクト: greor/satin-spb
 public function action_index()
 {
     if (!file_exists(DOCROOT . $this->sitemap_directory_base)) {
         throw new HTTP_Exception_404();
     }
     $this->site_code = ORM::factory('site', $this->request->site_id)->code;
     $this->sitemap_directory = $this->sitemap_directory_base . DIRECTORY_SEPARATOR . $this->site_code;
     $this->response->headers('Content-Type', 'text/xml')->headers('cache-control', 'max-age=0, must-revalidate, public')->headers('expires', gmdate('D, d M Y H:i:s', time()) . ' GMT');
     try {
         $dir = new DirectoryIterator(DOCROOT . $this->sitemap_directory);
         $xml = new DOMDocument('1.0', Kohana::$charset);
         $xml->formatOutput = TRUE;
         $root = $xml->createElement('sitemapindex');
         $root->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
         $xml->appendChild($root);
         foreach ($dir as $fileinfo) {
             if ($fileinfo->isDot() or $fileinfo->isDir()) {
                 continue;
             }
             $_file_path = str_replace(DOCROOT, '', $fileinfo->getPathName());
             $_file_url = $this->domain . '/' . str_replace(DIRECTORY_SEPARATOR, '/', $_file_path);
             $sitemap = $xml->createElement('sitemap');
             $root->appendChild($sitemap);
             $sitemap->appendChild(new DOMElement('loc', $_file_url));
             $_last_mod = Sitemap::date_format($fileinfo->getCTime());
             $sitemap->appendChild(new DOMElement('lastmod', $_last_mod));
         }
     } catch (Exception $e) {
         echo Debug::vars($e->getMessage());
         die;
     }
     echo $xml->saveXML();
 }
コード例 #10
0
 private function _buildTransaction($action, HpsCheck $check, $amount, $clientTransactionId = null)
 {
     $amount = HpsInputValidation::checkAmount($amount);
     if ($check->secCode == HpsSECCode::CCD && ($check->checkHolder == null || $check->checkHolder->checkName == null)) {
         throw new HpsInvalidRequestException(HpsExceptionCodes::MISSING_CHECK_NAME, 'For SEC code CCD, the check name is required', 'check_name');
     }
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsCheckSale = $xml->createElement('hps:CheckSale');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', sprintf("%0.2f", round($amount, 3))));
     $hpsBlock1->appendChild($this->_hydrateCheckData($check, $xml));
     $hpsBlock1->appendChild($xml->createElement('hps:CheckAction', $action));
     $hpsBlock1->appendChild($xml->createElement('hps:SECCode', $check->secCode));
     if ($check->checkType != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:CheckType', $check->checkType));
     }
     $hpsBlock1->appendChild($xml->createElement('hps:DataEntryMode', $check->dataEntryMode));
     if ($check->checkHolder != null) {
         $hpsBlock1->appendChild($this->_hydrateConsumerInfo($check, $xml));
     }
     $hpsCheckSale->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsCheckSale);
     return $this->_submitTransaction($hpsTransaction, 'CheckSale', $clientTransactionId);
 }
コード例 #11
0
ファイル: MAM.php プロジェクト: Hywan/moxl
 static function get($jid, $start = false, $end = false, $limit = false)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $query = $dom->createElementNS('urn:xmpp:mam:0', 'query');
     $x = $dom->createElementNS('jabber:x:data', 'x');
     $query->appendChild($x);
     $field_type = $dom->createElement('field');
     $field_type->setAttribute('var', 'FORM_TYPE');
     $field_type->appendChild($dom->createElement('value', 'urn:xmpp:mam:0'));
     $x->appendChild($field_type);
     $field_with = $dom->createElement('field');
     $field_with->setAttribute('var', 'with');
     $field_with->appendChild($dom->createElement('value', $jid));
     $x->appendChild($field_with);
     if ($start) {
         $field_start = $dom->createElement('field');
         $field_start->setAttribute('var', 'start');
         $field_start->appendChild($dom->createElement('value', date('Y-m-d\\TH:i:s\\Z', $start + 1)));
         $x->appendChild($field_start);
     }
     if ($end) {
         $field_end = $dom->createElement('field');
         $field_end->setAttribute('var', 'end');
         $field_end->appendChild($dom->createElement('value', date('Y-m-d\\TH:i:s\\Z', $end + 1)));
         $x->appendChild($field_end);
     }
     if ($limit) {
         $field_limit = $dom->createElement('field');
         $field_limit->setAttribute('var', 'limit');
         $field_limit->appendChild($dom->createElement($limit));
         $x->appendChild($field_limit);
     }
     $xml = \Moxl\API::iqWrapper($query, null, 'set');
     \Moxl\API::request($xml);
 }
コード例 #12
0
ファイル: Item.php プロジェクト: bardascat/blogify
 public function createXmlElement(DOMDocument $xmlDoc)
 {
     if (!$xmlDoc instanceof DOMDocument) {
         throw new Exception('', self::ERROR_INVALID_PARAMETER);
     }
     $xmlItemElem = $xmlDoc->createElement('item');
     if ($this->code == null || $this->name == null || $this->measurment == null || $this->quantity == null || $this->price == null || $this->vat == null) {
         throw new Exception('Invalid property', self::ERROR_INVALID_PROPERTY);
     }
     $xmlElem = $xmlDoc->createElement('code');
     $xmlElem->appendChild($xmlDoc->createCDATASection(urlencode($this->code)));
     $xmlItemElem->appendChild($xmlElem);
     $xmlElem = $xmlDoc->createElement('name');
     $xmlElem->appendChild($xmlDoc->createCDATASection(urlencode($this->name)));
     $xmlItemElem->appendChild($xmlElem);
     $xmlElem = $xmlDoc->createElement('measurment');
     $xmlElem->appendChild($xmlDoc->createCDATASection(urlencode($this->measurment)));
     $xmlItemElem->appendChild($xmlElem);
     $xmlElem = $xmlDoc->createElement('quantity');
     $xmlElem->nodeValue = $this->quantity;
     $xmlItemElem->appendChild($xmlElem);
     $xmlElem = $xmlDoc->createElement('price');
     $xmlElem->nodeValue = $this->price;
     $xmlItemElem->appendChild($xmlElem);
     $xmlElem = $xmlDoc->createElement('vat');
     $xmlElem->nodeValue = $this->vat;
     $xmlItemElem->appendChild($xmlElem);
     return $xmlItemElem;
 }
コード例 #13
0
ファイル: DfxpRenderer.php プロジェクト: ske/captions-php
 public function render($caption_set, $file = false)
 {
     $dom = new \DOMDocument("1.0");
     $dom->formatOutput = true;
     $root = $dom->createElement('tt');
     $dom->appendChild($root);
     $body = $dom->createElement('body');
     $root->appendChild($body);
     $xmlns = $dom->createAttribute('xmlns');
     $xmlns->appendChild($dom->createTextNode('http://www.w3.org/ns/ttml'));
     $root->appendChild($xmlns);
     $div = $dom->createElement('div');
     $body->appendChild($div);
     foreach ($caption_set->captions() as $index => $caption) {
         $entry = $dom->createElement('p');
         $from = $dom->createAttribute('begin');
         $from->appendChild($dom->createTextNode(DfxpHelper::time_to_string($caption->start())));
         $entry->appendChild($from);
         $to = $dom->createAttribute('end');
         $to->appendChild($dom->createTextNode(DfxpHelper::time_to_string($caption->end())));
         $entry->appendChild($to);
         $entry->appendChild($dom->createCDATASection($caption->text()));
         $div->appendChild($entry);
     }
     if ($file) {
         return file_put_contents($file, $dom->saveXML());
     } else {
         return $dom->saveHTML();
     }
 }
コード例 #14
0
 public function unequalObjectsProvider()
 {
     $dom = new \DOMDocument();
     $element1 = $dom->createElement('foo', 'bar');
     $element2 = $dom->createElement('foo', 'baz');
     return array(array(new \StdClass(), new TestClass()), array(new TestClass('foo'), new TestClass('bar')), array(new TestClass(new \StdClass()), new TestClass(new TestClass())), array(new TestClass(new TestClass('foo')), new TestClass(new TestClass('bar'))), array(new TestClass($element1), new TestClass($element2)));
 }
コード例 #15
0
ファイル: NewsDB.class.php プロジェクト: kapsilon/Specialist
 function createRss()
 {
     $dom = new DOMDocument("1.0", "utf-8");
     $dom->formatOutput = true;
     $dom->preserveWhiteSpace = false;
     $rss = $dom->createElement("rss");
     $dom->appendChild($rss);
     $version = $dom->createAttribute("version");
     $version->value = '2.0';
     $rss->appendChild($version);
     $channel = $dom->createElement("channel");
     $rss->appendChild($channel);
     $title = $dom->createElement("title", self::RSS_TITLE);
     $channel->appendChild($title);
     $link = $dom->createElement("link", self::RSS_LINK);
     $channel->appendChild($link);
     $items = $this->getNews();
     foreach ($items as $item) {
         $rssItem = $dom->createElement("item");
         $nTitle = $dom->createElement("title", $item["title"]);
         $nLink = $dom->createElement("link", $item["source"]);
         $nDesc = $dom->createElement("description", $item["description"]);
         $nPub = $dom->createElement("pubYear", $item["datetime"]);
         $nCategory = $dom->createElement("category", $item["category"]);
         $rssItem->appendChild($nTitle);
         $rssItem->appendChild($nLink);
         $rssItem->appendChild($nDesc);
         $rssItem->appendChild($nPub);
         $rssItem->appendChild($nCategory);
         $channel->appendChild($rssItem);
     }
     $dom->save(self::RSS_NAME);
 }
コード例 #16
0
ファイル: token.php プロジェクト: hegelmax/OAuth-2.0
 public function xml()
 {
     $doc = new DOMDocument('1.0', 'UTF-8');
     $doc->formatOutput = true;
     $oauth = $doc->createElement('OAuth');
     $doc->appendChild($oauth);
     if (empty($this->error)) {
         foreach (get_object_vars($this) as $key => $val) {
             if (empty($val)) {
                 continue;
             }
             $node = $doc->createElement($key);
             $node->appendChild($doc->createTextNode($val));
             $oauth->appendChild($node);
         }
     } else {
         $node = $doc->createElement('error');
         $node->appendChild($doc->createTextNode($this->error));
         $oauth->appendChild($node);
         if (property_exists($this, 'state') and $this->state) {
             $node = $doc->createElement('state');
             $node->appendChild($doc->createTextNode($this->state));
             $oauth->appendChild($node);
         }
     }
     return $doc->saveXML();
 }
コード例 #17
0
 public function xmlAction()
 {
     $this->getHelper('layout')->disableLayout();
     $this->getHelper('viewRenderer')->setNoRender();
     $model = new Stat_Model_Requests();
     $auth = Zend_Auth::getInstance();
     $ident = $auth->getIdentity();
     $requests = $model->getResponsesReports(0, $ident->STRUCTURE_CODE == 0 ? 0 : $ident->STRUCTUREID);
     $dom = new DOMDocument('1.0', 'utf-8');
     $root = $dom->createElement('requestlist');
     foreach ($requests as $request) {
         if ($request['UPLOADDATE']) {
             continue;
         }
         // Пропустить, если отчёт уже подан
         $publicDate = strtotime($request['PUBLICDATE']);
         if ($publicDate < strtotime('-30 day')) {
             continue;
         }
         // Пропустить, если от даты публикации прошло больше 30 дней
         $req = $dom->createElement('request');
         $req->setAttribute("id", $request['PERIODID']);
         $req->setAttribute("title", $request['REPORT'] . ' (' . $request['PERIOD'] . ')');
         $req->setAttribute("publicdate", $request['PUBLICDATE']);
         $root->appendChild($req);
     }
     $dom->appendChild($root);
     //		$dom->formatOutput = TRUE;
     header("Content-type: text/xml");
     echo $dom->saveXML();
 }
コード例 #18
0
	/**
	 * Cria o nó XML que representa o objeto ou conjunto de objetos na composição
	 * @return	string
	 * @see		Cielo::createXMLNode()
	 * @throws	BadMethodCallException Se a URL de retorno não tiver sido especificada
	 * @throws	BadMethodCallException Se os dados do pedido não tiver sido especificado
	 */
	public function createXMLNode() {
		if (  !empty( $this->tid ) ) {
			$dom = new DOMDocument( '1.0' , 'UTF-8' );
			$dom->loadXML( parent::createXMLNode() );
			$dom->encoding = 'UTF-8';

			$namespace = $this->getNamespace();
			$query = $dom->getElementsByTagNameNS( $namespace , $this->getRootNode() )->item( 0 );
			$EcData = $dom->getElementsByTagNameNS( $namespace , 'dados-ec' )->item( 0 );

			if ( $EcData instanceof DOMElement ) {
				$tid = $dom->createElement( 'tid' , $this->tid );
				$query->insertBefore( $tid , $EcData );

				if (  !is_null( $this->value ) ) {
					$value = $dom->createElement( 'valor' , $this->value );
					$query->insertBefore( $value , $EcData );
				}

				if (  !is_null( $this->annex ) ) {
					$annex = $dom->createElement( 'anexo' );
					$query->insertBefore( $annex , $EcData );
				}
			} else {
				throw new BadMethodCallException( 'O nó dados-ec precisa ser informado.' );
			}

			return $dom->saveXML();
		} else {
			throw new BadMethodCallException( 'O ID da transação deve ser informado.' );
		}
	}
コード例 #19
0
 public function searchAction()
 {
     // Get parameters from URL
     $center_lat = $this->getRequest()->getParam('lat');
     $center_lng = $this->getRequest()->getParam('lng');
     $radius = $this->getRequest()->getParam('radius');
     // Start XML file, create parent node
     $dom = new DOMDocument("1.0");
     $node = $dom->createElement("markers");
     $parnode = $dom->appendChild($node);
     $collection = Mage::getModel('storelocator/storelocator')->getCollection();
     if (isset($radius)) {
         $distance = sprintf("3959 * 0.621 * acos( cos( radians(%s) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(%s) ) + sin( radians(%s) ) * sin( radians( lat ) ) )", $center_lat, $center_lng, $center_lat);
         $collection->addExpressionFieldToSelect('distance', $distance, array('lat' => 'lat', 'lng' => 'lng'));
         $collection->getSelect()->having('distance < ' . $radius)->order('distance', 'ASC');
     }
     $stores = $collection->load();
     header("Content-type: text/xml");
     // Iterate through the rows, adding XML nodes for each
     foreach ($stores as $store) {
         $node = $dom->createElement("marker");
         $newnode = $parnode->appendChild($node);
         $newnode->setAttribute("id", $store['storelocator_id']);
         $newnode->setAttribute("name", $store['store_name']);
         $newnode->setAttribute("address", $store['address']);
         $newnode->setAttribute("city", $store['city']);
         $newnode->setAttribute("lat", $store['lat']);
         $newnode->setAttribute("lng", $store['lng']);
         $newnode->setAttribute("distance", $store['distance']);
     }
     echo $dom->saveXML();
 }
コード例 #20
0
 /**
  * Método que genera el formulario de pago en HTML
  *
  * @param string $button_type
  *   Dimensión del boton a mostrar
  *
  * @return string
  *   Formulario renderizado
  */
 public function renderForm($button_type = '100x50')
 {
     $values = $this->getFormLabels();
     $html = new DOMDocument();
     $html->formatOutput = true;
     $form = $html->createElement('form');
     $form->setAttribute('action', $this->getApiUrl());
     $form->setAttribute('method', 'POST');
     foreach ($values as $name => $value) {
         $input_hidden = $html->createElement('input');
         $input_hidden->setAttribute('type', 'hidden');
         $input_hidden->setAttribute('name', $name);
         $input_hidden->setAttribute('value', $value);
         $form->appendChild($input_hidden);
     }
     $input_hidden = $html->createElement('input');
     $input_hidden->setAttribute('type', 'hidden');
     $input_hidden->setAttribute('name', 'agent');
     $input_hidden->setAttribute('value', $this->agent);
     $form->appendChild($input_hidden);
     $buttons = Khipu::getButtonsKhipu();
     if (isset($buttons[$button_type])) {
         $button = $buttons[$button_type];
     } else {
         $button = $buttons['100x50'];
     }
     $submit = $html->createElement('input');
     $submit->setAttribute('type', 'image');
     $submit->setAttribute('src', $button);
     $form->appendChild($submit);
     $html->appendChild($form);
     return $html->saveHTML();
 }
コード例 #21
0
 /**
  * Creates a verify transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsCreditAccountVerify = $xml->createElement('hps:CreditAccountVerify');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     if ($this->cardHolder != null) {
         $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder, $xml));
     }
     $cardData = $xml->createElement('hps:CardData');
     if ($this->card != null) {
         $cardData->appendChild($this->service->_hydrateManualEntry($this->card, $xml, $this->cardPresent, $this->readerPresent));
         if ($this->card->encryptionData != null) {
             $cardData->appendChild($this->service->_hydrateEncryptionData($this->card->encryptionData));
         }
     } else {
         if ($this->token != null) {
             $cardData->appendChild($this->service->_hydrateTokenData($this->token, $xml, $this->cardPresent, $this->readerPresent));
         } else {
             if ($this->trackData != null) {
                 $cardData->appendChild($this->service->_hydrateTrackData($this->trackData));
                 if ($this->trackData->encryptionData != null) {
                     $cardData->appendChild($this->service->_hydrateEncryptionData($this->trackData->encryptionData));
                 }
             }
         }
     }
     $cardData->appendChild($xml->createElement('hps:TokenRequest', $this->requestMultiUseToken ? 'Y' : 'N'));
     $hpsBlock1->appendChild($cardData);
     $hpsCreditAccountVerify->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsCreditAccountVerify);
     return $this->service->_submitTransaction($hpsTransaction, 'CreditAccountVerify', $this->clientTransactionId);
 }
コード例 #22
0
ファイル: sitemap.php プロジェクト: romuland/khparts
 public function createSitemap()
 {
     $where = "published = 1 and menutype = 'mainmenu' and access IN (1)";
     $result = $this->db->select($this->table_prefix . "menu", "*", "{$where}", 'std');
     $dom = new DOMDocument('1.0');
     $dom->formatOutput = true;
     $root = $dom->createElement('urlset');
     $root = $dom->appendChild($root);
     $ns = $dom->createAttributeNS("http://www.sitemaps.org/schemas/sitemap/0.9", "xmlns");
     foreach ($result["value"] as $row) {
         $link_arr = parse_url($row['link']);
         if (isset($link_arr['query'])) {
             parse_str(html_entity_decode($link_arr['query']), $link_vars);
             $option = HELPER::getValue($link_vars, 'option', '');
             $view = HELPER::getValue($link_vars, 'view', '');
             $layout = HELPER::getValue($link_vars, 'layout', '');
             if ($option == "com_virtuemart" && $view == "category") {
                 $id = HELPER::getValue($link_vars, 'virtuemart_category_id', 0);
             } elseif ($option == "com_fabrik" && $view == "form") {
                 $id = HELPER::getValue($link_vars, 'formid', 0);
             } else {
                 $id = HELPER::getValue($link_vars, 'id', 0);
             }
             $url = $dom->createElement('url');
             $url = $root->appendChild($url);
             $this->setMenuUrl($view, $row, $option, $id, $dom, $root, $url);
         }
     }
     $str = $dom->saveXML();
     echo "Создана карта сайта sitemap.xml, размер " . $dom->save($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $this->SITEMAP_FILE_NAME) . " байт.";
 }
コード例 #23
0
ファイル: program_xml.php プロジェクト: h3len/Project
 function show()
 {
     $channel_id = $this->input['channel_id'];
     if (!$channel_id) {
         $this->errorOutput('该频道不存在或者已被删除');
     }
     $dates = $this->input['dates'];
     if (!$dates) {
         $this->errorOutput('这一天不存在节目');
     }
     $sql = "select * from " . DB_PREFIX . "program where channel_id=" . $channel_id . " AND dates='" . $dates . "' ORDER BY start_time ASC ";
     $q = $this->db->query($sql);
     header('Content-Type: text/xml; charset=UTF-8');
     $dom = new DOMDocument('1.0', 'utf-8');
     $program = $dom->createElement('program');
     while ($row = $this->db->fetch_array($q)) {
         $item = $dom->createElement('item');
         $item->setAttribute('name', urldecode($row['theme']));
         $item->setAttribute('startTime', $row['start_time'] * 1000);
         $item->setAttribute('duration', $row['toff'] * 1000);
         $program->appendChild($item);
     }
     $dom->appendChild($program);
     echo $dom->saveXml();
 }
コード例 #24
0
 public function buscar()
 {
     $this->autoRender = false;
     $dom = new DOMDocument("1.0");
     $node = $dom->createElement("markers");
     $parnode = $dom->appendChild($node);
     if (!$this->Auth->loggedIn()) {
         $conditions = array('conditions' => array('status !=' => '1'));
     }
     if (isset($this->data['status']) && $this->data['status'] != "") {
         if ($this->data['status'] == "-1") {
             if (!$this->Auth->loggedIn()) {
                 $conditions = array('conditions' => array('status !=' => '1'));
             }
         } else {
             $conditions = array('conditions' => array('status' => $this->data['status']));
         }
     }
     $results = $this->Marker->find("all", $conditions);
     if (!$results) {
         exit;
     }
     header("Content-type: text/xml");
     foreach ($results as $result) {
         $node = $dom->createElement("marker");
         $newnode = $parnode->appendChild($node);
         $newnode->setAttribute("id", $result['Marker']['id']);
         $newnode->setAttribute("lat", $result['Marker']['lat']);
         $newnode->setAttribute("lng", $result['Marker']['lng']);
         $newnode->setAttribute("status", $result['Marker']['status']);
         $newnode->setAttribute("created", $this->formatarData($result['Marker']['created']));
         $newnode->setAttribute("modified", $this->formatarData($result['Marker']['modified']));
     }
     return $dom->saveXML();
 }
コード例 #25
0
 /**
  * This method generates the checkstyle.xml report
  *
  * @param ProjectDescriptor $project        Document containing the structure.
  * @param Transformation    $transformation Transformation to execute.
  *
  * @return void
  */
 public function transform(ProjectDescriptor $project, Transformation $transformation)
 {
     $artifact = $this->getDestinationPath($transformation);
     $this->checkForSpacesInPath($artifact);
     $document = new \DOMDocument();
     $document->formatOutput = true;
     $report = $document->createElement('checkstyle');
     $report->setAttribute('version', '1.3.0');
     $document->appendChild($report);
     /** @var FileDescriptor $fileDescriptor */
     foreach ($project->getFiles()->getAll() as $fileDescriptor) {
         $file = $document->createElement('file');
         $file->setAttribute('name', $fileDescriptor->getPath());
         $report->appendChild($file);
         /** @var Error $error */
         foreach ($fileDescriptor->getAllErrors()->getAll() as $error) {
             $item = $document->createElement('error');
             $item->setAttribute('line', $error->getLine());
             $item->setAttribute('severity', $error->getSeverity());
             $item->setAttribute('message', vsprintf($this->getTranslator()->translate($error->getCode()), $error->getContext()));
             $item->setAttribute('source', 'phpDocumentor.file.' . $error->getCode());
             $file->appendChild($item);
         }
     }
     $this->saveCheckstyleReport($artifact, $document);
 }
コード例 #26
0
ファイル: CPD.php プロジェクト: kdambekalns/framework-benchs
 /**
  * @param  PHPUnit_Framework_TestResult $result
  */
 public function process(PHPUnit_Framework_TestResult $result, $minLines = 5, $minMatches = 70)
 {
     $codeCoverage = $result->getCodeCoverageInformation();
     $summary = PHPUnit_Util_CodeCoverage::getSummary($codeCoverage);
     $files = array_keys($summary);
     $metrics = new PHPUnit_Util_Metrics_Project($files, $summary, TRUE, $minLines, $minMatches);
     $document = new DOMDocument('1.0', 'UTF-8');
     $document->formatOutput = TRUE;
     $cpd = $document->createElement('pmd-cpd');
     $cpd->setAttribute('version', 'PHPUnit ' . PHPUnit_Runner_Version::id());
     $document->appendChild($cpd);
     foreach ($metrics->getDuplicates() as $duplicate) {
         $xmlDuplication = $cpd->appendChild($document->createElement('duplication'));
         $xmlDuplication->setAttribute('lines', $duplicate['numLines']);
         $xmlDuplication->setAttribute('tokens', $duplicate['numTokens']);
         $xmlFile = $xmlDuplication->appendChild($document->createElement('file'));
         $xmlFile->setAttribute('path', $duplicate['fileA']->getPath());
         $xmlFile->setAttribute('line', $duplicate['firstLineA']);
         $xmlFile = $xmlDuplication->appendChild($document->createElement('file'));
         $xmlFile->setAttribute('path', $duplicate['fileB']->getPath());
         $xmlFile->setAttribute('line', $duplicate['firstLineB']);
         $xmlDuplication->appendChild($document->createElement('codefragment', PHPUnit_Util_XML::prepareString(join('', array_slice($duplicate['fileA']->getLines(), $duplicate['firstLineA'] - 1, $duplicate['numLines'])))));
     }
     $this->write($document->saveXML());
     $this->flush();
 }
コード例 #27
0
 public function renderXml()
 {
     $system =& $this->_params['system'];
     $widgets =& $this->_params['widgets'];
     $document = new DOMDocument('1.0', 'utf-8');
     $document->formatOutput = true;
     $rootNode = $document->createElement('widget_framework');
     $rootNode->setAttribute('version', $system['version_string']);
     $document->appendChild($rootNode);
     foreach ($widgets as $widget) {
         $widgetNode = $document->createElement('widget');
         $widgetNode->setAttribute('title', $widget['title']);
         $widgetNode->setAttribute('class', $widget['class']);
         $optionsNode = $document->createElement('options');
         $optionsString = $widget['options'];
         if (!is_string($optionsString)) {
             $optionsString = serialize($optionsString);
         }
         $optionsData = XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $optionsString);
         $optionsNode->appendChild($optionsData);
         $widgetNode->appendChild($optionsNode);
         $widgetNode->setAttribute('position', $widget['position']);
         $widgetNode->setAttribute('display_order', $widget['display_order']);
         $widgetNode->setAttribute('active', $widget['active']);
         $rootNode->appendChild($widgetNode);
     }
     $this->setDownloadFileName('widget_framework-widgets-' . XenForo_Template_Helper_Core::date(XenForo_Application::$time, 'YmdHi') . '.xml');
     return $document->saveXml();
 }
 /**
  *
  * @param DOMElement $items
  * @param DOMDocument $xml
  * @param array $data 
  */
 protected function addHTMLChildren($items, $xml, &$data, $css, &$javascripts)
 {
     $items->appendChild($itemsInner = $xml->createElement('div', 'items-inner'));
     $itemsInner->appendChild($table = $xml->createElement('table'));
     $table->appendChild($row = $xml->createElement('tr'));
     $s = isset($data['settings']['currentscreen']) ? $data['settings']['currentscreen'] : null;
     $data['settings']['currentscreen'] = $this->getId();
     $i = 0;
     $cols = $this->getStyle('cols');
     if (!$cols) {
         $cols = 3;
     }
     foreach ($this->children as $child) {
         $c = $child->getHTMLNode($xml, $data);
         if ($c) {
             if ($i == $cols) {
                 $table->appendChild($row = $xml->createElement('tr'));
                 $i = 0;
             }
             $i++;
             $row->appendChild($c);
         }
         $child->getCSS($css, $data);
         $child->getJavascript($javascripts);
     }
     while ($i < $cols) {
         $row->appendChild($xml->createElement('td'));
         $i++;
     }
     $data['settings']['currentscreen'] = $s;
 }
コード例 #29
0
ファイル: I18nXml.php プロジェクト: suga/Megiddo
 public static function create($isoLang = 'pt_BR')
 {
     $xmlDoc = new DOMDocument('1.0', 'utf-8');
     $xmlDoc->formatOutput = true;
     $culture = $xmlDoc->createElement($isoLang);
     $culture = $xmlDoc->appendChild($culture);
     $criteria = new Criteria();
     $criteria->add(TagI18n::TABLE . '.' . TagI18n::ISOLANG, $isoLang);
     $objTagI18n = new TagI18nPeer();
     $arrayObjTagI18n = $objTagI18n->doSelect($criteria);
     if (!is_object($arrayObjTagI18n) && count($arrayObjTagI18n == 0)) {
         $log = new Log();
         $log->setLog(__FILE__, 'There are no tags with that language ' . $isoLang, true);
         throw new Exception('There are no tags with that language ' . $isoLang);
     }
     foreach ($arrayObjTagI18n as $objTagI18nPeer) {
         $item = $xmlDoc->createElement('item');
         $item->setAttribute('idTagI18n', $objTagI18nPeer->getIdTagI18n());
         $item = $culture->appendChild($item);
         $title = $xmlDoc->createElement('tag', utf8_encode($objTagI18nPeer->getTag()));
         $title = $item->appendChild($title);
         $link = $xmlDoc->createElement('i18n', utf8_encode($objTagI18nPeer->getTranslate()));
         $link = $item->appendChild($link);
     }
     //header("Content-type:application/xml; charset=utf-8");
     $file = PATH . PATH_I18N . $isoLang . '.xml';
     try {
         file_put_contents($file, $xmlDoc->saveXML());
     } catch (Exception $e) {
         $log = new Log();
         $log->setLog(__FILE__, 'Unable to write the XML file I18n ' . $e->getMessage(), true);
     }
     return true;
 }
コード例 #30
0
 /**
  * Converts an array of command-line arguments to the equivalent XML,
  * writes this XML to a temporary file, and returns the path to the file.
  *
  * @param array $args
  * @return string
  */
 private function _argsToXML(array $args)
 {
     $xml = new \DOMDocument('1.0', 'UTF-8');
     $conf = $xml->createElement('conf');
     $xml->appendChild($conf);
     $queries = $xml->createElement('queries');
     $conf->appendChild($queries);
     $globalArgs = array('email', 'file', 'group-name', 'formatter');
     foreach ($globalArgs as $arg) {
         if (isset($args[$arg])) {
             $conf->setAttribute($arg, $args[$arg]);
             unset($args[$arg]);
         }
     }
     /* See if there are any arrays in the argument list, which means we'll
        be doing multiple queries. */
     $multipleArgs = array();
     $keys = array_keys($args);
     foreach ($keys as $key) {
         if (is_array($args[$key])) {
             $multipleArgs[$key] = $args[$key];
             unset($args[$key]);
         }
     }
     /* If we're doing a single query, just put everything in the <query>
        element; otherwise, put all the single instances in the <conf> element
        and everything else in its own <query> element. */
     if ($multipleArgs) {
         foreach ($args as $arg => $argVal) {
             $conf->setAttribute($arg, $argVal);
         }
         /* It's the responsibility of the test writer to ensure that the
            parameter counts are correct, because we're assuming that we can
            examine an arbitrary member of $multipleArgs and know how many
            queries we're doing. */
         $queryCount = count($multipleArgs[key($multipleArgs)]);
         for ($i = 0; $i < $queryCount; $i++) {
             $query = $xml->createElement('query');
             $queries->appendChild($query);
             foreach ($multipleArgs as $key => $argList) {
                 // We can skip the placeholders
                 if ($argList[$i] == '_') {
                     continue;
                 }
                 // We can also unescape
                 if ($argList[$i] == '\\_') {
                     $argList[$i] = '_';
                 }
                 $query->setAttribute($key, $argList[$i]);
             }
         }
     } else {
         $query = $xml->createElement('query');
         $queries->appendChild($query);
         foreach ($args as $arg => $argVal) {
             $query->setAttribute($arg, $argVal);
         }
     }
     return $this->_createTempFile(null, $xml->saveXML());
 }