Legend:
- Unmodified
- Added
- Removed
-
base.php
r6 r8 1 1 <?php 2 include('database.php');3 include('common.php');4 2 5 3 // Include type definitions … … 15 13 include('types/Hyperlink.php'); 16 14 17 function ShowList($List, $Column = '', $ColumnValue = 0 )15 function ShowList($List, $Column = '', $ColumnValue = 0, $Title = '') 18 16 { 19 17 global $Database, $Types, $Config; 20 18 21 $Output = '<div>'.$List['Title'].'</div><table class="WideTable"><tr>'; 19 if($Title == '') $Output = '<div>'.$List['Title'].'</div>'; 20 else $Output = '<div>'.$Title.'</div>'; 21 $Output .= '<table class="WideTable"><tr>'; 22 22 foreach($List['Items'] as $Item) 23 23 { … … 52 52 { 53 53 $OrderDirection = array('ASC', 'DESC'); 54 $ Where .= 'ORDER BY `'.$_SESSION['OrderColumn'].'` '.$OrderDirection[$_SESSION['OrderDirection']];55 } 54 $Order = 'ORDER BY `'.$_SESSION['OrderColumn'].'` '.$OrderDirection[$_SESSION['OrderDirection']]; 55 } else $Order = ''; 56 56 57 57 if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0; 58 //$Where .= ' AND (ValidFromTime <= NOW()) AND ((ValidToTime >= NOW()) OR (ValidToTime IS NULL))'; 59 $Where .= ' '.$Order; 58 60 $DbResult = $Database->select($List['TableName'], 'COUNT(*)', $Where); 59 61 //echo($Database->LastQuery); … … 71 73 $ItemType = explode(':', $Item['Type']); 72 74 $Type = $Types[$ItemType[0]]; 73 if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1];74 if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ DbRow[$Index], $List['TableName'], $DbRow['Id']);75 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 76 if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ItemDefinition); 75 77 else $Value = $Type['CallbackView']; 76 $Value = str_replace('%value%', $DbRow[$Index], $Value);77 78 $Output .= '<td>'.$Value.'</td>'; 78 79 } … … 101 102 { 102 103 $Type = $Types[$ItemType[0]]; 103 if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1];104 if(is_callable($Type['CallbackEdit'])) $Value = $Type['CallbackEdit']($Type, $ DbRow[$Index], $List['TableName'], $DbRow['Id']);104 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 105 if(is_callable($Type['CallbackEdit'])) $Value = $Type['CallbackEdit']($Type, $ItemDefinition); 105 106 else $Value = $Type['CallbackEdit']; 106 $Value = str_replace('%value%', $DbRow[$Index], $Value); 107 $Value = str_replace('%name%', $Index, $Value); 108 if($Item['Required'] == 1) $Required = ' *'; else $Required = ''; 107 if($Item['Required'] == 1) $Required = '*'; else $Required = ''; 109 108 $Output .= '<tr><td>'.$Item['TextBefore'].':'.$Required.'</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>'; 110 109 } … … 147 146 global $Database, $Types; 148 147 149 $Output = '<form action="?Action=AddItemFinish" method="post"><table class="WideTable">'; 150 $Output .= '<tr><th>Jméno položky</th><th>Hodnota</th></tr>'; 148 $DefinitionItems = array(); 151 149 $AfterTableOutput = ''; 152 150 foreach($List['Items'] as $Index => $Item) … … 155 153 if(($ItemType[0] != 'PointerOneToMany') and ($Item['Name'] != $Column)) 156 154 { 157 $Type = $Types[$ItemType[0]]; 158 if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1]; 159 if(is_callable($Type['CallbackEdit'])) $Value = $Type['CallbackEdit']($Type, $Type['InitValue'], $List['TableName'], 0); 160 else $Value = $Type['CallbackEdit']; 161 $Value = str_replace('%value%', $Type['InitValue'], $Value); 162 $Value = str_replace('%name%', $Index, $Value); 163 if($Item['Required'] == 1) $Required = ' *'; else $Required = ''; 164 $Output .= '<tr><td>'.$Item['TextBefore'].':'.$Required.'</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>'; 155 if($Item['Required'] == 1) $Required = '*'; else $Required = ''; 156 $DefinitionItems[] = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['TableName'], 'SourceItemId' => 0); 165 157 } else 166 158 if($Item['Name'] == $Column) 167 159 { 168 $AfterTableOutput = '<input type="hidden" name="'.$Column.'" value="'.$ColumnValue.'" />'; 169 } 170 } 171 $Output .= '</table>'.$AfterTableOutput.'<input type="submit" value="Přidat"></form>'; 160 $DefinitionItems[] = array('Name' => $Column, 'Type' => 'String', 'Caption' => '', 'Value' => $ColumnValue); 161 } 162 } 163 $Form = new Form(); 164 $Form->Definition = array 165 ( 166 'Title' => 'Titulek', 167 'SubmitBuffonText' => 'Přidat', 168 'Items' => $DefinitionItems, 169 ); 170 $Form->OnSubmit = '?Action=AddItemFinish'; 171 $Output .= $Form->ShowEditForm().$AfterTableOutput; 172 172 if(($Column != '') and ($ColumnValue != 0)) 173 173 { … … 216 216 { 217 217 $Type = $Types[$ItemType[0]]; 218 if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1];219 if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ DbRow[$Index], $List['TableName'], $DbRow['Id']);218 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 219 if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ItemDefinition); 220 220 else $Value = $Type['CallbackView']; 221 $Value = str_replace('%value%', $DbRow[$Index], $Value);222 221 $Output .= '<tr><td>'.$Item['TextBefore'].':</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>'; 223 222 } … … 241 240 { 242 241 $SubList = $Lists[$ItemType[1]]; 243 $Output .= ShowList($SubList, $ItemType[2], $DbRow['Id'] ).'<br /><br />';242 $Output .= ShowList($SubList, $ItemType[2], $DbRow['Id'], $Item['TextBefore']).'<br /><br />'; 244 243 } 245 244 }
Note:
See TracChangeset
for help on using the changeset viewer.