Пример #1
0
print XML_Util::replaceEntities("This string contains < & >.");
print "\n<br><br>\n";
/**
 * reversing XML entities
 */
print "replace XML entities:<br>\n";
print XML_Util::reverseEntities("This string contains &lt; &amp; &gt;.");
print "\n<br><br>\n";
/**
 * building XML declaration
 */
print "building XML declaration:<br>\n";
print htmlspecialchars(XML_Util::getXMLDeclaration());
print "\n<br><br>\n";
print "building XML declaration with additional attributes:<br>";
print htmlspecialchars(XML_Util::getXMLDeclaration("1.0", "UTF-8", true));
print "\n<br><br>\n";
/**
 * building document type declaration
 */
print "building DocType declaration:<br>\n";
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package', 'http://pear.php.net/dtd/package-1.0'));
print "\n<br><br>\n";
print "building DocType declaration with public ID (does not exist):<br>\n";
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package', array('uri' => 'http://pear.php.net/dtd/package-1.0', 'id' => '-//PHP//PEAR/DTD PACKAGE 0.1')));
print "\n<br><br>\n";
print "building DocType declaration with internal DTD:<br>\n";
print "<pre>";
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package', 'http://pear.php.net/dtd/package-1.0', '<!ELEMENT additionalInfo (#PCDATA)>'));
print "</pre>";
print "\n<br><br>\n";
Пример #2
0
 /**
  * Returns a formatted string of the object
  * @param    object  $obj    Container object to be output as string
  * @access   public
  * @return   string
  */
 function toString(&$obj)
 {
     $indent = '';
     if (!$obj->isRoot()) {
         // no indent for root
         $this->_deep++;
         $indent = str_repeat($this->options['indent'], $this->_deep);
     } else {
         // Initialize string with xml declaration
         $string = '';
         if ($this->options['addDecl']) {
             $string .= XML_Util::getXMLDeclaration($this->options['version'], $this->options['encoding']);
             $string .= $this->options['linebreak'];
         }
         if (!empty($this->options['name'])) {
             $string .= '<' . $this->options['name'] . '>' . $this->options['linebreak'];
             $this->_deep++;
             $indent = str_repeat($this->options['indent'], $this->_deep);
         }
     }
     if (!isset($string)) {
         $string = '';
     }
     switch ($obj->type) {
         case 'directive':
             $attributes = $this->options['useAttr'] ? $obj->attributes : array();
             $string .= $indent . XML_Util::createTag($obj->name, $attributes, $obj->content, null, $this->options['useCData'] ? XML_UTIL_CDATA_SECTION : XML_UTIL_REPLACE_ENTITIES);
             $string .= $this->options['linebreak'];
             break;
         case 'comment':
             $string .= $indent . '<!-- ' . $obj->content . ' -->';
             $string .= $this->options['linebreak'];
             break;
         case 'section':
             if (!$obj->isRoot()) {
                 $string = $indent . '<' . $obj->name;
                 $string .= $this->options['useAttr'] ? XML_Util::attributesToString($obj->attributes) : '';
             }
             if ($children = count($obj->children)) {
                 if (!$obj->isRoot()) {
                     $string .= '>' . $this->options['linebreak'];
                 }
                 for ($i = 0; $i < $children; $i++) {
                     $string .= $this->toString($obj->getChild($i));
                 }
             }
             if (!$obj->isRoot()) {
                 if ($children) {
                     $string .= $indent . '</' . $obj->name . '>' . $this->options['linebreak'];
                 } else {
                     $string .= '/>' . $this->options['linebreak'];
                 }
             } else {
                 if (!empty($this->options['name'])) {
                     $string .= '</' . $this->options['name'] . '>' . $this->options['linebreak'];
                 }
             }
             break;
         default:
             $string = '';
     }
     if (!$obj->isRoot()) {
         $this->_deep--;
     }
     return $string;
 }
