~jwh376/helioviewer.org/jonathan-dev

« back to all changes in this revision

Viewing changes to api/modules/WebClient.php

  • Committer: Jonathan Harper
  • Date: 2010-01-26 14:54:51 UTC
  • Revision ID: jharper@tethys-20100126145451-6wsu3up13znkofje
Compatibility fixed for the API refactoring.
Events module to handle features and events.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
    public function __construct($params)
10
10
    {
11
 
        require_once("Base.php");
12
 
        require_once("Config.php");
13
 
        new Config("../settings/Config.ini");
 
11
        require_once("Helper.php");
14
12
        $this->params = $params;
15
13
 
 
14
 
 
15
        $this->execute();
 
16
 
 
17
    }
 
18
 
 
19
    public function execute()
 
20
    {
16
21
        if($this->validate())
17
22
        {
18
 
            $this->execute();
 
23
            $this->{$this->params['action']}();
19
24
        }
20
 
 
21
 
    }
22
 
 
23
 
    public function execute()
24
 
    {
25
 
        $this->{$this->params['action']}();
26
25
    }
27
26
 
28
27
    public function validate()
33
32
                Helper::checkForMissingParams(array('url'), $this->params);
34
33
                break;
35
34
            case "getClosestImage":
 
35
                if ($this->params['server'] === 'api/index.php') {
 
36
                //    Helper::checkForMissingParams(array('server', 'observatory', 'instrument', 'detector', 'measurement'), $this->params);
 
37
                }
 
38
                else
 
39
                {
 
40
                    Helper::checkForMissingParams(array('sourceId', 'date'), $this->params);
 
41
                }
 
42
                break;
 
43
            case "getDataSources":
 
44
                break;
 
45
            case "getTile":
 
46
                //Note: disabled because of a bug in checkForMissingParams when x=0
 
47
                //Helper::checkForMissingParams(array('uri', 'x', 'y', 'zoom', 'ts', 'jp2Width', 'jp2Height', 'jp2Scale',
 
48
                //                                    'offsetX', 'offsetY', 'format', 'obs', 'inst', 'det', 'meas'), $this->params);
 
49
                break;
 
50
            case "getJP2Header":
 
51
                break;
 
52
            case "getViewerImage":
 
53
                break;
 
54
            case "formatLayerString":
36
55
                break;
37
56
            default:
38
57
                throw new Exception("Invalid action specified. See the <a href='http://www.helioviewer.org/api/'>API Documentation</a> for a list of valid actions.");
39
58
        }
40
 
        $this->execute();
 
59
        return true;
41
60
    }
42
61
 
43
62
    public static function printDoc()
87
106
    {
88
107
        // TILE_SERVER_1
89
108
        if ($this->params['server'] === 'api/index.php') {
90
 
            require_once('ImgIndex.php');
 
109
            require_once('lib/ImgIndex.php');
 
110
            require_once('lib/DbConnection.php');
91
111
            $imgIndex = new ImgIndex(new DbConnection());
92
112
 
93
113
            // Search by source id
101
121
                $result = $imgIndex->getClosestImage($this->params['date'], $parameters);
102
122
            }
103
123
 
104
 
            if ($this->format == "json")
 
124
            //if ($this->format == "json")
105
125
            header('Content-type: application/json');
106
126
 
107
127
            echo json_encode($result);
125
145
     */
126
146
    private function getDataSources ()
127
147
    {
128
 
        require('lib/ImgIndex.php');
 
148
        require_once('lib/ImgIndex.php');
 
149
        require_once('lib/DbConnection.php');
129
150
 
130
151
        // NOTE: Make sure to remove database specification after testing completed!
131
152
        $imgIndex = new ImgIndex(new DbConnection($dbname = "helioviewer"));
132
153
        $dataSources = json_encode($imgIndex->getDataSources());
133
154
 
134
 
        if ($this->format == "json")
135
 
            header('Content-type: application/json');
 
155
        header('Content-type: application/json');
136
156
 
137
157
        print $dataSources;
138
158
 
178
198
     */
179
199
    private function getTile ()
180
200
    {
181
 
        require_once("HelioviewerTile.php");
 
201
        require_once("lib/HelioviewerTile.php");
182
202
        $tile = new HelioviewerTile($this->params['uri'], $this->params['x'], $this->params['y'], $this->params['zoom'], $this->params['ts'],
183
203
        $this->params['jp2Width'], $this->params['jp2Height'], $this->params['jp2Scale'], $this->params['offsetX'], $this->params['offsetY'],
184
204
        $this->params['format'],  $this->params['obs'], $this->params['inst'], $this->params['det'], $this->params['meas']);
191
211
     */
192
212
    private function launchJHelioviewer ()
193
213
    {
194
 
        require_once('lib/helioviewer/JHV.php');
 
214
        require_once('lib/JHV.php');
195
215
        if ((isset($this->params['files'])) && ($this->params['files'] != "")) {
196
216
            $jhv = new JHV($this->params['files']);
197
217
        } else {
236
256
     */
237
257
    private function takeScreenshot()
238
258
    {
239
 
        require_once('Screenshot.php');
 
259
        require_once('lib/Screenshot.php');
240
260
 
241
261
        $obsDate   = $this->params['obsDate'];
242
262
        $zoomLevel = $this->params['zoomLevel'];