3 /* *************************************************************************
5 * Copyright (c) by Andreas Unterkircher, unki@netshadow.at
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
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.
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.
22 * *************************************************************************/
24 require_once "phpfspot.class.php";
28 public function __construct()
34 public function process_ajax_request()
36 require_once 'HTML/AJAX/Server.php';
38 $server = new HTML_AJAX_Server();
39 $server->handleRequest();
41 $fspot = new PHPFSPOT();
43 /* if no action is specified, no need to further process this
46 if(!isset($_GET['action']) && !isset($_POST['action']))
49 if(isset($_GET['action']))
50 $action = $_GET['action'];
51 if(isset($_POST['action']))
52 $action = $_POST['action'];
56 if(isset($_GET['id']) && is_numeric($_GET['id'])) {
57 $fspot->showPhoto($_GET['id']);
61 case 'show_available_tags':
62 print $fspot->getAvailableTags();
65 case 'show_selected_tags':
66 print $fspot->getSelectedTags();
70 if(isset($_POST['id']) && is_numeric($_POST['id'])) {
71 print $fspot->addTag($_POST['id']);
76 if(isset($_POST['id']) && is_numeric($_POST['id'])) {
77 print $fspot->delTag($_POST['id']);
82 $fspot->resetTagSearch();
83 $fspot->resetNameSearch();
85 $fspot->resetDateSearch();
86 $fspot->resetPhotoView();
90 if(isset($_POST['mode']) && in_array($_POST['mode'], Array('or', 'and'))) {
91 print $fspot->setTagCondition($_POST['mode']);
95 case 'show_photo_index':
96 if(isset($_GET['begin_with']) && is_numeric($_GET['begin_with'])) {
97 $_SESSION['begin_with'] = $_GET['begin_with'];
100 unset($_SESSION['begin_with']);
102 if(isset($_GET['last_photo']) && is_numeric($_GET['last_photo']))
103 $_SESSION['last_photo'] = $_GET['last_photo'];
105 $fspot->showPhotoIndex();
109 $fspot->showCredits();
113 print $fspot->startSearch();
116 case 'update_sort_order':
117 if(isset($_POST['value']) && is_string($_POST['value'])) {
118 print $fspot->updateSortOrder($_POST['value']);
123 /* $_GET['mode'] will be validated by getExport() */
124 $fspot->getExport($_GET['mode']);
127 case 'get_photo_to_show':
128 $fspot->getCurrentPhoto();
131 case 'get_calendar_matrix':
132 if((is_numeric($_GET['year']) || !isset($_GET['year'])) &&
133 (is_numeric($_GET['month']) || !isset($_GET['month'])) &&
134 (is_numeric($_GET['day']) || !isset($_GET['day']))) {
135 $fspot->get_calendar_matrix($_GET['year'], $_GET['month'], $_GET['day']);
140 print $fspot->whatToDo();
143 case 'reset_slideshow':
144 print $fspot->resetSlideShow();
147 case 'get_next_slideshow_img':
148 print $fspot->getNextSlideShowImage();
151 case 'get_prev_slideshow_img':
152 print $fspot->getPrevSlideShowImage();
157 } // process_ajax_request();
159 } // class PHPFSPOT_RPC
161 $rpc = new PHPFSPOT_RPC();
162 $rpc->process_ajax_request();