Changeset 146


Ignore:
Timestamp:
11/07/11 14:41:16 (13 years ago)
Author:
fpvanagthoven
Message:

Merged step/displaystep class functionality, division is unnecessary.
Added some javascript to manipulate editor objects in sequencerScripts.js

Location:
Dev/trunk
Files:
3 added
5 edited

Legend:

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

    r144 r146  
    4545        //output a display object
    4646        //echo '<div class="displayStep"><div class="displayStepIcon" style="background-image: url('.$this->imageURL.');"></div>'.$this->caption.'</div>'."\n";
    47         echo '<div class="displayStep"><div class="displayStepIcon"><img src="' . $this->imageURL . '" /></div>' . $this->caption . '</div>';
     47        echo '<div class="displayStep" onClick="checkSelectedStep('.$this->id.');"><div class="displayStepIcon"><img src="' . $this->imageURL . '" /></div>' . $this->caption . '</div>';
    4848    }
    4949
  • Dev/trunk/classes/Step.php

    r144 r146  
    1717    public $name;
    1818    public $id;
     19    // merging step and displayStep
     20
     21    public $imageURL;
    1922
    2023    public function __construct($t, $n, $i) {
    2124
    2225        if (strtolower($t) == "application" || strtolower($t) == "dashboard" || strtolower($t) == "questionnaire") {
     26            $this->type = $t;
    2327            $this->name = $n;
    24             $this->type = $t;
    2528            $this->id = $i;
     29        } else {
     30            die("Invalid type given: " . $t . "\n $n $i");
    2631        }
    27         else {
    28             die("Invalid type given: ".$t."\n $n $i");
     32
     33        switch (strtolower($this->type)) {
     34            case "questionnaire":
     35                $this->imageURL = "images/icons/questionnaire.png";
     36                break;
     37            case "dashboard":
     38                $this->imageURL = "images/icons/dashboard.png";
     39                break;
     40            case "application":
     41                $this->imageURL = "images/icons/application.png";
     42                break;
     43            default:
     44                $this->imageURL = "images/icons/unknowntype.png";
     45                break;
    2946        }
     47    }
     48
     49    public function AdjustID($offset) {
     50        $this->id += $offset;
     51    }
     52
     53    public function DrawStep() {
     54        if (isset($this->type) && isset($this->imageURL) && isset($this->name)) {
     55            ?>
     56<div class="displayStep" onClick="checkSelectedStep('<?php echo $this->id; ?>');"><div class="displayStepIcon"><img src="<?php echo $this->imageURL; ?>" /></div><?php echo $this->name; ?></div>
     57<?php       
     58}
    3059    }
    3160
  • Dev/trunk/classes/pipelineSequencer.php

    r144 r146  
    1010 * @author HP
    1111 */
    12 class pipelineSequencer {
     12class PipelineSequencer {
    1313
    1414    // properties
    15     private $steps;
    16     private $title = "testSequencer";
    17     private $id = 1;
     15    private $pipeline = array();
     16    private $name = "testSequencer";
    1817    private $numStepsInArray = 0;
    19     private $maxNumStepsInArray = 8;
     18    private $maxNumStepsInArray = 10;
    2019    private $selectedStep;
    2120
    22     public function __construct($steps) {
    23         $this->steps = $steps;
    24         $this->selectedStep = $this->steps[2];
     21    public function __construct($pipeline, $name, $id) {
     22        $this->pipeline = $pipeline;
     23        $this->name = $name;
     24    }
    2525
    26         $this->moveStep(1);
    27 
    28 //        echo '<br /><fieldset id="sequencer">'."\n\n";
    29 //        echo '<div class="title">Name: '.$this->title.'</div>';
    30 //        echo '<div class="seqContent">'."\n\n";
    31 //        echo '';
    32 //        echo '</div>';
    33 //        echo '</fieldset>';
     26    public function DrawSequencer() {
    3427        ?>
    3528        <br /><form name="sequencer" action="pipelineEditor.php" method="post"><fieldset id="sequencer">
    36                 <div class="title">Name: <?php echo $this->title; ?> </div>
     29                <div class="title">Name: <?php echo $this->name; ?> </div>
    3730
    3831                <div class="seqContent">
    39                     <?php $this->drawSteps(); ?>         
     32                    <?php $this->DrawSteps(); ?>         
    4033                </div>
    4134
     
    4538                    <input type="submit" name="editSelected" value="Edit step" class="surveyButton" />
    4639                    <input type="submit" name="deleteSelected" value="Delete step" class="surveyButton" />
    47                     <input type="submit" name="clearPipeline" value="Clear pipeline" class="" disabled="true" />
    48                     <input type="checkbox" name="confirmClear" />Really clear?
     40                    <input type="submit" name="clearPipeline" value="Clear pipeline" class="surveyButton dis" disabled="true"/>
     41                    <input type="checkbox" name="confirmClear" onChange="IsCheckEnabled(this, document.sequencer.clearPipeline);" />Really clear?
    4942                    <input type="hidden" name="selectedStep" />
    5043                </div>
     
    5447    }
    5548
    56     public function AddStep($step) {
    57         $this->steps[] = $step;
     49    public function AddStep($newStep) {
     50        $n = 1;
     51        foreach ($this->pipeline as $existingStep) {
     52            if ($existingStep->name == $newStep . " $n") {
     53                $n++;
     54            }
     55        }
     56
     57        $this->pipeline[] = new Step($newStep, $newStep . " " . $n, count($this->pipeline) + 1);
     58        //var_dump($this->pipeline);
    5859        ?>
    5960        <script type="text/javascript">
     
    6566    public function RemoveStep($targetStep) {
    6667
    67         $tempArray;
    68         foreach ($this->steps as $step) {
    69             if ($step != targetStep) {
     68        $tempArray = array();
     69        $removed = false;
     70        foreach ($this->pipeline as $step) {
     71            if ($step->id != $targetStep) {
    7072                $tempArray[] = $step;
     73                if ($removed) {
     74                    $step::AdjustID(-1);
     75                }
     76            } else {
     77                $removed = true;
    7178            }
    7279        }
    73         $this->steps = $tempArray;
     80        $this->pipeline = $tempArray;
    7481    }
    7582
    76     public function GetSteps() {
    77         return $this->steps;
     83    public function GetPipeline() {
     84        return $this->pipeline;
    7885    }
    7986
    80     public function drawSteps() {
     87    public function DrawSteps() {
    8188        //draw the actual icons in the container div.
    82         foreach ($this->steps as $step) {
    83             if ($this->numStepsInArray < $this->maxNumStepsInArray) {
    84                 new DisplayStep($step->type, null, $step->name, $step->id);
    85                 $this->numStepsInArray++;
    86                 if ($this->numStepsInArray < $this->maxNumStepsInArray && $this->numStepsInArray < count($this->steps)) {
    87                     echo "<div class='divider'></div>";
     89        if (!empty($this->pipeline)) {
     90            foreach ($this->pipeline as $step) {
     91                if ($this->numStepsInArray < $this->maxNumStepsInArray) {
     92                    //var_dump($step);
     93                    $step->DrawStep();
     94                    $this->numStepsInArray++;
     95                    if ($this->numStepsInArray < $this->maxNumStepsInArray && $this->numStepsInArray < count($this->pipeline)) {
     96                        echo "<div class='divider'></div>";
     97                    }
    8898                }
    8999            }
     
    91101    }
    92102
    93     public function moveStep($direction) {
    94         $key = array_search($this->selectedStep, $this->steps);
    95         echo $key;
     103    public function MoveStep($direction) {
     104        $key = array_search($this->selectedStep, $this->pipeline);
     105        //echo $key;
    96106    }
    97107
    98     private function moveEntry(&$array, $key, $dir) {
     108    private function MoveEntry(&$array, $key, $dir) {
    99109        if ($dir == -1) {   // move up
    100110            if ($key > 0) {
     
    110120    }
    111121
     122    public function SetSelected($key) {
     123
     124        if ($key > 0 && $key < count($this->pipeline)) {
     125            $this->selectedStep = $key;
     126        }
     127    }
     128
     129    public function GetName($name) {
     130        if ($name && $name != "") {
     131            $this->name = $name;
     132        }
     133    }
     134
     135    public function GetFromDB() {
     136
     137        if (isset($_POST['destroy'])) {
     138            unset($_POST['destroy']);
     139            unset($_SESSION['currentPipeline']);
     140        }
     141
     142        if (isset($_POST['clearPipeline'])) {
     143            $this->pipeline = array();
     144            $_SESSION['currentPipeline'] = $this->pipeline;
     145        }
     146
     147        if (isset($_SESSION['currentPipeline']) && !empty($_SESSION['currentPipeline'])) {      // take pipeline from session data
     148            $this->pipeline = $_SESSION['currentPipeline'];
     149        } else {
     150            $pipeline = array();
     151        }
     152
     153        if (isset($_POST['objectToCreate'])) {      // user clicked a button in the toolbox.
     154            //$this->pipeline[] = new Step($_POST['objectToCreate'], $_POST['objectToCreate'] . " NEW", null);
     155            $this::AddStep($_POST['objectToCreate']);
     156        }
     157
     158        if (isset($_POST['deleteSelected'])) {
     159            if (isset($_POST['selectedStep'])) {
     160                $this->RemoveStep($_POST['selectedStep']);
     161            }
     162        }
     163
     164        //var_dump($_POST);
     165
     166        if (isset($_POST['selectedStep'])) {
     167            $this::SetSelected($_POST['selectedStep']);
     168        }
     169
     170        $_SESSION['currentPipeline'] = $this->pipeline;
     171    }
     172
    112173}
    113174?>
  • Dev/trunk/css/awesome.css

    r144 r146  
    260260    -moz-border-radius: 6px;
    261261    border-radius: 6px;
     262}
     263
     264
     265.surveyButton.dis {
     266    color: #666;
     267}
     268
     269.surveyButton.dis:hover {
     270    background-color: transparent;
     271    color: #666;
     272    border-color: #555;
    262273}
    263274
     
    648659
    649660.seqContent .displayStep {
    650     /*height: 140px;*/
    651661    width: 52px;
    652662    padding: 0;
     
    666676
    667677.seqContent .displayStep p{
    668     margin-top: 55px;
     678    margin-top: 5px;
    669679    font-weight: normal;
    670680    font-size: 0.875em;
     
    697707    /*width: 40%;*/
    698708    float: left;
     709    margin: 1em 2em 0 0;
    699710    /*background-image: url('../images/bg/sequencerBG.png');*/
    700711    background-image: linear-gradient(top, #B0B0B0 21%, #888888 80%);
     
    727738    margin: 0 0 5px 0;
    728739    border: 1px solid #000;
    729     border-radius: 5px;
    730     -moz-border-radius: 5px;
     740    border-radius: 6px;
     741    -moz-border-radius: 6px;
     742    cursor: pointer;
    731743}
    732744
     
    737749
    738750#toolbox .buttonIcon {
    739     margin: 0 10px 0 5px;
     751    border: none;
     752    border-radius: 6px;
     753    margin: 0 10px 0 0;
    740754    float: left;
    741755}
  • Dev/trunk/pipelineEditor.php

    r144 r146  
    22require 'classes/master.php'; //should be at top of every page
    33
     4/* if (!isset($_SESSION['user'])){
     5  redirect('index.php');
     6  } */
    47
    5 $pipeline = $_SESSION['currentPipeline'];
     8//var_dump($_POST);
    69
    7 // generate a set array of pipeline contents, in lieue of working database interface
    8 //if (isset($pipeline)){
    9 //$pipeline = array(new Step("Questionnaire", "Questionnaire 1", 1), new Step("Dashboard", "Dashboard 1", 2), new Step("Application", "Application 1", 3));
    10 //}
    11 //else {
    12     $pipeline = $_SESSION['currentPipeline'];
    13 //}
    14 
    15 if (isset($_POST['objectToCreate'])){
    16     $pipeline[] = new Step($_POST['objectToCreate'], $_POST['objectToCreate']." NEW", 4);
    17     unset($_POST);
     10if (isset($_SESSION['currentPipeline'])) {
     11    $sequencer = new PipelineSequencer($_SESSION['currentPipeline'], "Test Pipeline #1", 1);
     12} else {
     13    $sequencer = new PipelineSequencer(null, "Test Pipeline #1", 1);
    1814}
    1915
    20 $_SESSION['currentPipeline'] = $pipeline;
     16$sequencer->GetFromDB();    // doesn't actually currently get from db, uses session/post as a temporary alternative.
    2117
    22 $pipelineCount = 3;
    23 $pipelineName = "Test pipeline";
    2418
    25 $dbi = new DatabaseInterface();       //mkdir error?!?!?!
     19//$dbi = new DatabaseInterface();
    2620?>
    2721
     
    3630        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    3731        <title></title>
    38         <?php new StyleSheet("awesome"); ?>
     32<?php new StyleSheet("awesome"); ?>
    3933        <script type="text/javascript" src="js/menu.js"></script>
    4034        <script type="text/javascript" src="js/jquery.jps"></script>
    41         <script type="text/javascript" src="js/editorScripts.js"></script>
     35        <script type="text/javascript" src="js/sequencerScripts.js"></script>
    4236    </head>
    4337    <body>
    4438        <div id="header">
    45             <?php new Logo(); ?>
     39<?php new Logo(); ?>
    4640        </div>
    4741
    4842        <div id="wrapper">
    4943            <div id="content">
    50                 <?php new pipelineSequencer($pipeline); ?>
    51                 <?php new Toolbox(); ?>
     44<?php $sequencer->DrawSequencer(); ?>
     45                <?php $toolbox = new Toolbox(); ?>
    5246            </div>
    5347    </body>
Note: See TracChangeset for help on using the changeset viewer.