Пример #1
0
 public function to_html($parent)
 {
     if (!$this->get_lang()) {
         $this->log("to_html() no lang", 'error');
         return null;
     }
     if (!$this->get_id()) {
         $this->log("to_html() no id", 'error');
         return null;
     }
     if (!$parent->get_request()->is_lang_ok($this->get_lang())) {
         return null;
     }
     $w = new XMLWriter();
     $w->openMemory();
     $w->startElement('div');
     $w->writeAttribute('class', 'subtitle');
     $w->startElement('a');
     $w->writeAttribute('class', 'subtitle_href');
     $w->writeAttribute('href', $parent->get_prefix_url() . '/download-' . $this->get_id() . '.html');
     $w->startElement('img');
     $w->writeAttribute('class', 'subtitle_lang');
     $w->writeAttribute('src', $parent->get_prefix_url() . '/images/flags/' . $this->get_lang() . '.gif');
     $w->endElement();
     $w->endElement();
     $w->endElement();
     return $w->flush();
 }
Пример #2
0
 function impersonate_login($admin_user, $admin_pass, $site, $user)
 {
     //create a new xmlwriter object
     $xml = new XMLWriter();
     //using memory for string output
     $xml->openMemory();
     //set the indentation to true (if false all the xml will be written on one line)
     $xml->setIndent(true);
     //create the document tag, you can specify the version and encoding here
     $xml->startDocument();
     //Create an element
     $xml->startElement("tsRequest");
     $xml->startElement("credentials");
     $xml->writeAttribute("name", $admin_user);
     $xml->writeAttribute("password", $admin_pass);
     $xml->startElement("site");
     $xml->writeAttribute("contentUrl", strtoupper($site));
     $xml->endElement();
     //close contentUrl
     $xml->startElement("user");
     $xml->writeAttribute("id", $user);
     $xml->endElement();
     //close user
     $xml->endElement();
     //close credentials
     $xml->endElement();
     //close tsRequest
     return $data_string = $xml->outputMemory();
 }
Пример #3
0
 private function writeNamespaceAttributes(\XMLWriter $xmlWriter)
 {
     $xmlWriter->writeAttribute(UrlSetInterface::XML_NAMESPACE_ATTRIBUTE, UrlSetInterface::XML_NAMESPACE_URI);
     $xmlWriter->writeAttribute(ImageInterface::XML_NAMESPACE_ATTRIBUTE, ImageInterface::XML_NAMESPACE_URI);
     $xmlWriter->writeAttribute(NewsInterface::XML_NAMESPACE_ATTRIBUTE, NewsInterface::XML_NAMESPACE_URI);
     $xmlWriter->writeAttribute(VideoInterface::XML_NAMESPACE_ATTRIBUTE, VideoInterface::XML_NAMESPACE_URI);
 }
Пример #4
0
 public function to_html($parent)
 {
     $w = new XMLWriter();
     $w->openMemory();
     $w->startElement('div');
     $w->writeAttribute('class', 'show');
     $w->startElement('a');
     $w->writeAttribute('class', 'name');
     $w->writeAttribute('href', $parent->get_prefix_url() . $this->get_href());
     $w->text($this->get_name());
     $w->endElement();
     $img = null;
     if ($img = $this->get_img()) {
         $w->startElement('img');
         $w->writeAttribute('src', $parent->get_prefix_url() . $img);
         $w->writeAttribute('alt', $this->get_name());
         $w->endElement();
     }
     $str = "";
     $w->startElement('div');
     $w->writeAttribute('class', 'season_container');
     usort($this->seasons, 'wssub_cmp_num');
     foreach ($this->get_seasons() as $season) {
         if (!$season) {
             $this->log('to_html: "empty season', 'warn');
         }
         $str .= $season->to_html($parent);
     }
     $w->writeRaw($str);
     $w->endElement();
     $w->endElement();
     return $w->flush();
 }
