Example #1
0
 /**
  *   Funkce pro načtení XML dat z výstupu porovnávacího algoritmu a uložení do SESSION
  *   @param $xmlString - XML dokument...
  *   @param $workData - instance třídy workData	 
  *   @return boolean   	 
  */
 public static function loadMatchingXML($xmlString)
 {
     //require_once (JPATH_COMPONENT.DS.'models'.DS.'workdata.php');
     $workData = new WorkDataModel();
     @($xml = simplexml_load_string($xmlString));
     if ($xml) {
         //klíče dokumentu A
         $keysArr = array();
         $legendArr = array();
         $valuesArr = array();
         $legendArr_A = array();
         $legendArr_B = array();
         $index = 0;
         if (count($xml->keysA->key) > 0) {
             foreach ($xml->keysA->key as $key) {
                 //projdeme všechny klíče
                 $keyName = (string) $key["name"];
                 $keysArr[] = 'a' . $index;
                 $legendArr['a' . $index] = $keyName;
                 $legendArr_A[$keyName] = 'a' . $index;
                 /*hodnoty*/
                 if (count(@$key->enumeration[0]->value) > 0) {
                     foreach ($key->enumeration[0]->value as $value) {
                         $valuesArr['a' . $index][] = (string) $value;
                     }
                 }
                 //TODO ostatni datove typy
                 /*--hodnoty*/
                 $index++;
             }
         }
         //$_SESSION["keysArr"]=$keysArr;
         $workData->save('keysArr', $keysArr);
         //klíče dokumentu B
         $keys2Arr = array();
         $index = 0;
         if (count($xml->keysB->key) > 0) {
             foreach ($xml->keysB->key as $key) {
                 //projdeme všechny klíče
                 $keyName = (string) $key["name"];
                 $keys2Arr[] = 'b' . $index;
                 $legendArr['b' . $index] = $keyName;
                 $legendArr_B[$keyName] = 'b' . $index;
                 /*hodnoty*/
                 if (count(@$key->enumeration[0]->value) > 0) {
                     foreach ($key->enumeration[0]->value as $value) {
                         $valuesArr['b' . $index][] = (string) $value;
                     }
                 }
                 //TODO ostatni datove typy
                 /*--hodnoty*/
                 $index++;
             }
         }
         $workData->save('keys2Arr', $keys2Arr);
         $workData->save('valuesArr', $valuesArr);
         $workData->save('valuesMappingArr', array());
         //$_SESSION["keys2Arr"]=$keys2Arr;
         //matchovací data
         $dataArr = array();
         if (count($xml->match->keyA) > 0) {
             foreach ($xml->match->keyA as $keyA) {
                 $keyAname = (string) $keyA["name"];
                 $keyAname_legend = $legendArr_A[$keyAname];
                 $arr = array();
                 if (count($keyA->keyB) > 0) {
                     foreach ($keyA->keyB as $keyB) {
                         $keyBname = (string) $keyB["name"];
                         $keyBname_legend = $legendArr_B[$keyBname];
                         $arr[$keyBname_legend] = array('ratio' => (string) $keyB["ratio"], 'ratioArr' => array('names' => (string) $keyB["ratioNames"], 'values' => (string) $keyB["ratioValues"], 'expirience' => (string) $keyB["ratioExpirience"]));
                     }
                     $dataArr[$keyAname_legend] = $arr;
                 }
             }
         }
         $workData->save('legendArr', $legendArr);
         $workData->save('dataArr', $dataArr);
         //$_SESSION["defaultDataArr"]=$_SESSION["dataArr"];
         $workData->save('defaultDataArr', $dataArr);
         //$_SESSION["userIgnoreArr"]=array();
         $workData->save('userIgnoreArr', array());
         return true;
     } else {
         //nepodarilo se nacist XML data
         return false;
     }
 }
Example #2
0
 /**
  *  Akce pro vygenerování FML a jeho vypsání na výstup
  */
 private function generateFML()
 {
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'workdata.php';
     $workData = new WorkDataModel();
     require_once JPATH_COMPONENT . DS . 'library' . DS . 'XmlConnector.php';
     return XMLConnector::generateFML($workData->load("finalArr"), $workData->load("legendArr"), $workData->load("valuesMapArr"), $workData->load("userDataArr"), $workData->load("art1"), $workData->load("art2"));
 }