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

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

Register correct stylesheet. SessionCreationTool? adjusted.

File size: 6.8 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();
[65]44                                                                                                                   
[64]45            init();
[65]46                                                                                                                               
[64]47            function init() {
48                loadSurveys();
49                loadApplications();
50            }
[65]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            }
[65]64                                                                                                                   
[64]65            function loadApplications() {
[65]66                                                                                                                       
[64]67            }
[65]68                                                                                                                   
[64]69            function Survey(title, id)
70            {
71                this.title = title;
72                this.id = id;
73            }
[65]74                                                                                                                   
[64]75            // =============================================================
[65]76                                                                                                                   
[64]77            function addSurvey() {
78                var surveyList = document.createElement("select");
[65]79                surveyList.size = 1000;
80                surveyList.style.height = "10em";
81                surveyList.style.width = "15em";
82                                               
[64]83                for (var i = 0; i < surveys.length; i++)
84                {
85                    var option = document.createElement("option");
86                    option.setAttribute("value", surveys[i].id);
87                    option.innerHTML = surveys[i].title;
88                    surveyList.appendChild(option);
89                }
[65]90
91                                               
92
[64]93                var sessionCreation = document.getElementById("sessionCreationForm");
94                var pipelineOptions = document.getElementById("pipelineOptions");
[65]95                                                                                                                       
[64]96                sessionCreation.replaceChild(surveyList, pipelineOptions);
97            }
[65]98                                                                                                                           
[64]99        </script>
100        <?php
101    }
102
103    private function title() {
104        if (isset($this->session->title))
105            $value = $this->session->title;
106        else
107            $value = 'Untitled Session';
108        ?>
109        <input type="text" id="sessionTitle" class="titleBox" name="sessionTitle" value="<?php echo $value; ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
110        <?php
111    }
112
113    private function description() {
114        if (isset($this->session->description))
115            $value = $this->session->description;
116        else
117            $value = 'Write a description for this session here.';
118        ?>
119        <textarea id="sessionDescription" class="descriptionBox" name="sessionDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea>
120        <?php
121    }
122
123    private function pipeline() {
124        ?>
[65]125        <div id="pipelineWrapper">
126            <h2 class="pipelineHead">Pipeline</h2>
127            <?php $this->pipelineSelect(); ?>
128            <div id="pipelineOptions">
129                <?php
130                $this->addDashboardToPipelineButton();
131                ?>
132            </div>
[64]133        </div>
[65]134        <div id="surveysApplicationsWrapper">
135            <div id="surveysForPipelineWrapper">
136                <h2 class="pipelineHead">Surveys</h2>
137                <?php $this->surveysSelect(); ?>
138            </div>
139            <div id="applicationsForPipelineWrapper">
140                <h2 class="pipelineHead">Applications</h2>
141                <?php $this->applicationsSelect(); ?>
142            </div>
143        </div>
144        <?php
145    }
146
147    private function pipelineSelect() {
148        ?>
149        <select id="pipeline" size="5">
150
151        </select>
152        <?php
153    }
154
155    private function surveysSelect() {
156        ?>
157        <select size="5" class="width100p">
[64]158            <?php
[65]159            foreach ($this->surveys as $survey) {
160                ?>
161                <option value="<?php echo $survey->id; ?>">
162                    <?php echo $survey->title; ?>
163                </option>
164                <?php
165            }
166            ?>
167        </select>
[64]168        <?php
169    }
170
[65]171    private function applicationsSelect() {
172        ?>
173        <select size="5" class="width100p">
174        </select>
175        <?php
176    }
177
[64]178    private function addSurveyToPipelineButton() {
179        ?>
[65]180        <input type="button" id="surveyToPipeline" class="surveyButton pipelineButton leftAlign leftPadding1" value="+ Survey" onclick="addSurvey()"/>
[64]181        <?php
182    }
183
184    private function addApplicationToPipelineButton() {
185        ?>
[65]186        <input type="button" class="surveyButton pipelineButton leftAlign leftPadding1" value="+ Application" />
[64]187        <?php
188    }
189
190    private function addDashboardToPipelineButton() {
191        ?>
192        <input type="button" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Dashboard" />
193        <?php
194    }
195
196    private function makeSessionButton() {
197        ?>
198        <input type="submit" id="makeSessionButton" class="surveyButton" value="Make session" />
199        <?php
200    }
201
[58]202}
203?>
Note: See TracBrowser for help on using the repository browser.