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 .= '
';
// Header row
$output .= '';
$output .= ''.$lang['srv_text_analysis_page'].' | ';
$output .= ''.$lang['srv_text_analysis_question'].' | ';
$output .= ''.$lang['srv_text_analysis_charCount'].' | ';
$output .= ''.$lang['srv_text_analysis_charCountBlank'].' | ';
$output .= ''.$lang['srv_text_analysis_charCountHTML'].' | ';
$output .= ''.$lang['srv_text_analysis_wordCount'].' | ';
$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 .= ''.$grupa['naslov'].' | ';
$output .= ''.$spremenljivka['variable'].' | ';
$output .= ''.$spremenljivka['sum_char_count'].' | ';
$output .= ''.$spremenljivka['sum_char_count_noBlank'].' | ';
$output .= ''.$spremenljivka['sum_char_count_html'].' | ';
$output .= ''.$spremenljivka['sum_word_count'].' | ';
$output .= '
';
}
// Vsota znakov na strani
$output .= '';
$output .= ''.$grupa['naslov'].' | ';
$output .= ''.$lang['srv_text_analysis_sum'].' | ';
$output .= ''.$grupa['sum_char_count'].' | ';
$output .= ''.$grupa['sum_char_count_noBlank'].' | ';
$output .= ''.$grupa['sum_char_count_html'].' | ';
$output .= ''.$grupa['sum_word_count'].' | ';
$output .= '
';
}
// Vsota znakov v anketi
$output .= '';
$output .= ' | ';
$output .= ''.$lang['srv_text_analysis_sumSurvey'].' | ';
$output .= ''.$data['sum_char_count'].' | ';
$output .= ''.$data['sum_char_count_noBlank'].' | ';
$output .= ''.$data['sum_char_count_html'].' | ';
$output .= ''.$data['sum_word_count'].' | ';
$output .= '
';
$output .= '
';
}
function displaySprTable($data){
global $site_path;
global $lang;
global $output;
$output .= '';
// Header row
$output .= '';
$output .= ''.$lang['srv_text_analysis_page'].' | ';
$output .= ''.$lang['srv_text_analysis_question'].' | ';
$output .= ''.$lang['srv_text_analysis_value'].' | ';
$output .= ''.$lang['srv_text_analysis_text'].' | ';
$output .= ''.$lang['srv_text_analysis_charCount'].' | ';
$output .= ''.$lang['srv_text_analysis_charCountBlank'].' | ';
$output .= ''.$lang['srv_text_analysis_charCountHTML'].' | ';
$output .= ''.$lang['srv_text_analysis_wordCount'].' | ';
$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 .= ''.$grupa['naslov'].' | ';
$output .= ''.$spremenljivka['variable'].' | ';
$output .= ' | ';
$naslov = strip_tags($spremenljivka['naslov']);
$naslov = ($spremenljivka['char_count'] > 50) ? substr($naslov, 0, 47).'...' : $naslov;
$output .= ''.$naslov.' | ';
$output .= ''.$spremenljivka['char_count'].' | ';
$output .= ''.$spremenljivka['char_count_noBlank'].' | ';
$output .= ''.$spremenljivka['char_count_html'].' | ';
$output .= ''.$spremenljivka['word_count'].' | ';
$output .= '
';
// Loop po vrednostih v vprasanju
foreach($spremenljivka['vrednosti'] as $vre_id => $vrednost){
$output .= '';
$output .= ''.$grupa['naslov'].' | ';
$output .= ''.$spremenljivka['variable'].' | ';
$output .= ''.$vrednost['variable'].' | ';
$naslov = strip_tags($vrednost['naslov']);
$naslov = ($vrednost['char_count'] > 50) ? substr($naslov, 0, 47).'...' : $naslov;
$output .= ''.$naslov.' | ';
$output .= ''.$vrednost['char_count'].' | ';
$output .= ''.$vrednost['char_count_noBlank'].' | ';
$output .= ''.$vrednost['char_count_html'].' | ';
$output .= ''.$vrednost['word_count'].' | ';
$output .= '
';
}
}
}
$output .= '
';
}
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;
}
}
?>