Пример #3
0
 /**
  * serialize data
  *
  * @access   public
  * @param    mixed    $data data to serialize
  * @return   boolean  true on success, pear error on failure
  */
 function serialize($data, $options = null)
 {
     // if options have been specified, use them instead
     // of the previously defined ones
     if (is_array($options)) {
         $optionsBak = $this->options;
         if (isset($options['overrideOptions']) && $options['overrideOptions'] == true) {
             $this->options = array_merge($this->_defaultOptions, $options);
         } else {
             $this->options = array_merge($this->options, $options);
         }
     } else {
         $optionsBak = null;
     }
     //  start depth is zero
     $this->_tagDepth = 0;
     $this->_serializedData = '';
     // serialize an array
     if (is_array($data)) {
         if (isset($this->options['rootName'])) {
             $tagName = $this->options['rootName'];
         } else {
             $tagName = 'array';
         }
         $this->_serializedData .= $this->_serializeArray($data, $tagName, $this->options['rootAttributes']);
     }
     // add doctype declaration
     if ($this->options['addDoctype'] === true) {
         $this->_serializedData = XML_Util::getDoctypeDeclaration($tagName, $this->options['doctype']) . $this->options['linebreak'] . $this->_serializedData;
     }
     //  build xml declaration
     if ($this->options['addDecl']) {
         $atts = array();
         if (isset($this->options['encoding'])) {
             $encoding = $this->options['encoding'];
         } else {
             $encoding = null;
         }
         $this->_serializedData = XML_Util::getXMLDeclaration('1.0', $encoding) . $this->options['linebreak'] . $this->_serializedData;
     }
     if ($optionsBak !== null) {
         $this->options = $optionsBak;
     }
     return true;
 }
 /**
  * serialize a token
  *
  * This method does the actual beautifying.
  *
  * @param array $token structure that should be serialized
  *
  * @return mixed
  * @access private 
  * @todo split this method into smaller methods
  */
 function _serializeToken($token)
 {
     switch ($token["type"]) {
         /*
          * serialize XML Element
          */
         case XML_BEAUTIFIER_ELEMENT:
             $indent = $this->_getIndentString($token["depth"]);
             // adjust tag case
             if ($this->_options["caseFolding"] === true) {
                 switch ($this->_options["caseFoldingTo"]) {
                     case "uppercase":
                         $token["tagname"] = strtoupper($token["tagname"]);
                         $token["attribs"] = array_change_key_case($token["attribs"], CASE_UPPER);
                         break;
                     case "lowercase":
                         $token["tagname"] = strtolower($token["tagname"]);
                         $token["attribs"] = array_change_key_case($token["attribs"], CASE_LOWER);
                         break;
                 }
             }
             if ($this->_options["multilineTags"] == true) {
                 $attIndent = $indent . str_repeat(" ", 2 + strlen($token["tagname"]));
             } else {
                 $attIndent = null;
             }
             // check for children
             switch ($token["contains"]) {
                 // contains only CData or is empty
                 case XML_BEAUTIFIER_CDATA:
                 case XML_BEAUTIFIER_EMPTY:
                     if (sizeof($token["children"]) >= 1) {
                         $data = $token["children"][0]["data"];
                     } else {
                         $data = '';
                     }
                     if (strstr($data, "\n")) {
                         $data = "\n" . $this->_indentTextBlock($data, $token['depth'] + 1, true);
                     }
                     $xml = $indent . XML_Util::createTag($token["tagname"], $token["attribs"], $data, null, XML_UTIL_REPLACE_ENTITIES, $this->_options["multilineTags"], $attIndent) . $this->_options["linebreak"];
                     break;
                     // contains mixed content
                 // contains mixed content
                 default:
                     $xml = $indent . XML_Util::createStartElement($token["tagname"], $token["attribs"], null, $this->_options["multilineTags"], $attIndent) . $this->_options["linebreak"];
                     $cnt = count($token["children"]);
                     for ($i = 0; $i < $cnt; $i++) {
                         $xml .= $this->_serializeToken($token["children"][$i]);
                     }
                     $xml .= $indent . XML_Util::createEndElement($token["tagname"]) . $this->_options["linebreak"];
                     break;
                     break;
             }
             break;
             /*
              * serialize CData
              */
         /*
          * serialize CData
          */
         case XML_BEAUTIFIER_CDATA:
             if ($token["depth"] > 0) {
                 $xml = str_repeat($this->_options["indent"], $token["depth"]);
             } else {
                 $xml = "";
             }
             $xml .= XML_Util::replaceEntities($token["data"]) . $this->_options["linebreak"];
             break;
             /*
              * serialize CData section
              */
         /*
          * serialize CData section
          */
         case XML_BEAUTIFIER_CDATA_SECTION:
             if ($token["depth"] > 0) {
                 $xml = str_repeat($this->_options["indent"], $token["depth"]);
             } else {
                 $xml = "";
             }
             $xml .= '<![CDATA[' . $token["data"] . ']]>' . $this->_options["linebreak"];
             break;
             /*
              * serialize entity
              */
         /*
          * serialize entity
          */
         case XML_BEAUTIFIER_ENTITY:
             if ($token["depth"] > 0) {
                 $xml = str_repeat($this->_options["indent"], $token["depth"]);
             } else {
                 $xml = "";
             }
             $xml .= "&" . $token["name"] . ";" . $this->_options["linebreak"];
             break;
             /*
              * serialize Processing instruction
              */
         /*
          * serialize Processing instruction
          */
         case XML_BEAUTIFIER_PI:
             $indent = $this->_getIndentString($token["depth"]);
             $xml = $indent . "<?" . $token["target"] . $this->_options["linebreak"] . $this->_indentTextBlock(rtrim($token["data"]), $token["depth"]) . $indent . "?>" . $this->_options["linebreak"];
             break;
             /*
              * comments
              */
         /*
          * comments
          */
         case XML_BEAUTIFIER_COMMENT:
             $lines = count(explode("\n", $token["data"]));
             /*
              * normalize comment, i.e. combine it to one
              * line and remove whitespace
              */
             if ($this->_options["normalizeComments"] && $lines > 1) {
                 $comment = preg_replace("/\\s\\s+/s", " ", str_replace("\n", " ", $token["data"]));
                 $lines = 1;
             } else {
                 $comment = $token["data"];
             }
             /*
              * check for the maximum length of one line
              */
             if ($this->_options["maxCommentLine"] > 0) {
                 if ($lines > 1) {
                     $commentLines = explode("\n", $comment);
                 } else {
                     $commentLines = array($comment);
                 }
                 $comment = "";
                 for ($i = 0; $i < $lines; $i++) {
                     if (strlen($commentLines[$i]) <= $this->_options["maxCommentLine"]) {
                         $comment .= $commentLines[$i];
                         continue;
                     }
                     $comment .= wordwrap($commentLines[$i], $this->_options["maxCommentLine"]);
                     if ($i != $lines - 1) {
                         $comment .= "\n";
                     }
                 }
                 $lines = count(explode("\n", $comment));
             }
             $indent = $this->_getIndentString($token["depth"]);
             if ($lines > 1) {
                 $xml = $indent . "<!--" . $this->_options["linebreak"] . $this->_indentTextBlock($comment, $token["depth"] + 1, true) . $indent . "-->" . $this->_options["linebreak"];
             } else {
                 $xml = $indent . sprintf("<!-- %s -->", trim($comment)) . $this->_options["linebreak"];
             }
             break;
             /*
              * xml declaration
              */
         /*
          * xml declaration
          */
         case XML_BEAUTIFIER_XML_DECLARATION:
             $indent = $this->_getIndentString($token["depth"]);
             $xml = $indent . XML_Util::getXMLDeclaration($token["version"], $token["encoding"], $token["standalone"]);
             break;
             /*
              * xml declaration
              */
         /*
          * xml declaration
          */
         case XML_BEAUTIFIER_DT_DECLARATION:
             $xml = $token["data"];
             break;
             /*
              * all other elements
              */
         /*
          * all other elements
          */
         case XML_BEAUTIFIER_DEFAULT:
         default:
             $xml = XML_Util::replaceEntities($token["data"]);
             break;
     }
     return $xml;
 }
Пример #5
0
 /**
  * serialize data
  *
  * @param mixed $data    data to serialize
  * @param array $options options array
  *
  * @return boolean true on success, pear error on failure
  * @access public
  * @uses XML_Util::getDoctypeDeclaration()
  * @uses XML_Util::getXMLDeclaration()
  * @internal uses error suppression "@settype()"
  */
 function serialize($data, $options = null)
 {
     // if options have been specified, use them instead
     // of the previously defined ones
     if (is_array($options)) {
         $optionsBak = $this->options;
         if (isset($options['overrideOptions']) && $options['overrideOptions'] == true) {
             $this->options = array_merge($this->_defaultOptions, $options);
         } else {
             $this->options = array_merge($this->options, $options);
         }
     } else {
         $optionsBak = null;
     }
     //  start depth is zero
     $this->_tagDepth = 0;
     $rootAttributes = $this->options[XML_SERIALIZER_OPTION_ROOT_ATTRIBS];
     if (isset($this->options[XML_SERIALIZER_OPTION_NAMESPACE]) && is_array($this->options[XML_SERIALIZER_OPTION_NAMESPACE])) {
         $rootAttributes['xmlns:' . $this->options[XML_SERIALIZER_OPTION_NAMESPACE][0]] = $this->options[XML_SERIALIZER_OPTION_NAMESPACE][1];
     }
     $this->_serializedData = '';
     // serialize an array
     if (is_array($data)) {
         if (isset($this->options[XML_SERIALIZER_OPTION_ROOT_NAME])) {
             $tagName = $this->options[XML_SERIALIZER_OPTION_ROOT_NAME];
         } else {
             $tagName = 'array';
         }
         $this->_serializedData .= $this->_serializeArray($data, $tagName, $rootAttributes);
     } elseif (is_object($data)) {
         // serialize an object
         if (isset($this->options[XML_SERIALIZER_OPTION_ROOT_NAME])) {
             $tagName = $this->options[XML_SERIALIZER_OPTION_ROOT_NAME];
         } else {
             $tagName = get_class($data);
         }
         $this->_serializedData .= $this->_serializeObject($data, $tagName, $rootAttributes);
     } else {
         $tag = array();
         if (isset($this->options[XML_SERIALIZER_OPTION_ROOT_NAME])) {
             $tag['qname'] = $this->options[XML_SERIALIZER_OPTION_ROOT_NAME];
         } else {
             $tag['qname'] = gettype($data);
         }
         $tagName = $tag['qname'];
         if ($this->options[XML_SERIALIZER_OPTION_TYPEHINTS] === true) {
             $rootAttributes[$this->options[XML_SERIALIZER_OPTION_ATTRIBUTE_TYPE]] = gettype($data);
         }
         if (!is_bool($data)) {
             $tag['content'] = $data;
         } elseif ($data === false) {
             if ($this->options[XML_SERIALIZER_OPTION_FALSE_AS_STRING] === true) {
                 $tag['content'] = '0';
             } else {
                 $tag['content'] = '';
             }
         } else {
             $tag['content'] = $data;
         }
         @settype($data, 'string');
         $tag['attributes'] = $rootAttributes;
         $this->_serializedData = $this->_createXMLTag($tag);
     }
     // add doctype declaration
     if ($this->options[XML_SERIALIZER_OPTION_DOCTYPE_ENABLED] === true) {
         $this->_serializedData = XML_Util::getDoctypeDeclaration($tagName, $this->options[XML_SERIALIZER_OPTION_DOCTYPE]) . $this->options[XML_SERIALIZER_OPTION_LINEBREAKS] . $this->_serializedData;
     }
     //  build xml declaration
     if ($this->options[XML_SERIALIZER_OPTION_XML_DECL_ENABLED]) {
         $atts = array();
         $this->_serializedData = XML_Util::getXMLDeclaration('1.0', $this->options[XML_SERIALIZER_OPTION_XML_ENCODING]) . $this->options[XML_SERIALIZER_OPTION_LINEBREAKS] . $this->_serializedData;
     }
     if ($this->options[XML_SERIALIZER_OPTION_RETURN_RESULT] === true) {
         $result = $this->_serializedData;
     } else {
         $result = true;
     }
     if ($optionsBak !== null) {
         $this->options = $optionsBak;
     }
     return $result;
 }
