Changeset 19 for base.php


Ignore:
Timestamp:
Oct 22, 2008, 9:12:20 AM (16 years ago)
Author:
george
Message:
  • Upraveno: Typy přepsány z procedurálního zápisu na objektový.
  • Přidáno: Zobrazení špičky použité paměti.
  • Opraveno: Needitovat položky s neaktivním příznakem Editovatelné.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • base.php

    r18 r19  
    5858
    5959  $DbResult = $Database->query('SELECT t1.* FROM `'.$List['TableName'].'` AS t1 LEFT JOIN `'.$List['TableName'].'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)'.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);
     60  //echo($Database->LastQuery);
    6061  while($DbRow = $DbResult->fetch_assoc())
    6162  {
     
    135136      }
    136137    }
    137     //print_r($TypeNames);
    138     //print_r($Types);
    139138    $Item = array('Name' => 'Author', 'Type' => $TypeNames['PointerToUser']);
    140     //print_r($Item);
    141     $ItemType = explode('|', $Types[$Item['Type']]['Parameters']);
    142     $Type = $Types[$ItemType[0]];
    143139    $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
    144     if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ItemDefinition);
    145       else $Value = $Type['CallbackView'];
    146     $Output .= '<td>'.$Value.'</td>';
     140    $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>';
    147141
    148142    $Output .= '<td>'.$DbRow['CreationTime'].'</td><td>'.$DbRow['DeletionTime'].'</td>';
     
    168162      if($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany')
    169163      {
    170         $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     164        if($Item['Editable'] == 1)
     165        {
     166          $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     167        } else $DefinitionItems[] = array('Name' => $Index, 'Type' => 'Hidden', 'Caption' => '', 'Value' => $DbRow[$Index]);
    171168      }
    172169    }
     
    241238    {
    242239      if($Item['Required'] == 1) $Required = '*'; else $Required = '';
    243       $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['TableName'], 'SourceItemId' => 0);
     240      if($Item['Editable'] == 1)
     241        $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['TableName'], 'SourceItemId' => 0);
    244242    } else
    245243    if($Item['Name'] == $Column)
     
    308306}
    309307
    310 function ShowViewItem($List, $Id)
     308function ShowViewItem($List, $Id,  $Column = '', $ColumnValue = 0)
    311309{
    312310  global $Database, $Types, $Lists;
     
    318316  {
    319317    $DefinitionItems = array();
     318    $Required = '';
    320319    foreach($List['Items'] as $Index => $Item)
    321320    {
     
    372371  global $Lists, $Database;
    373372
     373  $Output = '';
    374374  $DbResult = $Database->query('SELECT t1.* FROM `SystemMenu` AS t1 LEFT JOIN `SystemMenu` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL)');
    375375  while($DbRow = $DbResult->fetch_assoc())
     
    421421          break;
    422422        case 'ViewItem':
    423           $Output = ShowViewItem($List, $_SESSION['Item']);
     423          $Output = ShowViewItem($List, $_SESSION['Item'], $_SESSION['Column'], $_SESSION['ColumnValue']);
    424424          break;
    425425        case 'AddItem':
     
    434434        case 'ShowList':
    435435        default:
    436           $Output = ShowList($List);
    437       }
    438     } else $Output = ShowList($List);
     436          $Output = ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']);
     437      }
     438    } else $Output = ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']);
    439439  }
    440440  return($Output);
     
    505505function ExecuteTypeEvent($Type, $Event, $Parameters)
    506506{
    507   global $Types;
    508 
    509   $Callback = 'Type'.$Types[$Type]['BaseType'].$Event;
     507  global $Types, $TypeDefinitionList;
     508
     509  $TypeObject = $TypeDefinitionList[$Types[$Type]['BaseType']];
    510510  //echo($Callback.',');
    511   if(is_callable($Callback)) return($Callback($Parameters));
    512     else return($Callback.'('.$Type.')');
     511  if(is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters));
     512    else return($Types[$Type]['BaseType'].'->'.$Event.'('.$Type.')');
    513513}
    514514
Note: See TracChangeset for help on using the changeset viewer.