annotate classes/basecontroller.php @ 122:a36bb5a48af4 extractapp tip

1. remove redundancy server side code. 2. All pop up sub-windows are made with dialog component of bootstrap v3.3.2
author Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
date Thu, 28 Sep 2017 22:26:48 +0200
parents 7d6a107c37da
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
886f43b26ee2 move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1 <?php
81
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
2 /* basecontroller.php
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
3 * This file is part of Extraction-interface.
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
4 *
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
5 * Extraction-interface is free software: you can redistribute it and/or modify
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
6 * it under the terms of the GNU General Public License as published by
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
8 * (at your option) any later version.
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
9 *
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
10 * Extraction-interface is distributed in the hope that it will be useful,
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
13 * GNU General Public License for more details.
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
14 *
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
15 * You should have received a copy of the GNU General Public License
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
16 * along with Extraction-interface. If not, see <http://www.gnu.org/licenses/>.
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
17 */
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
18
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
19 /**
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
20 * A controller can send commands to the model to process or update the model's state.
81
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
21 * It can also pass the commands or data (from model) to the associated view to change the view's presentation.
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
22 *
81
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
23 * An instance of the BaseController class can't be created directly.
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
24 * It can only be extended/inherited by other classes.
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
25 * For example in controllers/ folder, Extractapp is extended from the BaseController.
81
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
26 * An instance of Extractapp can be created directly.
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
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 {
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
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;
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
34
47
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 }
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
40
47
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 }
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
44
47
886f43b26ee2 move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
45 protected function ReturnView($viewmodel, $fullview) {
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
46 /**
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
47 * Return the corresponding view in the views folder.
77
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
f1f849d31272 book_id as string
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 77
diff changeset
49 * In this design, we can query the corresponding views php code by defining controller and action in url.
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
50 *
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
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;
77
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) {
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
57 //require('views/maintemplate.php');
47
886f43b26ee2 move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
58 }
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
59
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
60 require($viewloc);
47
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 protected function ReturnView_localtest($viewmodel, $fullview) {
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
64 /** Return the corresponding view in the views folder.
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
65 *
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
66 * This is only been used when developing on local machine.
77
97c1e5102a22 New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 47
diff changeset
67 */
47
886f43b26ee2 move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
68 $viewloc = 'views/' . get_class($this) . '/' . $this->action . '.php';
886f43b26ee2 move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
69 if ($fullview) {
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
70 //require('views/maintemplate_local.php');
47
886f43b26ee2 move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
71 }
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
72
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
73 require($viewloc);
47
886f43b26ee2 move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
74 }
886f43b26ee2 move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
75 }
114
7d6a107c37da refactoring, make it more condensed.
Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
parents: 81
diff changeset
76 ?>