Пример #1
0
 public function prihlasNaTermin(Trace $trace, $terminIndex)
 {
     $table = $this->components['zoznamTerminovTable_dataView'];
     $table->selectSingleRow((int) $terminIndex);
     $table->setActiveRow((int) $terminIndex);
     $data = $this->doAction('enterAction');
     $data = $data->getElementById("init-data");
     $data = $data->textContent;
     $error = StrUtil::match('@webui\\(\\)\\.messageBox\\("([^"]*)",@', $data);
     if ($error) {
         throw new Exception('Nepodarilo sa prihlásiť na zvolený termín.<br/>' . 'Dôvod: <b>' . $error . '</b>');
     }
     if (!preg_match("@dm\\(\\)\\.closeDialog\\(" . "\"VSES206_VyberTerminuHodnoteniaDlg1\"\\);@", $data)) {
         throw new Exception("Problém pri prihlasovaní: " . "Neočakávaná odozva od AISu");
     }
     $this->closeWindow();
     return true;
 }
Пример #2
0
 public function login(AIS2ServerConnection $serverConnection)
 {
     $connection = $serverConnection->getHttpConnection();
     $login = $this->username;
     $password = $this->password;
     if ($login === null && $password === null) {
         throw new Exception("S týmto objektom nie je možné sa prihlásiť 2x. " . "Meno a heslo boli vymazané pri prvom prihlásení.");
     }
     // Username a password si nebudeme pamatat dlhsie ako treba
     $this->username = null;
     $this->password = null;
     // TODO(ppershing): why is there this line? Needed for some cookies?
     $this->isLoggedIn($serverConnection);
     $data = $connection->post(new NullTrace(), self::COSIGN_LOGIN, array('ref' => '', 'login' => $login, 'password' => $password));
     if (!preg_match(parent::LOGGED_ALREADY_PATTERN, $data)) {
         if (($reason = StrUtil::match(self::COSIGN_ERROR_PATTERN1, $data)) || ($reason = StrUtil::match(self::COSIGN_ERROR_PATTERN2, $data)) || ($reason = StrUtil::match(self::COSIGN_ERROR_PATTERN3, $data)) || ($reason = StrUtil::match(self::IIKS_ERROR, $data))) {
             throw new LoginException('Nepodarilo sa prihlásiť, dôvod: <b>' . $reason . '</b>');
         }
         throw new LoginException('Nepodarilo sa prihlásiť, dôvod neznámy.');
     }
     return true;
 }
Пример #3
0
 public function testMatch()
 {
     $this->assertEquals('ab', StrUtil::match('@x(.*)x@', 'yxabxy'));
     $this->assertEquals(false, StrUtil::match('@x(.*)x@', 'yyabxy'));
 }
Пример #4
0
 /**
  * Extract Table data from DOMDocument
  *
  * @param Trace $trace for creating logs, tracking activity
  * @param $dom DOMDocument part of ais2ResponseHTML which contain Table
  * @returns array(string=>array(string)) Returns rows of Table, where index is rowId
  */
 private function getTableDataFromDom(Trace $trace, DOMDocument $dom)
 {
     Preconditions::checkNotNull($dom);
     $tdata = array();
     $trace->tlog("Finding element with id dataTabBody0");
     $element = $dom->getElementById('dataTabBody0');
     if ($element == null) {
         throw new ParseException("Can't find table data");
     }
     $trace->tlog("Element found");
     foreach ($element->childNodes as $aisRow) {
         assert($aisRow->tagName == "tr");
         assert($aisRow->hasAttribute("id"));
         assert($aisRow->hasChildNodes());
         // TODO: asserty prerobit na exceptiony
         $row = array();
         $trace->tlog("Extracting row id.");
         $rowId = $aisRow->getAttribute("id");
         $index = StrUtil::match('@^row_([0-9]+)$@', $rowId);
         if ($index === false) {
             throw new ParseException("Unexpected row id format");
         }
         $trace->tlog("Extraction is correct.");
         $index = intval($index);
         foreach ($aisRow->childNodes as $ais_td) {
             assert($ais_td->tagName == "td");
             $row[] = $this->getCellContent($ais_td);
         }
         $tdata[$index] = $row;
     }
     return $tdata;
 }
 private function parseParamNameFromResponse($response)
 {
     $data = $response->getElementById("init-data");
     $data = $data->textContent;
     $data = StrUtil::match(self::APP_LOCATION_PATTERN, $data, 'params');
     if ($data === false) {
         throw new ParseException("Location of APP_PATTERN failed.");
     }
     $data = StrUtil::match(self::PARAM_NAME_PATTERN, $data, 'paramName');
     if ($data === false) {
         throw new ParseException("Parsing of ids from zapisnyListIndex failed.");
     }
     return $data;
 }
 public function odhlasZTerminu(Trace $trace, $terminIndex)
 {
     // Posleme request ze sa chceme odhlasit.
     $data = $this->executor->doRequest($trace, array('compName' => 'odstranitTerminAction', 'eventClass' => 'avc.ui.event.AVCActionEvent', 'embObj' => array('terminyTable' => array('dataView' => array('activeIndex' => $terminIndex, 'selectedIndexes' => $terminIndex), 'editMode' => 'false'))));
     if (!preg_match("@Skutočne chcete odobrať vybraný riadok?@", $data)) {
         throw new Exception("Problém pri odhlasovaní - neočakávaná odozva AISu");
     }
     // Odklikneme konfirmacne okno ze naozaj.
     $data = $this->executor->doRequest($trace, array('events' => false, 'app' => false, 'dlgName' => false, 'changedProperties' => array('confirmResult' => 2)));
     $message = StrUtil::match('@webui\\.messageBox\\("([^"]*)"@', $data);
     if ($message !== false && $message != 'Činnosť úspešne dokončená.') {
         throw new Exception("Z termínu sa (pravdepodobne) nepodarilo odhlásiť." . "Dôvod:<br/><b>" . $message . '</b>');
     }
     if (!preg_match("@dm\\(\\).setActiveDialogName\\(" . "'VSES007_StudentZoznamPrihlaseniNaSkuskuDlg0'\\);@", $data)) {
         throw new Exception("Problém pri odhlasovaní z termínu - neočakávaná odpoveď od AISu");
     }
     return true;
 }
Пример #7
0
 public function getTableData(Trace $trace, DOMDocument $dom)
 {
     $data = array();
     $trace->tlog("finding tbody element");
     $element = $dom->getElementById('dataTabBody0');
     if ($element == null) {
         throw new ParseException("Can't find table data");
     }
     foreach ($element->childNodes as $aisRow) {
         assert($aisRow->tagName == "tr");
         assert($aisRow->hasAttribute("id"));
         assert($aisRow->hasChildNodes());
         // TODO: asserty prerobit na exceptiony
         $row = array();
         $rowId = $aisRow->getAttribute("id");
         $index = StrUtil::match('@^row_([0-9]+)$@', $rowId);
         if ($index === false) {
             throw new ParseException("Unexpected row id format");
         }
         foreach ($aisRow->childNodes as $ais_td) {
             assert($ais_td->tagName == "td");
             $row[] = $this->getCellContent($ais_td);
         }
         $data[$index] = $row;
     }
     $trace->tlogVariable("data", $data);
     return $data;
 }