vprasanja, 1->ankete (vprasanja iz anket)
var $folder_id = 0; // Trenutno aktiven folder
var $expanded_folders = array(); // Razprti folderji
var $root_folder = array(); // Root folderji (sistemski in uporabnikov)
var $folder_structure = array(); // Struktura direktorijev uporabnika
public function __construct ($ank_id=0) {
if($ank_id == 0)
die();
$this->ank_id = $ank_id;
// Nastavimo vse razprte folderje (vsi parenti ce je child aktiven)
$this->setExpandedFolders($this->folder_id);
}
// Loop cez folderje in rekurzivno nastavi razprte (parenti aktivnega)
private function setExpandedFolders($folder_id){
$this->expanded_folders[] = $folder_id;
if($folder_id == '0'){
return;
}
$sqlFolders = sisplet_query("SELECT parent FROM srv_library_folder WHERE id='".$folder_id."' AND tip='".$this->tab."'");
$rowFolders = mysqli_fetch_array($sqlFolders);
$this->setExpandedFolders($rowFolders['parent']);
}
/**
* @desc prikaze knjiznico znotraj ankete
*/
private function displayLibrary() {
global $admin_type;
global $global_user_id;
global $lang;
// Naslov v oknu
echo '
';
echo '';
}
// Priazemo glavno vsebino glede na aktiven tab
public function displayTabContent(){
global $lang;
// Levi seznam folderjev
echo '
';
$this->displayFolderList();
echo '
';
// Desna vsebina
echo '
';
// Seznam vprasanj
echo '
';
$this->displayQuestionList();
echo '
';
// Item counter
echo '
'.$lang['srv_library_item_counter'].': 0
';
// Gumbi na dnu
echo '
';
$this->displayButtons();
echo '
';
echo '
';
}
// Prikazemo seznam folderjev na levi
private function displayFolderList(){
global $global_user_id;
global $lang;
// Prikazemo seznam mojih folderjev v knjiznci
echo '
';
// Prikazemo se skrit div za dodaten popup (rename, add - title)
echo '';
// Klik izven "Vec" - zapremo okno
echo '';
}
private function displayFolderParent($parent, $uid) {
global $lang;
global $admin_type;
global $global_user_id;
global $site_url;
// Ce gre za root mapo prikazemo z ustreznim jezikom
if ($parent == 0 && $uid == 0) {
$language = " AND lang='".$lang['id']."' ";
}
// Dobimo vse folderje za parenta
$sqlFolders = sisplet_query("SELECT id, naslov
FROM srv_library_folder
WHERE uid='".$uid."' AND parent='".$parent."' AND tip='".$this->tab."' ".$language."
ORDER BY naslov
");
if (!$sqlFolders)
echo mysqli_error($GLOBALS['connect_db']);
// Za prvic ko pride user, da mu dodamo folder
if (mysqli_num_rows($sqlFolders) == 0 && $uid > 0 && $parent == 0){
// Nastavimo naslov mape
$naslov = ($this->tab == 0) ? $lang['srv_moja_vprasanja'] : $lang['srv_moje_ankete'];
sisplet_query("INSERT INTO srv_library_folder
(uid, tip, naslov, parent, lang)
VALUES
('".$uid."', '".$this->tab."', '".$naslov."', '0', '".$lang['id']."')
");
$sqlFolders = sisplet_query("SELECT id, naslov
FROM srv_library_folder
WHERE uid='".$uid."' AND parent='".$parent."' AND tip='".$this->tab."'
ORDER BY naslov
");
if (!$sqlFolders)
echo mysqli_error($GLOBALS['connect_db']);
}
// Loop po vseh mapah znotraj parenta
while ($rowFolders = mysqli_fetch_array($sqlFolders)) {
// Nastavimo default prvi aktiven folder
if($this->folder_id == 0 && $parent == 0 && $uid == 0){
$this->folder_id = $rowFolders['id'];
$this->setExpandedFolders($this->folder_id);
}
$this->displayFolderItem($rowFolders['id'], $rowFolders['naslov'], $uid);
$expanded = in_array($rowFolders['id'], $this->expanded_folders) ? true : false;
echo '
';
// Rekurzivno izpisemo childe
$this->displayFolderParent($rowFolders['id'], $uid);
// Smo tabu ankete - izpisemo se ankete v tem folderju
if($this->tab == '1'){
$sqlSurvey = sisplet_query("SELECT a.id, a.naslov FROM srv_anketa a, srv_library_anketa l WHERE a.id=l.ank_id AND l.folder='".$rowFolders['id']."' AND l.uid='".$uid."' ORDER BY naslov ASC");
if (!$sqlSurvey) echo mysqli_error($GLOBALS['connect_db']);
if (mysqli_num_rows($sqlSurvey) > 0) {
while ($rowSurvey = mysqli_fetch_array($sqlSurvey)) {
$this->displayFolderItemSurvey($rowSurvey['id'], $rowSurvey['naslov'], $uid);
}
}
}
echo '
';
}
}
// Levi item - folder
private function displayFolderItem($id, $title, $uid) {
global $lang;
global $admin_type;
$expanded = in_array($id, $this->expanded_folders) ? true : false;
$active = ($this->folder_id == $id) ? true : false;
echo '
';
// Ikoni puscice in mape
echo ' ';
echo ' ';
// Naslov folderja
echo ' '.$title.'';
// Stevilo itemov v folderju
//echo ' '.$child_count.'';
// Urejanje folderja
if($uid != 0 || $admin_type == 0){
// Tri pikice za prikaz urejanja folderja
echo ' ';
// Skrit div za urejanje folderja
echo '
';
echo '
';
echo '
'.$lang['srv_library_folder_add'].'
';
echo '
'.$lang['srv_library_folder_rename'].'
';
if($id != $this->root_folder['user'])
echo '
'.$lang['srv_library_folder_delete'].'
';
echo '
';
echo '
';
}
echo '
';
}
// Levi item - anketa
private function displayFolderItemSurvey($id, $title, $uid) {
global $lang;
// Javne ankete
$type = ($uid == '0') ? 'public' : 'my';
echo '
';
// Ikoni puscice in mape
echo ' ';
// Naslov folderja - ankete
echo ' '.$title.'';
echo '
';
}
// Dodaten popup za ime direktorija pri dodajanju
private function displayAddFolderPopup($folder_id, $uid){
global $lang;
echo '
'.$lang['srv_library_folder_name'].'
';
echo '
';
echo ' ';
echo '
';
echo '
';
echo ' ';
echo ' ';
echo '
';
}
// Dodaten popup za ime direktorija pri preimenovanju
private function displayRenameFolderPopup($folder_id, $folder_name){
global $lang;
echo '
'.$lang['srv_library_folder_name'].'
';
echo '
';
echo ' ';
echo '
';
echo '
';
echo ' ';
echo ' ';
echo '
';
}
// Prikazemo seznam vprasanj v folderju
private function displayQuestionList(){
global $global_user_id;
global $lang;
// Folder ni nastavljen
if($this->folder_id == 0)
return;
// Naslov trenutnega folderja
$sqlCurrentFolder = sisplet_query("SELECT naslov FROM srv_library_folder WHERE id='".$this->folder_id."'");
$rowCurrentFolder = mysqli_fetch_array($sqlCurrentFolder);
echo '
'.$rowCurrentFolder['naslov'].'
';
// Seznam vprasanj iz anket v knjiznici
if($this->tab == 1){
// Najprej zlistamo vse child folderje
$sqlFolders = sisplet_query("SELECT id, naslov FROM srv_library_folder WHERE parent='".$this->folder_id."' AND tip='".$this->tab."' ORDER BY naslov");
if (mysqli_num_rows($sqlFolders) > 0){
// Loop po vseh mapah znotraj parenta
while ($rowFolders = mysqli_fetch_array($sqlFolders)) {
$this->displayRightFolderItem($rowFolders['id'], $rowFolders['naslov']);
}
}
echo '';
$sqlFolderSurveys = sisplet_query("SELECT a.id, a.naslov FROM srv_anketa a, srv_library_anketa l WHERE a.id=l.ank_id AND l.folder='".$this->folder_id."' ORDER BY naslov ASC");
while ($rowFolderSurveys = mysqli_fetch_array($sqlFolderSurveys)) {
// Naslov ankete
echo '
';
$sqlQuestions = sisplet_query("SELECT s.id, s.naslov, s.lib_naslov, s.tip FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='".$rowFolderSurveys['id']."' ORDER BY g.vrstni_red ASC, s.vrstni_red ASC");
while ($rowQuestions = mysqli_fetch_array($sqlQuestions)) {
$this->displayRightQuestionItem($rowQuestions);
}
echo '
';
}
}
// Seznam vprasanj iz knjiznice
else{
// Najprej zlistamo vse child folderje
$sqlFolders = sisplet_query("SELECT id, naslov FROM srv_library_folder WHERE parent='".$this->folder_id."' AND tip='".$this->tab."' ORDER BY naslov");
if (mysqli_num_rows($sqlFolders) > 0){
// Loop po vseh mapah znotraj parenta
while ($rowFolders = mysqli_fetch_array($sqlFolders)) {
$this->displayRightFolderItem($rowFolders['id'], $rowFolders['naslov']);
}
}
echo '';
$allow_edit = true;
// Loop po vseh vprasanjih v folderju
$sqlFolderQuestions = sisplet_query("SELECT s.id, s.naslov, s.lib_naslov, s.tip, f.uid AS folder_uid
FROM srv_spremenljivka s, srv_library_folder f
WHERE s.folder='".$this->folder_id."' AND s.gru_id='-1' AND f.id=s.folder
ORDER BY s.naslov ASC
");
while ($rowFolderQuestions = mysqli_fetch_array($sqlFolderQuestions)) {
$this->displayRightQuestionItem($rowFolderQuestions);
}
// Loop po vseh if-ih/blokih v folderju
$sqlFolderIfs = sisplet_query("SELECT i.id, i.label, i.tip, f.uid AS folder_uid
FROM srv_if i, srv_library_folder f
WHERE i.folder='".$this->folder_id."' AND f.id=i.folder
ORDER BY i.label ASC, i.id ASC
");
while ($rowFolderIfs = mysqli_fetch_array($sqlFolderIfs)) {
$this->displayRightIfItem($rowFolderIfs);
}
// Init drag/drop js
echo '';
}
}
// Prikazemo seznam vprasanj v anketah iz knjiznice v folderju
private function displaySurveyQuestionList(){
global $global_user_id;
global $lang;
// Folder ni nastavljen
if($this->folder_id == 0)
return;
// Naslov ankete
SurveyInfo :: getInstance()->SurveyInit($this->folder_id);
echo '
'.SurveyInfo::getSurveyTitle().'
';
$sqlQuestions = sisplet_query("SELECT s.id, s.naslov, s.lib_naslov, s.tip FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='".$this->folder_id."' ORDER BY g.vrstni_red ASC, s.vrstni_red ASC");
while ($rowQuestions = mysqli_fetch_array($sqlQuestions)) {
$this->displayRightQuestionItem($rowQuestions);
}
}
// Prikazemo vrstico (item, folder) na desni
private function displayRightFolderItem($folder_id, $folder_name){
global $lang;
echo '
';
echo '
';
echo ' ';
echo ' '.$folder_name.'';
echo '
';
echo '
';
}
// Prikazemo 1 vrstico (item, vprasanje) na desni
private function displayRightQuestionItem($spremenljivka){
global $lang;
global $global_user_id;
global $admin_type;
echo '