/**
  * Nadviaže spojenie, spustí danú "aplikáciu" v AISe
  * a natiahne prvotné dáta do atribútu $data.
  */
 public function requestOpen(Trace $trace, ScreenData $data)
 {
     $trace->tlog("open screen");
     $url = $this->requestBuilder->getAppInitializationUrl($data);
     $response = AIS2Utils::request($trace->addChild("get app id"), $url);
     $this->appId = $this->parseAppIdFromResponse($response);
     $response = $this->doRequest($trace->addChild("Init command"), array('eventClass' => 'avc.ui.event.AVCComponentEvent', 'command' => 'INIT'));
     $this->formName = $this->parseFormNameFromResponse($response);
 }
 public function openDialogAndGetExecutor(Trace $trace, $dialogUid, DialogData $data)
 {
     $this->openIfNotAlready($trace->addChild("opening dialog parent"));
     if ($this->openedDialog != null) {
         throw new IllegalStateException('V AIS2 screene "' . $this->formName . '" už existuje otvorený dialog. Pre otvorenie nového treba pôvodný zatvoriť.');
     }
     $this->openedDialog = $dialogUid;
     return $this->executor->spawnDialogExecutor($data);
 }
 private function check(Trace $trace, $url, $response)
 {
     $matches = array();
     if (preg_match(self::INTERNAL_ERROR_PATTERN, $response, $matches)) {
         $trace->tlog("Expection encountered");
         throw $this->newException($matches[1], $url);
     }
     if (preg_match(self::APACHE_ERROR_PATTERN, $response, $matches)) {
         $trace->tlog("Expection encountered");
         throw $this->newException($matches[1], $url);
     }
     if (preg_match(self::UNAUTHORIZED, $response)) {
         $trace->tlog("Exception encountered");
         throw new AIS2LoginException("AIS hlási neautorizovaný prístup -\n        pravdepodobne vypršala platnosť cookie");
     }
     return $response;
 }
 public function getTableDefinition(Trace $trace, DOMDocument $dom)
 {
     $trace->tlog("finding table definition element");
     $trace->tlogVariable("", $dom->saveXML());
     $element = $dom->getElementById('dataTabColGroup');
     if ($element == null) {
         throw new Exception("Can't find table headers");
     }
     $list = $element->getElementsByTagName('col');
     $columns = array();
     foreach ($list as $node) {
         assert($node->hasAttribute('shortname'));
         $columns[] = $node->getAttribute('shortname');
     }
     $trace->tlogVariable("Parsed columns:", $columns);
     return $columns;
 }
 private function exec(Trace $trace)
 {
     // read cookie file
     curl_setopt($this->curl, CURLOPT_COOKIEFILE, $this->cookieFile);
     $output = curl_exec($this->curl);
     $child = $trace->addChild("Response");
     $child->tlogVariable("Http resonse code", curl_getinfo($this->curl, CURLINFO_HTTP_CODE));
     $child->tlogVariable("Http content type", curl_getinfo($this->curl, CURLINFO_CONTENT_TYPE));
     $child->tlogVariable("Response", $output);
     if (curl_errno($this->curl)) {
         $child->tlog("There was an error receiving data");
         throw new Exception("Chyba pri nadväzovaní spojenia:" . curl_error($this->curl));
     }
     // Do not forget to save current file content
     curl_setopt($this->curl, CURLOPT_COOKIEJAR, $this->cookieFile);
     return $output;
 }