本文整理汇总了PHP中XML_Util::reverseEntities方法的典型用法代码示例。如果您正苦于以下问题:PHP XML_Util::reverseEntities方法的具体用法?PHP XML_Util::reverseEntities怎么用?PHP XML_Util::reverseEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML_Util
的用法示例。
在下文中一共展示了XML_Util::reverseEntities方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error_reporting
* @subpackage examples
* @category XML
*/
error_reporting(E_ALL);
require_once 'XML/Util.php';
/**
* replacing XML entities
*/
print "replace XML entities:<br>\n";
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 < & >.");
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'));
示例2: execute
public function execute()
{
ini_set('max_execution_time', 0);
$tp = SJB_System::getTemplateProcessor();
$file_info = isset($_FILES['import_file']) ? $_FILES['import_file'] : null;
$encodingFromCharset = SJB_Request::getVar('encodingFromCharset', 'UTF-8');
$listingTypeID = SJB_Request::getVar('listing_type_id', null);
$productSID = SJB_Request::getVar('product_sid', 0);
$errors = array();
if ($listingTypeID && $productSID) {
$acl = SJB_Acl::getInstance();
$resource = 'post_' . strtolower($listingTypeID);
if (!$acl->isAllowed($resource, $productSID, 'product')) {
$errors[] = 'You cannot import listings of this type under the selected product';
}
}
if (!empty($file_info)) {
$extension = SJB_Request::getVar('file_type');
if (!SJB_ImportFile::isValidFileExtensionByFormat($extension, $file_info)) {
$errors['DO_NOT_MATCH_SELECTED_FILE_FORMAT'] = true;
}
}
if (empty($file_info) || $file_info['error'] || $errors) {
if (isset($file_info['error']) && $file_info['error'] > 0) {
$errors[SJB_UploadFileManager::getErrorId($file_info['error'])] = 1;
}
$listing_types = SJB_ListingTypeManager::getAllListingTypesInfo();
$products = SJB_ProductsManager::getProductsByProductType('post_listings');
$tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
$tp->assign('listing_types', $listing_types);
$tp->assign('products', $products);
$tp->assign('errors', $errors);
$tp->assign('charSets', SJB_HelperFunctions::getCharSets());
$tp->display('import_listings.tpl');
} else {
$i18n = SJB_I18N::getInstance();
$csv_delimiter = SJB_Request::getVar('csv_delimiter', null);
$activeStatus = SJB_Request::getVar('active', 0);
$activationDate = SJB_Request::getVar('activation_date', date('Y-m-d'));
$activationDate = $i18n->getInput('date', $activationDate);
$non_existed_values_flag = SJB_Request::getVar('non_existed_values', null);
$productInfo = SJB_ProductsManager::getProductInfoBySID($productSID);
if (empty($productInfo['listing_duration'])) {
$expirationDate = '';
} else {
$timestamp = strtotime($activationDate . ' + ' . $productInfo['listing_duration'] . ' days');
$expirationDate = $i18n->getDate(date('Y-m-d', $timestamp));
}
$extension = $_REQUEST['file_type'];
if ($extension == 'xls') {
$import_file = new SJB_ImportFileXLS($file_info);
} elseif ($extension == 'csv') {
$import_file = new SJB_ImportFileCSV($file_info, $csv_delimiter);
}
$import_file->parse($encodingFromCharset);
$listing = $this->CreateListing(array(), $listingTypeID);
$imported_data = $import_file->getData();
$isFileImported = true;
$count = 0;
$addedListingsSids = array();
$nonExistentUsers = array();
foreach ($imported_data as $key => $importedColumn) {
if ($key == 1) {
$imported_data_processor = new SJB_ImportedDataProcessor($importedColumn, $listing);
continue;
}
if (!$importedColumn) {
continue;
}
$count++;
$listingInfo = $imported_data_processor->getData($non_existed_values_flag, $importedColumn);
$doc = new DOMDocument();
foreach ($listing->getProperties() as $property) {
if ($property->getType() == 'complex' && !empty($listingInfo[$property->id])) {
$childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
$doc->loadXML($listingInfo[$property->id]);
$results = $doc->getElementsByTagName($property->id . 's');
$listingInfo[$property->id] = array();
foreach ($results as $complexparent) {
$i = 1;
foreach ($complexparent->getElementsByTagName($property->id) as $result) {
$resultXML = simplexml_import_dom($result);
foreach ($childFields as $childField) {
if (isset($resultXML->{$childField}['id'])) {
$listingInfo[$property->id][$childField['id']][$i] = XML_Util::reverseEntities((string) $resultXML->{$childField}['id']);
}
}
$i++;
}
}
} elseif ($property->getType() == 'monetary' && !empty($listingInfo[$property->id])) {
$value = $listingInfo[$property->id];
$listingInfo[$property->id] = array();
$listingInfo[$property->id]['value'] = $value;
$defaultCurrency = SJB_CurrencyManager::getDefaultCurrency();
$currencyCode = !empty($listingInfo[$property->id . "Currency"]) ? $listingInfo[$property->id . "Currency"] : $defaultCurrency['currency_code'];
$currency = SJB_CurrencyManager::getCurrencyByCurrCode($currencyCode);
$listingInfo[$property->id]['add_parameter'] = !empty($currency['sid']) ? $currency['sid'] : '';
if (isset($listingInfo[$property->id . "Currency"])) {
unset($listingInfo[$property->id . "Currency"]);
//.........这里部分代码省略.........