/**
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getContainer();
     $contentLoaderService = $container->get('blend_ez_sitemap.content');
     $locations = $contentLoaderService->loadLocations();
     $sitemap = new \DOMDocument('1.0', 'utf-8');
     $sitemap->preserveWhiteSpace = false;
     $sitemap->formatOutput = true;
     $urlSet = $sitemap->createElement('urlset');
     $sitemap->appendChild($urlSet);
     // add url blocks to sitemap xml
     //  <url>
     //    <loc>/</loc>
     //    <lastmod>2015-06-15</lastmod>
     //  </url>
     foreach ($locations as $location) {
         // create url block
         $urlBlock = $sitemap->createElement('url');
         $urlSet->appendChild($urlBlock);
         // create loc tag
         $loc = $sitemap->createElement('loc');
         $urlBlock->appendChild($loc);
         $url = $container->get('router')->generate($location);
         $locText = $sitemap->createTextNode($url);
         $loc->appendChild($locText);
         // create lastmod tag
         $lastmod = $sitemap->createElement('lastmod');
         $urlBlock->appendChild($lastmod);
         $lastmodText = $sitemap->createTextNode($location->contentInfo->modificationDate->format('Y-m-d'));
         $lastmod->appendChild($lastmodText);
     }
     $fp = fopen('web/sitemap.xml', 'w');
     fwrite($fp, $sitemap->saveXml());
     fclose($fp);
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument('file');
     if (!preg_match("'^/|(?:[^:\\\\/]+://)|(?:[a-z]:[\\\\/])'i", $file)) {
         $file = $this->directory . '/resource/' . $file . '.html.xml';
     }
     $file = Filesystem::normalizePath($file);
     $questionHelper = $this->getHelper('question');
     $question = new ConfirmationQuestion(sprintf('Create view <info>%s</info>? [n] ', $file), false);
     if (!$questionHelper->ask($input, $output, $question)) {
         return;
     }
     $xml = new \DOMDocument('1.0', 'UTF-8');
     $xml->formatOutput = true;
     $root = $xml->appendChild($xml->createElementNS(ExpressViewParser::NS_EXPRESS, 'k:composition'));
     $root->appendChild($xml->createAttribute('extends'));
     $root->appendChild($xml->createAttribute('xmlns'))->appendChild($xml->createTextNode(ExpressViewParser::NS_XHTML));
     $root->appendChild($xml->createTextNode("\n\n  "));
     $block = $root->appendChild($xml->createElementNS(ExpressViewParser::NS_EXPRESS, 'k:block'));
     $block->appendChild($xml->createAttribute('name'))->appendChild($xml->createTextNode('main'));
     $block->appendChild($xml->createTextNode("\n    TODO: Create composition contents...\n  "));
     $root->appendChild($xml->createTextNode("\n\n"));
     Filesystem::writeFile($file, $xml->saveXML());
     $output->writeln('');
     $output->writeln(sprintf('CREATED: <info>%s</info>', $file));
 }
Example #3
0
 /**
  * 生成DOMElement树
  * array(
  *		'tagName'=>'Shanghai',			// 标签名称
  *		'nodeValue'=>'',				// 标签值,可选
  *		'attributeArr'=>array(),		// 属性值, 可选
  *		'subElementArr'=>array(			// 子节点,跟父类数据结构一样,可选
  *			array(
  *				'tagName'=>'Hongkou',
  *				'nodeValue'=>'Hongkou nodeValue',
  *				'attributeArr'=>array('lng'=>'100', 'lat'=>'300'),
  *				'subElementArr'=>array(),
  *			),
  *			array(
  *				'tagName'=>'Xuhui',
  *				'nodeValue'=>'Xuhui nodeValue',
  *				'attributeArr'=>array('lng'=>'200', 'lat'=>'400'),
  *				'subElementArr'=>array(),
  *			),
  *		),
  *	);
  * @param DOMDocument $DOMDocument 用于生成中间环节的DOMElement,DOMText,DOMAttr等,直接new DOMElement会出现不可写的报错
  * @param Array $arr
  */
 public static function DOMElement(DOMDocument $DOMDocument, $arr)
 {
     $DOMElement = $DOMDocument->createElement($arr['tagName']);
     $DOMDocument->appendChild($DOMElement);
     if (!empty($arr['nodeValue'])) {
         // 如果存在节点文本,则添加该文本
         $textNode = $DOMDocument->createTextNode($arr['nodeValue']);
         $DOMElement->appendChild($textNode);
     }
     if (!empty($arr['attributeArr'])) {
         // 如果存在属性,则循环为当前标签添加属性
         foreach ($arr['attributeArr'] as $k => $v) {
             $attribute = $DOMDocument->createAttribute($k);
             $attribute->appendChild($DOMDocument->createTextNode($v));
             $DOMElement->appendChild($attribute);
         }
     }
     if (!empty($arr['subElementArr'])) {
         // 如果存在子节点,则循环追加子节点
         foreach ($arr['subElementArr'] as $subElement) {
             $DOMElement->appendChild(self::DOMElement($DOMDocument, $subElement));
         }
     }
     return $DOMElement;
 }
 /**
  * @param \DOMDocument $dom
  * @param \DOMElement $productNode
  * @param Product $product
  */
 protected function addCommonNodesToContentDom($dom, \DOMElement $productNode, Product $product)
 {
     $productIdNode = $dom->createElement("id", $product->getProductId());
     $productNode->appendChild($productIdNode);
     $storeIdNode = $dom->createElement("storeid", $product->getStoreId());
     $productNode->appendChild($storeIdNode);
     $languageNode = $dom->createElement("language", $product->getLanguage());
     $productNode->appendChild($languageNode);
     $availabilityNode = $dom->createElement("availability", $product->getAvailability() ? 1 : 0);
     $productNode->appendChild($availabilityNode);
     $skuNode = $dom->createElement("sku", $product->getSku());
     $productNode->appendChild($skuNode);
     $titleNode = $dom->createElement("title");
     $titleValueTextNode = $dom->createTextNode($product->getTitle());
     $titleNode->appendChild($titleValueTextNode);
     $productNode->appendChild($titleNode);
     $descriptionNode = $dom->createElement("description");
     $descriptionValueTextNode = $dom->createTextNode($product->getDescription());
     $descriptionNode->appendChild($descriptionValueTextNode);
     $productNode->appendChild($descriptionNode);
     $shortDescriptionNode = $dom->createElement("short_description");
     $shortDescriptionValueTextNode = $dom->createTextNode($product->getShortDescription());
     $shortDescriptionNode->appendChild($shortDescriptionValueTextNode);
     $productNode->appendChild($shortDescriptionNode);
     $priceNode = $dom->createElement("price", number_format($product->getPrice(), 2));
     $productNode->appendChild($priceNode);
     $specialPriceNode = $dom->createElement("special_price", number_format($product->getSpecialPrice(), 2));
     $productNode->appendChild($specialPriceNode);
     $groupPriceNode = $dom->createElement("group_price", number_format($product->getGroupPrice(), 2));
     $productNode->appendChild($groupPriceNode);
     $imageLink = $dom->createElement("image_link", $product->getImageLink());
     $productNode->appendChild($imageLink);
 }
