Ignore:
Timestamp:
08/02/11 11:58:29 (14 years ago)
Author:
fpvanagthoven
Message:

Start at SessionCreationTool?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/SessionCreationTool.php

    r61 r64  
    88class SessionCreationTool {
    99
    10     public function __construct() {
     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();
    1119        ?>
     20
    1221        <div class="creation">
    13             lo
     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>
    1431        </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 surveyList = document.createElement("select");
     79                surveyList.setAttribute("size", "1000");
     80                surveyList.className = "toLoad";
     81               
     82                for (var i = 0; i < surveys.length; i++)
     83                {
     84                    var option = document.createElement("option");
     85                    option.setAttribute("value", surveys[i].id);
     86                    option.innerHTML = surveys[i].title;
     87                    surveyList.appendChild(option);
     88                }
     89                                                                                       
     90                var sessionCreation = document.getElementById("sessionCreationForm");
     91                var pipelineOptions = document.getElementById("pipelineOptions");
     92                                                                                       
     93                sessionCreation.replaceChild(surveyList, pipelineOptions);
     94            }
     95                                                                                           
     96        </script>
     97        <?php
     98    }
     99
     100    private function title() {
     101        if (isset($this->session->title))
     102            $value = $this->session->title;
     103        else
     104            $value = 'Untitled Session';
     105        ?>
     106        <input type="text" id="sessionTitle" class="titleBox" name="sessionTitle" value="<?php echo $value; ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
     107        <?php
     108    }
     109
     110    private function description() {
     111        if (isset($this->session->description))
     112            $value = $this->session->description;
     113        else
     114            $value = 'Write a description for this session here.';
     115        ?>
     116        <textarea id="sessionDescription" class="descriptionBox" name="sessionDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea>
     117        <?php
     118    }
     119
     120    private function pipeline() {
     121        ?>
     122        <h2 id="pipelineHead">Pipeline</h2>
     123        <div id="pipeline" class="padding2em">
     124            <i>-Empty- </i>
     125        </div>
     126        <div id="pipelineOptions">
     127            <?php
     128            $this->addSurveyToPipelineButton();
     129            $this->addApplicationToPipelineButton();
     130            $this->addDashboardToPipelineButton();
     131            ?></div>
     132        <?php
     133    }
     134
     135    private function addSurveyToPipelineButton() {
     136        ?>
     137        <input type="button" id="surveyToPipeline" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Survey" onclick="addSurvey()"/>
     138        <?php
     139    }
     140
     141    private function addApplicationToPipelineButton() {
     142        ?>
     143        <input type="button" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Application" />
     144        <?php
     145    }
     146
     147    private function addDashboardToPipelineButton() {
     148        ?>
     149        <input type="button" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Dashboard" />
     150        <?php
     151    }
     152
     153    private function makeSessionButton() {
     154        ?>
     155        <input type="submit" id="makeSessionButton" class="surveyButton" value="Make session" />
    15156        <?php
    16157    }
Note: See TracChangeset for help on using the changeset viewer.