Esempio n. 1
0
/**
* 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);
}
Esempio n. 2
0
/**
* 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);
}
Esempio n. 3
0
/**
* Generates plugin XML
* This command generates the necessary files and configuration 
* to "plugin" to a preexisting Magento 2 object manager object. 
*
*     pestle.phar generate_plugin_xml Pulsestorm_Helloworld 'Magento\Framework\Logger\Monolog' 'Pulsestorm\Helloworld\Plugin\Magento\Framework\Logger\Monolog'
* 
* @argument module_name Create in which module? [Pulsestorm_Helloworld]
* @argument class Which class are you plugging into? [Magento\Framework\Logger\Monolog]
* @argument class_plugin What's your plugin class name? [<$module_name$>\Plugin\<$class$>]
* @command generate_plugin_xml
*/
function pestle_cli($argv)
{
    // $module_info = askForModuleAndReturnInfo($argv);
    $module_info = getModuleInformation($argv['module_name']);
    $class = $argv['class'];
    $class_plugin = $argv['class_plugin'];
    $path_di = $module_info->folder . '/etc/di.xml';
    if (!file_exists($path_di)) {
        $xml = simplexml_load_string(getBlankXml('di'));
        writeStringToFile($path_di, $xml->asXml());
        output("Created new {$path_di}");
    }
    $xml = simplexml_load_file($path_di);
    //     $plugin_name    = strToLower($module_info->name) . '_' . underscoreClass($class);
    //     simpleXmlAddNodesXpath($xml,
    //         "/type[@name=$class]/plugin[@name=$plugin_name,@type=$class_plugin]");
    $type = $xml->addChild('type');
    $type->addAttribute('name', $class);
    $plugin = $type->addChild('plugin');
    $plugin->addAttribute('name', strToLower($module_info->name) . '_' . underscoreClass($class));
    $plugin->addAttribute('type', $class_plugin);
    writeStringToFile($path_di, formatXmlString($xml->asXml()));
    output("Added nodes to {$path_di}");
    $path_plugin = getPathFromClass($class_plugin);
    $body = implode("\n", ['    //function beforeMETHOD($subject, $arg1, $arg2){}', '    //function aroundMETHOD($subject, $procede, $arg1, $arg2){return $proceed($arg1, $arg2);}', '    //function afterMETHOD($subject, $result){return $result;}']);
    $class_definition = str_replace('<$body$>', "\n{$body}\n", createClassTemplate($class_plugin));
    writeStringToFile($path_plugin, $class_definition);
    output("Created file {$path_plugin}");
}
Esempio n. 4
0
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);
}
Esempio n. 5
0
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()));
}
Esempio n. 6
0
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()));
}
Esempio n. 7
0
/**
* 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()));
}
Esempio n. 8
0
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;
}
Esempio n. 9
0
/**
* 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}");
}
Esempio n. 10
0
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());
    //     }
    // }
}
Esempio n. 11
0
/**
* 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);
    $path = getBaseModuleDir($module_name) . '/etc/acl.xml';
    if (!file_exists($path)) {
        $xml = simplexml_load_string(getBlankXml('acl'));
        writeStringToFile($path, $xml->asXml());
    }
    $xml = simplexml_load_file($path);
    $xpath = 'acl/resources/resource[@id=Magento_Backend::admin]';
    foreach ($rule_ids as $id) {
        $id = trim($id);
        $xpath .= '/resource[@id=' . $id . ',@title=TITLE HERE FOR]';
    }
    simpleXmlAddNodesXpath($xml, $xpath);
    writeStringToFile($path, formatXmlString($xml->asXml()));
    output("Created {$path}");
}
Esempio n. 12
0
/**
* Generates a Magento 2.1 ui grid listing and support classes.
*
* @command magento2:generate:ui:add-column-actions
* @argument listing_file Which Listing File? []
* @argument index_field Index Field/Primary Key? [entity_id]
*/
function pestle_cli($argv)
{
    $xml = simplexml_load_file($argv['listing_file']);
    validateAsListing($xml);
    $actionsClass = generatePageActionsClassFromListingXmlFileAndXml($argv['listing_file'], $xml);
    $columns = getOrCreateColumnsNode($xml);
    $actionsColumn = $columns->addChild('actionsColumn');
    $actionsColumn->addAttribute('name', 'actions');
    $actionsColumn->addAttribute('class', $actionsClass);
    $argument = addArgument($actionsColumn, 'data', 'array');
    $configItem = addItem($argument, 'config', 'array');
    $indexField = addItem($configItem, 'indexField', 'string', $argv['index_field']);
    output(formatXmlString($xml->asXml()));
    // <actionsColumn name="actions" class="Pulsestorm\ToDoCrud\Ui\Component\Listing\Column\Pulsestormtodolisting\PageActions">
    //     <argument name="data" xsi:type="array">
    //         <item name="config" xsi:type="array">
    //             <item name="resizeEnabled" xsi:type="boolean">false</item>
    //             <item name="resizeDefaultWidth" xsi:type="string">107</item>
    //             <item name="indexField" xsi:type="string">pulsestorm_todocrud_todoitem_id</item>
    //         </item>
    //     </argument>
    // </actionsColumn>
}
Esempio n. 13
0
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);
}
Esempio n. 14
0
            $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('&nbsp;', " ", $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
Esempio n. 15
0
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;
}
Esempio n. 16
0
/**
 * 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;
}
Esempio n. 17
0
                }
                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('&lt;', '&gt;'), 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));
Esempio n. 18
0
     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);
Esempio n. 19
0
function download_consultation_times()
{
    global $config_url_consultation_times;
    $doc = new DomDocument('1.0');
    $root = $doc->createElement('mitglieder');
    $root->setAttribute("von", "Fachbereich 3");
    $doc->appendChild($root);
    @($dom = loadNprepare($config_url_consultation_times, 'UTF-8'));
    $dom->preserveWhiteSpace = false;
    $employee_table_wrapper = $dom->getElementById('c13016');
    $table_rows = $employee_table_wrapper->getElementsByTagName('tr');
    $table_rows->item(0);
    $current_person_function = "";
    foreach ($table_rows as $table_row) {
        $person_node = $doc->createElement('person');
        $headlines = $table_row->getElementsByTagName('h3');
        if ($headlines->length > 0) {
            $current_person_function = $headlines->item(0)->textContent;
            continue;
        }
        $current_entry = trim($table_row->getElementsByTagName('td')->item(0)->textContent);
        if (strpos($current_entry, "\n") > -1) {
            $text_parts_array = explode("\n", $current_entry);
            $person_node->appendChild($doc->createElement("titel", trim($text_parts_array[1])));
            $person_node->appendChild($doc->createElement("name", $text_parts_array[0]));
        } else {
            $person_node->appendChild($doc->createElement("name", $current_entry));
        }
        $person_node->appendChild($doc->createElement("funktion", $current_person_function));
        if ($table_row->getElementsByTagName('span')->length >= 1) {
            $person_node->appendChild($doc->createElement("sprechzeiten", $table_row->getElementsByTagName('span')->item(0)->textContent));
            if ($table_row->getElementsByTagName('span')->length == 2) {
                $person_node->appendChild($doc->createElement("raum", $table_row->getElementsByTagName('span')->item(1)->textContent));
            }
        }
        $root->appendChild($person_node);
    }
    $xml = combine_person_entries($doc);
    $xml = $doc->saveXML();
    $file_handle = fopen('data/sprechzeiten.xml', 'w');
    fwrite($file_handle, formatXmlString($xml));
    fclose($file_handle);
}
Esempio n. 20
0
        }
    }
}
if (isset($data['error'])) {
    $node = $xmlDoc->createElement("error");
    $errorNode = $parentNode->appendChild($node);
    $errorNode->setAttribute("id", $data['error']);
}
// Output
// Check whether we want XML or JSON output
if ($data['format'] == "xml" || $data['format'] == "xmlp" || $data['format'] == "xmlt") {
    if ($data['format'] == "xml" || $data['format'] == "xmlp") {
        // Set the content-type for browsers
        header("Content-type: text/xml");
    }
    echo formatXmlString($xmlDoc->saveXML());
} else {
    if ($data['format'] == "json") {
        // Set the content-type for browsers
        header("Content-type: application/json");
        // For now, our JSON output is simply the XML re-parsed with SimpleXML and
        // then re-encoded with json_encode
        $x = simplexml_load_string($xmlDoc->saveXML());
        $j = json_encode($x);
        echo $j;
    } else {
        echo "Error: Unknown format type '" . $data['format'] . "'.";
    }
}
// This function tidies up the outputted XML
function formatXmlString($xml)
Esempio n. 21
0
" ><?php 
i18n('VIEW');
?>
</a>
				<a href="sitemap.php?refresh" accesskey="<?php 
echo find_accesskey(i18n_r('REFRESH'));
?>
" ><?php 
i18n('REFRESH');
?>
</a>
			</div>
					
			<div class="unformatted"><code><?php 
if (file_exists('../sitemap.xml')) {
    echo htmlentities(formatXmlString(file_get_contents('../sitemap.xml')));
}
?>
</code></div>
		
		</div>
	</div>
	
	<div id="sidebar" >
	<?php 
include 'template/sidebar-theme.php';
?>
	</div>	

</div>
<?php 
        $space = $itr_count == 0 ? '' : ' ';
        $filename_pretty .= $space . $filename_part;
        $itr_count++;
    }
    $token = new stdClass();
    $token->prettyname = $filename_pretty;
    $token->filename = $filename;
    $token_array[] = $token;
}
//Create single token xml string and add it to an array
$token_xml_string_array = array();
foreach ($token_array as $token) {
    $string = '<File path="docs/' . $token->filename . '">';
    $string .= '<Token><TokenIdentifier>';
    $string .= '//apple_ref/cpp/cl/' . $token->prettyname;
    $string .= '</TokenIdentifier></Token>';
    $string .= '</File>';
    $token_xml_string_array[] = $string;
}
//Contruct full xml string
$xml_string = '<?xml version="1.0" encoding="UTF-8"?>';
$xml_string .= '<Tokens version="1.0">';
//Insert all tokens
foreach ($token_xml_string_array as $token_string) {
    $xml_string .= $token_string;
}
$xml_string .= '</Tokens>';
$xml_string = formatXmlString($xml_string);
//Write to Tokens.xml file
$file_path = 'output/' . $config['docset_filename'] . '/Contents/Resources/Tokens.xml';
file_put_contents($file_path, $xml_string);
Esempio n. 23
0
function generateUiComponentXmlFile($gridId, $databaseIdName, $module_info)
{
    $pageActionsClassName = generatePageActionClassNameFromPackageModuleAndGridId($module_info->vendor, $module_info->short_name, $gridId);
    $requestIdName = generateRequestIdName();
    $providerClass = generateProdiverClassFromGridIdAndModuleInfo($gridId, $module_info);
    $dataSourceName = generateDataSourceNameFromGridId($gridId);
    $columnsName = generateColumnsNameFromGridId($gridId);
    $xml = simplexml_load_string(getBlankXml('uigrid'));
    $argument = generateArgumentNode($xml, $gridId, $dataSourceName, $columnsName);
    $dataSource = generateDatasourceNode($xml, $dataSourceName, $providerClass, $databaseIdName, $requestIdName);
    $columns = generateColumnsNode($xml, $columnsName, $databaseIdName, $pageActionsClassName);
    generateListingToolbar($xml);
    $path = $module_info->folder . '/view/adminhtml/ui_component/' . $gridId . '.xml';
    output("Creating New {$path}");
    writeStringToFile($path, formatXmlString($xml->asXml()));
    return $xml;
}
Esempio n. 24
0
                    <input type="submit" name="send" value="<?php 
    echo _('Invoke');
    ?>
" />
                </form>
            </div>

            <?php 
    if (!is_null($response)) {
        ?>
            <h2><?php 
        echo _('Output');
        ?>
</h2>
            <textarea rows="12" cols="100" class="well"><?php 
        echo formatXmlString($response);
        ?>
</textarea>
            <?php 
    }
    ?>

        </div>
    <?php 
}
?>

</div>

</body>
</html>
Esempio n. 25
0
" ><?php 
i18n('VIEW');
?>
</a>
				<a href="sitemap.php?refresh" accesskey="<?php 
echo find_accesskey(i18n_r('REFRESH'));
?>
" ><?php 
i18n('REFRESH');
?>
</a>
			</div>
			<div class="unformatted">
				<code><?php 
if (file_exists($sitemapfile)) {
    echo htmlentities(formatXmlString(file_get_contents($sitemapfile)));
}
?>
				</code>
			</div>
		</div>
	</div>
	<div id="sidebar" >
	<?php 
include 'template/sidebar-theme.php';
?>
	</div>

</div>
<?php 
get_template('footer');
Esempio n. 26
0
" ><?php 
i18n('REFRESH');
?>
</a>
				<?php 
exec_action(get_filename_id() . '-edit-nav');
?>
			</div>		
			<?php 
exec_action(get_filename_id() . '-body');
?>
	
			<div class="unformatted">
				<code><?php 
if (file_exists($sitemapfile)) {
    echo htmlentities(formatXmlString(read_file($sitemapfile)));
}
?>
				</code>
			</div>
		</div>
	</div>
	<div id="sidebar" >
	<?php 
include 'template/sidebar-theme.php';
?>
	</div>

</div>
<?php 
get_template('footer');
Esempio n. 27
0
        $resp = CentralData::send_all_acars();
        break;
}
?>
<h3>Response:</h3>
<pre><?php 
$response = CentralData::$xml_response;
echo htmlentities(formatXmlString($response));
?>
</pre>

<h3>Sent Data</h3>
<pre><?php 
if (CentralData::$type == 'xml') {
    $xml = CentralData::$xml->asXML();
    echo htmlentities(formatXmlString($xml));
} elseif (CentralData::$type == 'json') {
    echo '<pre>';
    print_r(CentralData::$json);
    echo '</pre>';
}
?>
</pre>
</td>
</tr>	
</table>

</body>
</html>

<?php 
Esempio n. 28
0
function gs_anonymousdata()
{
    #grab data from this installation
    if (isset($_POST['preview'])) {
        global $LANG, $TIMEZONE, $SITEURL, $live_plugins, $thisfile_anony;
        $missing_modules = array();
        $php_modules = get_loaded_extensions();
        if (!in_arrayi('curl', $php_modules)) {
            $missing_modules[] = 'curl';
            $email_not_curl = true;
        } else {
            $email_not_curl = false;
        }
        if (!in_arrayi('gd', $php_modules)) {
            $missing_modules[] = 'GD';
        }
        if (!in_arrayi('zip', $php_modules)) {
            $missing_modules[] = 'ZipArchive';
        }
        if (!in_arrayi('SimpleXML', $php_modules)) {
            $missing_modules[] = 'SimpleXML';
        }
        if (function_exists('apache_get_modules')) {
            if (!in_arrayi('mod_rewrite', apache_get_modules())) {
                $missing_modules[] = 'mod_rewrite';
            }
        }
        $lastModified = @filemtime(GSDATAOTHERPATH . '.htaccess');
        if ($lastModified == NULL) {
            $lastModified = filemtime(utf8_decode(GSDATAOTHERPATH . '.htaccess'));
        }
        $preview_data = @new SimpleXMLExtended('<data></data>');
        $preview_data->addChild('submission_date', date('c'));
        $preview_data->addChild('getsimple_version', get_site_version(false));
        $preview_data->addChild('language', $LANG);
        $preview_data->addChild('timezone', $TIMEZONE);
        $preview_data->addChild('php_version', PHP_VERSION);
        $preview_data->addChild('server_type', PHP_OS);
        $preview_data->addChild('modules_missing', json_encode($missing_modules));
        $preview_data->addChild('number_pages', folder_items(GSDATAPAGESPATH) - 1);
        $preview_data->addChild('number_plugins', count($live_plugins));
        $preview_data->addChild('number_files', count(glob_recursive(GSDATAUPLOADPATH . '*')));
        $preview_data->addChild('number_themes', folder_items(GSTHEMESPATH));
        $preview_data->addChild('number_backups', count(getFiles(GSBACKUPSPATH . 'zip')));
        $preview_data->addChild('number_users', folder_items(GSUSERSPATH) - 1);
        $preview_data->addChild('domain_tld', get_tld_from_url($SITEURL));
        $preview_data->addChild('install_date', date('m-d-Y', $lastModified));
        $preview_data->addChild('category', $_POST['category']);
        $preview_data->addChild('link_back', $_POST['link_back']);
        XMLsave($preview_data, GSDATAOTHERPATH . 'anonymous_data.xml');
    }
    # post data to server
    if (isset($_POST['send'])) {
        global $thisfile_anony;
        $xml = file_get_contents(GSDATAOTHERPATH . 'anonymous_data.xml');
        $success = i18n_r($thisfile_anony . '/ANONY_SUCCESS');
        $php_modules = get_loaded_extensions();
        if (in_arrayi('curl', $php_modules)) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_TIMEOUT, 4);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_URL, 'http://get-simple.info/api/anonymous/?data=' . urlencode($xml));
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml'));
            $result = curl_exec($ch);
            curl_close($ch);
        } else {
            sendmail('*****@*****.**', 'Anonymous Data Submission', $xml);
        }
    }
    global $thisfile_anony;
    ?>
	<style>
		form#anondata p {margin-bottom:5px;}
		form#anondata label {display:block;width:220px;float:left;line-height:35px;}
		form#anondata select.text {width:auto;float:left;}
	</style>
	<h3><?php 
    i18n($thisfile_anony . '/ANONY_TITLE');
    ?>
</h3>
	
	<?php 
    if (isset($success)) {
        echo '<p style="color:#669933;"><b>' . $success . '</b></p>';
    }
    ?>
	
	<form method="post" id="anondata" action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
">
		
		<?php 
    if (isset($preview_data)) {
        ?>
			<p><?php 
        i18n($thisfile_anony . '/ANONY_CONFIRM');
        ?>
</p>
			<div class="unformatted"><code><?php 
        echo htmlentities(formatXmlString(file_get_contents(GSDATAOTHERPATH . 'anonymous_data.xml')));
        ?>
</code></div>
			<p class="submit"><br /><input type="submit" class="submit" value="<?php 
        i18n($thisfile_anony . '/ANONY_SEND_BTN');
        ?>
" name="send" /> &nbsp;&nbsp;<?php 
        i18n('OR');
        ?>
&nbsp;&nbsp; <a class="cancel" href="plugins.php?cancel"><?php 
        i18n('CANCEL');
        ?>
</a></p>		
		<?php 
    } else {
        ?>
 
			<p><?php 
        i18n($thisfile_anony . '/ANONY_PARAGRAPH');
        ?>
</p>
			<p><?php 
        i18n($thisfile_anony . '/ANONY_PARAGRAPH2');
        ?>
</p>
			<p class="clearfix" ><label><?php 
        i18n($thisfile_anony . '/ANONY_CATEGORY');
        ?>
:</label>
					<select name="category" class="text">
						<option value=""></option>
						<option value="Arts"><?php 
        i18n($thisfile_anony . '/ANONY_ARTS');
        ?>
</option>
						<option value="Business"><?php 
        i18n($thisfile_anony . '/ANONY_BUSINESS');
        ?>
</option>
						<option value="Children"><?php 
        i18n($thisfile_anony . '/ANONY_CHILDREN');
        ?>
</option>
						<option value="Computer &amp; Internet"><?php 
        i18n($thisfile_anony . '/ANONY_INTERNET');
        ?>
</option>
						<option value="Culture &amp; Religion"><?php 
        i18n($thisfile_anony . '/ANONY_RELIGION');
        ?>
</option>
						<option value="Education"><?php 
        i18n($thisfile_anony . '/ANONY_EDUCATION');
        ?>
</option>
						<option value="Employment"><?php 
        i18n($thisfile_anony . '/ANONY_EMPLOYMENT');
        ?>
</option>
						<option value="Entertainment"><?php 
        i18n($thisfile_anony . '/ANONY_ENTERTAINMENT');
        ?>
</option>
						<option value="Money &amp; Finance"><?php 
        i18n($thisfile_anony . '/ANONY_FINANCE');
        ?>
</option>
						<option value="Food"><?php 
        i18n($thisfile_anony . '/ANONY_FOOD');
        ?>
</option>
						<option value="Games"><?php 
        i18n($thisfile_anony . '/ANONY_GAMES');
        ?>
</option>
						<option value="Government"><?php 
        i18n($thisfile_anony . '/ANONY_GOVERNMENT');
        ?>
</option>
						<option value="Health &amp; Fitness"><?php 
        i18n($thisfile_anony . '/ANONY_HEALTHFITNESS');
        ?>
</option>
						<option value="HighTech"><?php 
        i18n($thisfile_anony . '/ANONY_HIGHTECH');
        ?>
</option>
						<option value="Hobbies &amp; Interests"><?php 
        i18n($thisfile_anony . '/ANONY_HOBBIES');
        ?>
</option>
						<option value="Law"><?php 
        i18n($thisfile_anony . '/ANONY_LAW');
        ?>
</option>
						<option value="Life Family Issues"><?php 
        i18n($thisfile_anony . '/ANONY_LIFEFAMILY');
        ?>
</option>
						<option value="Marketing"><?php 
        i18n($thisfile_anony . '/ANONY_MARKETING');
        ?>
</option>
						<option value="Media"><?php 
        i18n($thisfile_anony . '/ANONY_MEDIA');
        ?>
</option>
						<option value="Misc"><?php 
        i18n($thisfile_anony . '/ANONY_MISC');
        ?>
</option>
						<option value="Movies &amp; Television"><?php 
        i18n($thisfile_anony . '/ANONY_MOVIES');
        ?>
</option>
						<option value="Music &amp; Radio"><?php 
        i18n($thisfile_anony . '/ANONY_MUSIC');
        ?>
</option>
						<option value="Nature"><?php 
        i18n($thisfile_anony . '/ANONY_NATURE');
        ?>
</option>
						<option value="Non-Profit"><?php 
        i18n($thisfile_anony . '/ANONY_NONPROFIT');
        ?>
</option>
						<option value="Personal Homepages"><?php 
        i18n($thisfile_anony . '/ANONY_PERSONAL');
        ?>
</option>
						<option value="Pets"><?php 
        i18n($thisfile_anony . '/ANONY_PETS');
        ?>
</option>
						<option value="Home &amp; Garden"><?php 
        i18n($thisfile_anony . '/ANONY_HOMEGARDEN');
        ?>
</option>
						<option value="Real Estate"><?php 
        i18n($thisfile_anony . '/ANONY_REALESTATE');
        ?>
</option>
						<option value="Science &amp; Technology"><?php 
        i18n($thisfile_anony . '/ANONY_SCIENCE');
        ?>
</option>
						<option value="Shopping &amp; Services"><?php 
        i18n($thisfile_anony . '/ANONY_SHOPPING');
        ?>
</option>
						<option value="Society"><?php 
        i18n($thisfile_anony . '/ANONY_SOCIETY');
        ?>
</option>
						<option value="Sports"><?php 
        i18n($thisfile_anony . '/ANONY_SPORTS');
        ?>
</option>
						<option value="Tourism"><?php 
        i18n($thisfile_anony . '/ANONY_TOURISM');
        ?>
</option>
						<option value="Transportation"><?php 
        i18n($thisfile_anony . '/ANONY_TRANSPORTATION');
        ?>
</option>
						<option value="Travel"><?php 
        i18n($thisfile_anony . '/ANONY_TRAVEL');
        ?>
</option>
						<option value="X-rated"><?php 
        i18n($thisfile_anony . '/ANONY_XRATED');
        ?>
</option>
					</select>
			</p>
			<p class="clearfix" ><label><?php 
        i18n($thisfile_anony . '/ANONY_LINK');
        ?>
</label><select class="text" name="link_back"><option></option><option value="yes" ><?php 
        i18n($thisfile_anony . '/ANONY_YES');
        ?>
</option><option value="no" ><?php 
        i18n($thisfile_anony . '/ANONY_NO');
        ?>
</option></select></p>
			<p style="color:#cc0000;font-size:11px;" >* <?php 
        i18n($thisfile_anony . '/ANONY_DISCLAIMER');
        ?>
</p>
			<p class="submit"><br /><input type="submit" class="submit" value="<?php 
        i18n($thisfile_anony . '/ANONY_PREVIEW_BTN');
        ?>
" name="preview" /> &nbsp;&nbsp;<?php 
        i18n('OR');
        ?>
&nbsp;&nbsp; <a class="cancel" href="plugins.php?cancel"><?php 
        i18n('CANCEL');
        ?>
</a></p>
		<?php 
    }
    ?>
	</form>

	<?php 
}
Esempio n. 29
0
/**
 * XML Save
 *
 * @since 2.0
 * @todo create and chmod file before ->asXML call (if it doesnt exist already, if so, then just chmod it.)
 *
 * @param object $xml
 * @param string $file Filename that it will be saved as
 * @return bool
 */