Пример #5
0
 protected function setupStoreData()
 {
     // Using XMLWriter because SimpleXML namespaces on attribute names
     $this->doc = new XMLWriter();
     $this->doc->openMemory();
     $this->doc->setIndent(true);
     $this->doc->setIndentString('    ');
     $this->doc->startDocument('1.0', 'UTF-8');
     $this->doc->startElement('feed');
     $this->doc->writeAttribute('xmlns', 'http://www.w3.org/2005/Atom');
     $this->doc->writeAttribute('xmlns:g', 'http://base.google.com/ns/1.0');
     $this->doc->writeElement('title', $this->getConfig('title'));
     $this->doc->startElement('link');
     $this->doc->writeAttribute('rel', 'self');
     $this->doc->writeAttribute('href', $this->_store->getBaseUrl());
     $this->doc->endElement();
     $date = new Zend_Date();
     $this->doc->writeElement('updated', $date->get(Zend_Date::ATOM));
     $this->doc->startElement('author');
     $this->doc->writeElement('name', $this->getConfig('author'));
     $this->doc->endElement();
     $url = $this->_store->getBaseUrl();
     $day = $date->toString('yyyy-MM-dd');
     $path = $this->getConfig('output');
     $filename = $path . '/' . str_replace('+', '-', strtolower(urlencode($this->_store->getName()))) . '-products.xml';
     $this->doc->writeElement('id', 'tag:' . $url . ',' . $day . ':' . $filename);
 }
Пример #6
0
 public function to_html($parent)
 {
     $w = new XMLWriter();
     $w->openMemory();
     $w->startElement('div');
     $w->writeAttribute('class', 'season');
     $w->startElement('div');
     $w->writeAttribute('class', 'season_name');
     $w->text("Saison " . $this->get_num());
     $w->endElement();
     $w->startElement('div');
     $w->writeAttribute('class', 'episode_container');
     $str = "";
     usort($this->episodes, 'wssub_cmp_num');
     foreach ($this->episodes as $ep) {
         if (!$ep->get_num()) {
             $this->log("Bad ep with no number: " . $ep->to_string(), 'warn');
             continue;
         }
         $str .= $ep->to_html($parent);
     }
     $w->writeRaw($str);
     $w->endElement();
     $w->endElement();
     return $w->flush();
 }
Пример #7
0
 public function addTest($test)
 {
     if ($this->finalized) {
         throw new PHP_CodeCoverage_RuntimeException('Coverage Report already finalized');
     }
     $this->writer->startElement('covered');
     $this->writer->writeAttribute('by', $test);
     $this->writer->endElement();
 }
 /**
  * add number
  * 
  * @param integer $_number
  * @param string $_type
  */
 protected function _addNumber($_number, $_type)
 {
     $this->_writer->startElement("number");
     $this->_writer->writeAttribute("type", $_type);
     $this->_writer->writeAttribute("quickdial", "");
     $this->_writer->writeAttribute("vanity", "");
     $this->_writer->writeAttribute("prio", "");
     $this->_writer->text($_number);
     $this->_writer->endElement();
 }
Пример #9
0
 public function write(PlayerLocationInterface $playerLocation, \XMLWriter $xmlWriter)
 {
     $xmlWriter->startElement('video:player_loc');
     if ($playerLocation->allowEmbed()) {
         $xmlWriter->writeAttribute('allow_embed', $playerLocation->allowEmbed());
     }
     if ($playerLocation->autoPlay()) {
         $xmlWriter->writeAttribute('autoplay', $playerLocation->autoPlay());
     }
     $xmlWriter->text($playerLocation->location());
     $xmlWriter->endElement();
 }
Пример #10
0
 protected function doProcess($inputPath, $outputPath)
 {
     $sitemap = Yaml::parse(file_get_contents($inputPath));
     if (!isset($sitemap['locations'])) {
         throw new PieCrustException("No locations were defined in the sitemap.");
     }
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->startDocument('1.0', 'utf-8');
     $xml->startElement('urlset');
     $xml->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     foreach ($sitemap['locations'] as $loc) {
         $xml->startElement('url');
         // loc
         $locUrl = $this->pieCrust->getConfig()->getValueUnchecked('site/root') . ltrim($loc['url'], '/');
         $xml->writeElement('loc', $locUrl);
         // lastmod
         $locLastMod = null;
         if (isset($loc['lastmod'])) {
             $locLastMod = $loc['lastmod'];
         } else {
             if (isset($loc['lastmod_path'])) {
                 $fullPath = $this->pieCrust->getRootDir() . ltrim($loc['lastmod_path'], '/\\');
                 $locLastMod = date('c', filemtime($fullPath));
             } else {
                 $urlInfo = UriParser::parseUri($this->pieCrust, $loc['url']);
                 if ($urlInfo) {
                     if (is_file($urlInfo['path'])) {
                         $locLastMod = date('c', filemtime($urlInfo['path']));
                     }
                 }
             }
         }
         if (!$locLastMod) {
             throw new PieCrustException("No idea what '" . $loc['url'] . "' is. Please specify a 'lastmod' time, or 'lastmod_path' path.");
         }
         $xml->writeElement('lastmod', $locLastMod);
         // changefreq
         if (isset($loc['changefreq'])) {
             $xml->writeAttribute('changefreq', $loc['changefreq']);
         }
         // priority
         if (isset($loc['priority'])) {
             $xml->writeAttribute('priority', $loc['priority']);
         }
         $xml->endElement();
     }
     $xml->endElement();
     $xml->endDocument();
     $markup = $xml->outputMemory(true);
     file_put_contents($outputPath, $markup);
 }
