48 Log::trace(
'ActionLoading constructor started - PID: ' . $currentPid);
50 $bearsamppWinbinder->reset();
54 Log::trace(
'Loading PID added to tracking file: ' . $currentPid);
58 if (file_exists($pidFile)) {
59 $pids = file($pidFile);
60 foreach ($pids as $pid) {
62 if (!empty($pid) && $pid != $currentPid) {
63 Log::trace(
'ActionLoading: Found another loading process (PID ' . $pid .
'), killing it');
72 $screenWidth = intval($screenArea[2]);
73 $screenHeight = intval($screenArea[3]);
74 $xPos = $screenWidth - self::WINDOW_WIDTH;
75 $yPos = $screenHeight - self::WINDOW_HEIGHT - 5;
76 Log::trace(
'Screen dimensions: ' . $screenWidth .
'x' . $screenHeight .
', Window position: (' . $xPos .
',' . $yPos .
')');
80 $this->wbWindow = $bearsamppWinbinder->createWindow(
null, ToolDialog,
null, $xPos, $yPos, self::WINDOW_WIDTH, self::WINDOW_HEIGHT, WBC_TOP,
null);
83 if ($this->wbWindow ===
false || $this->wbWindow ===
null) {
84 Log::error(
'CRITICAL: Failed to create loading window - window handle is: ' . var_export($this->wbWindow,
true));
85 Log::error(
'WinBinder extension loaded: ' . (extension_loaded(
'winbinder') ?
'YES' :
'NO'));
86 Log::error(
'wb_create_window function exists: ' . (function_exists(
'wb_create_window') ?
'YES' :
'NO'));
91 Log::trace(
'Loading window created successfully - handle: ' . $this->wbWindow);
95 Log::trace(
'Making window visible with wb_set_visible()');
96 wb_set_visible($this->wbWindow,
true);
104 $this->wbProgressBar = $bearsamppWinbinder->createProgressBar($this->wbWindow, self::GAUGE + 1, 42, 24, self::WINDOW_WIDTH - 62, 15);
105 Log::trace(
'Progress bar created: ' . var_export($this->wbProgressBar,
true));
108 $this->wbLabel = $bearsamppWinbinder->drawText($this->wbWindow,
'', 42, 0, self::WINDOW_WIDTH - 64, 25);
109 Log::trace(
'Label created: ' . var_export($this->wbLabel,
true));
113 $bearsamppWinbinder->setHandler($this->wbWindow, $this,
'processLoading', 10);
114 Log::trace(
'Handler set, starting main loop...');
115 $bearsamppWinbinder->mainLoop();
128 for ($i = 0; $i < $nb; $i++) {
129 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
130 $bearsamppWinbinder->drawImage($this->wbWindow,
Path::getImagesPath() .
'/bearsampp.bmp', 4, 2, 32, 32);
133 $bearsamppWinbinder->wait();
134 $bearsamppWinbinder->wait($this->wbWindow);
161 $startTime = microtime(
true);
162 $maxLoadingTime = 15;
164 while ($iterations < $maxIterations && (microtime(
true) - $startTime) < $maxLoadingTime) {
166 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
170 for ($i = 0; $i < self::GAUGE && (microtime(
true) - $startTime) < $maxLoadingTime; $i++) {
181 if ($allServicesStarted) {
182 Log::trace(
'All services started successfully');
187 Log::trace(
'Loading iteration ' . $iterations .
' completed, checking services again');
190 if ($iterations >= $maxIterations) {
191 Log::trace(
'Maximum iterations reached (' . $maxIterations .
'), some services may not have started properly');
194 if ((microtime(
true) - $startTime) >= $maxLoadingTime) {
195 Log::trace(
'Loading timeout reached (' . $maxLoadingTime .
' seconds), some services may not have started properly');
228 if (file_exists($statusFile)) {
229 $content = @file_get_contents($statusFile);
230 if ($content !==
false && !empty($content)) {
231 $status = @json_decode($content,
true);
232 if ($status && isset($status[
'text']) && !empty($status[
'text'])) {
234 $bearsamppWinbinder->drawRect($this->wbWindow, 42, 0, self::WINDOW_WIDTH - 52, 25);
235 $this->wbLabel = $bearsamppWinbinder->drawText($this->wbWindow, $status[
'text'], 42, 0, self::WINDOW_WIDTH - 64, 25);
241 if (empty($currentText)) {
242 $bearsamppWinbinder->drawRect($this->wbWindow, 42, 0, self::WINDOW_WIDTH - 52, 25);
243 $this->wbLabel = $bearsamppWinbinder->drawText($this->wbWindow,
'Processing...', 42, 0, self::WINDOW_WIDTH - 64, 25);