Пример #6
0
 /**
  * Display final results
  *
  * Display final results, when data source parsing is over.
  *
  * @access public
  * @return void
  * @since  version 1.8.0b2 (2008-06-03)
  */
 function display()
 {
     if ($this->parseData === false) {
         // invalid data source
         return;
     }
     $version = isset($this->conf['xml']['version']) ? $this->conf['xml']['version'] : '1.0';
     $encoding = isset($this->conf['xml']['encoding']) ? $this->conf['xml']['encoding'] : 'UTF-8';
     $standalone = isset($this->conf['xml']['standalone']) ? $this->conf['xml']['standalone'] : null;
     $msg = XML_Util::getXMLDeclaration($version, $encoding, $standalone);
     $msg .= PHP_EOL;
     $msg .= XML_Util::createStartElement('pci', array('version' => '1.9.0'));
     $o = $this->args['output-level'];
     $v = $this->args['verbose'];
     $dataSource = $this->_parser->dataSource['dataSource'];
     $dataType = $this->_parser->dataSource['dataType'];
     $options = $this->_parser->options;
     if ($dataType == 'directory' || $dataType == 'array' || $dataType == 'file') {
         // parsing a directory or a list of files, chunks of code
         if ($options['is_string'] == false) {
             if ($dataType == 'directory') {
                 // print <dir> tag
                 $tag = array('qname' => 'dir', 'content' => dirname($dataSource[0]));
             } else {
                 // print <file> tag
                 $tag = array('qname' => 'file', 'content' => $dataSource[0]);
             }
             $msg .= XML_Util::createTagFromArray($tag);
             $msg .= PHP_EOL;
         }
         // print global <version> tag
         if ($o & 16) {
             if (empty($this->parseData['max_version'])) {
                 $attr = array();
             } else {
                 $attr = array('max' => $this->parseData['max_version']);
             }
             $tag = array('qname' => 'version', 'attributes' => $attr, 'content' => $this->parseData['version']);
             $msg .= XML_Util::createTagFromArray($tag);
             $msg .= PHP_EOL;
         }
         // print global <conditions> tag group
         if ($o & 1) {
             $msg .= $this->_printTagList($this->parseData['cond_code'], 'condition');
         }
         // print global <extensions> tag group
         if ($o & 2) {
             $msg .= $this->_printTagList($this->parseData['extensions'], 'extension');
         }
         // print global <constants> tag group
         if ($o & 4) {
             $msg .= $this->_printTagList($this->parseData['constants'], 'constant');
         }
         // print global <tokens> tag group
         if ($o & 8) {
             $msg .= $this->_printTagList($this->parseData['tokens'], 'token');
         }
         // print global <ignored> tag group
         $msg .= XML_Util::createStartElement('ignored');
         $msg .= PHP_EOL;
         // with children groups <files>, <functions>, <extensions>, <constants>
         $ignored = array('file' => $this->parseData['ignored_files'], 'function' => $this->parseData['ignored_functions'], 'extension' => $this->parseData['ignored_extensions'], 'constant' => $this->parseData['ignored_constants']);
         foreach ($ignored as $tag => $data) {
             $msg .= $this->_printTagList($data, $tag);
         }
         $msg .= XML_Util::createEndElement('ignored');
         $msg .= PHP_EOL;
         // remove summary data
         unset($this->parseData['ignored_files']);
         unset($this->parseData['ignored_functions']);
         unset($this->parseData['ignored_extensions']);
         unset($this->parseData['ignored_constants']);
         unset($this->parseData['max_version']);
         unset($this->parseData['version']);
         unset($this->parseData['classes']);
         unset($this->parseData['functions']);
         unset($this->parseData['extensions']);
         unset($this->parseData['constants']);
         unset($this->parseData['tokens']);
         unset($this->parseData['cond_code']);
         if ($v & 4 || $options['debug'] == true) {
             // print local <functions> tag group
             $msg .= $this->_printTagList($this->parseData, 'function');
             $entries = array_keys($this->parseData);
             foreach ($entries as $k) {
                 if (is_numeric($k[0])) {
                     unset($this->parseData[$k]);
                 }
             }
         }
         if ($dataType == 'file') {
             // parsing a single file
             $files = array($dataSource[0] => $this->parseData);
         } else {
             $files = $this->parseData;
         }
     } else {
         // ... or a chunk of code (string)
         $files = array($this->parseData);
     }
     if ($this->args['summarize'] === false && count($files) > 1) {
         if ($options['is_string'] == false) {
             // print <files> tag group
             $msg .= XML_Util::createStartElement('files', array('count' => count($files)));
             $msg .= PHP_EOL;
         }
         foreach ($files as $file => $this->parseData) {
             if ($options['is_string'] == true) {
                 $msg .= XML_Util::createStartElement('string', array('name' => $file));
             } else {
                 // print local <file> tag
                 $msg .= XML_Util::createStartElement('file', array('name' => $file));
             }
             $msg .= PHP_EOL;
             // print local <version> tag
             if ($o & 16) {
                 if (empty($this->parseData['max_version'])) {
                     $attr = array();
                 } else {
                     $attr = array('max' => $this->parseData['max_version']);
                 }
                 $tag = array('qname' => 'version', 'attributes' => $attr, 'content' => $this->parseData['version']);
                 $msg .= XML_Util::createTagFromArray($tag);
                 $msg .= PHP_EOL;
             }
             // print local <conditions> tag group
             if ($o & 1) {
                 $msg .= $this->_printTagList($this->parseData['cond_code'], 'condition');
             }
             // print local <extensions> tag group
             if ($o & 2) {
                 $msg .= $this->_printTagList($this->parseData['extensions'], 'extension');
             }
             // print local <constants> tag group
             if ($o & 4) {
                 $msg .= $this->_printTagList($this->parseData['constants'], 'constant');
             }
             // print local <tokens> tag group
             if ($o & 8) {
                 $msg .= $this->_printTagList($this->parseData['tokens'], 'token');
             }
             // print local <ignored> tag group
             $msg .= XML_Util::createStartElement('ignored');
             $msg .= PHP_EOL;
             // with children groups <functions>, <extensions>, <constants>
             $ignored = array('function' => $this->parseData['ignored_functions'], 'extension' => $this->parseData['ignored_extensions'], 'constant' => $this->parseData['ignored_constants']);
             foreach ($ignored as $tag => $data) {
                 $msg .= $this->_printTagList($data, $tag);
             }
             $msg .= XML_Util::createEndElement('ignored');
             $msg .= PHP_EOL;
             // extra information only if verbose mode >= 4
             if ($v & 4 || $options['debug'] == true) {
                 unset($this->parseData['ignored_files']);
                 unset($this->parseData['ignored_functions']);
                 unset($this->parseData['ignored_extensions']);
                 unset($this->parseData['ignored_constants']);
                 unset($this->parseData['max_version']);
                 unset($this->parseData['version']);
                 unset($this->parseData['classes']);
                 unset($this->parseData['functions']);
                 unset($this->parseData['extensions']);
                 unset($this->parseData['constants']);
                 unset($this->parseData['tokens']);
                 unset($this->parseData['cond_code']);
                 // print local <functions> tag group
                 $msg .= $this->_printTagList($this->parseData, 'function');
             }
             if ($options['is_string'] == true) {
                 $msg .= XML_Util::createEndElement('string');
             } else {
                 $msg .= XML_Util::createEndElement('file');
             }
             $msg .= PHP_EOL;
         }
         if ($options['is_string'] == false) {
             $msg .= XML_Util::createEndElement('files');
             $msg .= PHP_EOL;
         }
     }
     $msg .= XML_Util::createEndElement('pci');
     $msg .= PHP_EOL;
     if (strtolower($this->conf['use-beautifier']) != 'no') {
         // try to see if we can improve XML render
         $beautifier = 'XML/Beautifier.php';
         if (PHP_CompatInfo_Renderer::isIncludable($beautifier)) {
             include_once $beautifier;
             $def = array();
             $opt = isset($this->conf['beautifier']) ? $this->conf['beautifier'] : $def;
             $fmt = new XML_Beautifier($opt);
             $msg = $fmt->formatString($msg);
         }
     }
     echo $msg;
 }
