1
1
Fork 0

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"; echo "New DB VERSION: " . DB_UPDATE_VERSION . "\n";
if($build != DB_UPDATE_VERSION) { if ($build != DB_UPDATE_VERSION) {
echo "Updating database..."; echo "Updating database...";
check_db($a); check_db($a);
echo "Done\n"; echo "Done\n";

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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