Changeset 383 for trunk/Common
- Timestamp:
- Jan 23, 2012, 10:37:31 AM (14 years ago)
- Location:
- trunk/Common
- Files:
-
- 24 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Global.php
r379 r383 18 18 include_once('HTML.php'); 19 19 include_once('XHTML.php'); 20 include_once('URL.php'); 20 21 include_once('PageList.php'); 21 22 include_once('TableHeader.php'); … … 23 24 include_once('ViewList.php'); 24 25 include_once('ViewForm.php'); 26 include_once('Types/Type.php'); 25 27 26 28 … … 28 30 { 29 31 var $Pages = array(); 32 var $Type; 33 34 function __construct($Database) 35 { 36 parent::__construct($Database); 37 $this->Type = new Type($this); 38 } 30 39 31 40 function HumanDate($Time) … … 39 48 40 49 return($Config['Web']['RootFolder'].$Target); 41 } 50 } 42 51 } 43 52 -
trunk/Common/Module.php
r379 r383 77 77 var $Modules = array(); 78 78 var $Models = array(); 79 var $Menu = array(); 79 80 80 81 function __construct($Database) … … 92 93 //DebugLog('Loading modules...'); 93 94 $this->Modules = array(); 94 $Query = 'SELECT `Id`, `Name` FROM `SystemModule`';95 $Query = 'SELECT `Id`, `Name`,`Installed` FROM `SystemModule`'; 95 96 if($Installed) $Query .= ' WHERE `Installed`=1'; 96 else $Query .= ' WHERE `Installed`=0';97 else $Query .= ''; // WHERE `Installed`=0'; 97 98 $DbResult = $this->Database->query($Query); 98 99 while($Module = $DbResult->fetch_array()) … … 103 104 $NewModule = new $ModuleClassName($this->Database, $this); 104 105 $NewModule->Id = $Module['Id']; 106 $NewModule->Installed = $Module['Installed']; 105 107 $this->Modules[$Module['Name']] = $NewModule; 106 108 } … … 146 148 $this->LoadModules(false); 147 149 foreach($this->Modules as $Index => $Module) 148 { 150 { 149 151 $this->Modules[$Index]->Install(); 150 152 } -
trunk/Common/PageList.php
r373 r383 72 72 } 73 73 } 74 if($PagesMax < ($PageCount - 1)) $ Result .= ' ... ';74 if($PagesMax < ($PageCount - 1)) $this->Output .= ' ... '; 75 75 if($this->Page < ($PageCount - 1)) 76 76 { -
trunk/Common/TableHeader.php
r373 r383 13 13 var $Columns; 14 14 var $QueryString; 15 var $System; 15 16 16 17 function __construct($System) 17 18 { 18 parent::__construct($System); 19 //parent::__construct($System); 20 $this->System = &$System; 21 $this->Order = array(); 19 22 $this->OrderDirSQL = array('ASC', 'DESC'); 20 23 $this->OrderArrowImage = array('sort_asc.png', 'sort_desc.png'); … … 99 102 if(!array_key_exists('Title', $Column)) $Title = $ColumnName; 100 103 else $Title = $Column['Title']; 101 if(strpos($Title, '<') === false) $Title = $this->System->Localization->Translate($Title);104 //if(strpos($Title, '<') === false) $Title = $this->System->Localization->Translate($Title); 102 105 103 106 // Create hyperlink -
trunk/Common/View.php
r373 r383 23 23 class View 24 24 { 25 var $System; 25 26 var $Database; 26 27 var $Name; … … 29 30 var $ModelName; 30 31 31 function __construct($ Database)32 function __construct($System) 32 33 { 33 $this->Database = &$Database; 34 $this->System = &$System; 35 $this->Database = &$System->Database; 34 36 } 35 37 -
trunk/Common/ViewForm.php
r373 r383 7 7 var $OnSubmit = ''; 8 8 9 function __construct($ Database)10 { 11 $this->Database = &$Database;9 function __construct($System) 10 { 11 parent::__construct($System); 12 12 } 13 13 -
trunk/Common/ViewList.php
r373 r383 3 3 class ViewList extends View 4 4 { 5 function __construct($Database) 5 var $DefaultOrder; 6 var $Columns; 7 var $SQL; 8 var $SQLJoin; 9 var $Rows; 10 var $Actions; 11 var $PageList; 12 var $TableHeader; 13 var $FilterColumn; 14 var $Module; 15 var $PanelAction; 16 17 function __construct($System) 6 18 { 7 $this->Database = &$Database; 19 parent::__construct($System); 20 $this->FilterColumn = ''; 21 $this->FilterId = 0; 22 $this->PageList = new PageList($this->System); 23 $this->TableHeader = new TableHeader($this->System); 24 $this->Rows = array(); 25 $this->PanelAction = 'ListPanel'; 26 $this->DefaultOrder = array(); 8 27 } 9 28 29 function Show() 30 { 31 $Output = $this->PageList->Output; 32 $Output .= '<table class="WideTable">'; 33 $Output .= $this->TableHeader->Output; 34 foreach($this->Rows as $Row2) 35 { 36 $Row = array(); 37 foreach($Row2 as $Index => $Item) 38 $Row[$Index]['Value'] = $Item; 39 $Row = $this->ProcessRow($Row); 40 41 $Output .= '<tr>'; 42 foreach($this->Columns as $ColumnName => $Column) 43 if($Column['Type'] != 'Hidden') 44 { 45 if(array_key_exists('Class', $Row[$ColumnName]) and ($Row[$ColumnName]['Class'] != '')) 46 $Style = ' class="'.$Row[$ColumnName]['Class'].'"'; else $Style =''; 47 $Output .= '<td'.$Style.'>'; 48 $Output .= $this->System->Type->ExecuteTypeEvent($Column['Type'], 49 'OnView', array('Name' => $ColumnName, 'Value' => $Row[$ColumnName]['Value'], 'Type' => $Column['Type'])); 50 $Output .= '</td>'; 51 } 52 if(is_array($this->Actions)) 53 { 54 $Output .= '<td>'; 55 foreach($this->Actions as $Action) 56 { 57 if(array_key_exists('Confirm', $Action)) $Confirm = ' onclick="return confirmAction(\''.$this->System->Localization->Translate($Action['Confirm']).'\');"'; 58 else $Confirm = ''; 59 if(strpos($Action['Name'], '<') !== false) $ActionName = $Action['Name']; 60 else $ActionName = $this->System->Localization->Translate($Action['Name']); 61 $Output .= '<a'.$Confirm.' href="'.$this->System->Navigation->MakeLink($Action['Module'], $Action['Action'], array('Id' => $Row['Id']['Value'])).'">'. 62 $ActionName.'</a> '; 63 } 64 $Output .= '</td>'; 65 } 66 $Output .= '</tr>'; 67 } 68 $Output .= '</table>'; 69 $Output .= $this->PageList->Output; 70 return($Output); 71 } 72 73 function LoadFromDatabase() 74 { 75 // Get total item count 76 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM '.$this->Name. 77 ' '.$this->SQLJoin); 78 $DbRow = $DbResult->fetch_row(); 79 $this->PageList->TotalCount = $DbRow[0]; 80 $this->PageList->HTMLId = $this->Module; 81 $this->PageList->QueryItems->Data['M'] = $this->Module; 82 $this->PageList->QueryItems->Data['A'] = $this->PanelAction; 83 $this->PageList->QueryItems->Data['FilterColumn'] = $this->FilterColumn; 84 $this->PageList->Process(); 85 86 // Build table header and ordering 87 $this->TableHeader->QueryItems = $this->PageList->QueryItems; 88 $this->TableHeader->HTMLId = $this->Module; 89 $this->TableHeader->Columns = array(); 90 foreach($this->Columns as $Item) 91 { 92 $this->TableHeader->Columns[$Item['Name']] = array('Title' => $Item['Title'], 93 'Type' => $Item['Type'], 'SQL' => $Item['SQL']); 94 } 95 if(is_array($this->Actions)) 96 $this->TableHeader->Columns['Actions'] = array('Type' => 'String', 'SQL' => ''); 97 $this->TableHeader->DefaultOrder = $this->DefaultOrder; 98 $this->TableHeader->Process(); 99 100 //$this->System->Navigation->UnsetParameter('Panel'); 101 102 // Build column list 103 $Columns = $this->Name.'.Id'; 104 foreach($this->Columns as $ColumnName => $Column) 105 $Columns .= ', '.$Column['SQL'].' AS `'.$ColumnName.'`'; 106 107 $this->DbRows = array(); 108 $DbResult = $this->System->Database->query('SELECT '.$Columns.' FROM '.$this->Name. 109 ' '.$this->SQLJoin.$this->TableHeader->SQL.$this->PageList->SQLLimit); 110 while($DbRow = $DbResult->fetch_assoc()) 111 { 112 $this->Rows[] = $DbRow; 113 } 114 } 115 116 function ProcessRow($Row) 117 { 118 return($Row); 119 } 120 10 121 function AddItemString($Name, $Title) 11 122 { 12 $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 13 'Type' => ViewItemTypeString); 14 } 15 123 $this->Columns[$Name] = array('Name' => $Name, 'Title' => $Title, 124 'Type' => ViewItemTypeString, 'SQL' => $Name); 125 } 16 126 } 17 127
Note:
See TracChangeset
for help on using the changeset viewer.