Пример #7
0
print XML_Util::replaceEntities('This string contains < & >.');
print "\n<br><br>\n";
/**
 * reversing XML entities
 */
print 'replace XML entities:<br>';
print XML_Util::reverseEntities('This string contains &lt; &amp; &gt;.');
print "\n<br><br>\n";
/**
 * building XML declaration
 */
print 'building XML declaration:<br>';
print htmlspecialchars(XML_Util::getXMLDeclaration());
print "\n<br><br>\n";
print 'building XML declaration with additional attributes:<br>';
print htmlspecialchars(XML_Util::getXMLDeclaration('1.0', 'UTF-8', true));
print "\n<br><br>\n";
/**
 * building document type declaration
 */
print 'building DocType declaration:<br>';
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package', 'http://pear.php.net/dtd/package-1.0'));
print "\n<br><br>\n";
print 'building DocType declaration with public ID (does not exist):<br>';
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package', array('uri' => 'http://pear.php.net/dtd/package-1.0', 'id' => '-//PHP//PEAR/DTD PACKAGE 0.1')));
print "\n<br><br>\n";
print 'building DocType declaration with internal DTD:<br>';
print '<pre>';
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package', 'http://pear.php.net/dtd/package-1.0', '<!ELEMENT additionalInfo (#PCDATA)>'));
print '</pre>';
print "\n<br><br>\n";
 public function toString(__ConfigurationComponent &$configuration_component)
 {
     $indent = '';
     if (!$configuration_component->isRoot()) {
         // no indent for root
         $this->_deep++;
         $indent = str_repeat($this->options['indent'], $this->_deep);
     } else {
         // Initialize string with xml declaration
         $string = '';
         if ($this->options['addDecl']) {
             $string .= XML_Util::getXMLDeclaration($this->options['version'], $this->options['encoding']);
             $string .= $this->options['linebreak'];
         }
         if (!empty($this->options['name'])) {
             $string .= '<' . $this->options['name'] . '>' . $this->options['linebreak'];
             $this->_deep++;
             $indent = str_repeat($this->options['indent'], $this->_deep);
         }
     }
     if (!isset($string)) {
         $string = '';
     }
     if ($configuration_component instanceof __ConfigurationProperty) {
         $attributes = $this->options['useAttr'] ? $configuration_component->attributes : array();
         $string .= $indent . XML_Util::createTag($configuration_component->name, $attributes, $configuration_component->content, null, $this->options['useCData'] ? XML_UTIL_CDATA_SECTION : XML_UTIL_REPLACE_ENTITIES);
         $string .= $this->options['linebreak'];
     } else {
         if ($configuration_component instanceof __ConfigurationComment) {
             $string .= $indent . '<!-- ' . $configuration_component->content . ' -->';
             $string .= $this->options['linebreak'];
         } else {
             if ($configuration_component instanceof __ConfigurationSection) {
                 if (!$configuration_component->isRoot()) {
                     $string = $indent . '<' . $configuration_component->name;
                     $string .= $this->options['useAttr'] ? XML_Util::attributesToString($configuration_component->attributes) : '';
                 }
                 if ($children = count($configuration_component->children)) {
                     if (!$configuration_component->isRoot()) {
                         $string .= '>' . $this->options['linebreak'];
                     }
                     for ($i = 0; $i < $children; $i++) {
                         $string .= $this->toString($configuration_component->getChild($i));
                     }
                 }
                 if (!$configuration_component->isRoot()) {
                     if ($children) {
                         $string .= $indent . '</' . $configuration_component->name . '>' . $this->options['linebreak'];
                     } else {
                         $string .= '/>' . $this->options['linebreak'];
                     }
                 } else {
                     if (!empty($this->options['name'])) {
                         $string .= '</' . $this->options['name'] . '>' . $this->options['linebreak'];
                     }
                 }
             } else {
                 $string = '';
             }
         }
     }
     if (!$configuration_component->isRoot()) {
         $this->_deep--;
     }
     return $string;
 }