Example #5
0
function Write($title1, $title2, $author1, $author2, $publisher1, $publisher2)
{
    $books = array();
    $books[] = array('title' => $title1, 'author' => $author1, 'publisher' => $publisher1);
    $books[] = array('title' => $title2, 'author' => $author2, 'publisher' => $publisher2);
    $dom = new DOMDocument();
    $dom->formatOutput = true;
    $r = $dom->createElement("books");
    $dom->appendChild($r);
    foreach ($books as $book) {
        $b = $dom->createElement("book");
        $author = $dom->createElement("author");
        $author->appendChild($dom->createTextNode($book['author']));
        $b->appendChild($author);
        $title = $dom->createElement("title");
        $title->appendChild($dom->createTextNode($book['title']));
        $b->appendChild($title);
        $publisher = $dom->createElement("publisher");
        $publisher->appendChild($dom->createTextNode($book['publisher']));
        $b->appendChild($publisher);
        $r->appendChild($b);
    }
    global $diretorio;
    $fileSave = rand(100000000, 900000000) . ".xml";
    $dir_fileSave = $diretorio . $fileSave;
    $fp = fopen($dir_fileSave, "a");
    $escreve = fwrite($fp, $dom->saveXML());
    fclose($fp);
    echo "<div style='min-height:100px;background-color:rgba(255,255,255,0.2);margin-top:15px;padding:5px;border:1px solid gray;margin-bottom:15px;'>";
    echo "<div style='font-weight:bold;color:yellow;'>Xml gerado com sucesso!<br/>Nome do arquivo: {$fileSave}</div>";
    echo "<pre style='color:yellow;'>" . $dom->saveXML() . "</pre>";
    echo "</div>";
}
Example #6
0
 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();
     }
 }
Example #7
0
 function render()
 {
     $dom = new DOMDocument("1.0");
     $root = $dom->createElement("gpx");
     $dom->appendChild($root);
     $creator = $dom->createAttribute("createor");
     $version = $dom->createAttribute("version");
     $version_value = $dom->createTextNode("1.0");
     $version->appendChild($version_value);
     $root->appendChild($creator);
     $root->appendChild($version);
     $trk = $dom->createElement("trk");
     $root->appendChild($trk);
     $trkseg = $dom->createElement("trkseg");
     $trk->appendChild($trkseg);
     /* Create the items */
     foreach ($this->data as $point) {
         $trkpt = $dom->createElement("trkpt");
         foreach ($point as $key => $value) {
             $attribute = $dom->createAttribute($key);
             $text = $dom->createTextNode($value);
             $attribute->appendChild($text);
             $trkpt->appendChild($attribute);
         }
         $trkseg->appendChild($trkpt);
     }
     header("Content-type: text/xml");
     return $dom->saveXML();
 }
