Changeset 880 for trunk/includes/PageEdit.php
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/PageEdit.php
r838 r880 16 16 ); 17 17 $this->AllowEdit = false; 18 if ($this->AllowEdit) $this->ItemActions[] = array('Name' => T('Delete'), 'URL' => '?action=remove&id=#Id');18 if ($this->AllowEdit) $this->ItemActions[] = array('Name' => T('Delete'), 'URL' => '?action=remove&id=#Id'); 19 19 } 20 20 … … 22 22 { 23 23 $Output = ''; 24 if (array_key_exists('action', $_GET))24 if (array_key_exists('action', $_GET)) 25 25 { 26 if ($_GET['action'] == 'add') $Output .= $this->AddItem();27 else if ($_GET['action'] == 'view') $Output .= $this->ViewItem();28 else if ($_GET['action'] == 'edit') $Output .= $this->ModifyItem();29 else if ($_GET['action'] == 'remove') $Output .= $this->RemoveItem();30 else if ($_GET['action'] == 'delete') $Output .= $this->DeleteItem();26 if ($_GET['action'] == 'add') $Output .= $this->AddItem(); 27 else if ($_GET['action'] == 'view') $Output .= $this->ViewItem(); 28 else if ($_GET['action'] == 'edit') $Output .= $this->ModifyItem(); 29 else if ($_GET['action'] == 'remove') $Output .= $this->RemoveItem(); 30 else if ($_GET['action'] == 'delete') $Output .= $this->DeleteItem(); 31 31 else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL); 32 32 } else $Output .= $this->ViewList(); 33 return ($Output);33 return $Output; 34 34 } 35 35 … … 37 37 { 38 38 $DbResult = $this->Database->query('SELECT * FROM ('.$this->TableSQL.') AS `T` WHERE `Id`='.$_GET['id']); 39 if ($DbResult->num_rows > 0)39 if ($DbResult->num_rows > 0) 40 40 { 41 41 $DbRow = $DbResult->fetch_assoc(); … … 43 43 $Output = T('Item'). 44 44 '<table>'; 45 foreach ($this->Definition as $DefIndex => $Def)45 foreach ($this->Definition as $DefIndex => $Def) 46 46 { 47 47 $Output .= '<tr><td>'.$Def['Title'].':</td><td>'.$this->ViewControl($Def['Type'], $DefIndex, $DbRow[$DefIndex]).'</tr>'; … … 50 50 '</table>'; 51 51 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 52 if ($this->AllowEdit)52 if ($this->AllowEdit) 53 53 { 54 54 $Output .= '<a href="?action=add">'.T('Add').'</a> '; … … 57 57 } 58 58 $Output .= '<a href="?">'.T('List').'</a><br/>'; 59 return ($Output);59 return $Output; 60 60 } 61 61 … … 69 69 $Output .= '<table class="BaseTable">'; 70 70 $TableColumns = array(); 71 foreach ($this->Definition as $Index => $Def)72 if ($Def['InList'])71 foreach ($this->Definition as $Index => $Def) 72 if ($Def['InList']) 73 73 $TableColumns[] = array('Name' => $Index, 'Title' => $Def['Title']); 74 if (count($this->ItemActions) > 0)74 if (count($this->ItemActions) > 0) 75 75 $TableColumns[] = array('Name' => '', 'Title' => 'Akce'); 76 76 … … 79 79 80 80 $DbResult = $this->Database->query('SELECT * FROM ('.$this->Table.') '.$Order['SQL'].$PageList['SQLLimit']); 81 while ($Item = $DbResult->fetch_assoc())81 while ($Item = $DbResult->fetch_assoc()) 82 82 { 83 83 $Output .= '<tr>'; 84 foreach ($this->Definition as $Index => $Def)85 if ($Def['InList'])84 foreach ($this->Definition as $Index => $Def) 85 if ($Def['InList']) 86 86 { 87 if ($Def['Type'] == 'URL') $Output .= '<td><a href="'.$Item[$Index].'">'.$Item[$Index].'</a></td>';87 if ($Def['Type'] == 'URL') $Output .= '<td><a href="'.$Item[$Index].'">'.$Item[$Index].'</a></td>'; 88 88 else $Output .= '<td>'.$Item[$Index].'</td>'; 89 89 } 90 if (count($this->ItemActions) > 0)90 if (count($this->ItemActions) > 0) 91 91 { 92 92 $Output .= '<td>'; 93 foreach ($this->ItemActions as $Index => $Action)93 foreach ($this->ItemActions as $Index => $Action) 94 94 { 95 95 $URL = $Action['URL']; 96 if (strpos($URL, '#Id')) $URL = str_replace('#Id', $Item['Id'], $URL);96 if (strpos($URL, '#Id')) $URL = str_replace('#Id', $Item['Id'], $URL); 97 97 $Output .= '<a href="'.$URL.'">'.$Action['Name'].'</a> '; 98 98 } … … 102 102 } 103 103 $Output .= '</table>'; 104 if ($this->AllowEdit) $Output .= '<a href="?action=add">'.T('Add').'</a><br/>';105 return ($Output);104 if ($this->AllowEdit) $Output .= '<a href="?action=add">'.T('Add').'</a><br/>'; 105 return $Output; 106 106 } 107 107 … … 109 109 { 110 110 $Output = ''; 111 if ($this->System->User->Licence(LICENCE_USER))111 if ($this->System->User->Licence(LICENCE_USER)) 112 112 { 113 if (array_key_exists('finish', $_GET))113 if (array_key_exists('finish', $_GET)) 114 114 { 115 115 $Items = array(); 116 foreach ($this->Definition as $Index => $Def)116 foreach ($this->Definition as $Index => $Def) 117 117 { 118 118 $Items[$Index] = $_POST[$Index]; … … 125 125 '<fieldset><legend>'.T('New item').'</legend>'. 126 126 '<table>'; 127 foreach ($this->Definition as $DefIndex => $Def)127 foreach ($this->Definition as $DefIndex => $Def) 128 128 { 129 129 $Output .= '<tr><td>'.$Def['Title'].':</td><td>'.$this->GetControl($Def['Type'], $DefIndex, '').'</tr>'; … … 135 135 } 136 136 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 137 return ($Output);137 return $Output; 138 138 } 139 139 140 140 function DeleteItem() 141 141 { 142 if ($this->System->User->Licence(LICENCE_USER))142 if ($this->System->User->Licence(LICENCE_USER)) 143 143 { 144 144 $this->Database->query('DELETE FROM `'.$this->Table.'` WHERE (`User`='.$this->System->User->Id.') AND (`Id`='.($_GET['id'] * 1).')'); 145 145 $Output = ShowMessage(T('Record removed')); 146 146 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 147 return ($Output);147 return $Output; 148 148 } 149 149 150 150 function GetControl($Type, $Name, $Value) 151 151 { 152 if ($Type == 'Text') $Output = '<input type="text" name="'.$Name.'" value="'.$Value.'"/>';153 else if ($Type == 'Boolean') $Output = '<input type="checkbox" name="'.$Name.'"/>';152 if ($Type == 'Text') $Output = '<input type="text" name="'.$Name.'" value="'.$Value.'"/>'; 153 else if ($Type == 'Boolean') $Output = '<input type="checkbox" name="'.$Name.'"/>'; 154 154 else $Output = '<input type="text" name="'.$Name.'" value="'.$Value.'"/>'; 155 return ($Output);155 return $Output; 156 156 } 157 157 158 158 function ViewControl($Type, $Name, $Value) 159 159 { 160 if ($Type == 'Text') $Output = $Value;161 else if ($Type == 'URL') $Output = '<a href="'.$Value.'">'.$Value.'</a>';162 else if ($Type == 'Boolean') $Output = $Value;160 if ($Type == 'Text') $Output = $Value; 161 else if ($Type == 'URL') $Output = '<a href="'.$Value.'">'.$Value.'</a>'; 162 else if ($Type == 'Boolean') $Output = $Value; 163 163 else $Output = $Value; 164 return ($Output);164 return $Output; 165 165 } 166 166 }
Note:
See TracChangeset
for help on using the changeset viewer.