translator->addDomain("psyhvel", dirname(dirname(dirname(__FILE__)))."/i18n"); $TeKe->translator->useDomain("psyhvel"); $TeKe->template->setTemplateRepository(dirname(__FILE__).'/views/templates'); $TeKe->template->setTemplateRepository(dirname(__FILE__).'/views/macros'); $TeKe->template->setTemplateRepository(dirname(__FILE__).'/views/library'); $TeKe->template->setTemplateRepository(dirname(__FILE__).'/views/tests'); $TeKe->template->setTemplateRepository(dirname(__FILE__).'/views/test'); if (count($page)>0) { $this->loadTest($page); } $this->setNavigation($TeKe); } function setNavigation($teke) { if ($teke->is_manager()){ $teke->navigation['library'] = array('title'=>_('Library'), 'url'=>"library/view", 'current'=>$teke->is_current_main('library'), 'level'=>0); } $teke->navigation['tests'] = array('title'=>_('Tests'), 'url'=>"tests/view", 'current'=>$teke->is_current_main('tests'), 'level'=>0); } function getTypes() { $types = array( array("type"=>"Questionnaire", "name"=>"Questionnaire"), array("type"=>"TextStimulus", "name"=>"Text Stimulus"), array("type"=>"SoundStimulus", "name"=>"Sound Stimulus"), array("type"=>"WordStimulus", "name"=>"Word Stimulus"), array("type"=>"PictureStimulus", "name"=>"Picture Stimulus"), array("type"=>"MultiPictureStimulus", "name"=>"Multi Picture Stimulus"), array("type"=>"TMTTask", "name"=>"TMT Task"), array("type"=>"KSTask", "name"=>"KS Task"), array("type"=>"KSImgTask", "name"=>"KS Image Task"), array("type"=>"SliderTask", "name"=>"Slider Task"), array("type"=>"ChoiceTask", "name"=>"Choice Task"), array("type"=>"SoundTask", "name"=>"Sound Task"), array("type"=>"FlowerTask", "name"=>"Flower Task"), array("type"=>"HedgehogTask", "name"=>"Hedgehog Task"), array("type"=>"KeeperTask", "name"=>"Keeper Task"), array("type"=>"SoundTesting", "name"=>"Sound Testing"), array("type"=>"DragTask", "name"=>"Drag Task"), array("type"=>"DragTesting", "name"=>"Drag Testing"), array("type"=>"ImageDragTask", "name"=>"Image Drag Task"), array("type"=>"TimeelapseTask", "name"=>"Time Elapse Task"), //array("type"=>"TimestopTask", "name"=>"Time Stop Task"), ); return $types; } function getImportableTypes() { return array("ChoiceTask", "TMTTask", "Questionnaire", "TextStimulus", "KSTask", "MultiPictureStimulus", "ChoiceObject", "PictureStimulus", "SoundTask", "SoundStimulus", "SoundTesting"); //, "TimeelapseTask", "TimestopTask"); } function loadType($type, $id = false) { if (!$type && is_numeric($id) && $id > 0) { $type_q = query_row("SELECT type FROM " . DB_PREFIX . "base_object WHERE id=".$id); $type = $type_q->type; } if ($type) { if (is_file(dirname(__FILE__)."/objects/".$type.".php")) { require_once(dirname(__FILE__)."/objects/".$type.".php"); return new $type($id); } } return false; } function deleteType($type, $id) { if (!$type && is_numeric($id) && $id > 0) { $type_q = query_row("SELECT type FROM " . DB_PREFIX . "base_object WHERE id=".$id); $type = $type_q->type; } if ($type && is_numeric($id)) { if (is_file(dirname(__FILE__)."/objects/".$type.".php")) { require_once(dirname(__FILE__)."/objects/".$type.".php"); $obj = new $type($id); return $obj->delete(); } } return false; } function getFolders($folder=NULL) { $folder_sql = "folder IS NULL"; if ($folder) { $folder_sql = "folder = ".$folder; } return query_rows("SELECT * FROM " . DB_PREFIX . "folder WHERE ".$folder_sql." ORDER BY position ASC"); } function getTestFolders($folder=NULL) { $folder_sql = "folder IS NULL"; if ($folder) { $folder_sql = "folder = ".$folder; } return query_rows("SELECT * FROM " . DB_PREFIX . "test_folder WHERE !locked AND ".$folder_sql." ORDER BY position ASC"); } function getTests() { $tests = array(); foreach (query_rows("SELECT id FROM " . DB_PREFIX . "test ORDER BY position ASC") as $t) { $tests []= $this->loadType("Test", $t->id); } return $tests; } function getTestsByFolderId($id) { if (is_numeric($id)) { return query_rows("SELECT * FROM " . DB_PREFIX . "base_object WHERE folder=".$id); } return false; } function loadTest($page) { if (count($page)>=2 && is_numeric($page[1])) { $this->test = $this->loadType($page[0], $page[1]); } else if (count($page)>1) { $this->test = $this->loadType($page[0], false); if (count($page)>3 && ($page[1]=="TestFolder" || $page[1]=="Folder") && is_numeric($page[2])) { $this->test->setFolder($page[2]); } } } } ?>