Пример #9
0
/** baz_affiche_flux_RSS() - affiche le flux rss à partir de parametres
*
*
* @return  string Le flux RSS, avec les headers et tout et tout
*/
function baz_afficher_flux_RSS()
{
    if (isset($_GET['id_typeannonce'])) {
        $id_typeannonce = $_GET['id_typeannonce'];
    } else {
        $id_typeannonce = $GLOBALS['_BAZAR_']['id_typeannonce'];
    }
    if (isset($_GET['categorie_fiche'])) {
        $categorie_fiche = $_GET['categorie_fiche'];
    } else {
        $categorie_fiche = $GLOBALS['_BAZAR_']['categorie_nature'];
    }
    if (isset($_GET['nbitem'])) {
        $nbitem = $_GET['nbitem'];
    } else {
        $nbitem = BAZ_NB_ENTREES_FLUX_RSS;
    }
    if (isset($_GET['utilisateur'])) {
        $utilisateur = $_GET['utilisateur'];
    } else {
        $utilisateur = '';
    }
    if (isset($_GET['statut'])) {
        $statut = $_GET['statut'];
    } else {
        $statut = 1;
    }
    if (isset($_GET['query'])) {
        $query = $_GET['query'];
    } else {
        $query = '';
    }
    $tableau_flux_rss = baz_requete_recherche_fiches($query, '', $id_typeannonce, $categorie_fiche, $statut, $utilisateur, 20);
    require_once 'XML/Util.php';
    // setlocale() pour avoir les formats de date valides (w3c) --julien
    setlocale(LC_TIME, "C");
    $xml = XML_Util::getXMLDeclaration('1.0', 'UTF-8', 'yes');
    $xml .= "\r\n  ";
    $xml .= XML_Util::createStartElement('rss', array('version' => '2.0', 'xmlns:atom' => "http://www.w3.org/2005/Atom"));
    $xml .= "\r\n    ";
    $xml .= XML_Util::createStartElement('channel');
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('title', null, utf8_encode(html_entity_decode(BAZ_DERNIERE_ACTU)));
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('link', null, utf8_encode(html_entity_decode(BAZ_RSS_ADRESSESITE)));
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('description', null, utf8_encode(html_entity_decode(BAZ_RSS_DESCRIPTIONSITE)));
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('language', null, 'fr-FR');
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('copyright', null, 'Copyright (c) ' . date('Y') . ' ' . utf8_encode(html_entity_decode(BAZ_RSS_NOMSITE)));
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('lastBuildDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT'));
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('docs', null, 'http://www.stervinou.com/projets/rss/');
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('category', null, BAZ_RSS_CATEGORIE);
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('managingEditor', null, BAZ_RSS_MANAGINGEDITOR);
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('webMaster', null, BAZ_RSS_WEBMASTER);
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('ttl', null, '60');
    $xml .= "\r\n      ";
    $xml .= XML_Util::createStartElement('image');
    $xml .= "\r\n        ";
    $xml .= XML_Util::createTag('title', null, utf8_encode(html_entity_decode(BAZ_DERNIERE_ACTU)));
    $xml .= "\r\n        ";
    $xml .= XML_Util::createTag('url', null, BAZ_RSS_LOGOSITE);
    $xml .= "\r\n        ";
    $xml .= XML_Util::createTag('link', null, BAZ_RSS_ADRESSESITE);
    $xml .= "\r\n      ";
    $xml .= XML_Util::createEndElement('image');
    if (count($tableau_flux_rss) > 0) {
        // Creation des items : titre + lien + description + date de publication
        foreach ($tableau_flux_rss as $ligne) {
            $ligne = json_decode($ligne[0], true);
            $ligne = array_map('utf8_decode', $ligne);
            $xml .= "\r\n      ";
            $xml .= XML_Util::createStartElement('item');
            $xml .= "\r\n        ";
            $xml .= XML_Util::createTag('title', null, encoder_en_utf8(html_entity_decode(stripslashes($ligne['bf_titre']))));
            $xml .= "\r\n        ";
            $lien = $GLOBALS['_BAZAR_']['url'];
            $lien->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
            $lien->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_CONSULTER);
            $lien->addQueryString('id_fiche', $ligne['id_fiche']);
            $xml .= XML_Util::createTag('link', null, '<![CDATA[' . $lien->getURL() . ']]>');
            $xml .= "\r\n        ";
            $xml .= XML_Util::createTag('guid', null, '<![CDATA[' . $lien->getURL() . ']]>');
            $xml .= "\r\n        ";
            $tab = explode("wakka.php?wiki=", $lien->getURL());
            $xml .= XML_Util::createTag('description', null, '<![CDATA[' . encoder_en_utf8(html_entity_decode(baz_voir_fiche(0, $ligne))) . ']]>');
            $xml .= "\r\n        ";
            if ($ligne['date_debut_validite_fiche'] != '0000-00-00' && $ligne['date_debut_validite_fiche'] > $ligne['date_creation_fiche']) {
                $date_pub = $ligne['date_debut_validite_fiche'];
            } else {
                $date_pub = $ligne['date_creation_fiche'];
            }
            $xml .= XML_Util::createTag('pubDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT', strtotime($date_pub)));
            $xml .= "\r\n      ";
            $xml .= XML_Util::createEndElement('item');
        }
    } else {
        //pas d'annonces
        $xml .= "\r\n      ";
        $xml .= XML_Util::createStartElement('item');
        $xml .= "\r\n          ";
        $xml .= XML_Util::createTag('title', null, utf8_encode(html_entity_decode(BAZ_PAS_DE_FICHES)));
        $xml .= "\r\n          ";
        $xml .= XML_Util::createTag('link', null, '<![CDATA[' . $GLOBALS['_BAZAR_']['url']->getUrl() . ']]>');
        $xml .= "\r\n          ";
        $xml .= XML_Util::createTag('guid', null, '<![CDATA[' . $GLOBALS['_BAZAR_']['url']->getUrl() . ']]>');
        $xml .= "\r\n          ";
        $xml .= XML_Util::createTag('description', null, utf8_encode(html_entity_decode(BAZ_PAS_DE_FICHES)));
        $xml .= "\r\n          ";
        $xml .= XML_Util::createTag('pubDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT', strtotime("01/01/%Y")));
        $xml .= "\r\n      ";
        $xml .= XML_Util::createEndElement('item');
    }
    $xml .= "\r\n    ";
    $GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FLUX_RSS);
    //	$xml .= utf8_encode(html_entity_decode('<atom:link href="'.$GLOBALS['_BAZAR_']['url']->getUrl().'" rel="self" type="application/rss+xml" />'."\r\n  "));
    $xml .= XML_Util::createEndElement('channel');
    $xml .= "\r\n  ";
    $xml .= XML_Util::createEndElement('rss');
    // Nettoyage de l'url
    $GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
    $GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
    echo html_entity_decode($xml);
}
Пример #10
0
/** baz_affiche_flux_RSS() - affiche le flux rss a partir de parametres
 * @return  string Le flux RSS, avec les headers et tout et tout
 */