Пример #11
0
 public function to_html($parent)
 {
     $w = new XMLWriter();
     $w->openMemory();
     $w->startElement('div');
     $w->writeAttribute('class', 'log_message');
     $w->startElement('div');
     $w->writeAttribute('class', 'log_message_' . $this->type);
     $w->writeRaw('<div class="log_class">' . $this->class . '</div>::<div class="log_msg">' . $this->msg . '</div>');
     $w->endElement();
     $w->endElement();
     return $w->flush();
 }
Пример #12
0
 public function toXml(XMLWriter $x)
 {
     $x->writeAttribute('type', 'redirect');
     $x->writeElement('url', $this->_url);
     $x->startElement('params');
     foreach ($this->_params as $k => $v) {
         $x->startElement('param');
         $x->writeAttribute('name', $k);
         $x->text($v);
         $x->endElement();
     }
     $x->endElement();
 }
Пример #13
0
 public function write(PriceInterface $price, \XMLWriter $xmlWriter)
 {
     $xmlWriter->startElement('video:price');
     $xmlWriter->writeAttribute('currency', $price->currency());
     if ($price->type()) {
         $xmlWriter->writeAttribute('type', $price->type());
     }
     if ($price->resolution()) {
         $xmlWriter->writeAttribute('resolution', $price->resolution());
     }
     $xmlWriter->text(number_format($price->value(), 2));
     $xmlWriter->endElement();
 }
Пример #14
0
 /**
  * @return \XMLWriter
  */
 public function getObject()
 {
     $xmlWriter = new \XMLWriter();
     $xmlWriter->openMemory();
     $xmlWriter->startDocument('1.0', 'UTF-8');
     $xmlWriter->setIndent(true);
     $xmlWriter->writePi('xml-stylesheet', 'type="text/xsl" href="./sitemap_css.xsl"');
     $xmlWriter->startElement('urlset');
     $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $xmlWriter->writeAttribute('xmlns:image', 'http://www.google.com/schemas/sitemap-image/1.1');
     $xmlWriter->writeAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd');
     $xmlWriter->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     return $xmlWriter;
 }
 /**
  * 
  * @param int $pollerId
  * @throws \Centreon\Internal\Exception;
  */
 public function generate($pollerId)
 {
     $di = Di::getDefault();
     $dbconn = $di->get('db_centreon');
     /* Get tmp path */
     $config = Di::getDefault()->get('config');
     $tmpPath = rtrim($config->get('global', 'centreon_generate_tmp_dir'));
     if (!isset($tmpPath)) {
         throw new Exception('Temporary path not set');
     }
     $tmpPath = rtrim($tmpPath, '/') . '/broker/generate';
     $xml = new \XMLWriter();
     /* Create directories if they don't exist */
     if (!is_dir($tmpPath)) {
         mkdir($tmpPath);
     }
     if (!is_dir("{$tmpPath}/{$pollerId}")) {
         mkdir("{$tmpPath}/{$pollerId}");
     }
     $correlationFile = "{$tmpPath}/{$pollerId}/correlation_{$pollerId}.xml";
     if (false === @$xml->openURI($correlationFile)) {
         throw new Exception(sprintf('Error while opening %s', $correlationFile));
     }
     $xml->startDocument('1.0', 'UTF-8');
     /* Start Element conf */
     $xml->startElement('conf');
     /* Declare Host */
     $query = "SELECT h.host_id, h.poller_id \n            FROM cfg_hosts h \n            ORDER BY h.host_id";
     $stmt = $dbconn->query($query);
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $xml->startElement('host');
         $xml->writeAttribute('id', $row["host_id"]);
         $xml->writeAttribute('instance_id', $row["poller_id"]);
         $xml->endElement();
     }
     /* Declare Service */
     $query = "SELECT s.service_id, h.host_id, h.poller_id\n            FROM cfg_hosts h, cfg_services s, cfg_hosts_services_relations ns\n            WHERE h.host_id = ns.host_host_id\n            AND s.service_id = ns.service_service_id ";
     $stmt = $dbconn->query($query);
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $xml->startElement('service');
         $xml->writeAttribute('id', $row["service_id"]);
         $xml->writeAttribute('host', $row["host_id"]);
         $xml->writeAttribute('instance_id', $row["poller_id"]);
         $xml->endElement();
     }
     /* End conf Element */
     $xml->endElement();
     $xml->endDocument();
     static::generateInclusionFile($tmpPath);
 }
