Mercurial > hg > extraction-interface
annotate classes/basecontroller.php @ 90:94ad33739fa4 extractapp
modify the position of buttons in sidebar
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 12 Jun 2015 14:41:30 +0200 |
parents | f1f849d31272 |
children | 7d6a107c37da |
rev | line source |
---|---|
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1 <?php |
81 | 2 /* basecontroller.php |
3 * This file is part of Extraction-interface. | |
4 * | |
5 * Extraction-interface is free software: you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation, either version 3 of the License, or | |
8 * (at your option) any later version. | |
9 * | |
10 * Extraction-interface is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with Extraction-interface. If not, see <http://www.gnu.org/licenses/>. | |
17 */ | |
18 | |
77
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
19 /** |
81 | 20 * A controller can send commands to the model to process or update the model's state. |
21 * It can also pass the commands or data (from model) to the associated view to change the view's presentation. | |
22 * | |
23 * An instance of the BaseController class can't be created directly. | |
24 * It can only be extended/inherited by other classes. | |
25 * For example in controllers/ folder, Extractapp is extended from the BaseController. | |
26 * An instance of Extractapp can be created directly. | |
27 * | |
77
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
28 */ |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
29 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
30 abstract class BaseController { |
77
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
31 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
32 protected $urlvalues; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
33 protected $action; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
34 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
35 public function __construct($action, $urlvalues, $postdata) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
36 $this->action = $action; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
37 $this->urlvalues = $urlvalues; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
38 $this->postdata = $postdata; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
39 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
40 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
41 public function ExecuteAction() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
42 return $this->{$this->action}(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
43 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
44 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
45 protected function ReturnView($viewmodel, $fullview) { |
77
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
46 /** |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
47 * Return the corresponding view in the views folder. |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
48 * We use the same class name as the folder's name and action name as the file's name in the folder hierarchy. |
81 | 49 * In this design, we can query the corresponding views php code by defining controller and action in url. |
77
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
50 * |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
51 * If you also require the maintemplate.php, which now only contains scripts that need to be inclued, set $fullview to be true; |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
52 * otherwise, the maintemplate.php will not be applied. |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
53 */ |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
54 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
55 $viewloc = 'views/' . get_class($this) . '/' . $this->action . '.php'; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
56 if ($fullview) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
57 require('views/maintemplate.php'); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
58 require($viewloc); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
59 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
60 require($viewloc); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
61 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
62 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
63 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
64 protected function ReturnView_localtest($viewmodel, $fullview) { |
77
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
65 /** Return the corresponding view in the views folder. |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
66 * |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
67 * This is only been used when developing on local machine. |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
68 */ |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
69 $viewloc = 'views/' . get_class($this) . '/' . $this->action . '.php'; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
70 if ($fullview) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
71 require('views/maintemplate_local.php'); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
72 require($viewloc); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
73 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
74 require($viewloc); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
75 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
76 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
77 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
78 ?> |