3 /* *************************************************************************
5 * phpfspot, presents your F-Spot photo collection in Web browsers.
7 * Copyright (c) by Andreas Unterkircher
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
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.
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.
23 * *************************************************************************/
25 require_once "phpfspot.class.php";
30 * handles AJAX-RPC calls from client browsers
36 * PHPFSPOT_RPC constructor
38 public function __construct()
40 /* start PHP session */
45 public function process_ajax_request()
47 require_once 'HTML/AJAX/Server.php';
49 $server = new HTML_AJAX_Server();
50 $server->handleRequest();
52 $phpfspot = new PHPFSPOT();
54 /* if no action is specified, no need to further process this
57 if(!isset($_GET['action']) && !isset($_POST['action']))
60 if(isset($_GET['action']))
61 $action = $_GET['action'];
62 if(isset($_POST['action']))
63 $action = $_POST['action'];
67 if(isset($_GET['id']) && is_numeric($_GET['id'])) {
68 print $phpfspot->showPhoto($_GET['id']);
73 print $phpfspot->get_xml_tag_list();
76 case 'show_available_tags':
77 print $phpfspot->getAvailableTags();
80 case 'show_selected_tags':
81 print $phpfspot->getSelectedTags();
85 if(isset($_POST['id']) && is_numeric($_POST['id'])) {
86 print $phpfspot->addTag($_POST['id']);
91 if(isset($_POST['id']) && is_numeric($_POST['id'])) {
92 print $phpfspot->delTag($_POST['id']);
97 $phpfspot->resetTagSearch();
98 $phpfspot->resetNameSearch();
99 $phpfspot->resetTags();
100 $phpfspot->resetDateSearch();
101 $phpfspot->resetPhotoView();
105 if(isset($_POST['mode']) && in_array($_POST['mode'], Array('or', 'and'))) {
106 print $phpfspot->setTagCondition($_POST['mode']);
110 case 'show_photo_index':
111 if(isset($_GET['begin_with']) && is_numeric($_GET['begin_with'])) {
112 $_SESSION['begin_with'] = $_GET['begin_with'];
115 unset($_SESSION['begin_with']);
117 if(isset($_GET['last_photo']) && is_numeric($_GET['last_photo']))
118 $_SESSION['last_photo'] = $_GET['last_photo'];
120 print $phpfspot->showPhotoIndex();
124 $phpfspot->showCredits();
128 print $phpfspot->startSearch();
131 case 'update_sort_order':
132 if(isset($_POST['value']) && is_string($_POST['value'])) {
133 print $phpfspot->updateSortOrder($_POST['value']);
138 /* $_GET['mode'] will be validated by getExport() */
139 $phpfspot->getExport($_GET['mode']);
142 case 'get_photo_to_show':
143 $phpfspot->getCurrentPhoto();
146 case 'get_calendar_matrix':
147 if((is_numeric($_GET['year']) || !isset($_GET['year'])) &&
148 (is_numeric($_GET['month']) || !isset($_GET['month'])) &&
149 (is_numeric($_GET['day']) || !isset($_GET['day']))) {
150 $phpfspot->get_calendar_matrix($_GET['year'], $_GET['month'], $_GET['day']);
155 print $phpfspot->whatToDo();
158 case 'reset_slideshow':
159 print $phpfspot->resetSlideShow();
162 case 'get_next_slideshow_img':
163 print $phpfspot->getNextSlideShowImage();
166 case 'get_prev_slideshow_img':
167 print $phpfspot->getPrevSlideShowImage();
172 } // process_ajax_request();
174 } // class PHPFSPOT_RPC
176 $rpc = new PHPFSPOT_RPC();
177 $rpc->process_ajax_request();