function baz_afficher_flux_RSS()
{
    $urlrss = $GLOBALS['wiki']->href('rss');
    if (isset($_GET['id_typeannonce'])) {
        $id_typeannonce = $_GET['id_typeannonce'];
        $urlrss .= '&amp;id_typeannonce=' . $id_typeannonce;
    } else {
        $id_typeannonce = '';
    }
    if (isset($_GET['categorie_fiche'])) {
        $categorie_fiche = $_GET['categorie_fiche'];
        $urlrss .= '&amp;categorie_fiche=' . $categorie_fiche;
    } else {
        $categorie_fiche = '';
    }
    if (isset($_GET['nbitem'])) {
        $nbitem = $_GET['nbitem'];
        $urlrss .= '&amp;nbitem=' . $nbitem;
    } else {
        $nbitem = BAZ_NB_ENTREES_FLUX_RSS;
    }
    if (isset($_GET['utilisateur'])) {
        $utilisateur = $_GET['utilisateur'];
        $urlrss .= '&amp;utilisateur=' . $utilisateur;
    } else {
        $utilisateur = '';
    }
    if (isset($_GET['statut'])) {
        $statut = $_GET['statut'];
        $urlrss .= '&amp;statut=' . $statut;
    } else {
        $statut = 1;
    }
    if (isset($_GET['query'])) {
        $query = $_GET['query'];
        $urlrss .= '&amp;query=' . $query;
    } else {
        $query = '';
    }
    $tableau_flux_rss = baz_requete_recherche_fiches($query, '', $id_typeannonce, $categorie_fiche, $statut, $utilisateur, 20);
    require_once BAZ_CHEMIN . 'libs' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'XML/Util.php';
    // setlocale() pour avoir les formats de date valides (w3c) --julien
    setlocale(LC_TIME, 'C');
    $xml = XML_Util::getXMLDeclaration('1.0', 'UTF-8', 'yes');
    $xml .= "\r\n  ";
    $xml .= XML_Util::createStartElement('rss', array('version' => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/'));
    $xml .= "\r\n    ";
    $xml .= XML_Util::createStartElement('channel');
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('title', null, html_entity_decode(_t('BAZ_DERNIERE_ACTU'), ENT_QUOTES, 'UTF-8'));
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('link', null, html_entity_decode(BAZ_RSS_ADRESSESITE, ENT_QUOTES, 'UTF-8'));
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('description', null, html_entity_decode(BAZ_RSS_DESCRIPTIONSITE, ENT_QUOTES, 'UTF-8'));
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('language', null, 'fr-FR');
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('copyright', null, 'Copyright (c) ' . date('Y') . ' ' . html_entity_decode(BAZ_RSS_NOMSITE, ENT_QUOTES, 'UTF-8'));
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('lastBuildDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT'));
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('docs', null, 'http://www.stervinou.com/projets/rss/');
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('category', null, BAZ_RSS_CATEGORIE);
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('managingEditor', null, BAZ_RSS_MANAGINGEDITOR);
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('webMaster', null, BAZ_RSS_WEBMASTER);
    $xml .= "\r\n      ";
    $xml .= XML_Util::createTag('ttl', null, '60');
    $xml .= "\r\n      ";
    $xml .= XML_Util::createStartElement('image');
    $xml .= "\r\n        ";
    $xml .= XML_Util::createTag('title', null, html_entity_decode(_t('BAZ_DERNIERE_ACTU'), ENT_QUOTES, 'UTF-8'));
    $xml .= "\r\n        ";
    $xml .= XML_Util::createTag('url', null, BAZ_RSS_LOGOSITE);
    $xml .= "\r\n        ";
    $xml .= XML_Util::createTag('link', null, BAZ_RSS_ADRESSESITE);
    $xml .= "\r\n      ";
    $xml .= XML_Util::createEndElement('image');
    if (count($tableau_flux_rss) > 0) {
        // Creation des items : titre + lien + description + date de publication
        foreach ($tableau_flux_rss as $ligne) {
            $ligne = json_decode($ligne['body'], true);
            $ligne = _convert($ligne, 'UTF-8');
            $xml .= "\r\n      ";
            $xml .= XML_Util::createStartElement('item');
            $xml .= "\r\n        ";
            $xml .= XML_Util::createTag('title', null, html_entity_decode(stripslashes($ligne['bf_titre']), ENT_QUOTES, 'UTF-8'));
            $xml .= "\r\n        ";
            $lien = $GLOBALS['_BAZAR_']['url'];
            $lien->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
            $lien->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_CONSULTER);
            $lien->addQueryString('id_fiche', $ligne['id_fiche']);
            $xml .= XML_Util::createTag('link', null, '<![CDATA[' . $lien->getURL() . ']]>');
            $xml .= "\r\n        ";
            $xml .= XML_Util::createTag('guid', null, '<![CDATA[' . $lien->getURL() . ']]>');
            $xml .= "\r\n        ";
            $xml .= XML_Util::createTag('dc:creator', null, $ligne['createur']);
            $xml .= "\r\n      ";
            $tab = explode('wakka.php?wiki=', $lien->getURL());
            $xml .= XML_Util::createTag('description', null, '<![CDATA[' . preg_replace('/data-id=".*"/Ui', '', html_entity_decode(baz_voir_fiche(0, $ligne), ENT_QUOTES, 'UTF-8')) . ']]>');
            $xml .= "\r\n        ";
            $xml .= XML_Util::createTag('pubDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT', strtotime($ligne['date_creation_fiche'])));
            $xml .= "\r\n      ";
            $xml .= XML_Util::createEndElement('item');
        }
    } else {
        //pas d'annonces
        $xml .= "\r\n      ";
        $xml .= XML_Util::createStartElement('item');
        $xml .= "\r\n          ";
        $xml .= XML_Util::createTag('title', null, html_entity_decode(_t('BAZ_PAS_DE_FICHES'), ENT_QUOTES, 'UTF-8'));
        $xml .= "\r\n          ";
        $xml .= XML_Util::createTag('link', null, '<![CDATA[' . $GLOBALS['_BAZAR_']['url']->getUrl() . ']]>');
        $xml .= "\r\n          ";
        $xml .= XML_Util::createTag('guid', null, '<![CDATA[' . $GLOBALS['_BAZAR_']['url']->getUrl() . ']]>');
        $xml .= "\r\n          ";
        $xml .= XML_Util::createTag('description', null, html_entity_decode(_t('BAZ_PAS_DE_FICHES'), ENT_QUOTES, 'UTF-8'));
        $xml .= "\r\n          ";
        $xml .= XML_Util::createTag('pubDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT', strtotime('01/01/%Y')));
        $xml .= "\r\n      ";
        $xml .= XML_Util::createEndElement('item');
    }
    $xml .= "\r\n    ";
    $xml .= XML_Util::createEndElement('channel');
    $xml .= "\r\n  ";
    $xml .= XML_Util::createEndElement('rss');
    // Nettoyage de l'url
    $GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
    $GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
    echo str_replace('</image>', '</image>' . "\n" . '<atom:link href="' . $urlrss . '" rel="self" type="application/rss+xml" />', html_entity_decode($xml, ENT_QUOTES, 'UTF-8'));
}
Пример #11
0
 /**
  * serialize data
  *
  * @access   public
  * @param    mixed    $data data to serialize
  * @return   boolean  true on success, pear error on failure
  */
 function serialize($data, $options = null)
 {
     // if options have been specified, use them instead
     // of the previously defined ones
     if (is_array($options)) {
         $optionsBak = $this->options;
         if (isset($options["overrideOptions"]) && $options["overrideOptions"] == true) {
             $this->options = array_merge($this->_defaultOptions, $options);
         } else {
             $this->options = array_merge($this->options, $options);
         }
     } else {
         $optionsBak = null;
     }
     // maintain BC
     if (isset($this->options["tagName"])) {
         $this->options["rootName"] = $this->options["tagName"];
     }
     //  start depth is zero
     $this->_tagDepth = 0;
     $this->_serializedData = "";
     // serialize an array
     if (is_array($data)) {
         if (isset($this->options["rootName"])) {
             $tagName = $this->options["rootName"];
         } else {
             $tagName = "array";
         }
         $this->_serializedData .= $this->_serializeArray($data, $tagName, $this->options["rootAttributes"]);
     } elseif (is_object($data)) {
         if (isset($this->options["rootName"])) {
             $tagName = $this->options["rootName"];
         } else {
             $tagName = get_class($data);
         }
         $this->_serializedData .= $this->_serializeObject($data, $tagName, $this->options["rootAttributes"]);
     }
     // add doctype declaration
     if ($this->options["addDoctype"] === true) {
         $this->_serializedData = XML_Util::getDoctypeDeclaration($tagName, $this->options["doctype"]) . $this->options["linebreak"] . $this->_serializedData;
     }
     //  build xml declaration
     if ($this->options["addDecl"]) {
         $atts = array();
         if (isset($this->options["encoding"])) {
             $encoding = $this->options["encoding"];
         } else {
             $encoding = null;
         }
         $this->_serializedData = XML_Util::getXMLDeclaration("1.0", $encoding) . $this->options["linebreak"] . $this->_serializedData;
     }
     if ($optionsBak !== null) {
         $this->options = $optionsBak;
     }
     return true;
 }