Example #8
0
  private static function empty_news_xml($version, $encoding) {
    $newdoc = new DOMDocument($version, $encoding);
    
    /* rss wrapper section */

    $root = $newdoc->createElement('rss');
    $newdoc->appendChild($root);

    $version = $newdoc->createAttribute('version');
    $version->appendChild($newdoc->createTextNode('2.0'));
    $root->appendChild($version);

    $channel = $newdoc->createElement('channel');
    $root = $root->appendChild($channel);

    $title = $newdoc->createElement('title');
    $channel->appendChild($title);

    $link = $newdoc->createElement('link');
    $channel->appendChild($link);
    $link->appendChild($newdoc->createTextNode('http://web.mit.edu/newsoffice'));

    $description = $newdoc->createElement('description');
    $channel->appendChild($description);

    return $newdoc;
  }
 function geraXML()
 {
     $this->Id = 'ID' . $this->cUF . $this->CNPJ . $this->mod . $this->serie . $this->nNFIni . $this->nNFFin;
     $dom = new DOMDocument('1.0', 'utf-8');
     $dom->formatOutput = false;
     $DP01 = $dom->appendChild($dom->createElement('inutNFe'));
     $DP01_att1 = $DP01->appendChild($dom->createAttribute('versao'));
     $DP01_att1->appendChild($dom->createTextNode($this->versao));
     $DP01_att2 = $DP01->appendChild($dom->createAttribute('xmlns'));
     $DP01_att2->appendChild($dom->createTextNode('http://www.portalfiscal.inf.br/nfe'));
     $DP03 = $DP01->appendChild($dom->createElement('infInut'));
     $DP04 = $DP03->setAttribute('Id', $this->Id);
     $DP05 = $DP03->appendChild($dom->createElement('tpAmb', $this->tpAmb));
     $DP06 = $DP03->appendChild($dom->createElement('xServ', $this->xServ));
     $DP07 = $DP03->appendChild($dom->createElement('cUF', $this->cUF));
     $DP08 = $DP03->appendChild($dom->createElement('ano', $this->ano));
     $DP09 = $DP03->appendChild($dom->createElement('CNPJ', $this->CNPJ));
     $DP10 = $DP03->appendChild($dom->createElement('mod', $this->mod));
     $DP11 = $DP03->appendChild($dom->createElement('serie', $this->serie));
     $DP12 = $DP03->appendChild($dom->createElement('nNFIni', $this->nNFIni));
     $DP13 = $DP03->appendChild($dom->createElement('nNFFin', $this->nNFFin));
     $DP14 = $DP03->appendChild($dom->createElement('xJust', $this->xJust));
     $xml = $dom->saveXML();
     $assinatura = new assinatura();
     $this->XML = $assinatura->assinaXML($xml, 'infInut');
     return $this->XML;
 }
 public function generateIndex()
 {
     // Create dom object
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->formatOutput = true;
     $dom->substituteEntities = false;
     // Create <urlset> root tag
     $sitemapindex = $dom->createElement('sitemapindex');
     // Add attribute of urlset
     $xmlns = $dom->createAttribute('xmlns');
     $sitemapindexText = $dom->createTextNode('http://www.sitemaps.org/schemas/sitemap/0.9');
     $sitemapindex->appendChild($xmlns);
     $xmlns->appendChild($sitemapindexText);
     foreach ($this->generators as $generator) {
         $sitemap = $dom->createElement('sitemap');
         $loc = $dom->createElement('loc');
         $loc->appendChild($dom->createTextNode($generator->getWebFilePath()));
         $sitemap->appendChild($loc);
         $lastmod = $dom->createElement('lastmod');
         $lastmod->appendChild($dom->createTextNode(date('Y-m-d')));
         $sitemap->appendChild($lastmod);
         $sitemapindex->appendChild($sitemap);
     }
     $dom->appendChild($sitemapindex);
     return $dom->save($this->config['file_path']);
 }
 public function format(array $messages)
 {
     $dom = new \DOMDocument('1.0', 'utf-8');
     $dom->formatOutput = true;
     $xliff = $dom->appendChild($dom->createElement('xliff'));
     $xliff->setAttribute('version', '1.2');
     $xliff->setAttribute('xmlns', 'urn:oasis:names:tc:xliff:document:1.2');
     $xliffFile = $xliff->appendChild($dom->createElement('file'));
     $xliffFile->setAttribute('source-language', $this->source);
     $xliffFile->setAttribute('datatype', 'plaintext');
     $xliffFile->setAttribute('original', 'file.ext');
     $xliffBody = $xliffFile->appendChild($dom->createElement('body'));
     $id = 1;
     foreach ($messages as $source => $target) {
         $trans = $dom->createElement('trans-unit');
         $trans->setAttribute('id', $id);
         $s = $trans->appendChild($dom->createElement('source'));
         $s->appendChild($dom->createTextNode($source));
         $t = $trans->appendChild($dom->createElement('target'));
         $t->appendChild($dom->createTextNode($target));
         $xliffBody->appendChild($trans);
         $id++;
     }
     return $dom->saveXML();
 }
