1 | <?php |
---|
2 | /* |
---|
3 | * To change this template, choose Tools | Templates |
---|
4 | * and open the template in the editor. |
---|
5 | */ |
---|
6 | |
---|
7 | /** |
---|
8 | * Description of ApplicationCreationTool |
---|
9 | * |
---|
10 | * @author fpvanagthoven |
---|
11 | */ |
---|
12 | class ApplicationCreationTool { |
---|
13 | |
---|
14 | private $application; |
---|
15 | |
---|
16 | public function __construct($application = null) { |
---|
17 | $this->application = $application; |
---|
18 | |
---|
19 | $this->javascript(); |
---|
20 | |
---|
21 | $this->init(); |
---|
22 | } |
---|
23 | |
---|
24 | private function javascript() { |
---|
25 | ?> |
---|
26 | <script type="text/javascript" src="js/creation.js"></script> |
---|
27 | <script language="JavaScript" type="text/javascript"> |
---|
28 | function save(id){ |
---|
29 | var form = document.getElementById('applicationCreationForm'); |
---|
30 | var applicationUID = id; |
---|
31 | |
---|
32 | var applicationIDInput = document.createElement('input'); |
---|
33 | applicationIDInput.name = 'applicationUID'; |
---|
34 | applicationIDInput.value = applicationUID; |
---|
35 | applicationIDInput.type = 'hidden'; |
---|
36 | |
---|
37 | form.appendChild(applicationIDInput); |
---|
38 | |
---|
39 | form.submit(); |
---|
40 | } |
---|
41 | </script> |
---|
42 | <?php |
---|
43 | } |
---|
44 | |
---|
45 | private function init() { |
---|
46 | ?> |
---|
47 | <div class="creation"> |
---|
48 | <form id="applicationCreationForm" action="" method="post"> |
---|
49 | <?php |
---|
50 | $this->title(); |
---|
51 | $this->description(); |
---|
52 | |
---|
53 | $this->save(); |
---|
54 | ?> |
---|
55 | </form> |
---|
56 | </div> |
---|
57 | <?php |
---|
58 | } |
---|
59 | |
---|
60 | private function title() { |
---|
61 | if (isset($this->application->title)) |
---|
62 | $value = $this->application->title; |
---|
63 | else |
---|
64 | $value = 'Untitled Application'; |
---|
65 | ?> |
---|
66 | <input type="text" id="applicationTitle" class="titleBox" name="applicationTitle" value="<?php echo str_replace("\"", """, $value); ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" /> |
---|
67 | <?php |
---|
68 | } |
---|
69 | |
---|
70 | private function description() { |
---|
71 | if (isset($this->application->description)) |
---|
72 | $value = $this->application->description; |
---|
73 | else |
---|
74 | $value = 'Write a description for this application here.'; |
---|
75 | ?> |
---|
76 | <textarea id="applicationDescription" class="descriptionBox" name="applicationDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea> |
---|
77 | <?php |
---|
78 | } |
---|
79 | |
---|
80 | private function save() { |
---|
81 | if (isset($this->application)) { |
---|
82 | $id = $this->application->id; |
---|
83 | } else { |
---|
84 | $id = null; |
---|
85 | } |
---|
86 | ?> |
---|
87 | <input type="button" onclick="save('<?php echo $id; ?>')" class="surveyButton topRight" value="Save" /> |
---|
88 | <?php |
---|
89 | } |
---|
90 | |
---|
91 | } |
---|
92 | ?> |
---|