0){ $this->anketa = $anketa; } } // Izvozimo ustrezno tabelo v csv public function exportTable($table_name='srv_advanced_paradata_page'){ global $site_path; ini_set('memory_limit', '4048M'); // Dobimo naslove stolpcev $header = $this->getHeader($table_name); // Pripravimo datoteko za izvoz $file = $site_path.'admin/survey/modules/mod_advanced_paradata/temp/'.$table_name.'_'.$this->anketa.'.csv'; $fd = fopen($file, "w"); $convertTypes = array('charSet' => 'windows-1250', 'delimit' => ',', 'newLine' => "\n", 'BOMchar' => "\xEF\xBB\xBF"); # dodamo boomchar za utf-8 fwrite($fd, $convertTypes['BOMchar']); // Zapisemo header row $header_line = ''; foreach($header as $col){ $header_line .= $col.','; } $header_line = substr($header_line, 0, -1); fwrite($fd, $header_line."\r\n"); // Zapisemo vsako vrstico posebej // Dobimo vrstice s podatki switch($table_name){ case 'srv_advanced_paradata_question': $data = $this->writeQuestionParadata($fd, $header); break; case 'srv_advanced_paradata_vrednost': $data = $this->writeVrednostParadata($fd, $header); break; case 'srv_advanced_paradata_other': $data = $this->writeOtherParadata($fd, $header); break; case 'srv_advanced_paradata_movement': $data = $this->writeMovementParadata($fd, $header); break; case 'srv_advanced_paradata_alert': $data = $this->writeAlertParadata($fd, $header); break; default: $data = $this->writePageParadata($fd, $header); break; } fclose($fd); // Pripravimo file za download if(file_exists($file)){ header('Content-Description: File Transfer'); //header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename(''.$table_name.'_'.$this->anketa.'.csv'.'')); header("Content-type: text/x-csv; charset=utf-8"); //header("Content-type: text/csv"); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); } // Na koncu pobrisemo zacasne datoteke if (file_exists($file)) { unlink($file); } // Ugasnemo skripto:) die(); } // Izpisemo tabelo parapodatkov vezanih na strani public function displayPageTable(){ global $lang; $data = $this->getPageParadata(); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach($data as $row){ echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
IDUser IDPage IDRecnumLoad timePost timeUser AgentDevice pixel ratiowidth x heightavailWidth x availHeightjQuery windowWidth x windowHeightjQuery documentWidth x documentHeightLanguage
'.$row['id'].''.$row['usr_id'].''.$row['gru_id'].''.$row['recnum'].''.$row['load_time'].''.$row['post_time'].''.$row['user_agent'].''.$row['devicePixelRatio'].''.$row['width'].'px X '.$row['height'].'px'.$row['availWidth'].'px X '.$row['availHeight'].'px'.$row['jquery_windowW'].'px X '.$row['jquery_windowH'].'px'.$row['jquery_documentW'].'px X '.$row['jquery_documentH'].'px'.$row['language'].'
'; } // Izpisemo tabelo parapodatkov vezanih na vprasanja public function displayQuestionTable(){ $data = $this->getQuestionParadata(); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach($data as $row){ echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
Page session IDQuestion IDOrder
'.$row['page_id'].''.$row['spr_id'].''.$row['vre_order'].'
'; } // Izpisemo tabelo parapodatkov vezanih na vredosti public function displayVrednostTable(){ $data = $this->getVrednostParadata(); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach($data as $row){ echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
Page session IDQuestion IDVrednost IDTimeEventValue
'.$row['page_id'].''.$row['spr_id'].''.$row['vre_id'].''.$row['time'].''.$row['event'].''.$row['value'].'
'; } // Izpisemo tabelo ostalih parapodatkov public function displayOtherTable(){ $data = $this->getOtherParadata(); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach($data as $row){ echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
Page session IDTimeEventValuePositionElement typeElement idElement class
'.$row['page_id'].''.$row['time'].''.$row['event'].''.$row['value'].'X: '.$row['pos_x'].', Y: '.$row['pos_y'].''.$row['div_type'].''.$row['div_id'].''.$row['div_class'].'
'; } // Izpisemo tabelo premikov miske public function displayMovementTable(){ $data = $this->getMovementParadata(); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach($data as $row){ echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
Page session IDTime startTime endPosition startPosition endDistance traveled
'.$row['page_id'].''.$row['time_start'].''.$row['time_end'].'X: '.$row['pos_x_start'].', Y: '.$row['pos_y_start'].'X: '.$row['pos_x_end'].', Y: '.$row['pos_y_end'].''.$row['distance'].'
'; } // Izpisemo tabelo ostalih parapodatkov public function displayAlertTable(){ $data = $this->getAlertParadata(); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach($data as $row){ echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
Page session IDDisplay timeClose timeTypeTrigger IDTrigger typeIgnorableAlert textUser action
'.$row['page_id'].''.$row['time_display'].''.$row['time_close'].''.$row['type'].''.$row['trigger_id'].''.$row['trigger_type'].''.$row['ignorable'].''.$row['text'].''.$row['action'].'
'; } // Pridobimo naslove parapodatkov vezane na strani private function getHeader($table_name='srv_advanced_paradata_page'){ $header = array(); $sql = sisplet_query("SHOW columns FROM ".$table_name.""); while($row = mysqli_fetch_array($sql)){ $header[] = $row['Field']; } return $header; } // Pridobimo parapodatke vezane na strani private function getPageParadata($all=false){ $data = array(); $limit = $all ? '' : ' LIMIT '.$this->limit; $sql = sisplet_query("SELECT * FROM srv_advanced_paradata_page WHERE ank_id='".$this->anketa."' ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data[] = $row; } return $data; } // Pridobimo parapodatke vezane na vprasanja private function getQuestionParadata($all=false){ $data = array(); $limit = $all ? '' : ' LIMIT '.$this->limit; $sql = sisplet_query("SELECT q.* FROM srv_advanced_paradata_question q, srv_advanced_paradata_page p WHERE p.ank_id='".$this->anketa."' AND q.page_id=p.id ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data[] = $row; } return $data; } // Pridobimo parapodatke vezane na vrednosti v vprasanju private function getVrednostParadata($all=false){ $data = array(); $limit = $all ? '' : ' LIMIT '.$this->limit; $sql = sisplet_query("SELECT v.* FROM srv_advanced_paradata_vrednost v, srv_advanced_paradata_page p WHERE p.ank_id='".$this->anketa."' AND v.page_id=p.id ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data[] = $row; } return $data; } // Pridobimo ostale parapodatke private function getOtherParadata($all=false){ $data = array(); $limit = $all ? '' : ' LIMIT '.$this->limit; $sql = sisplet_query("SELECT o.* FROM srv_advanced_paradata_other o, srv_advanced_paradata_page p WHERE p.ank_id='".$this->anketa."' AND o.page_id=p.id ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data[] = $row; } return $data; } // Pridobimo parapodatke premikov miske private function getMovementParadata($all=false){ $data = array(); $limit = $all ? '' : ' LIMIT '.$this->limit; $sql = sisplet_query("SELECT m.* FROM srv_advanced_paradata_movement m, srv_advanced_paradata_page p WHERE p.ank_id='".$this->anketa."' AND m.page_id=p.id ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data[] = $row; } return $data; } // Pridobimo parapodatke alertov private function getAlertParadata($all=false){ $data = array(); $limit = $all ? '' : ' LIMIT '.$this->limit; $sql = sisplet_query("SELECT a.* FROM srv_advanced_paradata_alert a, srv_advanced_paradata_page p WHERE p.ank_id='".$this->anketa."' AND a.page_id=p.id ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data[] = $row; } return $data; } // Zapisemo v datoteko parapodatke vezane na strani private function writePageParadata($fd, $header){ $sql = sisplet_query("SELECT * FROM srv_advanced_paradata_page WHERE ank_id='".$this->anketa."' ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data_line = ''; foreach($header as $col){ $data_line .= '\''.$row[$col].'\','; } $data_line = substr($data_line, 0, -1); fwrite($fd, $data_line."\r\n"); } } // Zapisemo v datoteko parapodatke vezane na vprasanja private function writeQuestionParadata($fd, $header){ $sql = sisplet_query("SELECT q.* FROM srv_advanced_paradata_question q, srv_advanced_paradata_page p WHERE p.ank_id='".$this->anketa."' AND q.page_id=p.id ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data_line = ''; foreach($header as $col){ $data_line .= '\''.$row[$col].'\','; } $data_line = substr($data_line, 0, -1); fwrite($fd, $data_line."\r\n"); } } // Zapisemo v datoteko parapodatke vezane na vrednosti v vprasanju private function writeVrednostParadata($fd, $header){ $sql = sisplet_query("SELECT v.* FROM srv_advanced_paradata_vrednost v, srv_advanced_paradata_page p WHERE p.ank_id='".$this->anketa."' AND v.page_id=p.id ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data_line = ''; foreach($header as $col){ $data_line .= '\''.$row[$col].'\','; } $data_line = substr($data_line, 0, -1); fwrite($fd, $data_line."\r\n"); } } // Zapisemo v datoteko ostale parapodatke private function writeOtherParadata($fd, $header){ $sql = sisplet_query("SELECT o.* FROM srv_advanced_paradata_other o, srv_advanced_paradata_page p WHERE p.ank_id='".$this->anketa."' AND o.page_id=p.id ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data_line = ''; foreach($header as $col){ $data_line .= '\''.$row[$col].'\','; } $data_line = substr($data_line, 0, -1); fwrite($fd, $data_line."\r\n"); } } // Zapisemo v datoteko parapodatke premikov miske private function writeMovementParadata($fd, $header){ $sql = sisplet_query("SELECT m.* FROM srv_advanced_paradata_movement m, srv_advanced_paradata_page p WHERE p.ank_id='".$this->anketa."' AND m.page_id=p.id ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data_line = ''; foreach($header as $col){ $data_line .= '\''.$row[$col].'\','; } $data_line = substr($data_line, 0, -1); fwrite($fd, $data_line."\r\n"); } } // Zapisemo v datoteko parapodatke alertov private function writeAlertParadata($fd, $header){ $sql = sisplet_query("SELECT a.* FROM srv_advanced_paradata_alert a, srv_advanced_paradata_page p WHERE p.ank_id='".$this->anketa."' AND a.page_id=p.id ORDER BY id DESC ".$limit.""); while($row = mysqli_fetch_array($sql)){ $data_line = ''; foreach($header as $col){ $data_line .= '\''.$row[$col].'\','; } $data_line = substr($data_line, 0, -1); fwrite($fd, $data_line."\r\n"); } } }