src/Neuron/GameServer.php
private function getOpenWindows ()
	{
		$profiler = Neuron_Profiler_Profiler::getInstance ();

		$out = array ();

		// List all open windows
		$updatewindows = isset ($_POST['updatewindow']) ? $_POST['updatewindow'] : null;
		if (is_array ($updatewindows))
		{
			$profiler->start ('Ordering windows on priority');

			// Order window on input (put input first)
			$aantal = count ($updatewindows);
			for ($i = 0; $i < $aantal; $i ++)
			{
				$vervangen = $i;

				// Loop trough last, fine the one with more input.
				for ($j = $i + 1; $j < $aantal; $j ++)
				{
					if
					(
						isset  ($updatewindows[$j]['sInputData']) &&
						strlen ($updatewindows[$j]['sInputData']) > strlen ($updatewindows[$vervangen]['sInputData'])
					)
					{
						$vervangen = $j;
					}
				}

				// Vervangen
				$temp = $updatewindows[$i];
				$updatewindows[$i] = $updatewindows[$vervangen];
				$updatewindows[$vervangen] = $temp;
			}

			$profiler->stop ();

			//foreach ($updatewindows as $v)
			for ($i = 0; $i < count ($updatewindows); $i ++)
			{
				$v = $updatewindows[$i];

				if (is_array ($v) && count ($v) == 4)
				{
					// Put everything in a big TRY
					$profiler->start ('Loading window '.$v['sWindowId']);

					try
					{
						$window = $this->getWindow ($v['sWindowId']);

						if ($window)
						{
							$window->setDivId ($v['sDialogId']);

							// Set request data
							if (isset ($v['sRequestData']))
							{
								$window->setRequestData ($v['sRequestData']);
							}

							// Set input data
							$window->setJsonInputData ($v['sInputData']);

							// Initialize
							$window->setSettings ();
						}

						$out[] = $window;
					}
					catch (Exception $e)
					{
						// Send a mail
						Neuron_ErrorHandler_Handler::getInstance()->notify($e);

						if (defined ('OUTPUT_DEBUG_DATA') && OUTPUT_DEBUG_DATA)
						{
							echo $e;
						}
					}

					$profiler->stop ();
				}
			}
		}

		return $out;
	}
private function getOpenWindows ()
	{
		$profiler = Neuron_Profiler_Profiler::getInstance ();

		$out = array ();

		// List all open windows
		$updatewindows = isset ($_POST['updatewindow']) ? $_POST['updatewindow'] : null;
		if (is_array ($updatewindows))
		{
			$profiler->start ('Ordering windows on priority');

			// Order window on input (put input first)
			$aantal = count ($updatewindows);
			for ($i = 0; $i < $aantal; $i ++)
			{
				$vervangen = $i;

				// Loop trough last, fine the one with more input.
				for ($j = $i + 1; $j < $aantal; $j ++)
				{
					if
					(
						isset  ($updatewindows[$j]['sInputData']) &&
						strlen ($updatewindows[$j]['sInputData']) > strlen ($updatewindows[$vervangen]['sInputData'])
					)
					{
						$vervangen = $j;
					}
				}

				// Vervangen
				$temp = $updatewindows[$i];
				$updatewindows[$i] = $updatewindows[$vervangen];
				$updatewindows[$vervangen] = $temp;
			}

			$profiler->stop ();

			//foreach ($updatewindows as $v)
			for ($i = 0; $i < count ($updatewindows); $i ++)
			{
				$v = $updatewindows[$i];

				if (is_array ($v) && count ($v) == 4)
				{
					// Put everything in a big TRY
					$profiler->start ('Loading window '.$v['sWindowId']);

					try
					{
						$window = $this->getWindow ($v['sWindowId']);

						if ($window)
						{
							$window->setDivId ($v['sDialogId']);

							// Set request data
							if (isset ($v['sRequestData']))
							{
								$window->setRequestData ($v['sRequestData']);
							}

							// Set input data
							$window->setJsonInputData ($v['sInputData']);

							// Initialize
							$window->setSettings ();
						}

						$out[] = $window;
					}
					catch (Exception $e)
					{
						// Send a mail
						Neuron_ErrorHandler_Handler::getInstance()->notify($e);

						if (defined ('OUTPUT_DEBUG_DATA') && OUTPUT_DEBUG_DATA)
						{
							echo $e;
						}
					}

					$profiler->stop ();
				}
			}
		}

		return $out;
	}
/*
This method is used for the dialog method.
It returns all open windows (as received by post[updatewindow])
ordered by their priority (so basically all those wiht input go first)