Exemplo n.º 1
0
 public function addHeader($type, $hasFeeds = false)
 {
     $this->writer->startElement($type);
     $this->writer->writeAttribute('xmlns', "http://www.sitemaps.org/schemas/sitemap/0.9");
     if ($hasFeeds) {
         $this->writer->writeAttribute('xmlns:image', "http://www.google.com/schemas/sitemap-image/1.1");
         $this->writer->writeAttribute('xmlns:video', "http://www.google.com/schemas/sitemap-video/1.1");
     }
     $this->writer->endAttribute();
     $this->openElements++;
     return $this;
 }
Exemplo n.º 2
0
 public function html($mysqli_stmt)
 {
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $xml->startElement('table');
     $xml->writeAttribute('class', $this->tbl_class);
     $xml->startElement('thead');
     $xml->startElement('tr');
     //////////////////////////////////
     // Column Headers
     /////////////////////////////////
     $cntcol = count($this->col_classes);
     $altcol = 0;
     foreach (array_keys($this->cols) as $th) {
         $xml->startElement('th');
         $xml->writeAttribute('scope', 'col');
         if ($this->col_classes[$altcol] != "") {
             $xml->writeAttribute('class', $this->col_classes[$altcol]);
         }
         $altcol = ++$altcol % $cntcol;
         if (substr($th, 0, 2) == "__") {
             $xml->text('');
         } else {
             //Sorting
             $dir = "A";
             if (isset($_GET["sn"]) && $_GET["sn"] == $th && $_GET["sd"] == "A") {
                 $dir = "D";
             }
             $xml->startElement('a');
             $xml->startAttribute('href');
             $xml->writeRaw(quickgrid::get_href(["sn" => $th, "sd" => $dir, "p" => 1]));
             $xml->endAttribute();
             $xml->text($th);
             $xml->endElement();
             //a
         }
         $xml->endElement();
         //th
     }
     $xml->endElement();
     //tr
     $xml->endElement();
     //thead
     $xml->startElement('tfoot');
     $xml->startElement('tr');
     $xml->startElement('td');
     $xml->writeAttribute('colspan', count($this->cols));
     //////////////////////////////////
     // Pager
     /////////////////////////////////
     $last = ceil($this->row_count / $this->per_page);
     $length = 8;
     $lbound = $this->cur_page - $length / 2;
     $ubound = $this->cur_page + $length / 2;
     if ($lbound < 1) {
         $lbound = 1;
     }
     if ($ubound > $last) {
         $ubound = $last;
     }
     if ($this->cur_page != 1) {
         $xml->startElement('a');
         $xml->startAttribute('href');
         $xml->writeRaw(quickgrid::get_href(["p" => $this->cur_page - 1]));
         $xml->endAttribute();
         $xml->text("<");
         $xml->endElement();
         //a
     }
     for ($i = $lbound; $i <= $ubound; $i++) {
         if ($i != $this->cur_page) {
             $xml->startElement('a');
             $xml->startAttribute('href');
             $xml->writeRaw(quickgrid::get_href(["p" => $i]));
             $xml->endAttribute();
             $xml->text("{$i}");
             $xml->endElement();
             //a
         } else {
             $xml->startElement('span');
             $xml->text("{$i}");
             $xml->endElement();
             //span
         }
     }
     if ($this->cur_page != $last) {
         $xml->startElement('a');
         $xml->startAttribute('href');
         $xml->writeRaw(quickgrid::get_href(["p" => $this->cur_page + 1]));
         $xml->endAttribute();
         $xml->text(">");
         $xml->endElement();
         //a
     }
     $xml->endElement();
     //td
     $xml->endElement();
     //tr
     $xml->endElement();
     //tfoot
     $xml->startElement('tbody');
     //////////////////////////////////
     // Table Data
     /////////////////////////////////
     $cntrow = count($this->row_classes);
     $altrow = 0;
     $cntcol = count($this->col_classes);
     $altcol = 0;
     $result = $mysqli_stmt->get_result();
     while ($row = $result->fetch_assoc()) {
         $xml->startElement('tr');
         if ($this->row_classes[$altrow] != "") {
             $xml->writeAttribute('class', $this->row_classes[$altrow]);
         }
         $altrow = ++$altrow % $cntrow;
         foreach (array_keys($this->cols) as $th) {
             $xml->startElement('td');
             if ($this->col_classes[$altcol] != "") {
                 $xml->writeAttribute('class', $this->col_classes[$altcol]);
             }
             $altcol = ++$altcol % $cntcol;
             if (isset($this->td_formats[$th]) && is_callable($this->td_formats[$th])) {
                 $tmp = $this->td_formats[$th];
                 $xml->writeRaw(call_user_func($tmp, $row));
             } else {
                 $td = $this->cols[$th];
                 if (isset($row[$td])) {
                     $xml->text($row[$td]);
                 } else {
                     $xml->text('');
                 }
             }
             $xml->endElement();
             //td
         }
         $xml->endElement();
         //tr
     }
     $xml->endElement();
     //tbody
     $xml->endElement();
     //table
     return $xml->outputMemory();
 }
 /**
  * Generates a key attribute with $key as the value, if $key is not null
  *
  * @param \XmlWriter $writer
  * @param string|null $key
  */
 protected function generateKeyAttribute(\XmlWriter $writer, $key = null)
 {
     if ($key !== null) {
         $writer->startAttribute('key');
         $writer->text($key);
         $writer->endAttribute();
     }
 }
Exemplo n.º 4
0
 /**
  * Function builds OpenPayU Xml Document
  * @access public
  * @param string $data
  * @param string $rootElement
  * @param string $version
  * @param string $encoding
  * @param string $rootElementXsi
  * @return string $xml
  */
 public static function buildXmlFromArray($data, $rootElement, $version = '1.0', $encoding = 'UTF-8', $rootElementXsi = null)
 {
     if (!is_array($data)) {
         return null;
     }
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->startDocument($version, $encoding);
     $xml->startElementNS(null, 'OpenPayU', 'http://www.openpayu.com/20/openpayu.xsd');
     $xml->startElement($rootElement);
     if (!empty($rootElementXsi)) {
         $xml->startAttributeNs('xsi', 'type', 'http://www.w3.org/2001/XMLSchema-instance');
         $xml->text($rootElementXsi);
         $xml->endAttribute();
     }
     self::convertArrayToXml($xml, $data);
     $xml->endElement();
     $xml->endElement();
     $xml->endDocument();
     return trim($xml->outputMemory(true));
 }