Example #12
0
 public function actionMap()
 {
     Yii::$app->response->format = Response::FORMAT_RAW;
     $headers = Yii::$app->response->headers;
     $headers->add('Content-Type', 'text/xml');
     $dom = new \DOMDocument("1.0", "utf-8");
     $root = $dom->createElement("urlset");
     $root->setAttribute("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
     $dom->appendChild($root);
     $categories = Category::findAll(['is_active' => 1]);
     $articles = Article::findAll(['is_active' => 1]);
     $items = array_merge($categories, $articles);
     foreach ($items as $item) {
         $url = $dom->createElement("url");
         $loc = $dom->createElement("loc");
         if ($item instanceof Article) {
             $loc->appendChild($dom->createTextNode(Url::to(['article/view', 'id' => $item->id], true)));
         } else {
             $loc->appendChild($dom->createTextNode(Url::to(['category/view', 'id' => $item->id], true)));
         }
         $lastmod = $dom->createElement("lastmod");
         $lastmod->appendChild($dom->createTextNode($item->timestamp));
         $changefreq = $dom->createElement("changefreq");
         $changefreq->appendChild($dom->createTextNode("monthly"));
         $priority = $dom->createElement("priority");
         $priority->appendChild($dom->createTextNode("0.5"));
         $url->appendChild($loc);
         $url->appendChild($lastmod);
         $url->appendChild($changefreq);
         $url->appendChild($priority);
         $root->appendChild($url);
     }
     return $dom->saveXML();
 }
Example #13
0
 /**
  * Create a representation of this object in the given media type.
  *
  * @param  $mediaType The media (MIME) type to produce a representation in.
  * @return mixed A scalar value.
  */
 public function render($mediaType)
 {
     if ($mediaType != 'application/xml') {
         throw new \Exception('Cannot process anything other than application/xml');
     }
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->formatOutput = true;
     $root = $dom->createElement('Users');
     $root = $dom->appendChild($root);
     foreach ($this->_getUsers() as $userInfo) {
         $user = $dom->createElement('User');
         $user = $root->appendChild($user);
         $userId = $dom->createElement('ID');
         $userId = $user->appendChild($userId);
         $text = $dom->createTextNode($userInfo['id']);
         $text = $userId->appendChild($text);
         $fName = $dom->createElement('FirstName');
         $fName = $user->appendChild($fName);
         $text = $dom->createTextNode($userInfo['fname']);
         $text = $fName->appendChild($text);
         $lName = $dom->createElement('LastName');
         $lName = $user->appendChild($lName);
         $text = $dom->createTextNode($userInfo['lname']);
         $text = $lName->appendChild($text);
     }
     return $dom->saveXML();
 }
 /**
  *
  * @param  string        $event
  * @param  Array         $params
  * @param  mixed content $object
  * @return Void
  */
 public function fire($event, $params, &$object)
 {
     $default = ['usr_id' => null, 'lst' => '', 'ssttid' => '', 'dest' => '', 'reason' => ''];
     $params = array_merge($default, $params);
     $dom_xml = new DOMDocument('1.0', 'UTF-8');
     $dom_xml->preserveWhiteSpace = false;
     $dom_xml->formatOutput = true;
     $root = $dom_xml->createElement('datas');
     $lst = $dom_xml->createElement('lst');
     $ssttid = $dom_xml->createElement('ssttid');
     $dest = $dom_xml->createElement('dest');
     $reason = $dom_xml->createElement('reason');
     $lst->appendChild($dom_xml->createTextNode($params['lst']));
     $ssttid->appendChild($dom_xml->createTextNode($params['ssttid']));
     $dest->appendChild($dom_xml->createTextNode($params['dest']));
     $reason->appendChild($dom_xml->createTextNode($params['reason']));
     $root->appendChild($lst);
     $root->appendChild($ssttid);
     $root->appendChild($dest);
     $root->appendChild($reason);
     $dom_xml->appendChild($root);
     $datas = $dom_xml->saveXml();
     $mailed = false;
     if ($this->shouldSendNotificationFor($params['usr_id'])) {
         if (parent::email()) {
             $mailed = true;
         }
     }
     $this->broker->notify($params['usr_id'], __CLASS__, $datas, $mailed);
     return;
 }
Example #15
0
/**
 * This function is used to add quickly a DOMElement into another one
 *
 * @param DOMDocument $dom The xml document currently considered
 * @param DOMElement $nodeToAdd The dom element wherein the new dom node will be added
 * @param String $markupAndAttribute The specification of the new dom node
 * @param String $textContent Allow to add a textual content within the new node if needed
 *
 * Here is an inline example:
 * $newDomElement = xa($doc, $parentNode, 'newMarkupName'.xs.'param1=val1'.xs.'param2=val2', 'myTextContent');
 *
 * @return DOMElement The reference to the new created dom element
 */
function &xa(&$dom, &$nodeToAdd, $markupAndAttribute, $textContent = '')
{
    $tab = explode(xs, $markupAndAttribute);
    $markup = trim($tab[0]);
    unset($tab[0]);
    $attributes = array();
    foreach ($tab as $attAndValue) {
        if (!empty($attAndValue)) {
            list($attName, $attValue) = explode('=', $attAndValue);
            $attributes[$attName] = $attValue;
        }
    }
    $markupElt = $dom->createElement($markup);
    if (is_array($attributes)) {
        foreach ($attributes as $name => $value) {
            $att = $dom->createAttribute($name);
            $markupElt->appendChild($att);
            $attValue = $dom->createTextNode($value);
            $att->appendChild($attValue);
        }
    }
    $nodeToAdd->appendChild($markupElt);
    if (!empty($textContent) || $textContent === '0') {
        $txt = $dom->createTextNode($textContent);
        $markupElt->appendChild($txt);
    }
    return $markupElt;
}
Example #16
0
 public static function busdetail($data)
 {
     //print_r($data); exit;
     $date = date('Y-m-d', strtotime($data['formdate']));
     //header("Content-Type: text/xml");
     $xmlDoc = new DOMDocument();
     $root = $xmlDoc->appendChild($xmlDoc->createElement("soapenv:Envelope"));
     $root->appendChild($xmlDoc->createAttribute("xmlns:soapenv"))->appendChild($xmlDoc->createTextNode("http://www.w3.org/2003/05/soap-envelope"));
     $root->appendChild($xmlDoc->createAttribute("xmlns:bus"))->appendChild($xmlDoc->createTextNode("http://192.168.0.131/TT/BusBookingAPI"));
     $header = $root->appendChild($xmlDoc->createElement("soapenv:Header"));
     $authenticationdata = $header->appendChild($xmlDoc->createElement("bus:AuthenticationData"));
     //$authenticationdata->appendChild(
     //$xmlDoc->createElement("bus:SiteName",""));
     //$authenticationdata->appendChild(
     //$xmlDoc->createElement("bus:AccountCode",""));
     $authenticationdata->appendChild($xmlDoc->createElement("bus:UserName", "appan"));
     $authenticationdata->appendChild($xmlDoc->createElement("bus:Password", "appan@1234"));
     $body = $root->appendChild($xmlDoc->createElement("soapenv:Body"));
     $searchrequest = $body->appendChild($xmlDoc->createElement("bus:Search"));
     $search = $searchrequest->appendChild($xmlDoc->createElement("bus:wsBusSearchRequest"));
     $search->appendChild($xmlDoc->createElement("bus:SourceId", $data['formplace']));
     $search->appendChild($xmlDoc->createElement("bus:DestinationId", $data['toplace']));
     $search->appendChild($xmlDoc->createElement("bus:DateOfJourney", $date));
     $search->appendChild($xmlDoc->createElement("bus:SourceName", $data['sourcename']));
     $search->appendChild($xmlDoc->createElement("bus:DestinationName", $data['destinationname']));
     $search->appendChild($xmlDoc->createElement("bus:IsDomestic", '1'));
     $xmlDoc->formatOutput = true;
     //print_r($xmlDoc);
     return $xmlDoc->saveXML();
 }
Example #17
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();
 }
