Changeset 8 for types


Ignore:
Timestamp:
Sep 29, 2008, 2:35:42 PM (16 years ago)
Author:
george
Message:
  • Přidáno: Částečná podpora pro přihlašování uživatelů.
  • Přepracováno: Funkce pro generování formulářů podle dynamické definice namísto přímého generování podle databáze. Všechny formuláře nemají odpovídající strukturu v databázi.
Location:
types
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • types/Boolean.php

    r5 r8  
    11<?php
    22
    3 function TypeBooleanViewHtml($Type, $Parameter, $Table, $Id)
     3function TypeBooleanViewHtml($Type, $Item)
    44{
    5   return('<input type="checkbox" name="%name%" value="%value%" disabled="1">');
     5  return('<input type="checkbox" name="'.$Item['Name'].'" value="'.$Item['Value'].'" disabled="1">');
    66}
    77
    8 function TypeBooleanEditHtml($Type, $Parameter, $Table, $Id)
     8function TypeBooleanEditHtml($Type, $Item)
    99{
    10   return('<input type="checkbox" name="%name%" value="%value%">');
     10  return('<input type="checkbox" name="'.$Item['Name'].'" value="'.$Item['Value'].'">');
    1111}
    1212
  • types/Date.php

    r5 r8  
    33$MonthList = array('0', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
    44
    5 function TypeDateViewHtml($Type, $Parameter, $Table, $Id)
     5function TypeDateViewHtml($Type, $Item)
    66{
    77  global $MonthList;
    88
    9   $Parts = explode('-', $Parameter);
     9  $Parts = explode('-', $Item['Value']);
    1010
    1111  $Output = ($Parts[2] * 1).'.'.$MonthList[$Parts[1] * 1].'.'.$Parts[0];
     
    1313}
    1414
    15 function TypeDateEditHtml($Type, $Parameter, $Table, $Id)
     15function TypeDateEditHtml($Type, $Item)
    1616{
    1717  global $MonthList;
    1818
    19   $Parts = explode('-', $Parameter);
     19  $Parts = explode('-', $Item['Value']);
    2020
    2121  // Day
    22   $Output = '<select name="%name%-day">';
     22  $Output = '<select name="'.$Item['Name'].'-day">';
    2323  for($I = 1; $I <= 31; $I++)
    2424  {
     
    2828  $Output .= '</select>';
    2929  // Month
    30   $Output .= '<select name="%name%-month">';
     30  $Output .= '<select name="'.$Item['Name'].'-month">';
    3131  for($I = 1; $I <= 12; $I++)
    3232  {
     
    3636  $Output .= '</select>';
    3737  // Year
    38   $Output .= '<select name="%name%-month">';
     38  $Output .= '<select name="'.$Item['Name'].'-month">';
    3939  for($I = 1900; $I < 2100; $I++)
    4040  {
  • types/Enumeration.php

    r5 r8  
    11<?php
    22
    3 function TypeEnumerationViewHtml($Type, $Parameter, $Table, $Id)
     3function TypeEnumerationViewHtml($Type, $Item)
    44{
    5   $Output = $Type['Parameters'][$Parameter];
     5  $Output = $Type['Parameters'][$Item['Value']];
    66  return($Output);
    77}
    88
    9 function TypeEnumerationEditHtml($Type, $Parameter, $Table, $Id)
     9function TypeEnumerationEditHtml($Type, $Item)
    1010{
    11   $Output = '<select name="%name%">';
     11  $Output = '<select name="'.$Item['Name'].'">';
    1212  foreach($Type['Parameters'] as $Index => $StateName)
    1313  {
  • types/Float.php

    r6 r8  
    11<?php
    22
    3 function TypeFloatViewHtml($Type, $Parameter, $Table, $Id)
     3function TypeFloatViewHtml($Type, $Item)
    44{
    5   $Output = '%value%';
     5  $Output = $Item['Value'];
    66  return($Output);
    77}
    88
    9 function TypeFloatEditHtml($Type, $Parameter, $Table, $Id)
     9function TypeFloatEditHtml($Type, $Item)
    1010{
    11   $Output = '<input type="text" name="%name%" value="%value%">';
     11  $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
    1212  return($Output);
    1313}
  • types/Hyperlink.php

    r6 r8  
    11<?php
    22
    3 function TypeHyperlinkViewHtml($Type, $Parameter, $Table, $Id)
     3function TypeHyperlinkViewHtml($Type, $Item)
    44{
    5   $Output = '<a href="%value%">%value%</a>';
     5  $Output = '<a href="'.$Item['Name'].'">'.$Item['Value'].'</a>';
    66  return($Output);
    77}
     
    99function TypeHyperlinkEditHtml($Type, $Parameter, $Table, $Id)
    1010{
    11   $Output = '<input type="text" name="%name%" value="%value%">';
     11  $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
    1212  return($Output);
    1313}
  • types/Integer.php

    r5 r8  
    11<?php
    22
    3 function TypeIntegerViewHtml($Type, $Parameter, $Table, $Id)
     3function TypeIntegerViewHtml($Type, $Item)
    44{
    5   $Output = '%value%';
     5  $Output = $Item['Value'];
    66  return($Output);
    77}
    88
    9 function TypeIntegerEditHtml($Type, $Parameter, $Table, $Id)
     9function TypeIntegerEditHtml($Type, $Item)
    1010{
    11   $Output = '<input type="text" name="%name%" value="%value%">';
     11  $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
    1212  return($Output);
    1313}
  • types/Password.php

    r5 r8  
    33function TypePasswordViewHtml($Type, $Parameter, $Table, $Id)
    44{
    5   $Output = '%value%';
     5  $Output = '';
     6  for($I = 0; $I < strlen($Item['Value']); $I++)
     7    $Output .= '*';
    68  return($Output);
    79}
     
    911function TypePasswordEditHtml($Type, $Parameter, $Table, $Id)
    1012{
    11   $Output = '<input type="password" name="%name%" value="%value%">';
     13  $Output = '<input type="password" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
    1214  return($Output);
    1315}
  • types/PointerOneToMany.php

    r5 r8  
    11<?php
    22
    3 function TypePointerOneToManyViewHtml($Type, $Parameter, $Table, $Id)
     3function TypePointerOneToManyViewHtml($Type, $Item)
    44{
    5   $Output = '<a href="?Action=ShowList&amp;TableId='.$Type['TypeDefinition'].'&amp;ParentTable='.$Table.'&amp;ParentColumn='.$Id.'">Seznam</a>';
     5  $Output = '<a href="?Action=ShowList&amp;TableId='.$Type['TypeDefinition'].'&amp;ParentTable='.$Item['SourceTable'].'&amp;ParentColumn='.$Item['SourceItemId'].'">Seznam</a>';
    66  return($Output);
    77}
    88
    9 function TypePointerOneToManyEditHtml($Type, $Parameter, $Table, $Id)
     9function TypePointerOneToManyEditHtml($Type, $Item)
    1010{
    11   $Output = '<a href="?Action=ShowList&amp;TableId='.$Type['TypeDefinition'].'&amp;ParentTable='.$Table.'&amp;ParentColumn='.$Id.'">Seznam</a>';
     11  $Output = '<a href="?Action=ShowList&amp;TableId='.$Type['TypeDefinition'].'&amp;ParentTable='.$Item['SourceTable'].'&amp;ParentColumn='.$Item['SourceItemId'].'">Seznam</a>';
    1212  return($Output);
    1313}
  • types/PointerOneToOne.php

    r6 r8  
    11<?php
    22
    3 function TypePointerOneToOneViewHtml($Type, $Parameter, $Table, $Id)
     3function TypePointerOneToOneViewHtml($Type, $Item)
    44{
    55  global $Database, $Lists;
    66
     7  //print_r($Type);
    78  $Output = '';
    89  $Columns = '';
    9   foreach($Lists[$Type['Parameter']]['Items'] as $ListItem)
     10  $ItemType = explode(':', $Item['Type']);
     11  $TargetTable = $ItemType[1];
     12
     13  foreach($Lists[$TargetTable]['Items'] as $ListItem)
    1014    if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
    1115  $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
    12   $DbResult = $Database->select($Type['Parameter'], $Columns, 'Id='.$Parameter);
     16  $DbResult = $Database->select($TargetTable, $Columns, 'Id='.$Item['Value']);
    1317  //echo($Database->LastQuery);
    1418  if($DbResult->num_rows > 0)
    1519  {
    1620    $DbRow = $DbResult->fetch_array();
    17     $Output = '<a href="?Action=ViewItem&amp;Table='.$Type['Parameter'].'&amp;Item='.$DbRow['Id'].'">'.$DbRow['Name'].'</a>';
     21    $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$DbRow['Id'].'">'.$DbRow['Name'].'</a>';
    1822  }
    1923  return($Output);
    2024}
    2125
    22 function TypePointerOneToOneEditHtml($Type, $Parameter, $Table, $Id)
     26function TypePointerOneToOneEditHtml($Type, $Item)
    2327{
    2428  global $Database, $Lists;
    2529
    26   $Output = '<select name="%name%">';
     30  $Output = '<select name="'.$Item['Name'].'">';
    2731  $Columns = '';
    28   foreach($Lists[$Type['Parameter']]['Items'] as $ListItem)
     32  $ItemType = explode(':', $Item['Type']);
     33  $TargetTable = $ItemType[1];
     34  foreach($Lists[$TargetTable]['Items'] as $ListItem)
    2935    if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
    3036  $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
    31   $DbResult = $Database->select($Type['Parameter'], $Columns);
     37  $DbResult = $Database->select($TargetTable, $Columns);
    3238  //echo($Database->LastQuery);
    3339  while($DbRow = $DbResult->fetch_array())
  • types/String.php

    r5 r8  
    11<?php
    22
    3 function TypeStringViewHtml($Type, $Parameter, $Table, $Id)
     3function TypeStringViewHtml($Type, $Item)
    44{
    5   $Output = '%value%';
     5  $Output = $Item['Value'];
    66  return($Output);
    77}
    88
    9 function TypeStringEditHtml($Type, $Parameter, $Table, $Id)
     9function TypeStringEditHtml($Type, $Item)
    1010{
    11   $Output = '<input type="text" name="%name%" value="%value%">';
     11  $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
    1212  return($Output);
    1313}
Note: See TracChangeset for help on using the changeset viewer.