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
RevLine 
[58]1<?php
2
3/**
4 * Description of SessionCreationTool
5 *
6 * @author fpvanagthoven
7 */
8class SessionCreationTool {
[61]9
[64]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();
[61]19        ?>
[64]20
[61]21        <div class="creation">
[64]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>
[61]31        </div>
32        <?php
33    }
34
[64]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();
[67]44                                                                                                                                           
[64]45            init();
[67]46                                                                                                                                                       
[64]47            function init() {
48                loadSurveys();
49                loadApplications();
50            }
[67]51                                                                                                                                                       
[64]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            }
[67]64                                                                                                                                           
[64]65            function loadApplications() {
[67]66                                                                                                                                               
[64]67            }
[67]68                                                                                                                                           
[64]69            function Survey(title, id)
70            {
71                this.title = title;
72                this.id = id;
73            }
[67]74                                                                                                                                           
[64]75            // =============================================================
[67]76                                                                                                                                           
[64]77            function addSurvey() {
[66]78                var pipeline = document.getElementById("pipeline");
79                var surveysList = document.getElementById("surveysList");
[67]80                                       
[66]81                var entry = document.createElement("option");
82                entry.setAttribute("value", surveys[surveysList.selectedIndex].id);
[67]83                entry.style.backgroundColor = "#88c5e4";
[66]84                entry.innerHTML = surveys[surveysList.selectedIndex].title;
[67]85                               
86                pipeline.appendChild(entry);
87            }
88                   
89            function addDashboard() {
90                var pipeline = document.getElementById("pipeline");
[66]91                       
[67]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                       
[66]99                pipeline.appendChild(entry);
[64]100            }
[67]101                                                                                                                                                   
[64]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        ?>
[65]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>
[64]136        </div>
[65]137        <div id="surveysApplicationsWrapper">
138            <div id="surveysForPipelineWrapper">
139                <h2 class="pipelineHead">Surveys</h2>
[66]140                <?php
141                $this->surveysSelect();
142                $this->addSurveyToPipelineButton()
143                ?>
[65]144            </div>
145            <div id="applicationsForPipelineWrapper">
146                <h2 class="pipelineHead">Applications</h2>
[66]147                <?php
148                $this->applicationsSelect();
149                $this->addApplicationToPipelineButton();
150                ?>
[65]151            </div>
152        </div>
153        <?php
154    }
155
156    private function pipelineSelect() {
157        ?>
[67]158        <select id="pipeline" size="1000">
[65]159
160        </select>
161        <?php
162    }
163
164    private function surveysSelect() {
165        ?>
[66]166        <select id="surveysList" size="5" class="width100p">
[64]167            <?php
[65]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>
[64]177        <?php
178    }
179
[65]180    private function applicationsSelect() {
181        ?>
[67]182        <select id="applicationsList" size="5" class="width100p">
[65]183        </select>
184        <?php
185    }
186
[64]187    private function addSurveyToPipelineButton() {
188        ?>
[66]189        <input type="button" id="surveyToPipeline" class="surveyButton pipelineButton leftAlign leftPadding1" value="<=====" onclick="addSurvey()"/>
[64]190        <?php
191    }
192
193    private function addApplicationToPipelineButton() {
194        ?>
[66]195        <input type="button" class="surveyButton pipelineButton leftAlign leftPadding1" value="<=====" />
[64]196        <?php
197    }
198
199    private function addDashboardToPipelineButton() {
200        ?>
[67]201        <input type="button" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Dashboard" onclick="addDashboard()"/>
[64]202        <?php
203    }
204
205    private function makeSessionButton() {
206        ?>
207        <input type="submit" id="makeSessionButton" class="surveyButton" value="Make session" />
208        <?php
209    }
210
[58]211}
212?>
Note: See TracBrowser for help on using the repository browser.