public function testConvert() { $inputData = new \DOMDocument(); $inputData->load(__DIR__ . '/_files/api.xml'); $expectedResult = (require __DIR__ . '/_files/api.php'); $this->assertEquals($expectedResult, $this->_model->convert($inputData)); }
public function testConvert() { $document = new \DOMDocument(); $document->load(__DIR__ . '../../../_files/search_request.xml'); $result = $this->object->convert($document); $expected = (include __DIR__ . '/../../_files/search_request_config.php'); $this->assertEquals($expected, $result); }
/** * lisää käyttäjän lisäämän reitin tietokantaan * @param integer $_cragid cragin id mihin reitti lisätään * @param string $_routename lisättävän reitin nimi * @param string $_routegrade lisättävän reitin greidi * @param string $_routedesc reitin selostus * @return integer palauttaa viimeisimmän tietokantaan laitetun rivin id:n */ public function addRouteToDB($_cragid, $_routename, $_routegrade, $_routedesc) { require "/var/www/db-init-climb.php"; $_routegrade = parent::convert($_routegrade); $stmt = $db->prepare("INSERT INTO Route(CragId, Name, Grade, Description) \n VALUES(:cragid, :name, :grade, :description)"); $stmt->execute([':cragid' => $_cragid, ':name' => $_routename, ':grade' => $_routegrade, ':description' => $_routedesc]); return $db->lastInsertId(); }
public function convertFile($htmlFileName, $phpFileName = '') { $htmlContent = file_get_contents($htmlFileName); if ($htmlContent) { if (!$phpFileName) { $phpFileName = $this->_makeOutputFilename($htmlFileName, $htmlContent); } $result = $this->_converter->convert($htmlContent, $this->_makeTestName($htmlFileName), $this->_tplFile); file_put_contents($phpFileName, $result); print $phpFileName . "\n"; } }
/** * Run the application to convert files. * * @param bool $hack */ public function run($hack) { $converter = new Converter(); foreach ($this->getIterator() as $fileinfo) { $fileName = $fileinfo[0]; $file = new File($fileName); $converter->convert($file, $hack); if (0 === strpos($fileName, $this->sourceFolder)) { $path = substr($fileName, strlen($this->sourceFolder)); $destinationFile = $this->destinationFolder . $path; $destinationFolder = pathinfo($destinationFile, PATHINFO_DIRNAME); if (!file_exists($destinationFolder)) { mkdir($destinationFolder, 0777, true); } file_put_contents($destinationFile, $file->getCode()); } } }
public function testComment() { $converter = new Converter(['{', '}'], ['{{', '}}']); $text = '{* foobar *}'; $this->assertSame('{{* foobar *}}', $converter->convert($text)); }
public function write($data) { return array('mimetype' => $this->writeSpec['target'], 'content' => Converter::convert($data['content'], $this->writeSpec['format'], $this->writeSpec['extension'])); }
require CONV_ROOT . 'include/fluxbb.class.php'; $fluxbb = new FluxBB($pun_config); $db = $fluxbb->connect_database($db_config); // Load the migration script require CONV_ROOT . 'include/forum.class.php'; $forum = load_forum($forum_config, $fluxbb); $forum->connect_database($old_db_config); // Load converter script require CONV_ROOT . 'include/converter.class.php'; $converter = new Converter($fluxbb, $forum); // Start the converter $next_step = array(null); while ($next_step !== false) { conv_message(); conv_log('-----------------' . "\n"); $next_step = $converter->convert($next_step[0], isset($next_step[1]) ? $next_step[1] : 0); } // We're done $alerts = array(sprintf($lang_convert['Rebuild search index note'], $lang_convert['rebuild search index'])); if (!$forum->converts_password) { $alerts[] = $lang_convert['Password converter mod']; } $fluxbb->close_database(); if (!empty($session['dupe_users'])) { conv_message("\n" . '---------------------------' . "\n"); conv_message($lang_convert['Username dupes head']); conv_message($lang_convert['Error info 1']); conv_message($lang_convert['Error info 2']); foreach ($_SESSION['converter']['dupe_users'] as $id => $cur_user) { conv_message("\t" . $lang_convert['was renamed to'], $cur_user['old_username'], $cur_user['username']); }
/** * @param $space * @return array */ private function convert($space) { if (isset($this->{strtolower($space)})) { return $this->{strtolower($space)}; } return Converter::convert($this->originalSpace, $space, $this->{strtolower($this->originalSpace)}); }
private function callback($buffer) { // modify buffer here, and then return the updated code $converter = new Converter(); $options = ['input_font' => 'Myanmar3', 'output' => 'Zawgyi-One']; $buffer = $converter->convert($buffer, $options); return $buffer; }
<?php require_once dirname(__FILE__) . '/../../common.php'; require_once dirname(__FILE__) . '/../../Converter.php'; // ----------------------------------------------------------------------------- define('PATH_BASE', dirname(__FILE__)); //if (isset($_GET['fileName'])){ //$fileName = $_GET['fileName']; //} //$inputFilename = PATH_BASE . DIRECTORY_SEPARATOR . $fileName.'.rtf'; // convert this file //$outputFormat = 'pdf'; // into this format $inputFilename = PATH_BASE . DIRECTORY_SEPARATOR . $fileName . '.rtf'; // convert this file $outputFormat = 'pdf'; // ----------------------------------------------------------------------------- $outputFilename = Converter::getFilename($inputFilename, $outputFormat); //printf('Converting %s to %s... ', basename($inputFilename), basename($outputFilename)); $convertedDocument = Converter::convert($inputFilename, $outputFormat); if (false !== $convertedDocument) { file_put_contents($outputFilename, $convertedDocument); print "DONE.\n"; } else { print "ERROR.\n"; } // -----------------------------------------------------------------------------
} else { if ($argc == 4) { $in = $argv[1]; $out = $argv[2]; $name = $argv[3]; $newContent = Converter::convert($in, $name); file_put_contents($out, $newContent); } else { $dir = realpath(__DIR__ . '/../../extensions/'); if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { $fullPath = realpath($dir . DIRECTORY_SEPARATOR . $file); if ($file != "." && $file != ".." && $file != "themes" && $file != "translations" && is_dir($fullPath) && is_writable($fullPath)) { //echo $file.PHP_EOL; $origIni = realpath($fullPath . DIRECTORY_SEPARATOR . 'default.ini'); if (file_exists($origIni) && is_readable($origIni)) { $newFile = $fullPath . "/doap.n3"; echo "write " . $newFile . PHP_EOL; file_put_contents($newFile, Converter::convert($origIni, $file)); } else { echo 'no default.ini in ' . $fullPath . PHP_EOL; } } else { echo 'skipping non-extension dir ' . $fullPath . PHP_EOL; } } closedir($handle); } } } }
/** * @param array $data * @param \ReflectionClass $class * * @return ConversionResult */ public function convert(array $data, \ReflectionClass $class) { return $this->converter->convert($data, $class, $this->nameMangling); }
<?php include __DIR__ . '/Converter.php'; $content = file_get_contents('test.in'); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="bbs.js"></script> <link rel="stylesheet" href="bbs.css"> </head> <body> <div class="border"> <pre><?php echo Converter::convert($content); ?> </pre> </div> </body> </html>
addEvent(window, 'resize', resizeGridContainer); </script> <?php } ?> </head> <body scroll="auto"> <?php require_once dirname(__FILE__) . '/menu.php'; require_once dirname(__FILE__) . "/lib/Converter.php"; require_once dirname(__FILE__) . "/lib/Providers.php"; require_once dirname(__FILE__) . "/lib/Product.php"; $providers = Providers::getProviders(); try { if ($_POST['convert_pricelist'] && $_POST['prov_id'] > 0 && isset($providers[$_POST['prov_id']]) && strlen($providers[$_POST['prov_id']]['prog_name']) && $_FILES["file_to_convert"]["error"] == UPLOAD_ERR_OK) { $res = Converter::convert($_POST['prov_id'], $_FILES["file_to_convert"]); if ($res) { if ($_POST['preview']) { echo '<h2>Обновление цен от "' . $providers[$_POST['prov_id']]['name'] . '"</h2><form action ="" method="post"><input type="hidden" name="prov_id" value="' . $_POST['prov_id'] . '"><input type="checkbox" name="import_correct_pricelist" id="import_correct_pricelist"><label for="import_correct_pricelist"><b>Подтверждаю правильность</b></label><input type="submit" value="Заимпортировать"></form><table border><tbody>'; //$temp_prods = Product::getTempProds($_POST['prov_id']); echo '<div id="grid_container"></div>'; /*echo '<table border><tbody><tr><td>Наименование</td><td>Цена</td><td>Склад</td></tr>'; $temp_prods_count = count($temp_prods); for($i = 0; $i < $temp_prods_count; $i++) { echo '<tr><td>' . $temp_prods[$i]['prod_name'] . '</td><td>' . $temp_prods[$i]['price'] . '</td><td>' . $temp_prods[$i]['stock'] . '</td></tr>'; } echo '</tbody></table>';*/ } else { if (Product::importProducts($_POST['prov_id'])) { $min_peices_updated = Product::updateMinPrices();
conv_error('Same database tables'); } // Create a wrapper for fluxbb (has easy functions for adding users etc.) require CONV_ROOT . 'include/fluxbb.class.php'; $fluxbb = new FluxBB($pun_config); $db = $fluxbb->connect_database($db_config); // Load the migration script require CONV_ROOT . 'include/forum.class.php'; $forum = load_forum($forum_config, $fluxbb); $forum->connect_database($old_db_config); // Load converter script require CONV_ROOT . 'include/converter.class.php'; $converter = new Converter($fluxbb, $forum); if (!isset($step) || $step != 'results') { // Start the converter $redirect = $converter->convert($step, $start_at); $_SESSION['fluxbb_converter'] = $session; if ($redirect === false) { conv_redirect('results'); } else { conv_redirect($redirect[0], isset($redirect[1]) ? $redirect[1] : 0); } } // if (empty($session['dupe_users'])) // unset($_SESSION['fluxbb_converter']); // We're done $alerts = array(sprintf($lang_convert['Rebuild search index note'], '<a href="../admin_maintenance.php">' . $lang_convert['rebuild search index'] . '</a>')); if (!$forum->converts_password) { $alerts[] = $lang_convert['Password converter mod']; } $fluxbb->close_database();
<?php include 'initclasses.php'; $converter = new Converter(); $grade = $_POST['grade_number'] . $_POST['grade_letter'] . $_POST['grade_plus']; $type = "indoor-" . $_POST['type']; //lisätään uusi suoritus mongoon $exercise = new Exercise(); $exercise->addIndoorExercise($type, $converter->convert($grade)); $exercise = NULL; header('Location: sisa.php');
/** * @dataProvider providerInvalid * @expectedException \InvalidArgumentException */ public function testConvertInvalidValues($value, $from, $to) { $actual = $this->object->convert($value, $from, $to); }
/** * Moving a css file should update all relative urls. * Relative references (e.g. ../images/image.gif) in a certain css file, * will have to be updated when a file is being saved at another location * (e.g. ../../images/image.gif, if the new CSS file is 1 folder deeper). * * @param Converter $converter Relative path converter * @param string $content The CSS content to update relative urls for. * * @return string */ protected function move(Converter $converter, $content) { /* * Relative path references will usually be enclosed by url(). @import * is an exception, where url() is not necessary around the path (but is * allowed). * This *could* be 1 regular expression, where both regular expressions * in this array are on different sides of a |. But we're using named * patterns in both regexes, the same name on both regexes. This is only * possible with a (?J) modifier, but that only works after a fairly * recent PCRE version. That's why I'm doing 2 separate regular * expressions & combining the matches after executing of both. */ $relativeRegexes = array('/ # open url() url\\( \\s* # open path enclosure (?P<quotes>["\'])? # fetch path (?P<path> # do not fetch data uris or external sources (?!( \\s? ["\']? (data|https?): )) .+? ) # close path enclosure (?(quotes)(?P=quotes)) \\s* # close url() \\) /ix', '/ # import statement @import # whitespace \\s+ # we don\'t have to check for @import url(), because the # condition above will already catch these # open path enclosure (?P<quotes>["\']) # fetch path (?P<path> # do not fetch data uris or external sources (?!( ["\']? (data|https?): )) .+? ) # close path enclosure (?P=quotes) /ix'); // find all relative urls in css $matches = array(); foreach ($relativeRegexes as $relativeRegex) { if (preg_match_all($relativeRegex, $content, $regexMatches, PREG_SET_ORDER)) { $matches = array_merge($matches, $regexMatches); } } $search = array(); $replace = array(); // loop all urls foreach ($matches as $match) { // determine if it's a url() or an @import match $type = strpos($match[0], '@import') === 0 ? 'import' : 'url'; // fix relative url $url = $converter->convert($match['path']); // build replacement $search[] = $match[0]; if ($type == 'url') { $replace[] = 'url(' . $url . ')'; } elseif ($type == 'import') { $replace[] = '@import "' . $url . '"'; } } // replace urls $content = str_replace($search, $replace, $content); return $content; }
$orig_file_name = $_FILES['uploadedFile']['name']; $tmp_name = $_FILES['uploadedFile']['tmp_name']; if (empty($orig_file_name)) { echo "<p style='color:red'>No file uploaded!</p>"; exit(1); } if (strtolower(pathinfo($orig_file_name, PATHINFO_EXTENSION)) != 'lyx') { echo "<p style='color:red'>This ain't no LyX file!</p>"; exit(1); } $infile_name = $tmp_name . '.lyx'; rename($tmp_name, $infile_name); $logger->log('Converting input file: ' . $orig_file_name); // echo "Hi! $format $rendertype $orig_file_name $tmp_name\n"; $converter = new Converter(); $converter->convert($format, $infile_name, $outfile_name); switch ($format) { case 'text': $fname = $converter->change_suffix($orig_file_name, 'txt'); header("Content-Type: text/plain"); break; case 'html': $fname = $converter->change_suffix($orig_file_name, 'html'); header("Content-Type: text/html"); break; case 'xml': $fname = $converter->change_suffix($orig_file_name, 'xml'); header("Content-Type: text/xml"); break; } $logger->log('Successful conversion of input file: ' . $orig_file_name);
<?php require_once 'Converter.class.php'; /** * Just a demo. * Created by deshengkong. * Date: 14-9-18 * Time: 上午10:51 */ $chinese_str = '屌炸天'; $pinyin_str = Converter::convert($chinese_str); print $pinyin_str;