Changed:
[friendica-addons.git/.git] / convert / convert.php
index 5449cc1..1385731 100644 (file)
@@ -18,12 +18,6 @@ function convert_app_menu($a,&$b) {
 
 function convert_module() {}
 
-
-
-
-
-
-
 function convert_content($app) {
 
 include("UnitConvertor.php");
@@ -85,92 +79,90 @@ include("UnitConvertor.php");
        }
 }
 
-
 $conv = new TP_Converter('en');
 
-
 $conversions = [
-       'Temperature'=>['base' =>'Celsius',
-               'conv'=>[
-                       'Fahrenheit'=>['ratio'=>1.8, 'offset'=>32],
-                       'Kelvin'=>['ratio'=>1, 'offset'=>273],
-                       'Reaumur'=>0.8
+       'Temperature' => ['base'  => 'Celsius',
+               'conv' => [
+                       'Fahrenheit' => ['ratio' => 1.8, 'offset' => 32],
+                       'Kelvin' => ['ratio' => 1, 'offset' => 273],
+                       'Reaumur' => 0.8
                ]
        ],
-       'Weight' => ['base' =>'kg',
-               'conv'=>[
-                       'g'=>1000,
-                       'mg'=>1000000,
-                       't'=>0.001,
-                       'grain'=>15432,
-                       'oz'=>35.274,
-                       'lb'=>2.2046,
-                       'cwt(UK)'       => 0.019684,
-                       'cwt(US)'       => 0.022046,
-                       'ton (US)'      => 0.0011023,
-                       'ton (UK)'      => 0.0009842
+       'Weight'  =>  ['base'  => 'kg',
+               'conv' => [
+                       'g' => 1000,
+                       'mg' => 1000000,
+                       't' => 0.001,
+                       'grain' => 15432,
+                       'oz' => 35.274,
+                       'lb' => 2.2046,
+                       'cwt(UK)'        =>  0.019684,
+                       'cwt(US)'        =>  0.022046,
+                       'ton (US)'       =>  0.0011023,
+                       'ton (UK)'       =>  0.0009842
                ]
        ],
-       'Distance' => ['base' =>'km',
-               'conv'=>[
-                       'm'=>1000,
-                       'dm'=>10000,
-                       'cm'=>100000,
-                       'mm'=>1000000,
-                       'mile'=>0.62137,
-                       'naut.mile'=>0.53996,
-                       'inch(es)'=>39370,
-                       'ft'=>3280.8,
-                       'yd'=>1093.6,
-                       'furlong'=>4.970969537898672,
-                       'fathom'=>546.8066491688539
+       'Distance'  =>  ['base'  => 'km',
+               'conv' => [
+                       'm' => 1000,
+                       'dm' => 10000,
+                       'cm' => 100000,
+                       'mm' => 1000000,
+                       'mile' => 0.62137,
+                       'naut.mile' => 0.53996,
+                       'inch(es)' => 39370,
+                       'ft' => 3280.8,
+                       'yd' => 1093.6,
+                       'furlong' => 4.970969537898672,
+                       'fathom' => 546.8066491688539
                ]
        ],
-       'Area' => ['base' =>'km 2',
-               'conv'=>[
-                       'ha'=>100,
-                       'acre'=>247.105,
-                       'm 2'=>pow(1000,2),
-                       'dm 2'=>pow(10000,2),
-                       'cm 2'=>pow(100000,2),
-                       'mm 2'=>pow(1000000,2),
-                       'mile 2'=>pow(0.62137,2),
-                       'naut.miles 2'=>pow(0.53996,2),
-                       'in 2'=>pow(39370,2),
-                       'ft 2'=>pow(3280.8,2),
-                       'yd 2'=>pow(1093.6,2),
+       'Area'  =>  ['base'  => 'km 2',
+               'conv' => [
+                       'ha' => 100,
+                       'acre' => 247.105,
+                       'm 2' => pow(1000,2),
+                       'dm 2' => pow(10000,2),
+                       'cm 2' => pow(100000,2),
+                       'mm 2' => pow(1000000,2),
+                       'mile 2' => pow(0.62137,2),
+                       'naut.miles 2' => pow(0.53996,2),
+                       'in 2' => pow(39370,2),
+                       'ft 2' => pow(3280.8,2),
+                       'yd 2' => pow(1093.6,2),
                ]
        ],
-       'Volume' => ['base' =>'m 3',
-               'conv'=>[
-                       'in 3'=>61023.6,
-                       'ft 3'=>35.315,
-                       'cm 3'=>pow(10,6),
-                       'dm 3'=>1000,
-                       'litre'=>1000,
-                       'hl'=>10,
-                       'yd 3'=>1.30795,
-                       'gal(US)'=>264.172,
-                       'gal(UK)'=>219.969,
-                       'pint' => 2113.376,
-                       'quart' => 1056.688,
-                       'cup' => 4266.753,
-                       'fl oz' => 33814.02,
-                       'tablespoon' => 67628.04,
-                       'teaspoon' => 202884.1,
-                       'pt (UK)'=>1000/0.56826,
-                       'barrel petroleum'=>1000/158.99,
-                       'Register Tons'=>2.832,
-                       'Ocean Tons'=>1.1327
+       'Volume'  =>  ['base'  => 'm 3',
+               'conv' => [
+                       'in 3' => 61023.6,
+                       'ft 3' => 35.315,
+                       'cm 3' => pow(10,6),
+                       'dm 3' => 1000,
+                       'litre' => 1000,
+                       'hl' => 10,
+                       'yd 3' => 1.30795,
+                       'gal(US)' => 264.172,
+                       'gal(UK)' => 219.969,
+                       'pint'  =>  2113.376,
+                       'quart'  =>  1056.688,
+                       'cup'  =>  4266.753,
+                       'fl oz'  =>  33814.02,
+                       'tablespoon'  =>  67628.04,
+                       'teaspoon'  =>  202884.1,
+                       'pt (UK)' => 1000/0.56826,
+                       'barrel petroleum' => 1000/158.99,
+                       'Register Tons' => 2.832,
+                       'Ocean Tons' => 1.1327
                ]
        ],
-       'Speed' =>['base' =>'kmph',
-               'conv'=>[
-                       'mps'=>0.0001726031,
-                       'milesph'=>0.62137,
-                       'knots'=>0.53996,
-                       'mach STP'=>0.0008380431,
-                       'c (warp)'=>9.265669e-10
+       'Speed'  => ['base'  => 'kmph',
+               'conv' => [
+                       'mps' => 0.0001726031,
+                       'milesph' => 0.62137,
+                       'knots' => 0.53996,
+                       'mach STP' => 0.0008380431,
+                       'c (warp)' => 9.265669e-10
                ]
        ]
 ];
@@ -188,24 +180,21 @@ while (list($key,$val) = each($conversions)) {
 
 
        if (isset($_POST['from_unit']) && isset($_POST['value'])) {
-       $_POST['value'] = $_POST['value'] + 0;
-
-
+               $_POST['value'] = $_POST['value'] + 0;
                $o .= ($conv->getTable($_POST['value'], $_POST['from_unit'], $_POST['to_unit'], 5))."</p>";
        } else {
                $o .= "<p>Select:</p>";
        }
 
-       if(isset($_POST['value']))
+       if (isset($_POST['value'])) {
                $value = $_POST['value'];
-       else
+       } else {
                $value = '';
+       }
 
        $o .= '<form action="convert" method="post" name="conversion">';
-    $o .= '<input name="value" type="text" id="value" value="' . $value . '" size="10" maxlength="10" />';
-    $o .= '<select name="from_unit" size="12">';
-
-
+       $o .= '<input name="value" type="text" id="value" value="' . $value . '" size="10" maxlength="10" />';
+       $o .= '<select name="from_unit" size="12">';
 
        reset($list);
        while(list($key,$val) = each($list)) {
@@ -218,8 +207,7 @@ while (list($key,$val) = each($conversions)) {
        }
 
        $o .= '</select>';
-
-    $o .= '<input type="submit" name="Submit" value="Submit" /></form>';
+       $o .= '<input type="submit" name="Submit" value="Submit" /></form>';
 
        return $o;
 }