Example #18
0
function PrintResult($result, $log, $type, $index)
{
    header("content-type: application/xml; charset=UTF-8");
    $xmlDoc = new DOMDocument('1.0', 'UTF-8');
    $xmlDoc->formatOutput = true;
    $xmlRoot = $xmlDoc->createElement('xml');
    $xmlRoot = $xmlDoc->appendChild($xmlRoot);
    $xmlResult = $xmlDoc->createElement('result');
    $xmlRoot->appendChild($xmlResult);
    foreach ($index as $value) {
        $int = $xmlDoc->createElement('int');
        $pint = $xmlDoc->createTextNode($value);
        $int->appendChild($pint);
        $xmlResult->appendChild($int);
    }
    while ($row = mysqli_fetch_array($result)) {
        $rowElem = $xmlDoc->createElement('row');
        foreach ($index as $value) {
            $colElem = $xmlDoc->createElement('col');
            $valElem = $xmlDoc->createTextNode($row[$value]);
            $colElem->appendChild($valElem);
            $rowElem->appendChild($colElem);
        }
        $xmlResult->appendChild($rowElem);
    }
    $xmlLog = $xmlDoc->createElement('log', $log);
    $xmlRoot->appendChild($xmlLog);
    $xmlLType = $xmlDoc->createElement('type', $type);
    $xmlRoot->appendChild($xmlLType);
    //stampa del file xml
    echo $xmlDoc->saveXML();
}
 /**
  * {@inheritdoc}
  */
 protected function format(MessageCatalogue $messages, $domain)
 {
     $dom = new \DOMDocument('1.0', 'utf-8');
     $dom->formatOutput = true;
     $xliff = $dom->appendChild($dom->createElement('xliff'));
     $xliff->setAttribute('version', '1.2');
     $xliff->setAttribute('xmlns', 'urn:oasis:names:tc:xliff:document:1.2');
     $xliffFile = $xliff->appendChild($dom->createElement('file'));
     $xliffFile->setAttribute('source-language', $messages->getLocale());
     $xliffFile->setAttribute('datatype', 'plaintext');
     $xliffFile->setAttribute('original', 'file.ext');
     $xliffBody = $xliffFile->appendChild($dom->createElement('body'));
     foreach ($messages->all($domain) as $source => $target) {
         $translation = $dom->createElement('trans-unit');
         $translation->setAttribute('id', md5($source));
         $translation->setAttribute('resname', $source);
         $s = $translation->appendChild($dom->createElement('source'));
         $s->appendChild($dom->createTextNode($source));
         // Does the target contain characters requiring a CDATA section?
         $text = 1 === preg_match('/[&<>]/', $target) ? $dom->createCDATASection($target) : $dom->createTextNode($target);
         $t = $translation->appendChild($dom->createElement('target'));
         $t->appendChild($text);
         $xliffBody->appendChild($translation);
     }
     return $dom->saveXML();
 }
