pear mdb2 is not used anywhere here
[phpfspot.git] / rpc.php
1 <?php
2
3 /* *************************************************************************
4  *
5  * Copyright (c) by Andreas Unterkircher, unki@netshadow.at
6  * All rights reserved
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  * *************************************************************************/
23
24 require_once "phpfspot.class.php";
25
26 class PHPFSPOT_RPC {
27
28    public function __construct()
29    {
30       session_start();
31
32    } // __construct()
33
34    function process_ajax_request()
35    {
36       require_once 'HTML/AJAX/Server.php';
37
38       $server = new HTML_AJAX_Server();
39       $server->handleRequest();
40
41       $fspot = new PHPFSPOT();
42
43       switch($_GET['action']) {
44          case 'showphoto':
45             if(isset($_GET['id']) && is_numeric($_GET['id'])) {
46                $fspot->showPhoto($_GET['id']);
47             }
48             break;
49    
50          case 'show_available_tags':
51             $fspot->getAvailableTags();
52             break;
53
54          case 'show_selected_tags':
55             $fspot->getSelectedTags();
56             break;
57
58          case 'addtag':
59             if(isset($_GET['id']) && is_numeric($_GET['id'])) {
60                $fspot->addTag($_GET['id']);
61             }
62             break;
63
64          case 'deltag':
65             if(isset($_GET['id']) && is_numeric($_GET['id'])) {
66                $fspot->delTag($_GET['id']);
67             }
68             break;
69
70          case 'reset':
71             $fspot->resetTagSearch();
72             $fspot->resetTags();
73             $fspot->resetDateSearch();
74             $fspot->resetPhotoView();
75             break;
76
77          case 'tagcondition':
78             if(isset($_GET['mode']) && in_array($_GET['mode'], Array('or', 'and'))) {
79                $fspot->setTagCondition($_GET['mode']);
80             }
81             break;
82
83          case 'show_photo_index':
84             if(isset($_GET['begin_with']) && is_numeric($_GET['begin_with'])) {
85                $_SESSION['begin_with'] = $_GET['begin_with'];
86             }
87             else {
88                unset($_SESSION['begin_with']);
89             }
90             $fspot->showPhotoIndex();
91             break;
92    
93          case 'showcredits':
94             $fspot->showCredits();
95             break;
96
97          case 'search':
98             $fspot->startSearch($_GET['for'], $_GET['from'], $_GET['to'], $_GET['sort_order']);
99             break;
100
101          case 'get_export':
102             $fspot->getExport($_GET['mode']);
103             break;
104
105          case 'get_photo_to_show':
106             $fspot->getCurrentPhoto();
107             break;
108
109          case 'get_calendar_matrix':
110             $fspot->get_calendar_matrix($_GET['year'], $_GET['month'], $_GET['day']);
111             break;
112
113          case 'what_to_do':
114             print $fspot->whatToDo();
115             break;
116
117          case 'reset_slideshow':
118             print $fspot->resetSlideShow();
119             break;
120
121          case 'get_next_slideshow_img':
122             print $fspot->getNextSlideShowImage();
123             break;
124          
125          case 'get_prev_slideshow_img':
126             print $fspot->getPrevSlideShowImage();
127             break;
128
129       }
130
131    } // process_ajax_request();
132
133 }
134
135 $rpc = new PHPFSPOT_RPC();
136 $rpc->process_ajax_request();
137
138 ?>