Changeset 8
- Timestamp:
- May 9, 2008, 10:39:00 AM (17 years ago)
- Location:
- branches/2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2/database.php
r5 r8 9 9 var $LastQuery = ''; 10 10 11 function query($Query) 12 { 13 $this->LastQuery = $Query; 14 return(parent::query($Query)); 15 } 16 11 17 function select($Table, $What = '*', $Condition = 1) 12 18 { -
branches/2/frontend.php
r7 r8 34 34 function Login() 35 35 { 36 $Output = $this->System->Modules['User']->Login($_POST['Username'], $_POST['Password']); 37 $this->System->Modules['User']->Check(); 38 return($Output); 39 } 40 41 function Logout() 42 { 43 $Output = $this->System->Modules['User']->Logout(); 44 $this->System->Modules['User']->Check(); 45 return($Output); 46 } 47 48 function ShowText($TranslationGroupId) 49 { 36 50 37 return($this->System->Modules['User']->Login($_POST['Username'], $_POST['Password'])); 38 } 39 40 function Logout() 41 { 42 43 return($this->System->Modules['User']->Logout()); 44 } 45 46 function TranslationGroupEdit($TranslationGroupId) 47 { 48 $Output = '<strong>Překlad textů:</strong><br /><table class="TranslationTable">'; 49 foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem) 50 { 51 $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td><div><textarea name="GroupItem'.$GroupItem['Id'].'">'.$GroupItem['Text'].'</textarea></div></td></tr>'; 52 } 53 $Output .= '</table>'; 51 $TextList = $this->System->Modules['Translation']->GetMultipleText($TranslationGroupId, $_GET['Index']); 52 if(count($TextList) == 0) 53 { 54 // Edit new text 55 $Output = '<strong>Překlad textů:</strong><table class="TranslationTable">'; 56 foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem) 57 { 58 $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td><div><textarea name="GroupItem'.$GroupItem['Id'].'">'.$GroupItem['Text'].'</textarea></div></td></tr>'; 59 } 60 $Output .= '</table>'; 61 } 62 else if(count($TextList) == 1) 63 { 64 // Show only one 65 $Output = '<strong>Zobrazení textu:</strong><table class="TranslationTable">'; 66 foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem) 67 { 68 $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td>'.$GroupItem['Text'].'</td></tr>'; 69 } 70 $Output .= '</table>'; 71 } else 72 { 73 // Show multiple possibilites 74 $Output = '<strong>Více překladů jednoho textu:</strong><table class="TranslationTable">'. 75 '<tr><th>ID</th><th>Titulek</th></tr>'; 76 foreach($TextList as $Text) 77 { 78 $Output .= '<tr><td>'.$Text['Index'].'</td><td><a href="?Action=ShowText&GroupId='.$Text['Id'].'">'.$Text['Text'].'</a></td></tr>'; 79 } 80 $Output .= '</table>'; 81 } 54 82 return($Output); 55 83 } … … 59 87 $ItemPerPage = 30; 60 88 if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0; 61 $Output = '<strong>Seznam textů:</strong><br/>'; 89 $Output = '<strong>Seznam textů:</strong><table>'. 90 '<tr><th>ID</th><th>Titulek</th><th>Překladů</th></tr>'; 62 91 foreach($this->System->Modules['Translation']->GetTextGroupList($GroupId, 1, 1, $Page, $ItemPerPage) as $Translation) 63 92 { 64 93 if(strlen($Translation['Text']) > 30) $Translation['Text'] = substr($Translation['Text'], 0, 30).'...'; 65 $Output .= $Translation['Index'].'. <a href="?Action=TranslationGroupEdit&GroupId='.$Translation['Id'].'">'.$Translation['Text'].'</a><br />';66 } 67 $Output .= $this->System->PagesList('?Action=TextGroupList&GroupId='.$GroupId.'&Page=', $Page, $this->System->Modules['Translation']->GetTextGroupListCount($GroupId, 1, 1), $ItemPerPage);94 $Output .= '<tr><td>'.$Translation['Index'].'</td><td><a href="?Action=ShowText&GroupId='.$Translation['Id'].'&Index='.$Translation['Index'].'">'.$Translation['Text'].'</a></td><td>'.($Translation['TextCount'] - 1).'</td></tr>'; 95 } 96 $Output .= '</table>'.$this->System->PagesList('?Action=TextGroupList&GroupId='.$GroupId.'&Page=', $Page, $this->System->Modules['Translation']->GetTextGroupListCount($GroupId, 1, 1), $ItemPerPage); 68 97 return($Output); 69 98 } … … 71 100 function TranslationGroupList() 72 101 { 73 $Output = '<strong>Seznam skupin:</strong><br/>'; 102 $Output = '<strong>Seznam skupin:</strong><table>'. 103 '<tr><th>Skupina textů</th><th>Počet textů</th></tr>'; 74 104 foreach($this->System->Modules['Translation']->GetTranslationGroupList() as $Group) 75 105 { 76 $Output .= '< a href="?Action=TextGroupList&GroupId='.$Group['Id'].'">'.$Group['Name'].'</a><br />';106 $Output .= '<tr><td><a href="?Action=TextGroupList&GroupId='.$Group['Id'].'">'.$Group['Name'].'</a></td><td>'.$Group['TextCount'].'</td></tr>'; 77 107 } 78 108 return($Output); … … 84 114 '<a href="?">Uvodní stránka</a><br />'. 85 115 '<a href="?Action=TranslationGroupList">Seznam skupin</a><br />'. 86 '<a href="?Action=MangosImport">Import z MaNGOSu</a><br />'.87 116 '<br />'; 88 117 return($Output); … … 92 121 { 93 122 $Output = 'Uživatel: '.$this->System->Modules['User']->User['Name'].' '; 94 if($this->System->Modules['User']->User['Id'] == 0) $Output .= '<a href="?Action=LoginDialog">Přihlásit</a>';123 if($this->System->Modules['User']->User['Id'] == 1) $Output .= '<a href="?Action=LoginDialog">Přihlásit</a>'; 95 124 else $Output .= '<a href="?Action=Logout">Odhlásit</a>'; 96 125 97 126 return($Output.'<br />'); 98 127 } 99 128 129 function UserMenu() 130 { 131 $Output = '<strong>Uživatelské menu</strong><br />'; 132 $Permission = &$this->System->Modules['User']->User['Permission']; 133 if($Permission[9]['Read']) $Output .= '<a href="?Action=PermissionMatrix">Tabulka oprávnění</a><br />'; 134 if($Permission[4]['Read']) $Output .= '<a href="?Action=UserOptions">Nastavení účtu</a><br />'; 135 if($Permission[2]['Read']) $Output .= '<a href="?Action=UserTextList">Přeložené texty</a><br />'; 136 if($Permission[3]['Read']) $Output .= '<a href="?Action=UserNewText">Nový překlad</a><br />'; 137 if($Permission[5]['Read']) $Output .= '<a href="?Action=Import">Import</a><br />'; 138 return($Output.'<br />'); 139 } 140 141 function UserOptions() 142 { 143 $Output = ''; 144 return($Output); 145 } 146 147 function PermissionMatrix() 148 { 149 $Output = '<table>'; 150 $Matrix = $this->System->Modules['User']->PermissionMatrix(); 151 $ShowHeader = 1; 152 foreach($Matrix as $RowIndex => $Row) 153 { 154 if($ShowHeader == 1) 155 { 156 $Output .= '<tr><th> </th>'; 157 foreach($Row as $ColumnIndex => $Column) 158 $Output .= '<th>'.$ColumnIndex.'</th>'; 159 $Output .= '</tr>'; 160 $ShowHeader = 0; 161 } 162 $Output .= '<tr><th>'.$RowIndex.'</th>'; 163 foreach($Row as $ColumnIndex => $Column) 164 $Output .= '<td>'.$Column.'</td>'; 165 $Output .= '</tr>'; 166 } 167 $Output .= '</table>'; 168 return($Output); 169 } 170 171 function UserTextList($GroupId) 172 { 173 $ItemPerPage = 30; 174 if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0; 175 $Output = '<strong>Seznam vašich textů:</strong><br/>'; 176 foreach($this->System->Modules['Translation']->GetTextGroupList($GroupId, $this->System->Modules['User']->User['Id'], 1, $Page, $ItemPerPage) as $Translation) 177 { 178 if(strlen($Translation['Text']) > 30) $Translation['Text'] = substr($Translation['Text'], 0, 30).'...'; 179 $Output .= $Translation['Index'].'. <a href="?Action=TranslationGroupEdit&GroupId='.$Translation['Id'].'">'.$Translation['Text'].'</a><br />'; 180 } 181 $Output .= $this->System->PagesList('?Action=TextGroupList&GroupId='.$GroupId.'&Page=', $Page, $this->System->Modules['Translation']->GetTextGroupListCount($GroupId, 1, 1), $ItemPerPage); 182 return($Output); 183 } 184 185 function Import() 186 { 187 return('<a href="?Action=ImportMangos">Import z Mangosu</a><br />'. 188 '<a href="?Action=ImportOldSystem">Import ze starého systému</a><br />'); 189 } 100 190 101 191 function Output() … … 114 204 $Output = $this->Logout(); 115 205 break; 116 case ' TranslationGroupEdit':117 $Output = $this-> TranslationGroupEdit($_GET['GroupId']);206 case 'ShowText': 207 $Output = $this->ShowText($_GET['GroupId']); 118 208 break; 119 209 case 'TextGroupList': … … 123 213 $Output = $this->TranslationGroupList(); 124 214 break; 125 case 'MangosImport': 126 $Output = $this->System->Modules['MangosImport']->FullImport(); 215 case 'PermissionMatrix': 216 $Output = $this->PermissionMatrix(); 217 break; 218 case 'UserOptions': 219 $Output = $this->UserOptions(); 220 break; 221 case 'UserTextList': 222 $Output = $this->UserTextList(); 223 break; 224 case 'Import': 225 $Output = $this->Import(); 226 break; 227 case 'ImportMangos': 228 $Output = $this->System->Modules['MangosImport']->ImportFromMangos(); 229 break; 230 case 'ImportOldSystem': 231 $Output = $this->System->Modules['MangosImport']->ImportOldMangos(); 127 232 break; 128 233 } 129 234 else $Output = ''; 130 return($this->Header().'<table class="MainLayout"><tr><td id="LeftPanel">'.$this->User().$this->Menu(). '</td><td>'.$Output.'</td></tr></table>'.$this->Footer());235 return($this->Header().'<table class="MainLayout"><tr><td id="LeftPanel">'.$this->User().$this->Menu().$this->UserMenu().'</td><td class="MainLayoutTd">'.$Output.'</td></tr></table>'.$this->Footer()); 131 236 } 132 237 } -
branches/2/mangos_import.php
r5 r8 3 3 class MangosImport extends Module 4 4 { 5 function FullImport()5 function ImportFromMangos() 6 6 { 7 7 $Output = ''; … … 44 44 return($Output); 45 45 } 46 47 function ImportOldSystem() 48 { 49 } 46 50 } 47 51 -
branches/2/style.css
r7 r8 24 24 } 25 25 26 table 27 { 28 border-width: 1px; 29 border-style: solid; 30 border-color: black; 31 border-spacing: 0px; 32 } 33 34 table td 35 { 36 border-width: 1px; 37 border-style: solid; 38 border-color: black; 39 padding: 2px 5px 2px 5px; 40 } 41 42 table th 43 { 44 border-width: 1px; 45 border-style: solid; 46 border-color: black; 47 padding: 2px 5px 2px 5px; 48 } 49 26 50 textarea 27 51 { … … 37 61 } 38 62 39 .MainLayout td63 .MainLayoutTd 40 64 { 65 border: 0; 41 66 vertical-align: top; 42 67 } … … 44 69 .MainLayout #LeftPanel 45 70 { 71 border: 0; 46 72 width: 200px; 73 vertical-align: top; 47 74 } -
branches/2/translation.php
r6 r8 6 6 { 7 7 $Result = array(); 8 $DbResult = $this->Database-> select('TranslationGroup', '*');8 $DbResult = $this->Database->query('SELECT `TranslationGroup`.*, (SELECT COUNT(*) FROM `TextGroup` WHERE `TextGroup`.`Group` = `TranslationGroup`.`Id`) AS `TextCount` FROM `TranslationGroup`'); 9 9 while($DbRow = $DbResult->fetch_array()) 10 10 { … … 44 44 { 45 45 $Result = array(); 46 $DbResult = $this->Database->query('SELECT `TextGroup`.*, (SELECT `Text` FROM `Text` WHERE `Text`.`TranslationGroup` = `TextGroup`.`Id` LIMIT 1) as `Text` FROM `TextGroup`WHERE `TextGroup`.`Group`='.$GroupId.' AND `TextGroup`.`User`='.$UserId.' AND `TextGroup`.`Language`='.$Language.' LIMIT '.($Page * $ItemPerPage).','.$ItemPerPage);46 $DbResult = $this->Database->query('SELECT `TextGroup`.*, (SELECT `Text` FROM `Text` WHERE `Text`.`TranslationGroup` = `TextGroup`.`Id` LIMIT 1) as `Text`, (SELECT COUNT(`TextGroup2`.`User`) FROM `TextGroup` AS `TextGroup2` WHERE `TextGroup2`.`Id` = `TextGroup`.`Id`) as `TextCount` FROM `TextGroup` WHERE `TextGroup`.`Group`='.$GroupId.' AND `TextGroup`.`User`='.$UserId.' AND `TextGroup`.`Language`='.$Language.' LIMIT '.($Page * $ItemPerPage).','.$ItemPerPage); 47 47 //echo($this->Database->LastQuery); 48 48 if($DbResult->num_rows > 0) … … 62 62 return($DbRow[0]); 63 63 } 64 65 function GetMultipleText($GroupId, $Index) 66 { 67 $Result = array(); 68 $DbResult = $this->Database->query('SELECT `TextGroup`.*, (SELECT `Text` FROM `Text` WHERE `Text`.`TranslationGroup` = `TextGroup`.`Id` LIMIT 1) as `Text` FROM `TextGroup` WHERE `TextGroup`.`Group`='.$GroupId.' AND `TextGroup`.`Index` = '.$Index.' AND `TextGroup`.`Language` != 1'); 69 //echo($this->Database->LastQuery); 70 if($DbResult->num_rows > 0) 71 while($DbRow = $DbResult->fetch_array()) 72 { 73 $Result[] = $DbRow; 74 } 75 return($Result); 76 } 64 77 } 65 78 -
branches/2/user.php
r7 r8 16 16 class User extends Module 17 17 { 18 var $Roles = array( 'Člen', 'Uživatel', 'Administrator');18 var $Roles = array(); 19 19 var $User = array(); 20 var $DefaultRole = 2; 20 21 21 22 function Check() 22 23 { 23 24 $SID = session_id(); 25 24 26 // Lookup user record 25 27 $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"'); … … 28 30 // Refresh time of last access 29 31 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('Time' => 'NOW()')); 30 } else $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => 0, 'Time' => 'NOW()', 'IpAddress' => (gethostbyaddr(GetRemoteAddress()).' '.GetRemoteAddress())));32 } else $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => 1, 'Time' => 'NOW()', 'IpAddress' => (gethostbyaddr(GetRemoteAddress()).' '.GetRemoteAddress()))); 31 33 32 34 // Odeber neaktivní uživatele … … 38 40 if($Row['User'] != 0) 39 41 { 40 $Query = $this->Database->select('User', '*', "Id= '".$Row['User']."'");42 $Query = $this->Database->select('User', '*', "Id=".$Row['User'].""); 41 43 $this->User = $Query->fetch_array(); 42 44 $Result = USER_LOGGED; 43 45 } else { 44 $this->User = array('FullName' => 'Návštěvník', 'Id' => 0, 'Name' => 'Anonym'); 46 $Query = $this->Database->select('User', '*', "Id=1"); 47 $this->User = $Query->fetch_array(); 45 48 $Result = USER_NOT_LOGGED; 46 49 } 50 $this->LoadPermission($this->User['Role']); 51 52 // Role and permission 53 $this->LoadRoles(); 54 47 55 } 48 56 … … 59 67 else 60 68 { 61 $this->Database->insert('User', array('Name' => addslashes($Nick), 'FullName' => addslashes($FullName), 'Password' => addslashes($Password), 'Email' => htmlspecialchars($Email), ' Permission' => 1));69 $this->Database->insert('User', array('Name' => addslashes($Nick), 'FullName' => addslashes($FullName), 'Password' => addslashes($Password), 'Email' => htmlspecialchars($Email), 'Role' => $this->DefaultRole)); 62 70 $Result = USER_REGISTRATED; 63 71 } … … 89 97 { 90 98 $SID = session_id(); 91 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => 0));99 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => 1)); 92 100 return(USER_LOGGED_OUT); 101 } 102 103 function LoadRoles() 104 { 105 $this->Roles = array(); 106 $DbResult = $this->Database->select('UserRole', '*'); 107 while($DbRow = $DbResult->fetch_array()) 108 $this->Roles[] = $DbRow; 109 } 110 111 function LoadPermission($Role) 112 { 113 $this->User['Permission'] = array(); 114 $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description` FROM `UserRolePermission` JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` WHERE `UserRolePermission`.`Role` = '.$Role); 115 if($DbResult->num_rows > 0) 116 while($DbRow = $DbResult->fetch_array()) 117 $this->User['Permission'][$DbRow['Operation']] = $DbRow; 118 } 119 120 function PermissionMatrix() 121 { 122 $Result = array(); 123 $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description`, `UserRole`.`Title` FROM `UserRolePermission` LEFT JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` LEFT JOIN `UserRole` ON `UserRole`.`Id` = `UserRolePermission`.`Role`'); 124 while($DbRow = $DbResult->fetch_array()) 125 { 126 $Value = ''; 127 if($DbRow['Read']) $Value .= 'R'; 128 if($DbRow['Write']) $Value .= 'W'; 129 $Result[$DbRow['Description']][$DbRow['Title']] = $Value; 130 } 131 return($Result); 93 132 } 94 133 }
Note:
See TracChangeset
for help on using the changeset viewer.