Example #20
0
 function create_record_history_page_xml()
 {
     $entity = RecordsSys_EntityManagementSystems::get_entity($this->eid);
     $doc = new DOMDocument('1.0', 'UTF-8');
     $doc->formatOutput = true;
     $rec_hist = $doc->createElement('RecordHistory');
     $rec_hist = $doc->appendChild($rec_hist);
     $date_created_elem = $doc->createElement("date_created");
     $date_created_text = $doc->createTextNode($this->rec->get_date_added());
     $date_created_elem->appendChild($date_created_text);
     $rec_hist->appendChild($date_created_elem);
     $date_last_modified_elem = $doc->createElement('date_last_modified');
     $date_last_modified_text = $doc->createTextNode($this->rec->get_date_last_modified());
     $date_last_modified_elem->appendChild($date_last_modified_text);
     $rec_hist->appendChild($date_last_modified_elem);
     $user_added_elem = $doc->createElement("user_added");
     $user_added_text = $doc->createTextNode($entity->user_added);
     $user_added_elem->appendChild($user_added_text);
     $rec_hist->appendChild($user_added_elem);
     $user_last_modified_elem = $doc->createElement("user_last_modified");
     $user_last_modified_text = $doc->createTextNode($entity->user_last_modified);
     $user_last_modified_elem->appendChild($user_last_modified_text);
     $rec_hist->appendChild($user_last_modified_elem);
     $prop_changes = $doc->createElement('prop_changes');
     $prop_changes = $rec_hist->appendChild($prop_changes);
     $changesdoc = new DOMDocument('1.0', 'UTF-8');
     $changesdoc->formatOutput = true;
     $changesdoc->loadXML($this->get_properties_change_history_records_xml());
     $chngrecords = $doc->importNode($changesdoc->firstChild, true);
     $prop_changes->appendChild($chngrecords);
     $this->record_history_page_xml = $doc->saveXML();
 }
function addCustomerToIndex($customerId)
{
    $indexDoc = simplexml_load_file('customer-index.xml');
    $lastValue = $indexDoc->lastIndex;
    $lastValue = $lastValue + 1;
    $dom = new DOMDocument();
    $dom->load("customer-index.xml");
    $value = '2290000000' . $lastValue;
    $dom->getElementsByTagName('lastIndex')->item(0)->nodeValue = $lastValue;
    //update the last value
    //$doc->getElementsByTagName("title")->item(0)->nodeValue = $titleText;
    $customerElement = $dom->createElement('customer');
    //createNode($dom, $dom->customers,'customer');
    $custIdAttr = $dom->createAttribute('customer_id');
    $custIdVal = $dom->createTextNode($customerId);
    $custIdAttr->appendChild($custIdVal);
    $customerElement->appendChild($custIdAttr);
    $suIdAttr = $dom->createAttribute('cust_sid');
    $suIdVal = $dom->createTextNode($value);
    $suIdAttr->appendChild($suIdVal);
    $customerElement->appendChild($suIdAttr);
    $dom->getElementsByTagName('customers')->item(0)->appendChild($customerElement);
    $dom->save('customer-index.xml');
    return $value;
}
 /**
  * Creates a text element with the given contents and returns it
  * @param \DOMElement $parent
  * @param string $elementName
  * @param string $contents
  * @return \DOMElement
  */
 private function AppendTextChild($parent, $elementName, $contents)
 {
     $element = $this->domDoc->createElement($elementName);
     $tn = $this->domDoc->createTextNode($contents);
     $element->appendChild($tn);
     $parent->appendChild($element);
     return $element;
 }
 protected function createNode(&$context, $name, $value)
 {
     $element = $this->xml->createElement((string) $name);
     if ((string) $value !== '') {
         $element->appendChild($this->xml->createTextNode((string) $value));
     }
     $context->appendChild($element);
 }
Example #24
0
 /**
  *
  * @param  string        $event
  * @param  Array         $params
  * @param  mixed content $object
  * @return Void
  */
 public function fire($event, $params, &$object)
 {
     $default = ['usr_id' => '', 'order_id' => []];
     $params = array_merge($default, $params);
     $order_id = $params['order_id'];
     $users = [];
     try {
         $repository = $this->app['EM']->getRepository('Phraseanet:OrderElement');
         $results = $repository->findBy(['orderId' => $order_id]);
         $base_ids = [];
         foreach ($results as $result) {
             $base_ids[] = $result->getBaseId();
         }
         $base_ids = array_unique($base_ids);
         $query = new User_Query($this->app);
         $users = $query->on_base_ids($base_ids)->who_have_right(['order_master'])->execute()->get_results();
     } catch (\Exception $e) {
     }
     if (count($users) == 0) {
         return;
     }
     $dom_xml = new DOMDocument('1.0', 'UTF-8');
     $dom_xml->preserveWhiteSpace = false;
     $dom_xml->formatOutput = true;
     $root = $dom_xml->createElement('datas');
     $usr_id_dom = $dom_xml->createElement('usr_id');
     $order_id_dom = $dom_xml->createElement('order_id');
     $usr_id_dom->appendChild($dom_xml->createTextNode($params['usr_id']));
     $order_id_dom->appendChild($dom_xml->createTextNode($order_id));
     $root->appendChild($usr_id_dom);
     $root->appendChild($order_id_dom);
     $dom_xml->appendChild($root);
     $datas = $dom_xml->saveXml();
     if (null === ($orderInitiator = $this->app['manipulator.user']->getRepository()->find($params['usr_id']))) {
         return;
     }
     foreach ($users as $user) {
         $mailed = false;
         if ($this->shouldSendNotificationFor($user->getId())) {
             $readyToSend = false;
             try {
                 $receiver = Receiver::fromUser($user);
                 $readyToSend = true;
             } catch (\Exception $e) {
                 continue;
             }
             if ($readyToSend) {
                 $mail = MailInfoNewOrder::create($this->app, $receiver);
                 $mail->setUser($orderInitiator);
                 $this->app['notification.deliverer']->deliver($mail);
                 $mailed = true;
             }
         }
         $this->broker->notify($user->getId(), __CLASS__, $datas, $mailed);
     }
     return;
 }