Пример #16
0
/**
 * Create RSS Feed
 * @param entries
 * @param config
 */
function create_rss($entries, $config)
{
    // Inspired from http://www.phpntips.com/xmlwriter-2009-06/
    $xml = new XMLWriter();
    // Output directly to the user
    $xml->openURI('php://output');
    $xml->startDocument('1.0');
    $xml->setIndent(2);
    //rss
    $xml->startElement('rss');
    $xml->writeAttribute('version', '2.0');
    $xml->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
    //channel
    $xml->startElement('channel');
    // title, desc, link, date
    $xml->writeElement('title', $config['title']);
    // $xml->writeElement('description', $config['description']);
    // $xml->writeElement('link', 'http://www.example.com/rss.hml');
    $xml->writeElement('pubDate', date('r'));
    if (!empty($entries)) {
        foreach ($entries as $entry) {
            // item
            $xml->startElement('item');
            $xml->writeElement('title', $entry->title);
            if (isset($entry->permalink)) {
                $xml->writeElement('link', $entry->permalink);
            }
            $xml->startElement('description');
            $xml->writeCData($entry->content);
            $xml->endElement();
            $xml->writeElement('pubDate', date('r', strtotime($entry->date)));
            // category
            // $xml->startElement('category');
            // $xml->writeAttribute('domain', 'http://www.example.com/cat1.htm');
            // $xml->text('News');
            // $xml->endElement();
            // end item
            $xml->endElement();
        }
    }
    // end channel
    $xml->endElement();
    // end rss
    $xml->endElement();
    // end doc
    $xml->endDocument();
    // flush
    $xml->flush();
}
 public function addNotEmpty($node, \XMLWriter &$writer)
 {
     if (isset($node[$this->xsd_generator->getFullName('not_empty')]) && $node[$this->xsd_generator->getFullName('not_empty')]) {
         $writer->startElementNs('xsd', 'simpleType', null);
         $writer->startElementNs('xsd', 'restriction', null);
         $writer->writeAttribute('base', 'xsd:decimal');
         $writer->startElementNs('xsd', 'pattern', null);
         $writer->writeAttribute('value', '^[^0]*$');
         $writer->endElement();
         $writer->endElement();
         $writer->endElement();
         return true;
     }
     return false;
 }
 public function addNotEmpty($node, \XMLWriter &$writer)
 {
     if (isset($node[$this->xsd_generator->getFullName('not_empty')]) && $node[$this->xsd_generator->getFullName('not_empty')]) {
         $writer->startElementNs('xsd', 'simpleType', null);
         $writer->startElementNs('xsd', 'restriction', null);
         $writer->writeAttribute('base', 'xsd:normalizedString');
         $writer->startElementNs('xsd', 'minLength', null);
         $writer->writeAttribute('value', '200');
         $writer->endElement();
         $writer->endElement();
         $writer->endElement();
         return true;
     }
     return false;
 }
