|
8 | 8 | https://www.gnu.org/licenses/gpl-3.0.html
|
9 | 9 |
|
10 | 10 | Author: Justin Grimes
|
11 |
| -Date: 3/11/2021 |
| 11 | +Date: 3/12/2021 |
12 | 12 | <3 Open-Source
|
13 | 13 |
|
14 | 14 | The GUI Core provides resources for the user interfaces & decides which interface to use.
|
@@ -61,15 +61,22 @@ function getCurrentURL() {
|
61 | 61 | // / Set $includeDangerousFiles to TRUE to have dangerous files appear in the array of results.
|
62 | 62 | // / Set $includeDangerousFiles to FALSE to have dangerous files removed from the array of results.
|
63 | 63 | // / The $DangerousFiles array defined in config.php contains the global list of dangerous file extensions.
|
64 |
| -function getFiles($pathToFiles, $includeIndexFiles, $includeDangerousFiles) { |
| 64 | +// / Set $includeDirectories to TRUE to have directories appear in the array of results. |
| 65 | +// / Set $includeDirectories to FALSE to have directories removed from the array of results. |
| 66 | +function getFiles($pathToFiles, $includeIndexFiles, $includeDangerousFiles, $includeDirectories) { |
65 | 67 | global $DangerousFiles;
|
66 |
| - $dirtyFileArr = $dirtyFileArr = FALSE; |
| 68 | + $dirtyFileArr = $OperationSuccessful = FALSE; |
| 69 | + $dirtyFileArr = array(); |
67 | 70 | $dirtyFileArr = scandir($Files);
|
68 | 71 | foreach ($dirtyFileArr as $dirtyFile) {
|
| 72 | + if ($dirtyFile === '.' or $dirtyFile === '..') continue; |
69 | 73 | $dirtyExt = pathinfo($pathToFiles.DIRECTORY_SEPARATOR.$dirtyFile, PATHINFO_EXTENSION);
|
70 | 74 | if (!$includeDangerousFiles && in_array($dirtyExt, $DangerousFiles)) continue;
|
71 | 75 | if (!$includeIndexFiles && $dirtyFile == 'index.html') continue;
|
| 76 | + if (!$includeDirectories && is_dir($pathToFiles)) continue; |
72 | 77 | array_push($Files, $dirtyFile); }
|
| 78 | + // / Check that the operation returned some files. |
| 79 | + if (count($Files) > 0) $OperationSuccessful = TRUE; |
73 | 80 | $dirtyFileArr = $dirtyFile = $dirtyExt = $pathToFiles = $includeDangerousFiles = $includeIndexFiles = NULL;
|
74 | 81 | unset($dirtyFileArr, $dirtyFile, $dirtyExt, $pathToFiles, $includeDangerousFiles, $includeIndexFiles);
|
75 | 82 | return ($Files); }
|
@@ -109,15 +116,83 @@ function setColorScheme() {
|
109 | 116 | if ($ColorScheme == '5') {
|
110 | 117 | echo ('<link rel="stylesheet" type="text/css" href="'.$CD.'Styles/iframeStyleBLACK.css">'); } }
|
111 | 118 |
|
112 |
| -function getPageElement($htmlFile) { |
| 119 | +function outputPageElement($htmlFile) { |
113 | 120 | global $DefaultTheme;
|
114 | 121 |
|
| 122 | + return ($HtmlElement); |
| 123 | +} |
115 | 124 |
|
| 125 | +// / A function to initialize installed widgets. |
| 126 | +// / Widgets are small macros for adding standalone functionality to the GUI. |
| 127 | +function initializeWidgets() { |
| 128 | + global $WidgetsArrayCache; |
| 129 | + $wac = $wid = $widget = $widgets = $WidgetsAreLoaded = $key = $keyCheck = $keyWac = $widgetArrayCountRaw = $widgetArrayCountRaw = $widgetArrayCheck = FALSE; |
| 130 | + $widgetsArray = $newWidgetsArray = array(); |
| 131 | + // / Scan the Widgets directory and build an array of installed Widgets. |
| 132 | + $widgetsArray = getFiles('Widgets', FALSE, TRUE); |
| 133 | + // / Iterate through all installed widgets and |
| 134 | + foreach ($widgetsArray as $widget) if (!is_dir($widget) && !($widget === '.' or $widget === '..' or $widget === 'index.html')) array_push($WidgetsArrayCache, $widget); |
| 135 | + $WidgetArrayCountRaw = count($WidgetsArrayCache); |
| 136 | + $widgetArrayCountRaw = count($WidgetsArrayCache); |
| 137 | + // / Validate the Widget cache is accurate. |
| 138 | + // / The cahce is not for improving performance, but rather to store the order that the user has arranged their Widgets. |
| 139 | + // / Detects when Widgets are added or removed and updates the cache accordingly. |
| 140 | + foreach ($widgetsArray as $keyCheck => $widgetArrayCheck) { |
| 141 | + // / Detect if a Widget needs to be removed from the Widget cache. |
| 142 | + if (!in_array($widgetArrayCheck, $widgetsArray)) { |
| 143 | + // / Remove the Widget from the cache array. |
| 144 | + $WidgetsArrayCache[$keyCheck] = NULL; |
| 145 | + unset ($WidgetsArrayCache[$keyCheck]); } } |
| 146 | + // / Consolidate the WidgetsArrayCache but keep the order of array elements intact. |
| 147 | + foreach ($WidgetsArrayCache as $keyWac => $wac) { |
| 148 | + // / Add the current array index to a new array, but in the same order as the original array. |
| 149 | + // / This way new array keys will be generated in-order, but the order of the array will be preserved. |
| 150 | + // / This is required to keep the number of array keys down. |
| 151 | + // / Otherwise our array keys would become orphaned and the our index would grow arbitrarily. |
| 152 | + $newWidgetsArray = array_push($newWidgetsArray, $wac); |
| 153 | + // / Erase the current array index from the original WidgetsArrayCache array. |
| 154 | + $WidgetsArrayCache[$keyWac] = NULL; |
| 155 | + unset ($WidgetsArrayCache[$keyWac]); } |
| 156 | + // / Redefine the WidgetsArrayCache with data from the newWidgetsArray. |
| 157 | + $WidgetsArrayCache = $newWidgetsArray; |
| 158 | + // / Clean up unneeded memory. |
| 159 | + $wac = $wid = $widget = $widgets = $WidgetsAreLoaded = $key = $keyCheck = $keyWac = $widgetArrayCountRaw = $widgetArrayCountRaw = $widgetArrayCheck = $widgetsArray = $newWidgetsArray = NULL; |
| 160 | + unset($wac, $wid, $widget, $widgets, $WidgetsAreLoaded, $key, $keyCheck, $keyWac, $widgetArrayCountRaw, $widgetArrayCountRaw, $widgetArrayCheck, $widgetsArray, $newWidgetsArray); |
| 161 | + return (array($WidgetsArrayCache, $WidgetsAreLoaded)); } |
| 162 | + |
| 163 | +function updateWidgetOrder() { |
| 164 | + |
116 | 165 |
|
| 166 | + return ($WidgetOrder); |
117 | 167 | }
|
118 | 168 |
|
| 169 | +function outputWidgets($StyleToUse) { |
| 170 | + |
| 171 | + return ($WidgetsElement); |
| 172 | +} |
119 | 173 |
|
| 174 | +function initializeApplications() { |
| 175 | + $app = $application = $applications = $ApplicationsAreLoaded = $key = FALSE; |
| 176 | + $ApplicationsArray = $applicationArray = array(); |
| 177 | + $applicationsArray = scandir('Widgets'); |
| 178 | + foreach ($applicationsArray as $application) if (is_dir($application) && !($application === '.' or $application === '..')) array_push($ApplicationsArray, $application); |
| 179 | + foreach ($ApplicationsArray as $key => $application) { } |
| 180 | + $applicationsArray = $applications = NULL; |
| 181 | + unset($applicationsArray, $applications); |
| 182 | + return (array($ApplicationArray, $applicationsAreLoaded)); } |
| 183 | + |
| 184 | +function updateApplicationOrder() { |
| 185 | + |
| 186 | + return ($ApplicationOrder); |
| 187 | +} |
120 | 188 |
|
| 189 | +function outputApplications($StyleToUse) { |
| 190 | + |
| 191 | + return ($ApplicationsElement); |
| 192 | +} |
121 | 193 |
|
122 |
| - |
| 194 | +function outputLogs($StyleToUse, $LogSource) { |
| 195 | + |
| 196 | + return ($LogsElement); |
| 197 | +} |
123 | 198 | // / -----------------------------------------------------------------------------------
|
0 commit comments