summaryrefslogtreecommitdiffstats
path: root/admin/survey/classes/class.SurveyVariableView.php
blob: c2d04b7d2c09582e2a3687f7a5c9ebb37d6689fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php 

class VariableView {
	
	static private $_instance;			# Singleton static instance
	static private $_sid;				# id ankete
	
	static private $SDF = null;								# class za inkrementalno dodajanje fajlov
	static private $headFileName = null;					# pot do header fajla
	static private $dataFileName = null;					# pot do data fajla
	static private $dataFileStatus = null;					# status data datoteke
	static private $_HEADERS = array();						# shranimo podatke vseh variabel
	
	/**
	* Get the singleton instance of this class and enable writing at shutdown.
	 *
	 *     $VariableView = VariableView::instance();
	 *
	 * @return  VariableView
	 */
	 public static function instance() {
		 if (self::$_instance === NULL) {
		 // Create a new instance
		 	self::$_instance = new self;
		 }
		 return self::$_instance;
	 }
	 
	 public static function init($sid) {
	 	self::$_sid = $sid;
	 	
	 	# polovimo variable ankete
	 	#inicializiramo class za datoteke
		self::$SDF = SurveyDataFile::get_instance();
		self::$SDF->init($sid);

        self::$SDF->prepareFiles();
		
		self::$headFileName = self::$SDF->getHeaderFileName();
		self::$dataFileName = self::$SDF->getDataFileName();
		self::$dataFileStatus = self::$SDF->getStatus();
	 	self::$_HEADERS = self::$SDF->getHeader();
	 	
	 }
	 
	 public static function displayVariables() {
	 	global $lang;
				
        echo '<table class="variableView">';
         
	 	echo '<tr>';
	 	echo '<th>'.$lang['srv_variableView_h_name'].'</th>';
	 	echo '<th>'.$lang['srv_variableView_h_type'].'</th>';
	 	echo '<th>'.$lang['srv_variableView_h_measure'].'</th>';
	 	echo '<th>'.$lang['srv_variableView_h_label'].'</th>';
		echo '</tr>';
         
        foreach (self::$_HEADERS AS $skey => $spremenljivka) {
            if (isset($spremenljivka['tip']) && is_numeric($spremenljivka['tip']) && $spremenljivka['tip'] != '' && $spremenljivka['tip'] != 'm' && $spremenljivka['tip'] != 'sm') {

                $spss = $spremenljivka['grids'][0]['variables'][0]['spss'];
	 			$spss_type = substr($spss,0,1);
	 			$spss_length = explode('.',substr($spss,1));
	 			$spr_id = explode('_',$skey);
	 			$spr_id = $spr_id[0];
                 $legenda = Cache::spremenljivkaLegenda($spr_id);
                 
	 			echo '<tr>';
	 			echo '<td>'.$spremenljivka['variable'].'</td>';
	 			echo '<td class="nowrap">'.$legenda['izrazanje'].'</td>';
	 			echo '<td>'.$legenda['skala'].'</td>';
	 			echo '<td>'.((strlen($spremenljivka['naslov']) > 100) ? substr($spremenljivka['naslov'], 0, 97).'...' : $spremenljivka['naslov']).'</td>';
	 			echo '</tr>';
	 		}
         }
         
	 	echo '</table>';
	}
}