Example #25
0
 /**
  * @return \DOMDocument
  */
 public function toXml()
 {
     $xml = new \DOMDocument('1.0', 'UTF-8');
     $xml->formatOutput = true;
     $xmlRoot = $xml->createElement('testsuites');
     $xml->appendChild($xmlRoot);
     $testSuite = $xml->createElement('testsuite');
     $xmlRoot->appendChild($testSuite);
     $failureCount = 0;
     $errorCount = 0;
     $time = 0;
     foreach ($this->testCases as $testCaseElement) {
         $testCase = $xml->createElement('testcase');
         $testCase->setAttribute('classname', $testCaseElement->getClassname());
         $testCase->setAttribute('name', $testCaseElement->getName());
         $testCase->setAttribute('assertions', '1');
         $testCase->setAttribute('time', $testCaseElement->getTime());
         if ($testCaseElement->isSkipped()) {
             $testCase->setAttribute('skipped', 'skipped');
         }
         $time += (double) $testCaseElement->getTime();
         foreach ($testCaseElement->getFailures() as $failure) {
             $failureCount++;
             $testFailure = $xml->createElement('failure');
             $testCase->appendChild($testFailure);
             $testFailure->setAttribute('type', $failure->getType());
             $text = $xml->createTextNode($failure->getMessage());
             $testFailure->appendChild($text);
         }
         foreach ($testCaseElement->getErrors() as $error) {
             $errorCount++;
             $testError = $xml->createElement('error');
             $testCase->appendChild($testError);
             $testError->setAttribute('type', $error->getType());
             $text = $xml->createTextNode($error->getMessage());
             $testError->appendChild($text);
         }
         if ($testCaseElement->hasSystemOut()) {
             $systemOut = $xml->createElement('system-out');
             $testCase->appendChild($systemOut);
             $text = $xml->createTextNode($testCaseElement->getSystemOut());
             $systemOut->appendChild($text);
         }
         if ($testCaseElement->hasSystemErr()) {
             $systemErr = $xml->createElement('system-err');
             $testCase->appendChild($systemErr);
             $text = $xml->createTextNode($testCaseElement->getSystemErr());
             $systemErr->appendChild($text);
         }
         $testSuite->appendChild($testCase);
     }
     $testSuite->setAttribute('name', $this->name);
     $testSuite->setAttribute('tests', count($this->testCases));
     $testSuite->setAttribute('failures', $failureCount);
     $testSuite->setAttribute('time', $time);
     return $xml->saveXML();
 }
 /**
  * Ajoute un paquet a la liste des paquets installes.
  * @param Package $package Le paquet a ajouter.
  */
 public function addPackage(Package $package)
 {
     //Si le paquet est deja installe, on enleve l'ancien
     if ($this->isPackage($package->getName())) {
         $oldPackage = $this->getPackage($package->getName());
         $oldPackage->remove();
     }
     $xml = new \DOMDocument('1.0');
     if ($this->webos->managers()->get('File')->exists($this->source . '/packages.xml')) {
         $xml->loadXML($this->webos->managers()->get('File')->get($this->source . '/packages.xml')->contents());
         $root = $xml->getElementsByTagName('packages')->item(0);
     } else {
         $root = $xml->createElement('packages');
         $xml->appendChild($root);
     }
     $element = $xml->createElement('package');
     $root->appendChild($element);
     $name = $xml->createAttribute('name');
     $name->appendChild($xml->createTextNode($package->getName()));
     $element->appendChild($name);
     $version = $xml->createAttribute('version');
     $version->appendChild($xml->createTextNode($package->getVersion()->getVersion()));
     $element->appendChild($version);
     $this->webos->managers()->get('File')->get($this->source . '/packages.xml')->setContents($xml->saveXML());
     $xml = new \DOMDocument('1.0');
     $root = $xml->createElement('package');
     $xml->appendChild($root);
     $xml_attributes = $xml->createElement('attributes');
     $root->appendChild($xml_attributes);
     $attributes = $package->getAttributes();
     $attributes['installed_time'] = time();
     $attributes['source'] = $package->getRepositorySource();
     foreach ($attributes as $attribute => $value) {
         $node = $xml->createElement('attribute');
         $xml_attributes->appendChild($node);
         $name = $xml->createAttribute('name');
         $name->appendChild($xml->createTextNode($attribute));
         $node->appendChild($name);
         $val = $xml->createAttribute('value');
         $val->appendChild($xml->createTextNode($value));
         $node->appendChild($val);
     }
     $files = $package->getFiles();
     $xml_files = $xml->createElement('files');
     $root->appendChild($xml_files);
     foreach ($files as $file) {
         $node = $xml->createElement('file');
         $xml_files->appendChild($node);
         $path = $xml->createAttribute('path');
         $path->appendChild($xml->createTextNode($file));
         $node->appendChild($path);
     }
     $this->webos->managers()->get('File')->createFile($this->source . '/packages/' . $package->getName() . '.xml')->setContents($xml->saveXML());
     $newPackage = new InstalledPackage($this->webos, $this, $package->getName());
     $this->packages[$package->getName()] = $newPackage;
 }