Пример #12
0
 /**
  * Prepare the PUT query xml.
  *
  * @access private
  * @return string The query xml
  */
 function _prepareQueryString()
 {
     $data = array_merge($this->_options, $this->_data);
     $doc = XML_Util::getXMLDeclaration();
     $doc .= '<!DOCTYPE paymentService PUBLIC "-//Bibit//DTD Bibit PaymentService v1//EN" "http://dtd.bibit.com/paymentService_v1.dtd">';
     $doc .= XML_Util::createStartElement('paymentService', array('version' => $data['x_version'], 'merchantCode' => $data['x_login']));
     if ($data['x_action'] == PAYMENT_PROCESS_ACTION_BIBIT_CAPTURE || $data['x_action'] == PAYMENT_PROCESS_ACTION_BIBIT_REFUND) {
         $doc .= XML_Util::createStartElement('modify');
         $doc .= XML_Util::createStartElement('orderModification', array('orderCode' => $data['x_ordercode']));
         if ($data['x_action'] == PAYMENT_PROCESS_ACTION_BIBIT_CAPTURE) {
             $doc .= XML_Util::createStartElement('capture');
             $d = array();
             $t = time() - 86400;
             $d['dayOfMonth'] = date('d', $t);
             $d['month'] = date('m', $t);
             $d['year'] = date('Y', $t);
             $d['hour'] = date('H', $t);
             $d['minute'] = date('i', $t);
             $d['second'] = date('s', $t);
             $doc .= XML_Util::createTag('date', $d);
             $doc .= XML_Util::createTag('amount', array('value' => $data['x_amount'], 'currencyCode' => $data['x_currency'], 'exponent' => $data['x_exponent']));
             $doc .= XML_Util::createEndElement('capture');
         } else {
             if ($data['x_action'] == PAYMENT_PROCESS_ACTION_BIBIT_REFUND) {
                 $doc .= XML_Util::createStartElement('refund');
                 $doc .= XML_Util::createTag('amount', array('value' => $data['x_amount'], 'currencyCode' => $data['x_currency'], 'exponent' => $data['x_exponent']));
                 $doc .= XML_Util::createEndElement('refund');
             }
         }
         $doc .= XML_Util::createEndElement('orderModification');
         $doc .= XML_Util::createEndElement('modify');
     } else {
         $doc .= XML_Util::createStartElement('submit');
         $doc .= XML_Util::createStartElement('order', array('orderCode' => $data['x_ordercode']));
         $doc .= XML_Util::createTag('description', null, $data['x_descr']);
         $doc .= XML_Util::createTag('amount', array('value' => $data['x_amount'], 'currencyCode' => $data['x_currency'], 'exponent' => $data['x_exponent']));
         if (isset($data['x_ordercontent'])) {
             $doc .= XML_Util::createStartElement('orderContent');
             $doc .= XML_Util::createCDataSection($data['x_ordercontent']);
             $doc .= XML_Util::createEndElement('orderContent');
         }
         if ($data['x_action'] == PAYMENT_PROCESS_ACTION_BIBIT_REDIRECT) {
             if (is_array($data['paymentMethodMask']) && count($data['paymentMethodMask'] > 0)) {
                 $doc .= XML_Util::createStartElement('paymentMethodMask');
                 foreach ($data['paymentMethodMask']['include'] as $code) {
                     $doc .= XML_Util::createTag('include', array('code' => $code));
                 }
                 foreach ($data['paymentMethodMask']['exclude'] as $code) {
                     $doc .= XML_Util::createTag('exclude', array('code' => $code));
                 }
                 $doc .= XML_Util::createEndElement('paymentMethodMask');
             }
         } else {
             if ($data['x_action'] == PAYMENT_PROCESS_ACTION_BIBIT_AUTH) {
                 $doc .= XML_Util::createStartElement('paymentDetails');
                 switch ($this->_payment->type) {
                     case PAYMENT_PROCESS_CC_VISA:
                         $cc_type = 'VISA-SSL';
                         break;
                     case PAYMENT_PROCESS_CC_MASTERCARD:
                         $cc_type = 'ECMC-SSL';
                         break;
                     case PAYMENT_PROCESS_CC_AMEX:
                         $cc_type = 'AMEX-SSL';
                         break;
                 }
                 $doc .= XML_Util::createStartElement($cc_type);
                 if (isset($data['x_card_num'])) {
                     $doc .= XML_Util::createTag('cardNumber', null, $data['x_card_num']);
                 }
                 if (isset($data['x_exp_date'])) {
                     $doc .= XML_Util::createStartElement('expiryDate');
                     $doc .= XML_Util::createTag('date', array('month' => substr($data['x_exp_date'], 0, 2), 'year' => substr($data['x_exp_date'], 3, 4)));
                     $doc .= XML_Util::createEndElement('expiryDate');
                 }
                 if (isset($this->_payment->firstName) && isset($this->_payment->lastName)) {
                     $doc .= XML_Util::createTag('cardHolderName', null, $this->_payment->firstName . ' ' . $this->_payment->lastName);
                 }
                 if (isset($data['x_card_code'])) {
                     $doc .= XML_Util::createTag('cvc', null, $data['x_card_code']);
                 }
                 $doc .= XML_Util::createEndElement($cc_type);
                 if ((isset($data['shopperIPAddress']) || isset($data['sessionId'])) && ($data['shopperIPAddress'] != '' || $data['sessionId'] != '')) {
                     $t = array();
                     if ($data['shopperIPAddress'] != '') {
                         $t['shopperIPAddress'] = $data['shopperIPAddress'];
                     }
                     if ($data['sessionId'] != '') {
                         $t['id'] = $data['sessionId'];
                     }
                     $doc .= XML_Util::createTag('session', $t);
                     unset($t);
                 }
                 $doc .= XML_Util::createEndElement('paymentDetails');
             }
         }
         if (isset($data['shopperEmailAddress']) && $data['shopperEmailAddress'] != '' || isset($data['authenticatedShopperID']) && $data['authenticatedShopperID'] != '') {
             $doc .= XML_Util::createStartElement('shopper');
             if ($data['shopperEmailAddress'] != '') {
                 $doc .= XML_Util::createTag('shopperEmailAddress', null, $data['shopperEmailAddress']);
             }
             if ($data['authenticatedShopperID'] != '') {
                 $doc .= XML_Util::createTag('authenticatedShopperID', null, $data['authenticatedShopperID']);
             }
             $doc .= XML_Util::createEndElement('shopper');
         }
         if (is_array($data['shippingAddress']) && count($data['shippingAddress']) > 0) {
             $a = $data['shippingAddress'];
             $doc .= XML_Util::createStartElement('shippingAddress');
             $doc .= XML_Util::createStartElement('address');
             $fields = array('firstName', 'lastName', 'street', 'houseName', 'houseNumber', 'houseNumberExtension', 'postalCode', 'city', 'state', 'countryCode', 'telephoneNumber');
             foreach ($fields as $field) {
                 if (isset($a[$field])) {
                     $doc .= XML_Util::createTag($field, null, $a[$field]);
                 }
             }
             $doc .= XML_Util::createEndElement('address');
             $doc .= XML_Util::createEndElement('shippingAddress');
         }
         $doc .= XML_Util::createEndElement('order');
         $doc .= XML_Util::createEndElement('submit');
     }
     $doc .= XML_Util::createEndElement('paymentService');
     $doc1 = domxml_open_mem($doc);
     return $doc;
 }