Пример #19
0
 protected function getXmlLostCart(LostCart $lostCart)
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement("event");
     if ($lostCart->getLostCartUrl()) {
         $xml->writeAttribute('RESTORE_CART_URL', $lostCart->getLostCartUrl());
         // slevovy kupon
         $discountCoupon = $lostCart->getDiscountCoupon();
         if ($discountCoupon instanceof Discount) {
             $xml->writeAttribute('COUPON_CODE', $discountCoupon->getCode());
             $xml->writeAttribute('COUPON_VALUE', $discountCoupon->getValue());
             $xml->writeAttribute('COUPON_VALIDITY', $this->dayToDate($discountCoupon->getValidityDay()));
             $xml->writeAttribute('COUPON_ORDER_VALUE', $discountCoupon->getMinOrderValue());
         }
     }
     $xml->startElement("products");
     foreach ($lostCart->getProducts() as $product) {
         $xml->startElement("product");
         $xml->startElement("name");
         $xml->writeCData($product->getName());
         $xml->endElement();
         $xml->startElement("url");
         $xml->writeCData($product->getUrl());
         $xml->endElement();
         $xml->startElement("img");
         $xml->writeCData($product->getImage());
         $xml->endElement();
         $xml->startElement("price-old");
         $xml->writeCData($product->getPriceOld());
         $xml->endElement();
         $xml->startElement("price");
         $xml->writeCData($product->getPrice());
         $xml->endElement();
         $xml->startElement("sale");
         $xml->writeCData($product->getSale());
         $xml->endElement();
         $xml->startElement("buy-text");
         $xml->writeCData($this->getBuyText());
         $xml->endElement();
         $xml->endElement();
     }
     $xml->endElement();
     $xml->endElement();
     $xml->endDocument();
     return $xml->flush();
 }
Пример #20
0
 /**
  * Method for parsing of elements
  *
  * @param string $node - node name
  * @param string $item - node content
  * @param bool $wrap - should be wrapped in array for singularization
  *
  * @return void
  *
  * @since 1.0
  */
 protected function handleElement($node, $item, $wrap = true)
 {
     if ($this->dispatcher->listensTo($node)) {
         $this->dispatcher->trigger($node, array($this->writer, $node, $item));
     } else {
         if ($node === self::COMMENT) {
             if (!is_array($item)) {
                 $item = array($item);
             }
             foreach ($item as $comment) {
                 $this->writer->writeComment($comment);
             }
         } elseif ($node === self::CDATA) {
             $this->writer->writeCdata($item);
         } else {
             if ($wrap === true) {
                 if ($this->assertElementName($node)) {
                     if ($this->config->nil_on_null === true && is_null($item)) {
                         $this->writer->startElement($node);
                         $this->writer->writeAttribute('xsi:nil', 'true');
                         $this->writer->writeRaw($item);
                         $this->writer->endElement();
                     } else {
                         $this->writer->writeElement($node, $item);
                     }
                 }
             } else {
                 $this->writer->writeRaw($item);
             }
         }
     }
 }
Пример #21
0
 /**
  * Write meta data to xml
  *
  * @param XMLWriter $xml  XML
  * @param array     $meta Meta
  *
  * @return void
  */
 protected function _writeMetaToXml(XMLWriter $xml, array $meta)
 {
     unset($meta['_class']);
     foreach ($meta as $_code => $_value) {
         $xml->writeAttribute($_code, $_value);
     }
 }
Пример #22
0
 public function write(RestrictionInterface $restriction, \XMLWriter $xmlWriter)
 {
     $xmlWriter->startElement('video:restriction');
     $xmlWriter->writeAttribute('relationship', $restriction->relationship());
     $xmlWriter->text(implode(' ', $restriction->countryCodes()));
     $xmlWriter->endElement();
 }
