Changeset 9 for types


Ignore:
Timestamp:
Oct 11, 2008, 11:06:21 PM (16 years ago)
Author:
george
Message:
  • Přidáno: Částečná podpora pro historii všech záznamů. Editace vytváří nový záznam. Zobrazení historie dané položky.
Location:
types
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • types/Hyperlink.php

    r8 r9  
    33function TypeHyperlinkViewHtml($Type, $Item)
    44{
    5   $Output = '<a href="'.$Item['Name'].'">'.$Item['Value'].'</a>';
     5  $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>';
    66  return($Output);
    77}
    88
    9 function TypeHyperlinkEditHtml($Type, $Parameter, $Table, $Id)
     9function TypeHyperlinkEditHtml($Type, $Item)
    1010{
    1111  $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
  • types/Password.php

    r8 r9  
    11<?php
    22
    3 function TypePasswordViewHtml($Type, $Parameter, $Table, $Id)
     3function TypePasswordViewHtml($Type, $Item)
    44{
    55  $Output = '';
     
    99}
    1010
    11 function TypePasswordEditHtml($Type, $Parameter, $Table, $Id)
     11function TypePasswordEditHtml($Type, $Item)
    1212{
    1313  $Output = '<input type="password" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
  • types/PointerOneToOne.php

    r8 r9  
    11<?php
    22
    3 function TypePointerOneToOneViewHtml($Type, $Item)
     3function GetTablePointerName($Type, $Item)
    44{
    55  global $Database, $Lists;
    66
    7   //print_r($Type);
    8   $Output = '';
    97  $Columns = '';
    108  $ItemType = explode(':', $Item['Type']);
     
    1816  if($DbResult->num_rows > 0)
    1917  {
    20     $DbRow = $DbResult->fetch_array();
    21     $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$DbRow['Id'].'">'.$DbRow['Name'].'</a>';
    22   }
     18    return($DbResult->fetch_assoc());
     19  } else return('');
     20}
     21
     22function GetTablePointerNameList($Type, $Item)
     23{
     24  global $Database, $Lists;
     25
     26  $Columns = '';
     27  $ItemType = explode(':', $Item['Type']);
     28  $TargetTable = $ItemType[1];
     29
     30  foreach($Lists[$TargetTable]['Items'] as $ListItem)
     31    if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
     32  $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
     33  $DbResult = $Database->select($TargetTable, $Columns);
     34  //echo($Database->LastQuery);
     35  if($DbResult->num_rows > 0)
     36  {
     37    $Result = array();
     38    while($DbRow = $DbResult->fetch_assoc())
     39      $Result[] = $DbRow;
     40    return($Result);
     41  } else return(array());
     42}
     43
     44function TypePointerOneToOneViewHtml($Type, $Item)
     45{
     46  global $Database, $Lists;
     47
     48  $ItemType = explode(':', $Item['Type']);
     49  $TargetTable = $ItemType[1];
     50  $TargetName = GetTablePointerName($Type, $Item);
     51  $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName['Id'].'">'.$TargetName['Name'].'</a>';
    2352  return($Output);
    2453}
     
    2958
    3059  $Output = '<select name="'.$Item['Name'].'">';
    31   $Columns = '';
    32   $ItemType = explode(':', $Item['Type']);
    33   $TargetTable = $ItemType[1];
    34   foreach($Lists[$TargetTable]['Items'] as $ListItem)
    35     if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
    36   $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
    37   $DbResult = $Database->select($TargetTable, $Columns);
     60  $TargetNameList = GetTablePointerNameList($Type, $Item);
    3861  //echo($Database->LastQuery);
    39   while($DbRow = $DbResult->fetch_array())
     62  foreach($TargetNameList as $TargetName)
    4063  {
    41     if($Parameter == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';
    42     $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Name'].'</option>';
     64    if($Item['Value'] == $TargetName['Id']) $Selected = ' selected="1"'; else $Selected = '';
     65    $Output .= '<option value="'.$TargetName['Id'].'"'.$Selected.'>'.$TargetName['Name'].'</option>';
    4366  }
    4467  $Output .= '</select>';
Note: See TracChangeset for help on using the changeset viewer.