Пример #13
0
 /**
  * Serialize the document.
  *
  * @access public
  * @return string
  */
 public function serialize()
 {
     $doc = XML_Util::getXMLDeclaration('1.0', 'utf-8') . "\n\n";
     $doc .= $this->root->serialize();
     return $doc;
 }
Пример #14
0
 /**
  * Generates the XUL for the DataGrid
  *
  * @access  public
  * @return  string      The XUL of the DataGrid
  */
 function toXUL()
 {
     $dg =& $this->_dg;
     // Get the data to be rendered
     $dg->fetchDataSource();
     // Check to see if column headers exist, if not create them
     // This must follow after any fetch method call
     $dg->_setDefaultHeaders();
     // Define XML
     $xul = XML_Util::getXMLDeclaration() . "\n";
     // Define Stylesheets
     foreach ($this->css as $css) {
         $xul .= "<?xml-stylesheet href=\"{$css}\" type=\"text/css\"?>\n";
     }
     // Define Window Element
     $xul .= "<window title=\"{$this->title}\" " . "xmlns=\"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul\">\n";
     // Define Listbox Element
     $xul .= "<listbox rows=\"" . $this->_dg->rowLimit . "\">\n";
     // Build Grid Header
     $xul .= "  <listhead>\n";
     $prefix = $this->requestPrefix;
     foreach ($this->_dg->columnSet as $column) {
         if ($this->_dg->sortArray[0] == $column->orderBy) {
             if (strtoupper($this->_dg->sortArray[1]) == 'ASC') {
                 // The data is currently sorted by $column, ascending.
                 // That means we want $dirArg set to 'DESC', for the next
                 // click to trigger a reverse order sort, and we need
                 // $dirCur set to 'ascending' so that a neat xul arrow
                 // shows the current "ASC" direction.
                 $dirArg = 'DESC';
                 $dirCur = 'ascending';
             } else {
                 // Next click will do ascending sort, and we show a reverse
                 // arrow because we're currently descending.
                 $dirArg = 'ASC';
                 $dirCur = 'descending';
             }
         } else {
             // No current sort on this column. Next click will ascend. We
             // show no arrow.
             $dirArg = 'ASC';
             $dirCur = 'natural';
         }
         $onClick = "location.href='" . $_SERVER['PHP_SELF'] . '?' . $prefix . 'orderBy=' . $column->orderBy . "&amp;" . $prefix . "direction={$dirArg}';";
         $label = XML_Util::replaceEntities($column->columnName);
         $xul .= '    <listheader label="' . $label . '" ' . "sortDirection=\"{$dirCur}\" onCommand=\"{$onClick}\" />\n";
     }
     $xul .= "  </listhead>\n";
     // Build Grid Body
     foreach ($this->_dg->recordSet as $row) {
         $xul .= "  <listitem>\n";
         foreach ($this->_dg->columnSet as $column) {
             // Build Content
             if ($column->formatter != null) {
                 $content = $column->formatter($row);
             } elseif ($column->fieldName == null) {
                 if ($column->autoFillValue != null) {
                     $content = $column->autoFillValue;
                 } else {
                     $content = $column->columnName;
                 }
             } else {
                 $content = $row[$column->fieldName];
             }
             $xul .= '    ' . XML_Util::createTag('listcell', array('label' => $content)) . "\n";
         }
         $xul .= "  </listitem>\n";
     }
     $xul .= "</listbox>\n";
     $xul .= "</window>\n";
     return $xul;
 }
Пример #15
0
 function exportXML()
 {
     global $i18n, $ClassDir;
     require_once 'XML/Util.php';
     require_once $ClassDir . 'StringHelper.class.php';
     $header = array("name", "gender", "birthday", "mobile", "phone", "office_phone", "fax", "addrees", "category", "email", "homepage");
     $filename = date("Y_m_d") . "_contact_export.xml";
     $xml_data = "";
     $xml = new XML_Util();
     $xml_data .= $xml->getXMLDeclaration("1.0", "UTF-8") . "\n";
     $xml_data .= "" . $xml->createStartElement("contact") . "\n";
     //		Write contact record
     $apf_contact = DB_DataObject::factory('ApfContact');
     $apf_contact->orderBy('id desc');
     $apf_contact->find();
     while ($apf_contact->fetch()) {
         $xml_data .= "\t" . $xml->createStartElement("record") . "\n";
         foreach ($header as $title) {
             $coloum_function = "get" . StringHelper::CamelCaseFromUnderscore($title);
             $tag = array("qname" => $title, "content" => $apf_contact->{$coloum_function}());
             $xml_data .= "\t\t" . $xml->createTagFromArray($tag) . "\n";
         }
         $xml_data .= "\t" . $xml->createEndElement("record") . "\n";
     }
     $xml_data .= "" . $xml->createEndElement("contact") . "\n";
     $xml->send($xml_data, $filename);
     exit;
 }