function XMLsave($xml, $file)
{
    # get_execution_time(true);
    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 = file_put_contents($file, $data);
    // LOCK_EX ?
    // debugLog('XMLsave: ' . $file . ' ' . get_execution_time());
    if (getDef('GSDOCHMOD') === false) {
        return $success;
    }
    if (defined('GSCHMOD')) {
        return $success && chmod($file, GSCHMOD);
    } else {
        return $success && chmod($file, 0755);
    }
}
Esempio n. 30
0
<?php

require_once 'XML/Atom/Feed.php';
$feed = new XML_Atom_Feed('http://example.com/', 'Example Feed');
$feed->addAuthor('Michael Gauthier', '', '*****@*****.**');
$feed->setGenerator('PEAR::XML_Atom');
$entry = new XML_Atom_Entry('http://example.com/archive/2008/january/test-post', 'Test Post');
$entry->setContent('Hello, World!', 'html');
$feed->addEntry($entry);
$entry = new XML_Atom_Entry('http://example.com/archive/2008/february/atom-test', 'Lorem Ipsum Dolor');
$entry->setSummary('<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec eu tellus ut sapien pharetra hendrerit. Suspendisse sed risus. Donec a sapien eget quam malesuada blandit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin quis elit eget quam convallis dictum. Integer lorem quam, laoreet a, bibendum quis, eleifend at, orci. Ut sed est in sem congue lacinia. Praesent cursus feugiat ante. Cras enim. Duis venenatis rutrum tellus. Aliquam erat volutpat. Vestibulum volutpat orci nec lorem. Nunc elit est, gravida eget, mattis vitae, vestibulum at, quam. Aliquam ultrices lacinia tellus. Sed eu metus.</p>', 'html');
$entry->setContent('<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec eu tellus ut sapien pharetra hendrerit. Suspendisse sed risus. Donec a sapien eget quam malesuada blandit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin quis elit eget quam convallis dictum. Integer lorem quam, laoreet a, bibendum quis, eleifend at, orci. Ut sed est in sem congue lacinia. Praesent cursus feugiat ante. Cras enim. Duis venenatis rutrum tellus. Aliquam erat volutpat. Vestibulum volutpat orci nec lorem. Nunc elit est, gravida eget, mattis vitae, vestibulum at, quam. Aliquam ultrices lacinia tellus. Sed eu metus.</p><p>Ut non nisi vitae eros tempus nonummy. Etiam accumsan aliquam erat. Praesent magna pede, rhoncus eu, dictum non, vestibulum in, purus. Sed egestas ultrices sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis suscipit justo a sapien. Mauris gravida, tellus a dignissim congue, nisi magna vehicula lorem, sollicitudin viverra ligula augue et mi. Aliquam auctor. Sed faucibus lacus nec nisl. Nulla arcu lorem, dapibus eu, accumsan eu, pulvinar at, risus. Curabitur imperdiet urna sed erat. Vestibulum id nulla. Donec magna risus, egestas ac, imperdiet malesuada, accumsan in, velit. Etiam elementum, eros in tempor sodales, massa nisl vulputate ligula, id semper lectus justo vel enim. Sed nisi mi, tristique in, molestie vel, fermentum nec, nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Proin lacus erat, tristique nec, tempus sed, consectetuer ut, orci.</p>', 'html');
$feed->addEntry($entry);
$document = $feed->getDocument();
echo formatXmlString($document->saveXML());
// ===========================================================================
function formatXmlString($xml)
{
    // add marker linefeeds to aid the pretty-tokeniser (adds a linefeed between all tag-end boundaries)
    $xml = preg_replace('/(>)(<)(\\/*)/', "\$1\n\$2\$3", $xml);
    // now indent the tags
    $token = strtok($xml, "\n");
    $result = '';
    // holds formatted version as it is built
    $pad = 0;
    // initial indent
    $matches = array();
    // returns from preg_matches()
    // scan each line and adjust indent based on opening/closing tags
    while ($token !== false) {
        // test for the various tag states