curly braces + spaces added

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-01-26 14:44:46 +01:00 committed by Roland Haeder
parent 15c77beee2
commit 720e7d6034
No known key found for this signature in database
GPG Key ID: B72F8185C6C7BD78
7 changed files with 121 additions and 97 deletions

View File

@ -24,7 +24,7 @@ echo "Old DB VERSION: " . $build . "\n";
echo "New DB VERSION: " . DB_UPDATE_VERSION . "\n";
if($build != DB_UPDATE_VERSION) {
if ($build != DB_UPDATE_VERSION) {
echo "Updating database...";
check_db($a);
echo "Done\n";

View File

@ -33,7 +33,7 @@
*/
function namesList($fileset) {
$fsparam="";
foreach($fileset as $file) {
foreach ($fileset as $file) {
$fsparam=$fsparam.",".$file;
}
return $fsparam;
@ -50,7 +50,7 @@ function namesList($fileset) {
function runs($fileset) {
$fsParam=namesList($fileset);
exec('docblox -t phpdoc_out -f '.$fsParam);
if(file_exists("phpdoc_out/index.html")) {
if (file_exists("phpdoc_out/index.html")) {
echo "\n Subset ".$fsParam." is okay. \n";
exec('rm -r phpdoc_out');
return true;
@ -79,7 +79,7 @@ function reduce($fileset, $ps) {
//filter working subsets...
$parts=array_filter($parts, "runs");
//melt remaining parts together
if(is_array($parts)) {
if (is_array($parts)) {
return array_reduce($parts, "array_merge", array());
}
return array();
@ -94,17 +94,17 @@ $dirstack=array();
$filelist=array();
//loop over all files in $dir
while($dh=opendir($dir)) {
while($file=readdir($dh)) {
if(is_dir($dir."/".$file)) {
while ($dh=opendir($dir)) {
while ($file=readdir($dh)) {
if (is_dir($dir."/".$file)) {
//add to directory stack
if($file!=".." && $file!=".") {
if ($file!=".." && $file!=".") {
array_push($dirstack, $dir."/".$file);
echo "dir ".$dir."/".$file."\n";
}
} else {
//test if it is a source file and add to filelist
if(substr($file, strlen($file)-4)==".php") {
if (substr($file, strlen($file)-4)==".php") {
array_push($filelist, $dir."/".$file);
echo $dir."/".$file."\n";
}
@ -115,7 +115,7 @@ while($dh=opendir($dir)) {
}
//check the entire set
if(runs($filelist)) {
if (runs($filelist)) {
echo "I can not detect a problem. \n";
exit;
}
@ -128,15 +128,15 @@ do {
echo $i."/".count($fileset)." elements remaining. \n";
$res=reduce($res, count($res)/2);
shuffle($res);
} while(count($res)<$i);
} while (count($res)<$i);
//check one file after another
$needed=array();
while(count($res)!=0) {
while (count($res)!=0) {
$file=array_pop($res);
if(runs(array_merge($res, $needed))) {
if (runs(array_merge($res, $needed))) {
echo "needs: ".$file." and file count ".count($needed);
array_push($needed, $file);
}

View File

@ -6,7 +6,7 @@
$files = array_merge($files,glob('mod/*'),glob('include/*'),glob('addon/*/*'));
foreach($files as $file) {
foreach ($files as $file) {
$str = file_get_contents($file);
$pat = '| t\(([^\)]*)\)|';
@ -16,14 +16,14 @@
preg_match_all($patt, $str, $matchestt);
if(count($matches)){
foreach($matches[1] as $match) {
if(! in_array($match,$arr))
if (count($matches)){
foreach ($matches[1] as $match) {
if (! in_array($match,$arr))
$arr[] = $match;
}
}
if(count($matchestt)){
foreach($matchestt[1] as $match) {
if (count($matchestt)){
foreach ($matchestt[1] as $match) {
$matchtkns = preg_split("|[ \t\r\n]*,[ \t\r\n]*|",$match);
if (count($matchtkns)==3 && !in_array($matchtkns,$arr)){
$arr[] = $matchtkns;
@ -41,23 +41,26 @@ function string_plural_select($n){
';
foreach($arr as $a) {
foreach ($arr as $a) {
if (is_array($a)){
if(substr($a[1],0,1) == '$')
if (substr($a[1],0,1) == '$') {
continue;
}
$s .= '$a->strings[' . $a[0] . "] = array(\n";
$s .= "\t0 => ". $a[0]. ",\n";
$s .= "\t1 => ". $a[1]. ",\n";
$s .= ");\n";
} else {
if(substr($a,0,1) == '$')
continue;
if (substr($a,0,1) == '$') {
continue;
}
$s .= '$a->strings[' . $a . '] = '. $a . ';' . "\n";
}
}
$zones = timezone_identifiers_list();
foreach($zones as $zone)
foreach ($zones as $zone) {
$s .= '$a->strings[\'' . $zone . '\'] = \'' . $zone . '\';' . "\n";
}
echo $s;

View File

@ -17,14 +17,16 @@ unset($db_host, $db_user, $db_pass, $db_data);
Config::load();
$maint_mode = 1;
if($argc > 1)
if ($argc > 1) {
$maint_mode = intval($argv[1]);
}
set_config('system', 'maintenance', $maint_mode);
if($maint_mode)
if ($maint_mode) {
$mode_str = "maintenance mode";
else
} else {
$mode_str = "normal mode";
}
echo "\n\tSystem set in $mode_str\n\n";
echo "Usage:\n\n";

View File

@ -10,7 +10,7 @@
DEFINE("NORM_REGEXP", "|[\\\]|");
if(! class_exists('App')) {
if (! class_exists('App')) {
class TmpA {
public $strings = Array();
}
@ -68,7 +68,7 @@
}
$infile = file($phpfile);
foreach($infile as $l) {
foreach ($infile as $l) {
$l = trim($l);
if (startsWith($l, 'function string_plural_select_')) {
$lang = str_replace( 'function string_plural_select_' , '', str_replace( '($n){','', $l) );
@ -94,7 +94,7 @@
$norm_base_msgids = array();
$base_f = file("util/messages.po") or die("No base messages.po\n");
$_f = 0; $_mid = ""; $_mids = array();
foreach( $base_f as $l) {
foreach ( $base_f as $l) {
$l = trim($l);
//~ print $l."\n";
@ -165,7 +165,7 @@
}
$warnings = "";
foreach($a->strings as $key=>$str) {
foreach ($a->strings as $key=>$str) {
$msgid = massage_string($key);
if (preg_match("|%[sd0-9](\$[sn])*|", $msgid)) {

View File

@ -42,34 +42,45 @@ function po2php_run(&$argv, &$argc) {
foreach ($infile as $l) {
$l = str_replace('\"', DQ_ESCAPE, $l);
$len = strlen($l);
if ($l[0]=="#") $l="";
if (substr($l,0,15)=='"Plural-Forms: '){
if ($l[0]=="#") {
$l="";
}
if (substr($l,0,15) == '"Plural-Forms: '){
$match=Array();
preg_match("|nplurals=([0-9]*); *plural=(.*)[;\\\\]|", $l, $match);
$cond = str_replace('n','$n',$match[2]);
// define plural select function if not already defined
$fnname = 'string_plural_select_' . $lang;
$out .= 'if(! function_exists("'.$fnname.'")) {'."\n";
$out .= 'if (! function_exists("'.$fnname.'")) {'."\n";
$out .= 'function '. $fnname . '($n){'."\n";
$out .= ' return '.$cond.';'."\n";
$out .= '}}'."\n";
}
if ($k!="" && substr($l,0,7)=="msgstr "){
if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
if ($k!="" && substr($l,0,7) == "msgstr "){
if ($ink) {
$ink = False;
$out .= '$a->strings["'.$k.'"] = ';
}
if ($inv) {
$inv = False;
$out .= '"'.$v.'"';
}
$v = substr($l,8,$len-10);
$v = preg_replace_callback($escape_s_exp,'escape_s',$v);
$inv = True;
//$out .= $v;
}
if ($k!="" && substr($l,0,7)=="msgstr["){
if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
if ($k!="" && substr($l,0,7) == "msgstr["){
if ($ink) {
$ink = False;
$out .= '$a->strings["'.$k.'"] = ';
}
if ($inv) {
$inv = False;
$out .= '"'.$v.'"';
}
if (!$arr) {
$arr=True;
@ -85,7 +96,6 @@ function po2php_run(&$argv, &$argc) {
if (substr($l,0,6)=="msgid_") { $ink = False; $out .= '$a->strings["'.$k.'"] = '; };
if ($ink) {
$k .= trim($l,"\"\r\n");
$k = preg_replace_callback($escape_s_exp,'escape_s',$k);
@ -93,9 +103,14 @@ function po2php_run(&$argv, &$argc) {
}
if (substr($l,0,6)=="msgid "){
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
if ($k!="") $out .= $arr?");\n":";\n";
$arr=False;
if ($inv) {
$inv = False;
$out .= '"'.$v.'"';
}
if ($k != "") {
$out .= $arr?");\n":";\n";
}
$arr = False;
$k = str_replace("msgid ","",$l);
if ($k != '""' ) {
$k = trim($k,"\"\r\n");
@ -116,8 +131,13 @@ function po2php_run(&$argv, &$argc) {
}
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
if ($k!="") $out .= $arr?");\n":";\n";
if ($inv) {
$inv = False;
$out .= '"'.$v.'"';
}
if ($k!="") {
$out .= $arr?");\n":";\n";
}
$out = str_replace(DQ_ESCAPE, '\"', $out);
file_put_contents($outfile, $out);

View File

@ -1,59 +1,58 @@
<?php
// Tired of chasing typos and finding them after a commit.
// Run this from cmdline in basedir and quickly see if we've
// got any parse errors in our application files.
// Tired of chasing typos and finding them after a commit.
// Run this from cmdline in basedir and quickly see if we've
// got any parse errors in our application files.
error_reporting(E_ERROR | E_WARNING | E_PARSE );
ini_set('display_errors', '1');
ini_set('log_errors','0');
error_reporting(E_ERROR | E_WARNING | E_PARSE );
ini_set('display_errors', '1');
ini_set('log_errors','0');
include 'boot.php';
include 'boot.php';
$a = new App();
$a = new App();
if(x($a->config,'php_path'))
$phpath = $a->config['php_path'];
else
$phpath = 'php';
if (x($a->config,'php_path')) {
$phpath = $a->config['php_path'];
} else {
$phpath = 'php';
}
echo "Directory: mod\n";
$files = glob('mod/*.php');
foreach ($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}
echo "Directory: mod\n";
$files = glob('mod/*.php');
foreach($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
echo "Directory: include\n";
$files = glob('include/*.php');
foreach ($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}
echo "Directory: object\n";
$files = glob('object/*.php');
foreach ($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}
echo "Directory: addon\n";
$dirs = glob('addon/*');
foreach ($dirs as $dir) {
$addon = basename($dir);
$files = glob($dir . '/' . $addon . '.php');
foreach ($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}
}
echo "Directory: include\n";
$files = glob('include/*.php');
foreach($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}
echo "String files\n";
echo "Directory: object\n";
$files = glob('object/*.php');
foreach($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}
echo 'util/strings.php' . "\n";
passthru("$phpath -l util/strings.php", $ret); $ret===0 or die();
echo "Directory: addon\n";
$dirs = glob('addon/*');
foreach($dirs as $dir) {
$addon = basename($dir);
$files = glob($dir . '/' . $addon . '.php');
foreach($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}
}
echo "String files\n";
echo 'util/strings.php' . "\n";
passthru("$phpath -l util/strings.php", $ret); $ret===0 or die();
$files = glob('view/lang/*/strings.php');
foreach($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}
$files = glob('view/lang/*/strings.php');
foreach ($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}