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