Пример #23
0
 /**
  * @param string $fileToSave
  * @param number $offsetStart
  * @param number $limit
  * @param null | string $suffix
  *
  * @return string
  */
 protected function saveToFile($fileToSave, $offsetStart, $limit, $suffix = null)
 {
     $writer = new \XMLWriter();
     $path = pathinfo($fileToSave);
     $filePath = $path['dirname'] . '/' . $path['filename'];
     if (!is_null($suffix)) {
         $filePath .= self::SEPERATOR . $suffix;
     }
     if (empty($path['extension'])) {
         $filePath .= self::XML_EXT;
     } else {
         $filePath .= '.' . $path['extension'];
     }
     $writer->openURI($filePath);
     $writer->startDocument('1.0', 'UTF-8');
     $writer->setIndent(true);
     $writer->startElement('sitemapindex');
     $writer->writeAttribute('xmlns', self::SCHEMA);
     for ($i = $offsetStart; $i < count($this->items) && $i < $limit; $i++) {
         $item = $this->items[$i];
         $writer->startElement('sitemap');
         $writer->writeElement('loc', $item['url']);
         $writer->writeElement('lastmod', $item['modified']->format(ModifiableInterface::MODIFIED_DATE_FORMAT));
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endDocument();
     return $filePath;
 }
Пример #24
0
 /**
  * Takes an array and produces XML based on it.
  *
  * @param XMLWriter $xmlw       XMLWriter object that was previously instanted
  * and is used for creating the XML.
  * @param array     $data       Array to be converted to XML.
  * @param string    $defaultTag Default XML tag to be used if none specified.
  * 
  * @return void
  */
 private function _arr2xml(\XMLWriter $xmlw, $data, $defaultTag = null)
 {
     foreach ($data as $key => $value) {
         if ($key === Resources::XTAG_ATTRIBUTES) {
             foreach ($value as $attributeName => $attributeValue) {
                 $xmlw->writeAttribute($attributeName, $attributeValue);
             }
         } else {
             if (is_array($value)) {
                 if (!is_int($key)) {
                     if ($key != Resources::EMPTY_STRING) {
                         $xmlw->startElement($key);
                     } else {
                         $xmlw->startElement($defaultTag);
                     }
                 }
                 $this->_arr2xml($xmlw, $value);
                 if (!is_int($key)) {
                     $xmlw->endElement();
                 }
             } else {
                 $xmlw->writeElement($key, $value);
             }
         }
     }
 }
Пример #25
0
 public function write(PlatformInterface $platform, \XMLWriter $xmlWriter)
 {
     $xmlWriter->startElement('video:platform');
     $xmlWriter->writeAttribute('relationship', $platform->relationship());
     $xmlWriter->text(implode(' ', $platform->types()));
     $xmlWriter->endElement();
 }
 public function addIgnoreExtraKeys($node, \XMLWriter &$writer)
 {
     if (isset($node[$this->xsd_generator->getFullName('ignore_extra_keys')]) && $node[$this->xsd_generator->getFullName('ignore_extra_keys')]) {
         // not_empty makes sense only here - so let's test it
         $min = isset($node[$this->xsd_generator->getFullName('not_empty')]) && $node[$this->xsd_generator->getFullName('not_empty')] ? '1' : '0';
         $writer->startElementNs('xsd', 'sequence', null);
         $writer->startElementNs('xsd', 'any', null);
         $writer->writeAttribute('processContents', 'skip');
         $writer->writeAttribute('minOccurs', $min);
         $writer->writeAttribute('maxOccurs', 'unbounded');
         $writer->endElement();
         $writer->endElement();
         return true;
     }
     return false;
 }
Пример #27
0
 public function index()
 {
     $writter = new \XMLWriter();
     $writter->openMemory();
     $writter->startDocument('1.0', 'UTF-8');
     $writter->setIndent(TRUE);
     $writter->startElement('rss');
     $writter->writeAttribute('version', '2.0');
     $writter->startElement('channel');
     //header
     $writter->writeElement('title', 'phpMint RSS');
     $writter->writeElement('link', 'mein LINK');
     $writter->writeElement('description', 'Ein PHP-Blog über PHP, jQuery, JavaScript und weiteren Technik-Themen.');
     //body
     foreach ($this->getPosts() as $key => $post) {
         $writter->startElement('item');
         $writter->writeElement('title', $post['title']);
         $writter->writeElement('pubDate', $post['datum']);
         $writter->writeElement('link', $post['slug']);
         $writter->writeElement('description', $post['preview']);
         $writter->endElement();
     }
     while ($writter->endElement() !== false) {
         continue;
     }
     $writter->endDocument();
     $test = $writter->outputMemory(TRUE);
     $loger = new \Loger('session');
     $loger->write($test);
     $this->response->addHeader('Content-type: text/xml; charset=UTF-8');
     $this->response->setOutput($test);
 }
Пример #28
0
 private function writeCommon(\XMLWriter $writer, Common $common)
 {
     if ($common->getAuthor()) {
         $writer->startElement('itunes:author');
         $writer->writeCdata($common->getAuthor());
         $writer->endElement();
     }
     if ($common->getSummary()) {
         $writer->startElement('itunes:summary');
         $writer->writeCdata($common->getSummary());
         $writer->endElement();
     }
     if ($common->getBlock()) {
         $writer->writeElement('itunes:block', 'Yes');
     }
     if ($common->getImage()) {
         $writer->startElement('itunes:image');
         $writer->writeAttribute('href', $common->getImage());
         $writer->endElement();
     }
     $writer->writeElement('itunes:explicit', true === $common->getExplicit() ? 'Yes' : 'No');
     if ($common->getSubtitle()) {
         $writer->startElement('itunes:subtitle');
         $writer->writeCdata($common->getSubtitle());
         $writer->endElement();
     }
 }
Пример #29
0
 /**
  * Write the service document in Atom format.
  * 
  * @param Object &$dummy Dummy object
  * 
  * @return string
  */
 public function writeRequest(&$dummy)
 {
     $this->_xmlWriter = new \XMLWriter();
     $this->_xmlWriter->openMemory();
     $this->_xmlWriter->startElementNs(null, ODataConstants::ATOM_PUBLISHING_SERVICE_ELEMENT_NAME, ODataConstants::APP_NAMESPACE);
     $this->_xmlWriter->writeAttributeNs(ODataConstants::XML_NAMESPACE_PREFIX, ODataConstants::XML_BASE_ATTRIBUTE_NAME, null, $this->_baseUri);
     $this->_xmlWriter->writeAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, self::ATOM_NAMESPACE_PREFIX, null, ODataConstants::ATOM_NAMESPACE);
     $this->_xmlWriter->writeAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, self::APP_NAMESPACE_PREFIX, null, ODataConstants::APP_NAMESPACE);
     $this->_xmlWriter->startElement(ODataConstants::ATOM_PUBLISHING_WORKSPACE_ELEMNT_NAME);
     $this->_xmlWriter->startElementNs(self::ATOM_NAMESPACE_PREFIX, ODataConstants::ATOM_TITLE_ELELMET_NAME, null);
     $this->_xmlWriter->text(ODataConstants::ATOM_PUBLISHING_WORKSPACE_DEFAULT_VALUE);
     $this->_xmlWriter->endElement();
     foreach ($this->_metadataQueryproviderWrapper->getResourceSets() as $resourceSetWrapper) {
         //start collection node
         $this->_xmlWriter->startElement(ODataConstants::ATOM_PUBLISHING_COLLECTION_ELEMENT_NAME);
         $this->_xmlWriter->writeAttribute(ODataConstants::ATOM_HREF_ATTRIBUTE_NAME, $resourceSetWrapper->getName());
         //start title node
         $this->_xmlWriter->startElementNs(self::ATOM_NAMESPACE_PREFIX, ODataConstants::ATOM_TITLE_ELELMET_NAME, null);
         $this->_xmlWriter->text($resourceSetWrapper->getName());
         //end title node
         $this->_xmlWriter->endElement();
         //end collection node
         $this->_xmlWriter->endElement();
     }
     //End workspace and service nodes
     $this->_xmlWriter->endElement();
     $this->_xmlWriter->endElement();
     $serviceDocumentInAtom = $this->_xmlWriter->outputMemory(true);
     return $serviceDocumentInAtom;
 }
