Changeset 202


Ignore:
Timestamp:
Apr 30, 2009, 11:30:37 PM (15 years ago)
Author:
george
Message:
  • Upraveno: Při chybně vyplněném formuláři zobraz chybové hlášení i obsah formuláře, aby nebylo nutné vše vyplňovat znovu.
  • Přidáno: Možnost povolit v konfiguraci webu formátování výstupního HTML kódu.
  • Opraveno: Validace HTML kódu generování formulářů.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Readme.txt

    r185 r202  
    2626  finance/doklady - vlastníka nastavit na apache
    2727  aktuality/uploads - vlastníka nastavit na apache
     28
    2829 
    29305) Generování PDF dokumentů
  • trunk/aktuality/index.php

    r196 r202  
    179179            if($Row['Name'] == '') $Author = $Row['Author'];
    180180              else $Author = $Row['Name'];
    181             $Output .= '<div style="border: thin dotted #97ADFF; background: #F6F7FF; margin-top: 5px; padding: 0px 5px 5px 5px;"><div style="padding-bottom: 1px; border-bottom-width: 1; border-bottom-style: solid; border-bottom-color: silver;"><strong><a href="?action=view&id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')</strong>';
     181            $Output .= '<div style="border: thin dotted #97ADFF; background: #F6F7FF; margin-top: 5px; padding: 0px 5px 5px 5px;"><div style="padding-bottom: 1px; border-bottom-width: 1; border-bottom-style: solid; border-bottom-color: silver;"><strong><a href="?action=view&amp;id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')</strong>';
    182182            if($this->System->Modules['User']->User['Id'] == $Row['User'])
    183183            {
  • trunk/config.sample.php

    r189 r202  
    1414  'Web' => array
    1515  (
     16    'FormatHTML' => false,
    1617    'Charset' => 'utf-8',
    1718    'Host' => 'localhost',
  • trunk/form_classes.php

    r189 r202  
    5151    'Title' => 'Základní nastavení',
    5252    'Table' => 'User',
     53    'SubmitText' => 'Uložit',
    5354    'Items' => array(
    5455      'Login' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => ''),
     
    6263  'UserRegister' => array(
    6364    'Title' => 'Registrace uživatele',
     65    'SubmitText' => 'Registrovat',
    6466    'Table' => 'User',
    6567    'Items' => array(
     
    9092  'PasswordRecovery' => array(
    9193    'Title' => 'Obnova hesla',
     94    'SubmitText' => 'Obnovit',
    9295    'Table' => '',
    9396    'Items' => array(
    9497      'Name' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => ''),
    9598      'Email' => array('Type' => 'String', 'Caption' => 'E-mail', 'Default' => ''),
     99    ),
     100  ),
     101  'UserLogin' => array(
     102    'Title' => 'Přihlášení uživatele',
     103    'SubmitText' => 'Přihlásit',
     104    'Table' => '',
     105    'Items' => array(
     106      'Username' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => ''),
     107      'Password' => array('Type' => 'Password', 'Caption' => 'Heslo', 'Default' => ''),
    96108    ),
    97109  ),
  • trunk/forms.php

    r187 r202  
    99  var $Values = array();
    1010  var $OnSubmit = '';
    11 
     11 
    1212  function Form($ClassName)
    1313  { 
     
    1919  function ShowEditForm()
    2020  {
    21     $Output = '<form action="'.$this->OnSubmit.'" method="post"><center>'.$this->ShowEditBlock().'<input type="submit" value="Uložit"></center></form>';
     21    if(!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';
     22    $Output = '<form class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock().'<div><input type="submit" value="'.$this->Definition['SubmitText'].'" /></div></form>';
    2223    return($Output);
    2324  }
     
    3940        case 'Boolean':
    4041          if($this->Values[$Index] == 0) $Checked = ''; else $Checked = ' CHECKED';
    41           $Edit = '<input type="checkbox" name="'.$Context.$Index.'"'.$Checked.'>';
     42          $Edit = '<input type="checkbox" name="'.$Context.$Index.'"'.$Checked.' />';
    4243          break;
    4344        case 'String':
    44           $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">';
    45           break;
    46         case 'Password':
    47           $Edit = '<input type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">';
     45          $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';
     46          break;
     47        case 'Password':
     48          $Edit = '<input type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';
    4849          break;
    4950        case 'Integer':
    50           $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">';
     51          $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';
    5152          break;
    5253        case 'Float':
    53           $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">';
     54          $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';
    5455          break;
    5556        case 'Time':
    5657          if($this->Values[$Index] == 'Now') $this->Values[$Index] = date('j.n.Y');
    57           $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">';
     58          $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';
    5859          break;
    5960        case 'Array':
     
    6970            "scr.parentNode.insertBefore(newcontent, scr); }".
    7071            '</script>';
    71             $Edit .= '<form><input type="button" onclick="AddItem();" value="Přidat položku"></form>';
     72            $Edit .= '<form><input type="button" onclick="AddItem();" value="Přidat položku" /></form>';
    7273          break;
    7374        default:
     
    101102      array_push($Table['Rows'], array($Item['Caption'].':', $Edit));
    102103    }
    103     $Output = '<fieldset style="width: 500px;"><legend>'.$this->Definition['Title'].'</legend>'.Table($Table).
     104    $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.Table($Table).
    104105    '</fieldset>';
    105106    return($Output);
     
    166167    foreach($this->Definition['Items'] as $Index => $Item)
    167168    {
     169      if(array_key_exists($Context.$Index, $_POST))
    168170      switch($Item['Type'])
    169171      {
     
    227229{
    228230  $Result = '<table class="BasicTable">';
    229   $Result .= '<tr>';
    230231  if(array_key_exists('Header', $Table))
    231232  {
     233    $Result .= '<tr>';
    232234    foreach($Table['Header'] as $Item)
    233235      $Result .= '<th>'.$Item.'</th>';
  • trunk/index.php

    r197 r202  
    6868    'fun' => array('Zábava',
    6969            array('Youtube', 'http://www.youtube.com/', ''),
     70            array('Stream.cz', 'http://www.stream.cz/', ''),
    7071      array('Last.fm', 'http://www.last.fm/', ''),   
    7172    ),
     
    100101  function InfoBar()
    101102  {
    102     $this->Database->select_db('is');
     103    global $Config;
     104   
     105    $Database->select_db($Config['Database']['Database']);
    103106
    104107    $Output2 = '';
     
    197200  function GetServerUptime()
    198201  {
    199     $Data = explode(' ',exec('uptime'));
     202    $Data = explode(' ', exec('uptime'));
    200203    $Data = array_slice($Data, 3, -8);
    201204    $Uptime = '';
     
    227230      if($_GET['Action'] == 'LoginForm')
    228231      {
    229         $Output .= '<form action="?Action=Login" method="post"><center><fieldset style="width: 500px;"><legend>Přihlašovací údaje</legend>'.
    230         '<table class="hidden">'.
    231         '<tr align="left"><td colspan="2">Jméno:</td></tr>'.
    232         '<tr align="left"><td colspan="2"><input type="text" name="Username" size="40" maxlength="16" /></td></tr>'.
    233               '<tr align="left"><td colspan="2">Heslo:</td></tr>'.
    234               '<tr align="left"><td colspan="2"><input type="password" name="Password" size="40" maxlength="16" /></td></tr>'.
    235               '<tr><td colspan="2">&nbsp;</td></tr>'.
    236               '<tr align="left">'.
    237                   //<td><input type="checkbox" name="remember" value="1" checked="checked" /> Trvalé přihlášení</td>
    238                     '<td align="center" colspan="2"><input type="submit" value="Přihlásit" /></td>'.
    239               '</tr>'.
    240         '<tr align="left">'.
    241                     '<td><a href="?Action=UserRegister">Registrovat se</a></td>'.
    242                     '<td><a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></td>'.
    243               '</tr>'.
    244         '</table>'.
    245         '</fieldset></center>'.
    246         '</form>';
    247 //        $Output .= $this->SystemMessage('Test', $Output);
     232        $Form = new Form('UserLogin');
     233        $Form->OnSubmit = '?Action=Login';
     234        $Output .= $Form->ShowEditForm();
     235        $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '.
     236                    '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
    248237      } else
    249238      if($_GET['Action'] == 'Login')
    250239      {
    251         $Output .= $this->SystemMessage('Přihlášení', $this->System->Modules['User']->Login($_POST['Username'], $_POST['Password']));
     240        $Form = new Form('UserLogin');
     241        $Form->OnSubmit = '?Action=Login';
     242        $Result = $this->System->Modules['User']->Login($_POST['Username'], $_POST['Password']);
     243        $Output .= $this->SystemMessage('Přihlášení', $Result);
     244        if($Result <> USER_LOGGED_IN)
     245        {
     246          $Form->LoadValuesFromForm();
     247          $Form->Values['Password'] = '';
     248          $Output .= $Form->ShowEditForm();
     249          $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '.
     250                    '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
     251        }
    252252      } else
    253253      if($_GET['Action'] == 'Logout')
     
    275275      if($_GET['Action'] == 'UserRegister')
    276276      {
    277         $UserRegister = new Form('UserRegister');
    278         $UserRegister->OnSubmit = '?Action=UserRegisterSave';
    279         $Output .= $UserRegister->ShowEditForm();
     277        $Form = new Form('UserRegister');
     278        $Form->LoadValuesFromForm();
     279        $Form->OnSubmit = '?Action=UserRegisterSave';
     280        $Output .= $Form->ShowEditForm();
    280281      } else
    281282      if($_GET['Action'] == 'UserRegisterConfirm')
    282283      {
    283           $Output .= $this->SystemMessage('Potvrzení registrace', $this->System->Modules['User']->RegisterConfirm($_GET['User'], $_GET['H']));
     284        $Output .= $this->SystemMessage('Registrace nového účtu', $this->System->Modules['User']->RegisterConfirm($_GET['User'], $_GET['H']));
    284285      } else
    285286      if($_GET['Action'] == 'PasswordRecovery')
     
    293294        $Form = new Form('PasswordRecovery');
    294295        $Form->LoadValuesFromForm();
    295 
    296         $Output .= $this->SystemMessage('Obnova hesla', $this->System->Modules['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']));
     296        $Result = $this->System->Modules['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
     297        $Output .= $this->SystemMessage('Obnova hesla', $Result);
     298        if($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
     299        {
     300          $Output .= $Form->ShowEditForm();
     301        }       
    297302      } else
    298303      if($_GET['Action'] == 'PasswordRecoveryConfirm')
     
    302307      if($_GET['Action'] == 'UserRegisterSave')
    303308      {
    304         $UserRegister = new Form('UserRegister', array());
    305         $UserRegister->LoadValuesFromForm();
    306         $Output .= $this->SystemMessage('Nastavení', $this->System->Modules['User']->Register($UserRegister->Values['Login'], $UserRegister->Values['Password'], $UserRegister->Values['Password2'], $UserRegister->Values['Email'], $UserRegister->Values['Name'], $UserRegister->Values['PhoneNumber'], $UserRegister->Values['ICQ']));
     309        $Form = new Form('UserRegister', array());
     310        $Form->LoadValuesFromForm();
     311        $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name'], $Form->Values['PhoneNumber'], $Form->Values['ICQ']);
     312        $Output .= $this->SystemMessage('Nastavení', $Result);
     313        if($Result <> USER_REGISTRATED)
     314        {
     315          $Form->OnSubmit = '?Action=UserRegisterSave';
     316          $Output .= $Form->ShowEditForm();
     317        }
    307318      } else
    308319      if($_GET['Action'] == 'MemberOptions')
     
    344355    }
    345356
    346     $Database->select_db('is');
     357    $Database->select_db($Config['Database']['Database']);
    347358
    348359    //$Output .= $this->InfoBar();
  • trunk/page.php

    r197 r202  
    172172  function GetOutput()
    173173  {
     174    global $Config;
     175   
    174176    $Output = $this->Show();
    175177    $Output = $this->ShowHeader($this->FullTitle, $this->ShortTitle).$Output;
    176178    $Output .= $this->ShowFooter();
    177     //echo($this->FormatOutput($Output));
    178     echo($Output);
     179    if($Config['Web']['FormatHTML'] == true) echo($this->FormatOutput($Output));
     180    else echo($Output);
    179181  }
    180182
  • trunk/style.css

    r165 r202  
    179179}
    180180
     181.Centred
     182{
     183  text-align: center;
     184  margin-left: auto;
     185  margin-right: auto;
     186}
     187
     188.Form
     189{
     190  width: 500px;
     191  text-align: center;
     192  margin-left: auto;
     193  margin-right: auto;
     194}
     195
    181196.BasicTable
    182197{
    183198  width: 100%;
     199  text-align: center;
     200  margin-left: auto;
     201  margin-right: auto;
    184202}
    185203
Note: See TracChangeset for help on using the changeset viewer.