Changeset 7


Ignore:
Timestamp:
Apr 14, 2020, 11:13:32 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
Location:
trunk
Files:
54 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Core.php

    r3 r7  
    22
    33$ConfigFileName = dirname(__FILE__).'/../Config/Config.php';
    4 if(file_exists($ConfigFileName)) include_once($ConfigFileName);
     4if (file_exists($ConfigFileName)) include_once($ConfigFileName);
    55
    66include_once(dirname(__FILE__).'/../Packages/Common/Common.php');
     
    3131    $this->BaseURL = $_SERVER['SCRIPT_NAME'];
    3232    $BaseScriptName = '/index.php';
    33     if(substr($this->BaseURL, -strlen($BaseScriptName), strlen($BaseScriptName)) == $BaseScriptName)
     33    if (substr($this->BaseURL, -strlen($BaseScriptName), strlen($BaseScriptName)) == $BaseScriptName)
    3434      $this->BaseURL = substr($this->BaseURL, 0, -strlen($BaseScriptName));
    3535    $this->FormManager = new FormManager($this->Database);
     
    4848    $this->Config = &$Config;
    4949
    50     if(isset($this->Config['Database']))
     50    if (isset($this->Config['Database']))
    5151    {
    5252      $this->Database->Connect($Config['Database']['Host'], $Config['Database']['User'],
     
    5959
    6060    // SQL injection hack protection
    61     foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
    62     foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
     61    foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
     62    foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
    6363
    6464    $this->RegisterPageBar('Top');
     
    6868    $this->Setup = new Setup($this);
    6969    $this->Setup->Start();
    70     if($this->Setup->CheckState())
     70    if ($this->Setup->CheckState())
    7171    {
    7272      $this->ModuleManager->Start();
     
    7777  {
    7878    $this->RunCommon();
    79     if($this->ShowPage)
     79    if ($this->ShowPage)
    8080    {
    8181      $this->PathItems = ProcessURL();
     
    9090    /* @var $Page Page */
    9191    $ClassName = $this->SearchPage($this->PathItems, $this->Pages);
    92     if($ClassName != '')
     92    if ($ClassName != '')
    9393    {
    9494      $Page = new $ClassName($this);
     
    101101  function RegisterPage($Path, $Handler)
    102102  {
    103     if(is_array($Path))
     103    if (is_array($Path))
    104104    {
    105105      $Page = &$this->Pages;
    106106      $LastKey = array_pop($Path);
    107       foreach($Path as $PathItem)
     107      foreach ($Path as $PathItem)
    108108      {
    109109        $Page = &$Page[$PathItem];
    110110      }
    111       if(!is_array($Page)) $Page = array('' => $Page);
     111      if (!is_array($Page)) $Page = array('' => $Page);
    112112      $Page[$LastKey] = $Handler;
    113113    } else $this->Pages[$Path] = $Handler;
     
    136136  function SearchPage($PathItems, $Pages)
    137137  {
    138     if(count($PathItems) > 0) $PathItem = $PathItems[0];
     138    if (count($PathItems) > 0) $PathItem = $PathItems[0];
    139139      else $PathItem = '';
    140     if(array_key_exists($PathItem, $Pages))
     140    if (array_key_exists($PathItem, $Pages))
    141141    {
    142       if(is_array($Pages[$PathItem]))
     142      if (is_array($Pages[$PathItem]))
    143143      {
    144144        array_shift($PathItems);
    145         return($this->SearchPage($PathItems, $Pages[$PathItem]));
    146       } else return($Pages[$PathItem]);
    147     } else return('');
     145        return $this->SearchPage($PathItems, $Pages[$PathItem]);
     146      } else return $Pages[$PathItem];
     147    } else return '';
    148148  }
    149149
    150150  function Link($Target)
    151151  {
    152     return($this->BaseURL.$Target);
     152    return $this->BaseURL.$Target;
    153153  }
    154154}
     
    166166  {
    167167    Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
    168     return('<h3 align="center">'.T('Required page not found').'</h3>');
     168    return '<h3 align="center">'.T('Required page not found').'</h3>';
    169169  }
    170170}
  • trunk/Application/DefaultConfig.php

    r1 r7  
    66  {
    77    $IsDeveloper = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1'));
    8     return(array
     8    return array
    99    (
    1010        array('Name' => 'SystemPassword', 'Type' => 'PasswordEncoded', 'Default' => '', 'Title' => 'Systémové heslo'),
     
    3636        array('Name' => 'Web/ShowPHPError', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat PHP chyby'),
    3737        array('Name' => 'Web/ShowRuntimeInfo', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat běhové informace'),
    38     ));
     38    );
    3939  }
    4040}
  • trunk/Application/UpdateTrace.php

    r1 r7  
    99  function Get()
    1010  {
    11     return(array(
    12     ));
     11    return array(
     12    );
    1313  }
    1414}
  • trunk/Application/View.php

    r3 r7  
    55  function SystemMessage($Title, $Text)
    66  {
    7     return('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>');
     7    return '<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>';
    88  }
    99
     
    3737    $Output .= '<div class="MenuItem">';
    3838    $Bar = '';
    39     foreach($this->System->Bars['TopLeft'] as $BarItem)
     39    foreach ($this->System->Bars['TopLeft'] as $BarItem)
    4040      $Bar .= call_user_func($BarItem);
    41       if(trim($Bar) != '') $Output .= $Bar;
     41      if (trim($Bar) != '') $Output .= $Bar;
    4242      else $Output .= '&nbsp;';
    4343    $Output .= '</div><div class="MenuItem2">';
    4444    $Bar = '';
    45     foreach($this->System->Bars['Top'] as $BarItem)
     45    foreach ($this->System->Bars['Top'] as $BarItem)
    4646      $Bar .= call_user_func($BarItem);
    47       if(trim($Bar) != '') $Output .= $Bar;
     47      if (trim($Bar) != '') $Output .= $Bar;
    4848      else $Output .= '&nbsp;';
    4949    $Output .= '</div></div>';
    50     return($Output);
     50    return $Output;
    5151  }
    5252
     
    5555    $Page->OnSystemMessage = array($this->System->BaseView, 'SystemMessage');
    5656    $Output = $this->ShowPage($Page->Show());
    57     return($Output);
     57    return $Output;
    5858  }
    5959}
  • trunk/Global.php

    r1 r7  
    33function HumanDate($Time)
    44{
    5   return(date('j.n.Y', $Time));
     5  return date('j.n.Y', $Time);
    66}
    77
     
    99{
    1010  list($Usec, $Sec) = explode(" ", microtime());
    11   return ((float)$Usec + (float)$Sec);
     11  return (float)$Usec + (float)$Sec;
    1212}
    1313
    1414function MakeLink($Target, $Title)
    1515{
    16   return('<a href="'.$Target.'">'.$Title.'</a>');
     16  return '<a href="'.$Target.'">'.$Title.'</a>';
    1717}
    1818
     
    2121  $Result = '<table cellspacing="0" class="BasicTable">';
    2222  $Result .= '<tr>';
    23   foreach($Table['Header'] as $Item)
     23  foreach ($Table['Header'] as $Item)
    2424    $Result .= '<th>'.$Item.'</th>';
    2525  $Result .= '</tr>';
    26   foreach($Table['Rows'] as $Row)
     26  foreach ($Table['Rows'] as $Row)
    2727  {
    2828    $Result .= '<tr>';
    29     foreach($Row as $Item)
     29    foreach ($Row as $Item)
    3030      $Result .= '<td>'.$Item.'</td>';
    3131    $Result .= '</tr>';
    3232  }
    3333  $Result .= '</table>';
    34   return($Result);
     34  return $Result;
    3535}
    3636
     
    4444  );
    4545
    46   foreach($Class as $Index => $Item)
     46  foreach ($Class as $Index => $Item)
    4747  {
    48     if(!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default'];
    49     switch($Item['Type'])
     48    if (!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default'];
     49    switch ($Item['Type'])
    5050    {
    5151      case 'Boolean':
    52         if($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"';
     52        if ($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"';
    5353        $Edit = '<input type="checkbox" name="'.$Index.'"'.$Checked.'>';
    5454        break;
     
    6565  }
    6666  $Output = '<h3>Tabulka '.$ClassName.'</h3>'.Table($Table).MakeLink('?Operation=Add2', 'Přidat');
    67   return($Output);
     67  return $Output;
    6868}
    6969
    7070function ProcessURL()
    7171{
    72   if(array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
     72  if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
    7373    $PathString = $_SERVER['REDIRECT_QUERY_STRING'];
    7474    else $PathString = '';
    75   if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
     75  if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
    7676  $PathItems = explode('/', $PathString);
    77   if(array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))
     77  if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))
    7878    $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
    7979    else $_SERVER['QUERY_STRING'] = '';
    8080  parse_str($_SERVER['QUERY_STRING'], $_GET);
    81   return($PathItems);
     81  return $PathItems;
    8282}
    8383
     
    8686  $Result = array();
    8787  $Parts = explode('&', $QueryString);
    88   foreach($Parts as $Part)
     88  foreach ($Parts as $Part)
    8989  {
    90     if($Part != '')
     90    if ($Part != '')
    9191    {
    92       if(!strpos($Part, '=')) $Part .= '=';
     92      if (!strpos($Part, '=')) $Part .= '=';
    9393      $Item = explode('=', $Part);
    9494      $Result[$Item[0]] = $Item[1];
    9595    }
    9696  }
    97   return($Result);
     97  return $Result;
    9898}
    9999
     
    101101{
    102102  $Parts = array();
    103   foreach($QueryStringArray as $Index => $Item)
     103  foreach ($QueryStringArray as $Index => $Item)
    104104  {
    105105    $Parts[] = $Index.'='.$Item;
    106106  }
    107   return(implode('&amp;', $Parts));
     107  return implode('&amp;', $Parts);
    108108}
    109109
    110110function GetRemoteAddress()
    111111{
    112   if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
     112  if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
    113113  else $IP = '0.0.0.0';
    114   return($IP);
     114  return $IP;
    115115}
  • trunk/Modules/Map/Map.php

    r4 r7  
    5353  function Geolocate($Text)
    5454  {
    55     return(null);
    56   }
    57 
    58   function Show()
    59   {
    60     return('');
     55    return null;
     56  }
     57
     58  function Show()
     59  {
     60    return '';
    6161  }
    6262
     
    6666    $Result = substr($Text, 0, strpos($Text, $End) - 1);
    6767    $Text = substr($Text, strlen($End));
    68     return($Result);
     68    return $Result;
    6969  }
    7070}
     
    107107        <script>Loader.load()</script>';
    108108
    109     return($Output);
     109    return $Output;
    110110  }
    111111}
     
    117117    $Origins = array();
    118118    $Destinations = array();
    119     foreach($this->Path as $Index => $PathItem)
     119    foreach ($this->Path as $Index => $PathItem)
    120120    if ($Index > 0)
    121121    {
     
    134134      $I++;
    135135    }
    136     return($Points);
     136    return $Points;
    137137  }
    138138
     
    142142    array_shift($WayPoints);
    143143    array_pop($WayPoints);
    144     if(count($WayPoints) > 0)
     144    if (count($WayPoints) > 0)
    145145      $WaypointsQuery = '&waypoints='.implode('|', $WayPoints);
    146146      else $WaypointsQuery = '';
     
    151151      '&destination='.$this->Path[count($this->Path) - 1].''.
    152152      '" style="border: 1px solid black"></iframe>';
    153     return($Output);
     153    return $Output;
    154154  }
    155155}
     
    176176  {
    177177    $this->Points = array();
    178     foreach($TextPathItems as $TextPathItem)
     178    foreach ($TextPathItems as $TextPathItem)
    179179    {
    180180      $Result = $this->Geolocate($TextPathItem);
     
    184184
    185185    $WayPoints = array();
    186     foreach($this->Points as $Point)
     186    foreach ($this->Points as $Point)
    187187    {
    188188      $WayPoints[] = $Point['Longitude'];
     
    208208    $Points = array();
    209209    $Separator = '<gml:pos>';
    210     while(strpos($Result, $Separator) !== false)
     210    while (strpos($Result, $Separator) !== false)
    211211    {
    212212      $Result = substr($Result, strpos($Result, $Separator) + strlen($Separator));
     
    215215      $Points[] = array('Longitude' => $PosParts[0], 'Latitude' => $PosParts[1]);
    216216    }
    217     return(array('TotalDistance' => $TotalDistance, 'TotalTime' => $TotalTime,
    218       'Points' => $Points));
     217    return array('TotalDistance' => $TotalDistance, 'TotalTime' => $TotalTime,
     218      'Points' => $Points);
    219219  }
    220220
     
    222222  {
    223223    $WayPoints = array();
    224     foreach($this->Points as $Point)
     224    foreach ($this->Points as $Point)
    225225    {
    226226      $WayPoints[] = $Point['Longitude'];
  • trunk/Modules/Ride/Ride.php

    r6 r7  
    140140      'Vsetín', 'Nový Jičín', 'Prostějov', 'Vyškov', 'Mohelnice', 'Ústí nad Orlicí');
    141141
    142     for($I = 0; $I < 100; $I++)
     142    for ($I = 0; $I < 100; $I++)
    143143    {
    144144      $Stops = array_fill(0, random(5), '');
    145       for($J = 0; $J < count($Stops); $J++)
     145      for ($J = 0; $J < count($Stops); $J++)
    146146        $Stops[$J] = $Cities[random(count($Cities))];
    147147
     
    158158      '<a href="'.$this->System->Link('/jizdy/').'">Hledat jízdu</a> nebo '.
    159159      '<a href="'.$this->System->Link('/nova-jizda/').'">Nabídnout jízdu</a>';
    160     return($Output);
     160    return $Output;
    161161  }
    162162
     
    173173        'LEFT JOIN RideStop AS PassengerRideStopTo ON PassengerRideStopTo.Id=Passenger.RideStopTo '.
    174174        'WHERE Passenger.Ride='.$RideId);
    175     while($DbRow = $DbResult->fetch_assoc())
    176     {
    177       for($I = $DbRow['SequenceFrom'] + 1; $I <= $DbRow['SequenceTo']; $I++)
     175    while ($DbRow = $DbResult->fetch_assoc())
     176    {
     177      for ($I = $DbRow['SequenceFrom'] + 1; $I <= $DbRow['SequenceTo']; $I++)
    178178      {
    179179        $Stops[$I] = $Stops[$I] + $DbRow['SeatCount'];
    180180      }
    181181    }
    182     foreach($Stops as $Index => $Stop)
     182    foreach ($Stops as $Index => $Stop)
    183183    {
    184184      $this->System->Database->update('RideStop', 'Ride='.$RideId.' AND Sequence='.$Index, array('PassengerCount' => $Stop));
     
    206206    $Stops = array();
    207207    $DbResult2 = $this->Database->query('SELECT * FROM RideStop WHERE Ride='.$DbRow['Id'].' ORDER BY Sequence');
    208     while($DbRow2 = $DbResult2->fetch_assoc())
     208    while ($DbRow2 = $DbResult2->fetch_assoc())
    209209    {
    210210      $Track[] = $DbRow2;
     
    239239      'LEFT JOIN User ON User.Id=Passenger.User '.
    240240      'WHERE Passenger.Ride='.$RideId);
    241     while($Passenger = $DbResult->fetch_assoc())
     241    while ($Passenger = $DbResult->fetch_assoc())
    242242    {
    243243      $Passengers[] = $Passenger;
     
    245245      do {
    246246        $Check = true;
    247         for($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)
     247        for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)
    248248        {
    249           if($Table[$I][$Seat] != 0) $Check = false;
     249          if ($Table[$I][$Seat] != 0) $Check = false;
    250250        }
    251251        if (!$Check) $Seat++;
    252       } while(!$Check);
    253       for($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)
     252      } while (!$Check);
     253      for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)
    254254        $Table[$I][$Seat] = count($Passengers) - 1;
    255255    }
     
    259259      $Output .= '<th style="width: 80px">Cestující</th>';
    260260    $Output .= '</tr>';
    261     foreach($Track as $Index => $TrackItem)
     261    foreach ($Track as $Index => $TrackItem)
    262262    {
    263263      $Output .= '<tr><td style="height: 100px">'.$TrackItem['Place'].'<br/>'.$TrackItem['Time'].'</td>';
    264       if($Index == 0) $Output .= '<td rowspan="'.count($Track).'">Řidič</td>';
     264      if ($Index == 0) $Output .= '<td rowspan="'.count($Track).'">Řidič</td>';
    265265      for ($I = 0; $I < $DbRow['SeatCount']; $I++)
    266266      {
     
    271271        } else {
    272272          // Show unused space
    273           if(($Index == 0) or ((($Index - 1) >= 0) and (!is_null($Table[$Index - 1][$I]))))
     273          if (($Index == 0) or ((($Index - 1) >= 0) and (!is_null($Table[$Index - 1][$I]))))
    274274          {
    275275            $J = 1;
    276             while((($Index + $J) < count($Table)) and is_null($Table[$Index + $J][$I])) $J++;
     276            while ((($Index + $J) < count($Table)) and is_null($Table[$Index + $J][$I])) $J++;
    277277            $Output .= '<td rowspan="'.$J.'">&nbsp;</td>';
    278278          }
     
    284284
    285285
    286     return($Output);
     286    return $Output;
    287287  }
    288288
     
    303303      }
    304304    }
    305     return($Output);
     305    return $Output;
    306306  }
    307307}
     
    311311  function Show()
    312312  {
    313     if(array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];
     313    if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];
    314314      else $PlaceFrom = '';
    315     if(array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];
     315    if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];
    316316      else $PlaceTo = '';
    317     if(array_key_exists('time', $_GET)) $Time = $_GET['time'];
     317    if (array_key_exists('time', $_GET)) $Time = $_GET['time'];
    318318      else $Time = '';
    319319    $Output = '<table style="width: 100%; margin-top: 100px; margin-bottom: 100px;"><tr><td style="text-align: center">'.
     
    325325      '<input type="submit" value="Hledat"/>'.
    326326      '</form></div></td></tr></table>';
    327     return($Output);
     327    return $Output;
    328328  }
    329329}
     
    333333  function Show()
    334334  {
    335     if(array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];
     335    if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];
    336336      else $PlaceFrom = '';
    337     if(array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];
     337    if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];
    338338      else $PlaceTo = '';
    339     if(array_key_exists('time', $_GET)) $Time = $_GET['time'];
     339    if (array_key_exists('time', $_GET)) $Time = $_GET['time'];
    340340      else $Time = '';
    341341    $Output = '<table style="width: 100%"><tr><td style="text-align: center;">'.
     
    349349      $Output .= $this->ShowRides($_GET['from'], $_GET['to']);
    350350    } else $Output .= $this->ShowRides('', '');
    351     return($Output);
     351    return $Output;
    352352  }
    353353
     
    358358    $Query = 'SELECT Ride.Id, Ride.SeatCount, User.Name AS DriverName, User.BirthDate, '.
    359359      'CONCAT(CarManufacturer.Name, " ", CarModel.Name) AS CarName ';
    360     if((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))
     360    if ((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))
    361361      $Query .= ', (SELECT COALESCE(MAX(RideStop.PassengerCount), 0) FROM RideStop '.
    362362      'WHERE (RideStop.Ride=Ride.Id) AND (RideStop.Sequence > RideStopFrom.Sequence) AND '.
     
    371371      'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '.
    372372      'LEFT JOIN User ON User.Id=Ride.Driver ';
    373     if((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))
     373    if ((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))
    374374      $Query .= 'JOIN RideStop AS RideStopFrom ON (RideStopFrom.Ride = Ride.Id) AND (RideStopFrom.Place LIKE "%'.$PlaceFrom.'%") '.
    375375        'JOIN RideStop AS RideStopTo ON (RideStopTo.Ride = Ride.Id) AND (RideStopTo.Place LIKE "%'.$PlaceTo.'%") '.
     
    377377    $Query .= 'LIMIT 10';
    378378    $DbResult = $this->Database->query($Query);
    379     while($DbRow = $DbResult->fetch_assoc())
     379    while ($DbRow = $DbResult->fetch_assoc())
    380380    {
    381381      $Stops = array();
    382382      $Price = 0;
    383383      $DbResult2 = $this->Database->query('SELECT * FROM RideStop WHERE Ride='.$DbRow['Id'].' ORDER BY Sequence');
    384       while($DbRow2 = $DbResult2->fetch_assoc())
     384      while ($DbRow2 = $DbResult2->fetch_assoc())
    385385      {
    386386        $Stops[] = $DbRow2['Place'];
     
    400400    $Output .= '</table>';
    401401
    402     return($Output);
     402    return $Output;
    403403  }
    404404}
     
    416416
    417417  $ret = array();
    418   foreach($bit as $k => $v)
    419     if($v > 0)$ret[] = $v . $k;
     418  foreach ($bit as $k => $v)
     419    if ($v > 0)$ret[] = $v . $k;
    420420
    421421  return join(' ', $ret);
     
    483483          'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '.
    484484          'WHERE Car.Owner='.$this->System->User->User['Id']);
    485         while($DbRow = $DbResult->fetch_assoc())
     485        while ($DbRow = $DbResult->fetch_assoc())
    486486        {
    487487          $Output .= '<option value="'.$DbRow['Id'].'"/>'.$DbRow['ModelName'].'</option>';
     
    500500        $PricePerKm = 0.8;
    501501        $Output .= '<table class="WideTable"><tr><th>Úsek</th><th>Odjezd</th><th>Trvání</th><th>Vzdálenost [km]</th><th>Cena [Kč]</th></tr>';
    502         foreach($Track as $Index => $TrackItem)
     502        foreach ($Track as $Index => $TrackItem)
    503503        {
    504           if($Index > 0)
     504          if ($Index > 0)
    505505          {
    506506            $Track[$Index]['Time'] = $TimeFrom + $Track[$Index - 1]['Duration'];
     
    542542        ));
    543543        $RideId = $this->Database->insert_id;
    544         foreach($_SESSION['Track'] as $Index => $TrackItem)
     544        foreach ($_SESSION['Track'] as $Index => $TrackItem)
    545545        {
    546546          $this->Database->insert('RideStop', array(
     
    556556      }
    557557    }
    558     return($Output);
    559   }
    560 }
    561 
     558    return $Output;
     559  }
     560}
     561
  • trunk/Modules/User/User.php

    r5 r7  
    121121    /*
    122122
    123      if($this->InstalledVersion == '1.0') {
     123     if ($this->InstalledVersion == '1.0') {
    124124      $this->System->Database->Query('SELECT * FROM User WHERE Id=1');
    125125      $this->InstalledVersion = '1.1';
     
    131131  {
    132132    $this->System->User = new User($this->System);
    133     if(isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check();
     133    if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check();
    134134    $this->System->RegisterPage('userlist', 'PageUserList');
    135135    $this->System->RegisterPage('user', 'PageUser');
     
    287287  function TopBarCallback()
    288288  {
    289     if($this->System->User->User['Id'] == null)
     289    if ($this->System->User->User['Id'] == null)
    290290    {
    291291      $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '.
     
    298298      //   <a href="'.$this->System->Link('/?Action=UserOptions').'">Nastavení</a>';
    299299    }
    300     return($Output);
     300    return $Output;
    301301  }
    302302}
  • trunk/Modules/User/UserList.php

    r1 r7  
    99  function Show()
    1010  {
    11     if(!$this->System->User->CheckPermission('User', 'ShowList'))
    12       return('Nemáte oprávnění');
     11    if (!$this->System->User->CheckPermission('User', 'ShowList'))
     12      return 'Nemáte oprávnění';
    1313
    1414    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `User`');
     
    3030
    3131    $DbResult = $this->Database->query($Query);
    32     while($User = $DbResult->fetch_assoc())
     32    while ($User = $DbResult->fetch_assoc())
    3333    {
    3434      $Devices = array();
    3535      $DbResult2 = $this->Database->query('SELECT `Id` FROM `Member` WHERE `Member`.`ResponsibleUser` = '.$User['Id']);
    36       while($Member = $DbResult2->fetch_assoc())
     36      while ($Member = $DbResult2->fetch_assoc())
    3737      {
    3838        $DbResult3 = $this->Database->query('SELECT `Name`, `Id` FROM `NetworkDevice` '.
    3939          'WHERE `Member` = '.$Member['Id'].' AND `Used`=1 ORDER BY `Name`');
    40         while($Device = $DbResult3->fetch_assoc())
     40        while ($Device = $DbResult3->fetch_assoc())
    4141        {
    4242          $Devices[] = $Device['Name'];
     
    5252    $Output .= $PageList['Output'];
    5353
    54     return($Output);
     54    return $Output;
    5555  }
    5656}
  • trunk/Modules/User/UserModel.php

    r6 r7  
    3232  function Hash($Password, $Salt)
    3333  {
    34     return(sha1(sha1($Password).$Salt));
     34    return sha1(sha1($Password).$Salt);
    3535  }
    3636
    3737  function Verify($Password, $Salt, $StoredHash)
    3838  {
    39     return($this->Hash($Password, $Salt) == $StoredHash);
     39    return $this->Hash($Password, $Salt) == $StoredHash;
    4040  }
    4141
     
    7373    // Lookup user record
    7474    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    75     if($Query->num_rows > 0)
     75    if ($Query->num_rows > 0)
    7676    {
    7777      // Refresh time of last access
     
    8383
    8484    // Logged permanently?
    85     if(array_key_exists('LoginHash', $_COOKIE))
     85    if (array_key_exists('LoginHash', $_COOKIE))
    8686    {
    8787      $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId'].
    8888        ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"');
    89       if($DbResult->num_rows > 0)
     89      if ($DbResult->num_rows > 0)
    9090      {
    9191        $DbRow = $DbResult->fetch_assoc();
    92         if(sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash'])
     92        if (sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash'])
    9393        {
    9494          $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"');
     
    101101    $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"');
    102102    $Row = $Query->fetch_assoc();
    103     if($Row['User'] != '')
     103    if ($Row['User'] != '')
    104104    {
    105105      $Query = $this->Database->query('SELECT `User`.* FROM `User` '.
     
    116116    // Remove nonactive users
    117117    $DbResult = $this->Database->select('UserOnline', '`Id`, `User`', '(`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.$this->OnlineStateTimeout.' SECOND)) AND (`StayLogged` = 0)');
    118     while($DbRow = $DbResult->fetch_array())
     118    while ($DbRow = $DbResult->fetch_array())
    119119    {
    120120      $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']);
    121       if(($DbRow['User'] != null) and $this->System->ModuleManager->ModulePresent('Log'))
     121      if (($DbRow['User'] != null) and $this->System->ModuleManager->ModulePresent('Log'))
    122122        $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');
    123123    }
     
    130130  function Register($Login, $Password, $Password2, $Email, $Name)
    131131  {
    132     if(($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '')  || ($Name == '')) $Result = DATA_MISSING;
    133     else if($Password != $Password2) $Result = PASSWORDS_UNMATCHED;
     132    if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '')  || ($Name == '')) $Result = DATA_MISSING;
     133    else if ($Password != $Password2) $Result = PASSWORDS_UNMATCHED;
    134134    else
    135135    {
    136136      // Is user registred yet?
    137137      $Query = $this->Database->select('User', '*', 'Login = "'.$Login.'"');
    138       if($Query->num_rows > 0) $Result = LOGIN_USED;
     138      if ($Query->num_rows > 0) $Result = LOGIN_USED;
    139139      else
    140140      {
    141141        $Query = $this->Database->select('User', '*', 'Name = "'.$Name.'"');
    142         if($Query->num_rows > 0) $Result = NAME_USED;
     142        if ($Query->num_rows > 0) $Result = NAME_USED;
    143143        else
    144144        {
    145145          $Query = $this->Database->select('User', '*', 'Email = "'.$Email.'"');
    146           if($Query->num_rows > 0) $Result = EMAIL_USED;
     146          if ($Query->num_rows > 0) $Result = EMAIL_USED;
    147147          else
    148148          {
     
    175175
    176176            $Result = USER_REGISTRATED;
    177             if($this->System->ModuleManager->ModulePresent('Log'))
     177            if ($this->System->ModuleManager->ModulePresent('Log'))
    178178              $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);
    179179          }
     
    181181      }
    182182    }
    183     return($Result);
     183    return $Result;
    184184  }
    185185
     
    187187  {
    188188    $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id);
    189     if($DbResult->num_rows > 0)
     189    if ($DbResult->num_rows > 0)
    190190    {
    191191      $Row = $DbResult->fetch_array();
    192192      $NewPassword = substr(sha1(strtoupper($Row['Login'])), 0, 7);
    193       if($Hash == $NewPassword)
     193      if ($Hash == $NewPassword)
    194194      {
    195195        $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0));
    196196        $Output = USER_REGISTRATION_CONFIRMED;
    197         if($this->System->ModuleManager->ModulePresent('Log'))
     197        if ($this->System->ModuleManager->ModulePresent('Log'))
    198198          $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'Login='.
    199199            $Row['Login'].', Id='.$Row['Id']);
    200200      } else $Output = PASSWORDS_UNMATCHED;
    201201    } else $Output = USER_NOT_FOUND;
    202     return($Output);
     202    return $Output;
    203203  }
    204204
    205205  function Login($Login, $Password, $StayLogged = false)
    206206  {
    207     if($StayLogged) $StayLogged = 1; else $StayLogged = 0;
     207    if ($StayLogged) $StayLogged = 1; else $StayLogged = 0;
    208208    $SID = session_id();
    209209    $Query = $this->Database->select('User', '*', 'Login="'.$Login.'"');
    210     if($Query->num_rows > 0)
     210    if ($Query->num_rows > 0)
    211211    {
    212212      $Row = $Query->fetch_assoc();
    213213      $PasswordHash = new PasswordHash();
    214       if(!$PasswordHash->Verify($Password, $Row['Salt'], $Row['Password'])) $Result = BAD_PASSWORD;
    215       else if($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED;
     214      if (!$PasswordHash->Verify($Password, $Row['Salt'], $Row['Password'])) $Result = BAD_PASSWORD;
     215      else if ($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED;
    216216      else
    217217      {
     
    222222        $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array(
    223223          'User' => $Row['Id'], 'StayLogged' => $StayLogged, 'StayLoggedHash' => $StayLoggedSalt));
    224         if($StayLogged)
     224        if ($StayLogged)
    225225        {
    226226          setcookie('LoginUserId', $Row['Id'], time()+365*24*60*60, $this->System->Link('/'));
     
    233233        $Result = USER_LOGGED_IN;
    234234        $this->Check();
    235         if(array_key_exists('Log', $this->System->ModuleManager->Modules))
     235        if (array_key_exists('Log', $this->System->ModuleManager->Modules))
    236236          $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress()));
    237237      }
    238238    } else $Result = USER_NOT_REGISTRED;
    239     return($Result);
     239    return $Result;
    240240  }
    241241
     
    244244    $SID = session_id();
    245245    $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => null));
    246     if($this->System->ModuleManager->ModulePresent('Log'))
     246    if ($this->System->ModuleManager->ModulePresent('Log'))
    247247      $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']);
    248248    $this->Check();
    249     return(USER_LOGGED_OUT);
     249    return USER_LOGGED_OUT;
    250250  }
    251251
     
    254254    $this->Roles = array();
    255255    $DbResult = $this->Database->select('UserRole', '*');
    256     while($DbRow = $DbResult->fetch_array())
     256    while ($DbRow = $DbResult->fetch_array())
    257257      $this->Roles[] = $DbRow;
    258258  }
     
    262262    $this->User['Permission'] = array();
    263263    $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description` FROM `UserRolePermission` JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` WHERE `UserRolePermission`.`Role` = '.$Role);
    264     if($DbResult->num_rows > 0)
    265     while($DbRow = $DbResult->fetch_array())
     264    if ($DbResult->num_rows > 0)
     265    while ($DbRow = $DbResult->fetch_array())
    266266      $this->User['Permission'][$DbRow['Operation']] = $DbRow;
    267267  }
     
    271271    $Result = array();
    272272    $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description`, `UserRole`.`Title` FROM `UserRolePermission` LEFT JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` LEFT JOIN `UserRole` ON `UserRole`.`Id` = `UserRolePermission`.`Role`');
    273     while($DbRow = $DbResult->fetch_array())
     273    while ($DbRow = $DbResult->fetch_array())
    274274    {
    275275      $Value = '';
    276       if($DbRow['Read']) $Value .= 'R';
    277       if($DbRow['Write']) $Value .= 'W';
     276      if ($DbRow['Read']) $Value .= 'R';
     277      if ($DbRow['Write']) $Value .= 'W';
    278278      $Result[$DbRow['Description']][$DbRow['Title']] = $Value;
    279279    }
    280     return($Result);
     280    return $Result;
    281281  }
    282282
     
    285285    $PermissionExists = false;
    286286    // First try to check cache group-group relation
    287     if(array_key_exists($GroupId, $this->PermissionGroupCache))
     287    if (array_key_exists($GroupId, $this->PermissionGroupCache))
    288288    {
    289289      $PermissionExists = true;
     
    294294        '") AND (`AssignedGroup` IS NOT NULL)');
    295295      $DbRow = array();
    296       while($DbRow[] = $DbResult->fetch_array());
     296      while ($DbRow[] = $DbResult->fetch_array());
    297297        $this->PermissionGroupCache[$GroupId] = $DbRow;
    298298      $PermissionExists = true;
    299299    }
    300     if($PermissionExists)
    301     {
    302       foreach($this->PermissionGroupCache[$GroupId] as $DbRow)
    303       {
    304         if($DbRow['AssignedGroup'] != '')
    305         if($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);
     300    if ($PermissionExists)
     301    {
     302      foreach ($this->PermissionGroupCache[$GroupId] as $DbRow)
     303      {
     304        if ($DbRow['AssignedGroup'] != '')
     305        if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return true;
    306306      }
    307307    }
    308308
    309309    // Check group-operation relation
    310     if(array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp))
     310    if (array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp))
    311311    {
    312312      $PermissionExists = true;
     
    315315      // If no permission combination exists in cache, do new check of database items
    316316      $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedOperation`="'.$OperationId.'"');
    317       if($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true;
     317      if ($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true;
    318318        else $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = false;
    319319      $PermissionExists = true;
    320320    }
    321     if($PermissionExists)
    322     {
    323       return($this->PermissionGroupCacheOp[$GroupId.','.$OperationId]);
    324     }
    325     return(false);
     321    if ($PermissionExists)
     322    {
     323      return $this->PermissionGroupCacheOp[$GroupId.','.$OperationId];
     324    }
     325    return false;
    326326  }
    327327
     
    330330    // Get module id
    331331    $DbResult = $this->Database->select('Module', 'Id', '`Name`="'.$Module.'"');
    332     if($DbResult->num_rows > 0)
     332    if ($DbResult->num_rows > 0)
    333333    {
    334334      $DbRow = $DbResult->fetch_assoc();
    335335      $ModuleId = $DbRow['Id'];
    336     } else return(false);
     336    } else return false;
    337337
    338338    // First try to check cache
    339     if(in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache))
     339    if (in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache))
    340340    {
    341341      $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemIndex), $this->PermissionCache);
     
    346346      $DbResult = $this->Database->select('PermissionOperation', 'Id', '(`Module`="'.$ModuleId.
    347347        '") AND (`Item`="'.$ItemType.'") AND (`ItemId`='.$ItemIndex.') AND (`Operation`="'.$Operation.'")');
    348       if($DbResult->num_rows > 0)
     348      if ($DbResult->num_rows > 0)
    349349      {
    350350        $DbRow = $DbResult->fetch_array();
     
    359359    }
    360360
    361     if($PermissionExists)
    362     {
    363       if($this->User['Id'] == null) $UserCondition = '(`User` IS NULL)';
     361    if ($PermissionExists)
     362    {
     363      if ($this->User['Id'] == null) $UserCondition = '(`User` IS NULL)';
    364364        else $UserCondition = '(`User`="'.$this->User['Id'].'")';
    365365      // Check user-operation relation
    366366      $DbResult = $this->Database->select('PermissionUserAssignment', '*', $UserCondition.' AND (`AssignedOperation`="'.$OperationId.'")');
    367       if($DbResult->num_rows > 0) return(true);
     367      if ($DbResult->num_rows > 0) return true;
    368368
    369369      // Check user-group relation
    370370      $DbResult = $this->Database->select('PermissionUserAssignment', 'AssignedGroup', $UserCondition);
    371       while($DbRow = $DbResult->fetch_array())
    372       {
    373        if($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);
    374       }
    375       return(false);
    376     } else return(false);
     371      while ($DbRow = $DbResult->fetch_array())
     372      {
     373       if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return true;
     374      }
     375      return false;
     376    } else return false;
    377377  }
    378378
     
    380380  {
    381381    $DbResult = $this->Database->select('User', 'Login, Name, Id, Email, Password', '`Login`="'.$Login.'" AND `Email`="'.$Email.'"');
    382     if($DbResult->num_rows > 0)
     382    if ($DbResult->num_rows > 0)
    383383    {
    384384      $Row = $DbResult->fetch_array();
     
    399399
    400400      $Output = USER_PASSWORD_RECOVERY_SUCCESS;
    401       if($this->System->ModuleManager->ModulePresent('Log'))
     401      if ($this->System->ModuleManager->ModulePresent('Log'))
    402402        $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);
    403403    } else $Output = USER_PASSWORD_RECOVERY_FAIL;
    404     return($Output);
     404    return $Output;
    405405  }
    406406
     
    408408  {
    409409    $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id);
    410     if($DbResult->num_rows > 0)
     410    if ($DbResult->num_rows > 0)
    411411    {
    412412      $Row = $DbResult->fetch_array();
    413413      $NewPassword2 = substr(sha1(strtoupper($Row['Login'])), 0, 7);
    414       if(($NewPassword == $NewPassword2) and ($Hash == $Row['Password']))
     414      if (($NewPassword == $NewPassword2) and ($Hash == $Row['Password']))
    415415      {
    416416        $PasswordHash = new PasswordHash();
     
    418418        $this->Database->update('User', 'Id='.$Row['Id'], array('Password' => $PasswordHash->Hash($NewPassword, $Salt),
    419419          'Salt' => $Salt, 'Locked' => 0));
    420         if($this->System->ModuleManager->ModulePresent('Log'))
     420        if ($this->System->ModuleManager->ModulePresent('Log'))
    421421          $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']);
    422422      } else $Output = PASSWORDS_UNMATCHED;
    423423    } else $Output = USER_NOT_FOUND;
    424     return($Output);
     424    return $Output;
    425425  }
    426426
     
    428428  {
    429429    $DbResult = $this->Database->select('APIToken', 'User', '`Token`="'.$Token.'"');
    430     if($DbResult->num_rows > 0)
     430    if ($DbResult->num_rows > 0)
    431431    {
    432432      $DbRow = $DbResult->fetch_assoc();
    433433      $User = new User($this->System);
    434434      $User->User = array('Id' => $DbRow['User']);
    435       return($User->CheckPermission($Module, $Operation));
    436     } else return(false);
     435      return $User->CheckPermission($Module, $Operation);
     436    } else return false;
    437437  }
    438438}
  • trunk/Modules/User/UserPage.php

    r1 r7  
    99  function Panel($Title, $Content, $Menu = array())
    1010  {
    11     if(count($Menu) > 0)
    12       foreach($Menu as $Item)
     11    if (count($Menu) > 0)
     12      foreach ($Menu as $Item)
    1313        $Title .= '<div class="Action">'.$Item.'</div>';
    14     return('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');
     14    return '<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>';
    1515  }
    1616
     
    3939
    4040    $DbResult = $this->Database->query($Query);
    41     while($Contact = $DbResult->fetch_assoc())
     41    while ($Contact = $DbResult->fetch_assoc())
    4242    {
    4343      $Output .= '<tr>'.
     
    5050    $Output .= $PageList['Output'];
    5151
    52     return($Output);
     52    return $Output;
    5353  }
    5454
     
    5656  {
    5757    $Output = '';
    58     if($this->System->User->User['Id'] != null)
     58    if ($this->System->User->User['Id'] != null)
    5959    {
    6060      $Actions = '';
    61       foreach($this->System->ModuleManager->Modules['User']->UserPanel as $Action)
    62       {
    63         if(is_string($Action[0]))
     61      foreach ($this->System->ModuleManager->Modules['User']->UserPanel as $Action)
     62      {
     63        if (is_string($Action[0]))
    6464        {
    6565          $Class = new $Action[0]($this->System);
     
    7171      $Output .= $this->Panel('Nabídka uživatele', $Actions);
    7272      $Output .= '</td><td style="vertical-align:top;">';
    73       if($this->System->User->User['Id'] != null)
     73      if ($this->System->User->User['Id'] != null)
    7474        {
    7575          $Form = new Form($this->System->FormManager);
     
    8585      $Output .= '</td></tr></table></div>';
    8686    } else $Output .= $this->SystemMessage('Oprávnění', 'Nejste přihlášen');
    87     return($Output);
     87    return $Output;
    8888  }
    8989
     
    9191  {
    9292    $Output = '';
    93     if(array_key_exists('Action', $_GET))
     93    if (array_key_exists('Action', $_GET))
    9494    {
    9595      $Action = $_GET['Action'];
    96       if($Action == 'LoginForm')
     96      if ($Action == 'LoginForm')
    9797      {
    9898        $Form = new Form($this->System->FormManager);
     
    103103        '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
    104104      } else
    105       if($Action == 'Login')
    106       {
    107         if(array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST))
     105      if ($Action == 'Login')
     106      {
     107        if (array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST))
    108108        {
    109109          $Form = new Form($this->System->FormManager);
    110110          $Form->SetClass('UserLogin');
    111111          $Form->OnSubmit = '?Action=Login';
    112           if(array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true;
     112          if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true;
    113113            else $StayLogged = false;
    114114          $Result = $this->System->User->Login($_POST['Username'], $_POST['Password'], $StayLogged);
    115115          $Output .= $this->SystemMessage('Přihlášení', $Result);
    116           if($Result <> USER_LOGGED_IN)
     116          if ($Result <> USER_LOGGED_IN)
    117117          {
    118118            $Form->LoadValuesFromForm();
     
    128128        } else $Output .= $this->SystemMessage('Přihlášení', 'Nezadány přihlašovací údaje');
    129129      } else
    130       if($Action == 'Logout')
    131       {
    132         if($this->System->User->User['Id'] != null)
     130      if ($Action == 'Logout')
     131      {
     132        if ($this->System->User->User['Id'] != null)
    133133        {
    134134          $Output .= $this->SystemMessage('Odhlášení', $this->System->User->Logout());
    135135        } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen');
    136136      } else
    137       if($Action == 'UserOptions')
    138       {
    139         if($this->System->User->User['Id'] != null)
     137      if ($Action == 'UserOptions')
     138      {
     139        if ($this->System->User->User['Id'] != null)
    140140        {
    141141          $Form = new Form($this->System->FormManager);
     
    146146        } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen');
    147147      } else
    148       if($Action == 'UserOptionsSave')
     148      if ($Action == 'UserOptionsSave')
    149149      {
    150150        $Form = new Form($this->System->FormManager);
     
    158158        $Output .= $Form->ShowEditForm();
    159159      } else
    160       if($Action == 'UserRegister')
     160      if ($Action == 'UserRegister')
    161161      {
    162162        $Form = new Form($this->System->FormManager);
     
    166166        $Output .= $Form->ShowEditForm();
    167167      } else
    168       if($Action == 'UserRegisterConfirm')
     168      if ($Action == 'UserRegisterConfirm')
    169169      {
    170170        $Output .= $this->SystemMessage('Potvrzení registrace',
    171171          $this->System->User->RegisterConfirm($_GET['User'], $_GET['H']));
    172172      } else
    173       if($Action == 'PasswordRecovery')
     173      if ($Action == 'PasswordRecovery')
    174174      {
    175175        $Form = new Form($this->System->FormManager);
     
    178178        $Output .= $Form->ShowEditForm();
    179179      } else
    180       if($Action == 'PasswordRecovery2')
     180      if ($Action == 'PasswordRecovery2')
    181181      {
    182182        $Form = new Form($this->System->FormManager);
     
    185185        $Result = $this->System->User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
    186186        $Output .= $this->SystemMessage('Obnova hesla', $Result);
    187         if($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
     187        if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
    188188        {
    189189          $Output .= $Form->ShowEditForm();
    190190        }
    191191      } else
    192       if($Action == 'PasswordRecoveryConfirm')
     192      if ($Action == 'PasswordRecoveryConfirm')
    193193      {
    194194        $Output .= $this->SystemMessage('Obnova hesla', $this->System->User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));
    195195      } else
    196       if($Action == 'UserRegisterSave')
     196      if ($Action == 'UserRegisterSave')
    197197      {
    198198        $Form = new Form($this->System->FormManager);
     
    202202          $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']);
    203203        $Output .= $this->SystemMessage('Registrace nového účtu', $Result);
    204         if($Result <> USER_REGISTRATED)
     204        if ($Result <> USER_REGISTRATED)
    205205        {
    206206          $Form->OnSubmit = '?Action=UserRegisterSave';
     
    208208        }
    209209      } else
    210       if($Action == 'UserMenu')
     210      if ($Action == 'UserMenu')
    211211      {
    212212        $Output = $this->ShowUserPanel();
    213213      } else $Output = $this->ShowMain();
    214214    } else $Output = $this->ShowMain();
    215     return($Output);
     215    return $Output;
    216216  }
    217217
     
    219219  {
    220220    $Output = 'Nebyla vybrána akce';
    221     return($Output);
     221    return $Output;
    222222  }
    223223}
  • trunk/Packages/Common/AppModule.php

    r1 r7  
    7777  function Install()
    7878  {
    79     if($this->Installed) return;
     79    if ($this->Installed) return;
    8080    $List = array();
    8181    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotInstalled));
     
    8989  function Uninstall()
    9090  {
    91     if(!$this->Installed) return;
     91    if (!$this->Installed) return;
    9292    $this->Stop();
    9393    $this->Installed = false;
     
    100100  function Upgrade()
    101101  {
    102     if(!$this->Installed) return;
    103     if($this->InstalledVersion == $this->Version) return;
     102    if (!$this->Installed) return;
     103    if ($this->InstalledVersion == $this->Version) return;
    104104    $List = array();
    105105    $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed));
     
    117117  function Start()
    118118  {
    119     if($this->Running) return;
    120     if(!$this->Installed) return;
     119    if ($this->Running) return;
     120    if (!$this->Installed) return;
    121121    $List = array();
    122122    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotRunning));
     
    128128  function Stop()
    129129  {
    130     if(!$this->Running) return;
     130    if (!$this->Running) return;
    131131    $this->Running = false;
    132132    $List = array();
     
    144144  function Enable()
    145145  {
    146     if($this->Enabled) return;
    147     if(!$this->Installed) return;
     146    if ($this->Enabled) return;
     147    if (!$this->Installed) return;
    148148    $List = array();
    149149    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotEnabled));
     
    154154  function Disable()
    155155  {
    156     if(!$this->Enabled) return;
     156    if (!$this->Enabled) return;
    157157    $this->Stop();
    158158    $this->Enabled = false;
     
    203203  function Perform($List, $Actions, $Conditions = array(ModuleCondition::All))
    204204  {
    205     foreach($List as $Index => $Module)
    206     {
    207       if(in_array(ModuleCondition::All, $Conditions) or
     205    foreach ($List as $Index => $Module)
     206    {
     207      if (in_array(ModuleCondition::All, $Conditions) or
    208208        ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
    209209        (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or
     
    213213        (!$Module->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions)))
    214214      {
    215         foreach($Actions as $Action)
     215        foreach ($Actions as $Action)
    216216        {
    217           if($Action == ModuleAction::Start) $Module->Start();
    218           if($Action == ModuleAction::Stop) $Module->Stop();
    219           if($Action == ModuleAction::Install) $Module->Install();
    220           if($Action == ModuleAction::Uninstall) $Module->Uninstall();
    221           if($Action == ModuleAction::Enable) $Module->Enable();
    222           if($Action == ModuleAction::Disable) $Module->Disable();
    223           if($Action == ModuleAction::Upgrade) $Module->Upgrade();
     217          if ($Action == ModuleAction::Start) $Module->Start();
     218          if ($Action == ModuleAction::Stop) $Module->Stop();
     219          if ($Action == ModuleAction::Install) $Module->Install();
     220          if ($Action == ModuleAction::Uninstall) $Module->Uninstall();
     221          if ($Action == ModuleAction::Enable) $Module->Enable();
     222          if ($Action == ModuleAction::Disable) $Module->Disable();
     223          if ($Action == ModuleAction::Upgrade) $Module->Upgrade();
    224224        }
    225225      }
     
    229229  function EnumDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All))
    230230  {
    231     foreach($Module->Dependencies as $Dependency)
    232     {
    233       if(!array_key_exists($Dependency, $this->Modules))
     231    foreach ($Module->Dependencies as $Dependency)
     232    {
     233      if (!array_key_exists($Dependency, $this->Modules))
    234234        throw new Exception(sprintf(T('Module "%s" dependency "%s" not found'), $Module->Name, $Dependency));
    235235      $DepModule = $this->Modules[$Dependency];
    236       if(in_array(ModuleCondition::All, $Conditions) or
     236      if (in_array(ModuleCondition::All, $Conditions) or
    237237        ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
    238238        (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or
     
    250250  function EnumSuperiorDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All))
    251251  {
    252     foreach($this->Modules as $RefModule)
    253     {
    254       if(in_array($Module->Name, $RefModule->Dependencies) and
     252    foreach ($this->Modules as $RefModule)
     253    {
     254      if (in_array($Module->Name, $RefModule->Dependencies) and
    255255          (in_array(ModuleCondition::All, $Conditions) or
    256256          ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
     
    270270  {
    271271    $this->LoadModules();
    272     if(file_exists($this->FileName)) $this->LoadState();
     272    if (file_exists($this->FileName)) $this->LoadState();
    273273    $this->StartEnabled();
    274274  }
     
    315315  function ModulePresent($Name)
    316316  {
    317     return(array_key_exists($Name, $this->Modules));
     317    return array_key_exists($Name, $this->Modules);
    318318  }
    319319
    320320  function ModuleEnabled($Name)
    321321  {
    322     return(array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled);
     322    return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled;
    323323  }
    324324
    325325  function ModuleRunning($Name)
    326326  {
    327     return(array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running);
     327    return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running;
    328328  }
    329329
     
    331331  function SearchModuleById($Id)
    332332  {
    333     foreach($this->Modules as $Module)
     333    foreach ($this->Modules as $Module)
    334334    {
    335335      //DebugLog($Module->Name.' '.$Module->Id);
    336       if($Module->Id == $Id) return($Module->Name);
    337     }
    338     return('');
     336      if ($Module->Id == $Id) return $Module->Name;
     337    }
     338    return '';
    339339  }
    340340
     
    343343    $ConfigModules = array();
    344344    include($this->FileName);
    345     foreach($ConfigModules as $Mod)
    346     {
    347       if(array_key_exists($Mod['Name'], $this->Modules))
     345    foreach ($ConfigModules as $Mod)
     346    {
     347      if (array_key_exists($Mod['Name'], $this->Modules))
    348348      {
    349349        $this->Modules[$Mod['Name']] = $this->Modules[$Mod['Name']];
     
    358358  {
    359359    $Data = array();
    360     foreach($this->Modules as $Module)
     360    foreach ($this->Modules as $Module)
    361361    {
    362362      $Data[] = array('Name' => $Module->Name, 'Enabled' => $Module->Enabled,
     
    381381  {
    382382    $List = scandir($Directory);
    383     foreach($List as $Item)
    384     {
    385       if(is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn'))
     383    foreach ($List as $Item)
     384    {
     385      if (is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn'))
    386386      {
    387387        include_once($Directory.'/'.$Item.'/'.$Item.'.php');
     
    394394  function LoadModules()
    395395  {
    396     if(method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))
     396    if (method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))
    397397      $this->OnLoadModules();
    398398    else $this->LoadModulesFromDir($this->ModulesDir);
  • trunk/Packages/Common/Common.php

    r1 r7  
    6060
    6161    $Result = '';
    62     if(array_key_exists('all', $QueryItems))
     62    if (array_key_exists('all', $QueryItems))
    6363    {
    6464      $PageCount = 1;
     
    7171    }
    7272
    73     if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
    74     if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
    75     if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
    76     if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
     73    if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
     74    if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
     75    if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
     76    if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
    7777    $CurrentPage = $_SESSION['Page'];
    7878
     
    8080
    8181    $Result = '';
    82     if($PageCount > 1)
     82    if ($PageCount > 1)
    8383    {
    84       if($CurrentPage > 0)
     84      if ($CurrentPage > 0)
    8585      {
    8686        $QueryItems['page'] = 0;
     
    9191      $PagesMax = $PageCount - 1;
    9292      $PagesMin = 0;
    93       if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
    94       if($PagesMin < ($CurrentPage - $Around))
     93      if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
     94      if ($PagesMin < ($CurrentPage - $Around))
    9595      {
    9696        $Result.= ' ... ';
    9797        $PagesMin = $CurrentPage - $Around;
    9898      }
    99       for($i = $PagesMin; $i <= $PagesMax; $i++)
     99      for ($i = $PagesMin; $i <= $PagesMax; $i++)
    100100      {
    101         if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
     101        if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
    102102        else {
    103103         $QueryItems['page'] = $i;
     
    105105        }
    106106      }
    107       if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
    108       if($CurrentPage < ($PageCount - 1))
     107      if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
     108      if ($CurrentPage < ($PageCount - 1))
    109109      {
    110110        $QueryItems['page'] = ($CurrentPage + 1);
     
    115115    }
    116116    $QueryItems['all'] = '1';
    117     if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
     117    if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
    118118
    119119    $Result = '<div style="text-align: center">'.$Result.'</div>';
    120120    $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage;
    121121    $this->Page = $CurrentPage;
    122     return($Result);
     122    return $Result;
    123123  }
    124124}
  • trunk/Packages/Common/Config.php

    r1 r7  
    1212  function ReadValue($Name)
    1313  {
    14     if(!is_array($Name)) $Name = explode('/', $Name);
     14    if (!is_array($Name)) $Name = explode('/', $Name);
    1515    $Last = array_pop($Name);
    1616    $Data = &$this->Data;
    17     foreach($Name as $Item)
     17    foreach ($Name as $Item)
    1818    {
    1919      $Data = &$Data[$Item];
    2020    }
    21     return($Data[$Last]);
     21    return $Data[$Last];
    2222  }
    2323
    2424  function WriteValue($Name, $Value)
    2525  {
    26     if(!is_array($Name)) $Name = explode('/', $Name);
     26    if (!is_array($Name)) $Name = explode('/', $Name);
    2727    $Last = array_pop($Name);
    2828    $Data = &$this->Data;
    29     foreach($Name as $Item)
     29    foreach ($Name as $Item)
    3030    {
    3131      $Data = &$Data[$Item];
     
    3838    $ConfigData = array();
    3939    include $FileName;
    40     foreach($this->Data as $Index => $Item)
     40    foreach ($this->Data as $Index => $Item)
    4141    {
    42       if(array_key_exits($Index, $ConfigData))
     42      if (array_key_exits($Index, $ConfigData))
    4343        $this->Data[$Index] = $ConfigData[$Index];
    4444    }
     
    5252  function GetAsArray()
    5353  {
    54     return($this->Data);
     54    return $this->Data;
    5555  }
    5656}
  • trunk/Packages/Common/Database.php

    r1 r7  
    1111  function fetch_assoc()
    1212  {
    13     return($this->PDOStatement->fetch(PDO::FETCH_ASSOC));
     13    return $this->PDOStatement->fetch(PDO::FETCH_ASSOC);
    1414  }
    1515
    1616  function fetch_array()
    1717  {
    18     return($this->PDOStatement->fetch(PDO::FETCH_BOTH));
     18    return $this->PDOStatement->fetch(PDO::FETCH_BOTH);
    1919  }
    2020
    2121  function fetch_row()
    2222  {
    23     return($this->PDOStatement->fetch(PDO::FETCH_NUM));
     23    return $this->PDOStatement->fetch(PDO::FETCH_NUM);
    2424  }
    2525}
     
    5454  function Connect($Host, $User, $Password, $Database)
    5555  {
    56     if($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;
    57       else if($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host;
     56    if ($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;
     57      else if ($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host;
    5858      else $ConnectionString = '';
    5959    try {
     
    7474  function Connected()
    7575  {
    76     return(isset($this->PDO));
     76    return isset($this->PDO);
    7777  }
    7878
     
    8484  function query($Query)
    8585  {
    86     if(!$this->Connected()) throw new Exception(T('Not connected to database'));
    87     if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime();
     86    if (!$this->Connected()) throw new Exception(T('Not connected to database'));
     87    if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime();
    8888    $this->LastQuery = $Query;
    89     if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))
     89    if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))
    9090      $Duration = ' ; '.round(microtime() - $QueryStartTime, 4). ' s';
    91     if($this->LogSQLQuery == true)
     91    if ($this->LogSQLQuery == true)
    9292      file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);
    93     if($this->ShowSQLQuery == true)
     93    if ($this->ShowSQLQuery == true)
    9494      echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '.
    9595      'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n");
    9696    $Result = new DatabaseResult();
    9797    $Result->PDOStatement = $this->PDO->query($Query);
    98     if($Result->PDOStatement)
     98    if ($Result->PDOStatement)
    9999    {
    100100      $Result->num_rows = $Result->PDOStatement->rowCount();
     
    104104      $this->Error = $this->PDO->errorInfo();
    105105      $this->Error = $this->Error[2];
    106       if(($this->Error != '') and ($this->ShowSQLError == true))
     106      if (($this->Error != '') and ($this->ShowSQLError == true))
    107107        echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
    108108        throw new Exception('SQL Error: '.$this->Error.', Query: '.$Query);
    109109    }
    110     return($Result);
     110    return $Result;
    111111  }
    112112
    113113  function select($Table, $What = '*', $Condition = 1)
    114114  {
    115     return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition));
     115    return $this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition);
    116116  }
    117117
     
    125125    $Name = '';
    126126    $Values = '';
    127     foreach($Data as $Key => $Value)
     127    foreach ($Data as $Key => $Value)
    128128    {
    129129      $Name .= ',`'.$Key.'`';
    130       if(!in_array($Value, $this->Functions))
     130      if (!in_array($Value, $this->Functions))
    131131      {
    132         if(is_null($Value)) $Value = 'NULL';
     132        if (is_null($Value)) $Value = 'NULL';
    133133        else $Value = $this->PDO->quote($Value);
    134134      }
     
    144144  {
    145145    $Values = '';
    146     foreach($Data as $Key => $Value)
    147     {
    148       if(!in_array($Value, $this->Functions))
     146    foreach ($Data as $Key => $Value)
     147    {
     148      if (!in_array($Value, $this->Functions))
    149149      {
    150         if(is_null($Value)) $Value = 'NULL';
     150        if (is_null($Value)) $Value = 'NULL';
    151151        else $Value = $this->PDO->quote($Value);
    152152      }
     
    161161    $Name = '';
    162162    $Values = '';
    163     foreach($Data as $Key => $Value)
    164     {
    165       if(!in_array($Value, $this->Functions))
     163    foreach ($Data as $Key => $Value)
     164    {
     165      if (!in_array($Value, $this->Functions))
    166166      {
    167         if(is_null($Value)) $Value = 'NULL';
     167        if (is_null($Value)) $Value = 'NULL';
    168168        else $Value = $this->PDO->quote($Value);
    169169      }
     
    185185  function real_escape_string($Text)
    186186  {
    187     return(addslashes($Text));
     187    return addslashes($Text);
    188188  }
    189189
    190190  function quote($Text)
    191191  {
    192     return($this->PDO->quote($Text));
     192    return $this->PDO->quote($Text);
    193193  }
    194194
     
    205205function TimeToMysqlDateTime($Time)
    206206{
    207   if($Time == NULL) return(NULL);
    208     else return(date('Y-m-d H:i:s', $Time));
     207  if ($Time == NULL) return NULL;
     208    else return date('Y-m-d H:i:s', $Time);
    209209}
    210210
    211211function TimeToMysqlDate($Time)
    212212{
    213   if($Time == NULL) return(NULL);
    214     else return(date('Y-m-d', $Time));
     213  if ($Time == NULL) return NULL;
     214    else return date('Y-m-d', $Time);
    215215}
    216216
    217217function TimeToMysqlTime($Time)
    218218{
    219   if($Time == NULL) return(NULL);
    220     else return(date('H:i:s', $Time));
     219  if ($Time == NULL) return NULL;
     220    else return date('H:i:s', $Time);
    221221}
    222222
    223223function MysqlDateTimeToTime($DateTime)
    224224{
    225   if($DateTime == '') return(NULL);
     225  if ($DateTime == '') return NULL;
    226226  $Parts = explode(' ', $DateTime);
    227227  $DateParts = explode('-', $Parts[0]);
    228228  $TimeParts = explode(':', $Parts[1]);
    229229  $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
    230   return($Result);
     230  return $Result;
    231231}
    232232
    233233function MysqlDateToTime($Date)
    234234{
    235   if($Date == '') return(NULL);
    236   return(MysqlDateTimeToTime($Date.' 0:0:0'));
     235  if ($Date == '') return NULL;
     236  return MysqlDateTimeToTime($Date.' 0:0:0');
    237237}
    238238
    239239function MysqlTimeToTime($Time)
    240240{
    241   if($Time == '') return(NULL);
    242   return(MysqlDateTimeToTime('0000-00-00 '.$Time));
    243 }
     241  if ($Time == '') return NULL;
     242  return MysqlDateTimeToTime('0000-00-00 '.$Time);
     243}
  • trunk/Packages/Common/Error.php

    r1 r7  
    4545    );
    4646
    47     if(($this->UserErrors & $Number))
     47    if (($this->UserErrors & $Number))
    4848    {
    4949      // Error was suppressed with the @-operator
    50       if(0 === error_reporting())
     50      if (0 === error_reporting())
    5151      {
    5252        return false;
     
    5858      $Backtrace[0]['line'] = $LineNumber;
    5959      $this->Report($Backtrace);
    60       //if((E_ERROR | E_PARSE) & $Number)
     60      //if ((E_ERROR | E_PARSE) & $Number)
    6161      die();
    6262    }
     
    8282      'An internal error occurred!<br/>'.
    8383      'Administrator will be notified and the problem will be investigated and fixed soon.'.'<br/><br/>';
    84     if($this->ShowError == true)
     84    if ($this->ShowError == true)
    8585      $Output .= '<pre>'.$Message.'</pre><br/>';
    8686    $Output .= '</body></html>';
     
    9292    $Date = date('Y-m-d H:i:s');
    9393    $Error = '# '.$Date."\n";
    94     foreach($Backtrace as $Item)
     94    foreach ($Backtrace as $Item)
    9595    {
    96       if(!array_key_exists('line', $Item)) $Item['line'] = '';
    97       if(!array_key_exists('file', $Item)) $Item['file'] = '';
     96      if (!array_key_exists('line', $Item)) $Item['line'] = '';
     97      if (!array_key_exists('file', $Item)) $Item['file'] = '';
    9898
    9999      $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
    100100      $Arguments = '';
    101       if(array_key_exists('args', $Item) and is_array($Item['args']))
    102         foreach($Item['args'] as $Item)
     101      if (array_key_exists('args', $Item) and is_array($Item['args']))
     102        foreach ($Item['args'] as $Item)
    103103        {
    104           if(is_object($Item)) ;
    105           else if(is_array($Item)) $Arguments .= "'".serialize($Item)."',";
     104          if (is_object($Item)) ;
     105          else if (is_array($Item)) $Arguments .= "'".serialize($Item)."',";
    106106          else $Arguments .= "'".$Item."',";
    107107        }
    108         if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
     108        if (strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
    109109        $Error .= "\n";
    110110    }
    111111    $Error .= "\n";
    112112
    113     foreach($this->OnError as $OnError)
     113    foreach ($this->OnError as $OnError)
    114114      call_user_func($OnError, $Error);
    115115  }
  • trunk/Packages/Common/Form/Form.php

    r1 r7  
    4444  { 
    4545    $Result = '<table class="BasicTable">';
    46     if(array_key_exists('Header', $Table))
     46    if (array_key_exists('Header', $Table))
    4747    {
    4848      $Result .= '<tr>';
    49       foreach($Table['Header'] as $Item)
     49      foreach ($Table['Header'] as $Item)
    5050        $Result .= '<th>'.$Item.'</th>';
    5151      $Result .= '</tr>';
    5252    }
    53     foreach($Table['Rows'] as $Row)
     53    foreach ($Table['Rows'] as $Row)
    5454    {
    5555      $Result .= '<tr>';
    56       foreach($Row as $Index => $Item)
    57       {
    58         if($Index == 0) $Class = ' class="Header"'; else $Class = '';
     56      foreach ($Row as $Index => $Item)
     57      {
     58        if ($Index == 0) $Class = ' class="Header"'; else $Class = '';
    5959        $Result .= '<td'.$Class.' style="width: '.(floor(100 / count($Row))).'%">'.$Item.'</td>';
    6060      }
     
    6262    }
    6363    $Result .= '</table>';
    64     return($Result);
     64    return $Result;
    6565  }
    6666
    6767  function LoadDefaults()
    6868  {
    69     foreach($this->Definition['Items'] as $Index => $Item)
    70     if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     69    foreach ($this->Definition['Items'] as $Index => $Item)
     70    if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    7171    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    7272    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    7373    {
    74       if(!array_key_exists($Index, $this->Values) and isset($Item['Default']))
     74      if (!array_key_exists($Index, $this->Values) and isset($Item['Default']))
    7575        $this->Values[$Index] = $Item['Default'];
    7676    }
     
    8686  {
    8787    $Item = $this->Definition['Items'][$Index];
    88     if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    89     {
    90       if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     88    if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     89    {
     90      if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    9191        $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]);
    92       if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     92      if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    9393        $UseType = 'OneToMany';
    94       else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     94      else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    9595        $UseType = 'Enumeration';
    9696    } else $UseType = $Item['Type'];
     
    107107      'Rows' => array(),
    108108    );
    109     foreach($this->Definition['Items'] as $Index => $Item)
    110     if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
    111     if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     109    foreach ($this->Definition['Items'] as $Index => $Item)
     110    if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
     111    if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    112112    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    113113    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    114114    {
    115       if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    116       {
    117         if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     115      if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     116      {
     117        if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    118118          $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]);
    119         if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     119        if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    120120          $UseType = 'OneToMany';
    121         else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     121        else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    122122          $UseType = 'Enumeration';
    123123      } else $UseType = $Item['Type'];
     
    126126        'Type' => $Item['Type'], 'Values' => $this->Values,
    127127        'Filter' => $this->ValuesFilter[$Index]));
    128       if(array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix'];
    129       if(!$this->FormManager->Type->IsHidden($UseType))
     128      if (array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix'];
     129      if (!$this->FormManager->Type->IsHidden($UseType))
    130130        array_push($Table['Rows'], array($Item['Caption'].':', $Edit));
    131131    }
    132132    $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.$this->Table($Table).
    133133    '</fieldset>';
    134     return($Output);
     134    return $Output;
    135135  }
    136136
    137137  function ShowEditForm()
    138138  {
    139     if(!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';
     139    if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';
    140140    $Output = '<form enctype="multipart/form-data" class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock().
    141141      '<div><input name="submit" type="submit" value="'.$this->Definition['SubmitText'].'" /> '.
    142142      '<input type="button" value="Zrušit" onclick="location.href=\'?\'"/></div></form>';
    143     return($Output);
     143    return $Output;
    144144  }
    145145
     
    152152      'Rows' => array(),
    153153    );
    154     if($Context != '') $Context = $Context.'-';
    155     foreach($this->Definition['Items'] as $Index => $Item)
    156     {
    157       if(!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false;
    158     if($Item['ReadOnly'] == false)
    159     if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
    160     if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     154    if ($Context != '') $Context = $Context.'-';
     155    foreach ($this->Definition['Items'] as $Index => $Item)
     156    {
     157      if (!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false;
     158    if ($Item['ReadOnly'] == false)
     159    if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
     160    if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    161161    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    162162    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
     
    164164        $Parameters = array('Value' => $this->Values[$Index], 'Name' => $Index,
    165165            'Type' => $Item['Type'], 'Values' => $this->Values);
    166         if(array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];
     166        if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];
    167167          else unset($Parameters['Null']);
    168         if(array_key_exists('OnPreset', $Item)) $Parameters['OnPreset'] = $Item['OnPreset'];
     168        if (array_key_exists('OnPreset', $Item)) $Parameters['OnPreset'] = $Item['OnPreset'];
    169169          else unset($Parameters['OnPreset']);
    170170
    171         if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    172         {
    173           if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    174             $this->FormManager->Type->RegisterType($Item['Type'], '',
    175               $this->FormManager->FormTypes[$Item['Type']]);
    176           if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     171        if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     172        {
     173          if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     174            $this->FormManager->Type->RegisterType($Item['Type'], '',
     175              $this->FormManager->FormTypes[$Item['Type']]);
     176          if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    177177          {
    178178            $UseType = 'OneToMany';
    179           } else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     179          } else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    180180            $UseType = 'Enumeration';
    181181        } else $UseType = $Item['Type'];
    182182        $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnEdit', $Parameters);
    183         if(array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix'];
     183        if (array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix'];
    184184
    185185      $Caption = $Item['Caption'].':';
    186       if(array_key_exists($Index, $this->ValuesValidate) and
     186      if (array_key_exists($Index, $this->ValuesValidate) and
    187187        $this->ValuesValidate[$Index]) {
    188188          $Format = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'GetValidationFormat', array());
    189           if($Format != '') $Caption .= '<br/><small>'.$Format.'</small>';
     189          if ($Format != '') $Caption .= '<br/><small>'.$Format.'</small>';
    190190          $Caption = '<span style="color:red;">'.$Caption.'</span>';
    191191        }
    192       if(!$this->FormManager->Type->IsHidden($UseType))
     192      if (!$this->FormManager->Type->IsHidden($UseType))
    193193          array_push($Table['Rows'], array($Caption, $Edit));
    194194      else $Hidden .= $Edit;
     
    197197    $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.$this->Table($Table).
    198198    $Hidden.'</fieldset>';
    199     return($Output);
     199    return $Output;
    200200  }
    201201
    202202  function LoadValuesFromDatabase($Id)
    203203  {
    204     foreach($this->Definition['Items'] as $Index => $Item)
    205     if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     204    foreach ($this->Definition['Items'] as $Index => $Item)
     205    if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    206206    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    207207    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    208208    {
    209         if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    210         {
    211           if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    212             $this->FormManager->Type->RegisterType($Item['Type'], '',
    213               $this->FormManager->FormTypes[$Item['Type']]);
    214           if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    215             $UseType = 'OneToMany';
    216           else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    217             $UseType = 'Enumeration';
    218         } else $UseType = $Item['Type'];
    219       if(!array_key_exists('SQL', $Item)) $Item['SQL'] = '';
     209        if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     210        {
     211          if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     212            $this->FormManager->Type->RegisterType($Item['Type'], '',
     213              $this->FormManager->FormTypes[$Item['Type']]);
     214          if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     215            $UseType = 'OneToMany';
     216          else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     217            $UseType = 'Enumeration';
     218        } else $UseType = $Item['Type'];
     219      if (!array_key_exists('SQL', $Item)) $Item['SQL'] = '';
    220220        else $Item['SQL'] = str_replace('#Id', $Id, $Item['SQL']);
    221221      $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery',
     
    223223    }
    224224    $Columns = implode(',', $Columns);
    225     if(array_key_exists('SQL', $this->Definition))
     225    if (array_key_exists('SQL', $this->Definition))
    226226      $SourceTable = '('.$this->Definition['SQL'].') AS `TX`';
    227227      else $SourceTable = '`'.$this->Definition['Table'].'` AS `TX`';
    228228    $DbResult = $this->Database->query('SELECT '.$Columns.' FROM '.$SourceTable.' WHERE `TX`.`Id`='.$Id);
    229229    $DbRow = $DbResult->fetch_array();
    230     foreach($this->Definition['Items'] as $Index => $Item)
    231     if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     230    foreach ($this->Definition['Items'] as $Index => $Item)
     231    if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    232232    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    233233    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    234234    {
    235         if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    236         {
    237           if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    238             $this->FormManager->Type->RegisterType($Item['Type'], '',
    239               $this->FormManager->FormTypes[$Item['Type']]);
    240           if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    241             $UseType = 'OneToMany';
    242           else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     235        if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     236        {
     237          if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     238            $this->FormManager->Type->RegisterType($Item['Type'], '',
     239              $this->FormManager->FormTypes[$Item['Type']]);
     240          if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     241            $UseType = 'OneToMany';
     242          else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    243243            $UseType = 'Enumeration';
    244244        } else $UseType = $Item['Type'];
     
    253253  {
    254254    $Values = array();
    255     foreach($this->Definition['Items'] as $Index => $Item)
    256     {
    257       if(array_key_exists($Index, $this->Values))
    258       if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     255    foreach ($this->Definition['Items'] as $Index => $Item)
     256    {
     257      if (array_key_exists($Index, $this->Values))
     258      if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    259259      (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    260260      ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
     
    263263          'Type' => $Item['Type'], 'Values' => $this->Values);
    264264
    265         if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    266         {
    267           if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    268             $this->FormManager->Type->RegisterType($Item['Type'], '',
    269               $this->FormManager->FormTypes[$Item['Type']]);
    270           if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     265        if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     266        {
     267          if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     268            $this->FormManager->Type->RegisterType($Item['Type'], '',
     269              $this->FormManager->FormTypes[$Item['Type']]);
     270          if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    271271          {
    272272            $UseType = 'OneToMany';
    273273          }
    274           else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     274          else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    275275            $UseType = 'Enumeration';
    276276        } else $UseType = $Item['Type'];
    277277        $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters);
    278         if(($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]);
    279       }
    280     }
    281     if($Id == 0)
     278        if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]);
     279      }
     280    }
     281    if ($Id == 0)
    282282    {
    283283      $Values['Id'] = $Id;
     
    294294  function LoadValuesFromFormBlock($Context = '')
    295295  {
    296     if($Context != '') $Context = $Context.'-';
     296    if ($Context != '') $Context = $Context.'-';
    297297    $Values = array();
    298     foreach($this->Definition['Items'] as $Index => $Item)
    299     if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
    300     {
    301     if((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     298    foreach ($this->Definition['Items'] as $Index => $Item)
     299    if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
     300    {
     301    if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    302302    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    303303    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and
     
    306306    ($Item['ReadOnly'] != true))))
    307307    {
    308         //if(array_key_exists($Context.$Index, $_POST))
    309         if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    310         {
    311           if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     308        //if (array_key_exists($Context.$Index, $_POST))
     309        if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     310        {
     311          if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    312312            $this->FormManager->Type->RegisterType($Item['Type'], '',
    313313              $this->FormManager->FormTypes[$Item['Type']]);
    314314          $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type'];
    315           if($CustomType == 'Reference')
    316             $UseType = 'OneToMany';
    317           else if($CustomType == 'Enumeration')
     315          if ($CustomType == 'Reference')
     316            $UseType = 'OneToMany';
     317          else if ($CustomType == 'Enumeration')
    318318            $UseType = 'Enumeration';
    319319        } else $UseType = $Item['Type'];
    320320        $Parameters = array('Name' => $Index, 'Type' => $Item['Type'], 'Values' => $this->Values);
    321         if(array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];
     321        if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];
    322322          else unset($Parameters['Null']);
    323323        $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoad',
     
    326326    } else
    327327    {
    328       if(isset($Item['Default'])) {
    329         if(isset($Item['Null']) and ($Item['Null'] == true))
     328      if (isset($Item['Default'])) {
     329        if (isset($Item['Null']) and ($Item['Null'] == true))
    330330          $Values[$Index] = null;
    331331        else $Values[$Index] = $Item['Default'];
    332332      }
    333333    }
    334     return($Values);
     334    return $Values;
    335335  }
    336336
     
    338338  {
    339339    $Valid = true;
    340     foreach($this->Definition['Items'] as $Index => $Item)
    341     if((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     340    foreach ($this->Definition['Items'] as $Index => $Item)
     341    if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    342342    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    343343    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and
     
    346346    ($Item['ReadOnly'] != true))))
    347347    {
    348         //if(array_key_exists($Context.$Index, $_POST))
    349         if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    350         {
    351           if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     348        //if (array_key_exists($Context.$Index, $_POST))
     349        if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     350        {
     351          if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    352352            $this->FormManager->Type->RegisterType($Item['Type'], '',
    353353              $this->FormManager->FormTypes[$Item['Type']]);
    354354          $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type'];
    355           if($CustomType == 'Reference')
    356             $UseType = 'OneToMany';
    357           else if($CustomType == 'Enumeration')
     355          if ($CustomType == 'Reference')
     356            $UseType = 'OneToMany';
     357          else if ($CustomType == 'Enumeration')
    358358            $UseType = 'Enumeration';
    359359        } else $UseType = $Item['Type'];
    360360
    361361        $Parameters = array('Value' => $this->Values[$Index]);
    362         if(array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];
     362        if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];
    363363          else $Parameters['Null'] = false;
    364         if(!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate',
     364        if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate',
    365365          $Parameters)) {
    366366            $this->ValuesValidate[$Index] = true;
     
    368368          }
    369369    }
    370     if($Valid == false) throw new Exception('not validated');
    371     return($Valid);
     370    if ($Valid == false) throw new Exception('not validated');
     371    return $Valid;
    372372  }
    373373}
     
    418418    $this->Database->query('DELETE FROM DataType');
    419419
    420     foreach($this->Type->TypeDefinitionList as $Name => $Type)
     420    foreach ($this->Type->TypeDefinitionList as $Name => $Type)
    421421    {
    422422      $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Name.'"');
    423       if($DbResult->num_rows == 0)
     423      if ($DbResult->num_rows == 0)
    424424      {
    425425        $this->Database->insert('DataType', array('Name' => $Name,
     
    433433    }
    434434
    435     foreach($this->Classes as $Class)
    436     if(!array_key_exists('SQL', $Class) and ($Class['Table'] != ''))
     435    foreach ($this->Classes as $Class)
     436    if (!array_key_exists('SQL', $Class) and ($Class['Table'] != ''))
    437437    {
    438438      $DbResult = $this->Database->query('SELECT * FROM information_schema.tables  WHERE table_schema = "centrala_big"
    439439          AND table_name = "'.$Class['Table'].'" LIMIT 1');
    440       if($DbResult->num_rows == 0) continue;
     440      if ($DbResult->num_rows == 0) continue;
    441441
    442442      echo($Class['Table'].'<br>');
    443443      $Module = 1;
    444444      $DbResult = $this->Database->select('Model', 'Id', 'Name="'.$Class['Table'].'"');
    445       if($DbResult->num_rows == 0)
     445      if ($DbResult->num_rows == 0)
    446446      {
    447447        $this->Database->insert('Model', array('Name' => $Class['Table'], 'Title' => $Class['Title'], 'Module' => $Module));
     
    455455      }
    456456
    457       foreach($Class['Items'] as $Name => $Field)
     457      foreach ($Class['Items'] as $Name => $Field)
    458458      {
    459459        echo($Name.', ');
    460460        $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Field['Type'].'"');
    461         if($DbResult->num_rows > 0)
     461        if ($DbResult->num_rows > 0)
    462462        {
    463463          $DbRow = $DbResult->fetch_assoc();
     
    468468          // Search parent type
    469469          $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Type['Type'].'"');
    470           if($DbResult->num_rows > 0)
     470          if ($DbResult->num_rows > 0)
    471471          {
    472472            $DbRow = $DbResult->fetch_assoc();
     
    480480
    481481        $DbResult = $this->Database->select('ModelField', 'Id', '(Name="'.$Name.'") AND (Model='.$Model.')');
    482         if($DbResult->num_rows == 0)
     482        if ($DbResult->num_rows == 0)
    483483        {
    484484          $this->Database->insert('ModelField', array('Name' => $Name,
  • trunk/Packages/Common/Form/Types/Base.php

    r1 r7  
    1717  function OnView($Item)
    1818  {
    19     return('');
     19    return '';
    2020  }
    2121
    2222  function OnEdit($Item)
    2323  {
    24     return('');
     24    return '';
    2525  }
    2626
    2727  function OnLoad($Item)
    2828  {
    29     return('');
     29    return '';
    3030  }
    3131
    3232  function OnLoadDb($Item)
    3333  {
    34     return($Item['Value']);
     34    return $Item['Value'];
    3535  }
    3636
    3737  function OnSaveDb($Item)
    3838  {
    39     return($Item['Value']);
     39    return $Item['Value'];
    4040  }
    4141
    4242  function DatabaseEscape($Value)
    4343  {
    44     return(addslashes($Value));
     44    return addslashes($Value);
    4545  }
    4646
    4747  function OnFilterName($Item)
    4848  {
    49     if(array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
     49    if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
    5050      $SQL = '('.$Item['SQL'].') AS ';
    5151      else $SQL = '';
    52     return($SQL.'`'.$Item['Name'].'`');
     52    return $SQL.'`'.$Item['Name'].'`';
    5353  }
    5454
    5555  function OnFilterNameQuery($Item)
    5656  {
    57     if(array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
     57    if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
    5858      $Output = '('.$Item['SQL'].') AS `'.$Item['Name'].'`, ('.$Item['SQL'].') AS `'.$Item['Name'].'_Filter`';
    5959      else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`';
    60     return($Output);
     60    return $Output;
    6161  }
    6262
    6363  function Validate($Item)
    6464  {
    65     return(true);
     65    return true;
    6666  }
    6767
    6868  function GetValidationFormat()
    6969  {
    70     return('');
     70    return '';
    7171  }
    7272}
  • trunk/Packages/Common/Form/Types/Boolean.php

    r1 r7  
    99  function OnView($Item)
    1010  {
    11     if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
    12     return('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>');
     11    if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
     12    return '<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>';
    1313  }
    1414
    1515  function OnEdit($Item)
    1616  {
    17     if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
    18     return('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>');
     17    if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
     18    return '<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>';
    1919  }
    2020
    2121  function OnLoad($Item)
    2222  {
    23     if(array_key_exists($Item['Name'], $_POST)) return(1);
    24       else return(0);
     23    if (array_key_exists($Item['Name'], $_POST)) return 1;
     24      else return 0;
    2525  }
    2626}
  • trunk/Packages/Common/Form/Types/Color.php

    r1 r7  
    1010  {
    1111    $Output = '<span style="background-color: #'.$Item['Value'].'">&nbsp;&nbsp;&nbsp;&nbsp;</span>';
    12     return($Output);
     12    return $Output;
    1313  }
    1414
     
    1616  {
    1717    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    18     return($Output);
     18    return $Output;
    1919  }
    2020
    2121  function OnLoad($Item)
    2222  {
    23     return($_POST[$Item['Name']]);
     23    return $_POST[$Item['Name']];
    2424  }
    2525}
  • trunk/Packages/Common/Form/Types/Date.php

    r1 r7  
    1111    global $MonthNames;
    1212
    13     if($Item['Value'] == null) return('');
    14     if((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
     13    if ($Item['Value'] == null) return '';
     14    if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
    1515    $Parts = getdate($Item['Value']);
    1616
    1717    $Output = $Parts['mday'].'.'.$Parts['mon'].'.'.$Parts['year'];
    18     return($Output);
     18    return $Output;
    1919  }
    2020
     
    2323    global $MonthNames;
    2424
    25     if(($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time();
     25    if (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time();
    2626    $Parts = getdate($Item['Value']);
    2727
    2828    $Output = '';
    2929    $Style = '';
    30     if(array_key_exists('Null', $Item) and $Item['Null'])
     30    if (array_key_exists('Null', $Item) and $Item['Null'])
    3131    {
    32       if($Item['Value'] != null)
     32      if ($Item['Value'] != null)
    3333      {
    3434        $Checked = ' checked="1"';
     
    4545    // Day
    4646    $Output .= '<select name="'.$Item['Name'].'-day" id="'.$Item['Name'].'-day" '.$Style.'>';
    47     for($I = 1; $I <= 31; $I++)
     47    for ($I = 1; $I <= 31; $I++)
    4848    {
    49       if($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     49      if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    5050      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    5151    }
     
    5353    // Month
    5454   $Output .= '<select name="'.$Item['Name'].'-month" id="'.$Item['Name'].'-month" '.$Style.'>';
    55    for($I = 1; $I <= 12; $I++)
     55   for ($I = 1; $I <= 12; $I++)
    5656    {
    57       if($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     57      if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    5858      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>';
    5959    }
     
    6161    // Year
    6262    $Output .= '<select name="'.$Item['Name'].'-year" id="'.$Item['Name'].'-year" '.$Style.'>';
    63     for($I = 1900; $I < 2100; $I++)
     63    for ($I = 1900; $I < 2100; $I++)
    6464    {
    65       if($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     65      if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    6666      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    6767    }
    6868    $Output .= '</select>';
    69     return($Output);
     69    return $Output;
    7070  }
    7171
    7272  function OnLoad($Item)
    7373  {
    74     if(!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);
    75       else return(mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']));
     74    if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null;
     75      else return mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']);
    7676  }
    7777
    7878  function OnLoadDb($Item)
    7979  {
    80     return(MysqlDateToTime($Item['Value']));
     80    return MysqlDateToTime($Item['Value']);
    8181  }
    8282
    8383  function OnSaveDb($Item)
    8484  {
    85     if($Item['Value'] == null) return(null);
    86       else return(date('Y-m-d', $Item['Value']));
     85    if ($Item['Value'] == null) return null;
     86      else return date('Y-m-d', $Item['Value']);
    8787  }
    8888
    8989  function DatabaseEscape($Value)
    9090  {
    91     return('"'.addslashes($Value).'"');
     91    return '"'.addslashes($Value).'"';
    9292  }
    9393}
  • trunk/Packages/Common/Form/Types/DateTime.php

    r1 r7  
    1111    global $MonthNames;
    1212
    13     if($Item['Value'] == 0) return('');
    14     if((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
     13    if ($Item['Value'] == 0) return '';
     14    if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
    1515    $Parts = getdate($Item['Value']);
    1616    $Output = $Parts['mday'].'.'.$Parts['mon'].'.'.$Parts['year'].' '.
    1717      sprintf('%02d', $Parts['hours']).':'.sprintf('%02d', $Parts['minutes']).':'.sprintf('%02d', $Parts['seconds']);
    18     return($Output);
     18    return $Output;
    1919  }
    2020
     
    2323    global $MonthNames;
    2424
    25     if(($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time();
     25    if (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time();
    2626    $Parts = getdate($Item['Value']);
    2727
    2828    $Output = '';
    2929    $Style = '';
    30     if(array_key_exists('Null', $Item) and $Item['Null'])
     30    if (array_key_exists('Null', $Item) and $Item['Null'])
    3131    {
    32       if($Item['Value'] != null)
     32      if ($Item['Value'] != null)
    3333      {
    3434        $Checked = ' checked="1"';
     
    4646    // Hour
    4747    $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>';
    48     for($I = 1; $I <= 24; $I++)
     48    for ($I = 1; $I <= 24; $I++)
    4949    {
    50       if($Parts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     50      if ($Parts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    5151      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    5252    }
     
    5454    // Minute
    5555    $Output .= '<select name="'.$Item['Name'].'-minute" id="'.$Item['Name'].'-minute" '.$Style.'>';
    56     for($I = 1; $I <= 60; $I++)
     56    for ($I = 1; $I <= 60; $I++)
    5757    {
    58       if($Parts['minutes'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     58      if ($Parts['minutes'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    5959      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    6060    }
     
    6262    // Second
    6363    $Output .= '<select name="'.$Item['Name'].'-second" id="'.$Item['Name'].'-second" '.$Style.'>';
    64     for($I = 1; $I <= 60; $I++)
     64    for ($I = 1; $I <= 60; $I++)
    6565    {
    66       if($Parts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     66      if ($Parts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    6767      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    6868    }
     
    7070    // Day
    7171    $Output .= ' <select name="'.$Item['Name'].'-day" id="'.$Item['Name'].'-day" '.$Style.'>';
    72     for($I = 1; $I <= 31; $I++)
     72    for ($I = 1; $I <= 31; $I++)
    7373    {
    74       if($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     74      if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    7575      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    7676    }
     
    7878    // Month
    7979    $Output .= '<select name="'.$Item['Name'].'-month"  id="'.$Item['Name'].'-month" '.$Style.'>';
    80     for($I = 1; $I <= 12; $I++)
     80    for ($I = 1; $I <= 12; $I++)
    8181    {
    82       if($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     82      if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    8383      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>';
    8484    }
     
    8686    // Year
    8787    $Output .= '<select name="'.$Item['Name'].'-year" id="'.$Item['Name'].'-year" '.$Style.'>';
    88     for($I = 1900; $I < 2100; $I++)
     88    for ($I = 1900; $I < 2100; $I++)
    8989    {
    90       if($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     90      if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    9191      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    9292    }
    9393    $Output .= '</select>';
    94     return($Output);
     94    return $Output;
    9595  }
    9696
    9797  function OnLoad($Item)
    9898  {
    99     if(!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);
    100       else return(mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'],
    101         $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']));
     99    if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null;
     100      else return mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'],
     101        $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']);
    102102  }
    103103
    104104  function OnLoadDb($Item)
    105105  {
    106     return(MysqlDateTimeToTime($Item['Value']));
     106    return MysqlDateTimeToTime($Item['Value']);
    107107  }
    108108
    109109  function OnSaveDb($Item)
    110110  {
    111     if($Item['Value'] == null) return(null);
    112       else return(date('Y-m-d H:i:s', $Item['Value']));
     111    if ($Item['Value'] == null) return null;
     112      else return date('Y-m-d H:i:s', $Item['Value']);
    113113  }
    114114
    115115  function DatabaseEscape($Value)
    116116  {
    117     return('"'.addslashes($Value).'"');
     117    return '"'.addslashes($Value).'"';
    118118  }
    119119}
  • trunk/Packages/Common/Form/Types/Enumeration.php

    r1 r7  
    88  {
    99    $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']);
    10     if(array_key_exists($Item['Value'], $Type['Parameters']['States']))
     10    if (array_key_exists($Item['Value'], $Type['Parameters']['States']))
    1111      $Output = $Type['Parameters']['States'][$Item['Value']];
    1212      else $Output = $Item['Value'];
    13     return($Output);
     13    return $Output;
    1414  }
    1515
     
    1818    $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']);
    1919    $Output = '<select name="'.$Item['Name'].'">';
    20       if(array_key_exists('Null', $Item) and $Item['Null'])
     20      if (array_key_exists('Null', $Item) and $Item['Null'])
    2121    {
    22       if($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';
     22      if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';
    2323      $Output .= '<option value=""'.$Selected.'></option>';
    2424    }
    25     foreach($Type['Parameters']['States'] as $Index => $StateName)
     25    foreach ($Type['Parameters']['States'] as $Index => $StateName)
    2626    {
    27       if($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = '';
     27      if ($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = '';
    2828      $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$StateName.'</option>';
    2929    }
    3030    $Output .= '</select>';
    31     return($Output);
     31    return $Output;
    3232  }
    3333
    3434  function OnLoad($Item)
    3535  {
    36     if($_POST[$Item['Name']] == '') return(NULL);
    37     return($_POST[$Item['Name']]);
     36    if ($_POST[$Item['Name']] == '') return NULL;
     37    return $_POST[$Item['Name']];
    3838  }
    3939
    4040  function OnLoadDb($Item)
    4141  {
    42     if($Item['Value'] == '') return(NULL);
    43     else return($Item['Value']);
     42    if ($Item['Value'] == '') return NULL;
     43    else return $Item['Value'];
    4444  }
    4545}
  • trunk/Packages/Common/Form/Types/File.php

    r1 r7  
    1616    $Result = $FileInfo->file($this->FileName);
    1717    //$FileInfo->close();
    18     return($Result);
     18    return $Result;
    1919  }
    2020
     
    2222  {
    2323    $FileName = $this->GetFullName($Item);
    24     if(file_exists($FileName)) $Result = filesize($FileName);
     24    if (file_exists($FileName)) $Result = filesize($FileName);
    2525      else $Result = 0;
    26     return($Result);
     26    return $Result;
    2727  }
    2828
     
    3030  {
    3131    $ParentId = $this->Directory;
    32     while($ParentId != null)
     32    while ($ParentId != null)
    3333    {
    3434      $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$ParentId);
     
    3838    }
    3939    $Result = $this->UploadFileFolder.'/'.$Path.$File->Name;
    40     return($Result);
     40    return $Result;
    4141  }
    4242
    4343  function GetExt()
    4444  {
    45     return(substr($this->Name, 0, strpos($this->Name, '.') - 1));
     45    return substr($this->Name, 0, strpos($this->Name, '.') - 1);
    4646  }
    4747
    4848  function Delete()
    4949  {
    50     if(file_exists($this->GetFullName())) unlink($this->GetFullName());
     50    if (file_exists($this->GetFullName())) unlink($this->GetFullName());
    5151  }
    5252
    5353  function GetContent()
    5454  {
    55     if($this->TempName != '') $Content = file_get_contents($this->TempName);
     55    if ($this->TempName != '') $Content = file_get_contents($this->TempName);
    5656      else $Content = file_get_contents($this->GetFullName());
    57     return($Content);
     57    return $Content;
    5858  }
    5959}
     
    7575  {
    7676    $File = &$Item['Value'];
    77     return('<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'.
    78       $File.'</a> ('.HumanSize($File->Size).')');
     77    return '<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'.
     78      $File.'</a> ('.HumanSize($File->Size).')';
    7979  }
    8080
     
    8686    $File = &$Item['Value'];
    8787    $Output = '<input type="file" name="'.$Item['Name'].'" value="'.$File->Name.'">';
    88     return($Output);
     88    return $Output;
    8989  }
    9090
    9191  function OnLoad($Item)
    9292  {
    93     if(!is_object($Item['Value'])) $Item['Value'] = new DbFile();
     93    if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();
    9494    $File = &$Item['Value'];
    95     if(array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != ''))
     95    if (array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != ''))
    9696    {
    9797      $UploadFile = $_FILES[$Item['Name']];
    98       if(file_exists($UploadFile['tmp_name']))
     98      if (file_exists($UploadFile['tmp_name']))
    9999      {
    100100        $File->Name = $UploadFile['name'];
     
    103103      }
    104104    }
    105     return($File);
     105    return $File;
    106106  }
    107107
    108108  function OnLoadDb($Item)
    109109  {
    110     if(!is_object($Item['Value'])) $Item['Value'] = new DbFile();
     110    if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();
    111111    $File = &$Item['Value'];
    112112    $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id);
    113     if($DbResult->num_rows() > 0)
     113    if ($DbResult->num_rows() > 0)
    114114    {
    115115      $DbRow = $DbResult->fetch_assoc();
     
    118118      $File->Directory = $DbRow['Directory'];
    119119    }
    120     return($File);
     120    return $File;
    121121  }
    122122
    123123  function OnSaveDb($Item)
    124124  {
    125     if(!is_object($Item['Value'])) $Item['Value'] = new DbFile();
     125    if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();
    126126    $File = &$Item['Value'];
    127127    $Properties = array('Name' => $File->Name,
    128128      'Size' => $File->GetSize(), 'Directory' => $File->Directory);
    129129    $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id);
    130     if($DbResult->num_rows() > 0)
     130    if ($DbResult->num_rows() > 0)
    131131    {
    132132      $DbRow = $DbResult->fetch_assoc();
    133       if($File->TempName != '')
     133      if ($File->TempName != '')
    134134      {
    135135        $FileName = $File->GetFullName();
     
    142142      $File->Id = $this->Database->insert_id;
    143143    }
    144     if(!move_uploaded_file($File->TempName, $FileName))
     144    if (!move_uploaded_file($File->TempName, $FileName))
    145145      SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!');
    146146  }
  • trunk/Packages/Common/Form/Types/Float.php

    r1 r7  
    1010  {
    1111    $Output = $Item['Value'];
    12     return($Output);
     12    return $Output;
    1313  }
    1414
     
    1616  {
    1717    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    18     return($Output);
     18    return $Output;
    1919  }
    2020
    2121  function OnLoad($Item)
    2222  {
    23     return($_POST[$Item['Name']]);
     23    return $_POST[$Item['Name']];
    2424  }
    2525}
  • trunk/Packages/Common/Form/Types/GPS.php

    r1 r7  
    1010
    1111    $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);
    12     if($DbResult->num_rows > 0)
     12    if ($DbResult->num_rows > 0)
    1313    {
    1414      $DbRow = $DbResult->fetch_assoc();
     
    1717      $Output = '<a href="http://www.mapy.cz/?st=search&fr=loc:'.$DbRow['Latitude'].' '.$DbRow['Longitude'].'">'.$Latitude[0].'°'.$Latitude[1]."'".$Latitude[2].'" '.$Longitude[0].'°'.$Longitude[1]."'".$Longitude[2].'"</a>';
    1818    }
    19     return($Output);
     19    return $Output;
    2020  }
    2121
     
    2424    global $Database;
    2525
    26     if($Item['Value'] != '')
     26    if ($Item['Value'] != '')
    2727    {
    2828      $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);
    29       if($DbResult->num_rows > 0)
     29      if ($DbResult->num_rows > 0)
    3030      {
    3131        $DbRow = $DbResult->fetch_assoc();
     
    4040    $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'"/>\'';
    4141    $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'"/>"';
    42     return($Output);
     42    return $Output;
    4343  }
    4444
     
    5050    $Longitude = $this->Implode($_POST[$Item['Name'].'-lon-deg'], $_POST[$Item['Name'].'-lon-min'], $_POST[$Item['Name'].'-lon-sec']);
    5151    $Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")');
    52     return($Database->insert_id);
     52    return $Database->insert_id;
    5353  }
    5454
     
    6161    $Float = ($Float - intval($Float)) * 60;
    6262    $Seconds = round($Float, 3);
    63     return(array($Degrees, $Minutes, $Seconds));
     63    return array($Degrees, $Minutes, $Seconds);
    6464  }
    6565
    6666  function Implode($Degrees, $Minutes, $Seconds)
    6767  {
    68     if($Degrees < 0) return(-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60));
    69     else return($Degrees + ($Minutes + $Seconds / 60) / 60);
     68    if ($Degrees < 0) return -(abs($Degrees) + ($Minutes + $Seconds / 60) / 60);
     69    else return $Degrees + ($Minutes + $Seconds / 60) / 60;
    7070  }
    7171}
  • trunk/Packages/Common/Form/Types/Hidden.php

    r1 r7  
    1414  {
    1515    $Output = $Item['Value'];
    16     return($Output);
     16    return $Output;
    1717  }
    1818
     
    2020  {
    2121    $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />';
    22     return($Output);
     22    return $Output;
    2323  }
    2424
    2525  function OnLoad($Item)
    2626  {
    27     return($_POST[$Item['Name']]);
     27    return $_POST[$Item['Name']];
    2828  }
    2929}
  • trunk/Packages/Common/Form/Types/Hyperlink.php

    r1 r7  
    88  {
    99    $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>';
    10     return($Output);
     10    return $Output;
    1111  }
    1212
     
    1414  {
    1515    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    16     return($Output);
     16    return $Output;
    1717  }
    1818
    1919  function OnLoad($Item)
    2020  {
    21     return($_POST[$Item['Name']]);
     21    return $_POST[$Item['Name']];
    2222  }
    2323}
  • trunk/Packages/Common/Form/Types/IPv4Address.php

    r1 r7  
    88  {
    99    $Output = $Item['Value'];
    10     return($Output);
     10    return $Output;
    1111  }
    1212
     
    1414  {
    1515    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    16     return($Output);
     16    return $Output;
    1717  }
    1818
    1919  function OnLoad($Item)
    2020  {
    21     return($_POST[$Item['Name']]);
     21    return $_POST[$Item['Name']];
    2222  }
    2323
    2424  function Validate($Item)
    2525  {
    26     if($Item['Null'] and ($Item['Value'] == '')) return(true);
    27     return(filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)));
     26    if ($Item['Null'] and ($Item['Value'] == '')) return true;
     27    return filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4));
    2828  }
    2929
    3030  function GetValidationFormat()
    3131  {
    32     return('x.x.x.x kde x je hodnota 0..255');
     32    return 'x.x.x.x kde x je hodnota 0..255';
    3333  }
    3434}
  • trunk/Packages/Common/Form/Types/IPv6Address.php

    r1 r7  
    88  {
    99    $Output = $Item['Value'];
    10     return($Output);
     10    return $Output;
    1111  }
    1212
     
    1414  {
    1515    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    16     return($Output);
     16    return $Output;
    1717  }
    1818
    1919  function OnLoad($Item)
    2020  {
    21     return($_POST[$Item['Name']]);
     21    return $_POST[$Item['Name']];
    2222  }
    2323
    2424  function Validate($Item)
    2525  {
    26     if($Item['Null'] and ($Item['Value'] == '')) return(true);
    27     return(filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6)));
     26    if ($Item['Null'] and ($Item['Value'] == '')) return true;
     27    return filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6));
    2828  }
    2929
    3030  function GetValidationFormat()
    3131  {
    32     return('xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f');
     32    return 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f';
    3333  }
    3434}
  • trunk/Packages/Common/Form/Types/Image.php

    r1 r7  
    77    global $System;
    88
    9     return('<img src="'.$System->Link('/images/favicons/'.$Item['Value']).'"/> '.$Item['Value']);
     9    return '<img src="'.$System->Link('/images/favicons/'.$Item['Value']).'"/> '.$Item['Value'];
    1010  }
    1111}
  • trunk/Packages/Common/Form/Types/Integer.php

    r1 r7  
    1010  {
    1111    $Output = $Item['Value'];
    12     return($Output);
     12    return $Output;
    1313  }
    1414
     
    1616  {
    1717    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    18     return($Output);
     18    return $Output;
    1919  }
    2020
    2121  function OnLoad($Item)
    2222  {
    23     return($_POST[$Item['Name']]);
     23    return $_POST[$Item['Name']];
    2424  }
    2525
    2626  function Validate($Item)
    2727  {
    28     if($Item['Null'] and ($Item['Value'] == '')) return(true);
    29     return(preg_match('/^\-*[0-9\.]+$/', $Item['Value']));
     28    if ($Item['Null'] and ($Item['Value'] == '')) return true;
     29    return preg_match('/^\-*[0-9\.]+$/', $Item['Value']);
    3030  }
    3131
    3232  function GetValidationFormat()
    3333  {
    34     return('číselná hodnota');
     34    return 'číselná hodnota';
    3535  }
    3636}
  • trunk/Packages/Common/Form/Types/MacAddress.php

    r1 r7  
    1010  {
    1111    $Output = $Item['Value'];
    12     return($Output);
     12    return $Output;
    1313  }
    1414
     
    1616  {
    1717    $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    18     return($Output);
     18    return $Output;
    1919  }
    2020
     
    2222  {
    2323    //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>');
    24     return(strtoupper($_POST[$Item['Name']]));
     24    return strtoupper($_POST[$Item['Name']]);
    2525  }
    2626
    2727  function DatabaseEscape($Value)
    2828  {
    29     return('"'.addslashes($Value).'"');
     29    return '"'.addslashes($Value).'"';
    3030  }
    3131
    3232  function Validate($Item)
    3333  {
    34     if($Item['Null'] and ($Item['Value'] == '')) return(true);
    35     return(preg_match('/^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$/', $Item['Value']));
     34    if ($Item['Null'] and ($Item['Value'] == '')) return true;
     35    return preg_match('/^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$/', $Item['Value']);
    3636  }
    3737
    3838  function GetValidationFormat()
    3939  {
    40     return('XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F');
     40    return 'XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F';
    4141  }
    4242}
  • trunk/Packages/Common/Form/Types/OneToMany.php

    r1 r7  
    1010  {
    1111    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
    12     if($Item['Value'] != '')
     12    if ($Item['Value'] != '')
    1313    {
    1414      $Output = '<a href="?t='.$Type['Parameters']['Table'].'&amp;a='.
    1515        'view'.'&amp;i='.$Item['Value'].'">'.$Item['Filter'].'</a>';
    1616    } else $Output = '';
    17     return($Output);
     17    return $Output;
    1818  }
    1919
     
    2222    $Output = '<select name="'.$Item['Name'].'" id="'.$Item['Name'].'">';
    2323    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
    24     if(array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];
     24    if (array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];
    2525      else $Where = '';
    26     if(array_key_exists('Null', $Item) and $Item['Null'])
     26    if (array_key_exists('Null', $Item) and $Item['Null'])
    2727    {
    28       if($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';
     28      if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';
    2929      $Output .= '<option value=""'.$Selected.'></option>';
    3030    }
    31     if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
     31    if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
    3232      else $Table = $Type['Parameters']['Table'];
    3333    $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS `Name`,'.$Type['Parameters']['Id'].' AS `Id` FROM '.$Table.''.$Where.' ORDER BY `Name`');
    34     while($DbRow = $DbResult->fetch_assoc())
     34    while ($DbRow = $DbResult->fetch_assoc())
    3535    {
    36       if($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';
     36      if ($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';
    3737      $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Name'].'</option>';
    3838    }
    3939    $Output .= '</select>';
    40     if($this->FormManager->ShowRelation)
     40    if ($this->FormManager->ShowRelation)
    4141    {
    4242      $URL = '';
    43       if(array_key_exists('OnPreset', $Item))
     43      if (array_key_exists('OnPreset', $Item))
    4444      {
    4545        $Preset = call_user_func($Item['OnPreset'], $Item['Values']);
     
    5151        'onclick="return popupwindow(&quot;'.$this->FormManager->Root.'/is/?a=select&amp;t='.$Table.'&amp;r='.$Item['Name'].'&quot;,&quot;test&quot;);" style="cursor:hand;cursor:pointer"/>';
    5252    }
    53     return($Output);
     53    return $Output;
    5454  }
    5555
    5656  function OnLoad($Item)
    5757  {
    58     if($_POST[$Item['Name']] == '') return(NULL);
    59       else return($_POST[$Item['Name']]);
     58    if ($_POST[$Item['Name']] == '') return NULL;
     59      else return $_POST[$Item['Name']];
    6060  }
    6161
    6262  function OnLoadDb($Item)
    6363  {
    64     if($Item['Value'] == '') return(NULL);
    65       else return($Item['Value']);
     64    if ($Item['Value'] == '') return NULL;
     65      else return $Item['Value'];
    6666  }
    6767
    6868  function OnFilterName($Item)
    6969  {
    70     return('`'.$Item['Name'].'_Filter`');
     70    return '`'.$Item['Name'].'_Filter`';
    7171  }
    7272
     
    7474  {
    7575    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
    76     //if($Item['Value'] != '')
     76    //if ($Item['Value'] != '')
    7777    //{
    78       if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
     78      if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
    7979        else $Table = $Type['Parameters']['Table'];
    8080      $Output = '`'.$Item['Name'].'`, (SELECT '.$Type['Parameters']['Name'].''.
     
    8282        $Type['Parameters']['Id'].'`=`TX`.`'.$Item['Name'].'`) AS `'.$Item['Name'].'_Filter`';
    8383    //} else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`';
    84     return($Output);
     84    return $Output;
    8585  }
    8686}
  • trunk/Packages/Common/Form/Types/OneToMany2.php

    r1 r7  
    88  {
    99    $Output = '<a href="?Action=ShowList&amp;TableId='.$Item['TypeDefinition'].'&amp;ParentTable='.$Item['SourceTable'].'&amp;ParentColumn='.$Item['SourceItemId'].'">Seznam</a>';
    10     return($Output);
     10    return $Output;
    1111  }
    1212
     
    1414  {
    1515    $Output = '<a href="?Action=ShowList&amp;TableId='.$Item['TypeDefinition'].'&amp;ParentTable='.$Item['SourceTable'].'&amp;ParentColumn='.$Item['SourceItemId'].'">Seznam</a>';
    16     return($Output);
     16    return $Output;
    1717  }
    1818
    1919  function OnLoad($Item)
    2020  {
    21     return($_POST[$Item['Name']]);
     21    return $_POST[$Item['Name']];
    2222  }
    2323}
  • trunk/Packages/Common/Form/Types/Password.php

    r1 r7  
    1010  {
    1111    $Output = '';
    12     for($I = 0; $I < 6; $I++)
     12    for ($I = 0; $I < 6; $I++)
    1313      $Output .= '*';
    14     return($Output);
     14    return $Output;
    1515  }
    1616
     
    1818  {
    1919    $Output = '<input type="password" name="'.$Item['Name'].'" value=""/>';
    20     return($Output);
     20    return $Output;
    2121  }
    2222
     
    2727    $Result = $_POST[$Item['Name']];
    2828    /*
    29     if(!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]);
     29    if (!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]);
    3030    else
    3131    {
    3232      $DbRestult = $Database->query('SELECT '.$Item['Name'].' FROM '.$Item['SourceTable'].' WHERE Id='.$Item['SourceItemId']);
    33       if($DbResult->num_rows > 0)
     33      if ($DbResult->num_rows > 0)
    3434      {
    3535        $DbRow = $DbResult->fetch_assoc();
    36         if($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']];
     36        if ($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']];
    3737        else $Result = sha1($_POST[$Item['Name']]);
    3838      } else $Result = sha1($_POST[$Item['Name']]);
    3939    }
    4040    */
    41     return($Result);
     41    return $Result;
    4242  }
    4343
    4444  function OnSaveDb($Item)
    4545  {
    46     if($Item['Value'] == '') return('');
     46    if ($Item['Value'] == '') return '';
    4747    else {
    4848      $PasswordHash = new PasswordHash();
    49       return($PasswordHash->Hash($Item['Value'], $Item['Values']['Salt']));
     49      return $PasswordHash->Hash($Item['Value'], $Item['Values']['Salt']);
    5050    }
    5151  }
     
    5353  function OnLoadDb($Item)
    5454  {
    55     return('');
     55    return '';
    5656  }
    5757}
  • trunk/Packages/Common/Form/Types/RandomHash.php

    r1 r7  
    1414  {
    1515    $Output = $Item['Value'];
    16     return($Output);
     16    return $Output;
    1717  }
    1818
    1919  function OnEdit($Item)
    2020  {
    21     if($Item['Value'] == '')
     21    if ($Item['Value'] == '')
    2222    {
    2323      // Create only once
     
    2626    }
    2727    $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />';
    28     return($Output);
     28    return $Output;
    2929  }
    3030
    3131  function OnLoad($Item)
    3232  {
    33     return($_POST[$Item['Name']]);
     33    return $_POST[$Item['Name']];
    3434  }
    3535}
  • trunk/Packages/Common/Form/Types/String.php

    r1 r7  
    1010  {
    1111    $Output = $Item['Value'];
    12     return($Output);
     12    return $Output;
    1313  }
    1414
     
    1616  {
    1717    $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    18     return($Output);
     18    return $Output;
    1919  }
    2020
     
    2222  {
    2323    //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>');
    24     return($_POST[$Item['Name']]);
     24    return $_POST[$Item['Name']];
    2525  }
    2626
    2727  function DatabaseEscape($Value)
    2828  {
    29     return('"'.addslashes($Value).'"');
     29    return '"'.addslashes($Value).'"';
    3030  }
    3131}
  • trunk/Packages/Common/Form/Types/Text.php

    r1 r7  
    1010  {
    1111    $Output = str_replace("\n", '<br/>', strip_tags($Item['Value']));
    12     return($Output);
     12    return $Output;
    1313  }
    1414
     
    1616  {
    1717    $Output = '<textarea name="'.$Item['Name'].'">'.$Item['Value'].'</textarea>';
    18     return($Output);
     18    return $Output;
    1919  }
    2020
    2121  function OnLoad($Item)
    2222  {
    23     return($_POST[$Item['Name']]);
     23    return $_POST[$Item['Name']];
    2424  }
    2525
    2626  function DatabaseEscape($Value)
    2727  {
    28     return('"'.addslashes($Value).'"');
     28    return '"'.addslashes($Value).'"';
    2929  }
    3030}
  • trunk/Packages/Common/Form/Types/Time.php

    r1 r7  
    99  function OnView($Item)
    1010  {
    11     if($Item['Value'] == 0) return('');
    12     if((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
     11    if ($Item['Value'] == 0) return '';
     12    if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
    1313    $TimeParts = getdate($Item['Value']);
    1414
    1515    $Output = sprintf('%02d', $TimeParts['hours']).':'.sprintf('%02d', $TimeParts['minutes']).':'.sprintf('%02d', $TimeParts['seconds']);
    16     return($Output);
     16    return $Output;
    1717  }
    1818
    1919  function OnEdit($Item)
    2020  {
    21     if(($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time();
     21    if (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time();
    2222    $TimeParts = getdate($Item['Value']);
    2323
    2424    $Output = '';
    2525    $Style = '';
    26     if(array_key_exists('Null', $Item) and $Item['Null'])
     26    if (array_key_exists('Null', $Item) and $Item['Null'])
    2727    {
    28       if($Item['Value'] != null)
     28      if ($Item['Value'] != null)
    2929      {
    3030        $Checked = ' checked="1"';
     
    4141    // Hour
    4242    $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>';
    43     for($I = 1; $I <= 24; $I++)
     43    for ($I = 1; $I <= 24; $I++)
    4444    {
    45       if($TimeParts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     45      if ($TimeParts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    4646      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    4747    }
     
    4949    // Minute
    5050    $Output .= '<select name="'.$Item['Name'].'-minute" id="'.$Item['Name'].'-minute" '.$Style.'>';
    51     for($I = 1; $I <= 60; $I++)
     51    for ($I = 1; $I <= 60; $I++)
    5252    {
    53       if($TimeParts['month'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     53      if ($TimeParts['month'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    5454      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    5555    }
     
    5757    // Second
    5858    $Output .= '<select name="'.$Item['Name'].'-second" id="'.$Item['Name'].'-second" '.$Style.'>';
    59     for($I = 1; $I <= 60; $I++)
     59    for ($I = 1; $I <= 60; $I++)
    6060    {
    61       if($TimeParts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     61      if ($TimeParts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    6262      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    6363    }
    6464    $Output .= '</select>';
    65     return($Output);
     65    return $Output;
    6666  }
    6767
    6868  function OnLoad($Item)
    6969  {
    70     if(!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);
    71       return(mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second']));
     70    if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null;
     71      return mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second']);
    7272  }
    7373
    7474  function OnLoadDb($Item)
    7575  {
    76     return(MysqlTimeToTime($Item['Value']));
     76    return MysqlTimeToTime($Item['Value']);
    7777  }
    7878
    7979  function OnSaveDb($Item)
    8080  {
    81     if($Item['Value'] == null) return(null);
    82       else return(date('H:i:s', $Item['Value']));
     81    if ($Item['Value'] == null) return null;
     82      else return date('H:i:s', $Item['Value']);
    8383  }
    8484
    8585  function DatabaseEscape($Value)
    8686  {
    87     return('"'.addslashes($Value).'"');
     87    return '"'.addslashes($Value).'"';
    8888  }
    8989}
  • trunk/Packages/Common/Form/Types/TimeDiff.php

    r1 r7  
    77  function OnView($Item)
    88  {
    9     if($Item['Value'] == null) $Output = '';
     9    if ($Item['Value'] == null) $Output = '';
    1010    else {
    1111      $Output = sprintf('%02d', floor($Item['Value'] / 3600 % 24)).':'.
     
    1313        sprintf('%02d', floor($Item['Value'] % 60));
    1414      $Days = floor($Item['Value'] / (60 * 60 * 24));
    15       if($Days > 0) $Output = $Days.' dnů '.$Output;
     15      if ($Days > 0) $Output = $Days.' dnů '.$Output;
    1616    }
    17     return($Output);
     17    return $Output;
    1818  }
    1919}
  • trunk/Packages/Common/Form/Types/Type.php

    r1 r7  
    6767  function ExecuteTypeEvent($TypeName, $Event, $Parameters = array())
    6868  {
    69     if(array_key_exists($TypeName, $this->TypeDefinitionList))
     69    if (array_key_exists($TypeName, $this->TypeDefinitionList))
    7070    {
    7171      $Type = $this->TypeDefinitionList[$TypeName];
    7272      $TypeClass = 'Type'.$Type['Class'];
    7373      $TypeObject = new $TypeClass($this->FormManager);
    74       if(is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters));
    75         else return($TypeName.'->'.$Event.'('.serialize($Parameters).')');
    76     } else return($TypeName);
     74      if (is_callable(array($TypeObject, $Event))) return $TypeObject->$Event($Parameters);
     75        else return $TypeName.'->'.$Event.'('.serialize($Parameters).')';
     76    } else return $TypeName;
    7777  }
    7878
    7979  function IsHidden($TypeName)
    8080  {
    81     if(array_key_exists($TypeName, $this->TypeDefinitionList))
     81    if (array_key_exists($TypeName, $this->TypeDefinitionList))
    8282    {
    8383      $Type = $this->TypeDefinitionList[$TypeName];
    8484      $TypeClass = 'Type'.$Type['Class'];
    8585      $TypeObject = new $TypeClass($this->FormManager);
    86       return($TypeObject->Hidden);
    87     } else return(false);
     86      return $TypeObject->Hidden;
     87    } else return false;
    8888  }
    8989
    9090  function RegisterType($Name, $ParentType, $Parameters)
    9191  {
    92     if($ParentType != '')
     92    if ($ParentType != '')
    9393    {
    9494      $Type = $this->TypeDefinitionList[$ParentType];
     
    9797    $Type['Name'] = $Name;
    9898    $Type['Class'] = $Name;
    99     if(array_key_exists('Parameters', $Type))
     99    if (array_key_exists('Parameters', $Type))
    100100      $Type['Parameters'] = array_merge($Type['Parameters'], $Parameters);
    101101      else $Type['Parameters'] = $Parameters;
     
    111111  function GetTypeDefinition($TypeName)
    112112  {
    113     return($this->TypeDefinitionList[$TypeName]);
     113    return $this->TypeDefinitionList[$TypeName];
    114114  }
    115115}
  • trunk/Packages/Common/Image.php

    r1 r7  
    6565  function SaveToFile($FileName)
    6666  {
    67     if($this->Type == IMAGETYPE_JPEG)
     67    if ($this->Type == IMAGETYPE_JPEG)
    6868    {
    6969      imagejpeg($this->Image, $FileName);
    7070    } else
    71     if($this->Type == IMAGETYPE_GIF)
     71    if ($this->Type == IMAGETYPE_GIF)
    7272    {
    73       imagegif($this->Image, $FileName);
     73      imagegif ($this->Image, $FileName);
    7474    } else
    75     if($this->Type == IMAGETYPE_PNG)
     75    if ($this->Type == IMAGETYPE_PNG)
    7676    {
    7777      imagepng($this->Image, $FileName);
     
    8383    $ImageInfo = getimagesize($FileName);
    8484    $this->Type = $ImageInfo[2];
    85     if($this->Type == IMAGETYPE_JPEG)
     85    if ($this->Type == IMAGETYPE_JPEG)
    8686    {
    8787      $this->Image = imagecreatefromjpeg($FileName);
    8888    } else
    89     if($this->Type == IMAGETYPE_GIF)
     89    if ($this->Type == IMAGETYPE_GIF)
    9090    {
    9191      $this->Image = imagecreatefromgif($FileName);
    9292    } else
    93     if( $this->Type == IMAGETYPE_PNG)
     93    if ( $this->Type == IMAGETYPE_PNG)
    9494    {
    9595      $this->Image = imagecreatefrompng($FileName);
     
    112112  function GetWidth()
    113113  {
    114     return(imagesx($this->Image));
     114    return imagesx($this->Image);
    115115  }
    116116
    117117  function GetHeight()
    118118  {
    119     return(imagesy($this->Image));
     119    return imagesy($this->Image);
    120120  }
    121121
     
    127127  function ConvertColor($Color)
    128128  {
    129     return(imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff));
     129    return imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff);
    130130  }
    131131
  • trunk/Packages/Common/Locale.php

    r1 r7  
    2020  function Translate($Text, $Group = '')
    2121  {
    22     if(array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != ''))
    23       return($this->Data[$Group][$Text]);
    24       else return($Text);
     22    if (array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != ''))
     23      return $this->Data[$Group][$Text];
     24      else return $Text;
    2525  }
    2626
     
    2828  {
    2929    $Key = array_search($Text, $this->Data[$Group]);
    30     if(($Key === FALSE) or ($this->Data[$Group][$Key] == '')) return($Text);
    31       else return($Key);
     30    if (($Key === FALSE) or ($this->Data[$Group][$Key] == '')) return $Text;
     31      else return $Key;
    3232  }
    3333}
     
    4747  {
    4848    $FileName = $this->Dir.'/'.$Language.'.php';
    49     if(file_exists($FileName)) {
     49    if (file_exists($FileName)) {
    5050      include_once($FileName);
    5151      $ClassName = 'LocaleText'.$Language;
     
    5959    // Search for php files
    6060    $FileList = scandir($Path);
    61     foreach($FileList as $FileName)
     61    foreach ($FileList as $FileName)
    6262    {
    6363      $FullName = $Path.'/'.$FileName;
    64       if(($FileName == '.') or ($FileName == '..')) ; // Skip virtual items
    65       else if(substr($FileName, 0, 1) == '.') ; // Skip Linux hidden files
    66       else if(is_dir($FullName)) $this->AnalyzeCode($FullName);
    67       else if(file_exists($FullName))
    68       {
    69         if(substr($FullName, -4) == '.php')
     64      if (($FileName == '.') or ($FileName == '..')) ; // Skip virtual items
     65      else if (substr($FileName, 0, 1) == '.') ; // Skip Linux hidden files
     66      else if (is_dir($FullName)) $this->AnalyzeCode($FullName);
     67      else if (file_exists($FullName))
     68      {
     69        if (substr($FullName, -4) == '.php')
    7070        {
    7171          $Content = file_get_contents($FullName);
    7272          // Search occurence of T() function
    73           while(strpos($Content, 'T(') !== false)
     73          while (strpos($Content, 'T(') !== false)
    7474          {
    7575            $Previous = strtolower(substr($Content, strpos($Content, 'T(') - 1, 1));
     
    7777            $Ord = ord($Previous);
    7878            //echo($Ord.',');
    79             if(!(($Ord >= ord('a')) and ($Ord <= ord('z'))))
     79            if (!(($Ord >= ord('a')) and ($Ord <= ord('z'))))
    8080            {
    8181              // Do for non-alpha previous character
    8282              $Original = substr($Content, 0, strpos($Content, ')'));
    8383              $Original2 = '';
    84               if((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'"))
     84              if ((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'"))
    8585                $Original2 = substr($Original, 1, -1);
    86               if((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"'))
     86              if ((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"'))
    8787                $Original2 = substr($Original, 1, -1);
    88               if($Original2 != '')
     88              if ($Original2 != '')
    8989              {
    90                 if(!array_key_exists($Original2, $this->Texts->Data))
     90                if (!array_key_exists($Original2, $this->Texts->Data))
    9191                  $this->Texts->Data[$Original2] = '';
    9292              }
     
    109109    '    $this->Title = \''.$this->Texts->Title.'\';'."\n".
    110110    '    $this->Data = array('."\n";
    111     foreach($this->Texts->Data as $Index => $Item)
     111    foreach ($this->Texts->Data as $Index => $Item)
    112112    {
    113113      $Content .= "      '".$Index."' => '".$Item."',\n";
     
    122122  {
    123123    $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode));
    124     if($DbResult->num_rows > 0)
     124    if ($DbResult->num_rows > 0)
    125125    {
    126126      $Language = $DbResult->fetch_assoc();
    127127      $this->Texts->Data = array();
    128128      $DbResult = $Database->select('Locale', '`Original`, `Translated`', '`Language`='.$Language['Id']);
    129       while($DbRow = $DbResult->fetch_assoc())
     129      while ($DbRow = $DbResult->fetch_assoc())
    130130        $this->Texts->Data[$DbRow['Original']] = $DbRow['Translated'];
    131131    }
     
    135135  {
    136136    $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode));
    137     if($DbResult->num_rows > 0)
     137    if ($DbResult->num_rows > 0)
    138138    {
    139139      $Language = $DbResult->fetch_assoc();
    140140      $Database->delete('Locale', '`Language`='.$Language['Id']);
    141       foreach($this->Texts->Data as $Index => $Item)
     141      foreach ($this->Texts->Data as $Index => $Item)
    142142        $Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '.
    143143        'VALUES('.$Language['Id'].','.$Database->quote($Index).','.$Database->quote($Item).')');
     
    148148  {
    149149    $DbResult = $Database->select('Language', '*', '`Code`='.$Database->quote($LangCode));
    150     if($DbResult->num_rows > 0)
     150    if ($DbResult->num_rows > 0)
    151151    {
    152152      $Language = $DbResult->fetch_assoc();
    153       foreach($this->Texts->Data as $Index => $Item)
     153      foreach ($this->Texts->Data as $Index => $Item)
    154154      {
    155155        $DbResult = $Database->select('Locale', '*', '(`Original` ='.$Database->quote($Index).
    156156          ') AND (`Language`='.($Language['Id']).')');
    157         if($DbResult->num_rows > 0)
     157        if ($DbResult->num_rows > 0)
    158158        $Database->update('Locale', '(`Language`='.($Language['Id']).') AND '.
    159159          '(`Original` ='.$Database->quote($Index).')', array('Translated' => $Item));
     
    188188    $this->Available = array();
    189189    $FileList = scandir($this->Dir);
    190     foreach($FileList as $FileName)
    191     {
    192       if(substr($FileName, -4) == '.php')
     190    foreach ($FileList as $FileName)
     191    {
     192      if (substr($FileName, -4) == '.php')
    193193      {
    194194        $Code = substr($FileName, 0, -4);
     
    206206    $Locale->AnalyzeCode($Directory);
    207207    $FileList = scandir($this->Dir);
    208     foreach($FileList as $FileName)
    209     {
    210       if(substr($FileName, -4) == '.php')
     208    foreach ($FileList as $FileName)
     209    {
     210      if (substr($FileName, -4) == '.php')
    211211      {
    212212        $FileLocale = new LocaleFile($this->System);
     
    215215
    216216        // Add new
    217         foreach($Locale->Texts->Data as $Index => $Item)
    218           if(!array_key_exists($Index, $FileLocale->Texts->Data))
     217        foreach ($Locale->Texts->Data as $Index => $Item)
     218          if (!array_key_exists($Index, $FileLocale->Texts->Data))
    219219            $FileLocale->Texts->Data[$Index] = $Item;
    220220        // Remove old
    221         foreach($FileLocale->Texts->Data as $Index => $Item)
    222           if(!array_key_exists($Index, $Locale->Texts->Data))
     221        foreach ($FileLocale->Texts->Data as $Index => $Item)
     222          if (!array_key_exists($Index, $Locale->Texts->Data))
    223223            unset($FileLocale->Texts->Data[$Index]);
    224224        $FileLocale->UpdateToDatabase($this->System->Database, $FileLocale->Texts->Code);
     
    232232  function LoadLocale($Code)
    233233  {
    234     if(array_key_exists($Code, $this->Available))
     234    if (array_key_exists($Code, $this->Available))
    235235    {
    236236      $this->CurrentLocale->Dir = $this->Dir;
     
    245245  global $GlobalLocaleManager;
    246246
    247   if(isset($GlobalLocaleManager)) return($GlobalLocaleManager->CurrentLocale->Texts->Translate($Text, $Group));
    248     else return($Text);
    249 }
     247  if (isset($GlobalLocaleManager)) return $GlobalLocaleManager->CurrentLocale->Texts->Translate($Text, $Group);
     248    else return $Text;
     249}
  • trunk/Packages/Common/Mail.php

    r1 r7  
    6969  function Organization($org)
    7070  {
    71     if(trim($org != '')) $this->xheaders['Organization'] = $org;
     71    if (trim($org != '')) $this->xheaders['Organization'] = $org;
    7272  }
    7373
    7474  function Priority($Priority)
    7575  {
    76     if(!intval($Priority)) return(false);
    77 
    78     if(!isset($this->priorities[$Priority - 1])) return(false);
     76    if (!intval($Priority)) return false;
     77
     78    if (!isset($this->priorities[$Priority - 1])) return false;
    7979
    8080    $this->xheaders['X-Priority'] = $this->priorities[$Priority - 1];
    81     return(true);
     81    return true;
    8282  }
    8383
     
    9696  function Send()
    9797  {
    98     if(count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body'));
     98    if (count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body'));
    9999
    100100    $Body = $this->BuildAttachment($this->BuildBody());
     
    103103    $this->Headers['CC'] = '';
    104104    $this->Headers['BCC'] = '';
    105     foreach($this->Recipients as $Index => $Recipient)
    106     {
    107       if($Recipient['Type'] == 'SendCombined')
    108       {
    109         if($Index > 0) $To .= ', ';
     105    foreach ($this->Recipients as $Index => $Recipient)
     106    {
     107      if ($Recipient['Type'] == 'SendCombined')
     108      {
     109        if ($Index > 0) $To .= ', ';
    110110        $To .= $Recipient['Address'];
    111111      } else
    112       if($Recipient['Type'] == 'Send')
    113       {
    114         if($Index > 0) $To .= ', ';
     112      if ($Recipient['Type'] == 'Send')
     113      {
     114        if ($Index > 0) $To .= ', ';
    115115        $To .= $Recipient['Name'].' <'.$Recipient['Address'].'>';
    116116      } else
    117       if($Recipient['Type'] == 'Copy')
    118       {
    119         if($Index > 0) $this->Headers['CC'] .= ', ';
     117      if ($Recipient['Type'] == 'Copy')
     118      {
     119        if ($Index > 0) $this->Headers['CC'] .= ', ';
    120120        $this->Headers['CC'] .= $Recipient['Name'].' <'.$To['Address'].'>';
    121121      } else
    122       if($Recipient['Type'] == 'HiddenCopy')
    123       {
    124         if($Index > 0) $this->Headers['BCC'] .= ', ';
     122      if ($Recipient['Type'] == 'HiddenCopy')
     123      {
     124        if ($Index > 0) $this->Headers['BCC'] .= ', ';
    125125        $this->Headers['BCC'] .= $Recipient['Name'].' <'.$To['Address'].'>';
    126126      }
    127127    }
    128     if($To == '') throw new Exception(T('Mail message need at least one recipient address'));
     128    if ($To == '') throw new Exception(T('Mail message need at least one recipient address'));
    129129
    130130    $this->Headers['Mime-Version'] = '1.0';
    131131
    132     if($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent;
    133     if($this->ReplyTo != '') $this->Headers['Reply-To'] = $this->ReplyTo;
    134     if($this->From != '') $this->Headers['From'] = $this->From;
     132    if ($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent;
     133    if ($this->ReplyTo != '') $this->Headers['Reply-To'] = $this->ReplyTo;
     134    if ($this->From != '') $this->Headers['From'] = $this->From;
    135135
    136136    $Headers = '';
    137     foreach($this->Headers as $Header => $Value)
    138     {
    139       if(($Header != 'Subject') and ($Value != '')) $Headers .= $Header.': '.$Value."\n";
     137    foreach ($this->Headers as $Header => $Value)
     138    {
     139      if (($Header != 'Subject') and ($Value != '')) $Headers .= $Header.': '.$Value."\n";
    140140    }
    141141
    142142    $this->Subject = strtr($this->Subject, "\r\n", '  ');
    143143
    144     if($this->Subject == '') throw new Exception(T('Mail message missing Subject'));
     144    if ($this->Subject == '') throw new Exception(T('Mail message missing Subject'));
    145145
    146146
    147147    $res = mail($To, $this->Subject, $Body, $Headers);
    148     return($res);
     148    return $res;
    149149  }
    150150
    151151  function ValidEmail($Address)
    152152  {
    153     if(ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1];
    154     if(ereg("^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))
    155       return(true);
    156       else return(false);
     153    if (ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1];
     154    if (ereg("^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))
     155      return true;
     156      else return false;
    157157  }
    158158
    159159  function CheckAdresses($Addresses)
    160160  {
    161     foreach($Addresses as $Address)
    162     {
    163       if(!$this->ValidEmail($Address))
     161    foreach ($Addresses as $Address)
     162    {
     163      if (!$this->ValidEmail($Address))
    164164  throw new Exception(sprintf(T('Mail message invalid address %s'), $Address));
    165165    }
     
    168168  private function ContentEncoding($Charset)
    169169  {
    170     if($Charset != CHARSET_ASCII) return('8bit');
    171       else return('7bit');
     170    if ($Charset != CHARSET_ASCII) return '8bit';
     171      else return '7bit';
    172172  }
    173173
    174174  private function BuildAttachment($Body)
    175175  {
    176     if(count($this->Attachments) > 0)
     176    if (count($this->Attachments) > 0)
    177177    {
    178178      $this->Headers['Content-Type'] = "multipart/mixed;\n boundary=\"PHP-mixed-".$this->Boundary."\"";
     
    181181      $Result .= $Body;
    182182
    183       foreach($this->Attachments as $Attachment)
     183      foreach ($this->Attachments as $Attachment)
    184184      {
    185185        $FileName = $Attachment['FileName'];
     
    187187        $ContentType = $Attachment['FileType'];
    188188        $Disposition = $Attachment['Disposition'];
    189         if($Attachment['Type'] == 'File')
     189        if ($Attachment['Type'] == 'File')
    190190        {
    191           if(!file_exists($FileName))
     191          if (!file_exists($FileName))
    192192            throw new Exception(sprintf(T('Mail message attached file %s can\'t be found'), $FileName));
    193193          $Data = file_get_contents($FileName);
    194194        } else
    195         if($Attachment['Type'] == 'Data') $Data = $Attachment['Data'];
     195        if ($Attachment['Type'] == 'Data') $Data = $Attachment['Data'];
    196196          else $Data = '';
    197197
     
    203203      }
    204204    } else $Result = $Body;
    205     return($Result);
     205    return $Result;
    206206  }
    207207
     
    209209  {
    210210    $Result = '';
    211     if(count($this->Bodies) > 1)
     211    if (count($this->Bodies) > 1)
    212212    {
    213213      $this->Headers['Content-Type'] = 'multipart/alternative; boundary="PHP-alt-'.$this->Boundary.'"';
     
    221221
    222222
    223     foreach($this->Bodies as $Body)
    224     {
    225       if(count($this->Bodies) > 1) $Result .= "\n\n".'--PHP-alt-'.$this->Boundary."\n";
     223    foreach ($this->Bodies as $Body)
     224    {
     225      if (count($this->Bodies) > 1) $Result .= "\n\n".'--PHP-alt-'.$this->Boundary."\n";
    226226      $Result .= 'Content-Type: '.$Body['Type'].'; charset='.$Body['Charset'].
    227227        "\nContent-Transfer-Encoding: ".$this->ContentEncoding($Body['Charset'])."\n\n".$Body['Content']."\n";
    228228    }
    229     return($Result);
     229    return $Result;
    230230  }
    231231}
  • trunk/Packages/Common/NetworkAddress.php

    r1 r7  
    1414  function GetNetMask()
    1515  {
    16     return(0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1));
     16    return 0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1);
    1717  }
    1818
    1919  function AddressToString()
    2020  {
    21     return(implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));
     21    return implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255)));
    2222  }
    2323
     
    3737    $To->Address = $From->Address + $HostMask;
    3838    $To->Prefix = 32;
    39     return(array('From' => $From, 'To' => $To));
     39    return array('From' => $From, 'To' => $To);
    4040  }
    4141
     
    4343  {
    4444    $this->Prefix = $NewPrefix;
    45     if($this->Prefix > 32) $this->Prefix = 32;
    46     if($this->Prefix < 0) $this->Prefix = 0;
     45    if ($this->Prefix > 32) $this->Prefix = 32;
     46    if ($this->Prefix < 0) $this->Prefix = 0;
    4747    $this->Address = $this->Address & $this->GetNetMask();
    4848  }
     
    5151  {
    5252    $UpperNetmask = $this->GetNetMask();
    53     if(($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;
     53    if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;
    5454      else $Result = false;
    5555    //echo($Address->AddressToString().'/'.$Address->Prefix.' in '.$this->AddressToString().'/'.$this->Prefix.' '.$Result."\n");
    56     return($Result);
     56    return $Result;
    5757  }
    5858}
     
    7171  function AddressToString()
    7272  {
    73     return(inet_ntop($this->Address));
     73    return inet_ntop($this->Address);
    7474  }
    7575
     
    8383    $Result = array();
    8484    $Data = array_reverse(unpack('C*', $this->Address));
    85     foreach($Data as $Item)
     85    foreach ($Data as $Item)
    8686    {
    8787
     
    8989      $Result[] = dechex(($Item >> 4) & 15);
    9090    }
    91     return($Result);
     91    return $Result;
    9292  }
    9393
  • trunk/Packages/Common/Page.php

    r1 r7  
    1717  function Show()
    1818  {
    19     return('');
     19    return '';
    2020  }
    2121
     
    2323  {
    2424    $Output = $this->Show();
    25     return($Output);
     25    return $Output;
    2626  }
    2727
    2828  function SystemMessage($Title, $Text)
    2929  {
    30     return(call_user_func_array($this->OnSystemMessage, array($Title, $Text)));
     30    return call_user_func_array($this->OnSystemMessage, array($Title, $Text));
    3131  }
    3232}
  • trunk/Packages/Common/PrefixMultiplier.php

    r1 r7  
    7474  function TruncateDigits($Value, $Digits = 4)
    7575  {
    76     for($II = 2; $II > -6; $II--)
     76    for ($II = 2; $II > -6; $II--)
    7777    {
    78       if($Value >= pow(10, $II))
     78      if ($Value >= pow(10, $II))
    7979      {
    80         if($Digits < ($II + 1)) $RealDigits = $II + 1;
     80        if ($Digits < ($II + 1)) $RealDigits = $II + 1;
    8181          else $RealDigits = $Digits;
    8282        $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1);
     
    8484      }
    8585    }
    86     return($Value);
     86    return $Value;
    8787  }
    8888
     
    9393    $Negative = ($Value < 0);
    9494    $Value = abs($Value);
    95     if(($Unit == '') and ($PrefixType != 'Time'))
    96       return($this->TruncateDigits($Value, $Digits));
     95    if (($Unit == '') and ($PrefixType != 'Time'))
     96      return $this->TruncateDigits($Value, $Digits);
    9797
    9898    $I = $PrefixMultipliers[$PrefixType]['BaseIndex'];
    99     if($Value == 0) return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);
     99    if ($Value == 0) return $Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit;
    100100
    101     if($Value > 1)
     101    if ($Value > 1)
    102102    {
    103       while((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1))
     103      while ((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1))
    104104        $I = $I + 1;
    105105    } else
    106     if($Value < 1)
     106    if ($Value < 1)
    107107    {
    108       while((($I - 1) >= 0) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]) < 1))
     108      while ((($I - 1) >= 0) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]) < 1))
    109109        $I = $I - 1;
    110110    }
     
    113113    // Truncate digits count
    114114    $Value = $this->TruncateDigits($Value, $Digits);
    115     if($Negative) $Value = -$Value;
    116     return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);
     115    if ($Negative) $Value = -$Value;
     116    return $Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit;
    117117  }
    118118}
  • trunk/Packages/Common/RSS.php

    r1 r7  
    2828  "    <pubDate>".date('r')."</pubDate>\n".
    2929  "    <ttl>20</ttl>\n";
    30     foreach($this->Items as $Item)
     30    foreach ($this->Items as $Item)
    3131    {
    3232      $Result .= "    <item>\n".
     
    3939    $Result .= "  </channel>\n".
    4040    "</rss>";
    41     return($Result);
     41    return $Result;
    4242  }
    4343}
  • trunk/Packages/Common/Setup.php

    r1 r7  
    2929      '<input type="submit" name="login" value="'.T('Login').'"/>'.
    3030      '</form>';
    31     return($Output);
     31    return $Output;
    3232  }
    3333
     
    3737
    3838    $Output .= 'Je připojení k databázi: '.$this->YesNo[$this->UpdateManager->Database->Connected()].'<br/>';
    39     if($this->UpdateManager->Database->Connected())
     39    if ($this->UpdateManager->Database->Connected())
    4040    {
    4141      $Output .= 'Je instalováno: '.$this->YesNo[$this->UpdateManager->IsInstalled()].'<br/>';
    42       if($this->UpdateManager->IsInstalled())
     42      if ($this->UpdateManager->IsInstalled())
    4343        $Output .= 'Je aktuální: '.$this->YesNo[$this->UpdateManager->IsUpToDate()].'<br/>'.
    4444        'Verze databáze: '.$this->UpdateManager->GetDbVersion().'<br/>';
    4545      $Output .= 'Verze databáze kódu: '.$this->UpdateManager->Revision.'<br/>';
    46       if($this->UpdateManager->IsInstalled())
    47       {
    48         if(!$this->UpdateManager->IsUpToDate())
     46      if ($this->UpdateManager->IsInstalled())
     47      {
     48        if (!$this->UpdateManager->IsUpToDate())
    4949          $Output .= '<a href="?action=upgrade">'.T('Upgrade').'</a> ';
    5050        $Output .= '<a href="?action=insert_sample_data">Vložit vzorová data</a> ';
     
    5959    $Output .= '<a href="'.$this->System->Link('/').'">'.T('Go to main page').'</a> ';
    6060    $Output .= '';
    61     return($Output);
     61    return $Output;
    6262  }
    6363
     
    7373
    7474    $Output = '';
    75     if(isset($this->Config))
    76     {
    77       if(!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = '';
    78       if(array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword'];
    79       if(sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword'])
     75    if (isset($this->Config))
     76    {
     77      if (!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = '';
     78      if (array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword'];
     79      if (sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword'])
    8080      {
    8181        $Output .= $this->LoginPanel();
    8282      } else
    8383      {
    84         if(array_key_exists('action', $_GET)) $Action = $_GET['action'];
     84        if (array_key_exists('action', $_GET)) $Action = $_GET['action'];
    8585          else $Action = '';
    86         if($Action == 'logout')
     86        if ($Action == 'logout')
    8787        {
    8888          $_SESSION['SystemPassword'] = '';
     
    9090          $Output .= $this->LoginPanel();
    9191        } else
    92         if($Action == 'models')
     92        if ($Action == 'models')
    9393        {
    9494          $this->System->FormManager->UpdateSQLMeta();
    9595        } else
    96         if($Action == 'upgrade')
     96        if ($Action == 'upgrade')
    9797        {
    9898          $Output .= '<h3>Povýšení</h3>';
     
    105105          $Output .= $this->ControlPanel();
    106106        } else
    107         if($Action == 'install')
     107        if ($Action == 'install')
    108108        {
    109109          $Output .= '<h3>Instalace</h3>';
     
    114114          $Output .= $this->ControlPanel();
    115115        } else
    116         if($Action == 'uninstall')
     116        if ($Action == 'uninstall')
    117117        {
    118118          $Output .= '<h3>Odinstalace</h3>';
     
    120120          $Output .= $this->ControlPanel();
    121121        } else
    122         if($Action == 'reload_modules')
     122        if ($Action == 'reload_modules')
    123123        {
    124124          $Output .= '<h3>Znovunačtení seznamu modulů</h3>';
     
    127127          $Output .= $this->ControlPanel();
    128128        } else
    129         if($Action == 'insert_sample_data')
     129        if ($Action == 'insert_sample_data')
    130130        {
    131131          $Output .= '<h3>Vložení vzorových dat</h3>';
     
    133133          $Output .= $this->ControlPanel();
    134134        } else
    135         if($Action == 'modules')
     135        if ($Action == 'modules')
    136136        {
    137137          $Output .= $this->ShowModules();
    138138        } else
    139         if($Action == 'configure_save')
     139        if ($Action == 'configure_save')
    140140        {
    141141           $Output .= $this->ConfigSave($this->Config);
    142142           $Output .= $this->ControlPanel();
    143143        } else
    144         if($Action == 'configure')
     144        if ($Action == 'configure')
    145145        {
    146146          $Output .= $this->PrepareConfig($this->Config);
     
    152152    } else
    153153    {
    154       if(array_key_exists('configure_save', $_POST))
     154      if (array_key_exists('configure_save', $_POST))
    155155      {
    156156        $Output .= $this->ConfigSave(array());
     
    160160      }
    161161    }
    162     return($Output);
     162    return $Output;
    163163  }
    164164
     
    166166  {
    167167    $Output = '';
    168     if(array_key_exists('op', $_GET)) $Operation = $_GET['op'];
     168    if (array_key_exists('op', $_GET)) $Operation = $_GET['op'];
    169169      else $Operation = '';
    170     if($Operation == 'install')
     170    if ($Operation == 'install')
    171171    {
    172172      $this->System->ModuleManager->Modules[$_GET['name']]->Install();
     
    174174      $Output .= 'Modul '.$_GET['name'].' instalován<br/>';
    175175    } else
    176     if($Operation == 'uninstall')
     176    if ($Operation == 'uninstall')
    177177    {
    178178      $this->System->ModuleManager->Modules[$_GET['name']]->Uninstall();
     
    180180      $Output .= 'Modul '.$_GET['name'].' odinstalován<br/>';
    181181    } else
    182     if($Operation == 'enable')
     182    if ($Operation == 'enable')
    183183    {
    184184      $this->System->ModuleManager->Modules[$_GET['name']]->Enable();
     
    186186      $Output .= 'Modul '.$_GET['name'].' povolen<br/>';
    187187    } else
    188     if($Operation == 'disable')
     188    if ($Operation == 'disable')
    189189    {
    190190      $this->System->ModuleManager->Modules[$_GET['name']]->Disable();
     
    192192      $Output .= 'Modul '.$_GET['name'].' zakázán<br/>';
    193193    } else
    194     if($Operation == 'upgrade')
     194    if ($Operation == 'upgrade')
    195195    {
    196196      $this->System->ModuleManager->Modules[$_GET['name']]->Upgrade();
     
    200200    $Output .= '<h3>Správa modulů</h3>';
    201201    $Output .= $this->ShowList();
    202     return($Output);
     202    return $Output;
    203203  }
    204204
     
    221221      array('Name' => '', 'Title' => 'Akce'),
    222222    ));
    223     foreach($this->System->ModuleManager->Modules as $Module)
    224     {
    225       if(($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);
     223    foreach ($this->System->ModuleManager->Modules as $Module)
     224    {
     225      if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);
    226226       else $Dependencies = '&nbsp;';
    227227      $Actions = '';
    228       if($Module->Installed == true)
     228      if ($Module->Installed == true)
    229229      {
    230230        $Actions .= ' <a href="?action=modules&amp;op=uninstall&amp;name='.$Module->Name.'">Odinstalovat</a>';
    231         if($Module->Enabled == true) $Actions .= ' <a href="?action=modules&amp;op=disable&amp;name='.$Module->Name.'">Zakázat</a>';
     231        if ($Module->Enabled == true) $Actions .= ' <a href="?action=modules&amp;op=disable&amp;name='.$Module->Name.'">Zakázat</a>';
    232232        else $Actions .= ' <a href="?action=modules&amp;op=enable&amp;name='.$Module->Name.'">Povolit</a>';
    233         if($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&amp;op=upgrade&amp;name='.$Module->Name.'">Povýšit</a>';
     233        if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&amp;op=upgrade&amp;name='.$Module->Name.'">Povýšit</a>';
    234234      } else $Actions .= ' <a href="?action=modules&amp;op=install&amp;name='.$Module->Name.'">Instalovat</a>';
    235235
     
    244244    $Output .= $Pageing->Show();
    245245    //$Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>';
    246     return($Output);
     246    return $Output;
    247247  }
    248248
     
    250250  {
    251251    $Output = '';
    252     if(!file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir))
     252    if (!file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir))
    253253      $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože složka "'.$this->ConfigDir.'" není povolená pro zápis!';
    254     if(file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir.'/Config.php'))
     254    if (file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir.'/Config.php'))
    255255      $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože soubor "'.$this->ConfigDir.'/Config.php" není povolen pro zápis!';
    256256    $Output .= '<h3>Nastavení systému</h3>'.
    257257        '<form action="?action=configure_save" method="post">'.
    258258        '<table>';
    259     foreach($this->ConfigDefinition as $Def)
     259    foreach ($this->ConfigDefinition as $Def)
    260260    {
    261261      $PathParts = explode('/', $Def['Name']);
    262262      $TempConfig = &$Config;
    263       foreach($PathParts as $Part)
    264         if(array_key_exists($Part, $TempConfig))
     263      foreach ($PathParts as $Part)
     264        if (array_key_exists($Part, $TempConfig))
    265265        {
    266266          $TempConfig = &$TempConfig[$Part];
    267267        }
    268       if(!is_array($TempConfig)) $Value = $TempConfig;
     268      if (!is_array($TempConfig)) $Value = $TempConfig;
    269269        else $Value = $Def['Default'];
    270270      $Output .= '<tr><td>'.$Def['Title'].'</td><td>';
    271       if($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
    272       if($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';
    273       if($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';
    274       if($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
    275       if($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
    276       if($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
    277       if($Def['Type'] == 'Array') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.implode(',', $Value).'"/>';
     271      if ($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
     272      if ($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';
     273      if ($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';
     274      if ($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
     275      if ($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
     276      if ($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
     277      if ($Def['Type'] == 'Array') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.implode(',', $Value).'"/>';
    278278    }
    279279    $Output .= '</td></tr>'.
     
    281281        '</table>'.
    282282        '</form>';
    283     return($Output);
     283    return $Output;
    284284  }
    285285
     
    287287  {
    288288    $Config = $DefaultConfig;
    289     foreach($this->ConfigDefinition as $Def)
     289    foreach ($this->ConfigDefinition as $Def)
    290290    {
    291291      $Value = null;
    292       if($Def['Type'] == 'String') if(array_key_exists($Def['Name'], $_POST))
     292      if ($Def['Type'] == 'String') if (array_key_exists($Def['Name'], $_POST))
    293293        $Value = $_POST[$Def['Name']];
    294       if($Def['Type'] == 'Password') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))
     294      if ($Def['Type'] == 'Password') if (array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))
    295295        $Value = $_POST[$Def['Name']];
    296       if($Def['Type'] == 'PasswordEncoded') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))
     296      if ($Def['Type'] == 'PasswordEncoded') if (array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))
    297297        $Value = sha1($_POST[$Def['Name']]);
    298       if($Def['Type'] == 'Integer') if(array_key_exists($Def['Name'], $_POST))
     298      if ($Def['Type'] == 'Integer') if (array_key_exists($Def['Name'], $_POST))
    299299        $Value = $_POST[$Def['Name']];
    300       if($Def['Type'] == 'Float') if(array_key_exists($Def['Name'], $_POST))
     300      if ($Def['Type'] == 'Float') if (array_key_exists($Def['Name'], $_POST))
    301301        $Value = $_POST[$Def['Name']];
    302       if($Def['Type'] == 'Boolean') if(array_key_exists($Def['Name'], $_POST))
     302      if ($Def['Type'] == 'Boolean') if (array_key_exists($Def['Name'], $_POST))
    303303        $Value = $_POST[$Def['Name']];
    304       if($Def['Type'] == 'Array') if(array_key_exists($Def['Name'], $_POST))
     304      if ($Def['Type'] == 'Array') if (array_key_exists($Def['Name'], $_POST))
    305305        $Value = explode(',', $_POST[$Def['Name']]);
    306       if(!is_null($Value))
     306      if (!is_null($Value))
    307307      {
    308308        $PathParts = explode('/', $Def['Name']);
    309309        $TempConfig = &$Config;
    310         foreach($PathParts as $Part)
     310        foreach ($PathParts as $Part)
    311311        {
    312312          $TempConfig = &$TempConfig[$Part];
    313313        }
    314         if(!is_array($TempConfig)) $TempConfig = $Value;
     314        if (!is_array($TempConfig)) $TempConfig = $Value;
    315315        else $Value = $Def['Default'];
    316316      }
     
    319319    file_put_contents($this->ConfigDir.'/Config.php', $ConfigText);
    320320    $Output = 'Konfigurace nastavena<br/>';
    321     return($Output);
     321    return $Output;
    322322  }
    323323
     
    327327      "\$IsDeveloper = array_key_exists('REMOTE_ADDR', \$_SERVER) and  in_array(\$_SERVER['REMOTE_ADDR'], array('127.0.0.1'));\n\n";
    328328
    329     foreach($this->ConfigDefinition as $Def)
     329    foreach ($this->ConfigDefinition as $Def)
    330330    {
    331331      $PathParts = explode('/', $Def['Name']);
    332332      $Output .= "\$Config";
    333       foreach($PathParts as $Part)
     333      foreach ($PathParts as $Part)
    334334        $Output .= "['".$Part."']";
    335335      $TempConfig = &$Config;
    336336      $Output .= ' = ';
    337       foreach($PathParts as $Part)
    338         if(array_key_exists($Part, $TempConfig))
     337      foreach ($PathParts as $Part)
     338        if (array_key_exists($Part, $TempConfig))
    339339        {
    340340          $TempConfig = &$TempConfig[$Part];
    341341        }
    342       if(!is_array($TempConfig)) $Value = $TempConfig;
     342      if (!is_array($TempConfig)) $Value = $TempConfig;
    343343        else $Value = $Def['Default'];
    344       if($Def['Type'] == 'Array')
     344      if ($Def['Type'] == 'Array')
    345345      {
    346346        $Output .= ' array(';
    347         foreach($Value as $Index => $Item)
     347        foreach ($Value as $Index => $Item)
    348348          $Output .= '\''.$Item.'\', ';
    349349        $Output .= ')';
     
    353353    }
    354354    $Output .= "\n\n";
    355     return($Output);
     355    return $Output;
    356356  }
    357357}
     
    362362  {
    363363    $Output = '';
    364     if(!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>';
     364    if (!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>';
    365365    else {
    366       if(!$this->System->Setup->UpdateManager->IsInstalled())
     366      if (!$this->System->Setup->UpdateManager->IsInstalled())
    367367        $Output .= T('System requires database initialization').'<br>';
    368368      else
    369       if(!$this->System->Setup->UpdateManager->IsUpToDate())
     369      if (!$this->System->Setup->UpdateManager->IsUpToDate())
    370370        $Output .= T('System requires database upgrade').'<br>';
    371371    }
    372372    $Output .= sprintf(T('Front page was not configured. Continue to %s'), '<a href="'.$this->System->Link('/setup/').'">'.T('setup').'</a>');
    373     return($Output);
     373    return $Output;
    374374  }
    375375}
     
    402402  function CheckState()
    403403  {
    404     return($this->Database->Connected() and $this->UpdateManager->IsInstalled() and
    405       $this->UpdateManager->IsUpToDate());
     404    return $this->Database->Connected() and $this->UpdateManager->IsInstalled() and
     405      $this->UpdateManager->IsUpToDate();
    406406  }
    407407
     
    435435  {
    436436    $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->UpdateManager->VersionTable.'"');
    437     return($DbResult->num_rows > 0);
     437    return $DbResult->num_rows > 0;
    438438  }
    439439
     
    443443    $this->UpdateManager->Trace = $Updates->Get();
    444444    $Output = $this->UpdateManager->Upgrade();
    445     return($Output);
     445    return $Output;
    446446  }
    447447}
  • trunk/Packages/Common/Table.php

    r1 r7  
    77  function Show()
    88  {
    9     return('');
     9    return '';
    1010  }
    1111}
     
    1515  function GetCell($Y, $X)
    1616  {
    17     return('');
     17    return '';
    1818  }
    1919
     
    2828  function RowsCount()
    2929  {
    30     return(0);
     30    return 0;
    3131  }
    3232}
     
    3838  function GetCell($Y, $X)
    3939  {
    40     return($this->Cells[$Y][$X]);
     40    return $this->Cells[$Y][$X];
    4141  }
    4242
    4343  function RowsCount()
    4444  {
    45     return(count($this->Cells));
     45    return count($this->Cells);
    4646  }
    4747}
     
    5555  function GetCell($Y, $X)
    5656  {
    57     return($this->Cells[$Y][$X]);
     57    return $this->Cells[$Y][$X];
    5858  }
    5959
     
    6262    $this->Cells = array();
    6363    $DbResult = $this->Database->query($this->Query);
    64     while($DbRow = $DbResult->fetch_row())
     64    while ($DbRow = $DbResult->fetch_row())
    6565    {
    6666      $this->Cells[] = $DbRow;
     
    7575  function RowsCount()
    7676  {
    77     return(count($this->Cells));
     77    return count($this->Cells);
    7878  }
    7979}
     
    112112  {
    113113    $this->Columns = array();
    114     foreach($Columns as $Column)
     114    foreach ($Columns as $Column)
    115115    {
    116116      $NewCol = new TableColumn();
     
    119119      $this->Columns[] = $NewCol;
    120120    }
    121     if(count($this->Columns) > 0)
     121    if (count($this->Columns) > 0)
    122122      $this->DefaultColumn = $this->Columns[0]->Name;
    123123      else $this->DefaultColumn = '';
     
    129129    $Output .= $this->GetOrderHeader();
    130130    $this->Table->BeginRead();
    131     for($Y = 0; $Y < $this->Table->RowsCount(); $Y++)
     131    for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++)
    132132    {
    133133      $Output .= '<tr>';
    134134
    135       for($X = 0; $X < count($this->Columns); $X++)
     135      for ($X = 0; $X < count($this->Columns); $X++)
    136136      {
    137137        $Cell = $this->Table->GetCell($Y, $X);
    138         if($Cell == '') $Output .= '<td>&nbsp;</td>';
     138        if ($Cell == '') $Output .= '<td>&nbsp;</td>';
    139139          else $Output .= '<td>'.$Cell.'</td>';
    140140      }
     
    143143    $this->Table->EndRead();
    144144    $Output .= '</table>';
    145     return($Output);
     145    return $Output;
    146146  }
    147147
    148148  function GetOrderHeader()
    149149  {
    150     if(array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
    151     if(array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];
    152     if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn;
    153     if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder;
     150    if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
     151    if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];
     152    if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn;
     153    if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder;
    154154
    155155    // Check OrderCol
    156156    $Found = false;
    157     foreach($this->Columns as $Column)
     157    foreach ($this->Columns as $Column)
    158158    {
    159       if($Column->Name == $_SESSION['OrderCol'])
     159      if ($Column->Name == $_SESSION['OrderCol'])
    160160      {
    161161        $Found = true;
     
    163163      }
    164164    }
    165     if($Found == false)
     165    if ($Found == false)
    166166    {
    167167      $_SESSION['OrderCol'] = $this->DefaultColumn;
     
    169169    }
    170170    // Check OrderDir
    171     if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1))
     171    if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1))
    172172      $_SESSION['OrderDir'] = 0;
    173173
    174174    $Result = '';
    175175    $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    176     foreach($this->Columns as $Index => $Column)
     176    foreach ($this->Columns as $Index => $Column)
    177177    {
    178178      $QueryItems['OrderCol'] = $Column->Name;
    179179      $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir'];
    180       if($Column->Name == $_SESSION['OrderCol'])
     180      if ($Column->Name == $_SESSION['OrderCol'])
    181181        $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.$this->OrderArrowImage[$_SESSION['OrderDir']].'" alt="order arrow">';
    182182        else $ArrowImage = '';
    183       if($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>';
     183      if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>';
    184184        else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column->Title.$ArrowImage.'</a></th>';
    185185    }
     
    188188    $this->OrderDirection = $_SESSION['OrderDir'];
    189189
    190     return('<tr>'.$Result.'</tr>');
     190    return '<tr>'.$Result.'</tr>';
    191191  }
    192192}
  • trunk/Packages/Common/UTF8.php

    r1 r7  
    529529  {
    530530    $Result = '';
    531     for($I = 0; $I < strlen($String); $I++)
     531    for ($I = 0; $I < strlen($String); $I++)
    532532    {
    533        if(ord($String[$I]) < 128) $Result .= $String[$I];
    534        else if(ord($String[$I]) > 127)
     533       if (ord($String[$I]) < 128) $Result .= $String[$I];
     534       else if (ord($String[$I]) > 127)
    535535       {
    536536         $Result .= $this->CharTable[$Charset][ord($String[$I])];
    537537       }
    538538    }
    539     return($Result);
     539    return $Result;
    540540  }
    541541
     
    544544    $Result = '';
    545545    $UTFPrefix = '';
    546     for($I = 0; $I < strlen($String); $I++)
     546    for ($I = 0; $I < strlen($String); $I++)
    547547    {
    548       if(ord($String{$I}) & 0x80) // UTF control character
     548      if (ord($String{$I}) & 0x80) // UTF control character
    549549      {
    550         if(ord($String{$I}) & 0x40) // First
     550        if (ord($String{$I}) & 0x40) // First
    551551        {
    552           if($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
     552          if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
    553553          $UTFPrefix = $String{$I};
    554554        }
     
    556556      } else
    557557      {
    558         if($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
     558        if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
    559559        $UTFPrefix = '';
    560560        $Result .= $String{$I};
    561561      }
    562562    }
    563     return($Result);
     563    return $Result;
    564564  }
    565565}
  • trunk/Packages/Common/Update.php

    r1 r7  
    2323    $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1');
    2424    $Version = $DbResult->fetch_assoc();
    25     return($Version['Revision']);
     25    return $Version['Revision'];
    2626  }
    2727
     
    2929  {
    3030    $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
    31     return($DbResult->num_rows > 0);
     31    return $DbResult->num_rows > 0;
    3232  }
    3333
    3434  function IsUpToDate()
    3535  {
    36     return($this->Revision <= $this->GetDbVersion());
     36    return $this->Revision <= $this->GetDbVersion();
    3737  }
    3838
     
    4141    $DbRevision = $this->GetDbVersion();
    4242    $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>';
    43     while($this->Revision > $DbRevision)
     43    while ($this->Revision > $DbRevision)
    4444    {
    4545      $TraceItem = $this->Trace[$DbRevision];
     
    5454        $TraceItem['Revision'].' WHERE `Id`=1');
    5555    }
    56     return($Output);
     56    return $Output;
    5757  }
    5858
     
    7979    echo($Query.';<br/>');
    8080    flush();
    81     return($this->Database->query($Query));
     81    return $this->Database->query($Query);
    8282  }
    8383}
  • trunk/Packages/Common/VarDumper.php

    r1 r7  
    4949                self::$_depth=$depth;
    5050                self::dumpInternal($var,0);
    51                 if($highlight)
     51                if ($highlight)
    5252                {
    5353                        $result=highlight_string("<?php\n".self::$_output,true);
     
    6060        private static function dumpInternal($var,$level)
    6161        {
    62                 switch(gettype($var))
     62                switch (gettype($var))
    6363                {
    6464                        case 'boolean':
     
    8484                                break;
    8585                        case 'array':
    86                                 if(self::$_depth<=$level)
     86                                if (self::$_depth<=$level)
    8787                                        self::$_output.='array(...)';
    88                                 else if(empty($var))
     88                                else if (empty($var))
    8989                                        self::$_output.='array()';
    9090                                else
     
    9393                                        $spaces=str_repeat(' ',$level*4);
    9494                                        self::$_output.="array\n".$spaces.'(';
    95                                         foreach($keys as $key)
     95                                        foreach ($keys as $key)
    9696                                        {
    9797                                                self::$_output.="\n".$spaces."    [$key] => ";
     
    102102                                break;
    103103                        case 'object':
    104                                 if(($id=array_search($var,self::$_objects,true))!==false)
     104                                if (($id=array_search($var,self::$_objects,true))!==false)
    105105                                        self::$_output.=get_class($var).'#'.($id+1).'(...)';
    106                                 else if(self::$_depth<=$level)
     106                                else if (self::$_depth<=$level)
    107107                                        self::$_output.=get_class($var).'(...)';
    108108                                else
     
    114114                                        $spaces=str_repeat(' ',$level*4);
    115115                                        self::$_output.="$className#$id\n".$spaces.'(';
    116                                         foreach($keys as $key)
     116                                        foreach ($keys as $key)
    117117                                        {
    118118                                                $keyDisplay=strtr(trim($key),array("\0"=>':'));
Note: See TracChangeset for help on using the changeset viewer.