source: Dev/trunk/classes/SessionCreationTool.php @ 67

Last change on this file since 67 was 67, checked in by fpvanagthoven, 14 years ago

colors

File size: 7.3 KB
Line 
1<?php
2
3/**
4 * Description of SessionCreationTool
5 *
6 * @author fpvanagthoven
7 */
8class SessionCreationTool {
9
10    private $session;
11    private $surveys;
12
13    public function __construct($session = null) {
14        $this->session = $session;
15
16        $this->init();
17
18        $this->javascript();
19        ?>
20
21        <div class="creation">
22            <form id="sessionCreationForm" action="" method="post">
23                <?php
24                $this->title();
25                $this->description();
26                $this->pipeline();
27
28                $this->makeSessionButton();
29                ?>
30            </form>
31        </div>
32        <?php
33    }
34
35    private function init() {
36        $this->surveys = Loader::loadSurveys();
37    }
38
39    private function javascript() {
40        ?>
41        <script type="text/javascript" src="js/creation.js"></script>
42        <script type="text/javascript">
43            var surveys = new Array();
44                                                                                                                                           
45            init();
46                                                                                                                                                       
47            function init() {
48                loadSurveys();
49                loadApplications();
50            }
51                                                                                                                                                       
52            function loadSurveys() {
53        <?php
54        foreach ($this->surveys as $survey) {
55            ?>
56                        var title = <?php echo "'" . $survey->title . "'"; ?>;
57                        var id = <?php echo "'" . $survey->id . "'"; ?>;
58                        var survey = new Survey(title, id);
59                        surveys.push(survey);
60            <?php
61        }
62        ?>
63            }
64                                                                                                                                           
65            function loadApplications() {
66                                                                                                                                               
67            }
68                                                                                                                                           
69            function Survey(title, id)
70            {
71                this.title = title;
72                this.id = id;
73            }
74                                                                                                                                           
75            // =============================================================
76                                                                                                                                           
77            function addSurvey() {
78                var pipeline = document.getElementById("pipeline");
79                var surveysList = document.getElementById("surveysList");
80                                       
81                var entry = document.createElement("option");
82                entry.setAttribute("value", surveys[surveysList.selectedIndex].id);
83                entry.style.backgroundColor = "#88c5e4";
84                entry.innerHTML = surveys[surveysList.selectedIndex].title;
85                               
86                pipeline.appendChild(entry);
87            }
88                   
89            function addDashboard() {
90                var pipeline = document.getElementById("pipeline");
91                       
92                var entry = document.createElement("option");
93                entry.setAttribute("value", "dashboard");
94                entry.style.backgroundColor = "#555";
95                entry.style.color = "white";
96                entry.innerHTML = "Dashboard";
97               
98                       
99                pipeline.appendChild(entry);
100            }
101                                                                                                                                                   
102        </script>
103        <?php
104    }
105
106    private function title() {
107        if (isset($this->session->title))
108            $value = $this->session->title;
109        else
110            $value = 'Untitled Session';
111        ?>
112        <input type="text" id="sessionTitle" class="titleBox" name="sessionTitle" value="<?php echo $value; ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
113        <?php
114    }
115
116    private function description() {
117        if (isset($this->session->description))
118            $value = $this->session->description;
119        else
120            $value = 'Write a description for this session here.';
121        ?>
122        <textarea id="sessionDescription" class="descriptionBox" name="sessionDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea>
123        <?php
124    }
125
126    private function pipeline() {
127        ?>
128        <div id="pipelineWrapper">
129            <h2 class="pipelineHead">Pipeline</h2>
130            <?php $this->pipelineSelect(); ?>
131            <div id="pipelineOptions">
132                <?php
133                $this->addDashboardToPipelineButton();
134                ?>
135            </div>
136        </div>
137        <div id="surveysApplicationsWrapper">
138            <div id="surveysForPipelineWrapper">
139                <h2 class="pipelineHead">Surveys</h2>
140                <?php
141                $this->surveysSelect();
142                $this->addSurveyToPipelineButton()
143                ?>
144            </div>
145            <div id="applicationsForPipelineWrapper">
146                <h2 class="pipelineHead">Applications</h2>
147                <?php
148                $this->applicationsSelect();
149                $this->addApplicationToPipelineButton();
150                ?>
151            </div>
152        </div>
153        <?php
154    }
155
156    private function pipelineSelect() {
157        ?>
158        <select id="pipeline" size="1000">
159
160        </select>
161        <?php
162    }
163
164    private function surveysSelect() {
165        ?>
166        <select id="surveysList" size="5" class="width100p">
167            <?php
168            foreach ($this->surveys as $survey) {
169                ?>
170                <option value="<?php echo $survey->id; ?>">
171                    <?php echo $survey->title; ?>
172                </option>
173                <?php
174            }
175            ?>
176        </select>
177        <?php
178    }
179
180    private function applicationsSelect() {
181        ?>
182        <select id="applicationsList" size="5" class="width100p">
183        </select>
184        <?php
185    }
186
187    private function addSurveyToPipelineButton() {
188        ?>
189        <input type="button" id="surveyToPipeline" class="surveyButton pipelineButton leftAlign leftPadding1" value="<=====" onclick="addSurvey()"/>
190        <?php
191    }
192
193    private function addApplicationToPipelineButton() {
194        ?>
195        <input type="button" class="surveyButton pipelineButton leftAlign leftPadding1" value="<=====" />
196        <?php
197    }
198
199    private function addDashboardToPipelineButton() {
200        ?>
201        <input type="button" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Dashboard" onclick="addDashboard()"/>
202        <?php
203    }
204
205    private function makeSessionButton() {
206        ?>
207        <input type="submit" id="makeSessionButton" class="surveyButton" value="Make session" />
208        <?php
209    }
210
211}
212?>
Note: See TracBrowser for help on using the repository browser.