false); // za shrambo parametrov in sporocil /** * @desc konstruktor */ function __construct ($anketa = null){ global $site_path; global $global_user_id; global $output; // preverimo ali imamo stevilko ankete if ( is_numeric($anketa) ){ $this->anketa['id'] = $anketa; // create new XLS document $this->xls = new xls(); $_POST['podstran'] = 'text_analysis'; } else{ $this->pi['msg'] = "Anketa ni izbrana!"; $this->pi['canCreate'] = false; return false; } if (SurveyInfo::getInstance()->SurveyInit($this->anketa['id'])){ $this->anketa['uid'] = $global_user_id; } else return false; // ce smo prisli do tu je vse ok $this->pi['canCreate'] = true; return true; } function getAnketa(){ return $this->anketa['id']; } function checkCreate(){ return $this->pi['canCreate']; } function getFile($fileName){ $output = $this->createXls(); $this->xls->display($fileName, $output); } function createXls(){ global $site_path; global $lang; global $output; $convertTypes = array('charSet' => "windows-1250", 'delimit' => ";", 'newLine' => "\n", 'BOMchar' => "\xEF\xBB\xBF"); $output = $convertTypes['BOMchar']; // Dobimo podatke $STA = new SurveyTextAnalysis($this->anketa['id']); $data = $STA->getData(); // Tabela vsot znakov po straneh $output .= '
'.$lang['srv_text_analysis_title1'].'
'; $this->displayGrupaTable($data); $output .= '
'; $output .= '
'.$lang['srv_text_analysis_title2'].'
'; // Tabela znakov po vprasanjih in vrednostih $this->displaySprTable($data); return $output; } function displayGrupaTable($data){ global $site_path; global $lang; global $output; $output .= ''; // Header row $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; // Loop po straneh v anketi foreach($data['grupe'] as $gru_id => $grupa){ // Loop po vprasanjih na strani foreach($grupa['spremenljivke'] as $spr_id => $spremenljivka){ $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; } // Vsota znakov na strani $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; } // Vsota znakov v anketi $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= '
'.$lang['srv_text_analysis_page'].''.$lang['srv_text_analysis_question'].''.$lang['srv_text_analysis_charCount'].''.$lang['srv_text_analysis_charCountBlank'].''.$lang['srv_text_analysis_charCountHTML'].''.$lang['srv_text_analysis_wordCount'].'
'.$grupa['naslov'].''.$spremenljivka['variable'].''.$spremenljivka['sum_char_count'].''.$spremenljivka['sum_char_count_noBlank'].''.$spremenljivka['sum_char_count_html'].''.$spremenljivka['sum_word_count'].'
'.$grupa['naslov'].''.$lang['srv_text_analysis_sum'].''.$grupa['sum_char_count'].''.$grupa['sum_char_count_noBlank'].''.$grupa['sum_char_count_html'].''.$grupa['sum_word_count'].'
'.$lang['srv_text_analysis_sumSurvey'].''.$data['sum_char_count'].''.$data['sum_char_count_noBlank'].''.$data['sum_char_count_html'].''.$data['sum_word_count'].'
'; } function displaySprTable($data){ global $site_path; global $lang; global $output; $output .= ''; // Header row $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; // Loop po straneh v anketi foreach($data['grupe'] as $gru_id => $grupa){ // Loop po vprasanjih na strani foreach($grupa['spremenljivke'] as $spr_id => $spremenljivka){ $output .= ''; $output .= ''; $output .= ''; $output .= ''; $naslov = strip_tags($spremenljivka['naslov']); $naslov = ($spremenljivka['char_count'] > 50) ? substr($naslov, 0, 47).'...' : $naslov; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; // Loop po vrednostih v vprasanju foreach($spremenljivka['vrednosti'] as $vre_id => $vrednost){ $output .= ''; $output .= ''; $output .= ''; $output .= ''; $naslov = strip_tags($vrednost['naslov']); $naslov = ($vrednost['char_count'] > 50) ? substr($naslov, 0, 47).'...' : $naslov; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; } } } $output .= '
'.$lang['srv_text_analysis_page'].''.$lang['srv_text_analysis_question'].''.$lang['srv_text_analysis_value'].''.$lang['srv_text_analysis_text'].''.$lang['srv_text_analysis_charCount'].''.$lang['srv_text_analysis_charCountBlank'].''.$lang['srv_text_analysis_charCountHTML'].''.$lang['srv_text_analysis_wordCount'].'
'.$grupa['naslov'].''.$spremenljivka['variable'].''.$naslov.''.$spremenljivka['char_count'].''.$spremenljivka['char_count_noBlank'].''.$spremenljivka['char_count_html'].''.$spremenljivka['word_count'].'
'.$grupa['naslov'].''.$spremenljivka['variable'].''.$vrednost['variable'].''.$naslov.''.$vrednost['char_count'].''.$vrednost['char_count_noBlank'].''.$vrednost['char_count_html'].''.$vrednost['word_count'].'
'; } function encodeText($text) { // popravimo sumnike ce je potrebno $stringIn = array("č","š","đ","ć","ž","Č","Š","Đ","Ć","Ž"," "); $stringOut = array("č","š","đ","ć","ž","Č","Š","Đ","Ć","Ž"," "); //$text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8'); $text = str_replace($stringIn, $stringOut, $text); return $text; } function enkaEncode($text) { // popravimo sumnike ce je potrebno $text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8'); return strip_tags($text); } function formatNumber ($value, $digit = 0, $sufix = "") { if ($value <> 0 && $value != null) $result = round($value, $digit); else $result = "0"; //$result = number_format($result, $digit, '.', ',') . $sufix; $result = number_format($result, $digit, ',', '') . $sufix; return $result; } } ?>