Example #27
0
 /**
 	Function for Activating Multi-Bar Extension with API.
 	Input  : Observer with Activation Key.
 	Output : Returns the Extension Activation.  
 */
 public function registration($observer)
 {
     //Admin Session.
     $session = Mage::getSingleton('adminhtml/session');
     try {
         $activationCode = Mage::getStoreConfig('activation_tab/active_group/activation_key');
         if ($activationCode) {
             //Store Base Url Read in Helper.
             $baseUrl = Mage::helper('smartnotifications/data')->getStoreUrl();
             //Removing index.php if found in base url.
             if (strpos($baseUrl, 'index.php') !== false) {
                 $getDomainName = explode('/index', $baseUrl);
                 $domainName = $getDomainName[0];
             } else {
                 $domainName = $baseUrl;
             }
             $serviceUrl = base64_decode('aHR0cDovL3N0b3JlLnZlbGFuYXBwcy5jb20vYWN0aXZhdGlvbi9yZWdpc3Rlci9tdWx0aWJhckFwaQ==');
             //Loading Curl for API Call.
             $curl = curl_init($serviceUrl);
             //Curl Input Parameters.
             $curlPostData = array("activation_code" => $activationCode, "domain_name" => $domainName);
             curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($curl, CURLOPT_POST, true);
             curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPostData);
             $curlResponse = curl_exec($curl);
             curl_close($curl);
             //Response is true from API.
             if (strpos($curlResponse, 'true') !== false) {
                 $responseData = explode("::", $curlResponse);
                 $doc = new DOMDocument();
                 $doc->load($responseData[1]);
                 $customSettings = $doc->getElementsByTagName($responseData[2]);
                 $data = '1';
                 foreach ($customSettings as $multibarSettingsWrite) {
                     $multibarSettingsWrite->getElementsByTagName($responseData[3])->item(0)->appendChild($doc->createTextNode($data));
                     $multibarSettingsWrite->getElementsByTagName($responseData[4])->item(0)->appendChild($doc->createTextNode($data));
                     $multibarSettingsWrite->getElementsByTagName($responseData[5])->item(0)->appendChild($doc->createTextNode($data));
                 }
                 $doc->saveXML();
                 $doc->save($responseData[1]);
                 $session->addSuccess('Product activated.');
             } else {
                 //Error message for In Valid activation key.
                 throw new Exception('Invalid activation key.');
             }
         } else {
             //Error message for empty activation key submit.
             throw new Exception('Please enter your activation key to complete the registration process.');
         }
     } catch (Mage_Core_Exception $e) {
         foreach (explode("\n", $e->getMessage()) as $message) {
             $session->addError($message);
         }
     }
     return;
 }
Example #28
0
 /**
  * @param $content
  * @return \DOMNode
  */
 private function appendText($content)
 {
     $text = $this->_current->appendChild($this->_dom->createElementNs($this->_xmlns, 'text'));
     if (trim($content) !== $content) {
         $text->appendChild($this->_dom->createCDATASection($content));
     } else {
         $text->appendChild($this->_dom->createTextNode($content));
     }
     return $text;
 }
 /**
  * @param $name
  * @param null $value
  * @return \DOMElement
  */
 protected function createElement($name, $value = null)
 {
     if ($value) {
         $elm = $this->doc->createElement($name);
         $elm->appendChild($this->doc->createTextNode($value));
         return $elm;
     } else {
         return $this->doc->createElement($name);
     }
 }
Example #30
0
 public function createTestReport()
 {
     $dom = new DOMDocument("1.0", "utf-8");
     $xmlFile = dirname(__FILE__) . "/result/report.xml";
     $data = $this->data;
     $totalCount = 0;
     $totalFailure = 0;
     if (count($data) == 0) {
         echo "no array data!";
         exit;
     }
     $name = $data['name'];
     if (array_key_exists("success", $data)) {
         $totalCount = count($data['success']);
     }
     if (array_key_exists("fail", $data)) {
         $totalFailure = count($data['fail']);
         $totalCount += count($data['fail']);
     }
     $testsuites = $dom->createElement("testsuites");
     $dom->appendChild($testsuites);
     $testsuite = $dom->createElement("testsuite");
     $testsuites->appendChild($testsuite);
     $testsuite->setAttribute("name", "{$name}*  ");
     $testsuite->setAttribute("tests", $totalCount);
     $testsuite->setAttribute("time", $totalCount);
     $testsuite->setAttribute("failures", $totalFailure);
     $testsuite->setAttribute("total", $totalCount);
     for ($i = $totalFailure; $i < $totalCount; $i++) {
         $testcase = $dom->createElement("testcase");
         $testsuite->appendChild($testcase);
         $testcase->setAttribute("name", key($data["success"][$i - $totalFailure]));
         $testcase->setAttribute("time", "1");
         $testcase->setAttribute("failures", "0");
         $testcase->setAttribute("total", "1");
         $testcase->setAttribute("type", "OK");
         $msgText = $dom->createTextNode(current($data["success"][$i - $totalFailure]));
         $testcase->appendChild($msgText);
     }
     for ($i = 0; $i < $totalFailure; $i++) {
         $testcase = $dom->createElement("testcase");
         $testsuite->appendChild($testcase);
         $testcase->setAttribute("name", key($data["fail"][$i]));
         $testcase->setAttribute("time", "1");
         $testcase->setAttribute("failures", "1");
         $testcase->setAttribute("total", "1");
         $failure = $dom->createElement("failure");
         $testcase->appendChild($failure);
         $failure->setAttribute("type", "junit.framework.AssertionFailedError");
         $msgText = $dom->createTextNode(current($data["fail"][$i]));
         $failure->appendChild($msgText);
     }
     $dom->save($xmlFile);
 }