Пример #30
-11
 public static function Encode($requestObject)
 {
     $soap = "";
     try {
         $writer = new XMLWriter();
         $writer->openMemory();
         $writer->startDocument();
         $writer->setIndent(4);
         $writer->startElement("soap:Envelope");
         $writer->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
         $writer->writeAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
         $writer->writeAttribute("xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/");
         $writer->startElement("soap:Body");
         $options = array(XML_SERIALIZER_OPTION_INDENT => '    ', XML_SERIALIZER_OPTION_LINEBREAKS => "\n", XML_SERIALIZER_OPTION_DEFAULT_TAG => '', XML_SERIALIZER_OPTION_TYPEHINTS => false, XML_SERIALIZER_OPTION_IGNORE_NULL => true, XML_SERIALIZER_OPTION_CLASSNAME_AS_TAGNAME => true);
         $serializer = new XML_Serializer($options);
         $result = $serializer->serialize($requestObject);
         if ($result === true) {
             $xml = $serializer->getSerializedData();
             $xml = str_replace('<>', '', $xml);
             $xml = str_replace('</>', '', $xml);
         }
         $writer->writeRaw($xml);
         $writer->endElement();
         $writer->endElement();
         $writer->endDocument();
         $soap = $writer->flush();
         $soap = str_replace("<?xml version=\"1.0\"?>", "", $soap);
     } catch (Exception $ex) {
         throw new Exception("Error occurred while Soap encoding");
     }
     return $soap;
 }