source: Dev/branches/jos-branch/classes/widgets/SurveyEditorWidget.php @ 233

Last change on this file since 233 was 233, checked in by fpvanagthoven, 13 years ago
File size: 3.9 KB
Line 
1<?php
2/*
3 * To change this template, choose Tools | Templates
4 * and open the template in the editor.
5 */
6
7/**
8 * The PHP class that implements the survey editor interface
9 *
10 * @author Thijs Schipper
11 */
12class SurveyEditorWidget {
13
14    private $loadedSurvey;
15
16    public function __construct() {
17       
18    }
19
20    public function handlePost() {
21        // Get POSTed data and store variables to class instance properties
22       
23        if (isset($_POST['objectUid']) && !empty($_POST['objectUid'])) {
24            $surveyResults = Survey::get(array("uid" => $_POST['objectUid']));
25            if (!empty($surveyResults)) {
26                $this->loadedSurvey = $surveyResults[0];
27            } else {
28                die("No surveys found!");
29            }
30        } else {
31            die("Incorrect or null uid passed!");
32        }
33    }
34
35    public function init() {
36        $questionString = "";
37        foreach ($this->loadedSurvey->questions as $question) {
38            $questionString .= $question->uid . ",";
39        }
40        // echo the HTML markup to display the editor on the screen
41        ?>
42
43        <div id="surveyEditor" class="largeFrame">
44            <div class="largeTitle" id="surveyTitle">
45                <?php echo $this->loadedSurvey->title; ?>
46            </div>
47            <div id="seqContent" class="innerLargeFrame">
48                <div id="seqContentWrapper">
49
50                </div>
51            </div>
52            <div id="surveyEditorVertControls" class="vertControls">
53                <div class="segment">
54                    <label>Move</label>
55                    <input type="button" id="vertControls_MoveUp" class="bigButton vertical" value="˄" />
56                    <input type="button" id="vertControls_MoveDown" class="bigButton vertical" value="˅" />
57                </div>
58                <input type="button" id="vertControls_Add" class="bigButton vertical" value="+" onClick="addQuestion_Click();" />
59            </div>
60            <div id="surveyEditorControls" class="controls">
61                <div id="pageControls">
62                    <input type="button" value="<<" id="pageControls_first" onClick="" />
63                    <input type="button" value="<" id="pageControls_previous" onClick="" />
64                    Page <input type="text" value="1" id="pageControls_current" onChange="" class="smallTextField" /> of 5
65                    <input type="button" value=">" id="pageControls_next" onClick="" />
66                    <input type="button" value=">>" id="pageControls_last" onClick="" />
67                </div>
68
69                <input type="button" value="Discard survey" onClick="javascript:alert('discard not yet supported');" class="smallButton" />
70                <input type="button" value="Save survey" onClick="saveSurvey(true);" class="smallButton" />
71            </div>
72
73        </div>
74
75
76        <form id="hiddenInputs">
77            <input type="hidden" id="surveyUidField" value="<?php echo $this->loadedSurvey->uid; ?>" />
78            <input type="hidden" id="questionUidsField" value="<?php echo $questionString ?>" />
79            <input type="hidden" id="surveyTitleField" value="<?php echo $this->loadedSurvey->title; ?>" />
80            <input type="hidden" id="numQuestionsField" value="<?php echo count($this->loadedSurvey->questions); ?>" />
81            <input type="hidden" id="surveyDescriptionField" value="<?php echo $this->loadedSurvey->description; ?>" />
82        </form>
83
84
85        <?php
86    }
87
88    public function javascript() {
89        // output the javascript tags and needed functions in the head of the page
90        ?>
91        <script type="text/javascript" src="js/sequencerScripts.js"></script>
92        <script type="text/javascript" src="js/generalscripts.js"></script>
93        <script type="text/javascript" src="js/jquery.js"></script>
94        <script type="text/javascript">
95            $(document).ready(function() {
96                loadSequencer();
97            });
98        </script>
99        <?php
100    }
101
102}
103?>
Note: See TracBrowser for help on using the repository browser.