本文整理汇总了PHP中formatXmlString函数的典型用法代码示例。如果您正苦于以下问题:PHP formatXmlString函数的具体用法?PHP formatXmlString怎么用?PHP formatXmlString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatXmlString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pestle_cli
/**
* Generates bin/magento command files
* This command generates the necessary files and configuration
* for a new command for Magento 2's bin/magento command line program.
*
* pestle.phar Pulsestorm_Generate Example
*
* Creates
* app/code/Pulsestorm/Generate/Command/Example.php
* app/code/Pulsestorm/Generate/etc/di.xml
*
* @command generate_command
* @argument module_name In which module? [Pulsestorm_Helloworld]
* @argument command_name Command Name? [Testbed]
*/
function pestle_cli($argv)
{
$module_info = getModuleInformation($argv['module_name']);
$namespace = $module_info->vendor;
$module_name = $module_info->name;
$module_shortname = $module_info->short_name;
$module_dir = $module_info->folder;
$command_name = $argv['command_name'];
// $command_name = input("Command Name?", 'Testbed');
output($module_dir);
createPhpClass($module_dir, $namespace, $module_shortname, $command_name);
$path_di_xml = createDiIfNeeded($module_dir);
$xml_di = simplexml_load_file($path_di_xml);
//get commandlist node
$nodes = $xml_di->xpath('/config/type[@name="Magento\\Framework\\Console\\CommandList"]');
$xml_type_commandlist = array_shift($nodes);
if (!$xml_type_commandlist) {
throw new Exception("Could not find CommandList node");
}
$argument = simpleXmlAddNodesXpath($xml_type_commandlist, '/arguments/argument[@name=commands,@xsi:type=array]');
$full_class = $namespace . '\\' . $module_shortname . '\\Command\\' . $command_name;
$item_name = str_replace('\\', '_', strToLower($full_class));
$item = $argument->addChild('item', $full_class);
$item->addAttribute('name', $item_name);
$item->addAttribute('xsi:type', 'object', 'http://www.w3.org/2001/XMLSchema-instance');
$xml_di = formatXmlString($xml_di->asXml());
writeStringToFile($path_di_xml, $xml_di);
}
示例2: pestle_cli
/**
* Creates a Route XML
* generate_route module area id
* @command generate_route
*/
function pestle_cli($argv)
{
$module_info = askForModuleAndReturnInfo($argv);
$module = $module_info->name;
$legend = ['frontend' => 'standard', 'adminhtml' => 'admin'];
$areas = array_keys($legend);
$area = inputOrIndex('Which area? [frontend, adminhtml]', 'frontend', $argv, 1);
$router_id = $legend[$area];
if (!in_array($area, $areas)) {
throw new Exception("Invalid areas");
}
$frontname = inputOrIndex('Frontname/Route ID?', null, $argv, 2);
$route_id = $frontname;
$path = $module_info->folder . '/etc/' . $area . '/routes.xml';
if (!file_exists($path)) {
$xml = simplexml_load_string(getBlankXml('routes'));
writeStringToFile($path, $xml->asXml());
}
$xml = simplexml_load_file($path);
simpleXmlAddNodesXpath($xml, "router[@id={$router_id}]/" . "route[@id={$route_id},@frontName={$frontname}]/" . "module[@name={$module}]");
writeStringToFile($path, formatXmlString($xml->asXml()));
$class = str_replace('_', '\\', $module) . '\\Controller\\Index\\Index';
$controllerClass = createControllerClass($class, $area);
$path_controller = getPathFromClass($class);
writeStringToFile($path_controller, $controllerClass);
output($path);
output($path_controller);
}
示例3: lsf_xml_save
function lsf_xml_save($doc)
{
// Save XML data to file
$xml = $doc->saveXML();
$file_handle = fopen('data/raumplan.xml', 'w');
fwrite($file_handle, formatXmlString($xml));
fclose($file_handle);
}
示例4: createViewXmlFile
function createViewXmlFile($base_folder, $package, $theme, $area)
{
$path = $base_folder . '/etc/view.xml';
$xml = simplexml_load_string(getBlankXml('view'));
$media = simpleXmlAddNodesXpath($xml, 'media');
output("Creating: {$path}");
writeStringToFile($path, formatXmlString($xml->asXml()));
}
示例5: generateDiConfiguration
function generateDiConfiguration($argv)
{
$moduleInfo = getModuleInformation($argv['module']);
$pathAndXml = loadOrCreateDiXml($moduleInfo);
$path = $pathAndXml['path'];
$di_xml = $pathAndXml['xml'];
$preference = $di_xml->addChild('preference');
$preference['for'] = $argv['for'];
$preference['type'] = $argv['type'];
writeStringToFile($path, formatXmlString($di_xml->asXml()));
}
示例6: pestle_cli
/**
* Generates a Magento 2.1 ui grid listing and support classes.
*
* @command magento2:generate:ui:add-column-sections
* @argument listing_file Which Listing File? []
* @argument column_name Column Name? [ids]
* @argument index_field Index Field/Primary Key? [entity_id]
*/
function pestle_cli($argv)
{
$xml = simplexml_load_file($argv['listing_file']);
validateAsListing($xml);
$columns = getOrCreateColumnsNode($xml);
$sectionsColumn = $columns->addChild('selectionsColumn');
$sectionsColumn->addAttribute('name', $argv['column_name']);
$argument = addArgument($sectionsColumn, 'data', 'array');
$configItem = addItem($argument, 'config', 'array');
$indexField = addItem($configItem, 'indexField', 'string', $argv['index_field']);
writeStringToFile($argv['listing_file'], formatXmlString($xml->asXml()));
}
示例7: createRoutesXmlFile
function createRoutesXmlFile($module_info, $area, $frontname, $router_id, $route_id)
{
$module = $module_info->name;
$path = $module_info->folder . '/etc/' . $area . '/routes.xml';
if (!file_exists($path)) {
$xml = simplexml_load_string(getBlankXml('routes'));
writeStringToFile($path, $xml->asXml());
}
$xml = simplexml_load_file($path);
simpleXmlAddNodesXpath($xml, "router[@id={$router_id}]/" . "route[@id={$route_id},@frontName={$frontname}]/" . "module[@name={$module}]");
writeStringToFile($path, formatXmlString($xml->asXml()));
output($path);
return $xml;
}
示例8: pestle_cli
/**
* One Line Description
*
* @command generate_acl
* @argument module_name Which Module? [Pulsestorm_HelloWorld]
* @argument rule_ids Rule IDs? [<$module_name$>::top,<$module_name$>::config,]
*/
function pestle_cli($argv)
{
extract($argv);
$rule_ids = explode(',', $rule_ids);
$rule_ids = array_filter($rule_ids);
$xml = simplexml_load_string(getBlankXml('acl'));
$nodes = $xml->xpath('//resource[@id="Magento_Backend::admin"]');
$node = array_shift($nodes);
foreach ($rule_ids as $id) {
$id = trim($id);
$node = $node->addChild('resource');
$node->addAttribute('id', $id);
$node->addAttribute('title', 'TITLE HERE FOR ' . $id);
}
$path = getBaseModuleDir($module_name) . '/etc/acl.xml';
writeStringToFile($path, formatXmlString($xml->asXml()));
output("Created {$path}");
}
示例9: backupOldCode
function backupOldCode($arguments, $options)
{
$xmls = [];
$frontend_models = getFrontendModelNodesFromMagento1SystemXml($xmls);
foreach ($frontend_models as $file => $nodes) {
$new_file = str_replace(['/Users/alanstorm/Sites/magento-1-9-2-2.dev', '/local'], '', $file);
$new_file = getBaseMagentoDir() . str_replace('/etc/', '/etc/adminhtml/', $new_file);
$xml = simplexml_load_file($new_file);
foreach ($nodes as $node) {
list($path, $frontend_alias) = explode('::', $node);
list($section, $group, $field) = explode('/', $path);
$node = getSectionXmlNodeFromSectionGroupAndField($xml, $section, $group, $field);
if ($node->frontend_model) {
output("The frontend_model node already exists: " . $path);
continue;
}
$class = convertAliasToClass($frontend_alias);
$node->frontend_model = $class;
}
file_put_contents($new_file, formatXmlString($xml->asXml()));
}
//search XML files
// $base = getBaseMagentoDir();
// $files = `find $base -name '*.xml'`;
// $files = preg_split('%[\r\n]%', $files);
// $files = array_filter($files, function($file){
// return strpos($file, '/view/') !== false &&
// !is_dir($file);
// });
//
// $report;
// foreach($files as $file)
// {
// $xml = simplexml_load_file($file);
// if(!$xml->head){ continue; }
// output($file);
// foreach($xml->head->children() as $node)
// {
// output(' ' . $node->getName());
// }
// }
}
示例10: download_specific_timetable
function download_specific_timetable($place_origin, $name_origin, $place_destination, $type_destination, $filepath)
{
$xml_string = getUnfilteredWebData($place_origin, $name_origin, $place_destination, $type_destination);
$xml_string_array = cut_xml_per_route($xml_string);
$timetable_dom = new DomDocument('1.0');
$rootNode = $timetable_dom->createElement('fahrplan');
$timetable_dom->appendChild($rootNode);
$rootNode->setAttribute("datum", date("H:i - d.m.y"));
foreach ($xml_string_array as $xml_string) {
$dom = new domDocument();
@$dom->loadHTML($xml_string);
$dom->preserveWhiteSpace = false;
$transport_type_array = get_transport_type_array($dom);
$time_array = get_time_array($dom);
$station_array = get_station_array($dom);
$rootNode->setAttribute("start", $station_array[0]);
$rootNode->setAttribute("stop", $station_array[sizeof($station_array) - 1]);
$rootNode->appendChild(create_route_node($timetable_dom, $station_array, $transport_type_array, $time_array));
}
$xml_timetable = $timetable_dom->saveXML();
$file_handle = fopen($filepath, 'w');
fwrite($file_handle, formatXmlString($xml_timetable));
fclose($file_handle);
}
示例11: str_replace
$formattedResults = str_replace('<DIV>', '', $formattedResults);
$formattedResults = str_replace('<pre>', '', $formattedResults);
$formattedResults = str_replace('</pre>', '', $formattedResults);
$formattedResults = str_replace('</div>', "\n", $formattedResults);
$formattedResults = str_replace('</DIV>', "\n", $formattedResults);
$formattedResults = str_replace(' ', " ", $formattedResults);
$formattedResults = str_replace('', " ", $formattedResults);
$sysout .= $clientName . "\n" . $formattedResults . "\n\n";
}
$xml->addAttribute('errors', $errors);
$xml->addAttribute('tests', $tests);
$xml->addAttribute('failures', $failures);
$xml->addChild('system-out')->addCData($sysout);
$userAgentName = $useragent['name'];
echo '<strong>' . $userAgentName . '</strong> finished';
echo "<pre>" . htmlentities(formatXmlString($xml->asXML())) . "</pre>";
if ($_REQUEST['output'] == "file") {
$fileName = "{$outputDir}/{$userAgentName}.xml";
$fileName = preg_replace('/\\s+/', '_', $fileName);
$xml->asXML($fileName);
echo " and file writen to " . $fileName;
//$root->asXML("/tmp/testswarm/job-$jobId-".date('Ymd-His').".xml");
}
echo "<br/>";
}
}
echo 'finished';
//==============================================================================
// helper
//==============================================================================
class SimpleXMLExtended extends SimpleXMLElement
示例12: formatOutput
function formatOutput($input, $_level_key_name)
{
$pattern = array('/\\<\\?xml.*\\?\\>/', '/\\<__rootnode .*\\">|\\<\\/__rootnode\\>/', "/ {$_level_key_name}=\".*?\"/");
$output = preg_replace($pattern, '', $input);
$pattern = array('/\\s*>/', '/^ /', '/\\n /');
$replacement = array('>', '', "\n");
$char_list = "\t\n\r\v";
$output = trim($output, $char_list);
$output = preg_replace($pattern, $replacement, $output);
$output = formatXmlString($output);
$output = preg_replace('/_#_void_value_#_/', '', $output);
return $output;
}
示例13: XMLsave
/**
* save XML to file
*
* @since 2.0
*
* @param object $xml simple xml object to save to file via asXml
* @param string $file Filename that it will be saved as
* @return bool
*/
function XMLsave($xml, $file)
{
if (!is_object($xml)) {
debugLog(__FUNCTION__ . ' failed to save xml');
return false;
}
$data = @$xml->asXML();
if (getDef('GSFORMATXML', true)) {
$data = formatXmlString($data);
}
// format xml if config setting says so
$data = exec_filter('xmlsave', $data);
// @filter xmlsave executed before writing string to file
$success = save_file($file, $data);
// LOCK_EX ?
return $success;
}
示例14: container
}
echo container('Edit Templates', '<table class="page rowHover">
<thead>
<tr class="ui-widget-header">
<td width="80%">Template</td>
<td width="20%">Actions</td>
</tr>
</thead>
<tbody>
' . $rows . '
</tbody>
</table>');
break;
case 'edit':
$template = $json[$request['templateName']];
$template = str_replace(array('<', '>'), array('<', '>'), formatXmlString($template));
$template = preg_replace('/template\\.([A-Z])/e', '"template." . lcfirst($1)', $template);
echo container("Edit Template \"{$request['templateName']}\"", "<form action=\"./moderate.php?do=templates&do2=edit2&templateName={$request['templateName']}\" method=\"post\">\n\n <label for=\"data\">New Value:</label><br />\n <textarea name=\"data\" id=\"textXml\" style=\"width: 100%; height: 300px;\">{$template}</textarea><br /><br />\n\n <button type=\"submit\">Update</button>\n</form>");
break;
case 'edit2':
$template = $request['data'];
$template = str_replace(array("\r", "\n", "\r\n"), '', $template);
// Remove new lines (required for JSON).
$template = preg_replace("/\\>(\\ +)/", ">", $template);
// Remove extra space between (looks better).
$json[$request['templateName']] = $template;
// Update the JSON object with the new template data.
file_put_contents('client/data/templates.json', json_encode($json)) or die('Unable to write');
// Send the new JSON data to the server.
$database->modLog('templateEdit', $template['templateName'] . '-' . $template['interfaceId']);
$database->fullLog('templateEdit', array('template' => $template));
示例15: trim
for ($i = 0; $i < $size_m - 1; $i++) {
$pattern = trim($match[0][$i]);
$copy_cf = str_replace($pattern, "", $copy_cf);
}
$pattern = trim($match[0][$size_m - 1]);
$copy_cf = str_replace($pattern, $unique_id, $copy_cf);
} else {
if (preg_match("/<\\s*ossec_config\\s*>/", $copy_cf)) {
$copy_cf = preg_replace("/<\\/\\s*ossec_config\\s*>/", "{$unique_id}</ossec_config>", $copy_cf, 1);
} else {
$copy_cf = "<ossec_config>{$unique_id}</ossec_config>";
}
}
$agentless_xml = implode("", $agentless_xml);
$copy_cf = preg_replace("/{$unique_id}/", $agentless_xml, $copy_cf);
$output = formatXmlString($copy_cf);
if (@file_put_contents($path, $output, LOCK_EX) === false) {
@unlink($path);
@copy($path_tmp, $path);
$info_error = _("Failure to update") . " <b>{$ossec_conf}</b>";
} else {
$result = test_conf();
if ($result !== true) {
$info_error = "<div class='errors_ossec'>{$result}</div>";
$error_conf = true;
@copy($path_tmp, $path);
@copy($path_tmp2, $path_passlist);
} else {
$result = system("sudo /var/ossec/bin/ossec-control restart > /tmp/ossec-action 2>&1");
$result = file('/tmp/ossec-control');
$size = count($result);