Changeset 5


Ignore:
Timestamp:
Sep 15, 2008, 10:44:29 PM (16 years ago)
Author:
george
Message:
  • Upraveno: Definice typů přesunuty do databáze tabulky SystemType. Funkční pro každý typ je řešena jako samostatný soubor v podsložce types se stejným jménem jako je jméno typu.
Files:
9 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • base.php

    r4 r5  
    44include('lists.php');
    55include('common.php');
     6
     7// Include type definitions
     8include('types/Enumeration.php');
     9include('types/Boolean.php');
     10include('types/Integer.php');
     11include('types/String.php');
     12include('types/PointerOneToMany.php');
     13include('types/PointerOneToOne.php');
     14include('types/Date.php');
     15include('types/Password.php');
    616
    717function ShowList($List, $Column = '', $ParentId = 0)
     
    5464        $Type = $Types[$ItemType[0]];
    5565        if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1];
    56         if(is_callable($Type['ViewHtml'])) $Value = $Type['ViewHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']);
    57         else $Value = $Type['ViewHtml'];
     66        if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']);
     67        else $Value = $Type['CallbackView'];
    5868        $Value = str_replace('%value%', $DbRow[$Index], $Value);
    5969        $Output .= '<td>'.$Value.'</td>';
     
    8494        $Type = $Types[$ItemType[0]];
    8595        if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1];
    86         if(is_callable($Type['EditHtml'])) $Value = $Type['EditHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']);
    87         else $Value = $Type['EditHtml'];
     96        if(is_callable($Type['CallbackEdit'])) $Value = $Type['CallbackEdit']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']);
     97        else $Value = $Type['CallbackEdit'];
    8898        $Value = str_replace('%value%', $DbRow[$Index], $Value);
    8999        $Value = str_replace('%name%', $Index, $Value);
     
    131141      $Type = $Types[$ItemType[0]];
    132142      if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1];
    133       if(is_callable($Type['EditHtml'])) $Value = $Type['EditHtml']($Type, $Type['InitValue'], $List['TableName'], 0);
    134       else $Value = $Type['EditHtml'];
     143      if(is_callable($Type['CallbackEdit'])) $Value = $Type['CallbackEdit']($Type, $Type['InitValue'], $List['TableName'], 0);
     144      else $Value = $Type['CallbackEdit'];
    135145      $Value = str_replace('%value%', $Type['InitValue'], $Value);
    136146      $Value = str_replace('%name%', $Index, $Value);
     
    180190        $Type = $Types[$ItemType[0]];
    181191        if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1];
    182         if(is_callable($Type['ViewHtml'])) $Value = $Type['ViewHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']);
    183         else $Value = $Type['ViewHtml'];
     192        if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']);
     193        else $Value = $Type['CallbackView'];
    184194        $Value = str_replace('%value%', $DbRow[$Index], $Value);
    185195        $Output .= '<tr><td>'.$Item['TextBefore'].':</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>';
     
    297307}
    298308
     309function LoadTypeDefinition()
     310{
     311  global $Database, $Types;
     312
     313  $Types = array();
     314  $DbResult = $Database->select('SystemType', '*');
     315  while($DbRow = $DbResult->fetch_assoc())
     316  {
     317    $DbRow['Parameters'] = explode('|', $DbRow['Parameters']);
     318    $Types[$DbRow['Name']] = $DbRow;
     319  }
     320
     321  // Merge parent type definition
     322  foreach($Types as $Index => $Type)
     323  {
     324    if($Type['ParentType'] != '')
     325    {
     326      foreach($Type as $Index2 => $Item)
     327        if($Item == '')
     328      {
     329        $Types[$Index][$Index2] = $Types[$Type['ParentType']][$Index2];
     330      }
     331    }
     332  }
     333  //print_r($Types);
     334}
     335
    299336?>
  • index.php

    r4 r5  
    1616    </head><body><table class="base"><tr><td class="menu">';
    1717
     18LoadTypeDefinition();
    1819LoadListDefinition();
    1920$Output .= $Output;
Note: See TracChangeset for help on using the changeset viewer.