本文整理汇总了PHP中XML_Util类的典型用法代码示例。如果您正苦于以下问题:PHP XML_Util类的具体用法?PHP XML_Util怎么用?PHP XML_Util使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XML_Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: arrayToXML
protected function arrayToXML($fieldInfo, SimpleXMLElement $xmlFieldInfo)
{
foreach ($fieldInfo as $treeItemSID => $treeItemInfo) {
$branch = $xmlFieldInfo->addChild('branch');
$branch->addChild('sid', $treeItemSID);
$branch->addChild('caption', XML_Util::replaceEntities($treeItemInfo['caption']));
if (!empty($treeItemInfo['items'])) {
$branchItems = $branch->addChild('items');
$this->arrayToXML($treeItemInfo['items'], $branchItems);
}
}
}
示例2: _prepareQueryString
/**
* 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');
//.........这里部分代码省略.........
示例3: array
/**
* creating an XML tag with a CData Section
*/
$tag = array("qname" => "foo", "attributes" => array("key" => "value", "argh" => "tütü"), "content" => "Also XHTML-tags can be created and HTML entities can be replaced Ä ä Ü ö <>.");
print "creating a tag with HTML entities:<br>\n";
print htmlentities(XML_Util::createTagFromArray($tag, XML_UTIL_ENTITIES_HTML));
print "\n<br><br>\n";
/**
* creating an XML tag with createTag
*/
print "creating a tag with createTag:<br>";
print htmlentities(XML_Util::createTag("myNs:myTag", array("foo" => "bar"), "This is inside the tag", "http://www.w3c.org/myNs#"));
print "\n<br><br>\n";
/**
* trying to create an XML tag with an array as content
*/
$tag = array("qname" => "bar", "content" => array("foo" => "bar"));
print "trying to create an XML tag with an array as content:<br>\n";
print "<pre>";
print_r(XML_Util::createTagFromArray($tag));
print "</pre>";
print "\n<br><br>\n";
/**
* trying to create an XML tag without a name
*/
$tag = array("attributes" => array("foo" => "bar"));
print "trying to create an XML tag without a name:<br>\n";
print "<pre>";
print_r(XML_Util::createTagFromArray($tag));
print "</pre>";
print "\n<br><br>\n";
示例4: isValidName
/**
* check, whether string is valid XML name
*
* <p>XML names are used for tagname, attribute names and various
* other, lesser known entities.</p>
* <p>An XML name may only consist of alphanumeric characters,
* dashes, undescores and periods, and has to start with a letter
* or an underscore.
* </p>
*
* <code>
* require_once 'XML/Util.php';
*
* // verify tag name
* $result = XML_Util::isValidName("invalidTag?");
* if (XML_Util::isError($result)) {
* print "Invalid XML name: " . $result->getMessage();
* }
* </code>
*
* @access public
* @static
* @param string $string string that should be checked
* @return mixed $valid true, if string is a valid XML name, PEAR error otherwise
* @todo support for other charsets
*/
function isValidName($string)
{
// check for invalid chars
if (!preg_match("/^[[:alnum:]_\\-.]\$/", $string[0])) {
return XML_Util::raiseError("XML names may only start with letter or underscore", XML_UTIL_ERROR_INVALID_START);
}
// check for invalid chars
if (!preg_match("/^([a-zA-Z_]([a-zA-Z0-9_\\-\\.]*)?:)?[a-zA-Z_]([a-zA-Z0-9_\\-\\.]+)?\$/", $string)) {
return XML_Util::raiseError("XML names may only contain alphanumeric chars, period, hyphen, colon and underscores", XML_UTIL_ERROR_INVALID_CHARS);
}
// XML name is valid
return true;
}
示例5: _createXMLTag
/**
* create a tag from an array
* this method awaits an array in the following format
* array(
* 'qname' => $tagName,
* 'attributes' => array(),
* 'content' => $content, // optional
* 'namespace' => $namespace // optional
* 'namespaceUri' => $namespaceUri // optional
* )
*
* @access private
* @param array $tag tag definition
* @param boolean $replaceEntities whether to replace XML entities in content or not
* @return string $string XML tag
*/
function _createXMLTag($tag, $replaceEntities = true)
{
if ($this->options['indentAttributes'] !== false) {
$multiline = true;
$indent = str_repeat($this->options['indent'], $this->_tagDepth);
if ($this->options['indentAttributes'] == '_auto') {
$indent .= str_repeat(' ', strlen($tag['qname']) + 2);
} else {
$indent .= $this->options['indentAttributes'];
}
} else {
$indent = $multiline = false;
}
if (is_array($tag['content'])) {
if (empty($tag['content'])) {
$tag['content'] = '';
}
} elseif (is_scalar($tag['content']) && (string) $tag['content'] == '') {
$tag['content'] = '';
}
if (is_scalar($tag['content']) || is_null($tag['content'])) {
if ($this->options['encoding'] == 'UTF-8' && version_compare(phpversion(), '5.0.0', 'lt')) {
$tag['content'] = utf8_encode($tag['content']);
}
if ($replaceEntities === true) {
$replaceEntities = XML_UTIL_ENTITIES_XML;
}
$tag = XML_Util::createTagFromArray($tag, $replaceEntities, $multiline, $indent, $this->options['linebreak']);
} elseif (is_array($tag['content'])) {
$tag = $this->_serializeArray($tag['content'], $tag['qname'], $tag['attributes']);
} elseif (is_object($tag['content'])) {
$tag = $this->_serializeObject($tag['content'], $tag['qname'], $tag['attributes']);
} elseif (is_resource($tag['content'])) {
settype($tag['content'], 'string');
$tag = XML_Util::createTagFromArray($tag, $replaceEntities);
}
return $tag;
}
示例6: _createXMLTag
/**
* create a tag from an array
* this method awaits an array in the following format
* array(
* 'qname' => $tagName,
* 'attributes' => array(),
* 'content' => $content, // optional
* 'namespace' => $namespace // optional
* 'namespaceUri' => $namespaceUri // optional
* )
*
* @param array $tag tag definition
* @param boolean $firstCall whether or not this is the first call
*
* @return string $string XML tag
* @access private
*/
function _createXMLTag($tag, $firstCall = true)
{
// build fully qualified tag name
if ($this->options[XML_SERIALIZER_OPTION_NAMESPACE] !== null) {
if (is_array($this->options[XML_SERIALIZER_OPTION_NAMESPACE])) {
$tag['qname'] = $this->options[XML_SERIALIZER_OPTION_NAMESPACE][0] . ':' . $tag['qname'];
} else {
$tag['qname'] = $this->options[XML_SERIALIZER_OPTION_NAMESPACE] . ':' . $tag['qname'];
}
}
// attribute indentation
if ($this->options[XML_SERIALIZER_OPTION_INDENT_ATTRIBUTES] !== false) {
$multiline = true;
$indent = str_repeat($this->options[XML_SERIALIZER_OPTION_INDENT], $this->_tagDepth);
if ($this->options[XML_SERIALIZER_OPTION_INDENT_ATTRIBUTES] == '_auto') {
$indent .= str_repeat(' ', strlen($tag['qname']) + 2);
} else {
$indent .= $this->options[XML_SERIALIZER_OPTION_INDENT_ATTRIBUTES];
}
} else {
$multiline = false;
$indent = false;
}
if (is_array($tag['content'])) {
if (empty($tag['content'])) {
$tag['content'] = '';
}
} elseif (XML_SERIALIZER_OPTION_FALSE_AS_STRING && $tag['content'] === false) {
$tag['content'] = '0';
} elseif (is_scalar($tag['content']) && (string) $tag['content'] == '') {
$tag['content'] = '';
}
// replace XML entities
if ($firstCall === true) {
if ($this->options[XML_SERIALIZER_OPTION_CDATA_SECTIONS] === true) {
$replaceEntities = XML_UTIL_CDATA_SECTION;
} else {
$replaceEntities = $this->options[XML_SERIALIZER_OPTION_ENTITIES];
}
} else {
// this is a nested call, so value is already encoded
// and must not be encoded again
$replaceEntities = XML_SERIALIZER_ENTITIES_NONE;
// but attributes need to be encoded anyways
// (done here because the rest of the code assumes the same encoding
// can be used both for attributes and content)
foreach ($tag['attributes'] as $k => $v) {
$v = XML_Util::replaceEntities($v, $this->options[XML_SERIALIZER_OPTION_ENTITIES]);
$tag['attributes'][$k] = $v;
}
}
if (is_scalar($tag['content']) || is_null($tag['content'])) {
if ($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC]) {
if ($firstCall === true) {
$tag['content'] = call_user_func($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC], $tag['content']);
}
$tag['attributes'] = array_map($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC], $tag['attributes']);
}
$tag = XML_Util::createTagFromArray($tag, $replaceEntities, $multiline, $indent, $this->options[XML_SERIALIZER_OPTION_LINEBREAKS]);
} elseif (is_array($tag['content'])) {
$tag = $this->_serializeArray($tag['content'], $tag['qname'], $tag['attributes']);
} elseif (is_object($tag['content'])) {
$tag = $this->_serializeObject($tag['content'], $tag['qname'], $tag['attributes']);
} elseif (is_resource($tag['content'])) {
settype($tag['content'], 'string');
if ($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC]) {
if ($replaceEntities === true) {
$tag['content'] = call_user_func($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC], $tag['content']);
}
$tag['attributes'] = array_map($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC], $tag['attributes']);
}
$tag = XML_Util::createTagFromArray($tag, $replaceEntities);
}
return $tag;
}
示例7: _createXMLTag
/**
* create a tag from an array
* this method awaits an array in the following format
* array(
* 'qname' => $tagName,
* 'attributes' => array(),
* 'content' => $content, // optional
* 'namespace' => $namespace // optional
* 'namespaceUri' => $namespaceUri // optional
* )
*
* @access private
* @param array $tag tag definition
* @param boolean $replaceEntities whether to replace XML entities in content or not
* @return string $string XML tag
*/
function _createXMLTag($tag, $firstCall = true)
{
// build fully qualified tag name
if ($this->options[XML_SERIALIZER_OPTION_NAMESPACE] !== null) {
if (is_array($this->options[XML_SERIALIZER_OPTION_NAMESPACE])) {
$tag['qname'] = $this->options[XML_SERIALIZER_OPTION_NAMESPACE][0] . ':' . $tag['qname'];
} else {
$tag['qname'] = $this->options[XML_SERIALIZER_OPTION_NAMESPACE] . ':' . $tag['qname'];
}
}
// attribute indentation
if ($this->options[XML_SERIALIZER_OPTION_INDENT_ATTRIBUTES] !== false) {
$multiline = true;
$indent = str_repeat($this->options[XML_SERIALIZER_OPTION_INDENT], $this->_tagDepth);
if ($this->options[XML_SERIALIZER_OPTION_INDENT_ATTRIBUTES] == '_auto') {
$indent .= str_repeat(' ', strlen($tag['qname']) + 2);
} else {
$indent .= $this->options[XML_SERIALIZER_OPTION_INDENT_ATTRIBUTES];
}
} else {
$multiline = false;
$indent = false;
}
if (is_array($tag['content'])) {
if (empty($tag['content'])) {
$tag['content'] = '';
}
} elseif (is_scalar($tag['content']) && (string) $tag['content'] == '') {
$tag['content'] = '';
}
// replace XML entities (only needed, if this is not a nested call)
if ($firstCall === true) {
if ($this->options[XML_SERIALIZER_OPTION_CDATA_SECTIONS] === true) {
$replaceEntities = XML_UTIL_CDATA_SECTION;
} else {
$replaceEntities = $this->options[XML_SERIALIZER_OPTION_ENTITIES];
}
} else {
$replaceEntities = XML_SERIALIZER_ENTITIES_NONE;
}
if (is_scalar($tag['content']) || is_null($tag['content'])) {
if ($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC]) {
if ($firstCall === true) {
$tag['content'] = call_user_func($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC], $tag['content']);
}
$tag['attributes'] = array_map($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC], $tag['attributes']);
}
$tag = XML_Util::createTagFromArray($tag, $replaceEntities, $multiline, $indent, $this->options[XML_SERIALIZER_OPTION_LINEBREAKS]);
} elseif (is_array($tag['content'])) {
$tag = $this->_serializeArray($tag['content'], $tag['qname'], $tag['attributes']);
} elseif (is_object($tag['content'])) {
$tag = $this->_serializeObject($tag['content'], $tag['qname'], $tag['attributes']);
} elseif (is_resource($tag['content'])) {
settype($tag['content'], 'string');
if ($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC]) {
if ($replaceEntities === true) {
$tag['content'] = call_user_func($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC], $tag['content']);
}
$tag['attributes'] = array_map($this->options[XML_SERIALIZER_OPTION_ENCODE_FUNC], $tag['attributes']);
}
$tag = XML_Util::createTagFromArray($tag, $replaceEntities);
}
return $tag;
}
示例8: _saveData
/**
* Serialize and save the updated tranlation data to the XML file
*
* @return boolean | PEAR_Error
* @access private
* @see Translation2_Admin_Container_xml::_scheduleSaving()
*/
function _saveData()
{
if ($this->options['save_on_shutdown']) {
$data =& $this->_data;
} else {
$data = $this->_data;
}
$this->_convertEncodings('to_xml', $data);
$this->_convertLangEncodings('to_xml', $data);
// Serializing
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" . "<!DOCTYPE translation2 [\n" . TRANSLATION2_DTD . "]>\n\n" . "<translation2>\n" . " <languages>\n";
foreach ($data['languages'] as $lang => $spec) {
extract($spec);
$xml .= " <lang id=\"{$lang}\">\n" . " <name>" . ($name ? ' ' . XML_Util::replaceEntities($name) . ' ' : '') . "</name>\n" . " <meta>" . ($meta ? ' ' . XML_Util::replaceEntities($meta) . ' ' : "") . "</meta>\n" . " <error_text>" . ($error_text ? ' ' . XML_Util::replaceEntities($error_text) . ' ' : "") . "</error_text>\n" . " <encoding>" . ($encoding ? " {$encoding} " : "") . "</encoding>\n" . " </lang>\n";
}
$xml .= " </languages>\n" . " <pages>\n";
foreach ($data['pages'] as $page => $strings) {
$xml .= " <page key=\"" . XML_Util::replaceEntities($page) . "\">\n";
foreach ($strings as $str_id => $translations) {
$xml .= " <string key=\"" . XML_Util::replaceEntities($str_id) . "\">\n";
foreach ($translations as $lang => $str) {
$xml .= " <tr lang=\"{$lang}\"> " . XML_Util::replaceEntities($str) . " </tr>\n";
}
$xml .= " </string>\n";
}
$xml .= " </page>\n";
}
$xml .= " </pages>\n" . "</translation2>\n";
unset($data);
// Saving
if (!($f = fopen($this->_filename, 'w'))) {
return $this->raiseError(sprintf('Unable to open the XML file ("%s") for writing', $this->_filename), TRANSLATION2_ERROR_CANNOT_WRITE_FILE, PEAR_ERROR_TRIGGER, E_USER_ERROR);
}
@flock($f, LOCK_EX);
fwrite($f, $xml);
//@flock($f, LOCK_UN);
fclose($f);
return true;
}
示例9: CreateNode
function CreateNode($NodeName, $NodeValue)
{
require_once 'XML/Util.php';
$xml = new XML_Util();
$node = "<" . $NodeName . ">" . $xml->replaceEntities($NodeValue) . "</" . $NodeName . ">";
return $node;
}
示例10: baz_afficher_flux_RSS
/** 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']) {
//.........这里部分代码省略.........
示例11: _createXMLTag
/**
* create a tag from an array
* this method awaits an array in the following format
* array(
* "qname" => $tagName,
* "attributes" => array(),
* "content" => $content, // optional
* "namespace" => $namespace // optional
* "namespaceUri" => $namespaceUri // optional
* )
*
* @access private
* @param array $tag tag definition
* @param boolean $replaceEntities whether to replace XML entities in content or not
* @return string $string XML tag
*/
function _createXMLTag($tag, $replaceEntities = true)
{
if ($this->options["indentAttributes"] !== false) {
$multiline = true;
$indent = str_repeat($this->options["indent"], $this->_tagDepth);
if ($this->options["indentAttributes"] == "_auto") {
$indent .= str_repeat(" ", strlen($tag["qname"]) + 2);
} else {
$indent .= $this->options["indentAttributes"];
}
} else {
$multiline = false;
$indent = false;
}
if (is_array($tag["content"])) {
if (empty($tag["content"])) {
$tag["content"] = '';
}
} elseif (is_scalar($tag["content"]) && (string) $tag["content"] == '') {
$tag["content"] = '';
}
if (is_scalar($tag["content"]) || is_null($tag["content"])) {
$tag = XML_Util::createTagFromArray($tag, $replaceEntities, $multiline, $indent, $this->options["linebreak"]);
} elseif (is_array($tag["content"])) {
$tag = $this->_serializeArray($tag["content"], $tag["qname"], $tag["attributes"]);
} elseif (is_object($tag["content"])) {
$tag = $this->_serializeObject($tag["content"], $tag["qname"], $tag["attributes"]);
} elseif (is_resource($tag["content"])) {
settype($tag["content"], "string");
$tag = XML_Util::createTagFromArray($tag, $replaceEntities);
}
return $tag;
}
示例12: generateExportData
public static function generateExportData($parameters)
{
$exportProperties = $aliases = $sid = null;
extract($parameters);
$listingInfo = SJB_ListingManager::getListingInfoBySID($sid);
$listingInfo = $aliases->changePropertiesInfo($listingInfo);
$exportData = array();
$i18n = SJB_I18N::getInstance();
foreach ($exportProperties as $propertyId => $value) {
if ('ApplicationSettings' == $propertyId) {
$exportData[$sid][$propertyId] = isset($listingInfo[$propertyId]['value']) ? $listingInfo[$propertyId]['value'] : null;
} else {
$fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($propertyId);
if (!empty($fieldInfo['type']) && $fieldInfo['type'] == 'complex' && isset($listingInfo[$propertyId])) {
$complexFields = $listingInfo[$propertyId];
if (is_string($listingInfo[$propertyId])) {
$complexFields = unserialize($complexFields);
}
if (is_array($complexFields)) {
$fieldsInfo = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($fieldInfo['sid']);
foreach ($fieldsInfo as $key => $info) {
$fieldsInfo[$info['id']] = $info;
unset($fieldsInfo[$key]);
}
$domDocument = new DOMDocument();
$rootElement = $domDocument->createElement($propertyId . 's');
$domDocument->appendChild($rootElement);
$propertyElements = array();
$createPropertyElements = true;
foreach ($complexFields as $fieldName => $fieldValue) {
$fieldInfo = isset($fieldsInfo[$fieldName]) ? $fieldsInfo[$fieldName] : array();
foreach ($fieldValue as $key => $value) {
if (isset($fieldInfo['type']) && $fieldInfo['type'] == 'complexfile' && $value != '') {
$fileName = SJB_UploadFileManager::getUploadedSavedFileName($value);
$value = $fileName ? 'files/' . $fileName : '';
} elseif (isset($fieldInfo['type']) && $fieldInfo['type'] == 'date' && $value != '') {
$value = $i18n->getDate($value);
}
if ($createPropertyElements) {
$propertyElement = $domDocument->createElement($propertyId);
$rootElement->appendChild($propertyElement);
$propertyElements[$key] = $propertyElement;
}
$fieldElement = $domDocument->createElement($fieldName);
$propertyElements[$key]->appendChild($fieldElement);
$valElement = $domDocument->createTextNode(XML_Util::replaceEntities($value));
$fieldElement->appendChild($valElement);
}
$createPropertyElements = false;
}
$exportData[$sid][$propertyId] = $domDocument->saveXML();
} else {
$exportData[$sid][$propertyId] = null;
}
} else {
$exportData[$sid][$propertyId] = isset($listingInfo[$propertyId]) ? $listingInfo[$propertyId] : null;
}
}
}
self::changeTreeProperties($exportProperties, $exportData);
self::changeMonetaryProperties($exportProperties, $exportData);
self::changeListProperties($exportProperties, $exportData);
self::changePicturesProperties($exportProperties, $exportData);
self::changeFileProperties($exportProperties, $exportData, 'file');
self::changeFileProperties($exportProperties, $exportData, 'video');
self::changeComplexFileProperties($exportProperties, $exportData, 'complexfile');
self::changeLocationProperties($exportProperties, $exportData);
return $exportData[$sid];
}
示例13: serialize
/**
* Serialize the element.
*
* @access public
* @return string string representation of the element and all of its childNodes
*/
public function serialize()
{
if (empty($this->_ns) || $this->knownElement === false) {
$el = $this->elementName;
} else {
$el = sprintf('%s:%s', $this->_ns, $this->elementName);
}
if (!$this->hasChildren()) {
if ($this->cdata !== null) {
$content = $this->cdata;
if ($this->replaceEntities) {
$content = XML_Util::replaceEntities($content);
}
}
} else {
$content = '';
$rit = new RecursiveIteratorIterator($this, RIT_SELF_FIRST);
while ($rit->getSubIterator()->valid()) {
$content .= $rit->getSubIterator()->current()->serialize();
$rit->getSubIterator()->next();
}
}
if ($this->isRoot) {
$nsUri = 'http://www.macromedia.com/2003/mxml';
} else {
$nsUri = null;
}
return XML_Util::createTag($el, $this->attributes, $content, $nsUri, false);
}
示例14: createTagFromArray
/**
* create a tag from an array
* this method awaits an array in the following format
* <pre>
* array(
* "qname" => $qname // qualified name of the tag
* "namespace" => $namespace // namespace prefix (optional, if qname is specified or no namespace)
* "localpart" => $localpart, // local part of the tagname (optional, if qname is specified)
* "attributes" => array(), // array containing all attributes (optional)
* "content" => $content, // tag content (optional)
* "namespaceUri" => $namespaceUri // namespaceUri for the given namespace (optional)
* )
* </pre>
*
* <code>
* require_once 'XML/Util.php';
*
* $tag = array(
* "qname" => "foo:bar",
* "namespaceUri" => "http://foo.com",
* "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
* "content" => "I'm inside the tag",
* );
* // creating a tag with qualified name and namespaceUri
* $string = PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray($tag);
* </code>
*
* @access public
* @static
* @param array $tag tag definition
* @param integer $replaceEntities whether to replace XML special chars in content, embedd it in a CData section or none of both
* @param boolean $multiline whether to create a multiline tag where each attribute gets written to a single line
* @param string $indent string used to indent attributes (_auto indents attributes so they start at the same column)
* @param string $linebreak string used for linebreaks
* @return string $string XML tag
* @see PEAR_PackageFile_Generator_v2_XML_Util::createTag()
* @uses XML_Util::attributesToString() to serialize the attributes of the tag
* @uses XML_Util::splitQualifiedName() to get local part and namespace of a qualified name
*/
function createTagFromArray($tag, $replaceEntities = PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES, $multiline = false, $indent = "_auto", $linebreak = "\n", $encoding = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML)
{
if (isset($tag["content"]) && !is_scalar($tag["content"])) {
return XML_Util::raiseError("Supplied non-scalar value as tag content", PEAR_PackageFile_Generator_v2_XML_Util_ERROR_NON_SCALAR_CONTENT);
}
if (!isset($tag['qname']) && !isset($tag['localPart'])) {
return XML_Util::raiseError('You must either supply a qualified name (qname) or local tag name (localPart).', PEAR_PackageFile_Generator_v2_XML_Util_ERROR_NO_TAG_NAME);
}
// if no attributes hav been set, use empty attributes
if (!isset($tag["attributes"]) || !is_array($tag["attributes"])) {
$tag["attributes"] = array();
}
// qualified name is not given
if (!isset($tag["qname"])) {
// check for namespace
if (isset($tag["namespace"]) && !empty($tag["namespace"])) {
$tag["qname"] = $tag["namespace"] . ":" . $tag["localPart"];
} else {
$tag["qname"] = $tag["localPart"];
}
// namespace URI is set, but no namespace
} elseif (isset($tag["namespaceUri"]) && !isset($tag["namespace"])) {
$parts = XML_Util::splitQualifiedName($tag["qname"]);
$tag["localPart"] = $parts["localPart"];
if (isset($parts["namespace"])) {
$tag["namespace"] = $parts["namespace"];
}
}
if (isset($tag["namespaceUri"]) && !empty($tag["namespaceUri"])) {
// is a namespace given
if (isset($tag["namespace"]) && !empty($tag["namespace"])) {
$tag["attributes"]["xmlns:" . $tag["namespace"]] = $tag["namespaceUri"];
} else {
// define this Uri as the default namespace
$tag["attributes"]["xmlns"] = $tag["namespaceUri"];
}
}
// check for multiline attributes
if ($multiline === true) {
if ($indent === "_auto") {
$indent = str_repeat(" ", strlen($tag["qname"]) + 2);
}
}
// create attribute list
$attList = XML_Util::attributesToString($tag["attributes"], true, $multiline, $indent, $linebreak);
if (!isset($tag["content"]) || (string) $tag["content"] == '') {
$tag = sprintf("<%s%s />", $tag["qname"], $attList);
} else {
if ($replaceEntities == PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES) {
$tag["content"] = PEAR_PackageFile_Generator_v2_XML_Util::replaceEntities($tag["content"], $encoding);
} elseif ($replaceEntities == PEAR_PackageFile_Generator_v2_XML_Util_CDATA_SECTION) {
$tag["content"] = XML_Util::createCDataSection($tag["content"]);
}
$tag = sprintf("<%s%s>%s</%s>", $tag["qname"], $attList, $tag["content"], $tag["qname"]);
}
return $tag;
}
示例15: array
echo 'assets url ' . $assets_url;
echo PHP_EOL;
$data = array('foo' => 'bar', 'baz' => 'boom', 'cow' => 'milk', 'php' => 'hypertext processor');
echo http_build_query($data) . "\n";
echo http_build_query($data, '', '&');
echo PHP_EOL;
echo nl2br("Welcome\r\nThis is my HTML document", false);
//lets look at some pear
echo PHP_EOL;
//C:\php\pear\docs\XML_Util\examples\example.php
require_once 'XML/Util.php';
/**
* 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";
$modes = mcrypt_list_modes();
echo "mcrypt_list_modes <br>\n";
echo print_r_xml($modes);
//F:\bit5411\php\PEAR\OS\Guess.php class OS_Guess
require_once 'OS/Guess.php';
$phpwhat = new OS_Guess();
//$phpwhat = OS_Guess::getSignature(); //fatal this
$tmp = $phpwhat->getSignature();
echo $tmp;
echo PHP_EOL;
$tmp = $phpwhat->getSysname();
echo $tmp;
echo PHP_EOL;
$tmp = $phpwhat->getNodename();