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'));
90 Log::trace(
'Loading window created successfully - handle: ' . $this->wbWindow);
94 Log::trace(
'Making window visible with wb_set_visible()');
95 wb_set_visible($this->wbWindow,
true);
103 $this->wbProgressBar = $bearsamppWinbinder->createProgressBar($this->wbWindow, self::GAUGE + 1, 42, 24, self::WINDOW_WIDTH - 62, 15);
104 Log::trace(
'Progress bar created: ' . var_export($this->wbProgressBar,
true));
107 $this->wbLabel = $bearsamppWinbinder->drawText($this->wbWindow,
'', 42, 0, self::WINDOW_WIDTH - 64, 25);
108 Log::trace(
'Label created: ' . var_export($this->wbLabel,
true));
112 $bearsamppWinbinder->setHandler($this->wbWindow, $this,
'processLoading', 10);
113 Log::trace(
'Handler set, starting main loop...');
114 $bearsamppWinbinder->mainLoop();
127 for ($i = 0; $i < $nb; $i++) {
128 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
129 $bearsamppWinbinder->drawImage($this->wbWindow,
Path::getImagesPath() .
'/bearsampp.bmp', 4, 2, 32, 32);
132 $bearsamppWinbinder->wait();
133 $bearsamppWinbinder->wait($this->wbWindow);
160 $startTime = microtime(
true);
161 $maxLoadingTime = 15;
163 while ($iterations < $maxIterations && (microtime(
true) - $startTime) < $maxLoadingTime) {
165 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
169 for ($i = 0; $i < self::GAUGE && (microtime(
true) - $startTime) < $maxLoadingTime; $i++) {
180 if ($allServicesStarted) {
181 Log::trace(
'All services started successfully');
186 Log::trace(
'Loading iteration ' . $iterations .
' completed, checking services again');
189 if ($iterations >= $maxIterations) {
190 Log::trace(
'Maximum iterations reached (' . $maxIterations .
'), some services may not have started properly');
193 if ((microtime(
true) - $startTime) >= $maxLoadingTime) {
194 Log::trace(
'Loading timeout reached (' . $maxLoadingTime .
' seconds), some services may not have started properly');
227 if (file_exists($statusFile)) {
228 $content = @file_get_contents($statusFile);
229 if ($content !==
false && !empty($content)) {
230 $status = @json_decode($content,
true);
231 if ($status && isset($status[
'text']) && !empty($status[
'text'])) {
233 $bearsamppWinbinder->drawRect($this->wbWindow, 42, 0, self::WINDOW_WIDTH - 52, 25);
234 $this->wbLabel = $bearsamppWinbinder->drawText($this->wbWindow, $status[
'text'], 42, 0, self::WINDOW_WIDTH - 64, 25);
240 if (empty($currentText)) {
241 $bearsamppWinbinder->drawRect($this->wbWindow, 42, 0, self::WINDOW_WIDTH - 52, 25);
242 $this->wbLabel = $bearsamppWinbinder->drawText($this->wbWindow,
'Processing...', 42, 0, self::WINDOW_WIDTH - 64, 25);